From: <em...@us...> - 2006-09-10 08:33:07
|
Author: emostar Date: Sun Sep 10 09:47:43 2006 New Revision: 4606 URL: http://svn.licq.org/viewvc/licq?rev=3D4606&view=3Drev Log: Fix #1371, make each protocol plugin be handled in the auto away handler. Modified: trunk/qt-gui/src/mainwin.cpp Modified: trunk/qt-gui/src/mainwin.cpp URL: http://svn.licq.org/viewvc/licq/trunk/qt-gui/src/mainwin.cpp?rev=3D460= 6&r1=3D4605&r2=3D4606&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/qt-gui/src/mainwin.cpp (original) +++ trunk/qt-gui/src/mainwin.cpp Sun Sep 10 09:47:43 2006 @@ -3960,14 +3960,9 @@ static bool bAutoNA =3D false; static bool bAutoOffline =3D false; =20 - // Fetch current status - unsigned short status =3D ICQ_STATUS_OFFLINE; - ICQOwner *o =3D gUserManager.FetchOwner(LOCK_R); - if (o !=3D NULL) - { - status =3D o->Status(); - gUserManager.DropOwner(); - } + bool bTempAutoAway =3D false; + bool bTempAutoNA =3D false; + bool bTempAutoOffline =3D false; =20 if (mit_info =3D=3D NULL) { @@ -3992,113 +3987,133 @@ } Time idleTime =3D mit_info->idle; =20 - // Check no one changed the status behind our back - if ( (bAutoOffline && status !=3D ICQ_STATUS_OFFLINE) || - (bAutoNA && status !=3D ICQ_STATUS_NA && !bAutoOffline) || - (bAutoAway && status !=3D ICQ_STATUS_AWAY && !bAutoNA && !bAutoOffl= ine) ) - { - bAutoOffline =3D false; - bAutoNA =3D false; - bAutoAway =3D false; - return; - } - -// gLog.Info("offl %d, n/a %d, away %d idlt %d\n", -// bAutoOffline, bAutoNA, bAutoAway, idleTime); - - if ( (autoOfflineTime > 0) && - (unsigned long)idleTime > (unsigned long)(autoOfflineTime * 60000)) - { - if (status !=3D ICQ_STATUS_OFFLINE) - { - changeStatus(ICQ_STATUS_OFFLINE); - bAutoOffline =3D true; - bAutoAway =3D (status =3D=3D ICQ_STATUS_ONLINE || bAutoAway); - bAutoNA =3D ((status =3D=3D ICQ_STATUS_AWAY && bAutoAway) || bAutoNA= ); - } - } - else if ( (autoNATime > 0) && - (unsigned long)idleTime > (unsigned long)(autoNATime * 60000)) - { - if (status !=3D ICQ_STATUS_NA && status !=3D ICQ_STATUS_OFFLINE) - { - if (autoNAMess) + // Go through each protocol, as the statuses may differ + FOR_EACH_PROTO_PLUGIN_START(licqDaemon) + { + unsigned long nPPID =3D (*_ppit)->PPID(); + + // Fetch current status + unsigned short status =3D ICQ_STATUS_OFFLINE; + ICQOwner *o =3D gUserManager.FetchOwner(nPPID, LOCK_R); + if (o !=3D NULL) + { + status =3D o->Status(); + gUserManager.DropOwner(nPPID); + } + + // Check no one changed the status behind our back + if ( (bAutoOffline && status !=3D ICQ_STATUS_OFFLINE) || + (bAutoNA && status !=3D ICQ_STATUS_NA && !bAutoOffline) || + (bAutoAway && status !=3D ICQ_STATUS_AWAY && !bAutoNA && !bAutoOf= fline) ) + { + bAutoOffline =3D false; + bAutoNA =3D false; + bAutoAway =3D false; + return; + } + + // gLog.Info("offl %d, n/a %d, away %d idlt %d\n", + // bAutoOffline, bAutoNA, bAutoAway, idleTime); + + if ( (autoOfflineTime > 0) && + (unsigned long)idleTime > (unsigned long)(autoOfflineTime * 60000= )) + { + if (status !=3D ICQ_STATUS_OFFLINE) { - SARList &sar =3D gSARManager.Fetch(SAR_NA); - ICQOwner *o =3D gUserManager.FetchOwner(LOCK_W); - if (o !=3D 0) + changeStatus(ICQ_STATUS_OFFLINE, nPPID); + bTempAutoOffline =3D true; + bTempAutoAway =3D (status =3D=3D ICQ_STATUS_ONLINE || bAutoAway); + bTempAutoNA =3D ((status =3D=3D ICQ_STATUS_AWAY && bAutoAway) || b= AutoNA); + } + } + else if ( (autoNATime > 0) && + (unsigned long)idleTime > (unsigned long)(autoNATime * 60000)) + { + if (status !=3D ICQ_STATUS_NA && status !=3D ICQ_STATUS_OFFLINE) + { + if (autoNAMess) { - o->SetAutoResponse(QString(sar[autoNAMess-1]->AutoResponse()).lo= cal8Bit()); - gUserManager.DropOwner(); + SARList &sar =3D gSARManager.Fetch(SAR_NA); + ICQOwner *o =3D gUserManager.FetchOwner(nPPID, LOCK_W); + if (o !=3D 0) + { + o->SetAutoResponse(QString(sar[autoNAMess-1]->AutoResponse()).= local8Bit()); + gUserManager.DropOwner(nPPID); + } + gSARManager.Drop(); } - gSARManager.Drop(); + + changeStatus(ICQ_STATUS_NA, nPPID); + bTempAutoNA =3D true; + bTempAutoAway =3D true; } - - changeStatus(ICQ_STATUS_NA); - bAutoNA =3D true; - bAutoAway =3D true; - } - } - else if ( (autoAwayTime > 0) && - (unsigned long)idleTime > (unsigned long)(autoAwayTime * 60000= )) - { - if (status !=3D ICQ_STATUS_AWAY && status !=3D ICQ_STATUS_OFFLINE) - { - if (autoAwayMess) + } + else if ( (autoAwayTime > 0) && + (unsigned long)idleTime > (unsigned long)(autoAwayTime * 600= 00)) + { + if (status !=3D ICQ_STATUS_AWAY && status !=3D ICQ_STATUS_OFFLINE) { - SARList &sar =3D gSARManager.Fetch(SAR_AWAY); - ICQOwner *o =3D gUserManager.FetchOwner(LOCK_W); - if (o !=3D 0) + if (autoAwayMess) { - o->SetAutoResponse(QString(sar[autoAwayMess-1]->AutoResponse()).= local8Bit()); - gUserManager.DropOwner(); + SARList &sar =3D gSARManager.Fetch(SAR_AWAY); + ICQOwner *o =3D gUserManager.FetchOwner(nPPID, LOCK_W); + if (o !=3D 0) + { + o->SetAutoResponse(QString(sar[autoAwayMess-1]->AutoResponse()= )=2Elocal8Bit()); + gUserManager.DropOwner(nPPID); + } + gSARManager.Drop(); } - gSARManager.Drop(); + + changeStatus(ICQ_STATUS_AWAY, nPPID); + bTempAutoAway =3D true; } - - changeStatus(ICQ_STATUS_AWAY); - bAutoAway =3D true; - } - } - else - { - if (bAutoOffline) - { - if (bAutoNA && bAutoAway) + } + else + { + if (bAutoOffline) { - changeStatus(ICQ_STATUS_ONLINE); - bAutoOffline =3D bAutoNA =3D bAutoAway =3D false; + if (bAutoNA && bAutoAway) + { + changeStatus(ICQ_STATUS_ONLINE, nPPID); + bTempAutoOffline =3D bTempAutoNA =3D bTempAutoAway =3D false; + } + else if (bAutoNA) + { + changeStatus(ICQ_STATUS_AWAY, nPPID); + bTempAutoNA =3D bTempAutoOffline =3D false; + } + else + { + changeStatus(ICQ_STATUS_NA, nPPID); + bTempAutoOffline =3D false; + } } else if (bAutoNA) { - changeStatus(ICQ_STATUS_AWAY); - bAutoNA =3D bAutoOffline =3D false; + if (bAutoAway) + { + changeStatus(ICQ_STATUS_ONLINE, nPPID); + bTempAutoNA =3D bTempAutoAway =3D false; + } + else + { + changeStatus(ICQ_STATUS_AWAY, nPPID); + bTempAutoNA =3D false; + } } - else + else if (bAutoAway) { - changeStatus(ICQ_STATUS_NA); - bAutoOffline =3D false; + changeStatus(ICQ_STATUS_ONLINE, nPPID); + bTempAutoAway =3D false; } } - else if (bAutoNA) - { - if (bAutoAway) - { - changeStatus(ICQ_STATUS_ONLINE); - bAutoNA =3D bAutoAway =3D false; - } - else - { - changeStatus(ICQ_STATUS_AWAY); - bAutoNA =3D false; - } - } - else if (bAutoAway) - { - changeStatus(ICQ_STATUS_ONLINE); - bAutoAway =3D false; - } - } + } + FOR_EACH_PROTO_PLUGIN_END + =20 + bAutoOffline =3D bTempAutoOffline; + bAutoNA =3D bTempAutoNA; + bAutoAway =3D bTempAutoAway; =20 #endif // USE_SCRNSAVER } |