Hi, all.

This patch add possibility of updating not only primary email, but secondary
and old email in owner info too. Also it fix overwriting primary email by
additional emails while retrieving user info. Also it contain small changes to
icqd-threads.cpp, that fix problem, reported by Juan F. Codagnone
([EMAIL PROTECTED]) few weeks ago (licq not correctly finish login
procedure, if error "Connecting to login server failed, failing event"
occured).

SergK.
diff -urN licq/include/licq_icq.h licq-sk11/include/licq_icq.h
--- licq/include/licq_icq.h     Sat Mar 23 08:15:08 2002
+++ licq-sk11/include/licq_icq.h        Tue Apr  2 14:03:11 2002
@@ -170,6 +170,7 @@
 const unsigned short ICQ_CMDxMETA_WORKxINFOxRSP    = 0x006E; // 110
 const unsigned short ICQ_CMDxMETA_MORExINFOxRSP    = 0x0078; // 120
 const unsigned short ICQ_CMDxMETA_ABOUTxRSP        = 0x0082; // 130
+const unsigned short ICQ_CMDxMETA_EMAILxINFOxRSP   = 0x0087; // 140
 const unsigned short ICQ_CMDxMETA_SECURITYxRSP     = 0x00A0; // 160
 const unsigned short ICQ_CMDxMETA_PASSWORDxRSP     = 0x00AA; // 170
 // Meta commands (user info)
@@ -187,6 +188,7 @@
 const unsigned short ICQ_CMDxMETA_WORKxINFOxSET    = 0x03F2; // 1010
 const unsigned short ICQ_CMDxMETA_MORExINFOxSET    = 0x03FD; // 1020
 const unsigned short ICQ_CMDxMETA_ABOUTxSET        = 0x0406; // 1030
+const unsigned short ICQ_CMDxMETA_EMAILxINFOxSET   = 0x040B; // 1040
 const unsigned short ICQ_CMDxMETA_SECURITYxSET     = 0x0424; // 1060
 const unsigned short ICQ_CMDxMETA_PASSWORDxSET     = 0x042E; // 1070
 const unsigned short ICQ_CMDxMETA_REQUESTxALLxINFO = 0x04B1; // 1201
diff -urN licq/include/licq_icqd.h licq-sk11/include/licq_icqd.h
--- licq/include/licq_icqd.h    Tue Mar 19 15:06:25 2002
+++ licq-sk11/include/licq_icqd.h       Tue Apr  2 14:03:03 2002
@@ -152,6 +152,7 @@
                               const char *szFaxNumber, const char *szAddress,
                               const char *szCellularNumber, const char *szZipCode,
                               unsigned short nCountryCode, bool bHideEmail);
+  unsigned long icqSetEmailInfo(const char *szEmailSecondary, const char *szEmailOld);
   unsigned long icqSetMoreInfo(unsigned short nAge,
                            char nGender, const char *szHomepage,
                            unsigned short nBirthYear, char nBirthMonth,
diff -urN licq/include/licq_packets.h licq-sk11/include/licq_packets.h
--- licq/include/licq_packets.h Thu Mar 14 10:13:44 2002
+++ licq-sk11/include/licq_packets.h    Tue Apr  2 14:03:20 2002
@@ -503,7 +503,7 @@
 
 
 
-//-----Meta_SetGeneralInfo------------------------------------------------------
+//-----Meta_SetGeneralInfo-----------------------------------------------------
 class CPU_Meta_SetGeneralInfo : public CPU_CommonFamily
 {
 public:
@@ -538,6 +538,23 @@
   unsigned short m_nCountryCode;
   char m_nTimezone;
   char m_nHideEmail;
+
+friend class CICQDaemon;
+};
+
+
+//-----Meta_SetMoreEmailInfo---------------------------------------------------
+class CPU_Meta_SetEmailInfo : public CPU_CommonFamily
+{
+public:
+  CPU_Meta_SetEmailInfo(const char *szEmailSecondary,
+                        const char *szEmailOld);
+  virtual const unsigned short SubCommand()  { return m_nMetaCommand; }
+protected:
+  unsigned short m_nMetaCommand;
+
+  char *m_szEmailSecondary;
+  char *m_szEmailOld;
 
 friend class CICQDaemon;
 };
diff -urN licq/plugins/qt-gui/src/userinfodlg.cpp 
licq-sk11/plugins/qt-gui/src/userinfodlg.cpp
--- licq/plugins/qt-gui/src/userinfodlg.cpp     Mon Mar 25 08:05:12 2002
+++ licq-sk11/plugins/qt-gui/src/userinfodlg.cpp        Tue Apr  2 14:04:13 2002
@@ -1352,6 +1352,8 @@
   {
     i = cmbCountry->currentItem();
     cc = GetCountryByIndex(i)->nCode;
+    server->icqSetEmailInfo(codec->fromUnicode(nfoEmailSecondary->text()),
+                           codec->fromUnicode(nfoEmailOld->text()));
     icqEventTag = server->icqSetGeneralInfo(codec->fromUnicode(nfoAlias->text()),
                                             codec->fromUnicode(nfoFirstName->text()),
                                             codec->fromUnicode(nfoLastName->text()),
diff -urN licq/src/icqd-srv.cpp licq-sk11/src/icqd-srv.cpp
--- licq/src/icqd-srv.cpp       Wed Mar 20 11:33:59 2002
+++ licq-sk11/src/icqd-srv.cpp  Tue Apr  2 14:01:55 2002
@@ -227,6 +227,20 @@
   return e->EventId();
 }
 
+//-----icqSetEmailInfo---------------------------------------------------------
+unsigned long CICQDaemon::icqSetEmailInfo(
+                          const char *szEmailSecondary, const char *szEmailOld)
+{
+  CPU_Meta_SetEmailInfo *p =
+    new CPU_Meta_SetEmailInfo(szEmailSecondary, szEmailOld);
+
+  gLog.Info("%sUpdating additional E-Mail info (#%ld/#%d)...\n", L_SRVxSTR, 
+p->Sequence(), p->SubSequence());
+
+  ICQEvent *e = SendExpectEvent_Server(0, p, NULL);
+  PushExtendedEvent(e);
+  return e->EventId();
+}
+
 //-----icqSetMoreInfo----------------------------------------------------
 unsigned long CICQDaemon::icqSetMoreInfo(unsigned short nAge,
                               char nGender, const char *szHomepage,
@@ -1991,6 +2005,34 @@
                }
                else /* META_FAILURE */
                        gLog.Info("%sGeneral info not updated.\n", L_SRVxSTR);         
 
+      } else if (nSubtype == ICQ_CMDxMETA_EMAILxINFOxRSP) {
+               if (nResult == META_SUCCESS) {
+                       gLog.Info("%sAdditional E-Mail info updated.\n", L_SRVxSTR);
+                       ICQEvent *e = DoneExtendedServerEvent(nSubSequence, 
+EVENT_SUCCESS);
+                       ICQEvent *e2 = new ICQEvent(e);
+                       e2->m_nCommand = ICQ_CMDxSND_META;
+                       e2->m_nSubCommand = ICQ_CMDxMETA_EMAILxINFOxSET;
+                       CPU_Meta_SetEmailInfo *p = (CPU_Meta_SetEmailInfo 
+*)e->m_pPacket;
+                       ICQOwner *o = gUserManager.FetchOwner(LOCK_W);
+                       
+                       o->SetEnableSave(false);
+                       o->SetEmailSecondary( p->m_szEmailSecondary );
+                       o->SetEmailOld( p->m_szEmailOld );
+
+                       // translating string with Translation Table
+                       gTranslator.ServerToClient(o->GetEmailSecondary());
+                       gTranslator.ServerToClient(o->GetEmailOld());
+
+                       // save the user infomation
+                       o->SetEnableSave(true);
+                       o->SaveGeneralInfo();
+                       
+                       gUserManager.DropOwner();
+                       PushPluginEvent(e2);
+                       DoneEvent(e, EVENT_SUCCESS);
+               }
+               else /* META_FAILURE */
+                       gLog.Info("%sAdditional E-Mail info not updated.\n", 
+L_SRVxSTR);        
       } else if (nSubtype == ICQ_CMDxMETA_MORExINFOxRSP) {
                if (nResult == META_SUCCESS) {
                        gLog.Info("%sMore info updated.\n", L_SRVxSTR);
@@ -2283,12 +2325,12 @@
            for(int i = 0; i < nEmail; i++) {
                msg.UnpackChar(); // publish email, not yet implemented
                if(i == 0) {
-                   u->SetEmailPrimary( msg.UnpackString() );
-                   gTranslator.ServerToClient(u->GetEmailPrimary());
-               }
-               if(i == 1) {
                    u->SetEmailSecondary( msg.UnpackString() );
                    gTranslator.ServerToClient(u->GetEmailSecondary());
+               }
+               if(i == 1) {
+                   u->SetEmailOld( msg.UnpackString() );
+                   gTranslator.ServerToClient(u->GetEmailOld());
                }
            }
 
diff -urN licq/src/icqd-threads.cpp licq-sk11/src/icqd-threads.cpp
--- licq/src/icqd-threads.cpp   Wed Dec 12 06:02:05 2001
+++ licq-sk11/src/icqd-threads.cpp      Tue Apr  2 14:02:11 2002
@@ -51,7 +51,9 @@
     // Check again, if still -1, fail the event
     if (e->m_nSocketDesc == -1)
     {
-        gLog.Info("%sConnecting to login server failed, failing event", L_SRVxSTR);
+      gLog.Info("%sConnecting to login server failed, failing event\n", L_SRVxSTR);
+      d->m_eStatus = STATUS_OFFLINE_FORCED;
+      d->m_bLoggingOn = false;
       if (d->DoneEvent(e, EVENT_ERROR) != NULL) d->ProcessDoneEvent(e);
       pthread_exit(NULL);
     }
diff -urN licq/src/icqpacket.cpp licq-sk11/src/icqpacket.cpp
--- licq/src/icqpacket.cpp      Tue Mar 19 15:06:26 2002
+++ licq-sk11/src/icqpacket.cpp Tue Apr  2 14:01:59 2002
@@ -1623,6 +1623,37 @@
   }
 }
 
+//-----Meta_SetEmailInfo------------------------------------------------------
+CPU_Meta_SetEmailInfo::CPU_Meta_SetEmailInfo( const char *szEmailSecondary,
+                       const char *szEmailOld)
+  : CPU_CommonFamily(ICQ_SNACxFAM_VARIOUS, ICQ_SNACxMETA_INFO)
+{
+  m_nMetaCommand = 0x0B04;
+
+  int packetSize = 2+2+2+4+2+2+2 + strlen_safe(szEmailSecondary) + 3 
+                                + strlen_safe(szEmailOld) + 3 + 3;
+  m_nSize += packetSize;
+  InitBuffer();
+
+  buffer->PackUnsignedShortBE(1);
+  buffer->PackUnsignedShortBE(packetSize-2-2);                 // TLV 1
+
+  buffer->PackUnsignedShort(packetSize-2-2-2);                 // bytes remaining
+  buffer->PackUnsignedLong(gUserManager.OwnerUin());
+  buffer->PackUnsignedShortBE(0xD007);                         // type
+  buffer->PackUnsignedShortBE(m_nSubSequence);
+  buffer->PackUnsignedShortBE(0x0B04);                         // subtype
+
+  gTranslator.ClientToServer((char *) szEmailSecondary);
+  gTranslator.ClientToServer((char *) szEmailOld);
+  
+  buffer->PackChar(2);
+  buffer->PackChar(0);
+  m_szEmailSecondary = buffer->PackString(szEmailSecondary);
+  buffer->PackChar(0);
+  m_szEmailOld = buffer->PackString(szEmailOld);
+}
+
 //-----Meta_SetMoreInfo------------------------------------------------------
 CPU_Meta_SetMoreInfo::CPU_Meta_SetMoreInfo( unsigned short nAge,
                        char nGender,

Reply via email to