diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-21 18:12:59 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-21 18:12:59 +0000 |
commit | 530ca4410d99e166f4bbf1d6ba23e348a53d4743 (patch) | |
tree | ddda1c7cbabb42b550acaa5d5512f5d235b48a25 | |
parent | 72fe92f13d8cc335b0a05a702b99f52811898786 (diff) |
change of idle switching behavior:
- we switch to idle from ANY online status, despite invisible, because idle is not a status, it's just a program state;
- we remove the saved status instead of setting it to zero
git-svn-id: http://svn.miranda-ng.org/main/trunk@4151 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | src/core/stdautoaway/autoaway.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/core/stdautoaway/autoaway.cpp b/src/core/stdautoaway/autoaway.cpp index 0062d107e2..55cd6289fa 100644 --- a/src/core/stdautoaway/autoaway.cpp +++ b/src/core/stdautoaway/autoaway.cpp @@ -46,7 +46,7 @@ static bool Proto_IsAccountLocked(PROTOACCOUNT* pa) static void Proto_SetStatus(const char* szProto, unsigned status)
{
- if ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
+ if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
TCHAR* awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, (WPARAM) status, (LPARAM) szProto);
if ((INT_PTR)awayMsg == CALLSERVICE_NOTFOUND) {
char* awayMsgA = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM) status, (LPARAM) szProto);
@@ -78,28 +78,36 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) for (int i=0; i < numAccounts; i++) {
PROTOACCOUNT* pa = accounts[i];
+ if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa))
+ continue;
- if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) continue;
+ int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
+ if (currentstatus < ID_STATUS_ONLINE || currentstatus == ID_STATUS_INVISIBLE)
+ continue;
int statusbits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
- int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
int status = mii.aaStatus;
if ( !(statusbits & Proto_Status2Flag(status))) {
// the protocol doesnt support the given status
if (statusbits & Proto_Status2Flag(ID_STATUS_AWAY))
status = ID_STATUS_AWAY;
}
- if (currentstatus >= ID_STATUS_ONLINE && currentstatus != ID_STATUS_INVISIBLE) {
- if ((lParam & IDF_ISIDLE) && (currentstatus == ID_STATUS_ONLINE || currentstatus == ID_STATUS_FREECHAT)) {
- db_set_b(NULL, AA_MODULE, pa->szModuleName, 1);
- Proto_SetStatus(pa->szModuleName, status);
- }
- else if ( !(lParam & IDF_ISIDLE) && db_get_b(NULL, AA_MODULE, pa->szModuleName, 0)) {
- // returning from idle and this proto was set away, set it back
- db_set_b(NULL, AA_MODULE, pa->szModuleName, 0);
- if ( !mii.aaLock)
- Proto_SetStatus(pa->szModuleName, ID_STATUS_ONLINE);
- } } }
+ if (lParam & IDF_ISIDLE) {
+ // save old status of account and set to given status
+ db_set_w(NULL, AA_MODULE, pa->szModuleName, currentstatus);
+ Proto_SetStatus(pa->szModuleName, status);
+ }
+ else {
+ int oldstatus = db_get_w(NULL, AA_MODULE, pa->szModuleName, 0);
+ if (oldstatus < ID_STATUS_ONLINE)
+ continue;
+
+ // returning from idle and this accout was set away, set it back
+ db_unset(NULL, AA_MODULE, pa->szModuleName);
+ if (!mii.aaLock)
+ Proto_SetStatus(pa->szModuleName, oldstatus);
+ }
+ }
if (mii.idlesoundsoff)
iBreakSounds = (lParam & IDF_ISIDLE) != 0;
|