diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-12 21:44:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-12 21:44:56 +0300 |
commit | 53fe3e46177d17b4941610de19f5cc6210700cb4 (patch) | |
tree | b67a6bc208dad141f9db14035cd7e42ff2a51872 /plugins/Sessions | |
parent | 488214ac8af0c4aeb1a5c1d8fd48368daaf4c4c7 (diff) |
db_* functions replaced with g_plugin calls
Diffstat (limited to 'plugins/Sessions')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 72 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 42 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 22 |
3 files changed, 68 insertions, 68 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index defae68111..4498daeb9b 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -95,13 +95,13 @@ INT_PTR CALLBACK ExitDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) SavePosition(hdlg, "ExitDlg");
SaveSessionDate();
SaveSessionHandles(0, 0);
- db_set_b(NULL, MODULENAME, "lastempty", 0);
+ g_plugin.setByte("lastempty", 0);
DestroyWindow(hdlg);
break;
case IDCANCEL:
SavePosition(hdlg, "ExitDlg");
- db_set_b(NULL, MODULENAME, "lastempty", 1);
+ g_plugin.setByte("lastempty", 1);
DestroyWindow(hdlg);
break;
}
@@ -261,7 +261,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM) case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
{
- int iDelay = db_get_w(NULL, MODULENAME, "StartupModeDelay", 1500);
+ int iDelay = g_plugin.getWord("StartupModeDelay", 1500);
if (g_hghostw == TRUE)
SetTimer(hdlg, TIMERID_LOAD, iDelay, nullptr);
else {
@@ -426,7 +426,7 @@ int SaveSessionHandles(WPARAM, LPARAM lparam) }
if (lparam == 1) {
g_ses_count++;
- db_set_b(0, MODULENAME, "UserSessionsCount", (BYTE)g_ses_count);
+ g_plugin.setByte("UserSessionsCount", (BYTE)g_ses_count);
}
return 0;
}
@@ -450,8 +450,8 @@ INT_PTR OpenSessionsManagerWindow(WPARAM, LPARAM) }
ptrW
- tszSession(db_get_wsa(NULL, MODULENAME, "SessionDate_0")),
- tszUserSession(db_get_wsa(NULL, MODULENAME, "UserSessionDsc_0"));
+ tszSession(g_plugin.getWStringA("SessionDate_0")),
+ tszUserSession(g_plugin.getWStringA("UserSessionDsc_0"));
if (g_bIncompletedSave || tszSession || tszUserSession) {
g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
return 0;
@@ -479,9 +479,9 @@ int SaveSessionDate() char szSetting[256];
mir_snprintf(szSetting, "%s_%d", "SessionDate", 0);
- wchar_t *ptszSaveSessionDate = db_get_wsa(NULL, MODULENAME, szSetting);
+ wchar_t *ptszSaveSessionDate = g_plugin.getWStringA(szSetting);
- db_set_ws(NULL, MODULENAME, szSetting, szSessionTime);
+ g_plugin.setWString(szSetting, szSessionTime);
mir_free(szSessionTime);
if (ptszSaveSessionDate)
@@ -493,7 +493,7 @@ int SaveSessionDate() mir_free(szDateBuf);
}
if (g_bCrashRecovery)
- db_set_b(NULL, MODULENAME, "lastSaveCompleted", 1);
+ g_plugin.setByte("lastSaveCompleted", 1);
return 0;
}
@@ -504,11 +504,11 @@ int SaveUserSessionName(wchar_t *szUSessionName) char szSetting[256];
mir_snprintf(szSetting, "%s_%u", "UserSessionDsc", 0);
- wchar_t *ptszUserSessionName = db_get_wsa(NULL, MODULENAME, szSetting);
+ wchar_t *ptszUserSessionName = g_plugin.getWStringA(szSetting);
if (ptszUserSessionName)
ResaveSettings("UserSessionDsc", 1, 255, ptszUserSessionName);
- db_set_ws(NULL, MODULENAME, szSetting, szUSessionName);
+ g_plugin.setWString(szSetting, szUSessionName);
return 0;
}
@@ -590,30 +590,30 @@ int DelUserDefSession(int ses_count) char szSessionName[256];
mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", ses_count);
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
mir_snprintf(szSessionName, "%s_%u", "FavUserSession", ses_count);
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
for (int i = ses_count + 1;; i++) {
mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", i);
- ptrW szSessionNameBuf(db_get_wsa(NULL, MODULENAME, szSessionName));
+ ptrW szSessionNameBuf(g_plugin.getWStringA(szSessionName));
mir_snprintf(szSessionName, "%s_%u", "UserSessionDsc", i - 1);
if (szSessionNameBuf) {
MarkUserDefSession(i - 1, IsMarkedUserDefSession(i));
- db_set_ws(NULL, MODULENAME, szSessionName, szSessionNameBuf);
+ g_plugin.setWString(szSessionName, szSessionNameBuf);
}
else {
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
mir_snprintf(szSessionName, "%s_%u", "FavUserSession", i - 1);
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
break;
}
}
g_ses_count--;
- db_set_b(0, MODULENAME, "UserSessionsCount", (BYTE)g_ses_count);
+ g_plugin.setByte("UserSessionsCount", (BYTE)g_ses_count);
return 0;
}
@@ -626,17 +626,17 @@ int DeleteAutoSession(int ses_count) char szSessionName[256];
mir_snprintf(szSessionName, "%s_%u", "SessionDate", ses_count);
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
for (int i = ses_count + 1;; i++) {
mir_snprintf(szSessionName, "%s_%u", "SessionDate", i);
- ptrW szSessionNameBuf(db_get_wsa(NULL, MODULENAME, szSessionName));
+ ptrW szSessionNameBuf(g_plugin.getWStringA(szSessionName));
mir_snprintf(szSessionName, "%s_%u", "SessionDate", i - 1);
if (szSessionNameBuf)
- db_set_ws(NULL, MODULENAME, szSessionName, szSessionNameBuf);
+ g_plugin.setWString(szSessionName, szSessionNameBuf);
else {
- db_unset(NULL, MODULENAME, szSessionName);
+ g_plugin.delSetting(szSessionName);
break;
}
}
@@ -651,23 +651,23 @@ int SessionPreShutdown(WPARAM, LPARAM) if (g_hDlg) DestroyWindow(g_hDlg);
if (g_hSDlg) DestroyWindow(g_hSDlg);
- db_set_b(NULL, MODULENAME, "lastSaveCompleted", 1);
+ g_plugin.setByte("lastSaveCompleted", 1);
return 0;
}
int OkToExit(WPARAM, LPARAM)
{
- int exitmode = db_get_b(NULL, MODULENAME, "ShutdownMode", 2);
+ int exitmode = g_plugin.getByte("ShutdownMode", 2);
DONT = 1;
if (exitmode == 2 && session_list[0] != 0) {
SaveSessionDate();
SaveSessionHandles(0, 0);
- db_set_b(NULL, MODULENAME, "lastempty", 0);
+ g_plugin.setByte("lastempty", 0);
}
else if (exitmode == 1 && session_list[0] != 0) {
DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXDIALOG), nullptr, ExitDlgProc);
}
- else db_set_b(NULL, MODULENAME, "lastempty", 1);
+ else g_plugin.setByte("lastempty", 1);
return 0;
}
@@ -731,7 +731,7 @@ static int CreateButtons(WPARAM, LPARAM) static void CALLBACK LaunchSessions()
{
- int startup = db_get_b(NULL, MODULENAME, "StartupMode", 3);
+ int startup = g_plugin.getByte("StartupMode", 3);
if (startup == 1 || (startup == 3 && isLastTRUE == TRUE)) {
StartUp = TRUE;
g_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WLCMDIALOG), nullptr, LoadSessionDlgProc);
@@ -815,15 +815,15 @@ int CMPlugin::Load() Miranda_WaitOnHandle(LaunchSessions);
- g_ses_count = db_get_b(NULL, MODULENAME, "UserSessionsCount", 0);
- g_ses_limit = db_get_b(NULL, MODULENAME, "TrackCount", 10);
- g_bExclHidden = db_get_b(NULL, MODULENAME, "ExclHidden", 0) != 0;
- g_bWarnOnHidden = db_get_b(NULL, MODULENAME, "WarnOnHidden", 0) != 0;
- g_bOtherWarnings = db_get_b(NULL, MODULENAME, "OtherWarnings", 1) != 0;
- g_bCrashRecovery = db_get_b(NULL, MODULENAME, "CrashRecovery", 0) != 0;
+ g_ses_count = g_plugin.getByte("UserSessionsCount", 0);
+ g_ses_limit = g_plugin.getByte("TrackCount", 10);
+ g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
+ g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
+ g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
+ g_bCrashRecovery = g_plugin.getByte("CrashRecovery", 0) != 0;
if (g_bCrashRecovery)
- g_bIncompletedSave = db_get_b(NULL, MODULENAME, "lastSaveCompleted", 0) == 0;
+ g_bIncompletedSave = g_plugin.getByte("lastSaveCompleted", 0) == 0;
if (g_bIncompletedSave) {
int i = 0;
@@ -837,9 +837,9 @@ int CMPlugin::Load() if (!session_list_recovered[0])
g_bIncompletedSave = false;
- db_set_b(NULL, MODULENAME, "lastSaveCompleted", 0);
+ g_plugin.setByte("lastSaveCompleted", 0);
- if (!db_get_b(NULL, MODULENAME, "lastempty", 1) || g_bIncompletedSave)
+ if (!g_plugin.getByte("lastempty", 1) || g_bIncompletedSave)
isLastTRUE = true;
HookEvent(ME_SYSTEM_MODULESLOADED, PluginInit);
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index 6aab0f3f35..aaa987388a 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -160,19 +160,19 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l hIcon = (bChecked = IsMarkedUserDefSession(opses_count)) ? hMarked : hNotMarked;
- SetDlgItemInt(hdlg, IDC_TRACK, g_ses_limit = db_get_b(NULL, MODULENAME, "TrackCount", 10), FALSE);
+ SetDlgItemInt(hdlg, IDC_TRACK, g_ses_limit = g_plugin.getByte("TrackCount", 10), FALSE);
SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, nullptr, FALSE));
SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- SetDlgItemInt(hdlg, IDC_STARTDELAY, db_get_w(NULL, MODULENAME, "StartupModeDelay", 1500), FALSE);
- int startupmode = db_get_b(NULL, MODULENAME, "StartupMode", 3);
- int exitmode = db_get_b(NULL, MODULENAME, "ShutdownMode", 2);
+ SetDlgItemInt(hdlg, IDC_STARTDELAY, g_plugin.getWord("StartupModeDelay", 1500), FALSE);
+ int startupmode = g_plugin.getByte("StartupMode", 3);
+ int exitmode = g_plugin.getByte("ShutdownMode", 2);
- g_bExclHidden = db_get_b(NULL, MODULENAME, "ExclHidden", 0) != 0;
- g_bWarnOnHidden = db_get_b(NULL, MODULENAME, "WarnOnHidden", 0) != 0;
- g_bOtherWarnings = db_get_b(NULL, MODULENAME, "OtherWarnings", 1) != 0;
- g_bCrashRecovery = db_get_b(NULL, MODULENAME, "CrashRecovery", 0) != 0;
+ g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
+ g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
+ g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
+ g_bCrashRecovery = g_plugin.getByte("CrashRecovery", 0) != 0;
CheckDlgButton(hdlg, IDC_EXCLHIDDEN, g_bExclHidden ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_LASTHIDDENWARN, g_bWarnOnHidden ? BST_CHECKED : BST_UNCHECKED);
@@ -242,30 +242,30 @@ static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM l case PSN_APPLY:
{
int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, nullptr, FALSE);
- db_set_w(0, MODULENAME, "StartupModeDelay", (WORD)iDelay);
- db_set_b(0, MODULENAME, "TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, nullptr, FALSE)));
+ g_plugin.setWord("StartupModeDelay", (WORD)iDelay);
+ g_plugin.setByte("TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, nullptr, FALSE)));
if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
- db_set_b(NULL, MODULENAME, "ShutdownMode", 2);
+ g_plugin.setByte("ShutdownMode", 2);
else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
- db_set_b(NULL, MODULENAME, "ShutdownMode", 0);
+ g_plugin.setByte("ShutdownMode", 0);
else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
- db_set_b(NULL, MODULENAME, "ShutdownMode", 1);
+ g_plugin.setByte("ShutdownMode", 1);
if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
- db_set_b(NULL, MODULENAME, "StartupMode", 1);
+ g_plugin.setByte("StartupMode", 1);
else
- db_set_b(NULL, MODULENAME, "StartupMode", 3);
+ g_plugin.setByte("StartupMode", 3);
}
else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
- db_set_b(NULL, MODULENAME, "StartupMode", 2);
+ g_plugin.setByte("StartupMode", 2);
else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
- db_set_b(NULL, MODULENAME, "StartupMode", 0);
+ g_plugin.setByte("StartupMode", 0);
- db_set_b(NULL, MODULENAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
- db_set_b(NULL, MODULENAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
- db_set_b(NULL, MODULENAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
- db_set_b(NULL, MODULENAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
+ g_plugin.setByte("ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
+ g_plugin.setByte("WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
+ g_plugin.setByte("OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
+ g_plugin.setByte("CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
}
return 1;
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index 36bdeae375..4142bb80aa 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -231,8 +231,8 @@ BOOL ResaveSettings(char *szName, int iFirst, int iLimit, wchar_t *szBuffer) char szNameBuf[256];
mir_snprintf(szNameBuf, "%s_%u", szName, i);
- wchar_t *ptszTemp = db_get_wsa(NULL, MODULENAME, szNameBuf);
- db_set_ws(NULL, MODULENAME, szNameBuf, szBuffer);
+ wchar_t *ptszTemp = g_plugin.getWStringA(szNameBuf);
+ g_plugin.setWString(szNameBuf, szBuffer);
mir_free(szBuffer);
BYTE marked = IsMarkedUserDefSession(i);
@@ -298,7 +298,7 @@ int LoadSessionToCombobox(HWND hdlg, BOOL mode, int iLimit, char* pszSetting, in for (int i = 0; i < iLimit; i++) {
mir_snprintf(szBuffer, "%s_%u", pszSetting, i);
- wchar_t *pszBuffer = db_get_wsa(NULL, MODULENAME, szBuffer);
+ wchar_t *pszBuffer = g_plugin.getWStringA(szBuffer);
if (pszBuffer) {
if (!IsMarkedUserDefSession(i + iFirstNum) || mode == 1) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)pszBuffer);
@@ -327,7 +327,7 @@ int FillFavoritesMenu(HMENU hMenu, int iLimit) if (IsMarkedUserDefSession(i)) {
char szBuffer[256];
mir_snprintf(szBuffer, "%s_%u", "UserSessionDsc", i);
- wchar_t *pszBuffer = db_get_wsa(NULL, MODULENAME, szBuffer);
+ wchar_t *pszBuffer = g_plugin.getWStringA(szBuffer);
if (pszBuffer) {
AppendMenu(hMenu, MF_STRING, i + 1, pszBuffer);
iItems++;
@@ -362,14 +362,14 @@ void RenameUserDefSession(int ses_count, wchar_t* ptszNewName) {
char szSession[256];
mir_snprintf(szSession, "%s_%u", "UserSessionDsc", ses_count);
- db_set_ws(NULL, MODULENAME, szSession, ptszNewName);
+ g_plugin.setWString(szSession, ptszNewName);
}
int MarkUserDefSession(int ses_count, BYTE bCheck)
{
char szSessionName[256];
mir_snprintf(szSessionName, "%s_%u", "FavUserSession", ses_count);
- db_set_b(NULL, MODULENAME, szSessionName, bCheck);
+ g_plugin.setByte(szSessionName, bCheck);
return 0;
}
@@ -377,7 +377,7 @@ BYTE IsMarkedUserDefSession(int ses_count) {
char szSessionName[256];
mir_snprintf(szSessionName, "%s_%u", "FavUserSession", ses_count);
- return db_get_b(NULL, MODULENAME, szSessionName, 0);
+ return g_plugin.getByte(szSessionName, 0);
}
void SavePosition(HWND hwnd, char *wndName)
@@ -386,17 +386,17 @@ void SavePosition(HWND hwnd, char *wndName) GetWindowRect(hwnd, &rc);
char buffer[512];
mir_snprintf(buffer, "%sPosX", wndName);
- db_set_dw(0, MODULENAME, buffer, rc.left);
+ g_plugin.setDword(buffer, rc.left);
mir_snprintf(buffer, "%sPosY", wndName);
- db_set_dw(0, MODULENAME, buffer, rc.top);
+ g_plugin.setDword(buffer, rc.top);
}
void LoadPosition(HWND hWnd, char *wndName)
{
char buffer[512];
mir_snprintf(buffer, "%sPosX", wndName);
- int x = db_get_dw(0, MODULENAME, buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2) - 130);
+ int x = g_plugin.getDword(buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2) - 130);
mir_snprintf(buffer, "%sPosY", wndName);
- int y = db_get_dw(0, MODULENAME, buffer, ((GetSystemMetrics(SM_CYSCREEN)) / 2) - 80);
+ int y = g_plugin.getDword(buffer, ((GetSystemMetrics(SM_CYSCREEN)) / 2) - 80);
SetWindowPos(hWnd, nullptr, x, y, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE);
}
|