Changeset 6279

Show
Ignore:
Timestamp:
06/13/08 03:40:47 (4 months ago)
Author:
flynd
Message:

Use new user group handling function so we need less code here in the plugin.

Location:
trunk/qt4-gui/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/core/groupmenu.cpp

    r6200 r6279  
    175175    unsigned long ppid = userIndex.data(ContactListModel::PpidRole).toUInt(); 
    176176 
    177     // Update user object 
    178     ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_W); 
    179     if (u == NULL) 
    180       continue; 
    181     u->SetInGroup(gtype, gid, true); 
    182     gUserManager.DropUser(u); 
    183  
    184     // Some special groups need special handling 
    185     if (groupId == ContactListModel::SystemGroupOffset + GROUP_VISIBLE_LIST) 
    186       gLicqDaemon->icqAddToVisibleList(id.toLatin1(), ppid); 
    187     if (groupId == ContactListModel::SystemGroupOffset + GROUP_INVISIBLE_LIST) 
    188       gLicqDaemon->icqAddToInvisibleList(id.toLatin1(), ppid); 
    189     if (groupId == ContactListModel::SystemGroupOffset + GROUP_IGNORE_LIST) 
    190       gLicqDaemon->icqAddToIgnoreList(id.toLatin1(), ppid); 
     177    gUserManager.SetUserInGroup(id.toLatin1(), ppid, gtype, gid, true, 
     178        gtype == GROUPS_SYSTEM); 
    191179 
    192180    // Daemon doesn't notify us when group memberships change so notify model from here 
  • trunk/qt4-gui/src/core/usermenu.cpp

    r6097 r6279  
    537537{ 
    538538  unsigned int gid = action->data().toUInt(); 
    539  
    540   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_W); 
    541  
    542   if (u == NULL) 
    543     return; 
    544  
    545   // Don't let the user to be deleted from local group 
    546   // if he is a member of the same server group 
    547   if (!action->isChecked() &&                             // delete 
    548       u->GetSID() &&                                      // server-side 
    549       gUserManager.GetGroupFromID(u->GetGSID()) == gid)   // same group 
    550   { 
    551     gUserManager.DropUser(u); 
    552     return; 
    553   } 
    554  
    555   u->SetInGroup(GROUPS_USER, gid, action->isChecked()); 
    556  
    557   gUserManager.DropUser(u); 
     539  gUserManager.SetUserInGroup(myId.toLatin1(), myPpid, GROUPS_USER, gid, 
     540      action->isChecked(), false); 
    558541 
    559542  // The daemon does not send an update when group membership changes 
     
    566549  unsigned int gid = action->data().toUInt(); 
    567550 
    568   ICQUser* u = NULL; 
    569   if (gid == GROUP_NEW_USERS || gid == GROUP_ONLINE_NOTIFY || gid == GROUP_IGNORE_LIST) 
    570   { 
    571     u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_W); 
     551  if (gid == GROUP_IGNORE_LIST && !action->isChecked()) 
     552  { 
     553    ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    572554    if (u == NULL) 
    573555      return; 
    574   } 
    575  
    576   switch (gid) 
    577   { 
    578     case GROUP_NEW_USERS: 
    579       u->SetNewUser(action->isChecked()); 
    580       break; 
    581  
    582     case GROUP_ONLINE_NOTIFY: 
    583       u->SetOnlineNotify(action->isChecked()); 
    584       break; 
    585  
    586     case GROUP_VISIBLE_LIST: 
    587       gLicqDaemon->ProtoToggleVisibleList(myId.toLatin1(), myPpid); 
    588       break; 
    589  
    590     case GROUP_INVISIBLE_LIST: 
    591       gLicqDaemon->ProtoToggleInvisibleList(myId.toLatin1(), myPpid); 
    592       break; 
    593  
    594     case GROUP_IGNORE_LIST: 
    595       if (!action->isChecked() || 
    596           QueryYesNo(this, tr("Do you really want to add\n%1 (%2)\nto your ignore list?") 
    597             .arg(QString::fromUtf8(u->GetAlias())).arg(myId))) 
    598       { 
    599         u->SetIgnoreList(action->isChecked()); 
    600         gUserManager.DropUser(u); 
    601         u = NULL; 
    602         gLicqDaemon->icqToggleIgnoreList(myId.toLatin1(), myPpid); // network only 
    603       } 
    604       break; 
    605   } 
    606  
    607   if (u != NULL) 
     556 
     557    QString alias = QString::fromUtf8(u->GetAlias()); 
    608558    gUserManager.DropUser(u); 
     559 
     560    if(!QueryYesNo(this, tr("Do you really want to add\n%1 (%2)\nto your ignore list?") 
     561        .arg(alias).arg(myId))) 
     562      return; 
     563  } 
     564 
     565  gUserManager.SetUserInGroup(myId.toLatin1(), myPpid, GROUPS_SYSTEM, gid, 
     566      action->isChecked(), true); 
    609567 
    610568  // The daemon does not send an update when group membership changes 
     
    615573void UserMenu::setServerGroup(QAction* action) 
    616574{ 
    617   gUserManager.AddUserToGroup(myId.toLatin1(), myPpid, action->data().toUInt()); 
     575  unsigned int gid = action->data().toUInt(); 
     576  gUserManager.SetUserInGroup(myId.toLatin1(), myPpid, GROUPS_USER, gid, true, true); 
    618577 
    619578  // The daemon does not send an update when group membership changes 
  • trunk/qt4-gui/src/views/userviewbase.cpp

    r6193 r6279  
    286286        if (!dropId.isEmpty()) 
    287287        { 
    288           gUserManager.AddUserToGroup(dropId.toLatin1(), dropPpid, gid); 
     288          gUserManager.SetUserInGroup(dropId.toLatin1(), dropPpid, GROUPS_USER, gid, true); 
    289289          myContactList->updateUser(dropId.toLatin1(), dropPpid); 
    290290        }