Show
Ignore:
Timestamp:
05/06/03 12:42:27 (6 years ago)
Author:
emostar
Message:

Sending contacts as a string (so you can send aim users to other icq users)

Location:
branches/protocol_plugin_1_3_0/licq
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/protocol_plugin_1_3_0/licq/include/licq_icqd.h

    r3482 r3495  
    139139     bool bOnline, unsigned short nLevel, bool bMultipleRecipients = false, 
    140140     CICQColor *pColor = NULL); 
    141       
     141 
    142142  unsigned long icqSendMessage(unsigned long nUin, const char *szMessage, 
    143143     bool bOnline, unsigned short nLevel, bool bMultipleRecipients = false, 
     
    148148     bool bMultipleRecipients = false, CICQColor *pColor = NULL); 
    149149  // Contact List 
     150  unsigned long icqSendContactList(const char *szId, UserStringList &users, 
     151     bool bOnline, unsigned short nLevel, bool bMultipleRecipients = false, 
     152     CICQColor *pColor = NULL); 
     153      
    150154  unsigned long icqSendContactList(unsigned long nUin, UinList &uins, 
    151155     bool bOnline, unsigned short nLevel, bool bMultipleRecipients = false, 
  • branches/protocol_plugin_1_3_0/licq/src/icqd-tcp.cpp

    r3469 r3495  
    364364 
    365365//-----CICQDaemon::sendContactList------------------------------------------- 
     366unsigned long CICQDaemon::icqSendContactList(const char *szId, 
     367   UserStringList &users, bool online, unsigned short nLevel, 
     368   bool bMultipleRecipients, CICQColor *pColor) 
     369{ 
     370  if (gUserManager.FindOwner(szId, LICQ_PPID) != NULL) return 0; 
     371 
     372  char *m = new char[3 + users.size() * 80]; 
     373  int p = sprintf(m, "%d%c", users.size(), char(0xFE)); 
     374  ContactList vc; 
     375 
     376  ICQUser *u = NULL; 
     377  UserStringList::iterator iter; 
     378  for (iter = users.begin(); iter != users.end(); iter++) 
     379  { 
     380    u = gUserManager.FetchUser(*iter, LICQ_PPID, LOCK_R); 
     381    p += sprintf(&m[p], "%s%c%s%c", *iter, char(0xFE), 
     382       u == NULL ? "" : u->GetAlias(), char(0xFE)); 
     383    vc.push_back(new CContact(*iter, LICQ_PPID, u == NULL ? "" : u->GetAlias())); 
     384    gUserManager.DropUser(u); 
     385  } 
     386 
     387  if (!online && p > MAX_MESSAGE_SIZE) 
     388  { 
     389    gLog.Warn("%sContact list too large to send through server.\n", L_WARNxSTR); 
     390    delete []m; 
     391    return 0; 
     392  } 
     393 
     394  CEventContactList *e = NULL; 
     395  ICQEvent *result = NULL; 
     396 
     397  unsigned long f = INT_VERSION; 
     398  if (online) f |= E_DIRECT; 
     399  if (nLevel == ICQ_TCPxMSG_URGENT) f |= E_URGENT; 
     400  if (bMultipleRecipients) f |= E_MULTIxREC; 
     401 
     402  if (!online) // send offline 
     403  { 
     404    e = new CEventContactList(vc, false, ICQ_CMDxSND_THRUxSERVER, TIME_NOW, f); 
     405    result = icqSendThroughServer(szId, 
     406      ICQ_CMDxSUB_CONTACTxLIST | (bMultipleRecipients ? ICQ_CMDxSUB_FxMULTIREC : 0), 
     407      m, e); 
     408    u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W); 
     409  } 
     410  else 
     411  { 
     412    u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W); 
     413    if (u == NULL) return 0; 
     414    if (u->Secure()) f |= E_ENCRYPTED; 
     415    e = new CEventContactList(vc, false, ICQ_CMDxTCP_START, TIME_NOW, f); 
     416    if (pColor != NULL) e->SetColor(pColor); 
     417    CPT_ContactList *p = new CPT_ContactList(m, nLevel, bMultipleRecipients, pColor, u); 
     418    gLog.Info("%sSending %scontact list to %s (#%ld).\n", L_TCPxSTR, 
     419       nLevel == ICQ_TCPxMSG_URGENT ? "urgent " : "", 
     420       u->GetAlias(), -p->Sequence()); 
     421    result = SendExpectEvent_Client(u, p, e); 
     422  } 
     423  if (u != NULL) 
     424  { 
     425    u->SetSendServer(!online); 
     426    u->SetSendLevel(nLevel); 
     427    gUserManager.DropUser(u); 
     428  } 
     429 
     430  if (pColor != NULL) CICQColor::SetDefaultColors(pColor); 
     431 
     432  delete []m; 
     433  if (result != NULL) 
     434    return result->EventId(); 
     435  return 0; 
     436} 
     437 
    366438unsigned long CICQDaemon::icqSendContactList(unsigned long nUin, 
    367439   UinList &uins, bool online, unsigned short nLevel, bool bMultipleRecipients, 
    368440   CICQColor *pColor) 
    369441{ 
     442  UserStringList users; 
     443  char szUin[24]; 
     444 
     445  UinList::iterator it; 
     446  for (it = uins.begin(); it != uins.end(); it++) 
     447  { 
     448    sprintf(szUin, "%lu", *it); 
     449    users.push_back(szUin); 
     450  } 
     451 
     452  sprintf(szUin, "%lu", nUin); 
     453  return icqSendContactList(szUin, users,online, nLevel, bMultipleRecipients, 
     454    pColor); 
     455#if 0 
    370456  if (nUin == gUserManager.OwnerUin()) return 0; 
    371457 
     
    432518    return result->EventId(); 
    433519  return 0; 
     520#endif 
    434521} 
    435522