Changeset 6307
- Timestamp:
- 06/14/08 18:34:29 (7 months ago)
- Location:
- trunk/licq/src
- Files:
-
- 2 modified
-
icqd-tcp.cpp (modified) (3 diffs)
-
icqd-threads.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/licq/src/icqd-tcp.cpp
r6306 r6307 194 194 CICQColor *pColor) 195 195 { 196 if (_nUin == gUserManager.OwnerUin() || m == NULL) return 0; 197 198 ICQEvent *result = NULL; 199 char *mDos = NULL; 200 if (m != NULL) 201 { 202 mDos = gTranslator.NToRN(m); 203 gTranslator.ClientToServer(mDos); 204 } 205 CEventMsg *e = NULL; 206 207 unsigned long f = INT_VERSION; 208 if (online) f |= E_DIRECT; 209 if (nLevel == ICQ_TCPxMSG_URGENT) f |= E_URGENT; 210 if (bMultipleRecipients) f |= E_MULTIxREC; 211 212 ICQUser *u; 213 if (!online) // send offline 214 { 215 e = new CEventMsg(m, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, f); 216 if (strlen(mDos) > MAX_MESSAGE_SIZE) 217 { 218 gLog.Warn(tr("%sTruncating message to %d characters to send through server.\n"), 219 L_WARNxSTR, MAX_MESSAGE_SIZE); 220 mDos[MAX_MESSAGE_SIZE] = '\0'; 221 } 222 result = icqSendThroughServer(_nUin, ICQ_CMDxSUB_MSG | (bMultipleRecipients ? ICQ_CMDxSUB_FxMULTIREC : 0), 223 mDos, e); 224 u = gUserManager.FetchUser(_nUin, LOCK_W); 225 } 226 else // send direct 227 { 228 u = gUserManager.FetchUser(_nUin, LOCK_W); 229 if (u == NULL) return 0; 230 if (u->Secure()) f |= E_ENCRYPTED; 231 e = new CEventMsg(m, ICQ_CMDxTCP_START, TIME_NOW, f); 232 if (pColor != NULL) e->SetColor(pColor); 233 CPT_Message *p = new CPT_Message(mDos, nLevel, bMultipleRecipients, pColor, u); 234 gLog.Info(tr("%sSending %smessage to %s (#%hu).\n"), L_TCPxSTR, 235 nLevel == ICQ_TCPxMSG_URGENT ? tr("urgent ") : "", 236 u->GetAlias(), -p->Sequence()); 237 result = SendExpectEvent_Client(u, p, e); 238 } 239 240 if (u != NULL) 241 { 242 u->SetSendServer(!online); 243 u->SetSendLevel(nLevel); 244 gUserManager.DropUser(u); 245 } 246 247 if (pColor != NULL) CICQColor::SetDefaultColors(pColor); 248 249 if (mDos) 250 delete [] mDos; 251 252 if (result != NULL) 253 return result->EventId(); 254 return 0; 196 char szId[13]; 197 snprintf(szId, 12, "%lu", _nUin); 198 szId[12] = 0; 199 return icqSendMessage(szId, m, online, nLevel, bMultipleRecipients, pColor); 255 200 } 256 201 … … 4212 4157 { 4213 4158 if (!Handshake_Recv(s, 0)) return false; 4214 unsigned long nUin = s->Owner(); 4215 if (nUin == 0) return false; 4216 4217 ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); 4159 const char* id = s->OwnerId(); 4160 unsigned long ppid = s->OwnerPPID(); 4161 if (id == NULL) 4162 return false; 4163 4164 ICQUser *u = gUserManager.FetchUser(id, ppid, LOCK_W); 4218 4165 if (u != NULL) 4219 4166 { 4220 gLog.Info(tr("%sConnection from %s (% ld) [v%ld].\n"), L_TCPxSTR,4221 u->GetAlias(), nUin, s->Version());4167 gLog.Info(tr("%sConnection from %s (%s) [v%ld].\n"), L_TCPxSTR, 4168 u->GetAlias(), id, s->Version()); 4222 4169 if (u->SocketDesc(s->Channel()) != s->Descriptor()) 4223 4170 { 4224 4171 if (u->SocketDesc(s->Channel()) != -1) 4225 4172 { 4226 gLog.Warn(tr("%sUser %s (% ld) already has an associated socket.\n"),4227 L_WARNxSTR, u->GetAlias(), nUin);4173 gLog.Warn(tr("%sUser %s (%s) already has an associated socket.\n"), 4174 L_WARNxSTR, u->GetAlias(), id); 4228 4175 gUserManager.DropUser(u); 4229 4176 return true; … … 4237 4184 else 4238 4185 { 4239 gLog.Info(tr("%sConnection from new user (% ld) [v%ld].\n"), L_TCPxSTR,4240 nUin, s->Version());4186 gLog.Info(tr("%sConnection from new user (%s) [v%ld].\n"), L_TCPxSTR, 4187 id, s->Version()); 4241 4188 } 4242 4189 -
trunk/licq/src/icqd-threads.cpp
r6306 r6307 858 858 int err = tcp->Error(); 859 859 if (err == 0) 860 gLog.Info(tr("%sConnection to % lu was closed.\n"), L_TCPxSTR861 , tcp->Owner());860 gLog.Info(tr("%sConnection to %s was closed.\n"), L_TCPxSTR, 861 tcp->OwnerId()); 862 862 else 863 863 { 864 864 char buf[128]; 865 gLog.Info(tr("%sConnection to % lulost:\n%s%s.\n"), L_TCPxSTR,866 tcp->Owner(), L_BLANKxSTR, tcp->ErrorStr(buf, 128));865 gLog.Info(tr("%sConnection to %s lost:\n%s%s.\n"), L_TCPxSTR, 866 tcp->OwnerId(), L_BLANKxSTR, tcp->ErrorStr(buf, 128)); 867 867 } 868 868 ICQUser *u = gUserManager.FetchUser(tcp->OwnerId(), … … 900 900 if (!r) 901 901 { 902 gLog.Info(tr("%sClosing connection to % lu.\n"), L_TCPxSTR,903 tcp->Owner());902 gLog.Info(tr("%sClosing connection to %s.\n"), L_TCPxSTR, 903 tcp->OwnerId()); 904 904 gSocketManager.DropSocket(tcp); 905 905 gSocketManager.CloseSocket(nCurrentSocket);
