Changeset 6405 for trunk/licq/src/icqd-srv.cpp
- Timestamp:
- 07/03/08 22:13:49 (5 months ago)
- Files:
-
- 1 modified
-
trunk/licq/src/icqd-srv.cpp (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/licq/src/icqd-srv.cpp
r6404 r6405 1068 1068 void CICQDaemon::icqRequestAuth(unsigned long _nUin, const char *_szMessage) 1069 1069 { 1070 CSrvPacketTcp *p = new CPU_RequestAuth(_nUin, _szMessage); 1070 char id[16]; 1071 snprintf(id, 16, "%lu", _nUin); 1072 icqRequestAuth(id, _szMessage); 1073 } 1074 1075 void CICQDaemon::icqRequestAuth(const char* id, const char *_szMessage) 1076 { 1077 CSrvPacketTcp* p = new CPU_RequestAuth(id, _szMessage); 1071 1078 SendEvent_Server(p); 1072 1079 } … … 1726 1733 unsigned long nUin) 1727 1734 { 1728 CEventSms *ue = new CEventSms(szNumber, szMessage, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, INT_VERSION); 1729 CPU_SendSms *p = new CPU_SendSms(szNumber, szMessage); 1735 char id[16]; 1736 snprintf(id, 16, "%lu", nUin); 1737 return icqSendSms(id, LICQ_PPID, szNumber, szMessage); 1738 } 1739 1740 unsigned long CICQDaemon::icqSendSms(const char* id, unsigned long ppid, 1741 const char* number, const char* message) 1742 { 1743 CEventSms* ue = new CEventSms(number, message, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, INT_VERSION); 1744 CPU_SendSms* p = new CPU_SendSms(number, message); 1730 1745 gLog.Info(tr("%sSending SMS through server (#%hu/#%d)...\n"), L_SRVxSTR, 1731 p->Sequence(), p->SubSequence());1732 ICQEvent *e = SendExpectEvent_Server(nUin, p, ue);1746 p->Sequence(), p->SubSequence()); 1747 ICQEvent* e = SendExpectEvent_Server(id, ppid, p, ue); 1733 1748 if (e != NULL) 1734 1749 return e->EventId(); … … 2171 2186 unsigned long CICQDaemon::FindUinByCellular(const char *szCellular) 2172 2187 { 2188 return strtoul(FindUserByCellular(szCellular).c_str(), NULL, 10); 2189 } 2190 2191 string CICQDaemon::FindUserByCellular(const char *szCellular) 2192 { 2173 2193 char szParsedNumber1[16], szParsedNumber2[16]; 2174 unsigned long nUin = 0;2175 2194 string id; 2195 2176 2196 FOR_EACH_USER_START(LOCK_R) 2177 2197 { … … 2179 2199 ParseDigits(szParsedNumber2, szCellular, 15); 2180 2200 if (!strcmp(szParsedNumber1, szParsedNumber2)) 2181 nUin = strtoul(pUser->IdString(), NULL, 10);2201 id = pUser->IdString(); 2182 2202 } 2183 2203 FOR_EACH_USER_END 2184 2204 2185 return nUin;2205 return id; 2186 2206 } 2187 2207 … … 3773 3793 delete [] buf; 3774 3794 //TODO 3775 CEventUnknownSysMsg *e = new CEventUnknownSysMsg(nTypeMsg, ICQ_CMDxRCV_SYSxMSGxONLINE, 3776 strtoul(szId, (char **)NULL, 10), 3777 szMessage, nTimeSent, 0); 3795 CEventUnknownSysMsg* e = new CEventUnknownSysMsg(nTypeMsg, ICQ_CMDxRCV_SYSxMSGxONLINE, 3796 szId, LICQ_PPID, szMessage, nTimeSent, 0); 3778 3797 3779 3798 ICQOwner *o = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); … … 3856 3875 CEventSms *eSms = (CEventSms *)eEvent; 3857 3876 //TODO 3858 unsigned long nUinSms = FindUinByCellular(eSms->Number());3859 3860 if (nUinSms != 0)3861 {3877 string idSms = FindUserByCellular(eSms->Number()); 3878 3879 if (!idSms.empty()) 3880 { 3862 3881 //TODO 3863 ICQUser* u = gUserManager.FetchUser(nUinSms, LOCK_W);3864 gLog.Info(tr("%sSMS from %s - %s (%lu).\n"), L_SBLANKxSTR, eSms->Number(), 3865 u->GetAlias(), nUinSms);3882 ICQUser* u = gUserManager.FetchUser(idSms.c_str(), LICQ_PPID, LOCK_W); 3883 gLog.Info(tr("%sSMS from %s - %s (%s).\n"), L_SBLANKxSTR, eSms->Number(), 3884 u->GetAlias(), idSms.c_str()); 3866 3885 if (AddUserEvent(u, eEvent)) 3867 3886 m_xOnEventManager.Do(ON_EVENT_SMS, u); … … 4753 4772 unsigned long nUin; 4754 4773 unsigned long nTimeSent; 4755 4774 4756 4775 nUin = msg.UnpackUnsignedLong(); 4776 char id[16]; 4777 snprintf(id, 16, "%lu", nUin); 4757 4778 4758 4779 sendTM.tm_year = msg.UnpackUnsignedShort() - 1900; … … 4808 4829 case ICQ_CMDxSUB_AUTHxREQUEST: 4809 4830 { 4810 gLog.Info(tr("%sOffline authorization request from %lu.\n"), L_SBLANKxSTR, nUin);4811 4831 gLog.Info(tr("%sOffline authorization request from %s.\n"), L_SBLANKxSTR, id); 4832 4812 4833 char **szFields = new char *[6]; // alias, first name, last name, email, auth, comment 4813 4834 … … 4829 4850 gTranslator.ServerToClient (szFields[5]); // comment 4830 4851 4831 CEventAuthRequest *e = new CEventAuthRequest(nUin, szFields[0], szFields[1],4832 szFields[2], szFields[3], szFields[5],4833 ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0);4834 delete [] szFields; 4852 CEventAuthRequest *e = new CEventAuthRequest(id, LICQ_PPID, 4853 szFields[0], szFields[1], szFields[2], szFields[3], 4854 szFields[5], ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0); 4855 delete [] szFields; 4835 4856 eEvent = e; 4836 4857 break; … … 4838 4859 case ICQ_CMDxSUB_AUTHxREFUSED: // system message: authorization refused 4839 4860 { 4840 gLog.Info(tr("%sOffline authorization refused by %lu.\n"), L_SBLANKxSTR, nUin);4861 gLog.Info(tr("%sOffline authorization refused by %s.\n"), L_SBLANKxSTR, id); 4841 4862 4842 4863 // Translating string with Translation Table 4843 4864 gTranslator.ServerToClient(szMessage); 4844 4865 4845 CEventAuthRefused *e = new CEventAuthRefused(nUin, szMessage, ICQ_CMDxRCV_SYSxMSGxOFFLINE,4846 nTimeSent, 0);4866 CEventAuthRefused* e = new CEventAuthRefused(id, LICQ_PPID, 4867 szMessage, ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0); 4847 4868 eEvent = e; 4848 4869 break; … … 4850 4871 case ICQ_CMDxSUB_AUTHxGRANTED: // system message: authorized 4851 4872 { 4852 gLog.Info(tr("%sOffline authorization granted by %lu.\n"), L_SBLANKxSTR, nUin);4873 gLog.Info(tr("%sOffline authorization granted by %s.\n"), L_SBLANKxSTR, id); 4853 4874 4854 4875 // translating string with Translation Table 4855 4876 gTranslator.ServerToClient (szMessage); 4856 4877 4857 ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W);4878 ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 4858 4879 if (u) 4859 4880 { … … 4862 4883 } 4863 4884 4864 CEventAuthGranted *e = new CEventAuthGranted(nUin, szMessage, ICQ_CMDxRCV_SYSxMSGxOFFLINE,4865 nTimeSent, 0);4885 CEventAuthGranted* e = new CEventAuthGranted(id, LICQ_PPID, 4886 szMessage, ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0); 4866 4887 eEvent = e; 4867 4888 break; … … 4885 4906 case ICQ_CMDxSUB_ADDEDxTOxLIST: // system message: added to a contact list 4886 4907 { 4887 gLog.Info(tr("%sUser %lu added you to their contact list (offline).\n"), L_SBLANKxSTR, nUin);4908 gLog.Info(tr("%sUser %s added you to their contact list (offline).\n"), L_SBLANKxSTR, id); 4888 4909 4889 4910 char **szFields = new char *[6]; // alias, first name, last name, email, auth, comment … … 4905 4926 gTranslator.ServerToClient (szFields[2]); // last name 4906 4927 4907 CEventAdded *e = new CEventAdded(nUin, szFields[0], szFields[1],4908 szFields[2], szFields[3],4909 ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0);4910 delete [] szFields; 4928 CEventAdded* e = new CEventAdded(id, LICQ_PPID, szFields[0], 4929 szFields[1], szFields[2], szFields[3], 4930 ICQ_CMDxRCV_SYSxMSGxOFFLINE, nTimeSent, 0); 4931 delete [] szFields; 4911 4932 eEvent = e; 4912 4933 break; … … 5010 5031 nTypeMsg, packet.print(buf)); 5011 5032 delete [] buf; 5012 CEventUnknownSysMsg *e = new CEventUnknownSysMsg(nTypeMsg, ICQ_CMDxRCV_SYSxMSGxOFFLINE,5013 nUin, szMessage, nTimeSent, 0);5033 CEventUnknownSysMsg* e = new CEventUnknownSysMsg(nTypeMsg, 5034 ICQ_CMDxRCV_SYSxMSGxOFFLINE, id, LICQ_PPID, szMessage, nTimeSent, 0); 5014 5035 5015 5036 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); … … 5026 5047 case ICQ_CMDxSUB_CONTACTxLIST: 5027 5048 { 5028 // Lock the user to add the message to their queue 5029 ICQUser* u = gUserManager.FetchUser(nUin, LOCK_W); 5030 if (u == NULL) 5031 { 5032 if (Ignore(IGNORE_NEWUSERS)) 5033 { 5034 gLog.Info(tr("%sOffline %s from new user (%lu), ignoring.\n"), L_SBLANKxSTR, szType, nUin); 5035 if (szType) free(szType); 5036 RejectEvent(nUin, eEvent); 5037 break; 5038 } 5039 gLog.Info(tr("%sOffline %s from new user (%lu).\n"), L_SBLANKxSTR, szType, nUin); 5040 AddUserToList(nUin); 5041 u = gUserManager.FetchUser(nUin, LOCK_W); 5042 } 5043 else 5044 gLog.Info(tr("%sOffline %s through server from %s (%lu).\n"), L_SBLANKxSTR, 5045 szType, u->GetAlias(), nUin); 5049 // Lock the user to add the message to their queue 5050 ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 5051 if (u == NULL) 5052 { 5053 if (Ignore(IGNORE_NEWUSERS)) 5054 { 5055 gLog.Info(tr("%sOffline %s from new user (%s), ignoring.\n"), 5056 L_SBLANKxSTR, szType, id); 5057 if (szType) free(szType); 5058 RejectEvent(id, eEvent); 5059 break; 5060 } 5061 gLog.Info(tr("%sOffline %s from new user (%s).\n"), L_SBLANKxSTR, szType, id); 5062 AddUserToList(id, LICQ_PPID); 5063 u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 5064 } 5065 else 5066 gLog.Info(tr("%sOffline %s through server from %s (%s).\n"), 5067 L_SBLANKxSTR, szType, u->GetAlias(), id); 5046 5068 5047 5069 if (szType) free(szType); … … 5059 5081 case ICQ_CMDxSUB_EMAILxPAGER: 5060 5082 { 5061 ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R);5083 ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 5062 5084 bool bIgnore = false; 5063 5085 if (u) … … 5087 5109 case ICQ_CMDxSUB_SMS: 5088 5110 { 5089 CEventSms *eSms = (CEventSms *)eEvent; 5090 unsigned long nUinSms = FindUinByCellular(eSms->Number()); 5091 5092 if (nUinSms != 0) 5093 { 5094 ICQUser* u = gUserManager.FetchUser(nUinSms, LOCK_W); 5095 gLog.Info(tr("%sOffline SMS from %s - %s (%lu).\n"), L_SBLANKxSTR, eSms->Number(), u->GetAlias(), nUin); 5111 CEventSms* eSms = (CEventSms *)eEvent; 5112 string idSms = FindUserByCellular(eSms->Number()); 5113 5114 if (!idSms.empty()) 5115 { 5116 ICQUser* u = gUserManager.FetchUser(idSms.c_str(), LICQ_PPID, LOCK_W); 5117 gLog.Info(tr("%sOffline SMS from %s - %s (%s).\n"), L_SBLANKxSTR, 5118 eSms->Number(), u->GetAlias(), id); 5096 5119 if (AddUserEvent(u, eEvent)) 5097 5120 m_xOnEventManager.Do(ON_EVENT_SMS, u); … … 5563 5586 icqRequestMetaInfo(szUin); 5564 5587 5565 e->m_pSearchAck = new CSearchAck( nUin);5588 e->m_pSearchAck = new CSearchAck(szUin, LICQ_PPID); 5566 5589 } 5567 5590 else
