summaryrefslogtreecommitdiff
path: root/plugins/XSoundNotify/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-20 15:08:48 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-20 15:08:48 +0300
commit8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch)
tree03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/XSoundNotify/src
parentc5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff)
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/XSoundNotify/src')
-rw-r--r--plugins/XSoundNotify/src/dialog.cpp22
-rw-r--r--plugins/XSoundNotify/src/options.cpp32
-rw-r--r--plugins/XSoundNotify/src/stdafx.h6
-rw-r--r--plugins/XSoundNotify/src/xsn_main.cpp26
4 files changed, 44 insertions, 42 deletions
diff --git a/plugins/XSoundNotify/src/dialog.cpp b/plugins/XSoundNotify/src/dialog.cpp
index 96d623ccbb..32754d42c2 100644
--- a/plugins/XSoundNotify/src/dialog.cpp
+++ b/plugins/XSoundNotify/src/dialog.cpp
@@ -21,7 +21,7 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
hContact = lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
WindowList_Add(hChangeSoundDlgList, hwndDlg, hContact);
- Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
+ Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULENAME, "ChangeSoundDlg");
char* szProto = GetContactProto(hContact);
PROTOACCOUNT *pa = Proto_GetAccount(szProto);
const char* szUniqueId = Proto_GetUniqueId(pa->szModuleName);
@@ -52,7 +52,7 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
}
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_CHOOSE_SOUND), TRUE);
DBVARIANT dbv = { 0 };
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
@@ -64,10 +64,10 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
}
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_IGNORE_SOUND), TRUE);
- CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, MODULENAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
p = XSN_Users.find((XSN_Data *)&hContact);
if (p == nullptr) {
- ptrW name(db_get_wsa(hContact, SETTINGSNAME, SETTINGSKEY));
+ ptrW name(db_get_wsa(hContact, MODULENAME, SETTINGSKEY));
if (name != NULL)
XSN_Users.insert(new XSN_Data(hContact, name, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0, 1));
}
@@ -82,9 +82,9 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
if (mir_wstrcmpi(p->path, L"")) {
wchar_t shortpath[MAX_PATH];
PathToRelativeW(p->path, shortpath);
- db_set_ws(hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
+ db_set_ws(hContact, MODULENAME, SETTINGSKEY, shortpath);
}
- db_set_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, p->ignore);
+ db_set_b(hContact, MODULENAME, SETTINGSIGNOREKEY, p->ignore);
}
case IDCANCEL:
@@ -134,7 +134,7 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
isIgnoreSound = 0;
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t longpath[MAX_PATH] = { 0 };
PathToAbsoluteW(dbv.ptszVal, longpath);
Skin_PlaySoundFile(longpath);
@@ -159,15 +159,15 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
XSN_Users.remove(p);
delete p;
}
- db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
- db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ db_unset(hContact, MODULENAME, SETTINGSKEY);
+ db_unset(hContact, MODULENAME, SETTINGSIGNOREKEY);
break;
case IDC_CONT_IGNORE_SOUND:
p = XSN_Users.find((XSN_Data *)&hContact);
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t longpath[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, longpath);
XSN_Users.insert(new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0, 1));
@@ -184,7 +184,7 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP
break;
case WM_DESTROY:
- Utils_SaveWindowPosition(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
+ Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "ChangeSoundDlg");
WindowList_Remove(hChangeSoundDlgList, hwndDlg);
}
return FALSE;
diff --git a/plugins/XSoundNotify/src/options.cpp b/plugins/XSoundNotify/src/options.cpp
index 61d9505381..f696ec49e6 100644
--- a/plugins/XSoundNotify/src/options.cpp
+++ b/plugins/XSoundNotify/src/options.cpp
@@ -97,7 +97,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (!cursel) {
PROTOACCOUNT *pa = (PROTOACCOUNT *)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_PROTO, CB_GETITEMDATA, cursel, 0);
DBVARIANT dbv = { 0 };
- if (!db_get_ws(NULL, SETTINGSNAME, pa->szModuleName, &dbv)) {
+ if (!db_get_ws(NULL, MODULENAME, pa->szModuleName, &dbv)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), TRUE);
SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
@@ -111,13 +111,13 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
size_t value_max_len = mir_strlen(pa->szModuleName) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
mir_snprintf(value, value_max_len, "%s_ignore", pa->szModuleName);
- CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, db_get_b(NULL, SETTINGSNAME, value, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, db_get_b(NULL, MODULENAME, value, 0) ? BST_CHECKED : BST_UNCHECKED);
mir_free(value);
}
else {
MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwndDlg, IDC_OPT_COMBO_USERS, CB_GETITEMDATA, cursel, 0);
DBVARIANT dbv = { 0 };
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_TEST_PLAY), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), TRUE);
SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
@@ -128,7 +128,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_BUTTON_RESET_SOUND), FALSE);
SetDlgItemText(hwndDlg, IDC_OPT_LABEL_SOUND, TranslateT("Not set"));
}
- CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_OPT_IGNORE_SOUND, db_get_b(hContact, MODULENAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
}
}
return 0;
@@ -200,7 +200,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
isIgnoreSound = 0;
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(NULL, SETTINGSNAME, pa->szModuleName, &dbv)) {
+ if (!db_get_ws(NULL, MODULENAME, pa->szModuleName, &dbv)) {
wchar_t longpath[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, longpath);
Skin_PlaySoundFile(longpath);
@@ -219,7 +219,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
isIgnoreSound = 0;
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t longpath[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, longpath);
Skin_PlaySoundFile(longpath);
@@ -250,11 +250,11 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
delete p;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- db_unset(NULL, SETTINGSNAME, pa->szModuleName);
+ db_unset(NULL, MODULENAME, pa->szModuleName);
size_t value_max_len = mir_strlen(pa->szModuleName) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
mir_snprintf(value, value_max_len, "%s_ignore", pa->szModuleName);
- db_unset(NULL, SETTINGSNAME, value);
+ db_unset(NULL, MODULENAME, value);
mir_free(value);
}
else {
@@ -265,8 +265,8 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
delete p;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
- db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
+ db_unset(hContact, MODULENAME, SETTINGSKEY);
+ db_unset(hContact, MODULENAME, SETTINGSIGNOREKEY);
}
}
return 0;
@@ -279,7 +279,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
XSN_Data *p = XSN_Users.find((XSN_Data *)&pa->szModuleName);
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(NULL, SETTINGSNAME, pa->szModuleName, &dbv)) {
+ if (!db_get_ws(NULL, MODULENAME, pa->szModuleName, &dbv)) {
wchar_t longpath[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, longpath);
XSN_Users.insert(new XSN_Data((LPARAM)pa->szModuleName, longpath, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0, 0));
@@ -295,7 +295,7 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
if (p == nullptr) {
DBVARIANT dbv;
- if (!db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t longpath[MAX_PATH];
PathToAbsoluteW(dbv.ptszVal, longpath);
XSN_Users.insert(new XSN_Data(hContact, longpath, IsDlgButtonChecked(hwndDlg, IDC_OPT_IGNORE_SOUND) ? 1 : 0, 1));
@@ -320,17 +320,17 @@ static INT_PTR CALLBACK OptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
wchar_t shortpath[MAX_PATH];
PathToRelativeW(it->path, shortpath);
if (it->iscontact)
- db_set_ws(it->hContact, SETTINGSNAME, SETTINGSKEY, shortpath);
+ db_set_ws(it->hContact, MODULENAME, SETTINGSKEY, shortpath);
else
- db_set_ws(NULL, SETTINGSNAME, (LPCSTR)it->hContact, shortpath);
+ db_set_ws(NULL, MODULENAME, (LPCSTR)it->hContact, shortpath);
}
if (it->iscontact)
- db_set_b(it->hContact, SETTINGSNAME, SETTINGSIGNOREKEY, it->ignore);
+ db_set_b(it->hContact, MODULENAME, SETTINGSIGNOREKEY, it->ignore);
else {
size_t value_max_len = mir_strlen((const char*)it->hContact) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
mir_snprintf(value, value_max_len, "%s_ignore", (const char*)it->hContact);
- db_set_b(NULL, SETTINGSNAME, value, it->ignore);
+ db_set_b(NULL, MODULENAME, value, it->ignore);
mir_free(value);
}
}
diff --git a/plugins/XSoundNotify/src/stdafx.h b/plugins/XSoundNotify/src/stdafx.h
index 8e147d857d..70c1a6b9d6 100644
--- a/plugins/XSoundNotify/src/stdafx.h
+++ b/plugins/XSoundNotify/src/stdafx.h
@@ -18,15 +18,13 @@
#include "resource.h"
#include "version.h"
-#define SETTINGSNAME "XSoundNotify"
+#define MODULENAME "XSoundNotify"
#define SETTINGSKEY "XSNPlugin_sound"
#define SETTINGSIGNOREKEY "XSNPlugin_ignore"
struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMPlugin() :
- PLUGIN<CMPlugin>(SETTINGSNAME)
- {}
+ CMPlugin();
};
struct XSN_Data
diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp
index 7e7166f6d6..866ddfcb22 100644
--- a/plugins/XSoundNotify/src/xsn_main.cpp
+++ b/plugins/XSoundNotify/src/xsn_main.cpp
@@ -20,7 +20,7 @@ BYTE isIgnoreSound = 0, isOwnSound = 0, isIgnoreAccSound = 0, isAccSound = 0;
/////////////////////////////////////////////////////////////////////////////////////////
-PLUGININFOEX pluginInfo =
+PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -34,9 +34,13 @@ PLUGININFOEX pluginInfo =
{ 0xa01e25f7, 0xa6ef, 0x4b40,{ 0x8c, 0xac, 0x75, 0x5a, 0x2f, 0x2e, 0x55, 0xb5 }}
};
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{}
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- return &pluginInfo;
+ return &pluginInfoEx;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -107,9 +111,9 @@ static int ProcessEvent(WPARAM hContact, LPARAM lParam)
if (!isReceiveMessage(lParam))
return 0;
- isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0);
+ isIgnoreSound = db_get_b(hContact, MODULENAME, SETTINGSIGNOREKEY, 0);
DBVARIANT dbv;
- if (!isIgnoreSound && !db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!isIgnoreSound && !db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t PlaySoundPath[MAX_PATH] = { 0 };
PathToAbsoluteW(dbv.ptszVal, PlaySoundPath);
isOwnSound = 0;
@@ -124,9 +128,9 @@ static int ProcessEvent(WPARAM hContact, LPARAM lParam)
size_t value_max_len = mir_strlen(pa->szModuleName) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
mir_snprintf(value, value_max_len, "%s_ignore", pa->szModuleName);
- isIgnoreAccSound = db_get_b(NULL, SETTINGSNAME, value, 0);
+ isIgnoreAccSound = db_get_b(NULL, MODULENAME, value, 0);
mir_free(value);
- if (!isIgnoreAccSound && !db_get_ws(NULL, SETTINGSNAME, pa->szModuleName, &dbv)) {
+ if (!isIgnoreAccSound && !db_get_ws(NULL, MODULENAME, pa->szModuleName, &dbv)) {
wchar_t PlaySoundPath[MAX_PATH] = { 0 };
PathToAbsoluteW(dbv.ptszVal, PlaySoundPath);
isAccSound = 0;
@@ -152,9 +156,9 @@ static int ProcessChatEvent(WPARAM, LPARAM lParam)
if (nick == NULL || gce->ptszText == nullptr)
return 0;
if (wcsstr(gce->ptszText, nick)) {
- isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0);
+ isIgnoreSound = db_get_b(hContact, MODULENAME, SETTINGSIGNOREKEY, 0);
DBVARIANT dbv;
- if (!isIgnoreSound && !db_get_ws(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
+ if (!isIgnoreSound && !db_get_ws(hContact, MODULENAME, SETTINGSKEY, &dbv)) {
wchar_t PlaySoundPath[MAX_PATH] = { 0 };
PathToAbsoluteW(dbv.ptszVal, PlaySoundPath);
isOwnSound = 0;
@@ -168,9 +172,9 @@ static int ProcessChatEvent(WPARAM, LPARAM lParam)
size_t value_max_len = mir_strlen(pa->szModuleName) + 8;
char *value = (char *)mir_alloc(sizeof(char) * value_max_len);
mir_snprintf(value, value_max_len, "%s_ignore", pa->szModuleName);
- isIgnoreAccSound = db_get_b(NULL, SETTINGSNAME, value, 0);
+ isIgnoreAccSound = db_get_b(NULL, MODULENAME, value, 0);
mir_free(value);
- if (!isIgnoreAccSound && !db_get_ws(NULL, SETTINGSNAME, pa->szModuleName, &dbv)) {
+ if (!isIgnoreAccSound && !db_get_ws(NULL, MODULENAME, pa->szModuleName, &dbv)) {
wchar_t PlaySoundPath[MAX_PATH] = { 0 };
PathToAbsoluteW(dbv.ptszVal, PlaySoundPath);
isAccSound = 0;
@@ -236,7 +240,7 @@ static int OnPreShutdown(WPARAM, LPARAM)
extern "C" int __declspec(dllexport) Load()
{
- mir_getLP(&pluginInfo);
+ mir_getLP(&pluginInfoEx);
pci = Chat_GetInterface();
CreateServiceFunction("XSoundNotify/ContactMenuCommand", ShowDialog);