summaryrefslogtreecommitdiff
path: root/plugins/QuickContacts
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-11-12 20:12:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-11-12 20:12:53 +0300
commit488214ac8af0c4aeb1a5c1d8fd48368daaf4c4c7 (patch)
tree96b0db981b4f5054f24d484902b597ba7da1c1a5 /plugins/QuickContacts
parent9b35784c5042984fbb60785f0a4a41a64af545f6 (diff)
end of ME_OPT_INITIALISE related zoo in another plugins
Diffstat (limited to 'plugins/QuickContacts')
-rw-r--r--plugins/QuickContacts/src/dialog.cpp24
-rw-r--r--plugins/QuickContacts/src/options.cpp61
-rw-r--r--plugins/QuickContacts/src/options.h9
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp26
4 files changed, 42 insertions, 78 deletions
diff --git a/plugins/QuickContacts/src/dialog.cpp b/plugins/QuickContacts/src/dialog.cpp
index 0d6aecf812..ff03b01b4a 100644
--- a/plugins/QuickContacts/src/dialog.cpp
+++ b/plugins/QuickContacts/src/dialog.cpp
@@ -132,7 +132,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
BOOL metacontactsEnabled = db_mc_isEnabled();
// Read last-sent-to contact from db and set handle as window-userdata
- HANDLE hlastsent = (HANDLE)db_get_dw(NULL, MODULENAME, "LastSentTo", -1);
+ HANDLE hlastsent = (HANDLE)g_plugin.getDword("LastSentTo", -1);
SetWindowLongPtr(hwndMain, GWLP_USERDATA, (LONG_PTR)hlastsent);
// enumerate all contacts and write them to the array
@@ -160,7 +160,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
char setting[128];
mir_snprintf(setting, "ShowOffline%s", pszProto);
- if (!db_get_b(NULL, MODULENAME, setting, FALSE))
+ if (!g_plugin.getByte(setting, FALSE))
continue;
// Check if proto offline
@@ -179,7 +179,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
char setting[128];
mir_snprintf(setting, "ShowOffline%s", META_PROTO);
- if (db_get_b(NULL, MODULENAME, setting, FALSE))
+ if (g_plugin.getByte(setting, FALSE))
continue;
}
}
@@ -530,8 +530,8 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
LoadContacts(hwndDlg, FALSE);
EnableButtons(hwndDlg, NULL);
- if (db_get_b(NULL, MODULENAME, "EnableLastSentTo", 0)) {
- int pos = GetItemPos((MCONTACT)db_get_dw(NULL, MODULENAME, "LastSentTo", -1));
+ if (g_plugin.getByte("EnableLastSentTo", 0)) {
+ int pos = GetItemPos(g_plugin.getDword("LastSentTo", -1));
if (pos != -1) {
SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETCURSEL, (WPARAM)pos, 0);
EnableButtons(hwndDlg, contacts[pos]->hcontact);
@@ -559,7 +559,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
Clist_ContactDoubleClicked(hContact);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -578,7 +578,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
break;
}
@@ -599,7 +599,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CallService(MS_FILE_SENDFILE, hContact, 0);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -620,7 +620,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CallService(MS_URL_SENDURL, hContact, 0);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -641,7 +641,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -662,7 +662,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
- db_set_dw(NULL, MODULENAME, "LastSentTo", hContact);
+ g_plugin.setDword("LastSentTo", hContact);
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -692,7 +692,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
Clist_MenuProcessCommand(LOWORD(ret), MPCF_CONTACTMENU, hContact);
}
- db_set_dw(NULL, MODULENAME, "LastSentTo", (DWORD)hContact);
+ g_plugin.setDword("LastSentTo", (DWORD)hContact);
}
break;
diff --git a/plugins/QuickContacts/src/options.cpp b/plugins/QuickContacts/src/options.cpp
index e0b59efd5f..43cb95c914 100644
--- a/plugins/QuickContacts/src/options.cpp
+++ b/plugins/QuickContacts/src/options.cpp
@@ -22,54 +22,21 @@ Boston, MA 02111-1307, USA.
// Prototypes /////////////////////////////////////////////////////////////////////////////////////
-HANDLE hOptHook = nullptr;
-
-
Options opts;
-static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-
-
// Functions //////////////////////////////////////////////////////////////////////////////////////
-
// Initializations needed by options
void LoadOptions()
{
- opts.last_sent_enable = db_get_b(NULL, MODULENAME, "EnableLastSentTo", TRUE);
- opts.last_sent_msg_type = db_get_w(NULL, MODULENAME, "MsgTypeRec", TYPE_GLOBAL);
- opts.hide_from_offline_proto = db_get_b(NULL, MODULENAME, "HideOfflineFromOfflineProto", TRUE);
- opts.group_append = db_get_b(NULL, MODULENAME, "AppendGroupName", FALSE);
- opts.group_column = db_get_b(NULL, MODULENAME, "GroupColumn", FALSE);
- opts.group_column_left = db_get_b(NULL, MODULENAME, "GroupColumnLeft", FALSE);
- opts.hide_subcontacts = db_get_b(NULL, MODULENAME, "HideSubcontacts", TRUE);
- opts.keep_subcontacts_from_offline = db_get_b(NULL, MODULENAME, "KeepSubcontactsFromOffline", TRUE);
-}
-
-int InitOptionsCallback(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = {};
- odp.szGroup.w = LPGENW("Contacts");
- odp.szTitle.w = LPGENW("Quick Contacts");
- odp.pfnDlgProc = OptionsDlgProc;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
- odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
- g_plugin.addOptions(wParam, &odp);
- return 0;
-}
-
-void InitOptions()
-{
- LoadOptions();
-
- hOptHook = HookEvent(ME_OPT_INITIALISE, InitOptionsCallback);
-}
-
-// Deinitializations needed by options
-void DeInitOptions()
-{
- UnhookEvent(hOptHook);
+ opts.last_sent_enable = g_plugin.getByte("EnableLastSentTo", TRUE);
+ opts.last_sent_msg_type = g_plugin.getWord("MsgTypeRec", TYPE_GLOBAL);
+ opts.hide_from_offline_proto = g_plugin.getByte("HideOfflineFromOfflineProto", TRUE);
+ opts.group_append = g_plugin.getByte("AppendGroupName", FALSE);
+ opts.group_column = g_plugin.getByte("GroupColumn", FALSE);
+ opts.group_column_left = g_plugin.getByte("GroupColumnLeft", FALSE);
+ opts.hide_subcontacts = g_plugin.getByte("HideSubcontacts", TRUE);
+ opts.keep_subcontacts_from_offline = g_plugin.getByte("KeepSubcontactsFromOffline", TRUE);
}
// Options page
@@ -130,3 +97,15 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return ret;
}
+
+int InitOptionsCallback(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = {};
+ odp.szGroup.w = LPGENW("Contacts");
+ odp.szTitle.w = LPGENW("Quick Contacts");
+ odp.pfnDlgProc = OptionsDlgProc;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
+ odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
+ g_plugin.addOptions(wParam, &odp);
+ return 0;
+}
diff --git a/plugins/QuickContacts/src/options.h b/plugins/QuickContacts/src/options.h
index 9f9f5083c5..ca311b3b3d 100644
--- a/plugins/QuickContacts/src/options.h
+++ b/plugins/QuickContacts/src/options.h
@@ -43,17 +43,10 @@ extern Options opts;
// Initializations needed by options
-void InitOptions();
-
-// Deinitializations needed by options
-void DeInitOptions();
-
+int InitOptionsCallback(WPARAM, LPARAM);
// Loads the options from DB
// It don't need to be called, except in some rare cases
void LoadOptions();
-
-
-
#endif // __OPTIONS_H__
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index 99e8b69857..e6039dc83e 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -24,10 +24,6 @@ Boston, MA 02111-1307, USA.
CMPlugin g_plugin;
-HANDLE hModulesLoaded = nullptr;
-HANDLE hEventAdded = nullptr;
-HANDLE hHotkeyPressed = nullptr;
-
INT_PTR ShowDialog(WPARAM wParam, LPARAM lParam);
void FreeContacts();
@@ -57,8 +53,6 @@ CMPlugin::CMPlugin() :
static int ModulesLoaded(WPARAM, LPARAM)
{
- InitOptions();
-
// Get number of protocols
Proto_EnumAccounts(&opts.num_protos, nullptr);
@@ -139,22 +133,25 @@ static int EventAdded(WPARAM wparam, LPARAM hDbEvent)
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
if (!(dbei.flags & DBEF_SENT) || (dbei.flags & DBEF_READ)
- || !db_get_b(NULL, MODULENAME, "EnableLastSentTo", 0)
- || db_get_w(NULL, MODULENAME, "MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
+ || !g_plugin.getByte("EnableLastSentTo", 0)
+ || g_plugin.getWord("MsgTypeRec", TYPE_GLOBAL) != TYPE_GLOBAL)
return 0;
- db_set_dw(NULL, MODULENAME, "LastSentTo", (UINT_PTR)wparam);
+ g_plugin.setDword("LastSentTo", (UINT_PTR)wparam);
return 0;
}
int CMPlugin::Load()
{
+ LoadOptions();
+
+ // services
CreateServiceFunction(MS_QC_SHOW_DIALOG, ShowDialog);
// hooks
- hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- hEventAdded = HookEvent(ME_DB_EVENT_ADDED, EventAdded);
-
+ HookEvent(ME_DB_EVENT_ADDED, EventAdded);
+ HookEvent(ME_OPT_INITIALISE, InitOptionsCallback);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
return 0;
}
@@ -163,10 +160,5 @@ int CMPlugin::Load()
int CMPlugin::Unload()
{
FreeContacts();
-
- DeInitOptions();
-
- UnhookEvent(hModulesLoaded);
- UnhookEvent(hEventAdded);
return 0;
}