-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oh yes, for all that decide to use this, you may have to edit your licq.conf 
file so that under the [groups] section, that each GroupX.name has a matching 
GroupX.id = 0  where X = 1 to NumOfGroups.

Jon

- ----------  Forwarded Message  ----------

Subject: [Licq-cvs] licq/src
Date: Sun, 05 May 2002 18:51:28 -0700
From: Jon Keating <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]

Update of /cvsroot/licq/licq/src
In directory usw-pr-cvs1:/tmp/cvs-serv31265/src

Modified Files:
        buffer.cpp icqd-srv.cpp icqd-tcp.cpp icqd.cpp icqpacket.cpp
        licq.conf.h user.cpp
Log Message:
Initial server side contact list support.

The way it works is:

Every time you log on it will retrieve the server list.
It will add groups that the server list has if they are not local.
Contacts are added from the server list.
If they are already on the list they will be be in their group that the
 server s ays they are in, as well as the local groups they are in.
If they are not already on the list they will  only be in the group that the
 ser ver says they are in.
Visibile and Invisible contacts are put in the appropriate list according to
 wha t the server says.

It needs to update new and removed users.
It needs to update new, removed, and renamed groups.

Once again this is preliminary.


Index: buffer.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/buffer.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
- --- buffer.cpp        20 Mar 2002 16:00:53 -0000      1.11
+++ buffer.cpp  6 May 2002 01:51:26 -0000       1.12
@@ -301,9 +301,22 @@

 char *CBuffer::UnpackStringBE(char* sz)
 {
- -  unsigned char nLen;
+  unsigned short nLen;
   sz[0] = '\0';
   *this >> nLen;
+  rev_e_short(nLen);
+  for (unsigned short i = 0; i < nLen; i++) *this >> sz[i];
+  sz[nLen] = '\0';
+  return sz;
+}
+
+char *CBuffer::UnpackStringBE()
+{
+  unsigned short nLen;
+  *this >> nLen;
+  rev_e_short(nLen);
+  char *sz = new char[nLen+1];
+  sz[0] = '\0';
   for (unsigned short i = 0; i < nLen; i++) *this >> sz[i];
   sz[nLen] = '\0';
   return sz;
@@ -513,11 +526,13 @@

 //-----TLV------------------------------------------------------------------
- ----

- -bool CBuffer::readTLV(int count)
+bool CBuffer::readTLV(int nCount, int nBytes)
 {
- -  if (m_pTLV || !count) return false; // already have one
+  if (m_pTLV || !nCount) return false; // already have one

   int num = 0;
+  int nCurBytes = 0;
+
   while(getDataPosRead() + 4 < (getDataStart() + getDataSize())) {
     SOscarTLV_Chain *now = new SOscarTLV_Chain;
     now->pTLV = new SOscarTLV;
@@ -525,11 +540,10 @@
     *this >> now->pTLV->nType;
     *this >> now->pTLV->nLen;

- -
     rev_e_short(now->pTLV->nType);
     rev_e_short(now->pTLV->nLen);

- -    //gLog.Info("got type %d, len: %d\n", now->pTLV->nType,
 now->pTLV->nLen); +    nCurBytes += 4 + now->pTLV->nLen;

     if(getDataPosRead() + now->pTLV->nLen > (getDataStart() + getDataSize())
 || now->pTLV->nLen < 1) {
@@ -546,8 +560,25 @@
     m_pTLV = now;

     ++num;
- -    if (count > 0 && num == count)
+    if (nCount > 0 && num == nCount)
       return true;
+
+    if (nBytes > 0 && nCurBytes == nBytes)
+      return true;
+
+    if (nBytes > 0 && nCurBytes > nBytes)
+    {
+      gLog.Warn("%sRead too much TLV data!\n", L_WARNxSTR);
+      return true;
+    }
+  }
+
+  // Finish off the number of bytes we wanted
+  if (nCurBytes < nBytes)
+  {
+    gLog.Warn("%sUnable to read requested amount of TLV data!\n",
 L_WARNxSTR); +    for (; nCurBytes < nBytes; nCurBytes++)
+      UnpackChar();
   }

   return true;

Index: icqd-srv.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-srv.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
- --- icqd-srv.cpp      30 Apr 2002 08:33:28 -0000      1.33
+++ icqd-srv.cpp        6 May 2002 01:51:26 -0000       1.34
@@ -1012,6 +1012,12 @@
       p = new CPU_GenericFamily(ICQ_SNACxFAM_BUDDY,
 ICQ_SNACxBDY_REQUESTxRIGHTS); SendEvent_Server(p);

+      // Jon XXX Use the server side list if wanted
+      // This request does contain parameters
+      gLog.Info("%sRequesting Server Contact List rights.\n", L_SRVxSTR);
+      p = new CPU_RequestList();
+      SendEvent_Server(p);
+
       gLog.Info("%sRequesting Instant Messaging rights.\n", L_SRVxSTR);
       p = new CPU_GenericFamily(ICQ_SNACxFAM_MESSAGE,
 ICQ_SNACxMSG_REQUESTxRIGHTS); SendEvent_Server(p);
@@ -1683,6 +1689,106 @@
   }
 }

+//--------ProcessListFam--------------------------------------------
+void CICQDaemon::ProcessListFam(CBuffer &packet, unsigned short nSubtype)
+{
+  /*unsigned short nFlags = */packet.UnpackUnsignedShortBE();
+  /*unsigned long nSubSequence = */packet.UnpackUnsignedLongBE();
+
+  switch (nSubtype)
+  {
+    case ICQ_SNACxLIST_RIGHTSxGRANTED:
+    {
+      gLog.Info("%sServer granted Server Contact List.\n", L_SRVxSTR);
+      gLog.Info("%sRequesting Server Contact List.\n", L_SRVxSTR);
+
+      CSrvPacketTcp *p = new CPU_GenericFamily(ICQ_SNACxFAM_LIST,
+        ICQ_SNACxLIST_REQUESTxROST);
+      SendEvent_Server(p);
+      break;
+    }
+
+    case ICQ_SNACxLIST_ROSTxREPLY:
+    {
+      unsigned short nCount;
+      unsigned long nTime;
+
+      gLog.Info("%sReceived contact list.\n", L_SRVxSTR);
+
+      packet.UnpackChar();  // unknown
+      nCount = packet.UnpackUnsignedShortBE();
+
+      for (unsigned short i = 0; i < nCount; i++)
+      {
+        char *szName;
+        unsigned short nTag, nID, nType, nByteLen;
+
+        // Can't use UnpackUinString because this may be a group name
+        szName = packet.UnpackStringBE();
+        nTag = packet.UnpackUnsignedShortBE();
+        nID = packet.UnpackUnsignedShortBE();
+        nType = packet.UnpackUnsignedShortBE();
+        nByteLen = packet.UnpackUnsignedShortBE();
+
+        if (nByteLen)
+        {
+          if (!packet.readTLV(-1, nByteLen))
+          {
+            gLog.Error("%sUnable to parse contact list TLV, aborting!\n",
 L_ERRORxSTR); +            return;
+          }
+        }
+
+        switch (nType)
+        {
+          case ICQ_ROSTxNORMAL:
+          case ICQ_ROSTxVISIBLE:
+          case ICQ_ROSTxINVISIBLE:
+          {
+            unsigned long nUin = atoi(szName);
+            unsigned short nInGroup = gUserManager.GetGroupFromID(nTag);
+            AddUserToList(nUin, false); // Don't notify server
+            ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W);
+            if (u)
+            {
+              u->SetSID(nID);
+
+              if (nType == ICQ_ROSTxINVISIBLE)  u->SetInvisibleList(true);
+              else if (nType == ICQ_ROSTxVISIBLE) u->SetVisibleList(true);
+
+              // Drop before lock. I'm a poet and didn't know it.
+              gUserManager.DropUser(u);
+              gUserManager.AddUserToGroup(nUin, nInGroup);
+            }
+
+            char *szNewName = packet.UnpackStringTLV(0x0131);
+            gLog.Info("%sAdded %s (%ld) to list from server.\n", L_SRVxSTR,
+              (szNewName ? szNewName : ""), nUin);
+            if (szNewName)
+              delete [] szNewName;
+
+            break;
+          }
+
+          case ICQ_ROSTxGROUP:
+          {
+            if (szName[0] != '\0')
+            {
+              // Add the group, if it already exists change the tag on this
 grp +              if (!gUserManager.AddGroup(szName, nTag))
+                gUserManager.ModifyGroupID(szName, nTag);
+            }
+            break;
+          }
+        }  // switch (nType)
+
+        packet.cleanupTLV();
+      } // for count
+      break;
+    } // case rost reply
+  } // switch subtype
+}
+
 //--------ProcessBosFam---------------------------------------------
 void CICQDaemon::ProcessBOSFam(CBuffer &packet, unsigned short nSubtype)
 {
@@ -2705,6 +2811,10 @@

   case ICQ_SNACxFAM_MESSAGE:
     ProcessMessageFam(packet, nSubtype);
+    break;
+
+  case ICQ_SNACxFAM_LIST:
+    ProcessListFam(packet, nSubtype);
     break;

   case ICQ_SNACxFAM_BOS:

Index: icqd-tcp.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd-tcp.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
- --- icqd-tcp.cpp      5 Mar 2002 16:55:59 -0000       1.32
+++ icqd-tcp.cpp        6 May 2002 01:51:26 -0000       1.33
@@ -575,6 +575,7 @@
     }

     case 7:
+    case 8:
     {
       // Send the hanshake
       CPacketTcp_Handshake_v7 p(nUin, 0, nPort);
@@ -602,7 +603,7 @@
       s->ClearRecvBuffer();
       if (p.SessionId() != p_in.SessionId())
       {
- -        gLog.Warn("%sBad handshake session id: received %ld, expecting
 %ld.\n", +        gLog.Warn("%sBad handshake cookie: received %ld, expecting
 %ld.\n", L_WARNxSTR, p_in.SessionId(), p.SessionId());
         return false;
       }

Index: icqd.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqd.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
- --- icqd.cpp  12 Apr 2002 18:44:51 -0000      1.32
+++ icqd.cpp    6 May 2002 01:51:26 -0000       1.33
@@ -782,7 +782,7 @@
  * Adds the given uin to the contact list.  Note that when this call returns
  * the user is not locked.
 
 *-------------------------------------------------------------------------*/
 -bool CICQDaemon::AddUserToList(unsigned long nUin)
+bool CICQDaemon::AddUserToList(unsigned long nUin, bool bNotify)
 {
   // Don't add invalid uins
   if (nUin == 0) return false;
@@ -799,7 +799,7 @@
   gUserManager.DropUser(u);
   SaveUserList();

- -  if (m_nTCPSrvSocketDesc != -1) icqAddUser(nUin);
+  if (m_nTCPSrvSocketDesc != -1 && bNotify) icqAddUser(nUin);

   PushPluginSignal(new CICQSignal(SIGNAL_UPDATExLIST, LIST_ADD, nUin));


Index: icqpacket.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/icqpacket.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
- --- icqpacket.cpp     16 Apr 2002 13:38:33 -0000      1.37
+++ icqpacket.cpp       6 May 2002 01:51:26 -0000       1.38
@@ -304,6 +304,7 @@
       break;
     case 6:
     case 7:
+    case 8:
     default:
       offset = 0;
   }
@@ -375,6 +376,7 @@
     break;
   case 6:
   case 7:
+  case 8:
   default:
     offset = 0;
   }
@@ -1196,6 +1198,19 @@
   InitBuffer();
 }

+//-----RequestList----------------------------------------------------------
- ---- +CPU_RequestList::CPU_RequestList()
+  : CPU_CommonFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_REQUESTxROST)
+{
+  m_nSize += 6;
+  InitBuffer();
+
+  ICQOwner *o = gUserManager.FetchOwner(LOCK_R);
+  buffer->PackUnsignedLongBE(o->GetSSCheck());
+  buffer->PackUnsignedShortBE(o->GetSSCount());
+  gUserManager.DropOwner();
+}
+
 //-----SearchByInfo---------------------------------------------------------
- ----- CPU_SearchByInfo::CPU_SearchByInfo(const char *szAlias, const char
 *szFirstName, const char *szLastName, const char *szEmail) @@ -1989,8
 +2004,6 @@
    unsigned long nSessionId, unsigned short nLocalPort)
 {
   m_nDestinationUin = nDestinationUin;
- -  m_nSessionId = nSessionId;
- -  if (m_nSessionId == 0) m_nSessionId = rand();

   m_nSize = 48;
   buffer = new CBuffer(m_nSize);
@@ -2006,7 +2019,12 @@
   buffer->PackUnsignedLong(s_nLocalIp);
   buffer->PackChar(s_nMode);
   buffer->PackUnsignedLong(nLocalPort == 0 ? s_nLocalPort : nLocalPort);
- -  buffer->PackUnsignedLong(m_nSessionId);
+
+  ICQUser *u = gUserManager.FetchUser(nDestinationUin, LOCK_R);
+  buffer->PackUnsignedLong(u->Cookie());
+  m_nSessionId = u->Cookie();
+  gUserManager.DropUser(u);
+
   buffer->PackUnsignedLong(0x00000050); // constant
   buffer->PackUnsignedLong(0x00000003); // constant
   buffer->PackUnsignedLong(0x00000000); // ???
@@ -2018,7 +2036,7 @@
 {
   m_nHandshake = inbuf->UnpackChar();
   m_nVersionMajor = inbuf->UnpackUnsignedShort();
- -  m_nVersionMinor = inbuf->UnpackUnsignedShort();
+  inbuf->UnpackUnsignedShort();  // Length
   m_nDestinationUin = inbuf->UnpackUnsignedLong();
   inbuf->UnpackUnsignedShort();
   inbuf->UnpackUnsignedLong();
@@ -2026,10 +2044,8 @@
   m_nRealIp = inbuf->UnpackUnsignedLong();
   m_nLocalIp = inbuf->UnpackUnsignedLong();
   m_nMode = inbuf->UnpackChar();
- -  inbuf->UnpackUnsignedLong(); // port of some kind...?
- -  m_nSessionId = inbuf->UnpackUnsignedLong();
- -  //inbuf->UnpackUnsignedLong(); // constant
- -  //inbuf->UnpackUnsignedLong(); // constant
+  inbuf->UnpackUnsignedLong();
+  m_nSessionId = inbuf->UnpackUnsignedLong(); // Mmmm cookie
 }


@@ -2149,6 +2165,7 @@
   {
     case 6:
     case 7:
+    case 8:
       InitBuffer_v6();
       break;
     case 4:
@@ -2168,6 +2185,7 @@
   {
     case 6:
     case 7:
+    case 8:
       PostBuffer_v6();
       break;
     case 4:

Index: licq.conf.h
===================================================================
RCS file: /cvsroot/licq/licq/src/licq.conf.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
- --- licq.conf.h       17 Mar 2002 05:47:55 -0000      1.12
+++ licq.conf.h 6 May 2002 01:51:26 -0000       1.13
@@ -50,4 +50,7 @@
 "Group1.name = New Users\n"
 "Group2.name = Friends\n"
 "Group3.name = Family\n"
+"Group1.id = 0\n"
+"Group2.id = 0\n"
+"Group3.id = 0\n"
 "\n";

Index: user.cpp
===================================================================
RCS file: /cvsroot/licq/licq/src/user.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
- --- user.cpp  19 Mar 2002 06:54:24 -0000      1.36
+++ user.cpp    6 May 2002 01:51:26 -0000       1.37
@@ -87,7 +87,8 @@
   // Set up the basic all users and new users group
   pthread_rdwr_init_np(&mutex_grouplist, NULL);
   pthread_rdwr_init_np(&mutex_userlist, NULL);
- -  m_nUserListLockType = m_nGroupListLockType = LOCK_N;
+  pthread_rdwr_init_np(&mutex_groupidlist, NULL);
+  m_nUserListLockType = m_nGroupListLockType = m_nGroupIDListLockType =
 LOCK_N;

   m_xOwner = NULL;
   m_nOwnerUin = 0;
@@ -147,12 +148,16 @@
   licqConf.ReadNum("NumOfGroups", nGroups);

   m_bAllowSave = false;
- -  char sGroupKey[MAX_KEYxNAME_LEN], sGroupName[MAX_LINE_LEN];
+  char sGroupKey[MAX_KEYxNAME_LEN], sGroupIDKey[MAX_KEYxNAME_LEN],
+       sGroupName[MAX_LINE_LEN];
+  unsigned short nID;
   for (unsigned short i = 1; i <= nGroups; i++)
   {
      sprintf(sGroupKey, "Group%d.name", i);
      licqConf.ReadStr(sGroupKey, sGroupName);
- -     AddGroup(strdup(sGroupName));
+     sprintf(sGroupIDKey, "Group%d.id", i);
+     licqConf.ReadNum(sGroupIDKey, nID, 0);
+     AddGroup(strdup(sGroupName), nID);
   }
   m_bAllowSave = true;

@@ -260,14 +265,46 @@
 /*--------------------------------------------------------------------------
- - * CUserManager::AddGroup
 
 *-------------------------------------------------------------------------*/
 -void CUserManager::AddGroup(char *_szName)
+bool CUserManager::AddGroup(char *_szName, unsigned short nID)
 {
- -  if(_szName) {
+  bool bRet = false;
+
+  if(_szName)
+  {
+    // Check to make sure it isn't a group name already
+    int j = 0;
     LockGroupList(LOCK_W);
- -    m_vszGroups.push_back(strdup(_szName));
- -    SaveGroups();
+    for (GroupList::iterator i = m_vszGroups.begin(); i !=
 m_vszGroups.end(); +      ++i)
+    {
+      if (strlen(_szName) == strlen(*i))
+      {
+        for (; j < strlen(_szName); j++)
+        {
+          if (toupper(_szName[j]) != toupper((*i)[j]))
+            break;
+        }
+      }
+    }
+
+    // Don't allow a duplicate name
+    if (j == strlen(_szName))
+    {
+      gLog.Warn("%sGroup %s already on list.\n", L_WARNxSTR, _szName);
+    }
+    else
+    {
+      AddGroupID(nID);
+
+      m_vszGroups.push_back(strdup(_szName));
+      SaveGroups();
+      bRet = true;
+    }
+
     UnlockGroupList();
   }
+
+  return bRet;
 }


@@ -275,7 +312,7 @@
 /*--------------------------------------------------------------------------
- - * CUserManager::RemoveGroup
  *
- - * Removes a group (note groups are numbered 1 to NumGroups() )
+ * Removes a group and it's id (note groups are numbered 1 to NumGroups() )
 
 *-------------------------------------------------------------------------*/
 void CUserManager::RemoveGroup(unsigned short n)
 {
@@ -298,6 +335,9 @@
   FOR_EACH_USER_END;
   if (m_nDefaultGroup >= n) m_nDefaultGroup--;
   //if (m_nNewUserGroup >= n) m_nNewUserGroup--;
+
+  RemoveGroupID(n);
+
   SaveGroups();
   UnlockGroupList();
 }
@@ -357,7 +397,7 @@
 /*--------------------------------------------------------------------------
- - * CUserManager::SaveGroups
  *
- - * Assumes a lock on the group list.
+ * Assumes a lock on the group list
 
 *-------------------------------------------------------------------------*/
 void CUserManager::SaveGroups()
 {
@@ -372,13 +412,18 @@
   licqConf.SetSection("groups");
   licqConf.WriteNum("NumOfGroups", NumGroups());

- -  char sGroupKey[MAX_KEYxNAME_LEN];
+  char sGroupKey[MAX_KEYxNAME_LEN], sGroupIDKey[MAX_KEYxNAME_LEN];
   //LockGroupList(LOCK_R);
+  LockGroupIDList(LOCK_R);
   for (unsigned short i = 0; i < m_vszGroups.size(); i++)
   {
      sprintf(sGroupKey, "Group%d.name", i + 1);
      licqConf.WriteStr(sGroupKey, m_vszGroups[i]);
+
+     sprintf(sGroupIDKey, "Group%d.id", i + 1);
+     licqConf.WriteNum(sGroupIDKey, m_vnGroupsID[i]);
   }
+  UnlockGroupIDList();
   //UnlockGroupList();

   licqConf.WriteNum("DefaultGroup", m_nDefaultGroup);
@@ -387,7 +432,99 @@
   licqConf.CloseFile();
 }

+/*--------------------------------------------------------------------------
- - + * CUserManager::AddGroupID
+
 *-------------------------------------------------------------------------*/
 +void CUserManager::AddGroupID(unsigned short nID)
+{
+  LockGroupIDList(LOCK_W);
+  m_vnGroupsID.push_back(nID);
+  //SaveGroupIDs();
+  UnlockGroupIDList();
+}
+
+/*--------------------------------------------------------------------------
- - + * CUserManager::RemoveGroupID
+
 *-------------------------------------------------------------------------*/
 +void CUserManager::RemoveGroupID(unsigned short n)
+{
+  LockGroupIDList(LOCK_W);
+  m_vnGroupsID.erase(m_vnGroupsID.begin()+n-1);
+  SaveGroupIDs();
+  UnlockGroupIDList();
+}
+
+/*--------------------------------------------------------------------------
- - + * CUserManager::GetGroupFromID
+
 *-------------------------------------------------------------------------*/
 +unsigned short CUserManager::GetGroupFromID(unsigned short nID)
+{
+  unsigned short nGroup = 1;
+
+  LockGroupIDList(LOCK_R);
+  for (GroupIDList::iterator i = m_vnGroupsID.begin(); i !=
 m_vnGroupsID.end(); +      ++i)
+  {
+    if (*i == nID)  break;
+    nGroup++;
+  }
+  UnlockGroupIDList();

+  return nGroup;
+}
+
+/*--------------------------------------------------------------------------
- - + * CUserManager::ModifyGroupID
+
 *-------------------------------------------------------------------------*/
 +void CUserManager::ModifyGroupID(char *szGroup, unsigned short nNewID) +{
+  unsigned short nGroup = 0;
+  LockGroupList(LOCK_R);
+  LockGroupIDList(LOCK_W);
+  for (GroupList::iterator i = m_vszGroups.begin(); i != m_vszGroups.end();
+      ++i)
+  {
+    if (strcmp(*i, szGroup) == 0)
+    {
+      m_vnGroupsID[nGroup] = nNewID;
+      break;
+    }
+    else
+      nGroup++;
+  }
+  UnlockGroupIDList();
+
+  SaveGroups();
+  UnlockGroupList();
+}
+
+/*--------------------------------------------------------------------------
- - + * CUserManager::SaveGroupIDs
+ *
+ * Assumes a lock on the group id list
+
 *-------------------------------------------------------------------------*/
 +void CUserManager::SaveGroupIDs()
+{
+  if (!m_bAllowSave) return;
+
+  // Load the group info from licq.conf
+  char filename[MAX_FILENAME_LEN];
+  snprintf(filename, MAX_FILENAME_LEN, "%s/licq.conf", BASE_DIR);
+  CIniFile licqConf(INI_FxWARN);
+  licqConf.LoadFile(filename);
+
+  licqConf.SetSection("groups");
+
+  char sGroupKey[MAX_KEYxNAME_LEN];
+  for (unsigned short i = 0; i < m_vnGroupsID.size(); i++)
+  {
+     sprintf(sGroupKey, "Group%d.id", i + 1);
+     licqConf.WriteNum(sGroupKey, m_vnGroupsID[i]);
+  }
+
+  licqConf.FlushFile();
+  licqConf.CloseFile();
+}

 /*--------------------------------------------------------------------------
- - * CUserManager::FetchUser
@@ -580,6 +717,51 @@


 /*--------------------------------------------------------------------------
- - + * LockGroupIDList
+ *
+ * Locks the entire group id list for iterating through...
+
 *-------------------------------------------------------------------------*/
 +GroupIDList *CUserManager::LockGroupIDList(unsigned short _nLockType) +{
+  switch (_nLockType)
+  {
+  case LOCK_R:
+    pthread_rdwr_rlock_np (&mutex_groupidlist);
+    break;
+  case LOCK_W:
+    pthread_rdwr_wlock_np(&mutex_groupidlist);
+    break;
+  default:
+    break;
+  }
+  m_nGroupIDListLockType = _nLockType;
+  return &m_vnGroupsID;
+}
+
+
+
+/*--------------------------------------------------------------------------
- - + * CUserManager::UnlockGroupIDList
+
 *-------------------------------------------------------------------------*/
 +void CUserManager::UnlockGroupIDList()
+{
+  unsigned short nLockType = m_nGroupIDListLockType;
+  m_nGroupIDListLockType = LOCK_R;
+  switch (nLockType)
+  {
+  case LOCK_R:
+    pthread_rdwr_runlock_np(&mutex_groupidlist);
+    break;
+  case LOCK_W:
+    pthread_rdwr_wunlock_np(&mutex_groupidlist);
+    break;
+  default:
+    break;
+  }
+}
+
+
+/*--------------------------------------------------------------------------
- - * CUserManager::AddUserToGroup
 
 *-------------------------------------------------------------------------*/
 void CUserManager::AddUserToGroup(unsigned long _nUin, unsigned short
 _nGroup) @@ -904,6 +1086,7 @@
   m_fConf.ReadStr("History", szTemp, "default");
   if (szTemp[0] == '\0') strcpy(szTemp, "default");
   SetHistoryFile(szTemp);
+  m_fConf.ReadNum("SID", m_nSID, 0);

   if (nNewMessages > 0)
   {
@@ -1110,6 +1293,7 @@
   m_nAutoAccept = 0;
   m_szCustomAutoResponse = NULL;
   m_bConnectionInProgress = false;
+  m_nSID = 0;

   pthread_rdwr_init_np (&mutex_rw, NULL);
 }
@@ -1874,6 +2058,7 @@
    m_fConf.WriteStr("CustomAutoRsp", CustomAutoResponse());
    m_fConf.WriteBool("SendRealIp", m_bSendRealIp);
    m_fConf.WriteStr("UserEncoding", m_szEncoding);
+   m_fConf.WriteNum("SID", m_nSID);

    if (!m_fConf.FlushFile())
    {
@@ -2147,6 +2332,8 @@
   m_fConf.ReadBool("HideIP", m_bHideIp, false);
   m_fConf.ReadNum("RCG", m_nRandomChatGroup, ICQ_RANDOMxCHATxGROUP_NONE);
   m_fConf.ReadStr("AutoResponse", szTemp, "");
+  m_fConf.ReadNum("SSTime", (unsigned long)m_nSSTime, 0L);
+  m_fConf.ReadNum("SSCount", m_nSSCount, 0);
   SetAutoResponse(szTemp);

   m_fConf.CloseFile();
@@ -2223,6 +2410,8 @@
   m_fConf.WriteBool("HideIP", HideIp());
   m_fConf.WriteBool("Authorization", GetAuthorization());
   m_fConf.WriteNum("RCG", RandomChatGroup());
+  m_fConf.WriteNum("SSTime", (unsigned long)m_nSSTime);
+  m_fConf.WriteNum("SSCount", m_nSSCount);

   if (!m_fConf.FlushFile())
   {


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Licq-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-cvs

- -------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE81eQJld1KayKQpx8RAhx2AJ9H4tZqttRvAEO3ZKslf/DghrMqBACgz88/
4QrwXcZyv5p5T7iO7q0ZBGU=
=Tja0
-----END PGP SIGNATURE-----


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Licq-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-devel

Reply via email to