diff options
author | George Hazan <ghazan@miranda.im> | 2017-10-15 15:28:23 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-10-15 15:28:23 +0300 |
commit | cc2d5db55ce7c1d65d7919c7e7f0ce5c48da26f2 (patch) | |
tree | b23e75abe8f09cd6e45d41f078878271079dedc0 /plugins/StatusManager/src | |
parent | 73c3207950044c5156bbb74ca2f60fc5b5b2d81a (diff) |
StatusManager: code cleaning
Diffstat (limited to 'plugins/StatusManager/src')
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp | 18 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp | 58 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp | 74 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.cpp | 382 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.h | 1 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/ks_options.cpp | 330 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_options.cpp | 196 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_profiles.cpp | 68 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp | 14 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/startupstatus.cpp | 116 | ||||
-rw-r--r-- | plugins/StatusManager/src/commonstatus.cpp | 16 | ||||
-rw-r--r-- | plugins/StatusManager/src/confirmdialog.cpp | 26 | ||||
-rw-r--r-- | plugins/StatusManager/src/options.cpp | 10 | ||||
-rw-r--r-- | plugins/StatusManager/src/version.h | 2 |
14 files changed, 657 insertions, 654 deletions
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp index b18d1ef558..35834d4e75 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp @@ -74,14 +74,14 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L settings[count]->status = statusModeList[i]; DBVARIANT dbv; - if (!db_get(NULL, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_STATUSMSG), &dbv)) { + if (!db_get(0, 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); } - else settings[count]->msg = NULL; + else settings[count]->msg = nullptr; - settings[count]->useCustom = db_get_b(NULL, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_MSGCUSTOM), FALSE); + settings[count]->useCustom = db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(statusModeList[i], SETTING_MSGCUSTOM), FALSE); count += 1; } SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); @@ -113,7 +113,7 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L int i = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0); int len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); if (last != -1) { - if (settings[last]->msg == NULL) + if (settings[last]->msg == nullptr) settings[last]->msg = (char*)malloc(len + 1); else settings[last]->msg = (char*)realloc(settings[last]->msg, len + 1); @@ -121,11 +121,11 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L } if (i != -1) { - if (settings[i]->msg != NULL) + if (settings[i]->msg != nullptr) SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[i]->msg); else { ptrW msgw((wchar_t*)CallService(MS_AWAYMSG_GETSTATUSMSGW, settings[i]->status, 0)); - SetDlgItemText(hwndDlg, IDC_STATUSMSG, (msgw != NULL) ? msgw : L""); + SetDlgItemText(hwndDlg, IDC_STATUSMSG, (msgw != nullptr) ? msgw : L""); } if (settings[i]->useCustom) { @@ -156,9 +156,9 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L 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); + db_set_b(0, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status, SETTING_MSGCUSTOM), (BYTE)settings[i]->useCustom); + if ((settings[i]->useCustom) && (settings[i]->msg != nullptr) && (settings[i]->msg[0] != '\0')) + db_set_s(0, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status, SETTING_STATUSMSG), settings[i]->msg); } break; } diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp index c069b46db8..58b79a22f0 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp @@ -32,17 +32,17 @@ static int WriteAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoNa { char setting[128]; mir_snprintf(setting, "%s_OptionFlags", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.optionFlags); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.optionFlags); mir_snprintf(setting, "%s_AwayTime", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.awayTime); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.awayTime); mir_snprintf(setting, "%s_NATime", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.naTime); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.naTime); mir_snprintf(setting, "%s_StatusFlags", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.statusFlags); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.statusFlags); mir_snprintf(setting, "%s_Lv1Status", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv1Status); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv1Status); mir_snprintf(setting, "%s_Lv2Status", protoName); - db_set_w(NULL, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv2Status); + db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv2Status); return 0; } @@ -90,16 +90,16 @@ static TAAAProtoSetting* GetSetting(HWND hwndDlg, TAAAProtoSetting *sameSetting) int iItem = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_GETCURSEL, 0, 0); if (iItem == -1) - return NULL; + return nullptr; INT_PTR iData = (INT_PTR)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_GETITEMDATA, iItem, 0); - return (iData == -1) ? NULL : (TAAAProtoSetting*)iData; + return (iData == -1) ? nullptr : (TAAAProtoSetting*)iData; } static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting) { TAAAProtoSetting *setting = GetSetting(hwndDlg, sameSetting); - if (setting == NULL) + if (setting == nullptr) return; // create columns @@ -265,11 +265,11 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM break; case IDC_AWAYTIME: - setting->awayTime = GetDlgItemInt(hwndDlg, IDC_AWAYTIME, NULL, FALSE); + setting->awayTime = GetDlgItemInt(hwndDlg, IDC_AWAYTIME, nullptr, FALSE); break; case IDC_NATIME: - setting->naTime = GetDlgItemInt(hwndDlg, IDC_NATIME, NULL, FALSE); + setting->naTime = GetDlgItemInt(hwndDlg, IDC_NATIME, nullptr, FALSE); break; case IDC_LV2ONINACTIVE: @@ -362,19 +362,19 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_IGNLOCK, db_get_b(NULL, AAAMODULENAME, SETTING_IGNLOCK, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IGNSYSKEYS, db_get_b(NULL, AAAMODULENAME, SETTING_IGNSYSKEYS, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_IGNALTCOMBO, db_get_b(NULL, AAAMODULENAME, SETTING_IGNALTCOMBO, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MONITORMOUSE, db_get_b(NULL, AAAMODULENAME, SETTING_MONITORMOUSE, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MONITORKEYBOARD, db_get_b(NULL, AAAMODULENAME, SETTING_MONITORKEYBOARD, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, db_get_w(NULL, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5), FALSE); - SetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, db_get_w(NULL, AAAMODULENAME, SETTING_CONFIRMDELAY, 5), FALSE); + CheckDlgButton(hwndDlg, IDC_IGNLOCK, db_get_b(0, AAAMODULENAME, SETTING_IGNLOCK, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IGNSYSKEYS, db_get_b(0, AAAMODULENAME, SETTING_IGNSYSKEYS, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IGNALTCOMBO, db_get_b(0, AAAMODULENAME, SETTING_IGNALTCOMBO, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MONITORMOUSE, db_get_b(0, AAAMODULENAME, SETTING_MONITORMOUSE, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MONITORKEYBOARD, db_get_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, db_get_w(0, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5), FALSE); + SetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5), FALSE); CheckDlgButton(hwndDlg, bSettingSame ? IDC_SAMESETTINGS : IDC_PERPROTOCOLSETTINGS, BST_CHECKED); - ShowWindow(GetDlgItem(hwndDlg, IDC_IDLEWARNING), db_get_b(NULL, "Idle", "AAEnable", 0)); + ShowWindow(GetDlgItem(hwndDlg, IDC_IDLEWARNING), db_get_b(0, "Idle", "AAEnable", 0)); break; case WM_SHOWWINDOW: - ShowWindow(GetDlgItem(hwndDlg, IDC_IDLEWARNING), (db_get_b(NULL, "Idle", "AAEnable", 0))); + ShowWindow(GetDlgItem(hwndDlg, IDC_IDLEWARNING), (db_get_b(0, "Idle", "AAEnable", 0))); break; case WM_COMMAND: @@ -399,14 +399,14 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - db_set_b(NULL, AAAMODULENAME, SETTING_IGNLOCK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNLOCK)); - db_set_b(NULL, AAAMODULENAME, SETTING_IGNSYSKEYS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNSYSKEYS)); - db_set_b(NULL, AAAMODULENAME, SETTING_IGNALTCOMBO, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNALTCOMBO)); - db_set_b(NULL, AAAMODULENAME, SETTING_SAMESETTINGS, (BYTE)bSettingSame); - db_set_w(NULL, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, (WORD)GetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, NULL, FALSE)); - db_set_w(NULL, AAAMODULENAME, SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, NULL, FALSE)); - db_set_b(NULL, AAAMODULENAME, SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE)); - db_set_b(NULL, AAAMODULENAME, SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD)); + db_set_b(0, AAAMODULENAME, SETTING_IGNLOCK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNLOCK)); + db_set_b(0, AAAMODULENAME, SETTING_IGNSYSKEYS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNSYSKEYS)); + db_set_b(0, AAAMODULENAME, SETTING_IGNALTCOMBO, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNALTCOMBO)); + db_set_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, (BYTE)bSettingSame); + db_set_w(0, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, (WORD)GetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, nullptr, FALSE)); + db_set_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, nullptr, FALSE)); + db_set_b(0, AAAMODULENAME, SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE)); + db_set_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD)); AAALoadOptions(autoAwaySettings, FALSE); } break; @@ -424,7 +424,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayTabs(HWND hwndDlg, UINT msg, WPARAM, LPAR TranslateDialogDefault(hwndDlg); { RECT rcTabs, rcOptions, rcPage; - bSettingSame = db_get_b(NULL, AAAMODULENAME, SETTING_SAMESETTINGS, FALSE); + bSettingSame = db_get_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, FALSE); // set tabs int tabCount = 0; diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp index c15fc40239..71805df1c1 100644 --- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp @@ -37,7 +37,7 @@ TAAAProtoSetting::TAAAProtoSetting(PROTOACCOUNT *pa) m_szName = pa->szModuleName; m_tszAccName = pa->tszAccountName; m_lastStatus = m_status = originalStatusMode = ID_STATUS_CURRENT; - m_szMsg = NULL; + m_szMsg = nullptr; curState = ACTIVE; mStatus = FALSE; } @@ -49,7 +49,7 @@ TAAAProtoSetting::~TAAAProtoSetting() ///////////////////////////////////////////////////////////////////////////////////////// -HANDLE hStateChangedEvent = NULL; +HANDLE hStateChangedEvent = nullptr; static BOOL ignoreLockKeys = FALSE; static BOOL ignoreSysKeys = FALSE; @@ -58,13 +58,13 @@ static BOOL monitorMouse = TRUE; static BOOL monitorKeyboard = TRUE; static HWND confirmDialog; static int mouseStationaryTimer; -HHOOK hMirandaMouseHook = NULL; -HHOOK hMirandaKeyBoardHook = NULL; +HHOOK hMirandaMouseHook = nullptr; +HHOOK hMirandaKeyBoardHook = nullptr; #pragma data_seg("Shared") DWORD lastInput = 0; POINT lastMousePos = { 0 }; -HHOOK hMouseHook = NULL; -HHOOK hKeyBoardHook = NULL; +HHOOK hMouseHook = nullptr; +HHOOK hKeyBoardHook = nullptr; #pragma data_seg() #pragma comment(linker, "/section:Shared,rws") DWORD lastMirandaInput = 0; @@ -95,18 +95,18 @@ void AAALoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) if (!override) UnhookWindowsHooks(); if (hAutoAwayTimer != 0) - KillTimer(NULL, hAutoAwayTimer); + KillTimer(nullptr, hAutoAwayTimer); - ignoreLockKeys = db_get_b(NULL, AAAMODULENAME, SETTING_IGNLOCK, FALSE); - ignoreSysKeys = db_get_b(NULL, AAAMODULENAME, SETTING_IGNSYSKEYS, FALSE); - ignoreAltCombo = db_get_b(NULL, AAAMODULENAME, SETTING_IGNALTCOMBO, FALSE); - monitorMouse = db_get_b(NULL, AAAMODULENAME, SETTING_MONITORMOUSE, TRUE); - monitorKeyboard = db_get_b(NULL, AAAMODULENAME, SETTING_MONITORKEYBOARD, TRUE); + ignoreLockKeys = db_get_b(0, AAAMODULENAME, SETTING_IGNLOCK, FALSE); + ignoreSysKeys = db_get_b(0, AAAMODULENAME, SETTING_IGNSYSKEYS, FALSE); + ignoreAltCombo = db_get_b(0, AAAMODULENAME, SETTING_IGNALTCOMBO, FALSE); + monitorMouse = db_get_b(0, AAAMODULENAME, SETTING_MONITORMOUSE, TRUE); + monitorKeyboard = db_get_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, TRUE); lastInput = lastMirandaInput = GetTickCount(); for (int i = 0; i < loadSettings.getCount(); i++) { char* protoName; - if ((db_get_b(NULL, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) && !override) + if ((db_get_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) && !override) protoName = SETTING_ALL; else protoName = loadSettings[i].m_szName; @@ -119,34 +119,34 @@ void AAALoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) } } - if (db_get_b(NULL, "Idle", "AAEnable", 0)) + if (db_get_b(0, "Idle", "AAEnable", 0)) return; HookWindowsHooks(monitorMiranda, monitorAll); - hAutoAwayTimer = SetTimer(NULL, 0, db_get_w(NULL, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5) * 1000, AutoAwayTimer); + hAutoAwayTimer = SetTimer(nullptr, 0, db_get_w(0, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5) * 1000, AutoAwayTimer); } int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char* protoName) { char setting[128]; mir_snprintf(setting, "%s_OptionFlags", protoName); - autoAwaySetting.optionFlags = db_get_w(NULL, AAAMODULENAME, setting, FLAG_LV2ONINACTIVE | FLAG_RESET); + autoAwaySetting.optionFlags = db_get_w(0, AAAMODULENAME, setting, FLAG_LV2ONINACTIVE | FLAG_RESET); mir_snprintf(setting, "%s_AwayTime", protoName); - autoAwaySetting.awayTime = db_get_w(NULL, AAAMODULENAME, setting, SETTING_AWAYTIME_DEFAULT); + autoAwaySetting.awayTime = db_get_w(0, AAAMODULENAME, setting, SETTING_AWAYTIME_DEFAULT); mir_snprintf(setting, "%s_NATime", protoName); - autoAwaySetting.naTime = db_get_w(NULL, AAAMODULENAME, setting, SETTING_NATIME_DEFAULT); + autoAwaySetting.naTime = db_get_w(0, AAAMODULENAME, setting, SETTING_NATIME_DEFAULT); mir_snprintf(setting, "%s_StatusFlags", protoName); - autoAwaySetting.statusFlags = db_get_w(NULL, AAAMODULENAME, setting, StatusModeToProtoFlag(ID_STATUS_ONLINE) | StatusModeToProtoFlag(ID_STATUS_FREECHAT)); + autoAwaySetting.statusFlags = db_get_w(0, AAAMODULENAME, setting, StatusModeToProtoFlag(ID_STATUS_ONLINE) | StatusModeToProtoFlag(ID_STATUS_FREECHAT)); int flags; - if (db_get_b(NULL, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) + if (db_get_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) flags = 0xFFFFFF; else flags = CallProtoService(protoName, PS_GETCAPS, PFLAGNUM_2, 0)&~CallProtoService(protoName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0); mir_snprintf(setting, "%s_Lv1Status", protoName); - autoAwaySetting.lv1Status = db_get_w(NULL, AAAMODULENAME, setting, (flags&StatusModeToProtoFlag(ID_STATUS_AWAY)) ? ID_STATUS_AWAY : ID_STATUS_OFFLINE); + autoAwaySetting.lv1Status = db_get_w(0, AAAMODULENAME, setting, (flags&StatusModeToProtoFlag(ID_STATUS_AWAY)) ? ID_STATUS_AWAY : ID_STATUS_OFFLINE); mir_snprintf(setting, "%s_Lv2Status", protoName); - autoAwaySetting.lv2Status = db_get_w(NULL, AAAMODULENAME, setting, (flags&StatusModeToProtoFlag(ID_STATUS_NA)) ? ID_STATUS_NA : ID_STATUS_OFFLINE); + autoAwaySetting.lv2Status = db_get_w(0, AAAMODULENAME, setting, (flags&StatusModeToProtoFlag(ID_STATUS_NA)) ? ID_STATUS_NA : ID_STATUS_OFFLINE); return 0; } @@ -222,22 +222,22 @@ static int changeState(TAAAProtoSetting &setting, STATES newState) NotifyEventHooks(hStateChangedEvent, 0, (LPARAM)&setting); if (setting.curState != SET_ORGSTATUS && setting.curState != ACTIVE && setting.statusChanged) { /* change the awaymessage */ - if (setting.m_szMsg != NULL) { + if (setting.m_szMsg != nullptr) { free(setting.m_szMsg); - setting.m_szMsg = NULL; + setting.m_szMsg = nullptr; } - if (db_get_b(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_MSGCUSTOM), FALSE)) { + if (db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_MSGCUSTOM), FALSE)) { DBVARIANT dbv; - if (!db_get_ws(NULL, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_STATUSMSG), &dbv)) { + if (!db_get_ws(0, AAAMODULENAME, StatusModeToDbSetting(setting.m_status, SETTING_STATUSMSG), &dbv)) { setting.m_szMsg = wcsdup(dbv.ptszVal); db_free(&dbv); } } } - else if (setting.m_szMsg != NULL) { + else if (setting.m_szMsg != nullptr) { free(setting.m_szMsg); - setting.m_szMsg = NULL; + setting.m_szMsg = nullptr; } return 0; @@ -370,7 +370,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) } if (confirm) - confirmDialog = ShowConfirmDialogEx((TProtoSettings*)&ps, db_get_w(NULL, AAAMODULENAME, SETTING_CONFIRMDELAY, 5)); + confirmDialog = ShowConfirmDialogEx((TProtoSettings*)&ps, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5)); else if (statusChanged) CallService(MS_CS_SETSTATUSEX, (WPARAM)&ps, 0); } @@ -382,15 +382,15 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) static int HookWindowsHooks(int hookMiranda, int hookAll) { if (hookMiranda) { - if (monitorKeyboard && hMirandaKeyBoardHook == NULL) - hMirandaKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, MirandaKeyBoardHookFunction, NULL, GetCurrentThreadId()); - if (monitorMouse && hMirandaMouseHook == NULL) - hMirandaMouseHook = SetWindowsHookEx(WH_MOUSE, MirandaMouseHookFunction, NULL, GetCurrentThreadId()); + if (monitorKeyboard && hMirandaKeyBoardHook == nullptr) + hMirandaKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, MirandaKeyBoardHookFunction, nullptr, GetCurrentThreadId()); + if (monitorMouse && hMirandaMouseHook == nullptr) + hMirandaMouseHook = SetWindowsHookEx(WH_MOUSE, MirandaMouseHookFunction, nullptr, GetCurrentThreadId()); } if (hookAll) { - if (monitorKeyboard && hKeyBoardHook == NULL) + if (monitorKeyboard && hKeyBoardHook == nullptr) hKeyBoardHook = SetWindowsHookEx(WH_KEYBOARD, KeyBoardHookFunction, 0, GetCurrentThreadId()); - if (monitorMouse && hMouseHook == NULL) + if (monitorMouse && hMouseHook == nullptr) hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookFunction, 0, GetCurrentThreadId()); } @@ -404,7 +404,7 @@ static int UnhookWindowsHooks() UnhookWindowsHookEx(hMirandaMouseHook); UnhookWindowsHookEx(hMirandaKeyBoardHook); - hMouseHook = hKeyBoardHook = hMirandaMouseHook = hMirandaKeyBoardHook = NULL; + hMouseHook = hKeyBoardHook = hMirandaMouseHook = hMirandaKeyBoardHook = nullptr; return 0; } @@ -539,7 +539,7 @@ static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lPa static int AutoAwayShutdown(WPARAM, LPARAM) { - KillTimer(NULL, hAutoAwayTimer); + KillTimer(nullptr, hAutoAwayTimer); #ifdef TRIGGERPLUGIN DeInitTrigger(); diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index def0bdf677..148f62a9ff 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -31,16 +31,16 @@ struct TimerInfo HANDLE hMainThread = 0; unsigned long mainThreadId = 0; -HANDLE hConnectionEvent = NULL; +HANDLE hConnectionEvent = nullptr; static mir_cs GenTimerCS, GenStatusCS, CheckContinueslyCS; -static HANDLE hProtoAckHook = NULL; -static HANDLE hStatusChangeHook = NULL; -static HANDLE hCSStatusChangeHook = NULL; -static HANDLE hCSStatusChangeExHook = NULL; +static HANDLE hProtoAckHook = nullptr; +static HANDLE hStatusChangeHook = nullptr; +static HANDLE hCSStatusChangeHook = nullptr; +static HANDLE hCSStatusChangeExHook = nullptr; -static HWND hMessageWindow = NULL; +static HWND hMessageWindow = nullptr; static int CompareConnections(const TKSSettings *p1, const TKSSettings *p2) { @@ -92,7 +92,7 @@ TKSSettings::TKSSettings(PROTOACCOUNT *pa) { m_szName = pa->szModuleName; m_tszAccName = pa->tszAccountName; - m_szMsg = NULL; + m_szMsg = nullptr; int iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); AssignStatus(iStatus, iStatus, nullptr); @@ -100,7 +100,7 @@ TKSSettings::TKSSettings(PROTOACCOUNT *pa) TKSSettings::~TKSSettings() { - if (m_szMsg != NULL) + if (m_szMsg != nullptr) free(m_szMsg); } @@ -114,25 +114,26 @@ int KSLoadOptions() if (IsWindow(hMessageWindow)) DestroyWindow(hMessageWindow); - if (StartTimer(IDT_CHECKCONTIN, -1, FALSE)) { + + if (StartTimer(IDT_CHECKCONTIN, -1, FALSE)) WSACleanup(); - } + StopTimer(IDT_CHECKCONN | IDT_PROCESSACK | IDT_AFTERCHECK | IDT_CHECKCONTIN | IDT_CHECKCONNECTING); GetCurrentConnectionSettings(); - if (db_get_b(NULL, KSMODULENAME, SETTING_CHECKCONNECTION, FALSE)) { - if (db_get_b(NULL, KSMODULENAME, SETTING_CONTCHECK, FALSE)) { - if (db_get_b(NULL, KSMODULENAME, SETTING_BYPING, FALSE)) { + if (db_get_b(0, KSMODULENAME, SETTING_CHECKCONNECTION, FALSE)) { + if (db_get_b(0, KSMODULENAME, SETTING_CONTCHECK, FALSE)) { + if (db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE)) { WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); } StartTimer(IDT_CHECKCONTIN, 0, FALSE); } - increaseExponential = db_get_b(NULL, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, FALSE); - currentDelay = initDelay = 1000 * db_get_dw(NULL, KSMODULENAME, SETTING_INITDELAY, DEFAULT_INITDELAY); - maxDelay = 1000 * db_get_dw(NULL, KSMODULENAME, SETTING_MAXDELAY, DEFAULT_MAXDELAY); - maxRetries = db_get_b(NULL, KSMODULENAME, SETTING_MAXRETRIES, 0); + increaseExponential = db_get_b(0, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, FALSE); + currentDelay = initDelay = 1000 * db_get_dw(0, KSMODULENAME, SETTING_INITDELAY, DEFAULT_INITDELAY); + maxDelay = 1000 * db_get_dw(0, KSMODULENAME, SETTING_MAXDELAY, DEFAULT_MAXDELAY); + maxRetries = db_get_b(0, KSMODULENAME, SETTING_MAXRETRIES, 0); if (maxRetries == 0) maxRetries = -1; hProtoAckHook = HookEvent(ME_PROTO_ACK, ProcessProtoAck); @@ -140,9 +141,9 @@ int KSLoadOptions() if (ServiceExists(ME_CS_STATUSCHANGE)) hCSStatusChangeHook = HookEvent(ME_CS_STATUSCHANGE, CSStatusChange); hCSStatusChangeExHook = HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChangeEx); - if (db_get_b(NULL, KSMODULENAME, SETTING_CHECKAPMRESUME, 0)) { + if (db_get_b(0, KSMODULENAME, SETTING_CHECKAPMRESUME, 0)) { if (!IsWindow(hMessageWindow)) { - hMessageWindow = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc); } } @@ -169,20 +170,20 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() { mir_cslock lck(GenStatusCS); PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(connectionSettings.getCount() * sizeof(PROTOCOLSETTINGEX *)); - if (ps == NULL) { - return NULL; + if (ps == nullptr) { + return nullptr; } for (int i = 0; i < connectionSettings.getCount(); i++) { ps[i] = (PROTOCOLSETTINGEX*)calloc(1, sizeof(PROTOCOLSETTINGEX)); - if (ps[i] == NULL) { + if (ps[i] == nullptr) { free(ps); - return NULL; + return nullptr; } - TKSSettings& cs = connectionSettings[i]; + 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_szMsg = nullptr; ps[i]->m_szName = cs.m_szName; ps[i]->m_tszAccName = cs.m_tszAccName; } @@ -193,7 +194,7 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy() static void FreeProtoSettings(PROTOCOLSETTINGEX** ps) { for (int i = 0; i < connectionSettings.getCount(); i++) { - if (ps[i]->m_szMsg != NULL) + if (ps[i]->m_szMsg != nullptr) free(ps[i]->m_szMsg); free(ps[i]); } @@ -206,58 +207,68 @@ int TKSSettings::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg) 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)) + if (!db_get_b(0, KSMODULENAME, SETTING_NOLOCKED, 0) && db_get_b(0, m_szName, "LockMainStatus", 0)) return -3; mir_cslock lck(GenStatusCS); char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", m_szName); - m_lastStatus = iLastStatus == 0 ? m_status : iLastStatus; - if (!db_get_b(NULL, KSMODULENAME, dbSetting, 1)) + m_lastStatus = (iLastStatus == 0) ? m_status : iLastStatus; + if (!db_get_b(0, KSMODULENAME, dbSetting, 1)) m_status = ID_STATUS_DISABLED; - else if (m_status == ID_STATUS_LAST) + else if (iStatus == ID_STATUS_LAST) m_status = m_lastStatus; else m_status = iStatus; - log_infoA("KeepStatus: assigning status %d to %s", m_status, m_szName); + log_infoA("KeepStatus: assigning status %d (%d, %d) to %s", m_status, m_lastStatus, iLastStatus, m_szName); - if (pwszMsg != NULL && mir_wstrcmp(pwszMsg, m_szMsg)) { - if (m_szMsg != NULL) + if (pwszMsg != nullptr && mir_wstrcmp(pwszMsg, m_szMsg)) { + if (m_szMsg != nullptr) free(m_szMsg); m_szMsg = wcsdup(pwszMsg); } else if (pwszMsg != m_szMsg) { - if (m_szMsg != NULL) + if (m_szMsg != nullptr) free(m_szMsg); - m_szMsg = NULL; + m_szMsg = nullptr; } return 0; } -static int GetStatus(const TKSSettings& cs) +int TKSSettings::GetStatus() const { - if (cs.m_status == ID_STATUS_CURRENT) - return CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); - - return cs.m_status; + switch (m_status) { + case ID_STATUS_CURRENT: + return CallProtoService(m_szName, PS_GETSTATUS, 0, 0); + case ID_STATUS_LAST: + return m_lastStatus; + default: + return m_status; + } } static int SetCurrentStatus() { PROTOCOLSETTINGEX **ps = GetCurrentProtoSettingsCopy(); for (int i = 0; i < connectionSettings.getCount(); i++) { - 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 = ""; + auto p = ps[i]; + int realStatus = CallProtoService(p->m_szName, PS_GETSTATUS, 0, 0); + int curStatus = connectionSettings[i].GetStatus(); + if (curStatus == ID_STATUS_DISABLED || curStatus == realStatus) { // ignore this proto by removing it's name (not so nice) + p->m_szName = ""; } - 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]->m_szName); - CallProtoService(ps[i]->m_szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); + else { + log_infoA("KeepStatus: status for %s differs: stored = %d, real = %d", p->m_szName, curStatus, realStatus); + + // force offline before reconnecting? + if (realStatus != ID_STATUS_OFFLINE && db_get_b(0, KSMODULENAME, SETTING_FIRSTOFFLINE, FALSE)) { + log_infoA("KeepStatus: Setting %s offline before making a new connection attempt", p->m_szName); + CallProtoService(p->m_szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); + } } } ProcessPopup(KS_CONN_STATE_RETRY, (LPARAM)ps); @@ -269,16 +280,16 @@ static int SetCurrentStatus() static int StatusChange(WPARAM wParam, LPARAM lParam) { - char* szProto = (char *)lParam; - if (szProto == NULL) { // global status change + char *szProto = (char *)lParam; + if (szProto == nullptr) { // global status change for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; cs.AssignStatus(wParam, 0, cs.m_szMsg); } } else { for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; if (!mir_strcmp(cs.m_szName, szProto)) cs.AssignStatus(wParam, 0, cs.m_szMsg); } @@ -291,17 +302,22 @@ static int CSStatusChange(WPARAM wParam, LPARAM) { // the status was changed by commonstatus (old) if (wParam != 0) { - PROTOCOLSETTING** protoSettings = *(PROTOCOLSETTING***)wParam; - if (protoSettings == NULL) + PROTOCOLSETTING **protoSettings = *(PROTOCOLSETTING***)wParam; + if (protoSettings == nullptr) return -1; for (int i = 0; i < connectionSettings.getCount(); i++) { + auto psi = protoSettings[i]; + if (psi->szName == nullptr) + continue; + for (int j = 0; j < connectionSettings.getCount(); j++) { - if ((protoSettings[i]->szName == NULL) || (connectionSettings[j].m_szName == NULL)) + TKSSettings &cs = connectionSettings[i]; + if (cs.m_szName == nullptr) continue; - if (!mir_strcmp(protoSettings[i]->szName, connectionSettings[j].m_szName)) - connectionSettings[j].AssignStatus(protoSettings[i]->status, protoSettings[i]->lastStatus, connectionSettings[j].m_szMsg); + if (!mir_strcmp(psi->szName, cs.m_szName)) + cs.AssignStatus(psi->status, psi->lastStatus, cs.m_szMsg); } } } @@ -314,17 +330,21 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM) // the status was changed by commonstatus (new) if (wParam != 0) { PROTOCOLSETTINGEX** protoSettings = *(PROTOCOLSETTINGEX***)wParam; - - if (protoSettings == NULL) + if (protoSettings == nullptr) return -1; for (int i = 0; i < connectionSettings.getCount(); i++) { + auto psi = protoSettings[i]; + if (psi->m_szName == nullptr) + continue; + for (int j = 0; j < connectionSettings.getCount(); j++) { - if ((protoSettings[i]->m_szName == NULL) || (connectionSettings[j].m_szName == NULL)) + TKSSettings &cs = connectionSettings[i]; + if (cs.m_szName == nullptr) continue; - 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); + if (!mir_strcmp(psi->m_szName, cs.m_szName)) + cs.AssignStatus(psi->m_status, psi->m_lastStatus, psi->m_szMsg); } } } @@ -344,11 +364,11 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) if (((processAckTimerId == 0) && (checkConnectionTimerId == 0)) || (restart)) { if (timeout != -1) { if (restart) - KillTimer(NULL, processAckTimerId); + KillTimer(nullptr, processAckTimerId); if (timeout == 0) - processAckTimerId = SetTimer(NULL, 0, ackDelay, CheckAckStatusTimer); + processAckTimerId = SetTimer(nullptr, 0, ackDelay, CheckAckStatusTimer); else - processAckTimerId = SetTimer(NULL, 0, timeout, CheckAckStatusTimer); + processAckTimerId = SetTimer(nullptr, 0, timeout, CheckAckStatusTimer); } } } @@ -358,11 +378,11 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) if ((checkConnectionTimerId == 0) || (restart)) { if (timeout != -1) { if (restart) - KillTimer(NULL, checkConnectionTimerId); + KillTimer(nullptr, checkConnectionTimerId); if (timeout == 0) - checkConnectionTimerId = SetTimer(NULL, 0, initDelay, CheckConnectionTimer); + checkConnectionTimerId = SetTimer(nullptr, 0, initDelay, CheckConnectionTimer); else - checkConnectionTimerId = SetTimer(NULL, 0, timeout, CheckConnectionTimer); + checkConnectionTimerId = SetTimer(nullptr, 0, timeout, CheckConnectionTimer); } } } @@ -372,11 +392,11 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) if ((afterCheckTimerId == 0) || (restart)) { if (timeout != -1) { if (restart) - KillTimer(NULL, afterCheckTimerId); + KillTimer(nullptr, afterCheckTimerId); if (timeout == 0) - afterCheckTimerId = SetTimer(NULL, 0, initDelay / 2, AfterCheckTimer); + afterCheckTimerId = SetTimer(nullptr, 0, initDelay / 2, AfterCheckTimer); else - afterCheckTimerId = SetTimer(NULL, 0, timeout, AfterCheckTimer); + afterCheckTimerId = SetTimer(nullptr, 0, timeout, AfterCheckTimer); } } } @@ -386,12 +406,12 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) if ((checkContinTimerId == 0) || (restart)) { if (timeout != -1) { if (restart) - KillTimer(NULL, checkContinTimerId); + KillTimer(nullptr, checkContinTimerId); if (timeout == 0) { - checkContinTimerId = SetTimer(NULL, 0, 1000 * db_get_dw(NULL, KSMODULENAME, SETTING_CNTDELAY, CHECKCONTIN_DELAY), CheckContinueslyTimer); + checkContinTimerId = SetTimer(nullptr, 0, 1000 * db_get_dw(0, KSMODULENAME, SETTING_CNTDELAY, CHECKCONTIN_DELAY), CheckContinueslyTimer); } else - checkContinTimerId = SetTimer(NULL, 0, timeout, CheckContinueslyTimer); + checkContinTimerId = SetTimer(nullptr, 0, timeout, CheckContinueslyTimer); } } } @@ -401,18 +421,17 @@ static int StartTimerFunction(int timer, int timeout, BOOL restart) if ((checkConnectingTimerId == 0) || (restart)) { if (timeout != -1) { if (restart) - KillTimer(NULL, checkConnectingTimerId); + KillTimer(nullptr, checkConnectingTimerId); if (timeout == 0) { timeout = initDelay / 2; } - checkConnectingTimerId = SetTimer(NULL, 0, timeout, CheckConnectingTimer); + checkConnectingTimerId = SetTimer(nullptr, 0, timeout, CheckConnectingTimer); } } } log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); log_debugA("StartTimer done %d", res); - return res; } @@ -433,7 +452,7 @@ static int StartTimer(int timer, int timeout, BOOL restart) ti->timer = timer; ti->timeout = timeout; ti->restart = restart; - ti->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + ti->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); QueueUserAPC(StartTimerApcProc, hMainThread, (ULONG_PTR)ti); WaitForSingleObject(ti->hEvent, INFINITE); CloseHandle(ti->hEvent); @@ -454,7 +473,7 @@ static int StopTimer(int timer) if (processAckTimerId == 0) res = 0; else { - KillTimer(NULL, processAckTimerId); + KillTimer(nullptr, processAckTimerId); processAckTimerId = 0; res = 1; } @@ -464,7 +483,7 @@ static int StopTimer(int timer) if (checkConnectionTimerId == 0) res = 0 || res; else { - KillTimer(NULL, checkConnectionTimerId); + KillTimer(nullptr, checkConnectionTimerId); checkConnectionTimerId = 0; res = 1; } @@ -474,7 +493,7 @@ static int StopTimer(int timer) if (afterCheckTimerId == 0) res = 0 || res; else { - KillTimer(NULL, afterCheckTimerId); + KillTimer(nullptr, afterCheckTimerId); afterCheckTimerId = 0; res = 1; } @@ -484,7 +503,7 @@ static int StopTimer(int timer) if (checkContinTimerId == 0) res = 0 || res; else { - KillTimer(NULL, checkContinTimerId); + KillTimer(nullptr, checkContinTimerId); checkContinTimerId = 0; res = 1; } @@ -494,7 +513,7 @@ static int StopTimer(int timer) if (checkConnectingTimerId == 0) res = 0 || res; else { - KillTimer(NULL, checkConnectingTimerId); + KillTimer(nullptr, checkConnectingTimerId); checkConnectingTimerId = 0; res = 1; } @@ -502,25 +521,23 @@ static int StopTimer(int timer) log_debugA("ack: %u, chk: %u, aft: %u, cnt: %u, con: %u", processAckTimerId, checkConnectionTimerId, afterCheckTimerId, checkContinTimerId, checkConnectingTimerId); log_debugA("StopTimer done %d", res); - return res; } static int ProcessProtoAck(WPARAM, LPARAM lParam) { ACKDATA *ack = (ACKDATA*)lParam; - if (ack->type != ACKTYPE_STATUS && ack->type != ACKTYPE_LOGIN) return 0; char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", ack->szModule); - if (!db_get_b(NULL, KSMODULENAME, dbSetting, 1)) + if (!db_get_b(0, KSMODULENAME, dbSetting, 1)) return 0; if (ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) { for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; if (!mir_strcmp(cs.m_szName, ack->szModule)) cs.lastStatusAckTime = GetTickCount(); } @@ -531,10 +548,10 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) if (ack->type == ACKTYPE_LOGIN) { if (ack->lParam == LOGINERR_OTHERLOCATION) { for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + 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)) { + if (db_get_b(0, KSMODULENAME, SETTING_CNCOTHERLOC, 0)) { StopTimer(IDT_PROCESSACK); for (int j = 0; j < connectionSettings.getCount(); j++) connectionSettings[j].AssignStatus(ID_STATUS_OFFLINE); @@ -548,24 +565,23 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) else if (ack->result == ACKRESULT_FAILED) { // login failed NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); - switch (db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING)) { + + switch (db_get_b(0, 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++) { - 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(); + 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(); 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); + int newDelay = 1000 * db_get_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY); + log_infoA("KeepStatus: set delay to %d ms on login error (%s)", newDelay, ack->szModule); StartTimer(IDT_CHECKCONN, newDelay, TRUE); } ProcessPopup(KS_CONN_STATE_LOGINERROR, (LPARAM)ack->szModule); @@ -584,16 +600,14 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) static VOID CALLBACK CheckConnectingTimer(HWND, UINT, UINT_PTR, DWORD) { - int maxConnectingTime; - StopTimer(IDT_CHECKCONNECTING); - //log_debugA("KeepStatus: CheckConnectingTimer"); + for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; - int curStatus = GetStatus(cs); + int curStatus = cs.GetStatus(); if (IsStatusConnecting(curStatus)) { // connecting - maxConnectingTime = db_get_dw(NULL, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0); + int maxConnectingTime = db_get_dw(0, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0); if (maxConnectingTime > 0) { if ((unsigned int)maxConnectingTime <= ((GetTickCount() - cs.lastStatusAckTime) / 1000)) { // set offline @@ -607,21 +621,20 @@ static VOID CALLBACK CheckConnectingTimer(HWND, UINT, UINT_PTR, DWORD) static VOID CALLBACK CheckAckStatusTimer(HWND, UINT, UINT_PTR, DWORD) { - int maxConnectingTime; bool needChecking = false; StopTimer(IDT_PROCESSACK); for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; - int curStatus = GetStatus(cs); + int curStatus = cs.GetStatus(); 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; if (IsStatusConnecting(newStatus)) { // connecting - maxConnectingTime = db_get_dw(NULL, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0); + int maxConnectingTime = db_get_dw(0, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0); if (maxConnectingTime > 0) StartTimer(IDT_CHECKCONNECTING, (maxConnectingTime * 1000 - (GetTickCount() - cs.lastStatusAckTime)), FALSE); } @@ -646,27 +659,19 @@ static VOID CALLBACK CheckAckStatusTimer(HWND, UINT, UINT_PTR, DWORD) static VOID CALLBACK CheckConnectionTimer(HWND, UINT, UINT_PTR, DWORD) { - int shouldBeStatus, realStatus; - HICON hIcon; - log_debugA("CheckConnectionTimer"); bool setStatus = false; - if (showConnectionPopups) - hIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE); for (int i = 0; i < connectionSettings.getCount() && !setStatus; i++) { - TKSSettings& cs = connectionSettings[i]; - realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); - shouldBeStatus = GetStatus(cs); + TKSSettings &cs = connectionSettings[i]; + int realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); + int shouldBeStatus = cs.GetStatus(); if (shouldBeStatus == ID_STATUS_LAST) shouldBeStatus = cs.m_lastStatus; if (shouldBeStatus == ID_STATUS_DISABLED) continue; - if ((shouldBeStatus != realStatus) && (realStatus == ID_STATUS_OFFLINE) || (realStatus < MIN_STATUS)) { + if ((shouldBeStatus != realStatus) && (realStatus == ID_STATUS_OFFLINE) || (realStatus < MIN_STATUS)) setStatus = true; - if (showConnectionPopups) - hIcon = Skin_LoadProtoIcon(cs.m_szName, ID_STATUS_OFFLINE); - } } // one of the status was wrong @@ -674,15 +679,14 @@ static VOID CALLBACK CheckConnectionTimer(HWND, UINT, UINT_PTR, DWORD) if (increaseExponential) currentDelay = min(2 * currentDelay, maxDelay); - if (((db_get_b(NULL, KSMODULENAME, SETTING_CHKINET, 0)) && (!InternetGetConnectedState(NULL, 0))) || ((db_get_b(NULL, KSMODULENAME, SETTING_BYPING, FALSE)) && (!bLastPingResult))) { + if (((db_get_b(0, KSMODULENAME, SETTING_CHKINET, 0)) && (!InternetGetConnectedState(nullptr, 0))) || ((db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE)) && (!bLastPingResult))) { // no network NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_RETRYNOCONN, (LPARAM)retryCount + 1); ProcessPopup(KS_CONN_STATE_RETRYNOCONN, 0); } else { NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_RETRY, (LPARAM)retryCount + 1); - /* set the status */ - SetCurrentStatus(); + SetCurrentStatus(); // set the status } retryCount += 1; StartTimer(IDT_AFTERCHECK, min(currentDelay, AFTERCHECK_DELAY) / 2, FALSE); @@ -700,8 +704,8 @@ static int StopChecking() BOOL isOk = TRUE; for (int i = 0; i < connectionSettings.getCount() && isOk; i++) { - TKSSettings& cs = connectionSettings[i]; - int curStatus = GetStatus(cs); + TKSSettings &cs = connectionSettings[i]; + int curStatus = cs.GetStatus(); int newStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); if (newStatus != curStatus) { cs.AssignStatus(newStatus); @@ -726,9 +730,9 @@ static VOID CALLBACK AfterCheckTimer(HWND, UINT, UINT_PTR, DWORD) bool setStatus = false; for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; int realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0); - int shouldBeStatus = GetStatus(cs); + int shouldBeStatus = cs.GetStatus(); if (shouldBeStatus == ID_STATUS_LAST) // this should never happen shouldBeStatus = cs.m_lastStatus; if (shouldBeStatus == ID_STATUS_DISABLED) // (on ignoring proto) @@ -753,8 +757,8 @@ static void CheckContinueslyFunction(void *) // do a ping, even if reconnecting bool doPing = false; for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; - int shouldBeStatus = GetStatus(cs); + TKSSettings &cs = connectionSettings[i]; + int shouldBeStatus = cs.GetStatus(); if (shouldBeStatus == ID_STATUS_LAST) shouldBeStatus = cs.m_lastStatus; @@ -772,10 +776,10 @@ static void CheckContinueslyFunction(void *) return; } - BOOL ping = db_get_b(NULL, KSMODULENAME, SETTING_BYPING, FALSE); + BOOL ping = db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE); if (ping) { DBVARIANT dbv; - if (db_get(NULL, KSMODULENAME, SETTING_PINGHOST, &dbv)) + if (db_get(0, KSMODULENAME, SETTING_PINGHOST, &dbv)) ping = FALSE; else { char *start, *end; @@ -799,9 +803,9 @@ static void CheckContinueslyFunction(void *) memset(host, '\0', sizeof(host)); strncpy(host, start, end - start); hostent = gethostbyname(host); - if (hostent != NULL) { + if (hostent != nullptr) { addr = (DWORD *)(*hostent->h_addr_list); - bLastPingResult = (IcmpSendEcho(hICMPFile, *addr, 0, 0, NULL, reply, sizeof(ICMP_ECHO_REPLY) + 8, 5000) != 0); + bLastPingResult = (IcmpSendEcho(hICMPFile, *addr, 0, 0, nullptr, reply, sizeof(ICMP_ECHO_REPLY) + 8, 5000) != 0); if (bLastPingResult) pingFailures = 0; @@ -822,11 +826,10 @@ static void CheckContinueslyFunction(void *) db_free(&dbv); } - if (StartTimer(IDT_CHECKCONN, -1, FALSE)) { - return; // already connecting, leave - } + if (StartTimer(IDT_CHECKCONN, -1, FALSE)) // already connecting, leave + return; - if (((!ping) && (!InternetGetConnectedState(NULL, 0))) || ((ping) && (!bLastPingResult) && (pingFailures >= db_get_w(NULL, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT)))) { + if (((!ping) && (!InternetGetConnectedState(nullptr, 0))) || ((ping) && (!bLastPingResult) && (pingFailures >= db_get_w(0, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT)))) { pingFailures = 0; int count; @@ -853,7 +856,7 @@ static void CheckContinueslyFunction(void *) log_infoA("KeepStatus: connection lost! (continuesly check)"); NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_LOST, 0); ProcessPopup(KS_CONN_STATE_LOST, 0); - maxRetries = db_get_b(NULL, KSMODULENAME, SETTING_MAXRETRIES, 0); + maxRetries = db_get_b(0, KSMODULENAME, SETTING_MAXRETRIES, 0); if (maxRetries == 0) maxRetries = -1; StartTimer(IDT_CHECKCONN, initDelay, FALSE); @@ -862,30 +865,32 @@ static void CheckContinueslyFunction(void *) static VOID CALLBACK CheckContinueslyTimer(HWND, UINT, UINT_PTR, DWORD) { - if (db_get_b(NULL, KSMODULENAME, SETTING_BYPING, FALSE)) - mir_forkthread(CheckContinueslyFunction, NULL); + if (db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE)) + mir_forkthread(CheckContinueslyFunction, nullptr); else - CheckContinueslyFunction(NULL); + CheckContinueslyFunction(nullptr); } -// =============== popup ====================== +///////////////////////////////////////////////////////////////////////////////////////// +// popup + static wchar_t* GetHumanName(LPARAM lParam) { PROTOACCOUNT *ProtoAccount = Proto_GetAccount((char*)lParam); - return (ProtoAccount != NULL) ? ProtoAccount->tszAccountName : TranslateT("Protocol"); + return (ProtoAccount != nullptr) ? ProtoAccount->tszAccountName : TranslateT("Protocol"); } static int ProcessPopup(int reason, LPARAM lParam) { - HICON hIcon = NULL; + HICON hIcon = nullptr; wchar_t text[MAX_SECONDLINE]; - if (!db_get_b(NULL, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, FALSE) || !ServiceExists(MS_POPUP_ADDPOPUPT)) + if (!db_get_b(0, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, FALSE) || !ServiceExists(MS_POPUP_ADDPOPUPT)) return -1; switch (reason) { case KS_CONN_STATE_OTHERLOCATION: // lParam = 1 proto - if (!db_get_b(NULL, KSMODULENAME, SETTING_PUOTHER, TRUE)) + if (!db_get_b(0, KSMODULENAME, SETTING_PUOTHER, TRUE)) return -1; hIcon = Skin_LoadProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); @@ -893,20 +898,20 @@ static int ProcessPopup(int reason, LPARAM lParam) break; case KS_CONN_STATE_LOGINERROR: // lParam = 1 proto - if (!db_get_b(NULL, KSMODULENAME, SETTING_PUOTHER, TRUE)) + if (!db_get_b(0, KSMODULENAME, SETTING_PUOTHER, TRUE)) return -1; hIcon = Skin_LoadProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE); - if (db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_CANCEL) + if (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_CANCEL) mir_snwprintf(text, TranslateT("%s login error, cancel reconnecting"), GetHumanName(lParam)); - else if (db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_SETDELAY) - mir_snwprintf(text, TranslateT("%s login error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, db_get_dw(NULL, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY)); + else if (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_SETDELAY) + mir_snwprintf(text, TranslateT("%s login error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, db_get_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY)); else return -1; break; - case KS_CONN_STATE_LOST: // lParam = 1 proto, or NULL - if (!db_get_b(NULL, KSMODULENAME, SETTING_PUCONNLOST, TRUE)) + case KS_CONN_STATE_LOST: // lParam = 1 proto, or nullptr + if (!db_get_b(0, KSMODULENAME, SETTING_PUCONNLOST, TRUE)) return -1; if (lParam) { // Óêàçàòåëü íà èìÿ ìîäóëÿ. @@ -917,8 +922,9 @@ static int ProcessPopup(int reason, LPARAM lParam) break; case KS_CONN_STATE_RETRY: // lParam = PROTOCOLSETTINGEX** - if (!db_get_b(NULL, KSMODULENAME, SETTING_PUCONNRETRY, TRUE)) + if (!db_get_b(0, KSMODULENAME, SETTING_PUCONNRETRY, TRUE)) return -1; + if (lParam) { PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX **)lParam; wchar_t protoInfoLine[512], protoInfo[MAX_SECONDLINE]; @@ -927,7 +933,7 @@ static int ProcessPopup(int reason, LPARAM lParam) mir_wstrcpy(protoInfo, L"\r\n"); for (int i = 0; i < connectionSettings.getCount(); i++) { if (mir_wstrlen(ps[i]->m_tszAccName) > 0 && mir_strlen(ps[i]->m_szName) > 0) { - if (db_get_b(NULL, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE)) { + if (db_get_b(0, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE)) { 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); } @@ -943,8 +949,8 @@ static int ProcessPopup(int reason, LPARAM lParam) } break; - case KS_CONN_STATE_RETRYNOCONN: // lParam = NULL - if (!db_get_b(NULL, KSMODULENAME, SETTING_PUOTHER, TRUE)) + case KS_CONN_STATE_RETRYNOCONN: // lParam = nullptr + if (!db_get_b(0, KSMODULENAME, SETTING_PUOTHER, TRUE)) return -1; if (retryCount == maxRetries - 1) @@ -954,7 +960,7 @@ static int ProcessPopup(int reason, LPARAM lParam) break; case KS_CONN_STATE_STOPPEDCHECKING: // lParam == BOOL succes - if (!db_get_b(NULL, KSMODULENAME, SETTING_PURESULT, TRUE)) + if (!db_get_b(0, KSMODULENAME, SETTING_PURESULT, TRUE)) return -1; if (lParam) { @@ -964,7 +970,7 @@ static int ProcessPopup(int reason, LPARAM lParam) else mir_snwprintf(text, TranslateT("Giving up")); break; } - if (hIcon == NULL) + if (hIcon == nullptr) hIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE); log_info(L"KeepStatus: %s", text); @@ -973,23 +979,23 @@ static int ProcessPopup(int reason, LPARAM lParam) static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon) { - POPUPDATAT ppd = { 0 }; + POPUPDATAT ppd = {}; ppd.lchIcon = hIcon; wcsncpy(ppd.lptzContactName, TranslateT("Keep status"), MAX_CONTACTNAME); wcsncpy(ppd.lptzText, msg, MAX_SECONDLINE); - if (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0)) { + if (db_get_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0)) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); } - else if (!db_get_b(NULL, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) { - ppd.colorBack = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA); - ppd.colorText = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC); + else if (!db_get_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) { + ppd.colorBack = db_get_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA); + ppd.colorText = db_get_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC); } ppd.PluginWindowProc = KSPopupDlgProc; - switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { + switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { case POPUP_DELAYCUSTOM: - ppd.iSeconds = (int)db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0); + ppd.iSeconds = (int)db_get_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0); if (ppd.iSeconds == 0) ppd.iSeconds = currentDelay / 1000 - 1; break; @@ -1011,7 +1017,7 @@ LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l switch (message) { case WM_CONTEXTMENU: // right case WM_COMMAND: // left - switch (db_get_b(NULL, KSMODULENAME, + switch (db_get_b(0, KSMODULENAME, (message == WM_COMMAND) ? SETTING_POPUP_LEFTCLICK : SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CLOSEPOPUP)) { case POPUP_ACT_CANCEL: @@ -1031,7 +1037,9 @@ LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return DefWindowProc(hWnd, message, wParam, lParam); } -// =============== services =================== +///////////////////////////////////////////////////////////////////////////////////////// +// services + INT_PTR StopReconnectingService(WPARAM, LPARAM) { int ret = StartTimer(IDT_CHECKCONN | IDT_AFTERCHECK, -1, FALSE); @@ -1042,17 +1050,17 @@ INT_PTR StopReconnectingService(WPARAM, LPARAM) INT_PTR EnableProtocolService(WPARAM wParam, LPARAM lParam) { char *szProto = (char *)lParam; - if (szProto == NULL) + if (szProto == nullptr) return -1; char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", szProto); - if (!db_get_b(NULL, KSMODULENAME, dbSetting, 1)) // 'hard' disabled + if (!db_get_b(0, KSMODULENAME, dbSetting, 1)) // 'hard' disabled return -1; int ret = -2; for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; if (!mir_strcmp(szProto, cs.m_szName)) { if (wParam) cs.AssignStatus(CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0)); @@ -1072,13 +1080,13 @@ INT_PTR IsProtocolEnabledService(WPARAM, LPARAM lParam) char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", szProto); - if (!db_get_b(NULL, KSMODULENAME, dbSetting, 1)) + if (!db_get_b(0, KSMODULENAME, dbSetting, 1)) return FALSE; for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; if (!mir_strcmp(szProto, cs.m_szName)) - return GetStatus(cs) != ID_STATUS_DISABLED; + return cs.GetStatus() != ID_STATUS_DISABLED; } return FALSE; @@ -1087,10 +1095,10 @@ 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->m_status, newSituation->m_szName == NULL ? "all" : newSituation->m_szName); + log_infoA("Another plugin announced a status change to %d for %s", newSituation->m_status, newSituation->m_szName == nullptr ? "all" : newSituation->m_szName); for (int i = 0; i < connectionSettings.getCount(); i++) { - TKSSettings& cs = connectionSettings[i]; + TKSSettings &cs = connectionSettings[i]; if (!mir_strcmp(cs.m_szName, newSituation->m_szName)) cs.AssignStatus(newSituation->m_status, newSituation->m_lastStatus, newSituation->m_szMsg); } @@ -1098,18 +1106,19 @@ INT_PTR AnnounceStatusChangeService(WPARAM, LPARAM lParam) return 0; } -// =============== window for suspend =============== +///////////////////////////////////////////////////////////////////////////////////////// +// window for suspend static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lParam) { - static PROTOCOLSETTINGEX** ps = NULL; + static PROTOCOLSETTINGEX** ps = nullptr; switch (msg) { case WM_POWERBROADCAST: switch (wParam) { case PBT_APMSUSPEND: log_infoA("KeepStatus: suspend state detected: %08X %08X", wParam, lParam); - if (ps == NULL) { + if (ps == nullptr) { ps = GetCurrentProtoSettingsCopy(); for (int i = 0; i < connectionSettings.getCount(); i++) EnableProtocolService(0, (LPARAM)ps[i]->m_szName); @@ -1123,11 +1132,11 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara case PBT_APMRESUMESUSPEND: case PBT_APMRESUMECRITICAL: log_infoA("KeepStatus: resume from suspend state"); - if (ps != NULL) { + if (ps != nullptr) { for (int i = 0; i < connectionSettings.getCount(); i++) connectionSettings[i].AssignStatus(ps[i]->m_status, ps[i]->m_lastStatus, ps[i]->m_szMsg); FreeProtoSettings(ps); - ps = NULL; + ps = nullptr; } StartTimer(IDT_PROCESSACK, 0, FALSE); break; @@ -1135,9 +1144,9 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_DESTROY: - if (ps != NULL) { + if (ps != nullptr) { FreeProtoSettings(ps); - ps = NULL; + ps = nullptr; } break; } @@ -1168,7 +1177,8 @@ int OnKSAccChanged(WPARAM wParam, LPARAM lParam) return 0; } -// =============== init stuff ================= +///////////////////////////////////////////////////////////////////////////////////////// +// init stuff static int onShutdown(WPARAM, LPARAM) { @@ -1190,7 +1200,7 @@ int KSModuleLoaded(WPARAM, LPARAM) { protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&connectionSettings; - hMessageWindow = NULL; + hMessageWindow = nullptr; KSLoadOptions(); HookEvent(ME_OPT_INITIALISE, KeepStatusOptionsInit); diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.h b/plugins/StatusManager/src/KeepStatus/keepstatus.h index 5c8f7aac26..d9fecb35f5 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.h +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.h @@ -97,6 +97,7 @@ struct TKSSettings : public PROTOCOLSETTINGEX ~TKSSettings(); int AssignStatus(int status, int lastStatus = 0, wchar_t *szMsg = nullptr); + int GetStatus() const; 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 a43d528c34..2974818bcd 100644 --- a/plugins/StatusManager/src/KeepStatus/ks_options.cpp +++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp @@ -19,7 +19,7 @@ #include "..\stdafx.h" -// prototypes + // prototypes 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) @@ -32,14 +32,14 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam LVITEM lvItem; DBVARIANT dbv; - SetDlgItemInt(hwndDlg, IDC_MAXRETRIES, db_get_b(NULL, KSMODULENAME, SETTING_MAXRETRIES, DEFAULT_MAXRETRIES), FALSE); - SetDlgItemInt(hwndDlg, IDC_INITDELAY, db_get_dw(NULL, KSMODULENAME, SETTING_INITDELAY, DEFAULT_INITDELAY), FALSE); - CheckDlgButton(hwndDlg, IDC_CHECKCONNECTION, db_get_b(NULL, KSMODULENAME, SETTING_CHECKCONNECTION, FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOWCONNECTIONPOPUPS, (db_get_b(NULL, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, FALSE) && ServiceExists(MS_POPUP_SHOWMESSAGE)) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHKINET, db_get_b(NULL, KSMODULENAME, SETTING_CHKINET, FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CONTCHECK, db_get_b(NULL, KSMODULENAME, SETTING_CONTCHECK, FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_BYPING, db_get_b(NULL, KSMODULENAME, SETTING_BYPING, FALSE) ? BST_CHECKED : BST_UNCHECKED); - if (!db_get_s(NULL, KSMODULENAME, SETTING_PINGHOST, &dbv)) { + SetDlgItemInt(hwndDlg, IDC_MAXRETRIES, db_get_b(0, KSMODULENAME, SETTING_MAXRETRIES, DEFAULT_MAXRETRIES), FALSE); + SetDlgItemInt(hwndDlg, IDC_INITDELAY, db_get_dw(0, KSMODULENAME, SETTING_INITDELAY, DEFAULT_INITDELAY), FALSE); + CheckDlgButton(hwndDlg, IDC_CHECKCONNECTION, db_get_b(0, KSMODULENAME, SETTING_CHECKCONNECTION, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOWCONNECTIONPOPUPS, (db_get_b(0, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, FALSE) && ServiceExists(MS_POPUP_SHOWMESSAGE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHKINET, db_get_b(0, KSMODULENAME, SETTING_CHKINET, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CONTCHECK, db_get_b(0, KSMODULENAME, SETTING_CONTCHECK, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_BYPING, db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE) ? BST_CHECKED : BST_UNCHECKED); + if (!db_get_s(0, KSMODULENAME, SETTING_PINGHOST, &dbv)) { SetDlgItemTextA(hwndDlg, IDC_PINGHOST, dbv.pszVal); db_free(&dbv); } @@ -71,7 +71,7 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", protos[i]->szModuleName); - ListView_SetCheckState(hList, lvItem.iItem, db_get_b(NULL, KSMODULENAME, dbSetting, TRUE)); + ListView_SetCheckState(hList, lvItem.iItem, db_get_b(0, KSMODULENAME, dbSetting, TRUE)); lvItem.iItem++; } EnableWindow(GetDlgItem(hwndDlg, IDC_MAXRETRIES), IsDlgButtonChecked(hwndDlg, IDC_CHECKCONNECTION)); @@ -109,12 +109,12 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam if (((NMHDR*)lParam)->idFrom == IDC_PROTOCOLLIST) { switch (((NMHDR*)lParam)->code) { case LVN_ITEMCHANGED: - { - NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if (IsWindowVisible(GetDlgItem(hwndDlg, IDC_PROTOCOLLIST)) && ((nmlv->uNewState^nmlv->uOldState)&LVIS_STATEIMAGEMASK)) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + if (IsWindowVisible(GetDlgItem(hwndDlg, IDC_PROTOCOLLIST)) && ((nmlv->uNewState^nmlv->uOldState)&LVIS_STATEIMAGEMASK)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; } } @@ -122,23 +122,23 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam int i; LVITEM lvItem; - db_set_b(NULL, KSMODULENAME, SETTING_MAXRETRIES, (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXRETRIES, NULL, FALSE)); - db_set_b(NULL, KSMODULENAME, SETTING_CHECKCONNECTION, (BYTE)SendMessage(GetParent(hwndDlg), KS_ISENABLED, (WPARAM)IDC_CHECKCONNECTION, 0)); - db_set_b(NULL, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWCONNECTIONPOPUPS)); - db_set_dw(NULL, KSMODULENAME, SETTING_INITDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_INITDELAY, NULL, FALSE)); - db_set_b(NULL, KSMODULENAME, SETTING_CHKINET, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHKINET)); - db_set_b(NULL, KSMODULENAME, SETTING_CONTCHECK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONTCHECK)); - db_set_b(NULL, KSMODULENAME, SETTING_BYPING, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BYPING)); + db_set_b(0, KSMODULENAME, SETTING_MAXRETRIES, (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXRETRIES, nullptr, FALSE)); + db_set_b(0, KSMODULENAME, SETTING_CHECKCONNECTION, (BYTE)SendMessage(GetParent(hwndDlg), KS_ISENABLED, (WPARAM)IDC_CHECKCONNECTION, 0)); + db_set_b(0, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWCONNECTIONPOPUPS)); + db_set_dw(0, KSMODULENAME, SETTING_INITDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_INITDELAY, nullptr, FALSE)); + db_set_b(0, KSMODULENAME, SETTING_CHKINET, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHKINET)); + db_set_b(0, KSMODULENAME, SETTING_CONTCHECK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONTCHECK)); + db_set_b(0, KSMODULENAME, SETTING_BYPING, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BYPING)); if (IsDlgButtonChecked(hwndDlg, IDC_BYPING)) { char *host; int len = SendDlgItemMessage(hwndDlg, IDC_PINGHOST, WM_GETTEXTLENGTH, 0, 0); if (len > 0) { host = (char*)malloc(len + 1); - if (host != NULL) { + if (host != nullptr) { memset(host, '\0', len + 1); GetDlgItemTextA(hwndDlg, IDC_PINGHOST, host, len + 1); - db_set_s(NULL, KSMODULENAME, SETTING_PINGHOST, host); + db_set_s(0, KSMODULENAME, SETTING_PINGHOST, host); } } } @@ -152,7 +152,7 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", (char *)lvItem.lParam); - db_set_b(NULL, KSMODULENAME, dbSetting, (BYTE)ListView_GetCheckState(hList, lvItem.iItem)); + db_set_b(0, KSMODULENAME, dbSetting, (BYTE)ListView_GetCheckState(hList, lvItem.iItem)); } } break; @@ -165,30 +165,30 @@ static INT_PTR CALLBACK DlgProcKSAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { switch (msg) { case WM_INITDIALOG: { - TranslateDialogDefault(hwndDlg); - SetDlgItemInt(hwndDlg, IDC_MAXDELAY, db_get_dw(NULL, KSMODULENAME, SETTING_MAXDELAY, DEFAULT_MAXDELAY), FALSE); - SetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, db_get_dw(NULL, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0), FALSE); - CheckDlgButton(hwndDlg, IDC_INCREASEEXPONENTIAL, db_get_b(NULL, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CNCOTHERLOC, (db_get_b(NULL, KSMODULENAME, SETTING_CNCOTHERLOC, FALSE)) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LOGINERR, db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_NOTHING ? BST_UNCHECKED : BST_CHECKED); - CheckDlgButton(hwndDlg, IDC_CHECKAPMRESUME, (db_get_b(NULL, KSMODULENAME, SETTING_CHECKAPMRESUME, FALSE)) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_FIRSTOFFLINE, (db_get_b(NULL, KSMODULENAME, SETTING_FIRSTOFFLINE, FALSE)) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NOLOCKED, (db_get_b(NULL, KSMODULENAME, SETTING_NOLOCKED, FALSE)) ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, db_get_dw(NULL, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY), FALSE); - SetDlgItemInt(hwndDlg, IDC_PINGCOUNT, db_get_w(NULL, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT), FALSE); - SetDlgItemInt(hwndDlg, IDC_CNTDELAY, db_get_dw(NULL, KSMODULENAME, SETTING_CNTDELAY, CHECKCONTIN_DELAY), FALSE); - switch (db_get_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_CANCEL)) { - case LOGINERR_SETDELAY: - CheckRadioButton(hwndDlg, IDC_LOGINERR_CANCEL, IDC_LOGINERR_SETDELAY, IDC_LOGINERR_SETDELAY); - break; - default: - case LOGINERR_CANCEL: - CheckRadioButton(hwndDlg, IDC_LOGINERR_CANCEL, IDC_LOGINERR_SETDELAY, IDC_LOGINERR_CANCEL); + TranslateDialogDefault(hwndDlg); + SetDlgItemInt(hwndDlg, IDC_MAXDELAY, db_get_dw(0, KSMODULENAME, SETTING_MAXDELAY, DEFAULT_MAXDELAY), FALSE); + SetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, db_get_dw(0, KSMODULENAME, SETTING_MAXCONNECTINGTIME, 0), FALSE); + CheckDlgButton(hwndDlg, IDC_INCREASEEXPONENTIAL, db_get_b(0, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CNCOTHERLOC, (db_get_b(0, KSMODULENAME, SETTING_CNCOTHERLOC, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOGINERR, db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_NOTHING ? BST_UNCHECKED : BST_CHECKED); + CheckDlgButton(hwndDlg, IDC_CHECKAPMRESUME, (db_get_b(0, KSMODULENAME, SETTING_CHECKAPMRESUME, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_FIRSTOFFLINE, (db_get_b(0, KSMODULENAME, SETTING_FIRSTOFFLINE, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NOLOCKED, (db_get_b(0, KSMODULENAME, SETTING_NOLOCKED, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, db_get_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY), FALSE); + SetDlgItemInt(hwndDlg, IDC_PINGCOUNT, db_get_w(0, KSMODULENAME, SETTING_PINGCOUNT, DEFAULT_PINGCOUNT), FALSE); + SetDlgItemInt(hwndDlg, IDC_CNTDELAY, db_get_dw(0, KSMODULENAME, SETTING_CNTDELAY, CHECKCONTIN_DELAY), FALSE); + switch (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_CANCEL)) { + case LOGINERR_SETDELAY: + CheckRadioButton(hwndDlg, IDC_LOGINERR_CANCEL, IDC_LOGINERR_SETDELAY, IDC_LOGINERR_SETDELAY); + break; + default: + case LOGINERR_CANCEL: + CheckRadioButton(hwndDlg, IDC_LOGINERR_CANCEL, IDC_LOGINERR_SETDELAY, IDC_LOGINERR_CANCEL); + break; + } + SendMessage(hwndDlg, KS_ENABLEITEMS, 0, 0); break; } - SendMessage(hwndDlg, KS_ENABLEITEMS, 0, 0); - break; - } case WM_COMMAND: if (((HIWORD(wParam) == EN_CHANGE) || (HIWORD(wParam) == BN_CLICKED)) && ((HWND)lParam == GetFocus())) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -209,25 +209,25 @@ static INT_PTR CALLBACK DlgProcKSAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { - db_set_b(NULL, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_INCREASEEXPONENTIAL)); - db_set_dw(NULL, KSMODULENAME, SETTING_MAXDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXDELAY, NULL, FALSE)); - db_set_dw(NULL, KSMODULENAME, SETTING_MAXCONNECTINGTIME, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, NULL, FALSE)); - db_set_b(NULL, KSMODULENAME, SETTING_FIRSTOFFLINE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FIRSTOFFLINE)); - db_set_b(NULL, KSMODULENAME, SETTING_NOLOCKED, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOLOCKED)); - db_set_b(NULL, KSMODULENAME, SETTING_CNCOTHERLOC, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CNCOTHERLOC)); - db_set_b(NULL, KSMODULENAME, SETTING_LOGINERR, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_LOGINERR)); + db_set_b(0, KSMODULENAME, SETTING_INCREASEEXPONENTIAL, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_INCREASEEXPONENTIAL)); + db_set_dw(0, KSMODULENAME, SETTING_MAXDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXDELAY, nullptr, FALSE)); + db_set_dw(0, KSMODULENAME, SETTING_MAXCONNECTINGTIME, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, nullptr, FALSE)); + db_set_b(0, KSMODULENAME, SETTING_FIRSTOFFLINE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FIRSTOFFLINE)); + db_set_b(0, KSMODULENAME, SETTING_NOLOCKED, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOLOCKED)); + db_set_b(0, KSMODULENAME, SETTING_CNCOTHERLOC, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CNCOTHERLOC)); + db_set_b(0, KSMODULENAME, SETTING_LOGINERR, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_LOGINERR)); if (IsDlgButtonChecked(hwndDlg, IDC_LOGINERR)) { if (IsDlgButtonChecked(hwndDlg, IDC_LOGINERR_SETDELAY)) { - db_set_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_SETDELAY); - db_set_dw(NULL, KSMODULENAME, SETTING_LOGINERR_DELAY, GetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, NULL, FALSE)); + db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_SETDELAY); + db_set_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, GetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, nullptr, FALSE)); } - else db_set_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_CANCEL); + else db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_CANCEL); } - else db_set_b(NULL, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING); + else db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING); - db_set_b(NULL, KSMODULENAME, SETTING_CHECKAPMRESUME, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKAPMRESUME)); - db_set_w(NULL, KSMODULENAME, SETTING_PINGCOUNT, (WORD)GetDlgItemInt(hwndDlg, IDC_PINGCOUNT, NULL, FALSE)); - db_set_dw(NULL, KSMODULENAME, SETTING_CNTDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_CNTDELAY, NULL, FALSE) == 0 ? CHECKCONTIN_DELAY : GetDlgItemInt(hwndDlg, IDC_CNTDELAY, NULL, FALSE)); + db_set_b(0, KSMODULENAME, SETTING_CHECKAPMRESUME, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKAPMRESUME)); + db_set_w(0, KSMODULENAME, SETTING_PINGCOUNT, (WORD)GetDlgItemInt(hwndDlg, IDC_PINGCOUNT, nullptr, FALSE)); + db_set_dw(0, KSMODULENAME, SETTING_CNTDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_CNTDELAY, nullptr, FALSE) == 0 ? CHECKCONTIN_DELAY : GetDlgItemInt(hwndDlg, IDC_CNTDELAY, nullptr, FALSE)); } break; @@ -263,46 +263,46 @@ static INT_PTR CALLBACK DlgProcKsTabs(HWND hwndDlg, UINT msg, WPARAM wParam, LPA switch (msg) { case WM_INITDIALOG: - { - HWND hShow, hPage; - RECT rcTabs, rcOptions, rcPage; + { + HWND hShow, hPage; + RECT rcTabs, rcOptions, rcPage; - TranslateDialogDefault(hwndDlg); + TranslateDialogDefault(hwndDlg); - // set tabs - int tabCount = 0; - HWND hTab = GetDlgItem(hwndDlg, IDC_TABS); - GetWindowRect(hTab, &rcTabs); - GetWindowRect(hwndDlg, &rcOptions); - - // basic tab - TCITEM tci; - memset(&tci, 0, sizeof(TCITEM)); - tci.mask = TCIF_TEXT | TCIF_PARAM; - tci.pszText = TranslateT("Basic"); - hShow = hBasicTab = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_KS_BASIC), hwndDlg, DlgProcKSBasicOpts, (LPARAM)GetParent(hwndDlg)); - EnableThemeDialogTexture(hPage, ETDT_ENABLETAB); - - tci.lParam = (LPARAM)hPage; - GetClientRect(hPage, &rcPage); - MoveWindow(hPage, (rcTabs.left - rcOptions.left) + ((rcTabs.right - rcTabs.left) - (rcPage.right - rcPage.left)) / 2, 10 + (rcTabs.top - rcOptions.top) + ((rcTabs.bottom - rcTabs.top) - (rcPage.bottom - rcPage.top)) / 2, rcPage.right - rcPage.left, rcPage.bottom - rcPage.top, TRUE); - ShowWindow(hPage, SW_HIDE); - TabCtrl_InsertItem(hTab, tabCount++, &tci); - - // advanced tab - tci.mask = TCIF_TEXT | TCIF_PARAM; - tci.pszText = TranslateT("Advanced"); - hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_KS_ADV), hwndDlg, DlgProcKSAdvOpts, (LPARAM)GetParent(hwndDlg)); - EnableThemeDialogTexture(hPage, ETDT_ENABLETAB); - - tci.lParam = (LPARAM)hPage; - GetClientRect(hPage, &rcPage); - MoveWindow(hPage, (rcTabs.left - rcOptions.left) + ((rcTabs.right - rcTabs.left) - (rcPage.right - rcPage.left)) / 2, 10 + (rcTabs.top - rcOptions.top) + ((rcTabs.bottom - rcTabs.top) - (rcPage.bottom - rcPage.top)) / 2, rcPage.right - rcPage.left, rcPage.bottom - rcPage.top, TRUE); - ShowWindow(hPage, SW_HIDE); - TabCtrl_InsertItem(hTab, tabCount++, &tci); - ShowWindow(hShow, SW_SHOW); - } - break; + // set tabs + int tabCount = 0; + HWND hTab = GetDlgItem(hwndDlg, IDC_TABS); + GetWindowRect(hTab, &rcTabs); + GetWindowRect(hwndDlg, &rcOptions); + + // basic tab + TCITEM tci; + memset(&tci, 0, sizeof(TCITEM)); + tci.mask = TCIF_TEXT | TCIF_PARAM; + tci.pszText = TranslateT("Basic"); + hShow = hBasicTab = hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_KS_BASIC), hwndDlg, DlgProcKSBasicOpts, (LPARAM)GetParent(hwndDlg)); + EnableThemeDialogTexture(hPage, ETDT_ENABLETAB); + + tci.lParam = (LPARAM)hPage; + GetClientRect(hPage, &rcPage); + MoveWindow(hPage, (rcTabs.left - rcOptions.left) + ((rcTabs.right - rcTabs.left) - (rcPage.right - rcPage.left)) / 2, 10 + (rcTabs.top - rcOptions.top) + ((rcTabs.bottom - rcTabs.top) - (rcPage.bottom - rcPage.top)) / 2, rcPage.right - rcPage.left, rcPage.bottom - rcPage.top, TRUE); + ShowWindow(hPage, SW_HIDE); + TabCtrl_InsertItem(hTab, tabCount++, &tci); + + // advanced tab + tci.mask = TCIF_TEXT | TCIF_PARAM; + tci.pszText = TranslateT("Advanced"); + hPage = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPT_KS_ADV), hwndDlg, DlgProcKSAdvOpts, (LPARAM)GetParent(hwndDlg)); + EnableThemeDialogTexture(hPage, ETDT_ENABLETAB); + + tci.lParam = (LPARAM)hPage; + GetClientRect(hPage, &rcPage); + MoveWindow(hPage, (rcTabs.left - rcOptions.left) + ((rcTabs.right - rcTabs.left) - (rcPage.right - rcPage.left)) / 2, 10 + (rcTabs.top - rcOptions.top) + ((rcTabs.bottom - rcTabs.top) - (rcPage.bottom - rcPage.top)) / 2, rcPage.right - rcPage.left, rcPage.bottom - rcPage.top, TRUE); + ShowWindow(hPage, SW_HIDE); + TabCtrl_InsertItem(hTab, tabCount++, &tci); + ShowWindow(hShow, SW_SHOW); + } + break; case KS_ISENABLED: SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)IsDlgButtonChecked(hBasicTab, wParam)); @@ -359,7 +359,7 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l bFreeze = true; // left action - switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL)) { + switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL)) { case POPUP_ACT_CLOSEPOPUP: CheckDlgButton(hwndDlg, IDC_LCLOSE, BST_CHECKED); break; @@ -374,7 +374,7 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; } // right action - switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL)) { + switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL)) { case POPUP_ACT_CLOSEPOPUP: CheckDlgButton(hwndDlg, IDC_RCLOSE, BST_CHECKED); break; @@ -393,7 +393,7 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l EnableWindow(GetDlgItem(hwndDlg, IDC_DELAYFROMPU), ServiceExists(MS_POPUP_ADDPOPUPT)); EnableWindow(GetDlgItem(hwndDlg, IDC_DELAYPERMANENT), ServiceExists(MS_POPUP_ADDPOPUPT)); EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY), ServiceExists(MS_POPUP_ADDPOPUPT)); - switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { + switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { case POPUP_DELAYCUSTOM: CheckDlgButton(hwndDlg, IDC_DELAYCUSTOM, BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY), ServiceExists(MS_POPUP_ADDPOPUPT)); @@ -411,25 +411,25 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; } // delay - SetDlgItemInt(hwndDlg, IDC_DELAY, db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0), FALSE); + SetDlgItemInt(hwndDlg, IDC_DELAY, db_get_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0), FALSE); // back color - SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA)); + SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, db_get_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA)); // text - SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC)); + SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, db_get_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC)); // wincolors - CheckDlgButton(hwndDlg, IDC_WINCOLORS, db_get_b(NULL, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_WINCOLORS, db_get_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0) ? BST_CHECKED : BST_UNCHECKED); // defaultcolors - CheckDlgButton(hwndDlg, IDC_DEFAULTCOLORS, ((db_get_b(NULL, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) && (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS))) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DEFAULTCOLORS, ((db_get_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) && (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS))) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), ((BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)) && (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)))); EnableWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR), ((BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)) && (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)))); EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULTCOLORS), (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS))); EnableWindow(GetDlgItem(hwndDlg, IDC_WINCOLORS), (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS))); // popup types - CheckDlgButton(hwndDlg, IDC_PUCONNLOST, db_get_b(NULL, KSMODULENAME, SETTING_PUCONNLOST, TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_PUOTHER, db_get_b(NULL, KSMODULENAME, SETTING_PUOTHER, TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_PUCONNRETRY, db_get_b(NULL, KSMODULENAME, SETTING_PUCONNRETRY, TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_PURESULT, db_get_b(NULL, KSMODULENAME, SETTING_PURESULT, TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_PUSHOWEXTRA, db_get_b(NULL, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUCONNLOST, db_get_b(0, KSMODULENAME, SETTING_PUCONNLOST, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUOTHER, db_get_b(0, KSMODULENAME, SETTING_PUOTHER, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUCONNRETRY, db_get_b(0, KSMODULENAME, SETTING_PUCONNRETRY, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PURESULT, db_get_b(0, KSMODULENAME, SETTING_PURESULT, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUSHOWEXTRA, db_get_b(0, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE) ? BST_CHECKED : BST_UNCHECKED); bFreeze = false; break; @@ -474,45 +474,37 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l break; case IDC_PREV: - { - POPUPDATAT ppd = { NULL }; - - ppd.lchContact = NULL; - ppd.lchIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE); - wcsncpy(ppd.lptzContactName, TranslateT("Keep status"), MAX_CONTACTNAME); - wcsncpy(ppd.lptzText, TranslateT("You broke the Internet!"), MAX_SECONDLINE); - if (IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)) - { - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - } - else if (IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)) - { - ppd.colorBack = NULL; - ppd.colorText = NULL; - } - else - { - ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); - ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0); - } - ppd.PluginWindowProc = KSPopupDlgProc; - ppd.PluginData = NULL; - if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) { - ppd.iSeconds = 0; - } - else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM)) - { - ppd.iSeconds = GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE); - } - else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT)) - { - ppd.iSeconds = -1; + POPUPDATAT ppd = {}; + ppd.lchIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE); + wcsncpy(ppd.lptzContactName, TranslateT("Keep status"), MAX_CONTACTNAME); + wcsncpy(ppd.lptzText, TranslateT("You broke the Internet!"), MAX_SECONDLINE); + if (IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)) { + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + } + else if (IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)) { + ppd.colorBack = 0; + ppd.colorText = 0; + } + else { + ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); + ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0); + } + ppd.PluginWindowProc = KSPopupDlgProc; + ppd.PluginData = nullptr; + if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) { + ppd.iSeconds = 0; + } + else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM)) { + ppd.iSeconds = GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE); + } + else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT)) { + ppd.iSeconds = -1; + } + PUAddPopupT(&ppd); } - PUAddPopupT(&ppd); - } - break; + break; } break; @@ -520,41 +512,41 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (((LPNMHDR)lParam)->code == PSN_APPLY) { // left action if (IsDlgButtonChecked(hwndDlg, IDC_LNOTHING)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_NOTHING); + db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_NOTHING); else if (IsDlgButtonChecked(hwndDlg, IDC_LCLOSE)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CLOSEPOPUP); + db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CLOSEPOPUP); else if (IsDlgButtonChecked(hwndDlg, IDC_LCANCEL)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL); + db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL); // right action if (IsDlgButtonChecked(hwndDlg, IDC_RNOTHING)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_NOTHING); + db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_NOTHING); else if (IsDlgButtonChecked(hwndDlg, IDC_RCLOSE)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CLOSEPOPUP); + db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CLOSEPOPUP); else if (IsDlgButtonChecked(hwndDlg, IDC_RCANCEL)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL); + db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL); // delay if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU); + db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU); else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYCUSTOM); + db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYCUSTOM); else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT)) - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYPERMANENT); + db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYPERMANENT); // delay - db_set_dw(NULL, KSMODULENAME, SETTING_POPUP_TIMEOUT, GetDlgItemInt(hwndDlg, IDC_DELAY, NULL, FALSE)); + db_set_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE)); // back color - db_set_dw(NULL, KSMODULENAME, SETTING_POPUP_BACKCOLOR, SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)); + db_set_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)); // text color - db_set_dw(NULL, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + db_set_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); // use win - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)); + db_set_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)); // use def - db_set_b(NULL, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)); + db_set_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)); // store types - db_set_b(NULL, KSMODULENAME, SETTING_PUCONNLOST, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNLOST)); - db_set_b(NULL, KSMODULENAME, SETTING_PUOTHER, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUOTHER)); - db_set_b(NULL, KSMODULENAME, SETTING_PUCONNRETRY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNRETRY)); - db_set_b(NULL, KSMODULENAME, SETTING_PURESULT, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PURESULT)); - db_set_b(NULL, KSMODULENAME, SETTING_PUSHOWEXTRA, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUSHOWEXTRA)); + db_set_b(0, KSMODULENAME, SETTING_PUCONNLOST, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNLOST)); + db_set_b(0, KSMODULENAME, SETTING_PUOTHER, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUOTHER)); + db_set_b(0, KSMODULENAME, SETTING_PUCONNRETRY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNRETRY)); + db_set_b(0, KSMODULENAME, SETTING_PURESULT, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PURESULT)); + db_set_b(0, KSMODULENAME, SETTING_PUSHOWEXTRA, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUSHOWEXTRA)); } break; } diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 9229f901b0..0629485f15 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -33,8 +33,8 @@ TSettingsList* GetCurrentProtoSettings() Proto_EnumAccounts(&count, &protos); TSettingsList *result = new TSettingsList(count, SSCompareSettings); - if (result == NULL) - return NULL; + if (result == nullptr) + return nullptr; for (int i = 0; i < count; i++) if (IsSuitableProto(protos[i])) @@ -66,8 +66,8 @@ static char* GetStatusDesc(int status) static char* GetCMDLArguments(TSettingsList& protoSettings) { - if (protoSettings.getCount() == NULL) - return NULL; + if (protoSettings.getCount() == 0) + return nullptr; char *cmdl, *pnt; pnt = cmdl = (char*)malloc(mir_strlen(protoSettings[0].m_szName) + mir_strlen(GetStatusDesc(protoSettings[0].m_status)) + 4); @@ -87,7 +87,7 @@ static char* GetCMDLArguments(TSettingsList& protoSettings) } } - if (db_get_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, FALSE) == TRUE) { + if (db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, FALSE) == TRUE) { *pnt++ = ' '; *pnt++ = '\0'; cmdl = (char*)realloc(cmdl, mir_strlen(cmdl) + 12); @@ -103,7 +103,7 @@ static char* GetCMDLArguments(TSettingsList& protoSettings) static char* GetCMDL(TSettingsList& protoSettings) { char path[MAX_PATH]; - GetModuleFileNameA(NULL, path, MAX_PATH); + GetModuleFileNameA(nullptr, path, MAX_PATH); char* cmdl = (char*)malloc(mir_strlen(path) + 4); mir_snprintf(cmdl, mir_strlen(path) + 4, "\"%s\" ", path); @@ -123,7 +123,7 @@ static char* GetCMDL(TSettingsList& protoSettings) static wchar_t* GetLinkDescription(TSettingsList& protoSettings) { if (protoSettings.getCount() == 0) - return NULL; + return nullptr; CMStringW result(SHORTCUT_DESC); for (int i = 0; i < protoSettings.getCount(); i++) { @@ -137,8 +137,8 @@ static wchar_t* GetLinkDescription(TSettingsList& protoSettings) 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 = nullptr; + if (status == nullptr) status = TranslateT("<unknown>"); result.AppendChar('\r'); @@ -154,14 +154,14 @@ static wchar_t* GetLinkDescription(TSettingsList& protoSettings) HRESULT CreateLink(TSettingsList& protoSettings) { wchar_t savePath[MAX_PATH]; - if (SHGetSpecialFolderPath(NULL, savePath, 0x10, FALSE)) + if (SHGetSpecialFolderPath(nullptr, savePath, 0x10, FALSE)) wcsncat_s(savePath, SHORTCUT_FILENAME, _countof(savePath) - mir_wstrlen(savePath)); else mir_snwprintf(savePath, L".\\%s", SHORTCUT_FILENAME); // 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, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl); if (SUCCEEDED(hres)) { char *args = GetCMDLArguments(protoSettings); wchar_t *desc = GetLinkDescription(protoSettings); @@ -169,7 +169,7 @@ HRESULT CreateLink(TSettingsList& protoSettings) // Set the path to the shortcut target, and add the // description. wchar_t path[MAX_PATH]; - GetModuleFileName(NULL, path, _countof(path)); + GetModuleFileName(nullptr, path, _countof(path)); psl->SetPath(path); psl->SetDescription(desc); psl->SetArguments(_A2T(args)); @@ -216,7 +216,7 @@ INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA char cmdl[2048]; GetDlgItemTextA(hwndDlg, IDC_CMDL, cmdl, _countof(cmdl)); HGLOBAL cmdlGlob = GlobalAlloc(GMEM_MOVEABLE, sizeof(cmdl)); - if (cmdlGlob == NULL) { + if (cmdlGlob == nullptr) { CloseClipboard(); break; } @@ -259,24 +259,24 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w bInitDone = FALSE; TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SETPROFILE, db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_OVERRIDE, db_get_b(NULL, SSMODULENAME, SETTING_OVERRIDE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOWDIALOG, db_get_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SETWINSTATE, db_get_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SETWINLOCATION, db_get_b(NULL, SSMODULENAME, SETTING_SETWINLOCATION, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SETDOCKED, db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SETWINSIZE, db_get_b(NULL, SSMODULENAME, SETTING_SETWINSIZE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_OFFLINECLOSE, db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AUTODIAL, db_get_b(NULL, SSMODULENAME, SETTING_AUTODIAL, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_AUTOHANGUP, db_get_b(NULL, SSMODULENAME, SETTING_AUTOHANGUP, 0) ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwndDlg, IDC_SETPROFILEDELAY, db_get_dw(NULL, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), FALSE); - SetDlgItemInt(hwndDlg, IDC_DLGTIMEOUT, db_get_dw(NULL, SSMODULENAME, SETTING_DLGTIMEOUT, 5), FALSE); - SetDlgItemInt(hwndDlg, IDC_XPOS, db_get_dw(NULL, SSMODULENAME, SETTING_XPOS, 0), TRUE); - SetDlgItemInt(hwndDlg, IDC_YPOS, db_get_dw(NULL, SSMODULENAME, SETTING_YPOS, 0), TRUE); - SetDlgItemInt(hwndDlg, IDC_WIDTH, db_get_dw(NULL, SSMODULENAME, SETTING_WIDTH, 0), FALSE); - SetDlgItemInt(hwndDlg, IDC_HEIGHT, db_get_dw(NULL, SSMODULENAME, SETTING_HEIGHT, 0), FALSE); + CheckDlgButton(hwndDlg, IDC_SETPROFILE, db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_OVERRIDE, db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOWDIALOG, db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SETWINSTATE, db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SETWINLOCATION, db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SETDOCKED, db_get_b(0, SSMODULENAME, SETTING_SETDOCKED, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SETWINSIZE, db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_OFFLINECLOSE, db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AUTODIAL, db_get_b(0, SSMODULENAME, SETTING_AUTODIAL, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_AUTOHANGUP, db_get_b(0, SSMODULENAME, SETTING_AUTOHANGUP, 0) ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_SETPROFILEDELAY, db_get_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), FALSE); + SetDlgItemInt(hwndDlg, IDC_DLGTIMEOUT, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5), FALSE); + SetDlgItemInt(hwndDlg, IDC_XPOS, db_get_dw(0, SSMODULENAME, SETTING_XPOS, 0), TRUE); + SetDlgItemInt(hwndDlg, IDC_YPOS, db_get_dw(0, SSMODULENAME, SETTING_YPOS, 0), TRUE); + SetDlgItemInt(hwndDlg, IDC_WIDTH, db_get_dw(0, SSMODULENAME, SETTING_WIDTH, 0), FALSE); + SetDlgItemInt(hwndDlg, IDC_HEIGHT, db_get_dw(0, SSMODULENAME, SETTING_HEIGHT, 0), FALSE); { - int val = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + int val = db_get_b(0, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); int item = SendDlgItemMessage(hwndDlg, IDC_DOCKED, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); SendDlgItemMessage(hwndDlg, IDC_DOCKED, CB_SETITEMDATA, (WPARAM)item, (LPARAM)DOCKED_LEFT); if (val == DOCKED_LEFT) @@ -304,7 +304,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w SendMessage(hwndDlg, UM_REINITDOCKED, 0, 0); SendMessage(hwndDlg, UM_REINITWINSTATE, 0, 0); SendMessage(hwndDlg, UM_REINITWINSIZE, 0, 0); - SetTimer(hwndDlg, 0, 100, NULL); + SetTimer(hwndDlg, 0, 100, nullptr); bInitDone = TRUE; break; @@ -317,13 +317,13 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w else { wchar_t text[128]; mir_snwprintf(text, TranslateT("size: %d x %d"), - db_get_dw(NULL, MODULE_CLIST, SETTING_WIDTH, 0), - db_get_dw(NULL, MODULE_CLIST, SETTING_HEIGHT, 0)); + db_get_dw(0, MODULE_CLIST, SETTING_WIDTH, 0), + db_get_dw(0, MODULE_CLIST, SETTING_HEIGHT, 0)); SetDlgItemText(hwndDlg, IDC_CURWINSIZE, text); mir_snwprintf(text, TranslateT("loc: %d x %d"), - db_get_dw(NULL, MODULE_CLIST, SETTING_XPOS, 0), - db_get_dw(NULL, MODULE_CLIST, SETTING_YPOS, 0)); + db_get_dw(0, MODULE_CLIST, SETTING_XPOS, 0), + db_get_dw(0, MODULE_CLIST, SETTING_YPOS, 0)); SetDlgItemText(hwndDlg, IDC_CURWINLOC, text); } break; @@ -347,7 +347,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w break; case UM_REINITDOCKED: - EnableWindow(GetDlgItem(hwndDlg, IDC_SETDOCKED), db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 1)); + EnableWindow(GetDlgItem(hwndDlg, IDC_SETDOCKED), db_get_b(0, MODULE_CLIST, SETTING_TOOLWINDOW, 1)); if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_SETDOCKED))) CheckDlgButton(hwndDlg, IDC_SETDOCKED, BST_UNCHECKED); @@ -356,7 +356,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w case UM_REINITWINSTATE: { - int val = db_get_b(NULL, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + int val = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_RESETCONTENT, 0, 0); int item = SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Hidden")); @@ -364,7 +364,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (val == SETTING_STATE_HIDDEN) SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_SETCURSEL, item, 0); - if (!db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) { + if (!db_get_b(0, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) { item = SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Minimized")); SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_SETITEMDATA, item, SETTING_STATE_MINIMIZED); if (val == SETTING_STATE_MINIMIZED) @@ -372,14 +372,14 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w } 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(0, 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(0, 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) @@ -418,7 +418,7 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (ps) { GetProfile(defProfile, *ps); for (int i = 0; i < ps->getCount(); i++) - if ((*ps)[i].m_szMsg != NULL) + if ((*ps)[i].m_szMsg != nullptr) (*ps)[i].m_szMsg = wcsdup((*ps)[i].m_szMsg); CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)ps); @@ -444,45 +444,45 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w if (((LPNMHDR)lParam)->code == PSN_APPLY) { int val; - db_set_b(NULL, SSMODULENAME, SETTING_SETPROFILE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); + db_set_b(0, SSMODULENAME, SETTING_SETPROFILE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)); if (IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE)) - db_set_dw(NULL, SSMODULENAME, SETTING_SETPROFILEDELAY, GetDlgItemInt(hwndDlg, IDC_SETPROFILEDELAY, NULL, FALSE)); + db_set_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, GetDlgItemInt(hwndDlg, IDC_SETPROFILEDELAY, nullptr, FALSE)); if (IsDlgButtonChecked(hwndDlg, IDC_SETPROFILE) || IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)) { val = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0); - db_set_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, (WORD)val); + db_set_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, (WORD)val); } - db_set_b(NULL, SSMODULENAME, SETTING_OVERRIDE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OVERRIDE)); - db_set_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); + db_set_b(0, SSMODULENAME, SETTING_OVERRIDE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OVERRIDE)); + db_set_b(0, SSMODULENAME, SETTING_SHOWDIALOG, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)); if (IsDlgButtonChecked(hwndDlg, IDC_SHOWDIALOG)) - db_set_dw(NULL, SSMODULENAME, SETTING_DLGTIMEOUT, GetDlgItemInt(hwndDlg, IDC_DLGTIMEOUT, NULL, FALSE)); + db_set_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, GetDlgItemInt(hwndDlg, IDC_DLGTIMEOUT, nullptr, FALSE)); - db_set_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINSTATE)); + db_set_b(0, SSMODULENAME, SETTING_SETWINSTATE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINSTATE)); if (IsDlgButtonChecked(hwndDlg, IDC_SETWINSTATE)) { val = (int)SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_WINSTATE, CB_GETCURSEL, 0, 0), 0); - db_set_b(NULL, SSMODULENAME, SETTING_WINSTATE, (BYTE)val); + db_set_b(0, SSMODULENAME, SETTING_WINSTATE, (BYTE)val); } - db_set_b(NULL, SSMODULENAME, SETTING_SETDOCKED, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETDOCKED)); + db_set_b(0, SSMODULENAME, SETTING_SETDOCKED, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETDOCKED)); if (IsDlgButtonChecked(hwndDlg, IDC_SETDOCKED)) { val = (int)SendDlgItemMessage(hwndDlg, IDC_DOCKED, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_DOCKED, CB_GETCURSEL, 0, 0), 0); - db_set_b(NULL, SSMODULENAME, SETTING_DOCKED, (BYTE)val); + db_set_b(0, SSMODULENAME, SETTING_DOCKED, (BYTE)val); } - db_set_b(NULL, SSMODULENAME, SETTING_SETWINLOCATION, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINLOCATION)); + db_set_b(0, SSMODULENAME, SETTING_SETWINLOCATION, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINLOCATION)); if (IsDlgButtonChecked(hwndDlg, IDC_SETWINLOCATION)) { - db_set_dw(NULL, SSMODULENAME, SETTING_XPOS, GetDlgItemInt(hwndDlg, IDC_XPOS, NULL, TRUE)); - db_set_dw(NULL, SSMODULENAME, SETTING_YPOS, GetDlgItemInt(hwndDlg, IDC_YPOS, NULL, TRUE)); + db_set_dw(0, SSMODULENAME, SETTING_XPOS, GetDlgItemInt(hwndDlg, IDC_XPOS, nullptr, TRUE)); + db_set_dw(0, SSMODULENAME, SETTING_YPOS, GetDlgItemInt(hwndDlg, IDC_YPOS, nullptr, TRUE)); } - db_set_b(NULL, SSMODULENAME, SETTING_SETWINSIZE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)); + db_set_b(0, SSMODULENAME, SETTING_SETWINSIZE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)); if (IsDlgButtonChecked(hwndDlg, IDC_SETWINSIZE)) { - db_set_dw(NULL, SSMODULENAME, SETTING_WIDTH, GetDlgItemInt(hwndDlg, IDC_WIDTH, NULL, FALSE)); - db_set_dw(NULL, SSMODULENAME, SETTING_HEIGHT, GetDlgItemInt(hwndDlg, IDC_HEIGHT, NULL, FALSE)); + db_set_dw(0, SSMODULENAME, SETTING_WIDTH, GetDlgItemInt(hwndDlg, IDC_WIDTH, nullptr, FALSE)); + db_set_dw(0, SSMODULENAME, SETTING_HEIGHT, GetDlgItemInt(hwndDlg, IDC_HEIGHT, nullptr, FALSE)); } - db_set_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OFFLINECLOSE)); - db_set_b(NULL, SSMODULENAME, SETTING_AUTODIAL, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTODIAL)); - db_set_b(NULL, SSMODULENAME, SETTING_AUTOHANGUP, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOHANGUP)); + db_set_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_OFFLINECLOSE)); + db_set_b(0, SSMODULENAME, SETTING_AUTODIAL, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTODIAL)); + db_set_b(0, SSMODULENAME, SETTING_AUTOHANGUP, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOHANGUP)); } break; } @@ -503,16 +503,16 @@ static int DeleteSetting(const char *szSetting, LPARAM lParam) static int ClearDatabase(char* filter) { LIST<char> arSettings(10); - db_enum_settings(NULL, DeleteSetting, SSMODULENAME, &arSettings); + db_enum_settings(0, DeleteSetting, SSMODULENAME, &arSettings); for (int i = 0; i < arSettings.getCount(); i++) { - if ((filter == NULL) || (!strncmp(filter, arSettings[i], mir_strlen(filter)))) - db_unset(NULL, SSMODULENAME, arSettings[i]); + if ((filter == nullptr) || (!strncmp(filter, arSettings[i], mir_strlen(filter)))) + db_unset(0, SSMODULENAME, arSettings[i]); mir_free(arSettings[i]); } - if (filter == NULL) - db_unset(NULL, "AutoAway", "Confirm"); + if (filter == nullptr) + db_unset(0, "AutoAway", "Confirm"); return 0; } @@ -588,26 +588,26 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM } else { for (int j = 0; j < ar.getCount(); j++) - if (ar[j].m_szMsg != NULL) + if (ar[j].m_szMsg != nullptr) ar[j].m_szMsg = wcsdup(ar[j].m_szMsg); - ppo->tszName = db_get_wsa(NULL, SSMODULENAME, OptName(i, SETTING_PROFILENAME)); - if (ppo->tszName == NULL) { + ppo->tszName = db_get_wsa(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME)); + if (ppo->tszName == nullptr) { if (i == defProfile) ppo->tszName = mir_wstrdup(TranslateT("default")); else 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->createTtb = db_get_b(0, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), 0); + ppo->showDialog = db_get_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), 0); + ppo->createMmi = db_get_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), 0); + ppo->inSubMenu = db_get_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1); + ppo->regHotkey = db_get_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), 0); + ppo->hotKey = db_get_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), MAKEWORD((char)('0' + i), HOTKEYF_CONTROL | HOTKEYF_SHIFT)); } arProfiles.insert(ppo); } - if (hTTBModuleLoadedHook == NULL) + if (hTTBModuleLoadedHook == nullptr) EnableWindow(GetDlgItem(hwndDlg, IDC_CREATETTB), FALSE); SendMessage(hwndDlg, UM_REINITPROFILES, 0, 0); @@ -697,8 +697,8 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM if (idx != -1) { TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, idx, 0); - CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->m_szMsg != NULL ? IDC_CUSTOMMSG : IDC_MIRANDAMSG); - if (ps->m_szMsg != NULL) + CheckRadioButton(hwndDlg, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->m_szMsg != nullptr ? IDC_CUSTOMMSG : IDC_MIRANDAMSG); + if (ps->m_szMsg != nullptr) SetDlgItemText(hwndDlg, IDC_STATUSMSG, ps->m_szMsg); bStatusMsg = ((((CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_MODEMSGSEND&~PF1_INDIVMODEMSG)) && @@ -714,7 +714,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM case UM_ADDPROFILE: { wchar_t *tszName = (wchar_t*)lParam; - if (tszName == NULL) + if (tszName == nullptr) break; PROFILEOPTIONS* ppo = new PROFILEOPTIONS; @@ -731,7 +731,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM int i = (int)wParam; if (arProfiles.getCount() == 1) { - MessageBox(NULL, TranslateT("At least one profile must exist"), TranslateT("Status manager"), MB_OK); + MessageBox(nullptr, TranslateT("At least one profile must exist"), TranslateT("Status manager"), MB_OK); break; } @@ -740,8 +740,8 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM 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); + MessageBox(nullptr, TranslateT("Your default profile will be changed"), TranslateT("Status manager"), MB_OK); + db_set_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); } SendMessage(hwndDlg, UM_REINITPROFILES, 0, 0); break; @@ -785,10 +785,10 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM int len; TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0), 0); - if (ps->m_szMsg != NULL) + if (ps->m_szMsg != nullptr) free(ps->m_szMsg); - ps->m_szMsg = NULL; + ps->m_szMsg = nullptr; if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOMMSG)) { len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); ps->m_szMsg = (wchar_t*)calloc(sizeof(wchar_t), len + 1); @@ -804,10 +804,10 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM // but it works TSSSetting* ps = (TSSSetting*)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, LB_GETCURSEL, 0, 0), 0); - if (ps->m_szMsg != NULL) { + if (ps->m_szMsg != nullptr) { if (*ps->m_szMsg) free(ps->m_szMsg); - ps->m_szMsg = NULL; + ps->m_szMsg = nullptr; } int len = SendDlgItemMessage(hwndDlg, IDC_STATUSMSG, WM_GETTEXTLENGTH, 0, 0); ps->m_szMsg = (wchar_t*)calloc(sizeof(wchar_t), len + 1); @@ -857,7 +857,7 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM 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, nullptr, "Protocol ID"); break; } break; @@ -865,31 +865,31 @@ static INT_PTR CALLBACK StatusProfilesOptDlgProc(HWND hwndDlg, UINT msg, WPARAM case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { char setting[128]; - int oldCount = db_get_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int oldCount = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); for (int i = 0; i < oldCount; i++) { mir_snprintf(setting, "%d_", i); ClearDatabase(setting); } 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); - db_set_b(NULL, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), po.createMmi); - db_set_b(NULL, SSMODULENAME, OptName(i, SETTING_INSUBMENU), po.inSubMenu); - db_set_b(NULL, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), po.regHotkey); - db_set_w(NULL, SSMODULENAME, OptName(i, SETTING_HOTKEY), po.hotKey); - db_set_ws(NULL, SSMODULENAME, OptName(i, SETTING_PROFILENAME), po.tszName); + db_set_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), po.showDialog); + db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), po.createTtb); + db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), po.createMmi); + db_set_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), po.inSubMenu); + db_set_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), po.regHotkey); + db_set_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), po.hotKey); + db_set_ws(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME), po.tszName); TSettingsList& ar = *po.ps; for (int j = 0; j < ar.getCount(); j++) { - if (ar[j].m_szMsg != NULL) { + if (ar[j].m_szMsg != nullptr) { 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_ws(0, SSMODULENAME, OptName(i, setting), ar[j].m_szMsg); } - db_set_w(NULL, SSMODULENAME, OptName(i, ar[j].m_szName), ar[j].m_status); + db_set_w(0, SSMODULENAME, OptName(i, ar[j].m_szName), ar[j].m_status); } } - db_set_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, (WORD)arProfiles.getCount()); + db_set_w(0, SSMODULENAME, SETTING_PROFILECOUNT, (WORD)arProfiles.getCount()); // Rebuild status menu if (bNeedRebuildMenu) diff --git a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp index ba056510f5..05fa484306 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp @@ -27,19 +27,19 @@ extern int protoCount; static int menuprofiles[MAX_MMITEMS]; static int mcount = 0; -static PROFILECE *pce = NULL; +static PROFILECE *pce = nullptr; static int pceCount = 0; static UINT_PTR releaseTtbTimerId = 0; static HANDLE hTBModuleLoadedHook; -static HANDLE hMessageHook = NULL; +static HANDLE hMessageHook = nullptr; -static HWND hMessageWindow = NULL; -static HKINFO *hkInfo = NULL; +static HWND hMessageWindow = nullptr; +static HKINFO *hkInfo = nullptr; static int hkiCount = 0; -static HANDLE* ttbButtons = NULL; +static HANDLE* ttbButtons = nullptr; static int ttbButtonCount = 0; HANDLE hTTBModuleLoadedHook; @@ -59,10 +59,10 @@ static int CreateMainMenuItems(WPARAM, LPARAM) int count = GetProfileCount(0, 0); for (int i = 0; i < count && mcount < MAX_MMITEMS; i++) { wchar_t profilename[128]; - if (!db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), 0) || GetProfileName(i, (LPARAM)profilename)) + if (!db_get_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), 0) || GetProfileName(i, (LPARAM)profilename)) continue; - if (db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1) && !mi.root) { + if (db_get_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1) && !mi.root) { mi.root = Menu_CreateRoot(MO_STATUS, LPGENW("Status profiles"), 2000100000); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "1AB30D51-BABA-4B27-9288-1A12278BAD8D"); } @@ -87,9 +87,9 @@ INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) { int profile = (int)wParam; if (profile < 0) // get default profile - profile = db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); - int count = db_get_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); if (profile >= count && count > 0) return -1; @@ -102,7 +102,7 @@ INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; char setting[80]; mir_snprintf(setting, "%d_%s", profile, SETTING_PROFILENAME); - if (db_get_ws(NULL, SSMODULENAME, setting, &dbv)) + if (db_get_ws(0, SSMODULENAME, setting, &dbv)) return -1; wcsncpy(buf, dbv.ptszVal, 128 - 1); buf[127] = 0; @@ -113,9 +113,9 @@ INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) INT_PTR GetProfileCount(WPARAM wParam, LPARAM) { int *def = (int*)wParam; - int count = db_get_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, 1); + int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 1); if (def != 0) { - *def = db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + *def = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); if (*def >= count) *def = 0; } @@ -131,31 +131,31 @@ wchar_t *GetStatusMessage(int profile, char *szProto) for (int i = 0; i < pceCount; i++) { if ((pce[i].profile == profile) && (!mir_strcmp(pce[i].szProto, szProto))) { mir_snprintf(dbSetting, "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!db_get_ws(NULL, SSMODULENAME, dbSetting, &dbv)) { // reload from db + if (!db_get_ws(0, SSMODULENAME, dbSetting, &dbv)) { // reload from db pce[i].msg = (wchar_t*)realloc(pce[i].msg, sizeof(wchar_t)*(mir_wstrlen(dbv.ptszVal) + 1)); - if (pce[i].msg != NULL) { + if (pce[i].msg != nullptr) { mir_wstrcpy(pce[i].msg, dbv.ptszVal); } db_free(&dbv); } else { - if (pce[i].msg != NULL) { + if (pce[i].msg != nullptr) { free(pce[i].msg); - pce[i].msg = NULL; + pce[i].msg = nullptr; } } return pce[i].msg; } } pce = (PROFILECE*)realloc(pce, (pceCount + 1)*sizeof(PROFILECE)); - if (pce == NULL) - return NULL; + if (pce == nullptr) + return nullptr; pce[pceCount].profile = profile; pce[pceCount].szProto = _strdup(szProto); - pce[pceCount].msg = NULL; + pce[pceCount].msg = nullptr; mir_snprintf(dbSetting, "%d_%s_%s", profile, szProto, SETTING_PROFILE_STSMSG); - if (!db_get_ws(NULL, SSMODULENAME, dbSetting, &dbv)) { + if (!db_get_ws(0, SSMODULENAME, dbSetting, &dbv)) { pce[pceCount].msg = wcsdup(dbv.ptszVal); db_free(&dbv); } @@ -167,9 +167,9 @@ wchar_t *GetStatusMessage(int profile, char *szProto) int GetProfile(int profile, TSettingsList& arSettings) { if (profile < 0) // get default profile - profile = db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); - int count = db_get_w(NULL, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); if (profile >= count && count > 0) return -1; @@ -188,7 +188,7 @@ int GetProfile(int profile, TSettingsList& arSettings) static void CALLBACK releaseTtbTimerFunction(HWND, UINT, UINT_PTR, DWORD) { - KillTimer(NULL, releaseTtbTimerId); + KillTimer(nullptr, releaseTtbTimerId); for (int i = 0; i < ttbButtonCount; i++) CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)ttbButtons[i], 0); } @@ -199,19 +199,19 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM) int profile = (int)iProfileNo; TSettingsList profileSettings(10, SSCompareSettings); if (!GetProfile(profile, profileSettings)) { - profile = (profile >= 0) ? profile : db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = (profile >= 0) ? profile : db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); char setting[64]; mir_snprintf(setting, "%d_%s", profile, SETTING_SHOWCONFIRMDIALOG); - if (!db_get_b(NULL, SSMODULENAME, setting, 0)) + if (!db_get_b(0, SSMODULENAME, setting, 0)) CallService(MS_CS_SETSTATUSEX, (WPARAM)&profileSettings, 0); else - ShowConfirmDialogEx((TProtoSettings*)&profileSettings, db_get_dw(NULL, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); + ShowConfirmDialogEx((TProtoSettings*)&profileSettings, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); } // add timer here if (hTTBModuleLoadedHook) - releaseTtbTimerId = SetTimer(NULL, 0, 100, releaseTtbTimerFunction); + releaseTtbTimerId = SetTimer(nullptr, 0, 100, releaseTtbTimerFunction); return 0; } @@ -244,7 +244,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM) static int UnregisterHotKeys() { - if (hkInfo != NULL) { + if (hkInfo != nullptr) { for (int i = 0; i < hkiCount; i++) { UnregisterHotKey(hMessageWindow, (int)hkInfo[i].id); GlobalDeleteAtom(hkInfo[i].id); @@ -254,8 +254,8 @@ static int UnregisterHotKeys() DestroyWindow(hMessageWindow); hkiCount = 0; - hkInfo = NULL; - hMessageWindow = NULL; + hkInfo = nullptr; + hMessageWindow = nullptr; return 0; } @@ -263,17 +263,17 @@ static int UnregisterHotKeys() // assumes UnregisterHotKeys was called before static int RegisterHotKeys() { - hMessageWindow = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc); int count = GetProfileCount(0, 0); for (int i = 0; i < count; i++) { - if (!db_get_b(NULL, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), 0)) + if (!db_get_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), 0)) continue; - WORD wHotKey = db_get_w(NULL, SSMODULENAME, OptName(i, SETTING_HOTKEY), 0); + WORD wHotKey = db_get_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), 0); hkInfo = (HKINFO*)realloc(hkInfo, (hkiCount + 1)*sizeof(HKINFO)); - if (hkInfo == NULL) + if (hkInfo == nullptr) return -1; char atomname[255]; diff --git a/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp index e9d153670a..e80f19f2a4 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp @@ -23,7 +23,7 @@ static LIST<void> ttbButtons(1); -static IconItem iconList[] = +static IconItem iconList[] = { { LPGEN("Pressed toolbar icon"), "StartupStatus/TtbDown", IDI_TTBDOWN }, { LPGEN("Released toolbar icon"), "StartupStatus/TtbUp", IDI_TTBUP }, @@ -33,14 +33,14 @@ static IconItem iconList[] = void RemoveTopToolbarButtons() { - for (int i=ttbButtons.getCount()-1; i >= 0; i--) + for (int i = ttbButtons.getCount() - 1; i >= 0; i--) CallService(MS_TTB_REMOVEBUTTON, (WPARAM)ttbButtons[i], 0); ttbButtons.destroy(); } int CreateTopToolbarButtons(WPARAM, LPARAM) { - if (iconList[0].hIcolib == NULL) + if (iconList[0].hIcolib == nullptr) Icon_Register(hInst, "Toolbar/StartupStatus", iconList, _countof(iconList)); int profileCount = CallService(MS_SS_GETPROFILECOUNT, 0, 0); @@ -48,15 +48,15 @@ int CreateTopToolbarButtons(WPARAM, LPARAM) TTBButton ttb = { 0 }; ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; ttb.pszService = MS_SS_LOADANDSETPROFILE; - for (int i=0; i < profileCount; i++) { + for (int i = 0; i < profileCount; i++) { char setting[80]; mir_snprintf(setting, "%d_%s", i, SETTING_CREATETTBBUTTON); - if (!db_get_b(NULL, SSMODULENAME, setting, FALSE)) + if (!db_get_b(0, SSMODULENAME, setting, FALSE)) continue; - + DBVARIANT dbv; mir_snprintf(setting, "%d_%s", i, SETTING_PROFILENAME); - if (db_get(NULL, SSMODULENAME, setting, &dbv)) + if (db_get(0, SSMODULENAME, setting, &dbv)) continue; ttb.hIconHandleDn = iconList[0].hIcolib; diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index fb2b87ea0f..0f02b2065d 100644 --- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -28,7 +28,7 @@ TSSSetting::TSSSetting(PROTOACCOUNT *pa) m_szName = pa->szModuleName; m_tszAccName = pa->tszAccountName; m_status = m_lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); - m_szMsg = NULL; + m_szMsg = nullptr; } TSSSetting::TSSSetting(int profile, PROTOACCOUNT *pa) @@ -40,14 +40,14 @@ TSSSetting::TSSSetting(int profile, PROTOACCOUNT *pa) // load status char setting[80]; mir_snprintf(setting, "%d_%s", profile, pa->szModuleName); - int iStatus = db_get_w(NULL, SSMODULENAME, setting, 0); + int iStatus = db_get_w(0, SSMODULENAME, setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; m_status = iStatus; // load last status mir_snprintf(setting, "%s%s", PREFIX_LAST, m_szName); - iStatus = db_get_w(NULL, SSMODULENAME, setting, 0); + iStatus = db_get_w(0, SSMODULENAME, setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; m_lastStatus = iStatus; @@ -79,7 +79,7 @@ static PROTOCOLSETTINGEX* IsValidProtocol(TSettingsList& protoSettings, char* pr if (!strncmp(protoSettings[i].m_szName, protoName, mir_strlen(protoSettings[i].m_szName))) return &protoSettings[i]; - return NULL; + return nullptr; } static int IsValidStatusDesc(char* statusDesc) @@ -133,7 +133,7 @@ static void ProcessCommandLineOptions(TSettingsList& protoSettings) } char *protoName = cmdl; // first protocol ? PROTOCOLSETTINGEX* protoSetting = IsValidProtocol(protoSettings, protoName); - if (protoSetting != NULL) { + if (protoSetting != nullptr) { while (*cmdl != '=') { if (*cmdl == '\0') return; @@ -163,7 +163,7 @@ static void SetLastStatusMessages(TSettingsList &ps) mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, ps[i].m_szName); DBVARIANT dbv; - if (ps[i].m_szMsg == NULL && !db_get_ws(NULL, SSMODULENAME, dbSetting, &dbv)) { + if (ps[i].m_szMsg == nullptr && !db_get_ws(0, SSMODULENAME, dbSetting, &dbv)) { ps[i].m_szMsg = wcsdup(dbv.ptszVal); // remember this won't be freed db_free(&dbv); } @@ -202,7 +202,7 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) if (ack->type != ACKTYPE_STATUS && ack->result != ACKRESULT_FAILED) return 0; - if (!db_get_b(NULL, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) + if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) return 0; for (int i = 0; i < startupSettings.getCount(); i++) { @@ -218,11 +218,11 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) static int StatusChange(WPARAM, LPARAM lParam) { // change by menu - if (!db_get_b(NULL, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) + if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) return 0; char *szProto = (char *)lParam; - if (szProto == NULL) { // global status change + if (szProto == nullptr) { // global status change for (int i = 0; i < startupSettings.getCount(); i++) { startupSettings[i].m_szName = ""; log_debugA("StartupStatus: all protos overridden by ME_CLIST_STATUSMODECHANGE, status will not be set"); @@ -243,17 +243,17 @@ static int StatusChange(WPARAM, LPARAM lParam) static int CSStatusChangeEx(WPARAM wParam, LPARAM) { // another status plugin made the change - if (!db_get_b(NULL, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) + if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0) return 0; if (wParam != 0) { PROTOCOLSETTINGEX** ps = *(PROTOCOLSETTINGEX***)wParam; - if (ps == NULL) + if (ps == nullptr) return -1; for (int i = 0; i < startupSettings.getCount(); i++) { for (int j = 0; j < startupSettings.getCount(); j++) { - if (ps[i]->m_szName == NULL || startupSettings[j].m_szName == NULL) + if (ps[i]->m_szName == nullptr || startupSettings[j].m_szName == nullptr) continue; if (!mir_strcmp(ps[i]->m_szName, startupSettings[j].m_szName)) { @@ -270,7 +270,7 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM) static void CALLBACK SetStatusTimed(HWND, UINT, UINT_PTR, DWORD) { - KillTimer(NULL, setStatusTimerId); + KillTimer(nullptr, setStatusTimerId); UnhookEvent(hProtoAckHook); UnhookEvent(hCSStatusChangeHook); UnhookEvent(hStatusChangeHook); @@ -294,9 +294,9 @@ static int OnOkToExit(WPARAM, LPARAM) char lastName[128], lastMsg[128]; mir_snprintf(lastName, "%s%s", PREFIX_LAST, pa->szModuleName); - db_set_w(NULL, SSMODULENAME, lastName, (WORD)CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)); + db_set_w(0, SSMODULENAME, lastName, (WORD)CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)); mir_snprintf(lastMsg, "%s%s", PREFIX_LASTMSG, pa->szModuleName); - db_unset(NULL, SSMODULENAME, lastMsg); + db_unset(0, SSMODULENAME, lastMsg); if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND & ~PF1_INDIVMODEMSG)) continue; @@ -310,19 +310,19 @@ static int OnOkToExit(WPARAM, LPARAM) NAS_PROTOINFO npi = { sizeof(npi) }; npi.szProto = pa->szModuleName; CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1); - if (npi.szMsg == NULL) { + if (npi.szMsg == nullptr) { npi.status = 0; - npi.szProto = NULL; + npi.szProto = nullptr; CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1); } - if (npi.szMsg != NULL) { - db_set_ws(NULL, SSMODULENAME, lastMsg, npi.tszMsg); + if (npi.szMsg != nullptr) { + db_set_ws(0, SSMODULENAME, lastMsg, npi.tszMsg); mir_free(npi.tszMsg); } } } - if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) Clist_SetStatusMode(ID_STATUS_OFFLINE); return 0; @@ -331,8 +331,8 @@ static int OnOkToExit(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM) { // set windowstate and docked for next startup - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, 0)) { - int state = db_get_b(NULL, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0)) { + int state = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); HWND hClist = pcli->hwndContactList; BOOL isHidden = !IsWindowVisible(hClist); switch (state) { @@ -343,7 +343,7 @@ static int OnShutdown(WPARAM, LPARAM) break; case SETTING_STATE_MINIMIZED: - if (!db_get_b(NULL, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) + if (!db_get_b(0, MODULE_CLIST, SETTING_TOOLWINDOW, 0)) ShowWindow(hClist, SW_SHOWMINIMIZED); break; @@ -356,13 +356,13 @@ static int OnShutdown(WPARAM, LPARAM) } // hangup - if (db_get_b(NULL, SSMODULENAME, SETTING_AUTOHANGUP, 0)) + if (db_get_b(0, SSMODULENAME, SETTING_AUTOHANGUP, 0)) InternetAutodialHangup(0); - int state = db_get_b(NULL, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + int state = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); // set windowstate and docked for next startup - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, 0)) - db_set_b(NULL, MODULE_CLIST, SETTING_WINSTATE, (BYTE)state); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0)) + db_set_b(0, MODULE_CLIST, SETTING_WINSTATE, (BYTE)state); if (hMessageWindow) DestroyWindow(hMessageWindow); @@ -401,7 +401,7 @@ int SSModuleLoaded(WPARAM, LPARAM) HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit); HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown); /* message window for poweroff */ - hMessageWindow = CreateWindowEx(0, L"STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc); GetProfile(-1, startupSettings); @@ -412,39 +412,39 @@ int SSModuleLoaded(WPARAM, LPARAM) return 0;// no protocols are loaded SetLastStatusMessages(startupSettings); - showDialogOnStartup = (showDialogOnStartup || db_get_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, 0)); + showDialogOnStartup = (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0)); // dial - if (showDialogOnStartup || db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1)) - if (db_get_b(NULL, SSMODULENAME, SETTING_AUTODIAL, 0)) - InternetAutodial(0, NULL); + if (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1)) + if (db_get_b(0, SSMODULENAME, SETTING_AUTODIAL, 0)) + InternetAutodial(0, nullptr); // set the status! - if (showDialogOnStartup || db_get_b(NULL, SSMODULENAME, SETTING_SHOWDIALOG, 0)) - ShowConfirmDialogEx((TProtoSettings*)&startupSettings, db_get_dw(NULL, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); - else if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1)) { + if (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0)) + ShowConfirmDialogEx((TProtoSettings*)&startupSettings, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); + else if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1)) { // set hooks for override - if (db_get_b(NULL, SSMODULENAME, SETTING_OVERRIDE, 1)) { + if (db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1)) { hProtoAckHook = HookEvent(ME_PROTO_ACK, ProcessProtoAck); hCSStatusChangeHook = HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChangeEx); hStatusChangeHook = HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChange); } - setStatusTimerId = SetTimer(NULL, 0, db_get_dw(NULL, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), SetStatusTimed); + setStatusTimerId = SetTimer(nullptr, 0, db_get_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), SetStatusTimed); } // win size and location - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINLOCATION, 0) || db_get_b(NULL, SSMODULENAME, SETTING_SETWINSIZE, 0)) { + if (db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0) || db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0)) { HWND hClist = pcli->hwndContactList; // store in db - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINLOCATION, 0)) { - db_set_dw(NULL, MODULE_CLIST, SETTING_XPOS, db_get_dw(NULL, SSMODULENAME, SETTING_XPOS, 0)); - db_set_dw(NULL, MODULE_CLIST, SETTING_YPOS, db_get_dw(NULL, SSMODULENAME, SETTING_YPOS, 0)); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0)) { + db_set_dw(0, MODULE_CLIST, SETTING_XPOS, db_get_dw(0, SSMODULENAME, SETTING_XPOS, 0)); + db_set_dw(0, MODULE_CLIST, SETTING_YPOS, db_get_dw(0, SSMODULENAME, SETTING_YPOS, 0)); } - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSIZE, 0)) { - db_set_dw(NULL, MODULE_CLIST, SETTING_WIDTH, db_get_dw(NULL, SSMODULENAME, SETTING_WIDTH, 0)); - if (!db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0)) - db_set_dw(NULL, MODULE_CLIST, SETTING_HEIGHT, db_get_dw(NULL, SSMODULENAME, SETTING_HEIGHT, 0)); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0)) { + db_set_dw(0, MODULE_CLIST, SETTING_WIDTH, db_get_dw(0, SSMODULENAME, SETTING_WIDTH, 0)); + if (!db_get_b(0, MODULE_CLUI, SETTING_AUTOSIZE, 0)) + db_set_dw(0, MODULE_CLIST, SETTING_HEIGHT, db_get_dw(0, SSMODULENAME, SETTING_HEIGHT, 0)); } WINDOWPLACEMENT wndpl = { sizeof(wndpl) }; @@ -456,14 +456,14 @@ int SSModuleLoaded(WPARAM, LPARAM) int y = rc.top; int width = rc.right - rc.left; int height = rc.bottom - rc.top; - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINLOCATION, 0)) { - x = db_get_dw(NULL, SSMODULENAME, SETTING_XPOS, x); - y = db_get_dw(NULL, SSMODULENAME, SETTING_YPOS, y); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0)) { + x = db_get_dw(0, SSMODULENAME, SETTING_XPOS, x); + y = db_get_dw(0, SSMODULENAME, SETTING_YPOS, y); } - if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSIZE, 0)) { - width = db_get_dw(NULL, SSMODULENAME, SETTING_WIDTH, width); - if (!db_get_b(NULL, MODULE_CLUI, SETTING_AUTOSIZE, 0)) - height = db_get_dw(NULL, SSMODULENAME, SETTING_HEIGHT, height); + if (db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0)) { + width = db_get_dw(0, SSMODULENAME, SETTING_WIDTH, width); + if (!db_get_b(0, MODULE_CLUI, SETTING_AUTOSIZE, 0)) + height = db_get_dw(0, SSMODULENAME, SETTING_HEIGHT, height); } MoveWindow(hClist, x, y, width, height, TRUE); } @@ -483,17 +483,17 @@ void StartupStatusLoad() { HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); - if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || - db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) - db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE); + if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || + db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + db_set_w(0, "CList", "Status", (WORD)ID_STATUS_OFFLINE); // docking - if (db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0)) { - int docked = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + if (db_get_b(0, SSMODULENAME, SETTING_SETDOCKED, 0)) { + int docked = db_get_b(0, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) docked = -docked; - db_set_b(NULL, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); + db_set_b(0, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); } // Create service functions; the get functions are created here; they don't rely on commonstatus diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp index 6869550b1a..4487d2830f 100644 --- a/plugins/StatusManager/src/commonstatus.cpp +++ b/plugins/StatusManager/src/commonstatus.cpp @@ -50,7 +50,7 @@ char *StatusModeToDbSetting(int status, const char *suffix) case ID_STATUS_INVISIBLE: prefix = "Inv"; break; case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break; case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break; - default: return NULL; + default: return nullptr; } mir_strcpy(str, prefix); mir_strcat(str, suffix); return str; @@ -93,7 +93,7 @@ int GetActualStatus(PROTOCOLSETTINGEX *protoSetting) wchar_t* GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) { - if (ps->m_szMsg != NULL) {// custom message set + if (ps->m_szMsg != nullptr) {// custom message set log_infoA("CommonStatus: Status message set by calling plugin"); return mir_wstrdup(ps->m_szMsg); } @@ -108,7 +108,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) int i, j, pstatus = 0, gstatus = 0; for (i = 0; i < protoList->getCount(); i++) - if (ps[i]->m_szMsg != NULL && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE) + if (ps[i]->m_szMsg != nullptr && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE) return 0; int count; @@ -127,7 +127,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) if (pstatus == 0) pstatus = CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0); - if (db_get_b(NULL, protos[i]->szModuleName, "LockMainStatus", 0)) { + if (db_get_b(0, protos[i]->szModuleName, "LockMainStatus", 0)) { // if proto is locked, pstatus must be the current status if (pstatus != CallProtoService(protos[i]->szModuleName, PS_GETSTATUS, 0, 0)) return 0; @@ -167,8 +167,8 @@ static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus) memcpy(tszMsg + j, substituteStr, sizeof(wchar_t)*mir_wstrlen(substituteStr)); } - wchar_t *szFormattedMsg = variables_parsedup(tszMsg, ps->m_tszAccName, NULL); - if (szFormattedMsg != NULL) { + wchar_t *szFormattedMsg = variables_parsedup(tszMsg, ps->m_tszAccName, 0); + if (szFormattedMsg != nullptr) { mir_free(tszMsg); tszMsg = szFormattedMsg; } @@ -181,7 +181,7 @@ static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus) INT_PTR SetStatusEx(WPARAM wParam, LPARAM) { PROTOCOLSETTINGEX** protoSettings = *(PROTOCOLSETTINGEX***)wParam; - if (protoSettings == NULL) + if (protoSettings == nullptr) return -1; int globStatus = equalsGlobalStatus(protoSettings); @@ -257,7 +257,7 @@ static INT_PTR GetProtocolCountService(WPARAM, LPARAM) bool IsSuitableProto(PROTOACCOUNT *pa) { - return (pa == NULL) ? false : (pcli->pfnGetProtocolVisibility(pa->szModuleName) != 0); + return (pa == nullptr) ? false : (pcli->pfnGetProtocolVisibility(pa->szModuleName) != 0); } int GetProtoCount() diff --git a/plugins/StatusManager/src/confirmdialog.cpp b/plugins/StatusManager/src/confirmdialog.cpp index c3d093738b..2e92f31b0f 100644 --- a/plugins/StatusManager/src/confirmdialog.cpp +++ b/plugins/StatusManager/src/confirmdialog.cpp @@ -51,15 +51,15 @@ static OBJLIST<TConfirmSetting> *confirmSettings; static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - static PROTOCOLSETTINGEX* protoSetting = NULL; + static PROTOCOLSETTINGEX* protoSetting = nullptr; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); protoSetting = (PROTOCOLSETTINGEX *)lParam; - if (protoSetting->m_szMsg == NULL) { + if (protoSetting->m_szMsg == nullptr) { wchar_t* smsg = GetDefaultStatusMessage(protoSetting, GetActualStatus(protoSetting)); - if (smsg != NULL) { + if (smsg != nullptr) { SetDlgItemText(hwndDlg, IDC_STSMSG, smsg); mir_free(smsg); } @@ -81,7 +81,7 @@ static INT_PTR CALLBACK StatusMessageDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar 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) + if (protoSetting->m_szMsg != nullptr) GetDlgItemText(hwndDlg, IDC_STSMSG, protoSetting->m_szMsg, len + 1); } SendMessage(GetParent(hwndDlg), UM_STSMSGDLGCLOSED, TRUE, 0); @@ -140,8 +140,8 @@ static int SetStatusList(HWND hwndDlg) // status message 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].m_tszAccName, NULL); + if (msg != nullptr) { + wchar_t* fMsg = variables_parsedup(msg, (*confirmSettings)[i].m_tszAccName, 0); ListView_SetItemText(hList, lvItem.iItem, 2, fMsg); mir_free(fMsg); mir_free(msg); @@ -206,13 +206,13 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP else SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_SETCURSEL, defaultProfile, 0); } - + // start timer if (timeOut > 0) { wchar_t text[32]; mir_snwprintf(text, TranslateT("Closing in %d"), timeOut); SetDlgItemText(hwndDlg, IDC_CLOSE, text); - SetTimer(hwndDlg, TIMER_ID, 1000, NULL); + SetTimer(hwndDlg, TIMER_ID, 1000, nullptr); } return TRUE; @@ -239,14 +239,14 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP { 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) { + if ((*confirmSettings)[i].m_szMsg != nullptr) { free((*confirmSettings)[i].m_szMsg); - (*confirmSettings)[i].m_szMsg = NULL; + (*confirmSettings)[i].m_szMsg = nullptr; } 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 + if ((*confirmSettings)[i].m_szMsg != nullptr) // we free this later, copy to our memory space (*confirmSettings)[i].m_szMsg = wcsdup((*confirmSettings)[i].m_szMsg); SetStatusList(hwndDlg); @@ -413,8 +413,8 @@ HWND ShowConfirmDialogEx(OBJLIST<PROTOCOLSETTINGEX> *params, int _timeout) if (timeOut < 0) timeOut = DEF_CLOSE_TIME; - if (GetWindow(win, 0) == NULL) { - win = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMDIALOG), NULL, ConfirmDlgProc, NULL); + if (GetWindow(win, 0) == nullptr) { + win = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONFIRMDIALOG), nullptr, ConfirmDlgProc, 0); EnableWindow(win, TRUE); } diff --git a/plugins/StatusManager/src/options.cpp b/plugins/StatusManager/src/options.cpp index cb3d19e7fe..3c5a33799c 100644 --- a/plugins/StatusManager/src/options.cpp +++ b/plugins/StatusManager/src/options.cpp @@ -5,11 +5,11 @@ bool IsSubPluginEnabled(const char *name) // Check if this plugin was disabled as separate dll CMStringA dllName(FORMAT, "%s.dll", name); dllName.MakeLower(); - int dllEnabled = !db_get_b(NULL, "PluginDisable", dllName); + int dllEnabled = !db_get_b(0, "PluginDisable", dllName); char setting[128]; mir_snprintf(setting, "%s_enabled", name); - return db_get_b(NULL, MODULENAME, setting, dllEnabled) != 0; + return db_get_b(0, MODULENAME, setting, dllEnabled) != 0; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -35,11 +35,11 @@ void CSubPluginsOptionsDlg::OnApply() { char setting[128]; mir_snprintf(setting, "%s_enabled", KSMODULENAME); - db_set_b(NULL, MODULENAME, setting, m_enableKeepStatus.GetState()); + db_set_b(0, MODULENAME, setting, m_enableKeepStatus.GetState()); mir_snprintf(setting, "%s_enabled", SSMODULENAME); - db_set_b(NULL, MODULENAME, setting, m_enableStartupStatus.GetState()); + db_set_b(0, MODULENAME, setting, m_enableStartupStatus.GetState()); mir_snprintf(setting, "%s_enabled", AAAMODULENAME); - db_set_b(NULL, MODULENAME, setting, m_enableAdvancedAutoAway.GetState()); + db_set_b(0, MODULENAME, setting, m_enableAdvancedAutoAway.GetState()); } int CSubPluginsOptionsDlg::OnOptionsInit(WPARAM wParam, LPARAM) diff --git a/plugins/StatusManager/src/version.h b/plugins/StatusManager/src/version.h index 07d9125074..82d57c0469 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 2 +#define __BUILD_NUM 3 // other stuff for Version resource #include <stdver.h> |