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/userevents
Files:
12 modified

Legend:

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

    r6352 r6463  
    155155  myTypingTimer = NULL; 
    156156 
    157   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     157  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    158158  if (u != NULL) 
    159159  { 
     
    283283} 
    284284 
    285 void UserEventCommon::updateWidgetInfo(ICQUser* u) 
     285void UserEventCommon::updateWidgetInfo(const ICQUser* u) 
    286286{ 
    287287  QTextCodec* codec = UserCodec::codecForICQUser(u); 
     
    467467  } 
    468468 
    469   ICQUser* u = gUserManager.FetchUser(sig->Id(), myPpid, LOCK_R); 
     469  const ICQUser* u = gUserManager.FetchUser(sig->Id(), myPpid, LOCK_R); 
    470470  if (u == NULL) 
    471471    return; 
  • trunk/qt4-gui/src/userevents/usereventcommon.h

    r6160 r6463  
    9898 
    9999  void flashTaskbar(); 
    100   void updateWidgetInfo(ICQUser* u); 
     100  void updateWidgetInfo(const ICQUser* u); 
    101101  void pushToolTip(QAction* action, QString tooltip); 
    102102 
  • trunk/qt4-gui/src/userevents/usereventtabdlg.cpp

    r6350 r6463  
    7575void UserEventTabDlg::addTab(UserEventCommon* tab, int index) 
    7676{ 
    77   ICQUser* u = gUserManager.FetchUser(tab->id().toLatin1(), tab->ppid(), LOCK_R); 
     77  const ICQUser* u = gUserManager.FetchUser(tab->id().toLatin1(), tab->ppid(), LOCK_R); 
    7878  if (u == NULL) 
    7979    return; 
     
    115115  for (it = users.begin(); it != users.end(); ++it) 
    116116  { 
    117     ICQUser* u = gUserManager.FetchUser((*it).c_str(), tab->ppid(), LOCK_R); 
     117    const ICQUser* u = gUserManager.FetchUser((*it).c_str(), tab->ppid(), LOCK_R); 
    118118 
    119119    if (!newLabel.isEmpty()) 
     
    132132} 
    133133 
    134 void UserEventTabDlg::updateTabLabel(ICQUser* u) 
     134void UserEventTabDlg::updateTabLabel(const ICQUser* u) 
    135135{ 
    136136  if (u == NULL) 
     
    147147} 
    148148 
    149 void UserEventTabDlg::updateTabLabel(UserEventCommon* tab, ICQUser* u) 
     149void UserEventTabDlg::updateTabLabel(UserEventCommon* tab, const ICQUser* u) 
    150150{ 
    151151  if (tab == NULL) 
     
    215215} 
    216216 
    217 void UserEventTabDlg::setTyping(ICQUser* u, int convoId) 
     217void UserEventTabDlg::setTyping(const ICQUser* u, int convoId) 
    218218{ 
    219219  for (int index = 0; index < myTabs->count(); index++) 
  • trunk/qt4-gui/src/userevents/usereventtabdlg.h

    r6182 r6463  
    4747  bool tabExists(QWidget* tab); 
    4848  void updateConvoLabel(UserEventCommon* tab); 
    49   void updateTabLabel(ICQUser* u); 
    50   void updateTabLabel(UserEventCommon* tab, ICQUser* u = NULL); 
    51   void setTyping(ICQUser* u, int convoId); 
     49  void updateTabLabel(const ICQUser* u); 
     50  void updateTabLabel(UserEventCommon* tab, const ICQUser* u = NULL); 
     51  void setTyping(const ICQUser* u, int convoId); 
    5252 
    5353#ifdef USE_KDE 
  • trunk/qt4-gui/src/userevents/usersendchatevent.cpp

    r6406 r6463  
    9292  if (!e->ExtendedAck() || !e->ExtendedAck()->Accepted()) 
    9393  { 
    94     ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     94    const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    9595    QString s = !e->ExtendedAck() ? 
    9696      tr("No reason provided") : 
  • trunk/qt4-gui/src/userevents/usersendcommon.cpp

    r6431 r6463  
    9191const size_t SHOW_RECENT_NUM = 5; 
    9292 
    93 typedef pair<CUserEvent*, char*> messagePair; 
     93typedef pair<const CUserEvent*, char*> messagePair; 
    9494 
    9595bool orderMessagePairs(const messagePair& mp1, const messagePair& mp2) 
     
    166166  bool canSendDirect = (mySendFuncs & PP_SEND_DIRECT); 
    167167 
    168   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     168  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    169169 
    170170  if (u != NULL) 
     
    313313      for (unsigned short i = 0; i < u->NewMessages(); i++) 
    314314      { 
    315         CUserEvent* e = u->EventPeek(i); 
     315        const CUserEvent* e = u->EventPeek(i); 
    316316        // Get the convo id now 
    317317        unsigned long convoId = e->ConvoId(); 
     
    498498} 
    499499 
    500 void UserSendCommon::updatePicture(ICQUser* u) 
     500void UserSendCommon::updatePicture(const ICQUser* u) 
    501501{ 
    502502  bool fetched = false; 
     
    581581  if (Config::Chat::instance()->msgChatView()) 
    582582  { 
    583     ICQUser* u = gUserManager.FetchUser(id.toLatin1(), myPpid, LOCK_R); 
     583    const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), myPpid, LOCK_R); 
    584584    QString userName; 
    585585    if (u != 0) 
     
    618618  if (Config::Chat::instance()->msgChatView()) 
    619619  { 
    620     ICQUser* u = gUserManager.FetchUser(id.toLatin1(), myPpid, LOCK_R); 
     620    ICQUser* u = gUserManager.FetchUser(id.toLatin1(), myPpid, LOCK_W); 
    621621    QString userName; 
    622622    if (u != 0) 
     
    760760    case ICQ_CMDxSUB_MSG: 
    761761    { 
    762       ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     762      const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    763763      bool userOffline = true; 
    764764      if (u != 0) 
     
    918918void UserSendCommon::userUpdated(CICQSignal* sig, QString id, unsigned long ppid) 
    919919{ 
    920   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     920  ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_W); 
    921921 
    922922  if (u == NULL) 
     
    943943    case USER_EVENTS: 
    944944    { 
    945       CUserEvent* e = u->EventPeekId(sig->Argument()); 
     945      const CUserEvent* e = u->EventPeekId(sig->Argument()); 
    946946 
    947947      if (e != NULL && myHighestEventId < sig->Argument() && 
     
    981981bool UserSendCommon::checkSecure() 
    982982{ 
    983   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     983  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    984984 
    985985  if (u == NULL) 
     
    998998    else 
    999999    { 
    1000       ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     1000      ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_W); 
    10011001      if (u != NULL) 
    10021002      { 
     
    14631463void UserSendCommon::sendTrySecure() 
    14641464{ 
    1465   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     1465  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    14661466 
    14671467  bool autoSecure = false; 
  • trunk/qt4-gui/src/userevents/usersendcommon.h

    r6293 r6463  
    9595  void retrySend(ICQEvent* e, bool online, unsigned short level); 
    9696  virtual void userUpdated(CICQSignal* sig, QString id = QString::null, unsigned long ppid = 0); 
    97   void updatePicture(ICQUser* u = NULL); 
     97  void updatePicture(const ICQUser* u = NULL); 
    9898  bool checkSecure(); 
    9999 
  • trunk/qt4-gui/src/userevents/usersendcontactevent.cpp

    r6430 r6463  
    9191void UserSendContactEvent::setContact(QString id, unsigned long ppid) 
    9292{ 
    93   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     93  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    9494 
    9595  if (u != NULL) 
     
    106106 
    107107  bool showAwayDlg = false; 
    108   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     108  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    109109  if (u != NULL) 
    110110  { 
  • trunk/qt4-gui/src/userevents/usersendfileevent.cpp

    r6294 r6463  
    124124  if (!e->ExtendedAck() || !e->ExtendedAck()->Accepted()) 
    125125  { 
    126     ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     126    const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    127127    QString s = !e->ExtendedAck() ? 
    128128      tr("No reason provided") : 
  • trunk/qt4-gui/src/userevents/usersendmsgevent.cpp

    r6142 r6463  
    7676 
    7777  bool showAwayDlg = false; 
    78   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     78  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    7979  if (u != NULL) 
    8080  { 
     
    127127    return; 
    128128 
    129   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     129  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    130130  bool userOffline = true; 
    131131  if (u != NULL) 
  • trunk/qt4-gui/src/userevents/usersendurlevent.cpp

    r6142 r6463  
    112112 
    113113  bool showAwayDlg = false; 
    114   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     114  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    115115  if (u != NULL) 
    116116  { 
  • trunk/qt4-gui/src/userevents/userviewevent.cpp

    r6433 r6463  
    144144  setTabOrder(myReadNextButton, myCloseButton); 
    145145 
    146   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     146  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    147147  if (u != NULL && u->NewMessages() > 0) 
    148148  { 
     
    169169    for (i++; i < u->NewMessages(); i++) 
    170170    { 
    171       CUserEvent* event = u->EventPeek(i); 
     171      const CUserEvent* event = u->EventPeek(i); 
    172172      if (!Config::Chat::instance()->msgChatView() || 
    173173          (event->SubCommand() != ICQ_CMDxSUB_MSG && 
     
    261261void UserViewEvent::userUpdated(CICQSignal* sig, QString id, unsigned long ppid) 
    262262{ 
    263   ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
     263  const ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    264264 
    265265  if (u == 0) 
     
    271271    { 
    272272      int eventId = sig->Argument(); 
    273       CUserEvent* e = u->EventPeekId(eventId); 
     273      const CUserEvent* e = u->EventPeekId(eventId); 
    274274      // Making sure we didn't handle this message already. 
    275275      if (e != NULL && myHighestEventId < eventId && 
     
    296296    return; 
    297297 
    298   ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
     298  const ICQUser* u = gUserManager.FetchUser(myUsers.front().c_str(), myPpid, LOCK_R); 
    299299 
    300300  bool doclose = false; 
     
    597597#undef GETINFO 
    598598 
    599       ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 
     599      const ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_R); 
    600600      if (u == NULL) 
    601601        gLicqDaemon->AddUserToList(id, ppid, false, true); 
     
    737737        myRead2Button->setText(tr("&Refuse")); 
    738738        CEventAuthRequest* pAuthReq = dynamic_cast<CEventAuthRequest*>(m); 
    739         ICQUser* u = gUserManager.FetchUser(pAuthReq->IdString(), pAuthReq->PPID(), LOCK_R); 
     739        const ICQUser* u = gUserManager.FetchUser(pAuthReq->IdString(), pAuthReq->PPID(), LOCK_R); 
    740740        if (u == NULL) 
    741741          myRead3Button->setText(tr("A&dd User")); 
     
    749749      { 
    750750        CEventAuthGranted* pAuth = dynamic_cast<CEventAuthGranted*>(m); 
    751         ICQUser* u = gUserManager.FetchUser(pAuth->IdString(), pAuth->PPID(), LOCK_R); 
     751        const ICQUser* u = gUserManager.FetchUser(pAuth->IdString(), pAuth->PPID(), LOCK_R); 
    752752        if (u == NULL) 
    753753          myRead1Button->setText(tr("A&dd User")); 
     
    761761      { 
    762762        CEventAdded* pAdd = dynamic_cast<CEventAdded*>(m); 
    763         ICQUser* u = gUserManager.FetchUser(pAdd->IdString(), pAdd->PPID(), LOCK_R); 
     763        const ICQUser* u = gUserManager.FetchUser(pAdd->IdString(), pAdd->PPID(), LOCK_R); 
    764764        if (u == NULL) 
    765765          myRead1Button->setText(tr("A&dd User"));