From 36500a6016b2b4c73f6d1fa99fc2adb0bd8ef17c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 14 Nov 2018 16:21:11 +0300 Subject: Non-IM Contact -> g_plugin --- plugins/Non-IM Contact/src/contactinfo.cpp | 122 +++++++++++++-------------- plugins/Non-IM Contact/src/dialog.cpp | 16 ++-- plugins/Non-IM Contact/src/files.cpp | 30 +++---- plugins/Non-IM Contact/src/main.cpp | 2 +- plugins/Non-IM Contact/src/namereplacing.cpp | 14 +-- plugins/Non-IM Contact/src/services.cpp | 30 +++---- plugins/Non-IM Contact/src/stdafx.h | 15 ++-- plugins/Non-IM Contact/src/timer.cpp | 10 +-- 8 files changed, 120 insertions(+), 119 deletions(-) (limited to 'plugins') diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp index 9ee6ce2d77..e60f82bd40 100644 --- a/plugins/Non-IM Contact/src/contactinfo.cpp +++ b/plugins/Non-IM Contact/src/contactinfo.cpp @@ -32,22 +32,22 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) if (GetWindowTextLength(GetDlgItem(hwnd, IDC_DISPLAY_NAME))) { char text[512]; GetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, text, _countof(text)); - db_set_s(hContact, MODNAME, "Name", text); + g_plugin.setString(hContact, "Name", text); WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick"); } else { - db_unset(hContact, MODNAME, "Name"); - db_unset(hContact, MODNAME, "Nick"); + g_plugin.delSetting(hContact, "Name"); + g_plugin.delSetting(hContact, "Nick"); } if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TOOLTIP))) { char text[2048]; GetDlgItemTextA(hwnd, IDC_TOOLTIP, text, _countof(text)); - db_set_s(hContact, MODNAME, "ToolTip", text); + g_plugin.setString(hContact, "ToolTip", text); WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes"); } else { - db_unset(hContact, MODNAME, "ToolTip"); + g_plugin.delSetting(hContact, "ToolTip"); db_unset(hContact, "UserInfo", "MyNotes"); } } @@ -120,12 +120,12 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP /* link*/ DBVARIANT dbv; - if (!db_get_ws(hContact, MODNAME, "ProgramString", &dbv)) { + if (!g_plugin.getWString(hContact, "ProgramString", &dbv)) { SetDlgItemText(hwnd, IDC_LINK, dbv.pwszVal); db_free(&dbv); } - if (!db_get_ws(hContact, MODNAME, "ProgramParamsString", &dbv)) { + if (!g_plugin.getWString(hContact, "ProgramParamsString", &dbv)) { SetDlgItemText(hwnd, IDC_PARAMS, dbv.pwszVal); db_free(&dbv); } @@ -141,7 +141,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP } /* icons */ - CheckRadioButton(hwnd, 40072, 40080, db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + CheckRadioButton(hwnd, 40072, 40080, g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG_PTR)Skin_LoadProtoIcon(MODNAME, ID_STATUS_ONLINE)); g_PrevBtnWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LONG_PTR)ButtWndProc); for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { @@ -150,24 +150,24 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP } db_free(&dbv); /* timer */ - CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME, "UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED); - if (db_get_w(hContact, MODNAME, "Timer", 15)) { + CheckDlgButton(hwnd, CHK_USE_TIMER, g_plugin.getByte(hContact, "UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED); + if (g_plugin.getWord(hContact, "Timer", 15)) { CheckDlgButton(hwnd, CHK_USE_TIMER, BST_CHECKED); EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1); wchar_t string[512]; - SetDlgItemText(hwnd, IDC_TIMER, _itow(db_get_w(hContact, MODNAME, "Timer", 15), string, 10)); - if (!db_get_w(0, MODNAME, "Timer", 1)) + SetDlgItemText(hwnd, IDC_TIMER, _itow(g_plugin.getWord(hContact, "Timer", 15), string, 10)); + if (!g_plugin.getWord("Timer", 1)) SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, TranslateT("Non-IM Contact protocol timer is Disabled")); else { - mir_snwprintf(string, TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"), db_get_w(0, MODNAME, "Timer", 1)); + mir_snwprintf(string, TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"), g_plugin.getWord("Timer", 1)); SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, string); } } /* always visible */ - if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0)) { + if (g_plugin.getByte(hContact, "AlwaysVisible", 0)) { CheckDlgButton(hwnd, IDC_ALWAYS_VISIBLE, BST_CHECKED); EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1); - CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, g_plugin.getByte(hContact, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); } } return TRUE; @@ -179,7 +179,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1); - CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, g_plugin.getByte(hContact, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED); } else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 0); break; @@ -189,7 +189,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); char string[4]; EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1); - SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME, "Timer", 15), string, 10)); + SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(g_plugin.getWord(hContact, "Timer", 15), string, 10)); } else EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 0); break; @@ -220,18 +220,18 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP if (GetWindowTextLength(GetDlgItem(hwnd, IDC_LINK))) { char text[512]; GetDlgItemTextA(hwnd, IDC_LINK, text, _countof(text)); - db_set_s(hContact, MODNAME, "ProgramString", text); + g_plugin.setString(hContact, "ProgramString", text); WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program"); } - else db_unset(hContact, MODNAME, "ProgramString"); + else g_plugin.delSetting(hContact, "ProgramString"); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_PARAMS))) { char text[512]; GetDlgItemTextA(hwnd, IDC_PARAMS, text, _countof(text)); - db_set_s(hContact, MODNAME, "ProgramParamsString", text); + g_plugin.setString(hContact, "ProgramParamsString", text); WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams"); } - else db_unset(hContact, MODNAME, "ProgramParamsString"); + else g_plugin.delSetting(hContact, "ProgramParamsString"); if (GetWindowTextLength(GetDlgItem(hwnd, IDC_GROUP))) { wchar_t text[512]; @@ -243,27 +243,27 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) if (IsDlgButtonChecked(hwnd, i)) - db_set_w(hContact, MODNAME, "Icon", (WORD)i); + g_plugin.setWord(hContact, "Icon", (WORD)i); /* set correct status */ - if (status == ID_STATUS_ONLINE || status == ID_STATUS_AWAY || (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE))) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + if (status == ID_STATUS_ONLINE || status == ID_STATUS_AWAY || (status == g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE))) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); else - db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) { if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER))) { wchar_t text[512]; GetDlgItemText(hwnd, IDC_TIMER, text, _countof(text)); - db_set_w(hContact, MODNAME, "Timer", (WORD)_wtoi(text)); + g_plugin.setWord(hContact, "Timer", (WORD)_wtoi(text)); } - else db_set_w(hContact, MODNAME, "Timer", 15); + else g_plugin.setWord(hContact, "Timer", 15); } - else db_set_w(hContact, MODNAME, "Timer", 0); + else g_plugin.setWord(hContact, "Timer", 0); // always visible - db_set_b(hContact, MODNAME, "AlwaysVisible", (BYTE)IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)); - db_set_b(hContact, MODNAME, "VisibleUnlessOffline", (BYTE)IsDlgButtonChecked(hwnd, IDC_VISIBLE_UNLESS_OFFLINE)); + g_plugin.setByte(hContact, "AlwaysVisible", (BYTE)IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)); + g_plugin.setByte(hContact, "VisibleUnlessOffline", (BYTE)IsDlgButtonChecked(hwnd, IDC_VISIBLE_UNLESS_OFFLINE)); } return TRUE; } @@ -341,21 +341,21 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) MCONTACT hContact2 = db_add_contact(); Proto_AddToContact(hContact2, MODNAME); CallService(MS_IGNORE_IGNORE, (WPARAM)hContact2, IGNOREEVENT_USERONLINE); - db_set_s(hContact2, MODNAME, "Nick", Translate("New Non-IM Contact")); + g_plugin.setString(hContact2, "Nick", Translate("New Non-IM Contact")); // blank dbVar2 so the replaceing doesnt crash.. mir_strcpy(dbVar2, ""); // copy the name (dbVar1 is the name) for (i = 0; i < k; i++) copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]); - db_set_s(hContact2, MODNAME, "Name", dbVar2); + g_plugin.setString(hContact2, "Name", dbVar2); // copy the ProgramString if (!db_get_static(hContact1, MODNAME, "ProgramString", dbVar1, _countof(dbVar1))) { mir_strcpy(dbVar2, ""); for (i = 0; i <= k; i++) copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]); - db_set_s(hContact2, MODNAME, "ProgramString", dbVar2); + g_plugin.setString(hContact2, "ProgramString", dbVar2); } // copy the ProgramParamString if (!db_get_static(hContact1, MODNAME, "ProgramParamString", dbVar1, _countof(dbVar1))) { @@ -363,7 +363,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) for (i = 0; i <= k; i++) copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]); - db_set_s(hContact2, MODNAME, "ProgramParamString", dbVar2); + g_plugin.setString(hContact2, "ProgramParamString", dbVar2); } // copy the group if (!db_get_static(hContact1, "CList", "Group", dbVar1, _countof(dbVar1))) { @@ -379,14 +379,14 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) for (i = 0; i <= k; i++) copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]); - db_set_s(hContact2, MODNAME, "ToolTip", dbVar2); + g_plugin.setString(hContact2, "ToolTip", dbVar2); } // timer - db_set_b(hContact2, MODNAME, "UseTimer", (BYTE)db_get_b(hContact1, MODNAME, "UseTimer", 0)); - db_set_b(hContact2, MODNAME, "Minutes", (BYTE)db_get_b(hContact1, MODNAME, "Minutes", 0)); - db_set_w(hContact2, MODNAME, "Timer", (WORD)db_get_w(hContact1, MODNAME, "Timer", 0)); + g_plugin.setByte(hContact2, "UseTimer", g_plugin.getByte(hContact1, "UseTimer")); + g_plugin.setByte(hContact2, "Minutes", g_plugin.getByte(hContact1, "Minutes")); + g_plugin.setWord(hContact2, "Timer", g_plugin.getWord(hContact1, "Timer")); //icon - db_set_w(hContact2, MODNAME, "Icon", (WORD)db_get_w(hContact1, MODNAME, "Icon", 40072)); + g_plugin.setWord(hContact2, "Icon", g_plugin.getWord(hContact1, "Icon", 40072)); replaceAllStrings(hContact2); } } @@ -401,14 +401,14 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } Proto_AddToContact(hContact2, MODNAME); CallService(MS_IGNORE_IGNORE, (WPARAM)hContact2, IGNOREEVENT_USERONLINE); - db_set_s(hContact2, MODNAME, "Nick", Translate("New Non-IM Contact")); - db_set_s(hContact2, MODNAME, "Name", dbVar1); + g_plugin.setString(hContact2, "Nick", Translate("New Non-IM Contact")); + g_plugin.setString(hContact2, "Name", dbVar1); if (!db_get_static(hContact1, MODNAME, "ProgramString", dbVar1, _countof(dbVar1))) - db_set_s(hContact2, MODNAME, "ProgramString", dbVar1); + g_plugin.setString(hContact2, "ProgramString", dbVar1); // copy the ProgramParamString if (!db_get_static(hContact1, MODNAME, "ProgramParamString", dbVar1, _countof(dbVar1))) - db_set_s(hContact2, MODNAME, "ProgramParamString", dbVar1); + g_plugin.setString(hContact2, "ProgramParamString", dbVar1); // copy the group if (!db_get_static(hContact1, "CList", "Group", dbVar1, _countof(dbVar1))) @@ -416,15 +416,15 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // copy the ToolTip if (!db_get_static(hContact1, MODNAME, "ToolTip", dbVar1, _countof(dbVar1))) - db_set_s(hContact2, MODNAME, "ToolTip", dbVar1); + g_plugin.setString(hContact2, "ToolTip", dbVar1); // timer - db_set_b(hContact2, MODNAME, "UseTimer", (BYTE)db_get_b(hContact1, MODNAME, "UseTimer", 0)); - db_set_b(hContact2, MODNAME, "Minutes", (BYTE)db_get_b(hContact1, MODNAME, "Minutes", 0)); - db_set_w(hContact2, MODNAME, "Timer", (WORD)db_get_w(hContact1, MODNAME, "Timer", 0)); + g_plugin.setByte(hContact2, "UseTimer", g_plugin.getByte(hContact1, "UseTimer")); + g_plugin.setByte(hContact2, "Minutes", g_plugin.getByte(hContact1, "Minutes")); + g_plugin.setWord(hContact2, "Timer", g_plugin.getWord(hContact1, "Timer")); //icon - db_set_w(hContact2, MODNAME, "Icon", (WORD)db_get_w(hContact1, MODNAME, "Icon", 40072)); + g_plugin.setWord(hContact2, "Icon", g_plugin.getWord(hContact1, "Icon", 40072)); replaceAllStrings(hContact2); } } @@ -466,13 +466,13 @@ void ExportContact(MCONTACT hContact) fprintf(file, "ToolTip=%s\r\n", DBVar); if (!db_get_static(hContact, "CList", "Group", DBVar, _countof(DBVar))) fprintf(file, "Group=%s\r\n", DBVar); - if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072)) + if (tmp = g_plugin.getWord(hContact, "Icon", 40072)) fprintf(file, "Icon=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0)) + if (tmp = g_plugin.getByte(hContact, "UseTimer", 0)) fprintf(file, "UseTimer=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1)) + if (tmp = g_plugin.getByte(hContact, "Minutes", 1)) fprintf(file, "Minutes=%d\r\n", tmp); - if (tmp = db_get_w(hContact, MODNAME, "Timer", 0)) + if (tmp = g_plugin.getWord(hContact, "Timer", 0)) fprintf(file, "Timer=%d\r\n", tmp); fprintf(file, "[/Non-IM Contact]\r\n"); } @@ -638,21 +638,21 @@ INT_PTR ImportContacts(WPARAM, LPARAM) } Proto_AddToContact(hContact, MODNAME); CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); - db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact")); - db_set_s(hContact, MODNAME, "Name", name); - db_set_s(hContact, MODNAME, "ProgramString", program); + g_plugin.setString(hContact, "Nick", Translate("New Non-IM Contact")); + g_plugin.setString(hContact, "Name", name); + g_plugin.setString(hContact, "ProgramString", program); // copy the ProgramParamString - db_set_s(hContact, MODNAME, "ProgramParamString", programparam); + g_plugin.setString(hContact, "ProgramParamString", programparam); // copy the group db_set_s(hContact, "CList", "Group", group); // copy the ToolTip - db_set_s(hContact, MODNAME, "ToolTip", tooltip); + g_plugin.setString(hContact, "ToolTip", tooltip); // timer - db_set_b(hContact, MODNAME, "UseTimer", (BYTE)usetimer); - db_set_b(hContact, MODNAME, "Minutes", (BYTE)minutes); - db_set_w(hContact, MODNAME, "Timer", (WORD)timer); + g_plugin.setByte(hContact, "UseTimer", (BYTE)usetimer); + g_plugin.setByte(hContact, "Minutes", (BYTE)minutes); + g_plugin.setWord(hContact, "Timer", (WORD)timer); //icon - db_set_w(hContact, MODNAME, "Icon", (WORD)icon); + g_plugin.setWord(hContact, "Icon", (WORD)icon); replaceAllStrings(hContact); } free(msg); diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 873aac3052..53f1db6781 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -22,10 +22,10 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); - CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(0, MODNAME, "AwayAsStatus", 0) ? BST_CHECKED : BST_UNCHECKED); - if (db_get_w(0, MODNAME, "Timer", 1)) { + CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, g_plugin.getByte("AwayAsStatus") ? BST_CHECKED : BST_UNCHECKED); + if (g_plugin.getWord("Timer", 1)) { EnableWindow(GetDlgItem(hwnd, IDC_TIMER_INT), 1); - SetDlgItemText(hwnd, IDC_TIMER_INT, _itow(db_get_w(0, MODNAME, "Timer", 1), tmp, 10)); + SetDlgItemText(hwnd, IDC_TIMER_INT, _itow(g_plugin.getWord("Timer", 1), tmp, 10)); EnableWindow(GetDlgItem(hwnd, IDC_TIMER_TEXT), 1); } else { @@ -58,12 +58,12 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - db_set_b(0, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE)); + g_plugin.setByte("AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE)); if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) { GetDlgItemText(hwnd, IDC_TIMER_INT, tmp, _countof(tmp)); - db_set_w(0, MODNAME, "Timer", (WORD)_wtoi(tmp)); + g_plugin.setWord("Timer", (WORD)_wtoi(tmp)); } - else db_set_w(0, MODNAME, "Timer", 0); + else g_plugin.setWord("Timer", 0); return TRUE; } } @@ -306,7 +306,7 @@ INT_PTR addContact(WPARAM, LPARAM) MCONTACT hContact = db_add_contact(); Proto_AddToContact(hContact, MODNAME); CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); - db_set_ws(hContact, MODNAME, "Nick", TranslateT("New Non-IM Contact")); + g_plugin.setWString(hContact, "Nick", TranslateT("New Non-IM Contact")); DoPropertySheet(hContact); if (db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp))) db_delete_contact(hContact); @@ -322,7 +322,7 @@ INT_PTR editContact(WPARAM wParam, LPARAM) hContact = db_add_contact(); Proto_AddToContact(hContact, MODNAME); CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); - db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact")); + g_plugin.setString(hContact, "Nick", Translate("New Non-IM Contact")); } DoPropertySheet(hContact); if (db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp))) diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp index a61d3a9095..6f90e5eb40 100644 --- a/plugins/Non-IM Contact/src/files.cpp +++ b/plugins/Non-IM Contact/src/files.cpp @@ -27,13 +27,13 @@ INT_PTR exportContacts(WPARAM, LPARAM) fprintf(file, "ToolTip=%s\r\n", DBVar); if (!db_get_static(hContact, "CList", "Group", DBVar, _countof(DBVar))) fprintf(file, "Group=%s\r\n", DBVar); - if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072)) + if (tmp = g_plugin.getWord(hContact, "Icon", 40072)) fprintf(file, "Icon=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0)) + if (tmp = g_plugin.getByte(hContact, "UseTimer", 0)) fprintf(file, "UseTimer=%d\r\n", tmp); - if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1)) + if (tmp = g_plugin.getByte(hContact, "Minutes", 1)) fprintf(file, "Minutes=%d\r\n", tmp); - if (tmp = db_get_w(hContact, MODNAME, "Timer", 0)) + if (tmp = g_plugin.getWord(hContact, "Timer", 0)) fprintf(file, "Timer=%d\r\n", tmp); fprintf(file, "[/Non-IM Contact]\r\n"); } @@ -132,8 +132,8 @@ void readFile(HWND hwnd) SendDlgItemMessageA(hwnd, IDC_FILE_CONTENTS, LB_ADDSTRING, 0, (LPARAM)temp1); lineNumber++; fileLength++; - if ((unsigned int)SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_GETHORIZONTALEXTENT, 0, 0) <= (mir_strlen(temp1)*db_get_b(0, MODNAME, "WidthMultiplier", 5))) - SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_SETHORIZONTALEXTENT, (mir_strlen(temp1)*db_get_b(0, MODNAME, "WidthMultiplier", 5)), 0); + if ((unsigned int)SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_GETHORIZONTALEXTENT, 0, 0) <= (mir_strlen(temp1)*g_plugin.getByte("WidthMultiplier", 5))) + SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_SETHORIZONTALEXTENT, (mir_strlen(temp1)*g_plugin.getByte("WidthMultiplier", 5)), 0); } fclose(filen); } @@ -157,7 +157,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if ((!strncmp("http://", string, mir_strlen("http://"))) || (!strncmp("https://", string, mir_strlen("https://")))) { SetDlgItemTextA(hwnd, IDC_URL, string); mir_snprintf(fn, "fn%d_timer", i); - SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(0, MODNAME, fn, 60), tmp, 10)); + SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(g_plugin.getWord(fn, 60), tmp, 10)); } readFile(hwnd); } @@ -184,7 +184,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) mir_snprintf(szFileName, "%s\\plugins\\%s.html", getMimDir(temp), fn); if (savehtml(szFileName)) { mir_snprintf(fn, "fn%d", i); - db_set_s(0, MODNAME, fn, url); + g_plugin.setString(fn, url); int timer; if (!GetWindowTextLength(GetDlgItem(hwnd, IDC_WWW_TIMER))) timer = 60; @@ -193,7 +193,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) timer = atoi(text); } mir_snprintf(fn, "fn%d_timer", i); - db_set_w(0, MODNAME, fn, (WORD)timer); + g_plugin.setWord(fn, (WORD)timer); SendMessage(hwnd, WM_RELOADWINDOW, 0, 0); } break; @@ -214,7 +214,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) mir_snprintf(fn, "fn%d", i); if (db_get_static(NULL, MODNAME, fn, file, _countof(file))) { if (Openfile(file, 1)) { - db_set_s(0, MODNAME, fn, file); + g_plugin.setString(fn, file); int index = SendDlgItemMessageA(hwnd, IDC_FILE_LIST, CB_ADDSTRING, 0, (LPARAM)file); SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_SETITEMDATA, index, (LPARAM)i); SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_SETCURSEL, index, 0); @@ -233,7 +233,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int count = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCOUNT, 0, 0) - 1; if (index == count) { mir_snprintf(fn, "fn%d", index); - db_unset(0, MODNAME, fn); + g_plugin.delSetting(fn); SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_DELETESTRING, index, 0); SendMessage(hwnd, WM_RELOADWINDOW, 0, 0); if (!index) { @@ -247,11 +247,11 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) while (!db_get_static(NULL, MODNAME, fn, tmp, _countof(tmp))) { char fn1[4]; mir_snprintf(fn1, "fn%d", i - 1); - db_set_s(0, MODNAME, fn1, tmp); + g_plugin.setString(fn1, tmp); mir_snprintf(fn, "fn%d", ++i); } mir_snprintf(fn, "fn%d", --i); - db_unset(0, MODNAME, fn); + g_plugin.delSetting(fn); SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_DELETESTRING, index, 0); SendMessage(hwnd, WM_RELOADWINDOW, 0, 0); } @@ -267,7 +267,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (!strncmp("http://", tmp, mir_strlen("http://")) || !strncmp("https://", tmp, mir_strlen("https://"))) { SetDlgItemTextA(hwnd, IDC_URL, tmp); mir_snprintf(fn, "fn%d_timer", index); - SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(0, MODNAME, fn, 60), tmp, 10)); + SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(g_plugin.getWord(fn, 60), tmp, 10)); } else { SetDlgItemText(hwnd, IDC_URL, L""); @@ -302,7 +302,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (!db_get_static(NULL, MODNAME, fn, string, _countof(string))) if (!strncmp("http://", string, mir_strlen("http://")) || !strncmp("https://", string, mir_strlen("https://"))) { mir_snprintf(fn, "fn%d_timer", i); - db_set_w(0, MODNAME, fn, (WORD)timer); + g_plugin.setWord(fn, (WORD)timer); } return TRUE; diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp index bbefafd3a6..f2f7a15b28 100644 --- a/plugins/Non-IM Contact/src/main.cpp +++ b/plugins/Non-IM Contact/src/main.cpp @@ -149,7 +149,7 @@ int CMPlugin::Load() mi.pszService = "LoadFilesDlg"; Menu_AddMainMenuItem(&mi); - if (db_get_b(0, MODNAME, "Beta", 0)) { + if (g_plugin.getByte("Beta", 0)) { SET_UID(mi, 0x23051356, 0xad45, 0x4101, 0x8e, 0x11, 0xf6, 0x3a, 0xe8, 0xa3, 0xa5, 0x25); mi.position = 600090002; mi.name.a = LPGEN("&Export all Non-IM Contacts"); diff --git a/plugins/Non-IM Contact/src/namereplacing.cpp b/plugins/Non-IM Contact/src/namereplacing.cpp index d7909d7281..8c1800b166 100644 --- a/plugins/Non-IM Contact/src/namereplacing.cpp +++ b/plugins/Non-IM Contact/src/namereplacing.cpp @@ -246,7 +246,7 @@ void checkStringForSave(MCONTACT hContact, CMStringA &str) B = strtok(nullptr, ",\")"); j = B - ©OfStr[i] + (int)mir_strlen(B) + 1; if (A && B) - db_set_s(hContact, MODNAME, A, B); + g_plugin.setString(hContact, A, B); else tmp.Append(str.c_str()+i, j); i += j; @@ -433,7 +433,7 @@ void checkIcon(MCONTACT hContact, char* string) if (str) { int icon = getNumber(str + 5); if (icon >= 0) - db_set_w(hContact, MODNAME, "Status", (WORD)(ID_STATUS_OFFLINE + icon)); + g_plugin.setWord(hContact, "Status", (WORD)(ID_STATUS_OFFLINE + icon)); } } @@ -604,13 +604,13 @@ void WriteSetting(MCONTACT hContact, char* module1, char* setting1, char* module if (!error) { if ((status == ID_STATUS_ONLINE) || (status == ID_STATUS_AWAY) || - (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)) || - db_get_b(hContact, MODNAME, "AlwaysVisible", 0)) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + (status == g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)) || + g_plugin.getByte(hContact, "AlwaysVisible", 0)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); else - db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); } - else db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); + else g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); } void replaceAllStrings(MCONTACT hContact) diff --git a/plugins/Non-IM Contact/src/services.cpp b/plugins/Non-IM Contact/src/services.cpp index 4e70d79a4e..18ae0aa1b4 100644 --- a/plugins/Non-IM Contact/src/services.cpp +++ b/plugins/Non-IM Contact/src/services.cpp @@ -55,11 +55,11 @@ int SetLCStatus(WPARAM wParam, LPARAM) { int oldStatus = LCStatus; LCStatus = wParam; - db_set_w(0, MODNAME, "Status", (WORD)wParam); - db_set_w(0, MODNAME, "timerCount", 0); - if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !db_get_b(0, MODNAME, "AwayAsStatus", 0)) || !db_get_w(0, MODNAME, "Timer", 1)) + g_plugin.setWord("Status", (WORD)wParam); + g_plugin.setWord("timerCount", 0); + if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !g_plugin.getByte("AwayAsStatus", 0)) || !g_plugin.getWord("Timer", 1)) killTimer(); - else if (db_get_w(0, MODNAME, "Timer", 1)) + else if (g_plugin.getWord("Timer", 1)) startTimer(TIMER); for (auto &hContact : Contacts(MODNAME)) { @@ -68,28 +68,28 @@ int SetLCStatus(WPARAM wParam, LPARAM) switch (LCStatus) { case ID_STATUS_OFFLINE: - if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0) && !db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1)) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + if (g_plugin.getByte(hContact, "AlwaysVisible", 0) && !g_plugin.getByte(hContact, "VisibleUnlessOffline", 1)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); else - db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); break; case ID_STATUS_ONLINE: - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); break; case ID_STATUS_AWAY: - if (db_get_b(0, MODNAME, "AwayAsStatus", 0) && (db_get_b(hContact, MODNAME, "AlwaysVisible", 0) || (db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE) == ID_STATUS_AWAY))) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); - else if (!db_get_b(0, MODNAME, "AwayAsStatus", 0)) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + if (g_plugin.getByte("AwayAsStatus", 0) && (g_plugin.getByte(hContact, "AlwaysVisible", 0) || (g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE) == ID_STATUS_AWAY))) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); + else if (!g_plugin.getByte("AwayAsStatus", 0)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); else - db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE); + g_plugin.setWord(hContact, "Status", ID_STATUS_OFFLINE); break; default: - if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0) || LCStatus == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)) - db_set_w(hContact, MODNAME, "Status", (WORD)db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)); + if (g_plugin.getByte(hContact, "AlwaysVisible", 0) || LCStatus == g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)) + g_plugin.setWord(hContact, "Status", (WORD)g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE)); break; } } diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index 7df1c07b7b..2c7df9029d 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -52,13 +52,14 @@ struct DLGTEMPLATEEX //======================================================= // Definitions //======================================================= -#define MODNAME "NIM_Contact" -#define modFullname "Non-IM Contact" -#define MAXLINES 10000 -#define MAX_STRING_LENGTH 10000 -#define LINE_LENGTH 10000 -#define msg(a,b) MessageBoxA(0,a,b,MB_OK); -#define TIMER (db_get_w(0, MODNAME, "Timer", 1) * 1000) +#define MODNAME "NIM_Contact" +#define modFullname "Non-IM Contact" +#define MAXLINES 10000 +#define MAX_STRING_LENGTH 10000 +#define LINE_LENGTH 10000 +#define msg(a,b) MessageBoxA(0,a,b,MB_OK); +#define TIMER (g_plugin.getWord("Timer", 1) * 1000) + /* ERROR VALUES */ #define ERROR_NO_LINE_AFTER_VAR_F -1 #define ERROR_LINE_NOT_READ -2 diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp index ba658997d6..6e34352f2e 100644 --- a/plugins/Non-IM Contact/src/timer.cpp +++ b/plugins/Non-IM Contact/src/timer.cpp @@ -13,13 +13,13 @@ void timerFunc(void*) { char text[512], fn[16], szFileName[MAX_PATH], temp[MAX_PATH]; - int timerCount = db_get_w(0, MODNAME, "timerCount", 1) + 1; + int timerCount = g_plugin.getWord("timerCount", 1) + 1; if (LCStatus == ID_STATUS_OFFLINE) { killTimer(); return; } - db_set_w(0, MODNAME, "timerCount", (WORD)timerCount); + g_plugin.setWord("timerCount", (WORD)timerCount); /* update the web pages*/ for (int i = 0;; i++) { @@ -29,7 +29,7 @@ void timerFunc(void*) if (!strncmp("http://", text, mir_strlen("http://")) || !strncmp("https://", text, mir_strlen("https://"))) { mir_snprintf(fn, "fn%d_timer", i); - int timer = db_get_w(0, MODNAME, fn, 60); + int timer = g_plugin.getWord(fn, 60); if (timer && !(timerCount % timer)) { if (!InternetDownloadFile(text)) { mir_snprintf(szFileName, "%s\\plugins\\fn%d.html", getMimDir(temp), i); @@ -41,7 +41,7 @@ void timerFunc(void*) /* update all the contacts */ for (auto &hContact : Contacts(MODNAME)) { - int timer = db_get_w(hContact, MODNAME, "Timer", 15); + int timer = g_plugin.getWord(hContact, "Timer", 15); if (timer && !(timerCount % timer)) if (!db_get_static(hContact, MODNAME, "Name", text, _countof(text))) replaceAllStrings(hContact); @@ -77,7 +77,7 @@ int startTimer(int interval) int killTimer() { if (timerId != 0) { - db_set_w(0, MODNAME, "timerCount", 0); + g_plugin.setWord("timerCount", 0); KillTimer(nullptr, timerId); timerId = 0; } -- cgit v1.2.3