diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-11 17:36:51 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-11 17:36:51 +0300 |
commit | 657afe8e174e6f0e9a2de1848546db8caa19dad4 (patch) | |
tree | 00ff036984aa2eadbee65d608fa10b81d017ba3c /plugins | |
parent | 7addc0e52c8518e40533341f265d0780d37a743c (diff) |
code cleaning
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/StatusManager/src/aaa_options.cpp | 50 | ||||
-rw-r--r-- | plugins/StatusManager/src/advancedautoaway.cpp | 30 | ||||
-rw-r--r-- | plugins/StatusManager/src/keepstatus.cpp | 2 | ||||
-rw-r--r-- | plugins/StatusManager/src/ks_options.cpp | 167 | ||||
-rw-r--r-- | plugins/StatusManager/src/ss_options.cpp | 118 | ||||
-rw-r--r-- | plugins/StatusManager/src/ss_profiles.cpp | 36 | ||||
-rw-r--r-- | plugins/StatusManager/src/ss_toolbars.cpp | 4 | ||||
-rw-r--r-- | plugins/StatusManager/src/startupstatus.cpp | 74 | ||||
-rw-r--r-- | plugins/StatusManager/src/version.h | 2 |
9 files changed, 240 insertions, 243 deletions
diff --git a/plugins/StatusManager/src/aaa_options.cpp b/plugins/StatusManager/src/aaa_options.cpp index 612722770d..0b6e5fc3a0 100644 --- a/plugins/StatusManager/src/aaa_options.cpp +++ b/plugins/StatusManager/src/aaa_options.cpp @@ -83,14 +83,14 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L settings[count]->status = it.iStatus; DBVARIANT dbv; - if (!db_get_s(0, AAAMODULENAME, StatusModeToDbSetting(it.iStatus, SETTING_STATUSMSG), &dbv)) { + if (!AAAPlugin.getString(StatusModeToDbSetting(it.iStatus, SETTING_STATUSMSG), &dbv)) { settings[count]->msg = (char*)mir_alloc(mir_strlen(dbv.pszVal) + 1); mir_strcpy(settings[count]->msg, dbv.pszVal); db_free(&dbv); } else settings[count]->msg = nullptr; - settings[count]->useCustom = db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(it.iStatus, SETTING_MSGCUSTOM), FALSE); + settings[count]->useCustom = AAAPlugin.getByte(StatusModeToDbSetting(it.iStatus, SETTING_MSGCUSTOM), FALSE); count += 1; } SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); @@ -169,9 +169,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(0, AAAMODULENAME, StatusModeToDbSetting(settings[i]->status, SETTING_MSGCUSTOM), (BYTE)settings[i]->useCustom); + AAAPlugin.setByte(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); + AAAPlugin.setString(StatusModeToDbSetting(settings[i]->status, SETTING_STATUSMSG), settings[i]->msg); } break; } @@ -196,17 +196,17 @@ static int WriteAutoAwaySetting(SMProto &autoAwaySetting, char *protoName) { char setting[128]; mir_snprintf(setting, "%s_OptionFlags", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.optionFlags); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.optionFlags); mir_snprintf(setting, "%s_AwayTime", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.awayTime); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.awayTime); mir_snprintf(setting, "%s_NATime", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.naTime); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.naTime); mir_snprintf(setting, "%s_StatusFlags", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.statusFlags); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.statusFlags); mir_snprintf(setting, "%s_Lv1Status", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv1Status); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.lv1Status); mir_snprintf(setting, "%s_Lv2Status", protoName); - db_set_w(0, AAAMODULENAME, setting, (WORD)autoAwaySetting.lv2Status); + AAAPlugin.setWord(setting, (WORD)autoAwaySetting.lv2Status); return 0; } @@ -542,13 +542,13 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - 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, IDC_IGNLOCK, AAAPlugin.getByte(SETTING_IGNLOCK, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IGNSYSKEYS, AAAPlugin.getByte(SETTING_IGNSYSKEYS, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_IGNALTCOMBO, AAAPlugin.getByte(SETTING_IGNALTCOMBO, FALSE) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MONITORMOUSE, AAAPlugin.getByte(SETTING_MONITORMOUSE, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MONITORKEYBOARD, AAAPlugin.getByte(SETTING_MONITORKEYBOARD, BST_CHECKED) != 0 ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, AAAPlugin.getWord(SETTING_AWAYCHECKTIMEINSECS, 5), FALSE); + SetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, AAAPlugin.getWord(SETTING_CONFIRMDELAY, 5), FALSE); CheckDlgButton(hwndDlg, g_bAAASettingSame ? IDC_SAMESETTINGS : IDC_PERPROTOCOLSETTINGS, BST_CHECKED); break; @@ -580,14 +580,14 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA break; case PSN_APPLY: - 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)g_bAAASettingSame); - 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)); + AAAPlugin.setByte(SETTING_IGNLOCK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNLOCK)); + AAAPlugin.setByte(SETTING_IGNSYSKEYS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNSYSKEYS)); + AAAPlugin.setByte(SETTING_IGNALTCOMBO, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IGNALTCOMBO)); + AAAPlugin.setByte(SETTING_SAMESETTINGS, (BYTE)g_bAAASettingSame); + AAAPlugin.setWord(SETTING_AWAYCHECKTIMEINSECS, (WORD)GetDlgItemInt(hwndDlg, IDC_AWAYCHECKTIMEINSECS, nullptr, FALSE)); + AAAPlugin.setWord(SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, nullptr, FALSE)); + AAAPlugin.setByte(SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE)); + AAAPlugin.setByte(SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD)); } } break; diff --git a/plugins/StatusManager/src/advancedautoaway.cpp b/plugins/StatusManager/src/advancedautoaway.cpp index 2d42c89007..aa630ccb36 100644 --- a/plugins/StatusManager/src/advancedautoaway.cpp +++ b/plugins/StatusManager/src/advancedautoaway.cpp @@ -110,8 +110,8 @@ static int changeState(SMProto &setting, int mode, STATES newState) setting.m_szMsg = nullptr; } - if (db_get_b(0, AAAMODULENAME, StatusModeToDbSetting(setting.aaaStatus, SETTING_MSGCUSTOM), FALSE)) - setting.m_szMsg = db_get_wsa(0, AAAMODULENAME, StatusModeToDbSetting(setting.aaaStatus, SETTING_STATUSMSG)); + if (AAAPlugin.getByte(StatusModeToDbSetting(setting.aaaStatus, SETTING_MSGCUSTOM), FALSE)) + setting.m_szMsg = AAAPlugin.getWStringA(StatusModeToDbSetting(setting.aaaStatus, SETTING_STATUSMSG)); } else if (setting.m_szMsg != nullptr) { mir_free(setting.m_szMsg); @@ -262,7 +262,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD) it->m_status = it->aaaStatus; if (confirm) - confirmDialog = ShowConfirmDialogEx(&ps, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5)); + confirmDialog = ShowConfirmDialogEx(&ps, AAAPlugin.getWord(SETTING_CONFIRMDELAY, 5)); else if (statusChanged) SetStatusEx(ps); } @@ -433,13 +433,13 @@ int LoadAutoAwaySetting(SMProto &autoAwaySetting, char *protoName) { char setting[128]; mir_snprintf(setting, "%s_OptionFlags", protoName); - autoAwaySetting.optionFlags = db_get_w(0, AAAMODULENAME, setting, FLAG_LV2ONINACTIVE | FLAG_RESET | FLAG_ENTERIDLE); + autoAwaySetting.optionFlags = AAAPlugin.getWord(setting, FLAG_LV2ONINACTIVE | FLAG_RESET | FLAG_ENTERIDLE); mir_snprintf(setting, "%s_AwayTime", protoName); - autoAwaySetting.awayTime = db_get_w(0, AAAMODULENAME, setting, SETTING_AWAYTIME_DEFAULT); + autoAwaySetting.awayTime = AAAPlugin.getWord(setting, SETTING_AWAYTIME_DEFAULT); mir_snprintf(setting, "%s_NATime", protoName); - autoAwaySetting.naTime = db_get_w(0, AAAMODULENAME, setting, SETTING_NATIME_DEFAULT); + autoAwaySetting.naTime = AAAPlugin.getWord(setting, SETTING_NATIME_DEFAULT); mir_snprintf(setting, "%s_StatusFlags", protoName); - autoAwaySetting.statusFlags = db_get_w(0, AAAMODULENAME, setting, StatusModeToProtoFlag(ID_STATUS_ONLINE) | StatusModeToProtoFlag(ID_STATUS_FREECHAT)); + autoAwaySetting.statusFlags = AAAPlugin.getWord(setting, StatusModeToProtoFlag(ID_STATUS_ONLINE) | StatusModeToProtoFlag(ID_STATUS_FREECHAT)); int flags; if (g_bAAASettingSame) @@ -447,9 +447,9 @@ int LoadAutoAwaySetting(SMProto &autoAwaySetting, char *protoName) 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(0, AAAMODULENAME, setting, (flags & StatusModeToProtoFlag(ID_STATUS_AWAY)) ? ID_STATUS_AWAY : ID_STATUS_OFFLINE); + autoAwaySetting.lv1Status = AAAPlugin.getWord(setting, (flags & StatusModeToProtoFlag(ID_STATUS_AWAY)) ? ID_STATUS_AWAY : ID_STATUS_OFFLINE); mir_snprintf(setting, "%s_Lv2Status", protoName); - autoAwaySetting.lv2Status = db_get_w(0, AAAMODULENAME, setting, (flags & StatusModeToProtoFlag(ID_STATUS_NA)) ? ID_STATUS_NA : ID_STATUS_OFFLINE); + autoAwaySetting.lv2Status = AAAPlugin.getWord(setting, (flags & StatusModeToProtoFlag(ID_STATUS_NA)) ? ID_STATUS_NA : ID_STATUS_OFFLINE); return 0; } @@ -468,11 +468,11 @@ void AAALoadOptions() bool monitorMiranda = false, monitorAll = false; - 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) != 0; - monitorKeyboard = db_get_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, TRUE) != 0; + ignoreLockKeys = AAAPlugin.getByte(SETTING_IGNLOCK, FALSE); + ignoreSysKeys = AAAPlugin.getByte(SETTING_IGNSYSKEYS, FALSE); + ignoreAltCombo = AAAPlugin.getByte(SETTING_IGNALTCOMBO, FALSE); + monitorMouse = AAAPlugin.getByte(SETTING_MONITORMOUSE, TRUE) != 0; + monitorKeyboard = AAAPlugin.getByte(SETTING_MONITORKEYBOARD, TRUE) != 0; lastInput = lastMirandaInput = GetTickCount(); for (auto &it : protoList) { @@ -490,7 +490,7 @@ void AAALoadOptions() } HookWindowsHooks(monitorMiranda, monitorAll); - hAutoAwayTimer = SetTimer(nullptr, 0, db_get_w(0, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5) * 1000, AutoAwayTimer); + hAutoAwayTimer = SetTimer(nullptr, 0, AAAPlugin.getWord(SETTING_AWAYCHECKTIMEINSECS, 5) * 1000, AutoAwayTimer); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/StatusManager/src/keepstatus.cpp b/plugins/StatusManager/src/keepstatus.cpp index 70d94d14cd..758b2d090a 100644 --- a/plugins/StatusManager/src/keepstatus.cpp +++ b/plugins/StatusManager/src/keepstatus.cpp @@ -193,7 +193,7 @@ static int SetCurrentStatus() // force offline before reconnecting? if (realStatus != ID_STATUS_OFFLINE && KSPlugin.getByte(SETTING_FIRSTOFFLINE, FALSE)) { - log_info(0, "KeepStatus: Setting %S offline before making a new connection attempt", p->m_szName); + log_info(0, "KeepStatus: Setting %s offline before making a new connection attempt", p->m_szName); CallProtoService(p->m_szName, PS_SETSTATUS, (WPARAM)ID_STATUS_OFFLINE, 0); } } diff --git a/plugins/StatusManager/src/ks_options.cpp b/plugins/StatusManager/src/ks_options.cpp index 730ebbbd52..767cb9f680 100644 --- a/plugins/StatusManager/src/ks_options.cpp +++ b/plugins/StatusManager/src/ks_options.cpp @@ -27,32 +27,29 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - { - LVCOLUMN lvCol; - LVITEM lvItem; - DBVARIANT 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) ? 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); - } + SetDlgItemInt(hwndDlg, IDC_MAXRETRIES, KSPlugin.getByte(SETTING_MAXRETRIES, DEFAULT_MAXRETRIES), FALSE); + SetDlgItemInt(hwndDlg, IDC_INITDELAY, KSPlugin.getDword(SETTING_INITDELAY, DEFAULT_INITDELAY), FALSE); + SetDlgItemTextA(hwndDlg, IDC_PINGHOST, KSPlugin.getMStringA(SETTING_PINGHOST)); + CheckDlgButton(hwndDlg, IDC_CHECKCONNECTION, KSPlugin.getByte(SETTING_CHECKCONNECTION, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOWCONNECTIONPOPUPS, KSPlugin.getByte(SETTING_SHOWCONNECTIONPOPUPS, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHKINET, KSPlugin.getByte(SETTING_CHKINET, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CONTCHECK, KSPlugin.getByte(SETTING_CONTCHECK, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_BYPING, KSPlugin.getByte(SETTING_BYPING, FALSE) ? BST_CHECKED : BST_UNCHECKED); + { // proto list HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST); ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + + LVCOLUMN lvCol; memset(&lvCol, 0, sizeof(lvCol)); lvCol.mask = LVCF_WIDTH | LVCF_TEXT; lvCol.pszText = TranslateT("Protocol"); lvCol.cx = 118; ListView_InsertColumn(hList, 0, &lvCol); + // fill the list + LVITEM lvItem; memset(&lvItem, 0, sizeof(lvItem)); lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iItem = 0; @@ -68,7 +65,7 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam char dbSetting[128]; mir_snprintf(dbSetting, "%s_enabled", pa->szModuleName); - ListView_SetCheckState(hList, lvItem.iItem, db_get_b(0, KSMODULENAME, dbSetting, TRUE)); + ListView_SetCheckState(hList, lvItem.iItem, KSPlugin.getByte(dbSetting, TRUE)); lvItem.iItem++; } EnableWindow(GetDlgItem(hwndDlg, IDC_MAXRETRIES), IsDlgButtonChecked(hwndDlg, IDC_CHECKCONNECTION)); @@ -120,19 +117,19 @@ static INT_PTR CALLBACK DlgProcKSBasicOpts(HWND hwndDlg, UINT msg, WPARAM wParam break; case PSN_APPLY: - db_set_b(0, KSMODULENAME, SETTING_MAXRETRIES, (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXRETRIES, nullptr, FALSE)); - db_set_b(0, KSMODULENAME, SETTING_CHECKCONNECTION, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKCONNECTION)); - 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)); + KSPlugin.setByte(SETTING_MAXRETRIES, (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXRETRIES, nullptr, FALSE)); + KSPlugin.setByte(SETTING_CHECKCONNECTION, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKCONNECTION)); + KSPlugin.setByte(SETTING_SHOWCONNECTIONPOPUPS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWCONNECTIONPOPUPS)); + KSPlugin.setDword(SETTING_INITDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_INITDELAY, nullptr, FALSE)); + KSPlugin.setByte(SETTING_CHKINET, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHKINET)); + KSPlugin.setByte(SETTING_CONTCHECK, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONTCHECK)); + KSPlugin.setByte(SETTING_BYPING, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BYPING)); if (IsDlgButtonChecked(hwndDlg, IDC_BYPING)) { int len = SendDlgItemMessage(hwndDlg, IDC_PINGHOST, WM_GETTEXTLENGTH, 0, 0); if (len > 0) { ptrA host((char*)mir_alloc(len + 1)); GetDlgItemTextA(hwndDlg, IDC_PINGHOST, host, len + 1); - db_set_s(0, KSMODULENAME, SETTING_PINGHOST, host); + KSPlugin.setString(SETTING_PINGHOST, host); } } @@ -146,7 +143,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(0, KSMODULENAME, dbSetting, (BYTE)ListView_GetCheckState(hList, lvItem.iItem)); + KSPlugin.setByte(dbSetting, (BYTE)ListView_GetCheckState(hList, lvItem.iItem)); } } break; @@ -163,19 +160,19 @@ 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(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)) { + SetDlgItemInt(hwndDlg, IDC_MAXDELAY, KSPlugin.getDword(SETTING_MAXDELAY, DEFAULT_MAXDELAY), FALSE); + SetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, KSPlugin.getDword(SETTING_MAXCONNECTINGTIME, 0), FALSE); + CheckDlgButton(hwndDlg, IDC_INCREASEEXPONENTIAL, KSPlugin.getByte(SETTING_INCREASEEXPONENTIAL, FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CNCOTHERLOC, (KSPlugin.getByte(SETTING_CNCOTHERLOC, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOGINERR, KSPlugin.getByte(SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_NOTHING ? BST_UNCHECKED : BST_CHECKED); + CheckDlgButton(hwndDlg, IDC_CHECKAPMRESUME, (KSPlugin.getByte(SETTING_CHECKAPMRESUME, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_FIRSTOFFLINE, (KSPlugin.getByte(SETTING_FIRSTOFFLINE, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NOLOCKED, (KSPlugin.getByte(SETTING_NOLOCKED, FALSE)) ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, KSPlugin.getDword(SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY), FALSE); + SetDlgItemInt(hwndDlg, IDC_PINGCOUNT, KSPlugin.getWord(SETTING_PINGCOUNT, DEFAULT_PINGCOUNT), FALSE); + SetDlgItemInt(hwndDlg, IDC_CNTDELAY, KSPlugin.getDword(SETTING_CNTDELAY, CHECKCONTIN_DELAY), FALSE); + + switch (KSPlugin.getByte(SETTING_LOGINERR, LOGINERR_CANCEL)) { case LOGINERR_SETDELAY: CheckRadioButton(hwndDlg, IDC_LOGINERR_CANCEL, IDC_LOGINERR_SETDELAY, IDC_LOGINERR_SETDELAY); break; @@ -217,25 +214,25 @@ static INT_PTR CALLBACK DlgProcKSAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, break; case PSN_APPLY: - 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)); + KSPlugin.setByte(SETTING_INCREASEEXPONENTIAL, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_INCREASEEXPONENTIAL)); + KSPlugin.setDword(SETTING_MAXDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXDELAY, nullptr, FALSE)); + KSPlugin.setDword(SETTING_MAXCONNECTINGTIME, (DWORD)GetDlgItemInt(hwndDlg, IDC_MAXCONNECTINGTIME, nullptr, FALSE)); + KSPlugin.setByte(SETTING_FIRSTOFFLINE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FIRSTOFFLINE)); + KSPlugin.setByte(SETTING_NOLOCKED, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOLOCKED)); + KSPlugin.setByte(SETTING_CNCOTHERLOC, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CNCOTHERLOC)); + KSPlugin.setByte(SETTING_LOGINERR, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_LOGINERR)); if (IsDlgButtonChecked(hwndDlg, IDC_LOGINERR)) { if (IsDlgButtonChecked(hwndDlg, IDC_LOGINERR_SETDELAY)) { - db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_SETDELAY); - db_set_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, GetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, nullptr, FALSE)); + KSPlugin.setByte(SETTING_LOGINERR, LOGINERR_SETDELAY); + KSPlugin.setDword(SETTING_LOGINERR_DELAY, GetDlgItemInt(hwndDlg, IDC_LOGINERR_DELAY, nullptr, FALSE)); } - else db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_CANCEL); + else KSPlugin.setByte(SETTING_LOGINERR, LOGINERR_CANCEL); } - else db_set_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING); + else KSPlugin.setByte(SETTING_LOGINERR, LOGINERR_NOTHING); - 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)); + KSPlugin.setByte(SETTING_CHECKAPMRESUME, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHECKAPMRESUME)); + KSPlugin.setWord(SETTING_PINGCOUNT, (WORD)GetDlgItemInt(hwndDlg, IDC_PINGCOUNT, nullptr, FALSE)); + KSPlugin.setDword(SETTING_CNTDELAY, (DWORD)GetDlgItemInt(hwndDlg, IDC_CNTDELAY, nullptr, FALSE) == 0 ? CHECKCONTIN_DELAY : GetDlgItemInt(hwndDlg, IDC_CNTDELAY, nullptr, FALSE)); } break; } @@ -257,7 +254,7 @@ static INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L bFreeze = true; // left action - switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL)) { + switch (KSPlugin.getByte(SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL)) { case POPUP_ACT_CLOSEPOPUP: CheckDlgButton(hwndDlg, IDC_LCLOSE, BST_CHECKED); break; @@ -273,7 +270,7 @@ static INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L } // right action - switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL)) { + switch (KSPlugin.getByte(SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL)) { case POPUP_ACT_CLOSEPOPUP: CheckDlgButton(hwndDlg, IDC_RCLOSE, BST_CHECKED); break; @@ -289,7 +286,7 @@ static INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L } // delay - switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { + switch (KSPlugin.getByte(SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { case POPUP_DELAYCUSTOM: CheckDlgButton(hwndDlg, IDC_DELAYCUSTOM, BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY), TRUE); @@ -307,25 +304,25 @@ static INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break; } // delay - SetDlgItemInt(hwndDlg, IDC_DELAY, db_get_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0), FALSE); + SetDlgItemInt(hwndDlg, IDC_DELAY, KSPlugin.getDword(SETTING_POPUP_TIMEOUT, 0), FALSE); // back color - SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, db_get_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA)); + SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, KSPlugin.getDword(SETTING_POPUP_BACKCOLOR, 0xAAAAAA)); // text - SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, db_get_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC)); + SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, KSPlugin.getDword(SETTING_POPUP_TEXTCOLOR, 0x0000CC)); // wincolors - CheckDlgButton(hwndDlg, IDC_WINCOLORS, db_get_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_WINCOLORS, KSPlugin.getByte(SETTING_POPUP_USEWINCOLORS, 0) ? BST_CHECKED : BST_UNCHECKED); // defaultcolors - CheckDlgButton(hwndDlg, IDC_DEFAULTCOLORS, ((db_get_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) && (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS))) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DEFAULTCOLORS, ((KSPlugin.getByte(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(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); + CheckDlgButton(hwndDlg, IDC_PUCONNLOST, KSPlugin.getByte(SETTING_PUCONNLOST, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUOTHER, KSPlugin.getByte(SETTING_PUOTHER, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUCONNRETRY, KSPlugin.getByte(SETTING_PUCONNRETRY, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PURESULT, KSPlugin.getByte(SETTING_PURESULT, TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PUSHOWEXTRA, KSPlugin.getByte(SETTING_PUSHOWEXTRA, TRUE) ? BST_CHECKED : BST_UNCHECKED); bFreeze = false; break; @@ -408,41 +405,41 @@ static INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L if (((LPNMHDR)lParam)->code == PSN_APPLY) { // left action if (IsDlgButtonChecked(hwndDlg, IDC_LNOTHING)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_NOTHING); + KSPlugin.setByte(SETTING_POPUP_LEFTCLICK, POPUP_ACT_NOTHING); else if (IsDlgButtonChecked(hwndDlg, IDC_LCLOSE)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CLOSEPOPUP); + KSPlugin.setByte(SETTING_POPUP_LEFTCLICK, POPUP_ACT_CLOSEPOPUP); else if (IsDlgButtonChecked(hwndDlg, IDC_LCANCEL)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL); + KSPlugin.setByte(SETTING_POPUP_LEFTCLICK, POPUP_ACT_CANCEL); // right action if (IsDlgButtonChecked(hwndDlg, IDC_RNOTHING)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_NOTHING); + KSPlugin.setByte(SETTING_POPUP_RIGHTCLICK, POPUP_ACT_NOTHING); else if (IsDlgButtonChecked(hwndDlg, IDC_RCLOSE)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CLOSEPOPUP); + KSPlugin.setByte(SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CLOSEPOPUP); else if (IsDlgButtonChecked(hwndDlg, IDC_RCANCEL)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL); + KSPlugin.setByte(SETTING_POPUP_RIGHTCLICK, POPUP_ACT_CANCEL); // delay if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU); + KSPlugin.setByte(SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU); else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYCUSTOM)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYCUSTOM); + KSPlugin.setByte(SETTING_POPUP_DELAYTYPE, POPUP_DELAYCUSTOM); else if (IsDlgButtonChecked(hwndDlg, IDC_DELAYPERMANENT)) - db_set_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYPERMANENT); + KSPlugin.setByte(SETTING_POPUP_DELAYTYPE, POPUP_DELAYPERMANENT); // delay - db_set_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE)); + KSPlugin.setDword(SETTING_POPUP_TIMEOUT, GetDlgItemInt(hwndDlg, IDC_DELAY, nullptr, FALSE)); // back color - db_set_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)); + KSPlugin.setDword(SETTING_POPUP_BACKCOLOR, SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0)); // text color - db_set_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); + KSPlugin.setDword(SETTING_POPUP_TEXTCOLOR, SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0)); // use win - db_set_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)); + KSPlugin.setByte(SETTING_POPUP_USEWINCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_WINCOLORS)); // use def - db_set_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)); + KSPlugin.setByte(SETTING_POPUP_USEDEFCOLORS, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFAULTCOLORS)); // store types - 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)); + KSPlugin.setByte(SETTING_PUCONNLOST, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNLOST)); + KSPlugin.setByte(SETTING_PUOTHER, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUOTHER)); + KSPlugin.setByte(SETTING_PUCONNRETRY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUCONNRETRY)); + KSPlugin.setByte(SETTING_PURESULT, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PURESULT)); + KSPlugin.setByte(SETTING_PUSHOWEXTRA, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PUSHOWEXTRA)); } break; } diff --git a/plugins/StatusManager/src/ss_options.cpp b/plugins/StatusManager/src/ss_options.cpp index 5c3a3b0d3f..2c5cdccd48 100644 --- a/plugins/StatusManager/src/ss_options.cpp +++ b/plugins/StatusManager/src/ss_options.cpp @@ -70,7 +70,7 @@ static char* GetCMDLArguments(TProtoSettings &protoSettings) } } - if (db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, FALSE) == TRUE) { + if (SSPlugin.getByte(SETTING_SHOWDIALOG, FALSE) == TRUE) { *pnt++ = ' '; *pnt++ = '\0'; cmdl = (char*)mir_realloc(cmdl, mir_strlen(cmdl) + 12); @@ -268,7 +268,7 @@ class CSSMainOptDlg : public CSSOptionsBaseDlg chkSetDocked.SetState(false); onChange_Docked(0); - int val = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + int val = SSPlugin.getByte(SETTING_WINSTATE, SETTING_STATE_NORMAL); SendDlgItemMessage(m_hwnd, IDC_WINSTATE, CB_RESETCONTENT, 0, 0); int item = SendDlgItemMessage(m_hwnd, IDC_WINSTATE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Hidden")); @@ -323,24 +323,24 @@ public: bool OnInitDialog() override { - CheckDlgButton(m_hwnd, IDC_SETPROFILE, db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_OVERRIDE, db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_SHOWDIALOG, db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_SETWINSTATE, db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_SETWINLOCATION, db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_SETDOCKED, db_get_b(0, SSMODULENAME, SETTING_SETDOCKED, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_SETWINSIZE, db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_OFFLINECLOSE, db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_AUTODIAL, db_get_b(0, SSMODULENAME, SETTING_AUTODIAL, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_AUTOHANGUP, db_get_b(0, SSMODULENAME, SETTING_AUTOHANGUP, 0) ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(m_hwnd, IDC_SETPROFILEDELAY, db_get_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), FALSE); - SetDlgItemInt(m_hwnd, IDC_DLGTIMEOUT, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5), FALSE); - SetDlgItemInt(m_hwnd, IDC_XPOS, db_get_dw(0, SSMODULENAME, SETTING_XPOS, 0), TRUE); - SetDlgItemInt(m_hwnd, IDC_YPOS, db_get_dw(0, SSMODULENAME, SETTING_YPOS, 0), TRUE); - SetDlgItemInt(m_hwnd, IDC_WIDTH, db_get_dw(0, SSMODULENAME, SETTING_WIDTH, 0), FALSE); - SetDlgItemInt(m_hwnd, IDC_HEIGHT, db_get_dw(0, SSMODULENAME, SETTING_HEIGHT, 0), FALSE); - - int val = db_get_b(0, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + CheckDlgButton(m_hwnd, IDC_SETPROFILE, SSPlugin.getByte(SETTING_SETPROFILE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_OVERRIDE, SSPlugin.getByte(SETTING_OVERRIDE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_SHOWDIALOG, SSPlugin.getByte(SETTING_SHOWDIALOG, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_SETWINSTATE, SSPlugin.getByte(SETTING_SETWINSTATE, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_SETWINLOCATION, SSPlugin.getByte(SETTING_SETWINLOCATION, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_SETDOCKED, SSPlugin.getByte(SETTING_SETDOCKED, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_SETWINSIZE, SSPlugin.getByte(SETTING_SETWINSIZE, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_OFFLINECLOSE, SSPlugin.getByte(SETTING_OFFLINECLOSE, 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_AUTODIAL, SSPlugin.getByte(SETTING_AUTODIAL, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_AUTOHANGUP, SSPlugin.getByte(SETTING_AUTOHANGUP, 0) ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(m_hwnd, IDC_SETPROFILEDELAY, SSPlugin.getWord(SETTING_SETPROFILEDELAY, 500), FALSE); + SetDlgItemInt(m_hwnd, IDC_DLGTIMEOUT, SSPlugin.getWord(SETTING_DLGTIMEOUT, 5), FALSE); + SetDlgItemInt(m_hwnd, IDC_XPOS, SSPlugin.getWord(SETTING_XPOS, 0), TRUE); + SetDlgItemInt(m_hwnd, IDC_YPOS, SSPlugin.getWord(SETTING_YPOS, 0), TRUE); + SetDlgItemInt(m_hwnd, IDC_WIDTH, SSPlugin.getWord(SETTING_WIDTH, 0), FALSE); + SetDlgItemInt(m_hwnd, IDC_HEIGHT, SSPlugin.getWord(SETTING_HEIGHT, 0), FALSE); + + int val = SSPlugin.getByte(SETTING_DOCKED, DOCKED_NONE); int item = SendDlgItemMessage(m_hwnd, IDC_DOCKED, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left")); SendDlgItemMessage(m_hwnd, IDC_DOCKED, CB_SETITEMDATA, (WPARAM)item, (LPARAM)DOCKED_LEFT); if (val == DOCKED_LEFT) @@ -369,45 +369,45 @@ public: bool OnApply() override { bool bChecked = chkSetProfile.GetState(); - db_set_b(0, SSMODULENAME, SETTING_SETPROFILE, bChecked); + SSPlugin.setByte(SETTING_SETPROFILE, bChecked); if (bChecked) - db_set_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, GetDlgItemInt(m_hwnd, IDC_SETPROFILEDELAY, nullptr, FALSE)); + SSPlugin.setDword(SETTING_SETPROFILEDELAY, GetDlgItemInt(m_hwnd, IDC_SETPROFILEDELAY, nullptr, FALSE)); if (bChecked || chkShowDialog.GetState()) - db_set_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, (WORD)profiles.GetItemData(profiles.GetCurSel())); + SSPlugin.setWord(SETTING_DEFAULTPROFILE, (WORD)profiles.GetItemData(profiles.GetCurSel())); - db_set_b(0, SSMODULENAME, SETTING_OVERRIDE, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_OVERRIDE)); - db_set_b(0, SSMODULENAME, SETTING_SHOWDIALOG, bChecked = chkShowDialog.GetState()); + SSPlugin.setByte(SETTING_OVERRIDE, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_OVERRIDE)); + SSPlugin.setByte(SETTING_SHOWDIALOG, bChecked = chkShowDialog.GetState()); if (bChecked) - db_set_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, GetDlgItemInt(m_hwnd, IDC_DLGTIMEOUT, nullptr, FALSE)); + SSPlugin.setDword(SETTING_DLGTIMEOUT, GetDlgItemInt(m_hwnd, IDC_DLGTIMEOUT, nullptr, FALSE)); - db_set_b(0, SSMODULENAME, SETTING_SETWINSTATE, bChecked = chkSetWinState.GetState()); + SSPlugin.setByte(SETTING_SETWINSTATE, bChecked = chkSetWinState.GetState()); if (bChecked) { int val = (int)SendDlgItemMessage(m_hwnd, IDC_WINSTATE, CB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_WINSTATE, CB_GETCURSEL, 0, 0), 0); - db_set_b(0, SSMODULENAME, SETTING_WINSTATE, (BYTE)val); + SSPlugin.setByte(SETTING_WINSTATE, (BYTE)val); } - db_set_b(0, SSMODULENAME, SETTING_SETDOCKED, bChecked = chkSetDocked.GetState()); + SSPlugin.setByte(SETTING_SETDOCKED, bChecked = chkSetDocked.GetState()); if (bChecked) { int val = (int)SendDlgItemMessage(m_hwnd, IDC_DOCKED, CB_GETITEMDATA, SendDlgItemMessage(m_hwnd, IDC_DOCKED, CB_GETCURSEL, 0, 0), 0); - db_set_b(0, SSMODULENAME, SETTING_DOCKED, (BYTE)val); + SSPlugin.setByte(SETTING_DOCKED, (BYTE)val); } - db_set_b(0, SSMODULENAME, SETTING_SETWINLOCATION, bChecked = chkSetWinLocation.GetState()); + SSPlugin.setByte(SETTING_SETWINLOCATION, bChecked = chkSetWinLocation.GetState()); if (bChecked) { - db_set_dw(0, SSMODULENAME, SETTING_XPOS, GetDlgItemInt(m_hwnd, IDC_XPOS, nullptr, TRUE)); - db_set_dw(0, SSMODULENAME, SETTING_YPOS, GetDlgItemInt(m_hwnd, IDC_YPOS, nullptr, TRUE)); + SSPlugin.setDword(SETTING_XPOS, GetDlgItemInt(m_hwnd, IDC_XPOS, nullptr, TRUE)); + SSPlugin.setDword(SETTING_YPOS, GetDlgItemInt(m_hwnd, IDC_YPOS, nullptr, TRUE)); } - db_set_b(0, SSMODULENAME, SETTING_SETWINSIZE, bChecked = chkSetWinSize.GetState()); + SSPlugin.setByte(SETTING_SETWINSIZE, bChecked = chkSetWinSize.GetState()); if (bChecked) { - db_set_dw(0, SSMODULENAME, SETTING_WIDTH, GetDlgItemInt(m_hwnd, IDC_WIDTH, nullptr, FALSE)); - db_set_dw(0, SSMODULENAME, SETTING_HEIGHT, GetDlgItemInt(m_hwnd, IDC_HEIGHT, nullptr, FALSE)); + SSPlugin.setDword(SETTING_WIDTH, GetDlgItemInt(m_hwnd, IDC_WIDTH, nullptr, FALSE)); + SSPlugin.setDword(SETTING_HEIGHT, GetDlgItemInt(m_hwnd, IDC_HEIGHT, nullptr, FALSE)); } - db_set_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_OFFLINECLOSE)); - db_set_b(0, SSMODULENAME, SETTING_AUTODIAL, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTODIAL)); - db_set_b(0, SSMODULENAME, SETTING_AUTOHANGUP, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTOHANGUP)); + SSPlugin.setByte(SETTING_OFFLINECLOSE, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_OFFLINECLOSE)); + SSPlugin.setByte(SETTING_AUTODIAL, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTODIAL)); + SSPlugin.setByte(SETTING_AUTOHANGUP, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTOHANGUP)); return true; } @@ -689,19 +689,19 @@ public: ppo->tszName = mir_wstrdup(TranslateT("unknown")); } else { - ppo->tszName = db_get_wsa(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME)); + ppo->tszName = SSPlugin.getWStringA(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(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)); + ppo->createTtb = SSPlugin.getByte(OptName(i, SETTING_CREATETTBBUTTON), 0); + ppo->showDialog = SSPlugin.getByte(OptName(i, SETTING_SHOWCONFIRMDIALOG), 0); + ppo->createMmi = SSPlugin.getByte(OptName(i, SETTING_CREATEMMITEM), 0); + ppo->inSubMenu = SSPlugin.getByte(OptName(i, SETTING_INSUBMENU), 1); + ppo->regHotkey = SSPlugin.getByte(OptName(i, SETTING_REGHOTKEY), 0); + ppo->hotKey = SSPlugin.getWord(OptName(i, SETTING_HOTKEY), MAKEWORD((char)('0' + i), HOTKEYF_CONTROL | HOTKEYF_SHIFT)); } arProfiles.insert(ppo); } @@ -715,7 +715,7 @@ public: bool OnApply() override { - int oldCount = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int oldCount = SSPlugin.getWord(SETTING_PROFILECOUNT, 0); for (int i = 0; i < oldCount; i++) { LIST<char> arSettings(10); db_enum_settings(0, DeleteSetting, SSMODULENAME, &arSettings); @@ -724,31 +724,31 @@ public: int len = mir_snprintf(setting, "%d_", i); for (auto &it : arSettings) { if (!strncmp(setting, it, len)) - db_unset(0, SSMODULENAME, it); + SSPlugin.delSetting(it); mir_free(it); } } for (auto &it : arProfiles) { int i = arProfiles.indexOf(&it); - db_set_b(0, SSMODULENAME, OptName(i, SETTING_SHOWCONFIRMDIALOG), it->showDialog); - db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATETTBBUTTON), it->createTtb); - db_set_b(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), it->createMmi); - db_set_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), it->inSubMenu); - db_set_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), it->regHotkey); - db_set_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), it->hotKey); - db_set_ws(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME), it->tszName); + SSPlugin.setByte(OptName(i, SETTING_SHOWCONFIRMDIALOG), it->showDialog); + SSPlugin.setByte(OptName(i, SETTING_CREATETTBBUTTON), it->createTtb); + SSPlugin.setByte(OptName(i, SETTING_CREATEMMITEM), it->createMmi); + SSPlugin.setByte(OptName(i, SETTING_INSUBMENU), it->inSubMenu); + SSPlugin.setByte(OptName(i, SETTING_REGHOTKEY), it->regHotkey); + SSPlugin.setWord(OptName(i, SETTING_HOTKEY), it->hotKey); + SSPlugin.setWString(OptName(i, SETTING_PROFILENAME), it->tszName); for (auto jt : it->ps) { if (jt->m_szMsg != nullptr) { char setting[128]; mir_snprintf(setting, "%s_%s", jt->m_szName, SETTING_PROFILE_STSMSG); - db_set_ws(0, SSMODULENAME, OptName(i, setting), jt->m_szMsg); + SSPlugin.setWString(OptName(i, setting), jt->m_szMsg); } - db_set_w(0, SSMODULENAME, OptName(i, jt->m_szName), jt->m_status); + SSPlugin.setWord(OptName(i, jt->m_szName), jt->m_status); } } - db_set_w(0, SSMODULENAME, SETTING_PROFILECOUNT, (WORD)arProfiles.getCount()); + SSPlugin.setWord(SETTING_PROFILECOUNT, (WORD)arProfiles.getCount()); // Rebuild status menu if (bNeedRebuildMenu) @@ -780,7 +780,7 @@ public: GetProfileCount((WPARAM)&defProfile, 0); if (sel == defProfile) { MessageBox(nullptr, TranslateT("Your default profile will be changed"), TranslateT("Status manager"), MB_OK); - db_set_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + SSPlugin.setWord(SETTING_DEFAULTPROFILE, 0); } ReinitProfiles();; } diff --git a/plugins/StatusManager/src/ss_profiles.cpp b/plugins/StatusManager/src/ss_profiles.cpp index 74726c1df2..c5f2038ed2 100644 --- a/plugins/StatusManager/src/ss_profiles.cpp +++ b/plugins/StatusManager/src/ss_profiles.cpp @@ -64,10 +64,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(0, SSMODULENAME, OptName(i, SETTING_CREATEMMITEM), 0) || GetProfileName(i, (LPARAM)profilename)) + if (!SSPlugin.getByte(OptName(i, SETTING_CREATEMMITEM), 0) || GetProfileName(i, (LPARAM)profilename)) continue; - if (db_get_b(0, SSMODULENAME, OptName(i, SETTING_INSUBMENU), 1) && !mi.root) { + if (SSPlugin.getByte(OptName(i, SETTING_INSUBMENU), 1) && !mi.root) { mi.root = g_plugin.addRootMenu(MO_STATUS, LPGENW("Status profiles"), 2000100000); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "1AB30D51-BABA-4B27-9288-1A12278BAD8D"); } @@ -92,9 +92,9 @@ INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) { int profile = (int)wParam; if (profile < 0) // get default profile - profile = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = SSPlugin.getWord(SETTING_DEFAULTPROFILE, 0); - int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int count = SSPlugin.getWord(SETTING_PROFILECOUNT, 0); if (profile >= count && count > 0) return -1; @@ -107,7 +107,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(0, SSMODULENAME, setting, &dbv)) + if (SSPlugin.getWString(setting, &dbv)) return -1; wcsncpy(buf, dbv.pwszVal, 128 - 1); buf[127] = 0; @@ -118,9 +118,9 @@ INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam) INT_PTR GetProfileCount(WPARAM wParam, LPARAM) { int *def = (int*)wParam; - int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int count = SSPlugin.getWord(SETTING_PROFILECOUNT, 0); if (def != nullptr) { - *def = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + *def = SSPlugin.getWord(SETTING_DEFAULTPROFILE, 0); if (*def >= count) *def = 0; } @@ -135,7 +135,7 @@ wchar_t* GetStatusMessage(int profile, const char *szProto) for (auto &p : arProfiles) { if (p->profile == profile && !mir_strcmp(p->szProto, szProto)) { - p->msg = db_get_wsa(0, SSMODULENAME, dbSetting); + p->msg = SSPlugin.getWStringA(dbSetting); return p->msg; } } @@ -143,7 +143,7 @@ wchar_t* GetStatusMessage(int profile, const char *szProto) PROFILECE *pce = new PROFILECE; pce->profile = profile; pce->szProto = mir_strdup(szProto); - pce->msg = db_get_wsa(0, SSMODULENAME, dbSetting); + pce->msg = SSPlugin.getWStringA(dbSetting); arProfiles.insert(pce); return pce->msg; @@ -154,14 +154,14 @@ void FillStatus(SMProto &ps, int profile) // load status char setting[80]; mir_snprintf(setting, "%d_%s", profile, ps.m_szName); - int iStatus = db_get_w(0, SSMODULENAME, setting, 0); + int iStatus = SSPlugin.getWord(setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; ps.m_status = iStatus; // load last status mir_snprintf(setting, "%s%s", PREFIX_LAST, ps.m_szName); - iStatus = db_get_w(0, SSMODULENAME, setting, 0); + iStatus = SSPlugin.getWord(setting, 0); if (iStatus < MIN_STATUS || iStatus > MAX_STATUS) iStatus = DEFAULT_STATUS; ps.m_lastStatus = iStatus; @@ -174,9 +174,9 @@ void FillStatus(SMProto &ps, int profile) int GetProfile(int profile, TProtoSettings &arSettings) { if (profile < 0) // get default profile - profile = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = SSPlugin.getWord(SETTING_DEFAULTPROFILE, 0); - int count = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); + int count = SSPlugin.getWord(SETTING_PROFILECOUNT, 0); if (profile >= count && count > 0) return -1; @@ -199,14 +199,14 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM) int profile = (int)iProfileNo; TProtoSettings ps(protoList); if (!GetProfile(profile, ps)) { - profile = (profile >= 0) ? profile : db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); + profile = (profile >= 0) ? profile : SSPlugin.getWord(SETTING_DEFAULTPROFILE, 0); char setting[64]; mir_snprintf(setting, "%d_%s", profile, SETTING_SHOWCONFIRMDIALOG); - if (!db_get_b(0, SSMODULENAME, setting, 0)) + if (!SSPlugin.getByte(setting, 0)) SetStatusEx(ps); else - ShowConfirmDialogEx(&ps, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); + ShowConfirmDialogEx(&ps, SSPlugin.getDword(SETTING_DLGTIMEOUT, 5)); } // add timer here @@ -266,10 +266,10 @@ int RegisterHotKeys() int count = GetProfileCount(0, 0); for (int i = 0; i < count; i++) { - if (!db_get_b(0, SSMODULENAME, OptName(i, SETTING_REGHOTKEY), 0)) + if (!SSPlugin.getByte(OptName(i, SETTING_REGHOTKEY), 0)) continue; - WORD wHotKey = db_get_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), 0); + WORD wHotKey = SSPlugin.getWord(OptName(i, SETTING_HOTKEY), 0); hkInfo = (HKINFO*)mir_realloc(hkInfo, (hkiCount + 1)*sizeof(HKINFO)); if (hkInfo == nullptr) return -1; diff --git a/plugins/StatusManager/src/ss_toolbars.cpp b/plugins/StatusManager/src/ss_toolbars.cpp index 8e0ed7e6cc..b3a7b856cf 100644 --- a/plugins/StatusManager/src/ss_toolbars.cpp +++ b/plugins/StatusManager/src/ss_toolbars.cpp @@ -51,12 +51,12 @@ int CreateTopToolbarButtons(WPARAM, LPARAM) for (int i = 0; i < profileCount; i++) { char setting[80]; mir_snprintf(setting, "%d_%s", i, SETTING_CREATETTBBUTTON); - if (!db_get_b(0, SSMODULENAME, setting, FALSE)) + if (!SSPlugin.getByte(setting, FALSE)) continue; DBVARIANT dbv; mir_snprintf(setting, "%d_%s", i, SETTING_PROFILENAME); - if (db_get_s(0, SSMODULENAME, setting, &dbv)) + if (SSPlugin.getString(setting, &dbv)) continue; ttb.hIconHandleDn = iconList[0].hIcolib; diff --git a/plugins/StatusManager/src/startupstatus.cpp b/plugins/StatusManager/src/startupstatus.cpp index 0a9ad2b585..45075ebf3a 100644 --- a/plugins/StatusManager/src/startupstatus.cpp +++ b/plugins/StatusManager/src/startupstatus.cpp @@ -123,7 +123,7 @@ static void SetLastStatusMessages(TProtoSettings &ps) char dbSetting[128]; mir_snprintf(dbSetting, "%s%s", PREFIX_LASTMSG, it->m_szName); - it->m_szMsg = db_get_wsa(0, SSMODULENAME, dbSetting); + it->m_szMsg = SSPlugin.getWStringA(dbSetting); } } @@ -138,7 +138,7 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) if (ack->type != ACKTYPE_STATUS && ack->result != ACKRESULT_FAILED) return 0; - if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0) + if (!SSPlugin.getByte(SETTING_OVERRIDE, 1) || protoList.getCount() == 0) return 0; for (auto &it : protoList) { @@ -154,7 +154,7 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam) static int StatusChange(WPARAM, LPARAM lParam) { // change by menu - if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0) + if (!SSPlugin.getByte(SETTING_OVERRIDE, 1) || protoList.getCount() == 0) return 0; char *szProto = (char *)lParam; @@ -179,7 +179,7 @@ static int StatusChange(WPARAM, LPARAM lParam) static int CSStatusChangeEx(WPARAM wParam, LPARAM) { // another status plugin made the change - if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0) + if (!SSPlugin.getByte(SETTING_OVERRIDE, 1) || protoList.getCount() == 0) return 0; if (wParam != 0) { @@ -230,9 +230,9 @@ static int OnOkToExit(WPARAM, LPARAM) char lastName[128], lastMsg[128]; mir_snprintf(lastName, "%s%s", PREFIX_LAST, pa->szModuleName); - db_set_w(0, SSMODULENAME, lastName, pa->iRealStatus); + SSPlugin.setWord(lastName, pa->iRealStatus); mir_snprintf(lastMsg, "%s%s", PREFIX_LASTMSG, pa->szModuleName); - db_unset(0, SSMODULENAME, lastMsg); + SSPlugin.delSetting(lastMsg); if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND & ~PF1_INDIVMODEMSG)) continue; @@ -251,13 +251,13 @@ static int OnOkToExit(WPARAM, LPARAM) CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1); } if (npi.szMsg != nullptr) { - db_set_ws(0, SSMODULENAME, lastMsg, npi.tszMsg); + SSPlugin.setWString(lastMsg, npi.tszMsg); mir_free(npi.tszMsg); } } } - if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + if (SSPlugin.getByte(SETTING_SETPROFILE, 1) || SSPlugin.getByte(SETTING_OFFLINECLOSE, 0)) Clist_SetStatusMode(ID_STATUS_OFFLINE); return 0; @@ -266,8 +266,8 @@ static int OnOkToExit(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM) { // set windowstate and docked for next startup - if (db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0)) { - int state = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + if (SSPlugin.getByte(SETTING_SETWINSTATE, 0)) { + int state = SSPlugin.getByte(SETTING_WINSTATE, SETTING_STATE_NORMAL); HWND hClist = g_clistApi.hwndContactList; BOOL isHidden = !IsWindowVisible(hClist); switch (state) { @@ -291,12 +291,12 @@ static int OnShutdown(WPARAM, LPARAM) } // hangup - if (db_get_b(0, SSMODULENAME, SETTING_AUTOHANGUP, 0)) + if (SSPlugin.getByte(SETTING_AUTOHANGUP, 0)) InternetAutodialHangup(0); - int state = db_get_b(0, SSMODULENAME, SETTING_WINSTATE, SETTING_STATE_NORMAL); + int state = SSPlugin.getByte(SETTING_WINSTATE, SETTING_STATE_NORMAL); // set windowstate and docked for next startup - if (db_get_b(0, SSMODULENAME, SETTING_SETWINSTATE, 0)) + if (SSPlugin.getByte(SETTING_SETWINSTATE, 0)) db_set_b(0, MODULE_CLIST, SETTING_WINSTATE, (BYTE)state); if (hMessageWindow) @@ -344,39 +344,39 @@ int SSModuleLoaded(WPARAM, LPARAM) return 0;// no protocols are loaded SetLastStatusMessages(protoList); - showDialogOnStartup = (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0)); + showDialogOnStartup = (showDialogOnStartup || SSPlugin.getByte(SETTING_SHOWDIALOG, 0)); // dial - if (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1)) - if (db_get_b(0, SSMODULENAME, SETTING_AUTODIAL, 0)) + if (showDialogOnStartup || SSPlugin.getByte(SETTING_SETPROFILE, 1)) + if (SSPlugin.getByte(SETTING_AUTODIAL, 0)) InternetAutodial(0, nullptr); // set the status! - if (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0)) - ShowConfirmDialogEx((TProtoSettings*)&protoList, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5)); - else if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1)) { + if (showDialogOnStartup || SSPlugin.getByte(SETTING_SHOWDIALOG, 0)) + ShowConfirmDialogEx((TProtoSettings*)&protoList, SSPlugin.getDword(SETTING_DLGTIMEOUT, 5)); + else if (SSPlugin.getByte(SETTING_SETPROFILE, 1)) { // set hooks for override - if (db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1)) { + if (SSPlugin.getByte(SETTING_OVERRIDE, 1)) { hProtoAckHook = HookEvent(ME_PROTO_ACK, ProcessProtoAck); hCSStatusChangeHook = HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChangeEx); hStatusChangeHook = HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChange); } - setStatusTimerId = SetTimer(nullptr, 0, db_get_dw(0, SSMODULENAME, SETTING_SETPROFILEDELAY, 500), SetStatusTimed); + setStatusTimerId = SetTimer(nullptr, 0, SSPlugin.getDword(SETTING_SETPROFILEDELAY, 500), SetStatusTimed); } // win size and location - if (db_get_b(0, SSMODULENAME, SETTING_SETWINLOCATION, 0) || db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0)) { + if (SSPlugin.getByte(SETTING_SETWINLOCATION, 0) || SSPlugin.getByte(SETTING_SETWINSIZE, 0)) { HWND hClist = g_clistApi.hwndContactList; // store in db - 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 (SSPlugin.getByte(SETTING_SETWINLOCATION, 0)) { + db_set_dw(0, MODULE_CLIST, SETTING_XPOS, SSPlugin.getDword(SETTING_XPOS, 0)); + db_set_dw(0, MODULE_CLIST, SETTING_YPOS, SSPlugin.getDword(SETTING_YPOS, 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 (SSPlugin.getByte(SETTING_SETWINSIZE, 0)) { + db_set_dw(0, MODULE_CLIST, SETTING_WIDTH, SSPlugin.getDword(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)); + db_set_dw(0, MODULE_CLIST, SETTING_HEIGHT, SSPlugin.getDword(SETTING_HEIGHT, 0)); } WINDOWPLACEMENT wndpl = { sizeof(wndpl) }; @@ -388,14 +388,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(0, SSMODULENAME, SETTING_SETWINLOCATION, 0)) { - x = db_get_dw(0, SSMODULENAME, SETTING_XPOS, x); - y = db_get_dw(0, SSMODULENAME, SETTING_YPOS, y); + if (SSPlugin.getByte(SETTING_SETWINLOCATION, 0)) { + x = SSPlugin.getDword(SETTING_XPOS, x); + y = SSPlugin.getDword(SETTING_YPOS, y); } - if (db_get_b(0, SSMODULENAME, SETTING_SETWINSIZE, 0)) { - width = db_get_dw(0, SSMODULENAME, SETTING_WIDTH, width); + if (SSPlugin.getByte(SETTING_SETWINSIZE, 0)) { + width = SSPlugin.getDword(SETTING_WIDTH, width); if (!db_get_b(0, MODULE_CLUI, SETTING_AUTOSIZE, 0)) - height = db_get_dw(0, SSMODULENAME, SETTING_HEIGHT, height); + height = SSPlugin.getDword(SETTING_HEIGHT, height); } MoveWindow(hClist, x, y, width, height, TRUE); } @@ -418,12 +418,12 @@ void StartupStatusLoad() else HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); - if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + if (SSPlugin.getByte(SETTING_SETPROFILE, 1) || SSPlugin.getByte(SETTING_OFFLINECLOSE, 0)) db_set_w(0, "CList", "Status", (WORD)ID_STATUS_OFFLINE); // docking - if (db_get_b(0, SSMODULENAME, SETTING_SETDOCKED, 0)) { - int docked = db_get_b(0, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + if (SSPlugin.getByte(SETTING_SETDOCKED, 0)) { + int docked = SSPlugin.getByte(SETTING_DOCKED, DOCKED_NONE); if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) docked = -docked; diff --git a/plugins/StatusManager/src/version.h b/plugins/StatusManager/src/version.h index 7cebacf7fa..607aa6455a 100644 --- a/plugins/StatusManager/src/version.h +++ b/plugins/StatusManager/src/version.h @@ -2,7 +2,7 @@ #define __MAJOR_VERSION 1 #define __MINOR_VERSION 2 #define __RELEASE_NUM 0 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 // other stuff for Version resource #include <stdver.h> |