diff options
author | George Hazan <ghazan@miranda.im> | 2017-10-09 19:57:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-10-09 19:57:09 +0300 |
commit | 85f20195ec2408938c5c06821914d1cc4dce1b41 (patch) | |
tree | a955886852026c09c7fc5fc48597211643947ecb /plugins | |
parent | e9fd088531d1520799f8ac48086cc9ae6656395e (diff) |
StatusManager:
- fix for the 'Ignore locked account statuses' checkbox behaviour;
- massive code cleaning;
- version bump
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExternalAPI/m_statusplugins.h | 20 | ||||
-rw-r--r-- | plugins/MyDetails/src/data.cpp | 12 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp | 110 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp | 10 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp | 168 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.cpp | 274 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.h | 8 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/ks_options.cpp | 1 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_options.cpp | 283 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/startupstatus.cpp | 68 | ||||
-rw-r--r-- | plugins/StatusManager/src/commonstatus.cpp | 40 | ||||
-rw-r--r-- | plugins/StatusManager/src/confirmdialog.cpp | 224 | ||||
-rw-r--r-- | plugins/StatusManager/src/version.h | 2 |
13 files changed, 601 insertions, 619 deletions
diff --git a/plugins/ExternalAPI/m_statusplugins.h b/plugins/ExternalAPI/m_statusplugins.h index 63e39e80b3..1e1c57f2a3 100644 --- a/plugins/ExternalAPI/m_statusplugins.h +++ b/plugins/ExternalAPI/m_statusplugins.h @@ -23,12 +23,11 @@ // -- common status -- (all three plugins)
typedef struct {
- int cbSize;
- char *szName; // pointer to protocol modulename
- TCHAR *szMsg; // pointer to the status message (may be NULL)
- WORD status; // the status
- WORD lastStatus;// last status
- TCHAR *tszAccName;
+ char *m_szName; // pointer to protocol modulename
+ TCHAR *m_szMsg; // pointer to the status message (may be NULL)
+ WORD m_status; // the status
+ WORD m_lastStatus;// last status
+ TCHAR *m_tszAccName;
} PROTOCOLSETTINGEX;
// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility)
@@ -136,11 +135,10 @@ typedef struct { __inline static int announce_status_change(char *szProto, int newstatus, TCHAR *szMsg) {
PROTOCOLSETTINGEX ps = { 0 };
- ps.cbSize = sizeof(PROTOCOLSETTINGEX);
- ps.lastStatus = szProto != NULL ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
- ps.status = newstatus;
- ps.szMsg = szMsg;
- ps.szName = szProto;
+ ps.m_lastStatus = szProto != NULL ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ ps.m_status = newstatus;
+ ps.m_szMsg = szMsg;
+ ps.m_szName = szProto;
return CallService(MS_KS_ANNOUNCESTATUSCHANGE, 0, (LPARAM)&ps);
}
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 7454b175b8..d0ab1a3ba2 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -81,8 +81,7 @@ Protocol::Protocol(const char *aName, const wchar_t *descr) }
Protocol::~Protocol()
-{
-}
+{}
void Protocol::lcopystr(wchar_t *dest, wchar_t *src, size_t maxlen)
{
@@ -161,16 +160,15 @@ void Protocol::SetStatus(int aStatus) PROTOCOLSETTINGEX **pse = (PROTOCOLSETTINGEX **)mir_calloc(pCount * sizeof(PROTOCOLSETTINGEX *));
for (i = 0; i < pCount; i++) {
pse[i] = (PROTOCOLSETTINGEX *)mir_calloc(sizeof(PROTOCOLSETTINGEX));
- pse[i]->szName = "";
+ pse[i]->m_szName = "";
}
- pse[0]->cbSize = sizeof(PROTOCOLSETTINGEX);
- pse[0]->status = aStatus;
- pse[0]->szName = name;
+ pse[0]->m_status = aStatus;
+ pse[0]->m_szName = name;
wchar_t status_msg[256];
GetStatusMsg(aStatus, status_msg, _countof(status_msg));
- pse[0]->szMsg = status_msg;
+ pse[0]->m_szMsg = status_msg;
CallService(MS_CS_SETSTATUSEX, (WPARAM)&pse, 0);
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp index 2484440b2a..b18d1ef558 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp @@ -1,25 +1,25 @@ /* - AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org) - Copyright 2003-2006 P. Boon - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org) + Copyright 2003-2006 P. Boon + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "..\stdafx.h" -extern char *StatusModeToDbSetting(int status,const char *suffix); +extern char *StatusModeToDbSetting(int status, const char *suffix); void DisableDialog(HWND hwndDlg) { @@ -35,49 +35,47 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L static AAMSGSETTING** settings; static int last, count; - switch( msg ) { + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); { - ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), ServiceExists(MS_VARS_SHOWHELP)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), ServiceExists(MS_VARS_SHOWHELP) ? SW_SHOW : SW_HIDE); count = 0; last = -1; - + PROTOACCOUNT** proto; int protoCount = 0; Proto_EnumAccounts(&protoCount, &proto); - if (protoCount <= 0) - { + if (protoCount <= 0) { DisableDialog(hwndDlg); break; } DWORD protoModeMsgFlags = 0; - for (int i=0; i < protoCount; i++) + for (int i = 0; i < protoCount; i++) if (CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND & ~PF1_INDIVMODEMSG) - protoModeMsgFlags |= CallProtoService( proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0 ); + protoModeMsgFlags |= CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); - if (protoModeMsgFlags == 0) - { + if (protoModeMsgFlags == 0) { DisableDialog(hwndDlg); break; } - settings = ( AAMSGSETTING** )malloc(sizeof(AAMSGSETTING*)); + settings = (AAMSGSETTING**)malloc(sizeof(AAMSGSETTING*)); count = 0; - for (int i=0; i < _countof(statusModeList); i++ ) { - if ( !( protoModeMsgFlags & Proto_Status2Flag( statusModeList[i] ))) + for (int i = 0; i < _countof(statusModeList); i++) { + if (!(protoModeMsgFlags & Proto_Status2Flag(statusModeList[i]))) continue; int j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModeList[i], 0)); - SendDlgItemMessage( hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModeList[i] ); - settings = ( AAMSGSETTING** )realloc(settings, (count+1)*sizeof(AAMSGSETTING*)); - settings[count] = ( AAMSGSETTING* )malloc(sizeof(AAMSGSETTING)); + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModeList[i]); + settings = (AAMSGSETTING**)realloc(settings, (count + 1) * sizeof(AAMSGSETTING*)); + settings[count] = (AAMSGSETTING*)malloc(sizeof(AAMSGSETTING)); settings[count]->status = statusModeList[i]; DBVARIANT dbv; - if ( !db_get(NULL, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i],SETTING_STATUSMSG), &dbv)) { - settings[count]->msg = ( char* )malloc(mir_strlen(dbv.pszVal) + 1); + if (!db_get(NULL, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_STATUSMSG), &dbv)) { + settings[count]->msg = (char*)malloc(mir_strlen(dbv.pszVal) + 1); mir_strcpy(settings[count]->msg, dbv.pszVal); db_free(&dbv); } @@ -86,40 +84,40 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L settings[count]->useCustom = db_get_b(NULL, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_MSGCUSTOM), FALSE); count += 1; } - SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,0,0); - SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_STATUS,CBN_SELCHANGE),0); + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); } break; case WM_COMMAND: - if ( ((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED)) && ((HWND)lParam == GetFocus())) + if (((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED)) && ((HWND)lParam == GetFocus())) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - - switch(LOWORD(wParam)) { + + switch (LOWORD(wParam)) { case IDC_RADUSEMIRANDA: CheckDlgButton(hwndDlg, IDC_RADUSECUSTOM, BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADUSEMIRANDA) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_STATUSMSG), IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM)); EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM)); - settings[SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_GETCURSEL,0,0)]->useCustom = IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM); + settings[SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0)]->useCustom = IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM); break; case IDC_RADUSECUSTOM: CheckDlgButton(hwndDlg, IDC_RADUSEMIRANDA, BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_STATUSMSG), IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM)); EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM)); - settings[SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_GETCURSEL,0,0)]->useCustom = IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM); + settings[SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0)]->useCustom = IsDlgButtonChecked(hwndDlg, IDC_RADUSECUSTOM); break; case IDC_STATUS: - if ( HIWORD( wParam ) == CBN_SELCHANGE ) { - int i = SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_GETCURSEL,0,0); + if (HIWORD(wParam) == CBN_SELCHANGE) { + int i = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0); int len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - if ( last != -1 ) { + if (last != -1) { if (settings[last]->msg == NULL) - settings[last]->msg = ( char* )malloc(len+1); + settings[last]->msg = (char*)malloc(len + 1); else - settings[last]->msg = (char*)realloc(settings[last]->msg, len+1); - GetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[last]->msg, (len+1)); + settings[last]->msg = (char*)realloc(settings[last]->msg, len + 1); + GetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[last]->msg, (len + 1)); } if (i != -1) { @@ -156,24 +154,24 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_STATUS,CBN_SELCHANGE),0); - for (int i=0; i < count; i++ ) { - db_set_b(NULL, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status,SETTING_MSGCUSTOM), (BYTE)settings[i]->useCustom); - if ( (settings[i]->useCustom) && (settings[i]->msg != NULL) && (settings[i]->msg[0] != '\0')) - db_set_s(NULL, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status,SETTING_STATUSMSG), settings[i]->msg); + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); + for (int i = 0; i < count; i++) { + db_set_b(NULL, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status, SETTING_MSGCUSTOM), (BYTE)settings[i]->useCustom); + if ((settings[i]->useCustom) && (settings[i]->msg != NULL) && (settings[i]->msg[0] != '\0')) + db_set_s(NULL, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status, SETTING_STATUSMSG), settings[i]->msg); } break; } break; - + case WM_DESTROY: - for (int i=0; i < count; i++ ) { + for (int i = 0; i < count; i++) { free(settings[i]->msg); free(settings[i]); } free(settings); break; } - + return FALSE; } diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp index df1055b5df..4b38ce59f8 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp @@ -121,7 +121,7 @@ static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting) int AAACompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2) { - return mir_strcmp(p1->szName, p2->szName); + return mir_strcmp(p1->m_szName, p2->m_szName); } static TAAAProtoSettingList optionSettings(10, AAACompareSettings); @@ -147,7 +147,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM { for (int i = 0; i < optionSettings.getCount(); i++) { TAAAProtoSetting &p = optionSettings[i]; - int item = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)p.tszAccName); + int item = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)p.m_tszAccName); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_SETITEMDATA, item, (LPARAM)&p); } } @@ -179,7 +179,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM int flags = 0; if (!bSettingSame) - flags = CallProtoService(setting->szName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(setting->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); + flags = CallProtoService(setting->m_szName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(setting->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); LVITEM lvItem = { 0 }; lvItem.mask = LVIF_TEXT | LVIF_PARAM; @@ -200,7 +200,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM { int flags = 0; if (!bSettingSame) - flags = CallProtoService(setting->szName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(setting->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); + flags = CallProtoService(setting->m_szName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(setting->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); // clear box and add new status, loop status and check if compatible with proto SendDlgItemMessage(hwndDlg, IDC_LV1STATUS, CB_RESETCONTENT, 0, 0); @@ -340,7 +340,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM WriteAutoAwaySetting(*sameSetting, SETTING_ALL); else { for (int i = 0; i < optionSettings.getCount(); i++) - WriteAutoAwaySetting(optionSettings[i], optionSettings[i].szName); + WriteAutoAwaySetting(optionSettings[i], optionSettings[i].m_szName); } AAALoadOptions(autoAwaySettings, FALSE); } diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp index b9647816f2..81361b5c73 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp @@ -1,22 +1,22 @@ /* - AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org) - Copyright 2003-2006 P. Boon + AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org) + Copyright 2003-2006 P. Boon - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Some code is copied from Miranda's AutoAway module */ @@ -25,9 +25,9 @@ int hAAALangpack = 0; #ifdef _DEBUG - #define SECS_PER_MINUTE 20 /* speedup */ +#define SECS_PER_MINUTE 20 /* speedup */ #else - #define SECS_PER_MINUTE 60 /* default I believe */ +#define SECS_PER_MINUTE 60 /* default I believe */ #endif ///////////////////////////////////////////////////////////////////////////////////////// @@ -36,24 +36,23 @@ TAAAProtoSettingList autoAwaySettings(10, AAACompareSettings); TAAAProtoSetting::TAAAProtoSetting(PROTOACCOUNT *pa) { - cbSize = sizeof(PROTOCOLSETTINGEX); - szName = pa->szModuleName; - tszAccName = pa->tszAccountName; - lastStatus = status = originalStatusMode = ID_STATUS_CURRENT; - szMsg = NULL; + m_szName = pa->szModuleName; + m_tszAccName = pa->tszAccountName; + m_lastStatus = m_status = originalStatusMode = ID_STATUS_CURRENT; + m_szMsg = NULL; curState = ACTIVE; mStatus = FALSE; } TAAAProtoSetting::~TAAAProtoSetting() { - free(szMsg); + free(m_szMsg); } ///////////////////////////////////////////////////////////////////////////////////////// HANDLE hAAAModuleLoadedHook = NULL, - hStateChangedEvent = NULL; +hStateChangedEvent = NULL; static BOOL ignoreLockKeys = FALSE; static BOOL ignoreSysKeys = FALSE; @@ -66,7 +65,7 @@ HHOOK hMirandaMouseHook = NULL; HHOOK hMirandaKeyBoardHook = NULL; #pragma data_seg("Shared") DWORD lastInput = 0; -POINT lastMousePos = {0}; +POINT lastMousePos = { 0 }; HHOOK hMouseHook = NULL; HHOOK hKeyBoardHook = NULL; #pragma data_seg() @@ -81,14 +80,11 @@ static LRESULT CALLBACK MouseHookFunction(int code, WPARAM wParam, LPARAM lParam static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK MirandaMouseHookFunction(int code, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK MirandaKeyBoardHookFunction(int code, WPARAM wParam, LPARAM lParam); -BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved); +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); -static VOID CALLBACK AutoAwayTimer(HWND hwnd,UINT message,UINT_PTR idEvent,DWORD dwTime); -extern int AutoAwayOptInitialise(WPARAM wParam,LPARAM lParam); -extern int AutoAwayMsgOptInitialise(WPARAM wParam,LPARAM lParam); -extern int SetStatus(WPARAM wParam, LPARAM lParam); -extern int ShowConfirmDialog(WPARAM wParam, LPARAM lParam); -extern char *StatusModeToDbSetting(int status,const char *suffix); +static VOID CALLBACK AutoAwayTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); +extern int AutoAwayOptInitialise(WPARAM wParam, LPARAM lParam); +extern char *StatusModeToDbSetting(int status, const char *suffix); ///////////////////////////////////////////////////////////////////////////////////////// // Load from DB @@ -116,7 +112,7 @@ void AAALoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) if ((db_get_b(NULL, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) && !override) protoName = SETTING_ALL; else - protoName = loadSettings[i].szName; + protoName = loadSettings[i].m_szName; LoadAutoAwaySetting(loadSettings[i], protoName); if (!override) { if (loadSettings[i].optionFlags & FLAG_MONITORMIRANDA) @@ -167,8 +163,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) log_debugA("ProcessProtoAck: ack->szModule: %s", ack->szModule); for (int i = 0; i < autoAwaySettings.getCount(); i++) { TAAAProtoSetting &p = autoAwaySettings[i]; - log_debugA("chk: %s", p.szName); - if (!mir_strcmp(p.szName, ack->szModule)) { + log_debugA("chk: %s", p.m_szName); + if (!mir_strcmp(p.m_szName, ack->szModule)) { log_debugA("ack->szModule: %s p.statusChanged: %d", ack->szModule, p.statusChanged); if (!p.statusChanged) p.mStatus = TRUE; @@ -193,7 +189,7 @@ int OnAAAAccChanged(WPARAM wParam, LPARAM lParam) case PRAC_REMOVED: for (int i = 0; i < autoAwaySettings.getCount(); i++) { - if (!mir_strcmp(autoAwaySettings[i].szName, pa->szModuleName)) { + if (!mir_strcmp(autoAwaySettings[i].m_szName, pa->szModuleName)) { autoAwaySettings.remove(i); break; } @@ -207,11 +203,11 @@ int OnAAAAccChanged(WPARAM wParam, LPARAM lParam) static char* status2descr(int status) { switch (status) { - case ACTIVE: return "ACTIVE"; - case STATUS1_SET: return "STATUS1_SET"; - case STATUS2_SET: return "STATUS2_SET"; - case SET_ORGSTATUS: return "SET_ORGSTATUS"; - case HIDDEN_ACTIVE: return "HIDDEN_ACTIVE"; + case ACTIVE: return "ACTIVE"; + case STATUS1_SET: return "STATUS1_SET"; + case STATUS2_SET: return "STATUS2_SET"; + case SET_ORGSTATUS: return "SET_ORGSTATUS"; + case HIDDEN_ACTIVE: return "HIDDEN_ACTIVE"; } return "ERROR"; } @@ -224,27 +220,27 @@ static int changeState(TAAAProtoSetting &setting, STATES newState) setting.oldState = setting.curState; setting.curState = newState; - log_debugA("%s state change: %s -> %s", setting.szName, status2descr(setting.oldState), status2descr(setting.curState)); + log_debugA("%s state change: %s -> %s", setting.m_szName, status2descr(setting.oldState), status2descr(setting.curState)); NotifyEventHooks(hStateChangedEvent, 0, (LPARAM)&setting); if (setting.curState != SET_ORGSTATUS && setting.curState != ACTIVE && setting.statusChanged) { /* change the awaymessage */ - if (setting.szMsg != NULL) { - free(setting.szMsg); - setting.szMsg = NULL; + if (setting.m_szMsg != NULL) { + free(setting.m_szMsg); + setting.m_szMsg = NULL; } - if (db_get_b(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.status, SETTING_MSGCUSTOM), FALSE)) { + if (db_get_b(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_MSGCUSTOM), FALSE)) { DBVARIANT dbv; - if (!db_get_ws(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.status, SETTING_STATUSMSG), &dbv)) { - setting.szMsg = wcsdup(dbv.ptszVal); + if (!db_get_ws(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_STATUSMSG), &dbv)) { + setting.m_szMsg = wcsdup(dbv.ptszVal); db_free(&dbv); } } } - else if (setting.szMsg != NULL) { - free(setting.szMsg); - setting.szMsg = NULL; + else if (setting.m_szMsg != NULL) { + free(setting.m_szMsg); + setting.m_szMsg = NULL; } return 0; @@ -257,7 +253,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) for (int i = 0; i < autoAwaySettings.getCount(); i++) { TAAAProtoSetting& aas = autoAwaySettings[i]; - aas.status = ID_STATUS_DISABLED; + aas.m_status = ID_STATUS_DISABLED; BOOL bTrigger = false; @@ -272,7 +268,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) int sts1Time = aas.awayTime * SECS_PER_MINUTE; int sts2Time = aas.naTime * SECS_PER_MINUTE; int sts1setTime = aas.sts1setTimer == 0 ? 0 : (GetTickCount() - aas.sts1setTimer) / 1000; - int currentMode = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); + int currentMode = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); if (aas.optionFlags & FLAG_ONSAVER) bTrigger |= IsScreenSaverRunning(); @@ -285,8 +281,8 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) if (aas.curState == ACTIVE) { if (((mouseStationaryTimer >= sts1Time && (aas.optionFlags & FLAG_ONMOUSE)) || bTrigger) && currentMode != aas.lv1Status && aas.statusFlags&StatusModeToProtoFlag(currentMode)) { /* from ACTIVE to STATUS1_SET */ - aas.lastStatus = aas.originalStatusMode = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); - aas.status = aas.lv1Status; + aas.m_lastStatus = aas.originalStatusMode = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); + aas.m_status = aas.lv1Status; aas.sts1setTimer = GetTickCount(); sts1setTime = 0; aas.statusChanged = statusChanged = TRUE; @@ -294,8 +290,8 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) } else if (mouseStationaryTimer >= sts2Time && currentMode == aas.lv1Status && currentMode != aas.lv2Status && (aas.optionFlags & FLAG_SETNA) && (aas.statusFlags & StatusModeToProtoFlag(currentMode))) { /* from ACTIVE to STATUS2_SET */ - aas.lastStatus = aas.originalStatusMode = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); - aas.status = aas.lv2Status; + aas.m_lastStatus = aas.originalStatusMode = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); + aas.m_status = aas.lv2Status; aas.statusChanged = statusChanged = TRUE; changeState(aas, STATUS2_SET); } @@ -305,19 +301,19 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) if ((mouseStationaryTimer < sts1Time && !bTrigger) && !(aas.optionFlags & FLAG_RESET)) { /* from STATUS1_SET to HIDDEN_ACTIVE */ changeState(aas, HIDDEN_ACTIVE); - aas.lastStatus = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); + aas.m_lastStatus = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); } else if (((mouseStationaryTimer < sts1Time) && !bTrigger) && - ((aas.optionFlags & FLAG_LV2ONINACTIVE) || (!(aas.optionFlags&FLAG_SETNA))) && - (aas.optionFlags & FLAG_RESET)) { + ((aas.optionFlags & FLAG_LV2ONINACTIVE) || (!(aas.optionFlags&FLAG_SETNA))) && + (aas.optionFlags & FLAG_RESET)) { /* from STATUS1_SET to SET_ORGSTATUS */ changeState(aas, SET_ORGSTATUS); } else if ((aas.optionFlags & FLAG_SETNA) && sts1setTime >= sts2Time) { /* when set STATUS2, currentMode doesn't have to be in the selected status list (statusFlags) */ /* from STATUS1_SET to STATUS2_SET */ - aas.lastStatus = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); - aas.status = aas.lv2Status; + aas.m_lastStatus = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); + aas.m_status = aas.lv2Status; aas.statusChanged = statusChanged = TRUE; changeState(aas, STATUS2_SET); } @@ -332,7 +328,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) /* from STATUS2_SET to HIDDEN_ACTIVE */ /* Remember: after status1 is set, and "only on inactive" is NOT set, it implies !reset. */ changeState(aas, HIDDEN_ACTIVE); - aas.lastStatus = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); + aas.m_lastStatus = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); } } @@ -345,19 +341,19 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) aas.mStatus = FALSE; } else if ((aas.optionFlags & FLAG_SETNA) && currentMode == aas.lv1Status && - currentMode != aas.lv2Status && (aas.statusFlags & StatusModeToProtoFlag(currentMode)) && - (mouseStationaryTimer >= sts2Time || (sts1setTime >= sts2Time && !(aas.optionFlags & FLAG_LV2ONINACTIVE)))) { + currentMode != aas.lv2Status && (aas.statusFlags & StatusModeToProtoFlag(currentMode)) && + (mouseStationaryTimer >= sts2Time || (sts1setTime >= sts2Time && !(aas.optionFlags & FLAG_LV2ONINACTIVE)))) { /* HIDDEN_ACTIVE to STATUS2_SET */ - aas.lastStatus = aas.originalStatusMode = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); - aas.status = aas.lv2Status; + aas.m_lastStatus = aas.originalStatusMode = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); + aas.m_status = aas.lv2Status; aas.statusChanged = statusChanged = TRUE; changeState(aas, STATUS2_SET); } } if (aas.curState == SET_ORGSTATUS) { /* SET_ORGSTATUS to ACTIVE */ - aas.lastStatus = CallProtoService(aas.szName, PS_GETSTATUS, 0, 0); - aas.status = aas.originalStatusMode; + aas.m_lastStatus = CallProtoService(aas.m_szName, PS_GETSTATUS, 0, 0); + aas.m_status = aas.originalStatusMode; confirm = (aas.optionFlags&FLAG_CONFIRM) ? TRUE : confirm; aas.statusChanged = statusChanged = TRUE; changeState(aas, ACTIVE); @@ -369,11 +365,11 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) if (confirm || statusChanged) { TAAAProtoSettingList ps = autoAwaySettings; for (int i = 0; i < ps.getCount(); i++) { - if (ps[i].szMsg) - ps[i].szMsg = wcsdup(ps[i].szMsg); + if (ps[i].m_szMsg) + ps[i].m_szMsg = wcsdup(ps[i].m_szMsg); - if (ps[i].status == ID_STATUS_DISABLED) - ps[i].szName = ""; + if (ps[i].m_status == ID_STATUS_DISABLED) + ps[i].m_szName = ""; } if (confirm) @@ -441,13 +437,12 @@ static LRESULT CALLBACK MirandaKeyBoardHookFunction(int code, WPARAM wParam, LPA if (code >= 0) { if (ignoreAltCombo) { if (((GetKeyState(VK_MENU) < 0) || (wParam == VK_MENU)) || - ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) || - ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) || - ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) || - ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) || - ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) || - ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) - { + ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) || + ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) || + ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) || + ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) || + ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) || + ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) { return CallNextHookEx(hMirandaKeyBoardHook, code, wParam, lParam); } } @@ -504,13 +499,12 @@ static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lPa if (code >= 0) { if (ignoreAltCombo) { if (((GetKeyState(VK_MENU) < 0) || (wParam == VK_MENU)) || - ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) || - ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) || - ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) || - ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) || - ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) || - ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) - { + ((GetKeyState(VK_TAB) < 0) || (wParam == VK_TAB)) || + ((GetKeyState(VK_SHIFT) < 0) || (wParam == VK_SHIFT)) || + ((GetKeyState(VK_CONTROL) < 0) || (wParam == VK_CONTROL)) || + ((GetKeyState(VK_ESCAPE) < 0) || (wParam == VK_ESCAPE)) || + ((GetKeyState(VK_LWIN) < 0) || (wParam == VK_LWIN)) || + ((GetKeyState(VK_RWIN) < 0) || (wParam == VK_RWIN))) { return CallNextHookEx(hKeyBoardHook, code, wParam, lParam); } } @@ -600,4 +594,4 @@ void AdvancedAutoAwayUnload() { UnhookEvent(hAAAModuleLoadedHook); DestroyHookableEvent(hStateChangedEvent); -}
\ No newline at end of file +} diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index d518b47edc..f0c0051e60 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -21,7 +21,8 @@ int hKSLangpack = 0; -struct TimerInfo { +struct TimerInfo +{ int timer; int timeout; BOOL restart; @@ -43,12 +44,12 @@ static HANDLE hCSStatusChangeExHook = NULL; static HWND hMessageWindow = NULL; -static int CompareConnections(const TConnectionSettings *p1, const TConnectionSettings *p2) +static int CompareConnections(const TKSSettings *p1, const TKSSettings *p2) { - return mir_strcmp(p1->szName, p2->szName); + return mir_strcmp(p1->m_szName, p2->m_szName); } -static OBJLIST<TConnectionSettings> connectionSettings(10, CompareConnections); +static OBJLIST<TKSSettings> connectionSettings(10, CompareConnections); static UINT_PTR checkConnectionTimerId = 0; static UINT_PTR afterCheckTimerId = 0; @@ -69,18 +70,15 @@ static int showConnectionPopups = 0; static int StartTimer(int timer, int timeout, BOOL restart); static int StopTimer(int timer); static void GetCurrentConnectionSettings(); -static int AssignStatus(TConnectionSettings* connSetting, int status, int lastStatus, wchar_t *szMsg); static int ProcessProtoAck(WPARAM wParam, LPARAM lParam); static VOID CALLBACK CheckConnectingTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); static VOID CALLBACK CheckAckStatusTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); static int StatusChange(WPARAM wParam, LPARAM lParam); static int CSStatusChange(WPARAM wParam, LPARAM lParam); static int CSStatusChangeEx(WPARAM wParam, LPARAM lParam); -static VOID CALLBACK StatusChangeTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); static VOID CALLBACK CheckConnectionTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); static int StopChecking(); static VOID CALLBACK AfterCheckTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); -static void ContinueslyCheckFunction(void *arg); static VOID CALLBACK CheckContinueslyTimer(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime); INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam); @@ -92,21 +90,20 @@ static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM // options.c extern int KeepStatusOptionsInit(WPARAM wparam, LPARAM); -TConnectionSettings::TConnectionSettings(PROTOACCOUNT *pa) +TKSSettings::TKSSettings(PROTOACCOUNT *pa) { - cbSize = sizeof(PROTOCOLSETTINGEX); - szName = pa->szModuleName; - tszAccName = pa->tszAccountName; - szMsg = NULL; + m_szName = pa->szModuleName; + m_tszAccName = pa->tszAccountName; + m_szMsg = NULL; int iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - AssignStatus(this, iStatus, iStatus, NULL); + AssignStatus(iStatus, iStatus, nullptr); } -TConnectionSettings::~TConnectionSettings() +TKSSettings::~TKSSettings() { - if (szMsg != NULL) - free(szMsg); + if (m_szMsg != NULL) + free(m_szMsg); } int KSLoadOptions() @@ -167,13 +164,13 @@ static void GetCurrentConnectionSettings() for (int i = 0; i < count; i++) if (IsSuitableProto(protos[i])) - connectionSettings.insert(new TConnectionSettings(protos[i])); + connectionSettings.insert(new TKSSettings(protos[i])); } static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() { mir_cslock lck(GenStatusCS); - PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(connectionSettings.getCount()*sizeof(PROTOCOLSETTINGEX *)); + PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(connectionSettings.getCount() * sizeof(PROTOCOLSETTINGEX *)); if (ps == NULL) { return NULL; } @@ -184,13 +181,12 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() return NULL; } - TConnectionSettings& cs = connectionSettings[i]; - ps[i]->cbSize = sizeof(PROTOCOLSETTINGEX); - ps[i]->lastStatus = cs.lastStatus; - ps[i]->status = cs.status; - ps[i]->szMsg = NULL; - ps[i]->szName = cs.szName; - ps[i]->tszAccName = cs.tszAccName; + TKSSettings& cs = connectionSettings[i]; + ps[i]->m_lastStatus = cs.m_lastStatus; + ps[i]->m_status = cs.m_status; + ps[i]->m_szMsg = NULL; + ps[i]->m_szName = cs.m_szName; + ps[i]->m_tszAccName = cs.m_tszAccName; } return ps; @@ -199,67 +195,71 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() static void FreeProtoSettings(PROTOCOLSETTINGEX** ps) { for (int i = 0; i < connectionSettings.getCount(); i++) { - if (ps[i]->szMsg != NULL) - free(ps[i]->szMsg); + if (ps[i]->m_szMsg != NULL) + free(ps[i]->m_szMsg); free(ps[i]); } free(ps); } -static int AssignStatus(TConnectionSettings* cs, int status, int lastStatus, wchar_t *szMsg) +int TKSSettings::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg) { - if (status < MIN_STATUS || status > MAX_STATUS) + if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) return -1; + if (iStatus != ID_STATUS_OFFLINE && m_status == ID_STATUS_DISABLED) + return -2; + if (!db_get_b(NULL, KSMODULENAME, SETTING_NOLOCKED, 0) && db_get_b(NULL, m_szName, "LockMainStatus", 0)) + return -3; mir_cslock lck(GenStatusCS); char dbSetting[128]; - mir_snprintf(dbSetting, "%s_enabled", cs->szName); - cs->lastStatus = lastStatus == 0 ? cs->status : lastStatus; + mir_snprintf(dbSetting, "%s_enabled", m_szName); + m_lastStatus = iLastStatus == 0 ? m_status : iLastStatus; if (!db_get_b(NULL, KSMODULENAME, dbSetting, 1)) - cs->status = ID_STATUS_DISABLED; - else if (status == ID_STATUS_LAST) - cs->status = cs->lastStatus; + m_status = ID_STATUS_DISABLED; + else if (m_status == ID_STATUS_LAST) + m_status = m_lastStatus; else - cs->status = status; + m_status = iStatus; - log_infoA("KeepStatus: assigning status %d to %s", cs->status, cs->szName); + log_infoA("KeepStatus: assigning status %d to %s", m_status, m_szName); - if (szMsg != NULL && mir_wstrcmp(szMsg, cs->szMsg)) { - if (cs->szMsg != NULL) - free(cs->szMsg); + if (pwszMsg != NULL && mir_wstrcmp(pwszMsg, m_szMsg)) { + if (m_szMsg != NULL) + free(m_szMsg); - cs->szMsg = wcsdup(szMsg); + m_szMsg = wcsdup(pwszMsg); } - else if (szMsg != cs->szMsg) { - if (cs->szMsg != NULL) - free(cs->szMsg); + else if (pwszMsg != m_szMsg) { + if (m_szMsg != NULL) + free(m_szMsg); - cs->szMsg = NULL; + m_szMsg = NULL; } return 0; } -static int GetStatus(const TConnectionSettings& cs) +static int GetStatus(const TKSSettings& cs) { - if (cs.status == ID_STATUS_CURRENT) - return CallProtoService(cs.szName, PS_GETSTATUS, 0, 0); + if (cs.m_status == ID_STATUS_CURRENT) + return CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); - return cs.status; + return cs.m_status; } static int SetCurrentStatus() { PROTOCOLSETTINGEX **ps = GetCurrentProtoSettingsCopy(); for (int i = 0; i < connectionSettings.getCount(); i++) { - int realStatus = CallProtoService(ps[i]->szName, PS_GETSTATUS, 0, 0); - if (ps[i]->status == ID_STATUS_DISABLED || ps[i]->status == realStatus) { // ignore this proto by removing it's name (not so nice) - ps[i]->szName = ""; + int realStatus = CallProtoService(ps[i]->m_szName, PS_GETSTATUS, 0, 0); + if (ps[i]->m_status == ID_STATUS_DISABLED || ps[i]->m_status == realStatus) { // ignore this proto by removing it's name (not so nice) + ps[i]->m_szName = ""; } - else if ((ps[i]->status != ID_STATUS_DISABLED) && (ps[i]->status != realStatus) && (realStatus != ID_STATUS_OFFLINE) && (db_get_b(NULL, KSMODULENAME, SETTING_FIRSTOFFLINE, FALSE))) { + else if ((ps[i]->m_status != ID_STATUS_DISABLED) && (ps[i]->m_status != realStatus) && (realStatus != ID_STATUS_OFFLINE) && (db_get_b(NULL, KSMODULENAME, SETTING_FIRSTOFFLINE, FALSE))) { // force offline before reconnecting - log_infoA("KeepStatus: Setting %s offline before making a new connection attempt", ps[i]->szName); - CallProtoService(ps[i]->szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); + log_infoA("KeepStatus: Setting %s offline before making a new connection attempt", ps[i]->m_szName); + CallProtoService(ps[i]->m_szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); } } ProcessPopup(KS_CONN_STATE_RETRY, (LPARAM)ps); @@ -274,18 +274,15 @@ static int StatusChange(WPARAM wParam, LPARAM lParam) char* szProto = (char *)lParam; if (szProto == NULL) { // global status change for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (GetStatus(cs) != ID_STATUS_DISABLED) - if (db_get_b(NULL, KSMODULENAME, SETTING_NOLOCKED, 0) || - !db_get_b(NULL, cs.szName, "LockMainStatus", 0)) - AssignStatus(&cs, wParam, 0, cs.szMsg); + TKSSettings& cs = connectionSettings[i]; + cs.AssignStatus(wParam, 0, cs.m_szMsg); } } else { for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (GetStatus(cs) != ID_STATUS_DISABLED && !mir_strcmp(cs.szName, szProto)) - AssignStatus(&cs, wParam, 0, cs.szMsg); + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(cs.m_szName, szProto)) + cs.AssignStatus(wParam, 0, cs.m_szMsg); } } @@ -297,18 +294,16 @@ static int CSStatusChange(WPARAM wParam, LPARAM) // the status was changed by commonstatus (old) if (wParam != 0) { PROTOCOLSETTING** protoSettings = *(PROTOCOLSETTING***)wParam; - if (protoSettings == NULL) return -1; for (int i = 0; i < connectionSettings.getCount(); i++) { for (int j = 0; j < connectionSettings.getCount(); j++) { - if ((protoSettings[i]->szName == NULL) || (connectionSettings[j].szName == NULL)) + if ((protoSettings[i]->szName == NULL) || (connectionSettings[j].m_szName == NULL)) continue; - if (!mir_strcmp(protoSettings[i]->szName, connectionSettings[j].szName)) - if (GetStatus(connectionSettings[j]) != ID_STATUS_DISABLED) - AssignStatus(&connectionSettings[j], protoSettings[i]->status, protoSettings[i]->lastStatus, connectionSettings[j].szMsg); + if (!mir_strcmp(protoSettings[i]->szName, connectionSettings[j].m_szName)) + connectionSettings[j].AssignStatus(protoSettings[i]->status, protoSettings[i]->lastStatus, connectionSettings[j].m_szMsg); } } } @@ -327,12 +322,11 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM) for (int i = 0; i < connectionSettings.getCount(); i++) { for (int j = 0; j < connectionSettings.getCount(); j++) { - if ((protoSettings[i]->szName == NULL) || (connectionSettings[j].szName == NULL)) + if ((protoSettings[i]->m_szName == NULL) || (connectionSettings[j].m_szName == NULL)) continue; - if (!mir_strcmp(protoSettings[i]->szName, connectionSettings[j].szName)) { - if (GetStatus(connectionSettings[j]) != ID_STATUS_DISABLED) - AssignStatus(&connectionSettings[j], protoSettings[i]->status, protoSettings[i]->lastStatus, protoSettings[i]->szMsg); - } + + if (!mir_strcmp(protoSettings[i]->m_szName, connectionSettings[j].m_szName)) + connectionSettings[j].AssignStatus(protoSettings[i]->m_status, protoSettings[i]->m_lastStatus, protoSettings[i]->m_szMsg); } } } @@ -528,8 +522,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) if (ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) { for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(cs.szName, ack->szModule)) + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(cs.m_szName, ack->szModule)) cs.lastStatusAckTime = GetTickCount(); } StartTimer(IDT_PROCESSACK, 0, FALSE); @@ -539,17 +533,16 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) if (ack->type == ACKTYPE_LOGIN) { if (ack->lParam == LOGINERR_OTHERLOCATION) { for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(ack->szModule, cs.szName)) { - AssignStatus(&cs, ID_STATUS_OFFLINE, 0, NULL); + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(ack->szModule, cs.m_szName)) { + cs.AssignStatus(ID_STATUS_OFFLINE); if (db_get_b(NULL, KSMODULENAME, SETTING_CNCOTHERLOC, 0)) { StopTimer(IDT_PROCESSACK); - for (int j = 0; j < connectionSettings.getCount(); j++) { - AssignStatus(&connectionSettings[j], ID_STATUS_OFFLINE, 0, NULL); - } + for (int j = 0; j < connectionSettings.getCount(); j++) + connectionSettings[j].AssignStatus(ID_STATUS_OFFLINE); } - NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_OTHERLOCATION, (LPARAM)cs.szName); + NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_OTHERLOCATION, (LPARAM)cs.m_szName); ProcessPopup(KS_CONN_STATE_OTHERLOCATION, (LPARAM)ack->szModule); } } @@ -559,26 +552,26 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); switch (db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING)) { case LOGINERR_CANCEL: - { - log_infoA("KeepStatus: cancel on login error (%s)", ack->szModule); - for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(ack->szModule, cs.szName)) - AssignStatus(&cs, ID_STATUS_OFFLINE, 0, NULL); + { + log_infoA("KeepStatus: cancel on login error (%s)", ack->szModule); + for (int i = 0; i < connectionSettings.getCount(); i++) { + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(ack->szModule, cs.m_szName)) + cs.AssignStatus(ID_STATUS_OFFLINE); + } + ProcessPopup(KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); + StopChecking(); } - ProcessPopup(KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); - StopChecking(); - } - break; + break; case LOGINERR_SETDELAY: - { - int newDelay = 1000 * db_get_dw(NULL, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY); - log_infoA("KeepStatus: set delay to %d on login error (%s)", newDelay / 1000, ack->szModule); - StartTimer(IDT_CHECKCONN, newDelay, TRUE); - } - ProcessPopup(KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); - break; + { + int newDelay = 1000 * db_get_dw(NULL, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY); + log_infoA("KeepStatus: set delay to %d on login error (%s)", newDelay / 1000, ack->szModule); + StartTimer(IDT_CHECKCONN, newDelay, TRUE); + } + ProcessPopup(KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); + break; default: case LOGINERR_NOTHING: @@ -598,7 +591,7 @@ static VOID CALLBACK CheckConnectingTimer(HWND, UINT, UINT_PTR, DWORD) StopTimer(IDT_CHECKCONNECTING); //log_debugA("KeepStatus: CheckConnectingTimer"); for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; + TKSSettings& cs = connectionSettings[i]; int curStatus = GetStatus(cs); if (IsStatusConnecting(curStatus)) { // connecting @@ -606,8 +599,8 @@ static VOID CALLBACK CheckConnectingTimer(HWND, UINT, UINT_PTR, DWORD) if (maxConnectingTime > 0) { if ((unsigned int)maxConnectingTime <= ((GetTickCount() - cs.lastStatusAckTime) / 1000)) { // set offline - log_infoA("KeepStatus: %s is too long connecting; setting offline", cs.szName); - CallProtoService(cs.szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); + log_infoA("KeepStatus: %s is too long connecting; setting offline", cs.m_szName); + CallProtoService(cs.m_szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); } } } @@ -621,10 +614,10 @@ static VOID CALLBACK CheckAckStatusTimer(HWND, UINT, UINT_PTR, DWORD) StopTimer(IDT_PROCESSACK); for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; + TKSSettings& cs = connectionSettings[i]; int curStatus = GetStatus(cs); - int newStatus = CallProtoService(cs.szName, PS_GETSTATUS, 0, 0); + int newStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); // ok, np if (curStatus == ID_STATUS_CURRENT || curStatus == ID_STATUS_DISABLED || curStatus == newStatus || newStatus > MAX_STATUS) continue; @@ -636,15 +629,15 @@ static VOID CALLBACK CheckAckStatusTimer(HWND, UINT, UINT_PTR, DWORD) } // keepstatus' administration was wrong! else if (newStatus != ID_STATUS_OFFLINE) - AssignStatus(&cs, newStatus, 0, NULL); + cs.AssignStatus(newStatus); // connection lost else if (newStatus == ID_STATUS_OFFLINE) {// start checking connection if (!StartTimer(IDT_CHECKCONN, -1, FALSE)) { /* check if not already checking */ needChecking = true; - log_infoA("KeepStatus: connection lost! (%s)", cs.szName); - NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOST, (LPARAM)cs.szName); - ProcessPopup(KS_CONN_STATE_LOST, (LPARAM)cs.szName); + log_infoA("KeepStatus: connection lost! (%s)", cs.m_szName); + NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOST, (LPARAM)cs.m_szName); + ProcessPopup(KS_CONN_STATE_LOST, (LPARAM)cs.m_szName); } } } @@ -664,17 +657,17 @@ static VOID CALLBACK CheckConnectionTimer(HWND, UINT, UINT_PTR, DWORD) hIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE); for (int i = 0; i < connectionSettings.getCount() && !setStatus; i++) { - TConnectionSettings& cs = connectionSettings[i]; - realStatus = CallProtoService(cs.szName, PS_GETSTATUS, 0, 0); + TKSSettings& cs = connectionSettings[i]; + realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); shouldBeStatus = GetStatus(cs); if (shouldBeStatus == ID_STATUS_LAST) - shouldBeStatus = cs.lastStatus; + shouldBeStatus = cs.m_lastStatus; if (shouldBeStatus == ID_STATUS_DISABLED) continue; if ((shouldBeStatus != realStatus) && (realStatus == ID_STATUS_OFFLINE) || (realStatus < MIN_STATUS)) { setStatus = true; if (showConnectionPopups) - hIcon = Skin_LoadProtoIcon(cs.szName, ID_STATUS_OFFLINE); + hIcon = Skin_LoadProtoIcon(cs.m_szName, ID_STATUS_OFFLINE); } } @@ -709,11 +702,11 @@ static int StopChecking() BOOL isOk = TRUE; for (int i = 0; i < connectionSettings.getCount() && isOk; i++) { - TConnectionSettings& cs = connectionSettings[i]; + TKSSettings& cs = connectionSettings[i]; int curStatus = GetStatus(cs); - int newStatus = CallProtoService(cs.szName, PS_GETSTATUS, 0, 0); - if (newStatus != curStatus && curStatus != ID_STATUS_DISABLED) { - AssignStatus(&cs, newStatus, 0, NULL); + int newStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); + if (newStatus != curStatus) { + cs.AssignStatus(newStatus); isOk = FALSE; } } @@ -735,11 +728,11 @@ static VOID CALLBACK AfterCheckTimer(HWND, UINT, UINT_PTR, DWORD) bool setStatus = false; for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - int realStatus = CallProtoService(cs.szName, PS_GETSTATUS, 0, 0); + TKSSettings& cs = connectionSettings[i]; + int realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); int shouldBeStatus = GetStatus(cs); if (shouldBeStatus == ID_STATUS_LAST) // this should never happen - shouldBeStatus = cs.lastStatus; + shouldBeStatus = cs.m_lastStatus; if (shouldBeStatus == ID_STATUS_DISABLED) // (on ignoring proto) continue; if ((shouldBeStatus != realStatus) && (realStatus == ID_STATUS_OFFLINE) || (realStatus < MIN_STATUS)) @@ -762,16 +755,16 @@ static void CheckContinueslyFunction(void *) // do a ping, even if reconnecting bool doPing = false; for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; + TKSSettings& cs = connectionSettings[i]; int shouldBeStatus = GetStatus(cs); if (shouldBeStatus == ID_STATUS_LAST) - shouldBeStatus = cs.lastStatus; + shouldBeStatus = cs.m_lastStatus; if (shouldBeStatus == ID_STATUS_DISABLED) continue; if (shouldBeStatus != ID_STATUS_OFFLINE) { - log_debugA("CheckContinueslyFunction: %s should be %d", cs.szName, shouldBeStatus); + log_debugA("CheckContinueslyFunction: %s should be %d", cs.m_szName, shouldBeStatus); doPing = true; } } @@ -935,14 +928,14 @@ static int ProcessPopup(int reason, LPARAM lParam) memset(protoInfo, '\0', sizeof(protoInfo)); mir_wstrcpy(protoInfo, L"\r\n"); for (int i = 0; i < connectionSettings.getCount(); i++) { - if (mir_wstrlen(ps[i]->tszAccName) > 0 && mir_strlen(ps[i]->szName) > 0) { + if (mir_wstrlen(ps[i]->m_tszAccName) > 0 && mir_strlen(ps[i]->m_szName) > 0) { if (db_get_b(NULL, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE)) { - mir_snwprintf(protoInfoLine, TranslateT("%s\t(will be set to %s)\r\n"), ps[i]->tszAccName, pcli->pfnGetStatusModeDescription(ps[i]->status, 0)); + mir_snwprintf(protoInfoLine, TranslateT("%s\t(will be set to %s)\r\n"), ps[i]->m_tszAccName, pcli->pfnGetStatusModeDescription(ps[i]->m_status, 0)); mir_wstrncat(protoInfo, protoInfoLine, _countof(protoInfo) - mir_wstrlen(protoInfo) - 1); } } } - hIcon = Skin_LoadProtoIcon(ps[0]->szName, SKINICON_STATUS_OFFLINE); + hIcon = Skin_LoadProtoIcon(ps[0]->m_szName, SKINICON_STATUS_OFFLINE); rtrimw(protoInfo); if (retryCount == (maxRetries - 1)) @@ -1061,13 +1054,12 @@ INT_PTR EnableProtocolService(WPARAM wParam, LPARAM lParam) int ret = -2; for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(szProto, cs.szName)) { - if (wParam) { - if (GetStatus(cs) == ID_STATUS_DISABLED) - AssignStatus(&cs, CallProtoService(cs.szName, PS_GETSTATUS, 0, 0), 0, NULL); - } - else AssignStatus(&cs, ID_STATUS_DISABLED, 0, NULL); + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(szProto, cs.m_szName)) { + if (wParam) + cs.AssignStatus(CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0)); + else + cs.AssignStatus(ID_STATUS_DISABLED); ret = 0; break; @@ -1086,8 +1078,8 @@ INT_PTR IsProtocolEnabledService(WPARAM, LPARAM lParam) return FALSE; for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(szProto, cs.szName)) + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(szProto, cs.m_szName)) return GetStatus(cs) != ID_STATUS_DISABLED; } @@ -1097,12 +1089,12 @@ INT_PTR IsProtocolEnabledService(WPARAM, LPARAM lParam) INT_PTR AnnounceStatusChangeService(WPARAM, LPARAM lParam) { PROTOCOLSETTINGEX *newSituation = (PROTOCOLSETTINGEX *)lParam; - log_infoA("Another plugin announced a status change to %d for %s", newSituation->status, newSituation->szName == NULL ? "all" : newSituation->szName); + log_infoA("Another plugin announced a status change to %d for %s", newSituation->m_status, newSituation->m_szName == NULL ? "all" : newSituation->m_szName); for (int i = 0; i < connectionSettings.getCount(); i++) { - TConnectionSettings& cs = connectionSettings[i]; - if (!mir_strcmp(cs.szName, newSituation->szName)) - AssignStatus(&cs, newSituation->status, newSituation->lastStatus, newSituation->szMsg); + TKSSettings& cs = connectionSettings[i]; + if (!mir_strcmp(cs.m_szName, newSituation->m_szName)) + cs.AssignStatus(newSituation->m_status, newSituation->m_lastStatus, newSituation->m_szMsg); } return 0; @@ -1122,7 +1114,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara if (ps == NULL) { ps = GetCurrentProtoSettingsCopy(); for (int i = 0; i < connectionSettings.getCount(); i++) - EnableProtocolService(0, (LPARAM)ps[i]->szName); + EnableProtocolService(0, (LPARAM)ps[i]->m_szName); // set proto's offline, the clist will not try to reconnect in that case Clist_SetStatusMode(ID_STATUS_OFFLINE); @@ -1135,7 +1127,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara log_infoA("KeepStatus: resume from suspend state"); if (ps != NULL) { for (int i = 0; i < connectionSettings.getCount(); i++) - AssignStatus(&connectionSettings[i], ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg); + connectionSettings[i].AssignStatus(ps[i]->m_status, ps[i]->m_lastStatus, ps[i]->m_szMsg); FreeProtoSettings(ps); ps = NULL; } @@ -1163,12 +1155,12 @@ int OnKSAccChanged(WPARAM wParam, LPARAM lParam) PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam; switch (wParam) { case PRAC_ADDED: - connectionSettings.insert(new TConnectionSettings(pa)); + connectionSettings.insert(new TKSSettings(pa)); break; case PRAC_REMOVED: for (int i = 0; i < connectionSettings.getCount(); i++) { - if (!mir_strcmp(connectionSettings[i].szName, pa->szModuleName)) { + if (!mir_strcmp(connectionSettings[i].m_szName, pa->szModuleName)) { connectionSettings.remove(i); break; } diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.h b/plugins/StatusManager/src/KeepStatus/keepstatus.h index 167bb1a051..3aa16d78b5 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.h +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.h @@ -93,10 +93,12 @@ extern int hKSLangpack; #define TRIGGER_CONNGIVEUP 0x20 #define SETTING_TRIGGERON "TriggerOn" -struct TConnectionSettings : public PROTOCOLSETTINGEX +struct TKSSettings : public PROTOCOLSETTINGEX { - TConnectionSettings(PROTOACCOUNT *pa); - ~TConnectionSettings(); + TKSSettings(PROTOACCOUNT *pa); + ~TKSSettings(); + + int AssignStatus(int status, int lastStatus = 0, wchar_t *szMsg = nullptr); int lastStatusAckTime; // the time the last status ack was received }; diff --git a/plugins/StatusManager/src/KeepStatus/ks_options.cpp b/plugins/StatusManager/src/KeepStatus/ks_options.cpp index 1a4d6075b8..0db88f5264 100644 --- a/plugins/StatusManager/src/KeepStatus/ks_options.cpp +++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp @@ -20,7 +20,6 @@ #include "..\stdafx.h" // prototypes -INT_PTR CALLBACK OptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 22372bcb1f..4e28b085b3 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -23,7 +23,7 @@ int SSCompareSettings(const TSSSetting *p1, const TSSSetting *p2) { - return mir_strcmp(p1->szName, p2->szName); + return mir_strcmp(p1->m_szName, p2->m_szName); } TSettingsList* GetCurrentProtoSettings() @@ -36,9 +36,9 @@ TSettingsList* GetCurrentProtoSettings() if (result == NULL) return NULL; - for (int i=0; i < count; i++) - if ( IsSuitableProto(protos[i])) - result->insert( new TSSSetting(protos[i])); + for (int i = 0; i < count; i++) + if (IsSuitableProto(protos[i])) + result->insert(new TSSSetting(protos[i])); return result; } @@ -49,47 +49,48 @@ TSettingsList* GetCurrentProtoSettings() static char* GetStatusDesc(int status) { switch (status) { - case ID_STATUS_AWAY: return "away"; - case ID_STATUS_NA: return "na"; - case ID_STATUS_DND: return "dnd"; - case ID_STATUS_OCCUPIED: return "occupied"; - case ID_STATUS_FREECHAT: return "freechat"; - case ID_STATUS_ONLINE: return "online"; - case ID_STATUS_OFFLINE: return "offline"; - case ID_STATUS_INVISIBLE: return "invisible"; - case ID_STATUS_ONTHEPHONE: return "onthephone"; - case ID_STATUS_OUTTOLUNCH: return "outtolunch"; - case ID_STATUS_LAST: return "last"; + case ID_STATUS_AWAY: return "away"; + case ID_STATUS_NA: return "na"; + case ID_STATUS_DND: return "dnd"; + case ID_STATUS_OCCUPIED: return "occupied"; + case ID_STATUS_FREECHAT: return "freechat"; + case ID_STATUS_ONLINE: return "online"; + case ID_STATUS_OFFLINE: return "offline"; + case ID_STATUS_INVISIBLE: return "invisible"; + case ID_STATUS_ONTHEPHONE: return "onthephone"; + case ID_STATUS_OUTTOLUNCH: return "outtolunch"; + case ID_STATUS_LAST: return "last"; } return "offline"; } static char* GetCMDLArguments(TSettingsList& protoSettings) { - if ( protoSettings.getCount() == NULL ) + if (protoSettings.getCount() == NULL) return NULL; char *cmdl, *pnt; - pnt = cmdl = ( char* )malloc(mir_strlen(protoSettings[0].szName) + mir_strlen(GetStatusDesc(protoSettings[0].status)) + 4); + pnt = cmdl = (char*)malloc(mir_strlen(protoSettings[0].m_szName) + mir_strlen(GetStatusDesc(protoSettings[0].m_status)) + 4); - for (int i=0; i < protoSettings.getCount(); i++ ) { + for (int i = 0; i < protoSettings.getCount(); i++) { *pnt++ = '/'; - mir_strcpy(pnt, protoSettings[i].szName); - pnt += mir_strlen(protoSettings[i].szName); + mir_strcpy(pnt, protoSettings[i].m_szName); + pnt += mir_strlen(protoSettings[i].m_szName); *pnt++ = '='; - mir_strcpy(pnt, GetStatusDesc(protoSettings[i].status)); - pnt += mir_strlen(GetStatusDesc(protoSettings[i].status)); - if (i != protoSettings.getCount()-1) { + mir_strcpy(pnt, GetStatusDesc(protoSettings[i].m_status)); + pnt += mir_strlen(GetStatusDesc(protoSettings[i].m_status)); + if (i != protoSettings.getCount() - 1) { *pnt++ = ' '; *pnt++ = '\0'; - cmdl = ( char* )realloc(cmdl, mir_strlen(cmdl) + mir_strlen(protoSettings[i+1].szName) + mir_strlen(GetStatusDesc(protoSettings[i+1].status)) + 4); + cmdl = (char*)realloc(cmdl, mir_strlen(cmdl) + mir_strlen(protoSettings[i + 1].m_szName) + mir_strlen(GetStatusDesc(protoSettings[i + 1].m_status)) + 4); pnt = cmdl + mir_strlen(cmdl); - } } + } + } - if ( db_get_b( NULL, SSMODULENAME, SETTING_SHOWDIALOG, FALSE ) == TRUE ) { + if (db_get_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, FALSE) == TRUE) { *pnt++ = ' '; *pnt++ = '\0'; - cmdl = ( char* )realloc(cmdl, mir_strlen(cmdl) + 12); + cmdl = (char*)realloc(cmdl, mir_strlen(cmdl) + 12); pnt = cmdl + mir_strlen(cmdl); mir_strcpy(pnt, "/showdialog"); pnt += 11; @@ -104,12 +105,12 @@ static char* GetCMDL(TSettingsList& protoSettings) char path[MAX_PATH]; GetModuleFileNameA(NULL, path, MAX_PATH); - char* cmdl = ( char* )malloc(mir_strlen(path) + 4); + char* cmdl = (char*)malloc(mir_strlen(path) + 4); mir_snprintf(cmdl, mir_strlen(path) + 4, "\"%s\" ", path); char* args = GetCMDLArguments(protoSettings); - if ( args ) { - cmdl = ( char* )realloc(cmdl, mir_strlen(cmdl) + mir_strlen(args) + 1); + if (args) { + cmdl = (char*)realloc(cmdl, mir_strlen(cmdl) + mir_strlen(args) + 1); mir_strcat(cmdl, args); free(args); } @@ -121,27 +122,27 @@ static char* GetCMDL(TSettingsList& protoSettings) static wchar_t* GetLinkDescription(TSettingsList& protoSettings) { - if ( protoSettings.getCount() == 0 ) + if (protoSettings.getCount() == 0) return NULL; CMStringW result(SHORTCUT_DESC); - for (int i=0; i < protoSettings.getCount(); i++) { + for (int i = 0; i < protoSettings.getCount(); i++) { TSSSetting &p = protoSettings[i]; wchar_t *status; - if ( p.status == ID_STATUS_LAST) + if (p.m_status == ID_STATUS_LAST) status = TranslateT("<last>"); - else if (p.status == ID_STATUS_CURRENT) + else if (p.m_status == ID_STATUS_CURRENT) status = TranslateT("<current>"); - else if (p.status >= MIN_STATUS && p.status <= MAX_STATUS) - status = pcli->pfnGetStatusModeDescription(p.status, 0); + else if (p.m_status >= MIN_STATUS && p.m_status <= MAX_STATUS) + status = pcli->pfnGetStatusModeDescription(p.m_status, 0); else status = NULL; if (status == NULL) status = TranslateT("<unknown>"); result.AppendChar('\r'); - result.Append(p.tszAccName); + result.Append(p.m_tszAccName); result.AppendChar(':'); result.AppendChar(' '); result.Append(status); @@ -160,7 +161,7 @@ HRESULT CreateLink(TSettingsList& protoSettings) // Get a pointer to the IShellLink interface. IShellLink *psl; - HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, ( void** )&psl); + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl); if (SUCCEEDED(hres)) { char *args = GetCMDLArguments(protoSettings); wchar_t *desc = GetLinkDescription(protoSettings); @@ -171,12 +172,12 @@ HRESULT CreateLink(TSettingsList& protoSettings) GetModuleFileName(NULL, path, _countof(path)); psl->SetPath(path); psl->SetDescription(desc); - psl->SetArguments( _A2T(args)); + psl->SetArguments(_A2T(args)); // Query IShellLink for the IPersistFile interface for saving the // shortcut in persistent storage. IPersistFile *ppf; - hres = psl->QueryInterface(IID_IPersistFile, ( void** )&ppf); + hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf); if (SUCCEEDED(hres)) { // Save the link by calling IPersistFile::Save. @@ -191,11 +192,11 @@ HRESULT CreateLink(TSettingsList& protoSettings) return hres; } -INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static TSettingsList* optionsProtoSettings; - switch(msg) { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { @@ -209,17 +210,17 @@ INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_COPY: - if ( OpenClipboard( hwndDlg )) { + if (OpenClipboard(hwndDlg)) { EmptyClipboard(); char cmdl[2048]; - GetDlgItemTextA(hwndDlg,IDC_CMDL, cmdl, _countof(cmdl)); + GetDlgItemTextA(hwndDlg, IDC_CMDL, cmdl, _countof(cmdl)); HGLOBAL cmdlGlob = GlobalAlloc(GMEM_MOVEABLE, sizeof(cmdl)); if (cmdlGlob == NULL) { CloseClipboard(); break; } - LPTSTR cmdlStr = ( LPTSTR )GlobalLock(cmdlGlob); + LPTSTR cmdlStr = (LPTSTR)GlobalLock(cmdlGlob); memcpy(cmdlStr, &cmdl, sizeof(cmdl)); GlobalUnlock(cmdlGlob); SetClipboardData(CF_TEXT, cmdlGlob); @@ -249,11 +250,11 @@ INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM l return 0; } -static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static BOOL bInitDone = FALSE; - switch(msg) { + switch (msg) { case WM_INITDIALOG: bInitDone = FALSE; @@ -292,7 +293,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa SendDlgItemMessage(hwndDlg, IDC_DOCKED, CB_SETCURSEL, (WPARAM)item, 0); } - EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)||IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE) || IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); EnableWindow(GetDlgItem(hwndDlg, IDC_SETPROFILEDELAY), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); EnableWindow(GetDlgItem(hwndDlg, IDC_OVERRIDE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); EnableWindow(GetDlgItem(hwndDlg, IDC_DLGTIMEOUT), IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); @@ -308,7 +309,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa break; case WM_TIMER: - if ( BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SETWINLOCATION) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)) { + if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SETWINLOCATION) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)) { SetDlgItemTextA(hwndDlg, IDC_CURWINSIZE, ""); SetDlgItemTextA(hwndDlg, IDC_CURWINLOC, ""); break; @@ -324,7 +325,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa db_get_dw(NULL, MODULE_CLIST, SETTING_XPOS, 0), db_get_dw(NULL, MODULE_CLIST, SETTING_YPOS, 0)); SetDlgItemText(hwndDlg, IDC_CURWINLOC, text); - } + } break; case UM_REINITPROFILES: @@ -333,9 +334,9 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa { int defProfile; int profileCount = GetProfileCount((WPARAM)&defProfile, 0); - for ( int i=0; i < profileCount; i++ ) { + for (int i = 0; i < profileCount; i++) { wchar_t profileName[128]; - if ( GetProfileName(i, (LPARAM)profileName)) + if (GetProfileName(i, (LPARAM)profileName)) continue; int item = SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profileName); @@ -347,7 +348,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa case UM_REINITDOCKED: EnableWindow(GetDlgItem(hwndDlg, IDC_SETDOCKED), db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 1)); - if (!IsWindowEnabled(GetDlgItem(hwndDlg,IDC_SETDOCKED))) + if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_SETDOCKED))) CheckDlgButton(hwndDlg, IDC_SETDOCKED, BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_DOCKED), IsDlgButtonChecked(hwndDlg, IDC_SETDOCKED)); @@ -371,28 +372,28 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa } item = SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Normal")); SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_SETITEMDATA, item, SETTING_STATE_NORMAL); - if ( val == SETTING_STATE_NORMAL || (val == SETTING_STATE_MINIMIZED) && db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) + if (val == SETTING_STATE_NORMAL || (val == SETTING_STATE_MINIMIZED) && db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_SETCURSEL, item, 0); } break; case UM_REINITWINSIZE: EnableWindow(GetDlgItem(hwndDlg, IDC_WIDTH), IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)); - EnableWindow(GetDlgItem(hwndDlg, IDC_HEIGHT), !db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0)&&IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)); + EnableWindow(GetDlgItem(hwndDlg, IDC_HEIGHT), !db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0) && IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)); case WM_COMMAND: - if ( HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == LBN_SELCHANGE || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == EN_CHANGE ) - if ( bInitDone ) + if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == LBN_SELCHANGE || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == EN_CHANGE) + if (bInitDone) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); switch (LOWORD(wParam)) { case IDC_SETPROFILE: - EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)||IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE) || IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); EnableWindow(GetDlgItem(hwndDlg, IDC_SETPROFILEDELAY), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); EnableWindow(GetDlgItem(hwndDlg, IDC_OVERRIDE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); break; case IDC_SHOWDIALOG: - EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)||IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILE), IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE) || IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); EnableWindow(GetDlgItem(hwndDlg, IDC_DLGTIMEOUT), IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); break; case IDC_SETWINSTATE: @@ -414,11 +415,11 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wPa SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0); TSettingsList* ps = GetCurrentProtoSettings(); - if ( ps ) { - GetProfile( defProfile, *ps ); - for ( int i=0; i < ps->getCount(); i++ ) - if ( (*ps)[i].szMsg != NULL ) - (*ps)[i].szMsg = wcsdup( (*ps)[i].szMsg ); + if (ps) { + GetProfile(defProfile, *ps); + for (int i = 0; i < ps->getCount(); i++) + if ((*ps)[i].m_szMsg != NULL) + (*ps)[i].m_szMsg = wcsdup((*ps)[i].m_szMsg); CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)ps); } @@ -509,7 +510,7 @@ static int ClearDatabase(char* filter) db_unset(NULL, SSMODULENAME, arSettings[i]); mir_free(arSettings[i]); } - + if (filter == NULL) db_unset(NULL, "AutoAway", "Confirm"); @@ -554,12 +555,12 @@ INT_PTR CALLBACK addProfileDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return 0; } -static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam) +static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static BOOL bNeedRebuildMenu = FALSE; static BOOL bInitDone = FALSE; - switch(msg) { + switch (msg) { case WM_INITDIALOG: bInitDone = false; @@ -573,36 +574,36 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP defProfile = 0; } - for (int i=0; i < profileCount; i++) { + for (int i = 0; i < profileCount; i++) { PROFILEOPTIONS *ppo = new PROFILEOPTIONS; ppo->ps = GetCurrentProtoSettings(); TSettingsList& ar = *ppo->ps; - if ( GetProfile(i, ar) == -1) { + if (GetProfile(i, ar) == -1) { /* create an empty profile */ if (i == defProfile) - ppo->tszName = mir_wstrdup( TranslateT("default")); + ppo->tszName = mir_wstrdup(TranslateT("default")); else - ppo->tszName = mir_wstrdup( TranslateT("unknown")); + ppo->tszName = mir_wstrdup(TranslateT("unknown")); } else { - for (int j=0; j < ar.getCount(); j++) - if ( ar[j].szMsg != NULL) - ar[j].szMsg = wcsdup( ar[j].szMsg ); + for (int j = 0; j < ar.getCount(); j++) + if (ar[j].m_szMsg != NULL) + ar[j].m_szMsg = wcsdup(ar[j].m_szMsg); ppo->tszName = db_get_wsa(NULL, SSMODULENAME, OptName(i, SETTING_PROFILENAME)); if (ppo->tszName == NULL) { if (i == defProfile) - ppo->tszName = mir_wstrdup( TranslateT("default")); + ppo->tszName = mir_wstrdup(TranslateT("default")); else - ppo->tszName = mir_wstrdup( TranslateT("unknown")); + ppo->tszName = mir_wstrdup(TranslateT("unknown")); } ppo->createTtb = db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), 0); ppo->showDialog = db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), 0); ppo->createMmi = db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), 0); ppo->inSubMenu = db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1); ppo->regHotkey = db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), 0); - ppo->hotKey = db_get_w(NULL, SSMODULENAME, OptName(i, SETTING_HOTKEY), MAKEWORD((char)('0'+i), HOTKEYF_CONTROL|HOTKEYF_SHIFT)); + ppo->hotKey = db_get_w(NULL, SSMODULENAME, OptName(i, SETTING_HOTKEY), MAKEWORD((char)('0' + i), HOTKEYF_CONTROL | HOTKEYF_SHIFT)); } arProfiles.insert(ppo); } @@ -610,7 +611,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP EnableWindow(GetDlgItem(hwndDlg, IDC_CREATETTB), FALSE); SendMessage(hwndDlg, UM_REINITPROFILES, 0, 0); - ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), ServiceExists(MS_VARS_SHOWHELPEX)?SW_SHOW:SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), ServiceExists(MS_VARS_SHOWHELPEX) ? SW_SHOW : SW_HIDE); bInitDone = true; } break; @@ -620,7 +621,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP { // creates profile combo box according to 'dat' SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_RESETCONTENT, 0, 0); - for (int i=0; i < arProfiles.getCount(); i++ ) { + for (int i = 0; i < arProfiles.getCount(); i++) { int item = SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)arProfiles[i].tszName); SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_SETITEMDATA, (WPARAM)item, (LPARAM)i); } @@ -646,8 +647,8 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP // fill proto list TSettingsList& ar = *arProfiles[sel].ps; - for ( int i=0; i < ar.getCount(); i++ ) { - int item = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_ADDSTRING, 0, (LPARAM)ar[i].tszAccName ); + for (int i = 0; i < ar.getCount(); i++) { + int item = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_ADDSTRING, 0, (LPARAM)ar[i].m_tszAccName); SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_SETITEMDATA, (WPARAM)item, (LPARAM)&ar[i]); } SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_SETCURSEL, 0, 0); @@ -658,29 +659,29 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP case UM_SETPROTOCOL: { int idx = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0); - if ( idx != -1 ) { + if (idx != -1) { // fill status box - TSSSetting* ps = ( TSSSetting* )SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); + TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); - int flags = (CallProtoService(ps->szName, PS_GETCAPS, PFLAGNUM_2, 0))&~(CallProtoService(ps->szName, PS_GETCAPS, PFLAGNUM_5, 0)); + int flags = (CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_2, 0))&~(CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_5, 0)); SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_RESETCONTENT, 0, 0); - for ( int i=0; i < _countof(statusModeList); i++ ) { - if ( (flags&statusModePf2List[i]) || (statusModeList[i] == ID_STATUS_OFFLINE)) { + for (int i = 0; i < _countof(statusModeList); i++) { + if ((flags&statusModePf2List[i]) || (statusModeList[i] == ID_STATUS_OFFLINE)) { int item = SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModeList[i], 0)); SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETITEMDATA, (WPARAM)item, (LPARAM)statusModeList[i]); - if (ps->status == statusModeList[i]) + if (ps->m_status == statusModeList[i]) SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETCURSEL, (WPARAM)item, 0); } } int item = SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<current>")); SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETITEMDATA, (WPARAM)item, (LPARAM)ID_STATUS_CURRENT); - if (ps->status == ID_STATUS_CURRENT) + if (ps->m_status == ID_STATUS_CURRENT) SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETCURSEL, (WPARAM)item, 0); item = SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<last>")); SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETITEMDATA, (WPARAM)item, (LPARAM)ID_STATUS_LAST); - if (ps->status == ID_STATUS_LAST) + if (ps->m_status == ID_STATUS_LAST) SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_SETCURSEL, (WPARAM)item, 0); } @@ -693,15 +694,15 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP // set status message BOOL bStatusMsg = FALSE; int idx = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0); - if ( idx != -1 ) { - TSSSetting* ps = ( TSSSetting* )SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); + if (idx != -1) { + TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); - CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->szMsg!=NULL?IDC_CUSTOMMSG:IDC_MIRANDAMSG); - if (ps->szMsg != NULL) - SetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->szMsg); + CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->m_szMsg != NULL ? IDC_CUSTOMMSG : IDC_MIRANDAMSG); + if (ps->m_szMsg != NULL) + SetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->m_szMsg); - bStatusMsg = ( (((CallProtoService(ps->szName, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_MODEMSGSEND&~PF1_INDIVMODEMSG)) && - (CallProtoService(ps->szName, PS_GETCAPS, PFLAGNUM_3, 0)&Proto_Status2Flag(ps->status))) || (ps->status == ID_STATUS_CURRENT) || (ps->status == ID_STATUS_LAST)); + bStatusMsg = ((((CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_MODEMSGSEND&~PF1_INDIVMODEMSG)) && + (CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_3, 0)&Proto_Status2Flag(ps->m_status))) || (ps->m_status == ID_STATUS_CURRENT) || (ps->m_status == ID_STATUS_LAST)); } EnableWindow(GetDlgItem(hwndDlg, IDC_MIRANDAMSG), bStatusMsg); EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMMSG), bStatusMsg); @@ -726,38 +727,38 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP break; case UM_DELPROFILE: { - // wparam == profile no - int i=(int)wParam; + // wparam == profile no + int i = (int)wParam; - if ( arProfiles.getCount() == 1) { - MessageBox(NULL, TranslateT("At least one profile must exist"), TranslateT("Status manager"), MB_OK); - break; - } + if (arProfiles.getCount() == 1) { + MessageBox(NULL, TranslateT("At least one profile must exist"), TranslateT("Status manager"), MB_OK); + break; + } - arProfiles.remove(i); + arProfiles.remove(i); - int defProfile; - GetProfileCount((WPARAM)&defProfile, 0); - if (i == defProfile) { - MessageBox(NULL, TranslateT("Your default profile will be changed"), TranslateT("Status manager"), MB_OK); - db_set_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + int defProfile; + GetProfileCount((WPARAM)&defProfile, 0); + if (i == defProfile) { + MessageBox(NULL, TranslateT("Your default profile will be changed"), TranslateT("Status manager"), MB_OK); + db_set_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + } + SendMessage(hwndDlg, UM_REINITPROFILES, 0, 0); + break; } - SendMessage(hwndDlg, UM_REINITPROFILES, 0, 0); - break; - } case WM_COMMAND: - if ( ((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == LBN_SELCHANGE)) && ((HWND)lParam == GetFocus())) - if ( bInitDone ) - SendMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); + if (((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == LBN_SELCHANGE)) && ((HWND)lParam == GetFocus())) + if (bInitDone) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); switch (LOWORD(wParam)) { case IDC_STATUS: if (HIWORD(wParam) == LBN_SELCHANGE) { int idx = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0); - if ( idx != -1 ) { - TSSSetting* ps = ( TSSSetting* )SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); - ps->status = (int)SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_GETITEMDATA, + if (idx != -1) { + TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); + ps->m_status = (int)SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_STATUS, LB_GETCURSEL, 0, 0), 0); } SendMessage(hwndDlg, UM_SETSTATUSMSG, 0, 0); @@ -782,16 +783,16 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP case IDC_CUSTOMMSG: { int len; - TSSSetting* ps = ( TSSSetting* )SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, + TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0), 0); - if (ps->szMsg != NULL) - free(ps->szMsg); + if (ps->m_szMsg != NULL) + free(ps->m_szMsg); - ps->szMsg = NULL; + ps->m_szMsg = NULL; if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOMMSG)) { len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (wchar_t*)calloc(sizeof(wchar_t), len+1); - GetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->szMsg, (len + 1)); + ps->m_szMsg = (wchar_t*)calloc(sizeof(wchar_t), len + 1); + GetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->m_szMsg, (len + 1)); } SendMessage(hwndDlg, UM_SETSTATUSMSG, 0, 0); } @@ -801,16 +802,16 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP if (HIWORD(wParam) == EN_CHANGE) { // update the status message in memory, this is done on each character tick, not nice // but it works - TSSSetting* ps = ( TSSSetting* )SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, + TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0), 0); - if (ps->szMsg != NULL) { - if ( *ps->szMsg ) - free(ps->szMsg); - ps->szMsg = NULL; + if (ps->m_szMsg != NULL) { + if (*ps->m_szMsg) + free(ps->m_szMsg); + ps->m_szMsg = NULL; } int len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); - ps->szMsg = (wchar_t*)calloc(sizeof(wchar_t), len+1); - GetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->szMsg, (len + 1)); + ps->m_szMsg = (wchar_t*)calloc(sizeof(wchar_t), len + 1); + GetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->m_szMsg, (len + 1)); } break; @@ -856,7 +857,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP break; case IDC_VARIABLESHELP: - variables_showhelp(hwndDlg, IDC_STATUSMSG, VHF_INPUT|VHF_EXTRATEXT|VHF_HELP|VHF_FULLFILLSTRUCT|VHF_HIDESUBJECTTOKEN, NULL, "Protocol ID"); + variables_showhelp(hwndDlg, IDC_STATUSMSG, VHF_INPUT | VHF_EXTRATEXT | VHF_HELP | VHF_FULLFILLSTRUCT | VHF_HIDESUBJECTTOKEN, NULL, "Protocol ID"); break; } break; @@ -865,11 +866,11 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP if (((LPNMHDR)lParam)->code == PSN_APPLY) { char setting[128]; int oldCount = db_get_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, 0); - for (int i=0; i < oldCount; i++) { + for (int i = 0; i < oldCount; i++) { mir_snprintf(setting, "%d_", i); ClearDatabase(setting); } - for (int i=0; i < arProfiles.getCount(); i++) { + for (int i = 0; i < arProfiles.getCount(); i++) { PROFILEOPTIONS& po = arProfiles[i]; db_set_b(NULL, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), po.showDialog); db_set_b(NULL, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), po.createTtb); @@ -880,12 +881,12 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP db_set_ws(NULL, SSMODULENAME, OptName(i, SETTING_PROFILENAME), po.tszName); TSettingsList& ar = *po.ps; - for (int j=0; j < ar.getCount(); j++) { - if ( ar[j].szMsg != NULL ) { - mir_snprintf(setting, "%s_%s", ar[j].szName, SETTING_PROFILE_STSMSG); - db_set_ws(NULL, SSMODULENAME, OptName(i, setting), ar[j].szMsg); + for (int j = 0; j < ar.getCount(); j++) { + if (ar[j].m_szMsg != NULL) { + mir_snprintf(setting, "%s_%s", ar[j].m_szName, SETTING_PROFILE_STSMSG); + db_set_ws(NULL, SSMODULENAME, OptName(i, setting), ar[j].m_szMsg); } - db_set_w(NULL, SSMODULENAME, OptName(i, ar[j].szName), ar[j].status); + db_set_w(NULL, SSMODULENAME, OptName(i, ar[j].m_szName), ar[j].m_status); } } db_set_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, (WORD)arProfiles.getCount()); @@ -906,7 +907,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wP return 0; } -int StartupStatusOptionsInit(WPARAM wparam,LPARAM) +int StartupStatusOptionsInit(WPARAM wparam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; @@ -918,12 +919,12 @@ int StartupStatusOptionsInit(WPARAM wparam,LPARAM) odp.szTab.a = LPGEN("General"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_STARTUPSTATUS); odp.pfnDlgProc = StartupStatusOptDlgProc; - Options_AddPage(wparam,&odp); + Options_AddPage(wparam, &odp); odp.szTab.a = LPGEN("Status profiles"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_STATUSPROFILES); odp.pfnDlgProc = StatusProfilesOptDlgProc; - Options_AddPage(wparam,&odp); + Options_AddPage(wparam, &odp); return 0; } diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index f2614903f6..4004bc4623 100644 --- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -27,20 +27,17 @@ static TSettingsList startupSettings(10, SSCompareSettings); TSSSetting::TSSSetting(PROTOACCOUNT *pa) { - cbSize = sizeof(PROTOCOLSETTINGEX); - szName = pa->szModuleName; - tszAccName = pa->tszAccountName; - status = lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - szMsg = NULL; + m_szName = pa->szModuleName; + m_tszAccName = pa->tszAccountName; + m_status = m_lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); + m_szMsg = NULL; } TSSSetting::TSSSetting(int profile, PROTOACCOUNT *pa) { - cbSize = sizeof(PROTOCOLSETTINGEX); - // copy name - szName = pa->szModuleName; - tszAccName = pa->tszAccountName; + m_szName = pa->szModuleName; + m_tszAccName = pa->tszAccountName; // load status char setting[80]; @@ -48,23 +45,23 @@ TSSSetting::TSSSetting(int profile, PROTOACCOUNT *pa) int iStatus = db_get_w(NULL, SSMODULENAME, setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; - status = iStatus; + m_status = iStatus; // load last status - mir_snprintf(setting, "%s%s", PREFIX_LAST, szName); + mir_snprintf(setting, "%s%s", PREFIX_LAST, m_szName); iStatus = db_get_w(NULL, SSMODULENAME, setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; - lastStatus = iStatus; + m_lastStatus = iStatus; - szMsg = GetStatusMessage(profile, szName); - if (szMsg) - szMsg = wcsdup(szMsg); + m_szMsg = GetStatusMessage(profile, m_szName); + if (m_szMsg) + m_szMsg = wcsdup(m_szMsg); } TSSSetting::~TSSSetting() { - free(szMsg); + free(m_szMsg); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -81,7 +78,7 @@ static BYTE showDialogOnStartup = 0; static PROTOCOLSETTINGEX* IsValidProtocol(TSettingsList& protoSettings, char* protoName) { for (int i = 0; i < protoSettings.getCount(); i++) - if (!strncmp(protoSettings[i].szName, protoName, mir_strlen(protoSettings[i].szName))) + if (!strncmp(protoSettings[i].m_szName, protoName, mir_strlen(protoSettings[i].m_szName))) return &protoSettings[i]; return NULL; @@ -153,7 +150,7 @@ static void ProcessCommandLineOptions(TSettingsList& protoSettings) char *statusDesc = cmdl; int status = IsValidStatusDesc(statusDesc); if (status != 0) - protoSetting->status = status; + protoSetting->m_status = status; } } } @@ -161,15 +158,15 @@ static void ProcessCommandLineOptions(TSettingsList& protoSettings) static void SetLastStatusMessages(TSettingsList &ps) { for (int i = 0; i < ps.getCount(); i++) { - if (ps[i].status != ID_STATUS_LAST) + if (ps[i].m_status != ID_STATUS_LAST) continue; char dbSetting[128]; - mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, ps[i].szName); + mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, ps[i].m_szName); DBVARIANT dbv; - if (ps[i].szMsg == NULL && !db_get_ws(NULL, SSMODULENAME, dbSetting, &dbv)) { - ps[i].szMsg = wcsdup(dbv.ptszVal); // remember this won't be freed + if (ps[i].m_szMsg == NULL && !db_get_ws(NULL, SSMODULENAME, dbSetting, &dbv)) { + ps[i].m_szMsg = wcsdup(dbv.ptszVal); // remember this won't be freed db_free(&dbv); } } @@ -188,7 +185,7 @@ int OnSSAccChanged(WPARAM wParam, LPARAM lParam) case PRAC_REMOVED: for (int i = 0; i < startupSettings.getCount(); i++) { - if (!mir_strcmp(startupSettings[i].szName, pa->szModuleName)) { + if (!mir_strcmp(startupSettings[i].m_szName, pa->szModuleName)) { startupSettings.remove(i); break; } @@ -211,8 +208,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) return 0; for (int i = 0; i < startupSettings.getCount(); i++) { - if (!mir_strcmp(ack->szModule, startupSettings[i].szName)) { - startupSettings[i].szName = ""; + if (!mir_strcmp(ack->szModule, startupSettings[i].m_szName)) { + startupSettings[i].m_szName = ""; log_debugA("StartupStatus: %s overridden by ME_PROTO_ACK, status will not be set", ack->szModule); } } @@ -229,14 +226,14 @@ static int StatusChange(WPARAM, LPARAM lParam) char *szProto = (char *)lParam; if (szProto == NULL) { // global status change for (int i = 0; i < startupSettings.getCount(); i++) { - startupSettings[i].szName = ""; + startupSettings[i].m_szName = ""; log_debugA("StartupStatus: all protos overridden by ME_CLIST_STATUSMODECHANGE, status will not be set"); } } else { for (int i = 0; i < startupSettings.getCount(); i++) { - if (!mir_strcmp(startupSettings[i].szName, szProto)) { - startupSettings[i].szName = ""; + if (!mir_strcmp(startupSettings[i].m_szName, szProto)) { + startupSettings[i].m_szName = ""; log_debugA("StartupStatus: %s overridden by ME_CLIST_STATUSMODECHANGE, status will not be set", szProto); } } @@ -258,13 +255,13 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM) for (int i = 0; i < startupSettings.getCount(); i++) { for (int j = 0; j < startupSettings.getCount(); j++) { - if (ps[i]->szName == NULL || startupSettings[j].szName == NULL) + if (ps[i]->m_szName == NULL || startupSettings[j].m_szName == NULL) continue; - if (!mir_strcmp(ps[i]->szName, startupSettings[j].szName)) { - log_debugA("StartupStatus: %s overridden by MS_CS_SETSTATUSEX, status will not be set", ps[i]->szName); + if (!mir_strcmp(ps[i]->m_szName, startupSettings[j].m_szName)) { + log_debugA("StartupStatus: %s overridden by MS_CS_SETSTATUSEX, status will not be set", ps[i]->m_szName); // use a hack to disable this proto - startupSettings[j].szName = ""; + startupSettings[j].m_szName = ""; } } } @@ -471,8 +468,11 @@ int SSModuleLoaded(WPARAM, LPARAM) height = db_get_dw(NULL, SSMODULENAME, SETTING_HEIGHT, height); } MoveWindow(hClist, x, y, width, height, TRUE); - } } } } - + } + } + } + } + return 0; } diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp index bea099864e..be3f778397 100644 --- a/plugins/StatusManager/src/commonstatus.cpp +++ b/plugins/StatusManager/src/commonstatus.cpp @@ -79,29 +79,29 @@ DWORD StatusModeToProtoFlag(int status) int GetActualStatus(PROTOCOLSETTINGEX *protoSetting) { - if (protoSetting->status == ID_STATUS_LAST) { - if ((protoSetting->lastStatus < MIN_STATUS) || (protoSetting->lastStatus > MAX_STATUS)) - return CallProtoService(protoSetting->szName, PS_GETSTATUS, 0, 0); - return protoSetting->lastStatus; + if (protoSetting->m_status == ID_STATUS_LAST) { + if ((protoSetting->m_lastStatus < MIN_STATUS) || (protoSetting->m_lastStatus > MAX_STATUS)) + return CallProtoService(protoSetting->m_szName, PS_GETSTATUS, 0, 0); + return protoSetting->m_lastStatus; } - if (protoSetting->status == ID_STATUS_CURRENT) - return CallProtoService(protoSetting->szName, PS_GETSTATUS, 0, 0); + if (protoSetting->m_status == ID_STATUS_CURRENT) + return CallProtoService(protoSetting->m_szName, PS_GETSTATUS, 0, 0); - if ((protoSetting->status < ID_STATUS_OFFLINE) || (protoSetting->status > ID_STATUS_OUTTOLUNCH)) { - log_debugA("invalid status detected: %d", protoSetting->status); + if ((protoSetting->m_status < ID_STATUS_OFFLINE) || (protoSetting->m_status > ID_STATUS_OUTTOLUNCH)) { + log_debugA("invalid status detected: %d", protoSetting->m_status); return 0; } - return protoSetting->status; + return protoSetting->m_status; } wchar_t* GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) { - if (ps->szMsg != NULL) {// custom message set + if (ps->m_szMsg != NULL) {// custom message set log_infoA("CommonStatus: Status message set by calling plugin"); - return mir_wstrdup(ps->szMsg); + return mir_wstrdup(ps->m_szMsg); } - wchar_t *tMsg = (wchar_t*)CallService(MS_AWAYMSG_GETSTATUSMSGW, newstatus, (LPARAM)ps->szName); + wchar_t *tMsg = (wchar_t*)CallService(MS_AWAYMSG_GETSTATUSMSGW, newstatus, (LPARAM)ps->m_szName); log_debugA("CommonStatus: Status message retrieved from general awaysys: %S", tMsg); return tMsg; } @@ -111,7 +111,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) int i, j, pstatus = 0, gstatus = 0; for (i = 0; i < protoList->getCount(); i++) - if (ps[i]->szMsg != NULL && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE) + if (ps[i]->m_szMsg != NULL && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE) return 0; int count; @@ -124,7 +124,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) pstatus = 0; for (j = 0; j < protoList->getCount(); j++) - if (!mir_strcmp(protos[i]->szModuleName, ps[j]->szName)) + if (!mir_strcmp(protos[i]->szModuleName, ps[j]->m_szName)) pstatus = GetActualStatus(ps[j]); if (pstatus == 0) @@ -170,14 +170,14 @@ static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus) memcpy(tszMsg + j, substituteStr, sizeof(wchar_t)*mir_wstrlen(substituteStr)); } - wchar_t *szFormattedMsg = variables_parsedup(tszMsg, ps->tszAccName, NULL); + wchar_t *szFormattedMsg = variables_parsedup(tszMsg, ps->m_tszAccName, NULL); if (szFormattedMsg != NULL) { mir_free(tszMsg); tszMsg = szFormattedMsg; } } - log_debugA("CommonStatus sets status message for %s directly", ps->szName); - CallProtoService(ps->szName, PS_SETAWAYMSG, newstatus, (LPARAM)tszMsg); + log_debugA("CommonStatus sets status message for %s directly", ps->m_szName); + CallProtoService(ps->m_szName, PS_SETAWAYMSG, newstatus, (LPARAM)tszMsg); mir_free(tszMsg); } @@ -196,7 +196,7 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM) // set all status messages first for (int i = 0; i < protoList->getCount(); i++) { - char *szProto = protoSettings[i]->szName; + char *szProto = protoSettings[i]->m_szName; if (!Proto_GetAccount(szProto)) { log_debugA("CommonStatus: %s is not loaded", szProto); continue; @@ -204,12 +204,12 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM) // some checks int newstatus = GetActualStatus(protoSettings[i]); if (newstatus == 0) { - log_debugA("CommonStatus: incorrect status for %s (%d)", szProto, protoSettings[i]->status); + log_debugA("CommonStatus: incorrect status for %s (%d)", szProto, protoSettings[i]->m_status); continue; } int oldstatus = CallProtoService(szProto, PS_GETSTATUS, 0, 0); // set last status - protoSettings[i]->lastStatus = oldstatus; + protoSettings[i]->m_lastStatus = oldstatus; if (IsStatusConnecting(oldstatus)) { // ignore if connecting, but it didn't came this far if it did log_debugA("CommonStatus: %s is already connecting", szProto); diff --git a/plugins/StatusManager/src/confirmdialog.cpp b/plugins/StatusManager/src/confirmdialog.cpp index 3a246cf8e3..82225f2320 100644 --- a/plugins/StatusManager/src/confirmdialog.cpp +++ b/plugins/StatusManager/src/confirmdialog.cpp @@ -32,19 +32,19 @@ struct TConfirmSetting : public PROTOCOLSETTINGEX TConfirmSetting(const PROTOCOLSETTINGEX& x) { memcpy(this, &x, sizeof(PROTOCOLSETTINGEX)); - if (szMsg) - szMsg = wcsdup(szMsg); + if (m_szMsg) + m_szMsg = wcsdup(m_szMsg); } ~TConfirmSetting() { - free(szMsg); + free(m_szMsg); } }; static int CompareSettings(const TConfirmSetting* p1, const TConfirmSetting* p2) { - return mir_strcmp(p1->szName, p2->szName); + return mir_strcmp(p1->m_szName, p2->m_szName); } static OBJLIST<TConfirmSetting> *confirmSettings; @@ -57,19 +57,19 @@ static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar TranslateDialogDefault(hwndDlg); protoSetting = (PROTOCOLSETTINGEX *)lParam; - if (protoSetting->szMsg == NULL) { + if (protoSetting->m_szMsg == NULL) { wchar_t* smsg = GetDefaultStatusMessage(protoSetting, GetActualStatus(protoSetting)); if (smsg != NULL) { SetDlgItemText(hwndDlg, IDC_STSMSG, smsg); mir_free(smsg); } } - else SetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->szMsg); + else SetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->m_szMsg); { wchar_t desc[512]; - mir_snwprintf(desc, TranslateT("Set %s message for %s."), - pcli->pfnGetStatusModeDescription(GetActualStatus(protoSetting), 0), protoSetting->tszAccName); + mir_snwprintf(desc, TranslateT("Set %s message for %s."), + pcli->pfnGetStatusModeDescription(GetActualStatus(protoSetting), 0), protoSetting->m_tszAccName); SetDlgItemText(hwndDlg, IDC_DESCRIPTION, desc); } break; @@ -77,17 +77,17 @@ static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_OK: - { - int len = SendDlgItemMessage(hwndDlg, IDC_STSMSG, WM_GETTEXTLENGTH, 0, 0); - if (len > 0) { - protoSetting->szMsg = (wchar_t*)realloc(protoSetting->szMsg, sizeof(wchar_t)*(len + 1)); - if (protoSetting->szMsg != NULL) - GetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->szMsg, len + 1); + { + int len = SendDlgItemMessage(hwndDlg, IDC_STSMSG, WM_GETTEXTLENGTH, 0, 0); + if (len > 0) { + protoSetting->m_szMsg = (wchar_t*)realloc(protoSetting->m_szMsg, sizeof(wchar_t)*(len + 1)); + if (protoSetting->m_szMsg != NULL) + GetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->m_szMsg, len + 1); + } + SendMessage(GetParent(hwndDlg), UM_STSMSGDLGCLOSED, TRUE, 0); + EndDialog(hwndDlg, IDC_OK); } - SendMessage(GetParent(hwndDlg), UM_STSMSGDLGCLOSED, TRUE, 0); - EndDialog(hwndDlg, IDC_OK); - } - break; + break; case IDC_CANCEL: SendMessage(GetParent(hwndDlg), UM_STSMSGDLGCLOSED, 0, 0); @@ -113,18 +113,18 @@ static int SetStatusList(HWND hwndDlg) lvItem.mask = LVIF_TEXT | LVIF_PARAM; for (int i = 0; i < confirmSettings->getCount(); i++) { - lvItem.pszText = (*confirmSettings)[i].tszAccName; + lvItem.pszText = (*confirmSettings)[i].m_tszAccName; if (ListView_GetItemCount(hList) < confirmSettings->getCount()) ListView_InsertItem(hList, &lvItem); int actualStatus; - switch ((*confirmSettings)[i].status) { - case ID_STATUS_LAST: actualStatus = (*confirmSettings)[i].lastStatus; break; - case ID_STATUS_CURRENT: actualStatus = CallProtoService((*confirmSettings)[i].szName, PS_GETSTATUS, 0, 0); break; - default: actualStatus = (*confirmSettings)[i].status; + switch ((*confirmSettings)[i].m_status) { + case ID_STATUS_LAST: actualStatus = (*confirmSettings)[i].m_lastStatus; break; + case ID_STATUS_CURRENT: actualStatus = CallProtoService((*confirmSettings)[i].m_szName, PS_GETSTATUS, 0, 0); break; + default: actualStatus = (*confirmSettings)[i].m_status; } wchar_t* status = pcli->pfnGetStatusModeDescription(actualStatus, 0); - switch ((*confirmSettings)[i].status) { + switch ((*confirmSettings)[i].m_status) { case ID_STATUS_LAST: mir_snwprintf(buf, L"%s (%s)", TranslateT("<last>"), status); ListView_SetItemText(hList, lvItem.iItem, 1, buf); @@ -138,10 +138,10 @@ static int SetStatusList(HWND hwndDlg) } // status message - if (!((!((CallProtoService((*confirmSettings)[i].szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService((*confirmSettings)[i].szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))))) { + if (!((!((CallProtoService((*confirmSettings)[i].m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService((*confirmSettings)[i].m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))))) { wchar_t *msg = GetDefaultStatusMessage(&(*confirmSettings)[i], actualStatus); if (msg != NULL) { - wchar_t* fMsg = variables_parsedup(msg, (*confirmSettings)[i].tszAccName, NULL); + wchar_t* fMsg = variables_parsedup(msg, (*confirmSettings)[i].m_tszAccName, NULL); ListView_SetItemText(hList, lvItem.iItem, 2, fMsg); mir_free(fMsg); mir_free(msg); @@ -216,17 +216,17 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_TIMER: - { - wchar_t text[32]; - mir_snwprintf(text, TranslateT("Closing in %d"), timeOut - 1); - SetDlgItemText(hwndDlg, IDC_CLOSE, text); - if (timeOut <= 0) { - KillTimer(hwndDlg, TIMER_ID); - SendMessage(hwndDlg, UM_CLOSECONFIRMDLG, 0, 0); + { + wchar_t text[32]; + mir_snwprintf(text, TranslateT("Closing in %d"), timeOut - 1); + SetDlgItemText(hwndDlg, IDC_CLOSE, text); + if (timeOut <= 0) { + KillTimer(hwndDlg, TIMER_ID); + SendMessage(hwndDlg, UM_CLOSECONFIRMDLG, 0, 0); + } + else timeOut--; } - else timeOut--; - } - break; + break; case WM_COMMAND: // stop timer @@ -235,77 +235,77 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == BN_CLICKED) || (HIWORD(wParam) == NM_CLICK)) { // something clicked switch (LOWORD(wParam)) { case IDC_PROFILE: - { - int profile = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0); - for (int i = 0; i < confirmSettings->getCount(); i++) - if ((*confirmSettings)[i].szMsg != NULL) { - free((*confirmSettings)[i].szMsg); - (*confirmSettings)[i].szMsg = NULL; - } - - CallService(MS_SS_GETPROFILE, (WPARAM)profile, (LPARAM)confirmSettings); - for (int i = 0; i < confirmSettings->getCount(); i++) - if ((*confirmSettings)[i].szMsg != NULL) // we free this later, copy to our memory space - (*confirmSettings)[i].szMsg = wcsdup((*confirmSettings)[i].szMsg); + { + int profile = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0); + for (int i = 0; i < confirmSettings->getCount(); i++) + if ((*confirmSettings)[i].m_szMsg != NULL) { + free((*confirmSettings)[i].m_szMsg); + (*confirmSettings)[i].m_szMsg = NULL; + } + + CallService(MS_SS_GETPROFILE, (WPARAM)profile, (LPARAM)confirmSettings); + for (int i = 0; i < confirmSettings->getCount(); i++) + if ((*confirmSettings)[i].m_szMsg != NULL) // we free this later, copy to our memory space + (*confirmSettings)[i].m_szMsg = wcsdup((*confirmSettings)[i].m_szMsg); - SetStatusList(hwndDlg); - } - break; + SetStatusList(hwndDlg); + } + break; case IDC_STATUS: - { - LVITEM lvItem = { 0 }; - lvItem.mask = LVIF_TEXT | LVIF_PARAM; - lvItem.iSubItem = 0; - lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED); - if (lvItem.iItem == -1) - break; - - ListView_GetItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), &lvItem); - PROTOCOLSETTINGEX* proto = (PROTOCOLSETTINGEX*)lvItem.lParam; - int actualStatus = proto->status = (int)SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0), 0); - - // LAST STATUS - if (proto->status == ID_STATUS_LAST) { - wchar_t last[80]; - mir_snwprintf(last, L"%s (%s)", TranslateT("<last>"), pcli->pfnGetStatusModeDescription(proto->lastStatus, 0)); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, last); - actualStatus = proto->lastStatus; - } + { + LVITEM lvItem = { 0 }; + lvItem.mask = LVIF_TEXT | LVIF_PARAM; + lvItem.iSubItem = 0; + lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED); + if (lvItem.iItem == -1) + break; + + ListView_GetItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), &lvItem); + PROTOCOLSETTINGEX* proto = (PROTOCOLSETTINGEX*)lvItem.lParam; + int actualStatus = proto->m_status = (int)SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0), 0); + + // LAST STATUS + if (proto->m_status == ID_STATUS_LAST) { + wchar_t last[80]; + mir_snwprintf(last, L"%s (%s)", TranslateT("<last>"), pcli->pfnGetStatusModeDescription(proto->m_lastStatus, 0)); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, last); + actualStatus = proto->m_lastStatus; + } - // CURRENT STATUS - else if (proto->status == ID_STATUS_CURRENT) { - int currentStatus = CallProtoService(proto->szName, PS_GETSTATUS, 0, 0); - wchar_t current[80]; - mir_snwprintf(current, L"%s (%s)", TranslateT("<current>"), pcli->pfnGetStatusModeDescription(currentStatus, 0)); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, current); - actualStatus = currentStatus; + // CURRENT STATUS + else if (proto->m_status == ID_STATUS_CURRENT) { + int currentStatus = CallProtoService(proto->m_szName, PS_GETSTATUS, 0, 0); + wchar_t current[80]; + mir_snwprintf(current, L"%s (%s)", TranslateT("<current>"), pcli->pfnGetStatusModeDescription(currentStatus, 0)); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, current); + actualStatus = currentStatus; + } + else ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, pcli->pfnGetStatusModeDescription(proto->m_status, 0)); + + if ((!((CallProtoService(proto->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)))) + EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), FALSE); + else if ((proto->m_status == ID_STATUS_LAST) || (proto->m_status == ID_STATUS_CURRENT)) + EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), TRUE); + else + EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)) ? TRUE : FALSE); + SetStatusList(hwndDlg); } - else ListView_SetItemText(GetDlgItem(hwndDlg, IDC_STARTUPLIST), lvItem.iItem, 1, pcli->pfnGetStatusModeDescription(proto->status, 0)); - - if ((!((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)))) - EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), FALSE); - else if ((proto->status == ID_STATUS_LAST) || (proto->status == ID_STATUS_CURRENT)) - EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), TRUE); - else - EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)) ? TRUE : FALSE); - SetStatusList(hwndDlg); - } - break; + break; case IDC_SETSTSMSG: - { - LVITEM lvItem = { 0 }; - lvItem.mask = LVIF_TEXT | LVIF_PARAM; - lvItem.iSubItem = 0; - lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED); - if (lvItem.iItem == -1) - break; - - ListView_GetItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), &lvItem); - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETSTSMSGDIALOG), hwndDlg, StatusMessageDlgProc, lvItem.lParam); - } - break; + { + LVITEM lvItem = { 0 }; + lvItem.mask = LVIF_TEXT | LVIF_PARAM; + lvItem.iSubItem = 0; + lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED); + if (lvItem.iItem == -1) + break; + + ListView_GetItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), &lvItem); + DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETSTSMSGDIALOG), hwndDlg, StatusMessageDlgProc, lvItem.lParam); + } + break; case IDC_CLOSE: SendMessage(hwndDlg, UM_CLOSECONFIRMDLG, 0, 0); @@ -336,49 +336,49 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP } PROTOCOLSETTINGEX *proto = (PROTOCOLSETTINGEX*)lvItem.lParam; - int flags = CallProtoService(proto->szName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); + int flags = CallProtoService(proto->m_szName, PS_GETCAPS, PFLAGNUM_2, 0) & ~CallProtoService(proto->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); // clear box and add new status, loop status and check if compatible with proto SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_RESETCONTENT, 0, 0); - int actualStatus = proto->status; + int actualStatus = proto->m_status; // last wchar_t buf[100]; - mir_snwprintf(buf, L"%s (%s)", TranslateT("<last>"), pcli->pfnGetStatusModeDescription(proto->lastStatus, 0)); + mir_snwprintf(buf, L"%s (%s)", TranslateT("<last>"), pcli->pfnGetStatusModeDescription(proto->m_lastStatus, 0)); int item = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)buf); SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, item, ID_STATUS_LAST); - if (proto->status == ID_STATUS_LAST) { + if (proto->m_status == ID_STATUS_LAST) { SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, item, 0); - actualStatus = proto->lastStatus; + actualStatus = proto->m_lastStatus; } // current - int currentStatus = CallProtoService(proto->szName, PS_GETSTATUS, 0, 0); + int currentStatus = CallProtoService(proto->m_szName, PS_GETSTATUS, 0, 0); mir_snwprintf(buf, L"%s (%s)", TranslateT("<current>"), pcli->pfnGetStatusModeDescription(currentStatus, 0)); item = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)buf); SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, item, ID_STATUS_CURRENT); - if (proto->status == ID_STATUS_CURRENT) { + if (proto->m_status == ID_STATUS_CURRENT) { SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, item, 0); actualStatus = currentStatus; } for (int i = 0; i < _countof(statusModeList); i++) { - if (((flags & statusModePf2List[i]) || (statusModePf2List[i] == PF2_OFFLINE)) && (!((!(flags)& Proto_Status2Flag(statusModePf2List[i]))) || ((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0)&Proto_Status2Flag(statusModePf2List[i]))))) { + if (((flags & statusModePf2List[i]) || (statusModePf2List[i] == PF2_OFFLINE)) && (!((!(flags)& Proto_Status2Flag(statusModePf2List[i]))) || ((CallProtoService(proto->m_szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0)&Proto_Status2Flag(statusModePf2List[i]))))) { wchar_t *statusMode = pcli->pfnGetStatusModeDescription(statusModeList[i], 0); item = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)statusMode); SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, item, statusModeList[i]); - if (statusModeList[i] == proto->status) + if (statusModeList[i] == proto->m_status) SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, item, 0); } } // enable status box EnableWindow(GetDlgItem(hwndDlg, IDC_STATUS), (ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED) >= 0)); - if ((!((CallProtoService(proto->szName, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->szName, PS_GETCAPS, PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)))) + if ((!((CallProtoService(proto->m_szName, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->m_szName, PS_GETCAPS, PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus)))) EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), FALSE); - else if (proto->status == ID_STATUS_LAST || proto->status == ID_STATUS_CURRENT) + else if (proto->m_status == ID_STATUS_LAST || proto->m_status == ID_STATUS_CURRENT) EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), TRUE); else - EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->szName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(actualStatus)) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->m_szName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(actualStatus)) ? TRUE : FALSE); } } break; diff --git a/plugins/StatusManager/src/version.h b/plugins/StatusManager/src/version.h index e853240085..9d249a356e 100644 --- a/plugins/StatusManager/src/version.h +++ b/plugins/StatusManager/src/version.h @@ -2,7 +2,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 11 #define __RELEASE_NUM 2 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 // other stuff for Version resource #include <stdver.h> |