Changeset 4606
- Timestamp:
- 09/10/06 16:47:43 (2 years ago)
- Files:
-
- 1 modified
-
trunk/qt-gui/src/mainwin.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt-gui/src/mainwin.cpp
r4555 r4606 3961 3961 static bool bAutoOffline = false; 3962 3962 3963 // Fetch current status 3964 unsigned short status = ICQ_STATUS_OFFLINE; 3965 ICQOwner *o = gUserManager.FetchOwner(LOCK_R); 3966 if (o != NULL) 3967 { 3968 status = o->Status(); 3969 gUserManager.DropOwner(); 3970 } 3963 bool bTempAutoAway = false; 3964 bool bTempAutoNA = false; 3965 bool bTempAutoOffline = false; 3971 3966 3972 3967 if (mit_info == NULL) … … 3993 3988 Time idleTime = mit_info->idle; 3994 3989 3995 // Check no one changed the status behind our back 3996 if ( (bAutoOffline && status != ICQ_STATUS_OFFLINE) || 3997 (bAutoNA && status != ICQ_STATUS_NA && !bAutoOffline) || 3998 (bAutoAway && status != ICQ_STATUS_AWAY && !bAutoNA && !bAutoOffline) ) 3999 { 4000 bAutoOffline = false; 4001 bAutoNA = false; 4002 bAutoAway = false; 4003 return; 4004 } 4005 4006 // gLog.Info("offl %d, n/a %d, away %d idlt %d\n", 4007 // bAutoOffline, bAutoNA, bAutoAway, idleTime); 4008 4009 if ( (autoOfflineTime > 0) && 4010 (unsigned long)idleTime > (unsigned long)(autoOfflineTime * 60000)) 4011 { 4012 if (status != ICQ_STATUS_OFFLINE) 4013 { 4014 changeStatus(ICQ_STATUS_OFFLINE); 4015 bAutoOffline = true; 4016 bAutoAway = (status == ICQ_STATUS_ONLINE || bAutoAway); 4017 bAutoNA = ((status == ICQ_STATUS_AWAY && bAutoAway) || bAutoNA); 4018 } 4019 } 4020 else if ( (autoNATime > 0) && 4021 (unsigned long)idleTime > (unsigned long)(autoNATime * 60000)) 4022 { 4023 if (status != ICQ_STATUS_NA && status != ICQ_STATUS_OFFLINE) 4024 { 4025 if (autoNAMess) 3990 // Go through each protocol, as the statuses may differ 3991 FOR_EACH_PROTO_PLUGIN_START(licqDaemon) 3992 { 3993 unsigned long nPPID = (*_ppit)->PPID(); 3994 3995 // Fetch current status 3996 unsigned short status = ICQ_STATUS_OFFLINE; 3997 ICQOwner *o = gUserManager.FetchOwner(nPPID, LOCK_R); 3998 if (o != NULL) 3999 { 4000 status = o->Status(); 4001 gUserManager.DropOwner(nPPID); 4002 } 4003 4004 // Check no one changed the status behind our back 4005 if ( (bAutoOffline && status != ICQ_STATUS_OFFLINE) || 4006 (bAutoNA && status != ICQ_STATUS_NA && !bAutoOffline) || 4007 (bAutoAway && status != ICQ_STATUS_AWAY && !bAutoNA && !bAutoOffline) ) 4008 { 4009 bAutoOffline = false; 4010 bAutoNA = false; 4011 bAutoAway = false; 4012 return; 4013 } 4014 4015 // gLog.Info("offl %d, n/a %d, away %d idlt %d\n", 4016 // bAutoOffline, bAutoNA, bAutoAway, idleTime); 4017 4018 if ( (autoOfflineTime > 0) && 4019 (unsigned long)idleTime > (unsigned long)(autoOfflineTime * 60000)) 4020 { 4021 if (status != ICQ_STATUS_OFFLINE) 4026 4022 { 4027 SARList &sar = gSARManager.Fetch(SAR_NA); 4028 ICQOwner *o = gUserManager.FetchOwner(LOCK_W); 4029 if (o != 0) 4023 changeStatus(ICQ_STATUS_OFFLINE, nPPID); 4024 bTempAutoOffline = true; 4025 bTempAutoAway = (status == ICQ_STATUS_ONLINE || bAutoAway); 4026 bTempAutoNA = ((status == ICQ_STATUS_AWAY && bAutoAway) || bAutoNA); 4027 } 4028 } 4029 else if ( (autoNATime > 0) && 4030 (unsigned long)idleTime > (unsigned long)(autoNATime * 60000)) 4031 { 4032 if (status != ICQ_STATUS_NA && status != ICQ_STATUS_OFFLINE) 4033 { 4034 if (autoNAMess) 4030 4035 { 4031 o->SetAutoResponse(QString(sar[autoNAMess-1]->AutoResponse()).local8Bit()); 4032 gUserManager.DropOwner(); 4036 SARList &sar = gSARManager.Fetch(SAR_NA); 4037 ICQOwner *o = gUserManager.FetchOwner(nPPID, LOCK_W); 4038 if (o != 0) 4039 { 4040 o->SetAutoResponse(QString(sar[autoNAMess-1]->AutoResponse()).local8Bit()); 4041 gUserManager.DropOwner(nPPID); 4042 } 4043 gSARManager.Drop(); 4033 4044 } 4034 gSARManager.Drop(); 4045 4046 changeStatus(ICQ_STATUS_NA, nPPID); 4047 bTempAutoNA = true; 4048 bTempAutoAway = true; 4035 4049 } 4036 4037 changeStatus(ICQ_STATUS_NA); 4038 bAutoNA = true; 4039 bAutoAway = true; 4040 } 4041 } 4042 else if ( (autoAwayTime > 0) && 4043 (unsigned long)idleTime > (unsigned long)(autoAwayTime * 60000)) 4044 { 4045 if (status != ICQ_STATUS_AWAY && status != ICQ_STATUS_OFFLINE) 4046 { 4047 if (autoAwayMess) 4050 } 4051 else if ( (autoAwayTime > 0) && 4052 (unsigned long)idleTime > (unsigned long)(autoAwayTime * 60000)) 4053 { 4054 if (status != ICQ_STATUS_AWAY && status != ICQ_STATUS_OFFLINE) 4048 4055 { 4049 SARList &sar = gSARManager.Fetch(SAR_AWAY); 4050 ICQOwner *o = gUserManager.FetchOwner(LOCK_W); 4051 if (o != 0) 4056 if (autoAwayMess) 4052 4057 { 4053 o->SetAutoResponse(QString(sar[autoAwayMess-1]->AutoResponse()).local8Bit()); 4054 gUserManager.DropOwner(); 4058 SARList &sar = gSARManager.Fetch(SAR_AWAY); 4059 ICQOwner *o = gUserManager.FetchOwner(nPPID, LOCK_W); 4060 if (o != 0) 4061 { 4062 o->SetAutoResponse(QString(sar[autoAwayMess-1]->AutoResponse()).local8Bit()); 4063 gUserManager.DropOwner(nPPID); 4064 } 4065 gSARManager.Drop(); 4055 4066 } 4056 gSARManager.Drop(); 4067 4068 changeStatus(ICQ_STATUS_AWAY, nPPID); 4069 bTempAutoAway = true; 4057 4070 } 4058 4059 changeStatus(ICQ_STATUS_AWAY); 4060 bAutoAway = true; 4061 } 4062 } 4063 else 4064 { 4065 if (bAutoOffline) 4066 { 4067 if (bAutoNA && bAutoAway) 4071 } 4072 else 4073 { 4074 if (bAutoOffline) 4068 4075 { 4069 changeStatus(ICQ_STATUS_ONLINE); 4070 bAutoOffline = bAutoNA = bAutoAway = false; 4076 if (bAutoNA && bAutoAway) 4077 { 4078 changeStatus(ICQ_STATUS_ONLINE, nPPID); 4079 bTempAutoOffline = bTempAutoNA = bTempAutoAway = false; 4080 } 4081 else if (bAutoNA) 4082 { 4083 changeStatus(ICQ_STATUS_AWAY, nPPID); 4084 bTempAutoNA = bTempAutoOffline = false; 4085 } 4086 else 4087 { 4088 changeStatus(ICQ_STATUS_NA, nPPID); 4089 bTempAutoOffline = false; 4090 } 4071 4091 } 4072 4092 else if (bAutoNA) 4073 4093 { 4074 changeStatus(ICQ_STATUS_AWAY); 4075 bAutoNA = bAutoOffline = false; 4094 if (bAutoAway) 4095 { 4096 changeStatus(ICQ_STATUS_ONLINE, nPPID); 4097 bTempAutoNA = bTempAutoAway = false; 4098 } 4099 else 4100 { 4101 changeStatus(ICQ_STATUS_AWAY, nPPID); 4102 bTempAutoNA = false; 4103 } 4076 4104 } 4077 else 4105 else if (bAutoAway) 4078 4106 { 4079 changeStatus(ICQ_STATUS_ NA);4080 b AutoOffline= false;4107 changeStatus(ICQ_STATUS_ONLINE, nPPID); 4108 bTempAutoAway = false; 4081 4109 } 4082 4110 } 4083 else if (bAutoNA) 4084 { 4085 if (bAutoAway) 4086 { 4087 changeStatus(ICQ_STATUS_ONLINE); 4088 bAutoNA = bAutoAway = false; 4089 } 4090 else 4091 { 4092 changeStatus(ICQ_STATUS_AWAY); 4093 bAutoNA = false; 4094 } 4095 } 4096 else if (bAutoAway) 4097 { 4098 changeStatus(ICQ_STATUS_ONLINE); 4099 bAutoAway = false; 4100 } 4101 } 4111 } 4112 FOR_EACH_PROTO_PLUGIN_END 4113 4114 bAutoOffline = bTempAutoOffline; 4115 bAutoNA = bTempAutoNA; 4116 bAutoAway = bTempAutoAway; 4102 4117 4103 4118 #endif // USE_SCRNSAVER
