Changeset 6463 for trunk/qt4-gui/src

Show
Ignore:
Timestamp:
07/24/08 04:08:58 (4 months ago)
Author:
flynd
Message:

Use a const pointer for user objects that are only fetched for read access. Fixed some places where we changed the user even though we just had a read lock.

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

Legend:

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

    r6330 r6463  
    9191    case LIST_CONTACT_ADDED: 
    9292    { 
    93       ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
     93      const ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
    9494      if (u == NULL) 
    9595      { 
     
    196196    return; 
    197197 
    198   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     198  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    199199  if (u == NULL) 
    200200    return; 
     
    339339} 
    340340 
    341 void ContactListModel::addUser(ICQUser* licqUser) 
     341void ContactListModel::addUser(const ICQUser* licqUser) 
    342342{ 
    343343  ContactUserData* newUser = new ContactUserData(licqUser, this); 
    344344  connect(newUser, SIGNAL(dataChanged(const ContactUserData*)), 
    345345      SLOT(userDataChanged(const ContactUserData*))); 
    346   connect(newUser, SIGNAL(updateUserGroups(ContactUserData*, ICQUser*)), 
    347       SLOT(updateUserGroups(ContactUserData*, ICQUser*))); 
     346  connect(newUser, SIGNAL(updateUserGroups(ContactUserData*, const ICQUser*)), 
     347      SLOT(updateUserGroups(ContactUserData*, const ICQUser*))); 
    348348 
    349349  myUsers.append(newUser); 
     
    351351} 
    352352 
    353 void ContactListModel::updateUserGroups(ContactUserData* user, ICQUser* licqUser) 
     353void ContactListModel::updateUserGroups(ContactUserData* user, const ICQUser* licqUser) 
    354354{ 
    355355  // Check which user groups the user should be member of 
  • trunk/qt4-gui/src/contactlist/contactlist.h

    r6323 r6463  
    210210   * @param licqUser The user to add 
    211211   */ 
    212   void addUser(ICQUser* licqUser); 
     212  void addUser(const ICQUser* licqUser); 
    213213 
    214214  /** 
     
    412412   * @param licqUser The daemon user to get group membership from 
    413413   */ 
    414   void updateUserGroups(ContactUserData* user, ICQUser* licqUser); 
     414  void updateUserGroups(ContactUserData* user, const ICQUser* licqUser); 
    415415 
    416416private: 
  • trunk/qt4-gui/src/contactlist/contactuserdata.cpp

    r6460 r6463  
    5858 
    5959 
    60 ContactUserData::ContactUserData(ICQUser* licqUser, QObject* parent) 
     60ContactUserData::ContactUserData(const ICQUser* licqUser, QObject* parent) 
    6161  : myStatus(ICQ_STATUS_OFFLINE), 
    6262    myEvents(0), 
     
    144144 
    145145 
    146   ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
     146  const ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); 
    147147  if (u != NULL) 
    148148  { 
     
    157157} 
    158158 
    159 void ContactUserData::updateAll(ICQUser* u) 
     159void ContactUserData::updateAll(const ICQUser* u) 
    160160{ 
    161161  myStatus = u->Status(); 
     
    396396} 
    397397 
    398 bool ContactUserData::updateText(ICQUser* licqUser) 
     398bool ContactUserData::updateText(const ICQUser* licqUser) 
    399399{ 
    400400  bool hasChanged = false; 
     
    425425void ContactUserData::configUpdated() 
    426426{ 
    427   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     427  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    428428  if (u == NULL) 
    429429    return; 
     
    499499  // Here we update any content that may be dynamic, for example timestamps 
    500500 
    501   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     501  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    502502  if (u == NULL) 
    503503    return; 
     
    669669QString ContactUserData::tooltip() const 
    670670{ 
    671   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     671  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    672672  if (u == NULL) 
    673673    return ""; 
  • trunk/qt4-gui/src/contactlist/contactuserdata.h

    r6150 r6463  
    5454   * @param parent Object to use as parent for those objects that needs it 
    5555   */ 
    56   ContactUserData(ICQUser* licqUser, QObject* parent); 
     56  ContactUserData(const ICQUser* licqUser, QObject* parent); 
    5757 
    5858  /** 
     
    7373   * @param licqUser Licq user to read information from 
    7474   */ 
    75   void updateAll(ICQUser* licqUser); 
     75  void updateAll(const ICQUser* licqUser); 
    7676 
    7777  /** 
     
    168168   * Signal emitted when the user group memberships (may) have changed 
    169169   */ 
    170   void updateUserGroups(ContactUserData* user, ICQUser* licqUser); 
     170  void updateUserGroups(ContactUserData* user, const ICQUser* licqUser); 
    171171 
    172172private: 
     
    192192   * @return True if any data was actually changed 
    193193   */ 
    194   bool updateText(ICQUser* licqUser); 
     194  bool updateText(const ICQUser* licqUser); 
    195195 
    196196  /** 
  • trunk/qt4-gui/src/core/licqgui.cpp

    r6430 r6463  
    725725    parent = myMainWindow; 
    726726 
    727   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     727  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    728728  if (u == NULL) 
    729729    return true; 
     
    10651065    return; 
    10661066 
    1067   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     1067  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    10681068 
    10691069  if (u == NULL) 
     
    12211221    if (Config::Chat::instance()->msgChatView()) 
    12221222    { 
    1223       ICQUser* u = NULL; 
     1223      const ICQUser* u = NULL; 
    12241224      if (ppid == 0) 
    12251225      { 
     
    13111311  if (id.isEmpty() || ppid == 0) 
    13121312    return; 
    1313   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     1313  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    13141314  if (u == NULL) 
    13151315    return; 
     
    14031403  unsigned long ppid = sig->PPID(); 
    14041404 
    1405   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     1405  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    14061406  if (u == NULL) 
    14071407  { 
     
    14541454        if (Config::Chat::instance()->autoPopup() >= popCheck) 
    14551455        { 
    1456           ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     1456          const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    14571457          if (u != NULL) 
    14581458          { 
     
    15001500    case USER_TYPING: 
    15011501    { 
    1502       ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     1502      const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    15031503      if (u == NULL) 
    15041504        break; 
  • trunk/qt4-gui/src/core/licqkimiface.cpp

    r6365 r6463  
    406406 
    407407    // check if user exists 
    408     ICQUser* pUser = gUserManager.FetchUser(contactId.latin1(), PPID, LOCK_R); 
     408    const ICQUser* pUser = gUserManager.FetchUser(contactId.latin1(), PPID, LOCK_R); 
    409409    if (pUser != 0) 
    410410    { 
     
    489489 
    490490    // check if user already exists 
    491     ICQUser* pUser = gUserManager.FetchUser(contactId.latin1(), PPID, LOCK_R); 
     491    const ICQUser* pUser = gUserManager.FetchUser(contactId.latin1(), PPID, LOCK_R); 
    492492    if (pUser != 0) 
    493493    { 
  • trunk/qt4-gui/src/core/mainwin.cpp

    r6374 r6463  
    633633      } 
    634634 
    635       ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     635      const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    636636      if (u == NULL) 
    637637      { 
  • trunk/qt4-gui/src/core/usermenu.cpp

    r6454 r6463  
    227227void UserMenu::aboutToShowMenu() 
    228228{ 
    229   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     229  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    230230 
    231231  int status = (u == NULL ? ICQ_STATUS_OFFLINE : u->Status()); 
     
    568568  if (gid == GROUP_IGNORE_LIST && !action->isChecked()) 
    569569  { 
    570     ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     570    const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    571571    if (u == NULL) 
    572572      return; 
  • trunk/qt4-gui/src/dialogs/adduserdlg.cpp

    r6315 r6463  
    9999  if (!id.isEmpty()) 
    100100  { 
    101     ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 
     101    const ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 
    102102 
    103103    if (u == NULL) 
     
    105105    else 
    106106    { 
    107       if (u->NotInList()) 
     107      bool notInList = u->NotInList(); 
     108      gUserManager.DropUser(u); 
     109 
     110      if (notInList) 
    108111      { 
    109         u->Unlock(); 
    110112        gUserManager.SetUserInGroup(id, ppid, GROUPS_USER, group, true, true); 
    111         u->Lock(LOCK_W); 
    112         u->SetPermanent(); 
     113        ICQUser* user = gUserManager.FetchUser(id, ppid, LOCK_W); 
     114        user->SetPermanent(); 
     115        gUserManager.DropUser(user); 
    113116        added = true; 
    114117      } 
    115       gUserManager.DropUser(u); 
    116118    } 
    117119  } 
  • trunk/qt4-gui/src/dialogs/authuserdlg.cpp

    r6352 r6463  
    7070    toplay->addWidget(lblUin); 
    7171    QString userName = myId; 
    72     ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     72    const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    7373    if (u != NULL) 
    7474    { 
  • trunk/qt4-gui/src/dialogs/customautorespdlg.cpp

    r6124 r6463  
    7373  lay->addWidget(buttons); 
    7474 
    75   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     75  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    7676 
    7777  if (u == NULL) 
  • trunk/qt4-gui/src/dialogs/forwarddlg.cpp

    r6352 r6463  
    164164  m_nPPID = nPPID; 
    165165 
    166   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
     166  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
    167167  if (u == NULL) 
    168168    return; 
  • trunk/qt4-gui/src/dialogs/gpgkeymanager.cpp

    r6352 r6463  
    193193  if (!found) 
    194194  { 
    195     ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     195    const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    196196    if (u == NULL) 
    197197      return; 
     
    266266 
    267267// KEYLISTITEM 
    268 KeyListItem::KeyListItem(QTreeWidget* parent, ICQUser* u) 
     268KeyListItem::KeyListItem(QTreeWidget* parent, const ICQUser* u) 
    269269  : QTreeWidgetItem(parent), 
    270270    szId(u->IdString()), 
     
    275275} 
    276276 
    277 void KeyListItem::updateText(ICQUser* u) 
     277void KeyListItem::updateText(const ICQUser* u) 
    278278{ 
    279279  setText(0, QString::fromUtf8(u->GetAlias())); 
     
    293293void KeyListItem::slot_done() 
    294294{ 
    295   ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
     295  const ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
    296296  keySelect = NULL; 
    297297 
  • trunk/qt4-gui/src/dialogs/gpgkeymanager.h

    r6219 r6463  
    7171 
    7272public: 
    73   KeyListItem(QTreeWidget* parent, ICQUser* u); 
     73  KeyListItem(QTreeWidget* parent, const ICQUser* u); 
    7474 
    7575  void edit(); 
     
    8383  unsigned long nPPID; 
    8484  GPGKeySelect* keySelect; 
    85   void updateText(ICQUser* u); 
     85  void updateText(const ICQUser* u); 
    8686 
    8787private slots: 
  • trunk/qt4-gui/src/dialogs/gpgkeyselect.cpp

    r5837 r6463  
    5656  Support::setWidgetProps(this, "GPGKeySelectDialog"); 
    5757 
    58   ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
     58  const ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
    5959  if (u == NULL) 
    6060    return; 
     
    224224} 
    225225 
    226 void KeyView::testViewItem(QTreeWidgetItem* item, ICQUser* u) 
     226void KeyView::testViewItem(QTreeWidgetItem* item, const ICQUser* u) 
    227227{ 
    228228  int val = 0; 
     
    253253  gpgme_new(&mCtx); 
    254254 
    255   ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
     255  const ICQUser* u = gUserManager.FetchUser(szId.toLatin1(), nPPID, LOCK_R); 
    256256  maxItemVal = -1; 
    257257  maxItem = NULL; 
  • trunk/qt4-gui/src/dialogs/gpgkeyselect.h

    r5837 r6463  
    4242  QString szId; 
    4343  unsigned long nPPID; 
    44   void testViewItem(QTreeWidgetItem* item, ICQUser* u); 
     44  void testViewItem(QTreeWidgetItem* item, const ICQUser* u); 
    4545  int maxItemVal; 
    4646  QTreeWidgetItem* maxItem; 
  • trunk/qt4-gui/src/dialogs/historydlg.cpp

    r6448 r6463  
    161161  show(); 
    162162 
    163   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     163  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    164164 
    165165  QString name = tr("INVALID USER"); 
     
    277277  if (signal->SubSignal() == USER_EVENTS) 
    278278  { 
    279     ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     279    const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    280280    if (u == NULL) 
    281281      return; 
  • trunk/qt4-gui/src/dialogs/keyrequestdlg.cpp

    r6294 r6463  
    4949  setAttribute(Qt::WA_DeleteOnClose, true); 
    5050 
    51   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     51  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    5252  setWindowTitle(tr("Licq - Secure Channel with %1") 
    5353      .arg(QString::fromUtf8(u->GetAlias()))); 
  • trunk/qt4-gui/src/dialogs/mmsenddlg.cpp

    r6430 r6463  
    168168    case ICQ_CMDxSUB_MSG: 
    169169    { 
    170       ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
     170      const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
    171171      if (u == NULL) return; 
    172172      QTextCodec* codec = UserCodec::codecForICQUser(u); 
     
    239239    case ICQ_CMDxSUB_URL: 
    240240    { 
    241       ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
     241      const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
    242242      if (u == NULL) return; 
    243243      grpSending->setTitle(tr("Sending mass URL to %1...").arg(QString::fromUtf8(u->GetAlias()))); 
     
    252252    case ICQ_CMDxSUB_CONTACTxLIST: 
    253253    { 
    254       ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
     254      const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
    255255      if (u == NULL) return; 
    256256      grpSending->setTitle(tr("Sending mass list to %1...").arg(QString::fromUtf8(u->GetAlias()))); 
  • trunk/qt4-gui/src/dialogs/refusedlg.cpp

    r6133 r6463  
    4545  QVBoxLayout* lay = new QVBoxLayout(this); 
    4646 
    47   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     47  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    4848  QLabel* lbl = new QLabel(tr("Refusal message for %1 with ").arg(t) + QString::fromUtf8(u->GetAlias()) + ":"); 
    4949  lay->addWidget(lbl); 
  • trunk/qt4-gui/src/dialogs/showawaymsgdlg.cpp

    r6352 r6463  
    8181  lay->addWidget(buttons); 
    8282 
    83   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     83  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    8484  QTextCodec* codec = UserCodec::codecForICQUser(u); 
    8585  chkShowAgain->setChecked(u->ShowAwayMsg()); 
     
    165165       e->SNAC() == MAKESNAC(ICQ_SNACxFAM_LOCATION, ICQ_SNACxLOC_INFOxREQ))) 
    166166  { 
    167     ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
     167    const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 
    168168    QTextCodec* codec = UserCodec::codecForICQUser(u); 
    169169    const char* szAutoResp = 
  • trunk/qt4-gui/src/dialogs/userinfodlg.cpp

    r6374 r6463  
    179179  lay->addLayout(l); 
    180180 
    181   ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
     181  const ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), m_nPPID, LOCK_R); 
    182182  if (u == NULL) 
    183183  { 
     
    348348} 
    349349 
    350 void UserInfoDlg::SetGeneralInfo(ICQUser* u) 
     350void UserInfoDlg::SetGeneralInfo(const ICQUser* u) 
    351351{ 
    352352  tabList[GeneralInfo].loaded = true; 
     
    587587} 
    588588 
    589 void UserInfoDlg::SetMoreInfo(ICQUser* u) 
     589void UserInfoDlg::SetMoreInfo(const ICQUser* u) 
    590590{ 
    591591  tabList[MoreInfo].loaded = true; 
     
    848848} 
    849849 
    850 void UserInfoDlg::SetMore2Info(ICQUser* u) 
    851 { 
    852   ICQUserCategory* cat; 
     850void UserInfoDlg::SetMore2Info(const ICQUser* u) 
     851