summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Popup/src/common.h2
-rw-r--r--plugins/Popup/src/config.cpp23
-rw-r--r--plugins/Popup/src/config.h7
-rw-r--r--plugins/Popup/src/history.cpp2
-rw-r--r--plugins/Popup/src/icons.cpp6
-rw-r--r--plugins/Popup/src/main.cpp40
-rw-r--r--plugins/Popup/src/opt_adv.cpp2
-rw-r--r--plugins/Popup/src/opt_gen.cpp2
-rw-r--r--plugins/Popup/src/opt_skins.cpp8
-rw-r--r--plugins/Popup/src/opttree.cpp2
-rw-r--r--plugins/Popup/src/popup_thread.cpp8
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp18
-rw-r--r--plugins/Popup/src/skin.cpp12
-rw-r--r--plugins/Popup/src/skin.h1
-rw-r--r--plugins/Popup/src/stdafx.h20
-rw-r--r--plugins/ProfileManager/src/pmanagerEx.cpp26
-rw-r--r--plugins/ProfileManager/src/stdafx.h1
-rw-r--r--plugins/QuickContacts/src/dialog.cpp881
-rw-r--r--plugins/QuickContacts/src/options.cpp2
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp955
-rw-r--r--plugins/QuickContacts/src/stdafx.h16
-rw-r--r--plugins/RemovePersonalSettings/src/rps.cpp624
-rw-r--r--plugins/RemovePersonalSettings/src/stdafx.h1
-rw-r--r--plugins/Restart/src/restart.cpp23
-rw-r--r--plugins/Restart/src/stdafx.h1
-rw-r--r--plugins/SMS/src/main.cpp93
-rw-r--r--plugins/SMS/src/stdafx.h23
-rw-r--r--plugins/SeenPlugin/src/history.cpp2
-rw-r--r--plugins/SeenPlugin/src/main.cpp31
-rw-r--r--plugins/SeenPlugin/src/missed.cpp2
-rw-r--r--plugins/SeenPlugin/src/options.cpp2
-rw-r--r--plugins/SeenPlugin/src/stdafx.h14
-rw-r--r--plugins/SeenPlugin/src/userinfo.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp53
-rw-r--r--plugins/SendScreenshotPlus/src/Main.h38
-rw-r--r--plugins/SendScreenshotPlus/src/UAboutForm.cpp14
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp10
-rw-r--r--plugins/SendScreenshotPlus/src/ctrl_button.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/dlg_msgbox.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/stdafx.h9
-rw-r--r--plugins/ShellExt/src/main.cpp33
-rw-r--r--plugins/ShellExt/src/options.cpp2
-rw-r--r--plugins/ShellExt/src/shlcom.cpp4
-rw-r--r--plugins/ShellExt/src/shlext.cpp2
-rw-r--r--plugins/ShellExt/src/stdafx.h17
-rw-r--r--plugins/ShellExt/src/utils.cpp16
-rw-r--r--plugins/SimpleAR/src/Main.cpp21
-rw-r--r--plugins/SimpleAR/src/Options.cpp2
-rw-r--r--plugins/SimpleAR/src/stdafx.h12
-rw-r--r--plugins/SimpleStatusMsg/src/awaymsg.cpp4
-rw-r--r--plugins/SimpleStatusMsg/src/main.cpp238
-rw-r--r--plugins/SimpleStatusMsg/src/msgbox.cpp88
-rw-r--r--plugins/SimpleStatusMsg/src/options.cpp148
-rw-r--r--plugins/SimpleStatusMsg/src/simplestatusmsg.h24
-rw-r--r--plugins/SimpleStatusMsg/src/stdafx.h10
-rw-r--r--plugins/SimpleStatusMsg/src/utils.cpp10
-rw-r--r--plugins/SkypeStatusChange/src/main.cpp57
-rw-r--r--plugins/SkypeStatusChange/src/options.cpp4
-rw-r--r--plugins/SkypeStatusChange/src/stdafx.h12
-rw-r--r--plugins/SmileyAdd/src/dlgboxsubclass.cpp2
-rw-r--r--plugins/SmileyAdd/src/general.cpp2
-rw-r--r--plugins/SmileyAdd/src/main.cpp25
-rw-r--r--plugins/SmileyAdd/src/options.cpp2
-rw-r--r--plugins/SmileyAdd/src/richcall.cpp2
-rw-r--r--plugins/SmileyAdd/src/smltool.cpp8
-rw-r--r--plugins/SmileyAdd/src/stdafx.h9
67 files changed, 1804 insertions, 1932 deletions
diff --git a/plugins/Popup/src/common.h b/plugins/Popup/src/common.h
index e09dc23f61..64269700b9 100644
--- a/plugins/Popup/src/common.h
+++ b/plugins/Popup/src/common.h
@@ -94,7 +94,7 @@ inline void AddTooltipTranslated(HWND hwndToolTip, HWND hwnd, int id, RECT rc, c
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwnd;
ti.uId = id;
- ti.hinst = hInst;
+ ti.hinst = g_plugin.getInst();
ti.lpszText = TranslateW(wtext);
ti.rect = rc;
SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp
index eafca08668..dc5e5dfdae 100644
--- a/plugins/Popup/src/config.cpp
+++ b/plugins/Popup/src/config.cpp
@@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
// ===== General Plugin =====
-HINSTANCE hInst;
-
HANDLE hSemaphore;
BOOL closing = FALSE;
MTEXT_INTERFACE MText = { 0 };
@@ -38,27 +36,6 @@ HBITMAP hbmNoAvatar;
// ===== Options =====
POPUPOPTIONS PopupOptions;
-// SKINELEMENT *skin;
-// SKINELEMENT *w_skin;
-// SKINELEMENT *n_skin;
-
-
-// ===== Plugin information =====
-
-PLUGININFOEX pluginInfoEx =
-{
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {26A9125D-7863-4E01-AF0E-D14EF95C5054}
- { 0x26a9125d, 0x7863, 0x4e01, { 0xaf, 0xe, 0xd1, 0x4e, 0xf9, 0x5c, 0x50, 0x54 } }
-};
-
HRESULT(WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBehind);
diff --git a/plugins/Popup/src/config.h b/plugins/Popup/src/config.h
index ae2d599e42..2819fd52f3 100644
--- a/plugins/Popup/src/config.h
+++ b/plugins/Popup/src/config.h
@@ -125,7 +125,6 @@ extern GLOBAL_WND_CLASSES g_wndClass;
void LoadOptions();
//===== General Plugin =====
-extern HINSTANCE hInst;
extern HANDLE hEventNotify;
extern HANDLE hSemaphore;
extern BOOL closing;
@@ -144,12 +143,6 @@ extern HBITMAP hbmNoAvatar;
//===== Options =====
extern POPUPOPTIONS PopupOptions;
extern bool OptionLoaded;
-//extern SKINELEMENT *skin;
-//extern SKINELEMENT *w_skin;
-//extern SKINELEMENT *n_skin;
-
-//===== Plugin informations struct =====
-extern PLUGININFOEX pluginInfoEx;
//===== Transparency & APIs which are not supported by every OS =====
#ifndef DWLP_MSGRESULT
diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp
index 5be7176009..5c191b2d7c 100644
--- a/plugins/Popup/src/history.cpp
+++ b/plugins/Popup/src/history.cpp
@@ -109,7 +109,7 @@ void PopupHistoryShow()
SetActiveWindow(hwndHistory);
}
else {
- hwndHistory = CreateDialog(hInst, MAKEINTRESOURCE(IDD_HISTORY), nullptr, HistoryDlgProc);
+ hwndHistory = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HISTORY), nullptr, HistoryDlgProc);
SetWindowText(hwndHistory, TranslateT("Popup History"));
}
}
diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp
index b1b5a985fc..525d5bbef8 100644
--- a/plugins/Popup/src/icons.cpp
+++ b/plugins/Popup/src/icons.cpp
@@ -62,9 +62,9 @@ static IconItem iconList[] =
void InitIcons()
{
- Icon_Register(hInst, SECT_POPUP, iconList, 8, MODULNAME);
- Icon_Register(hInst, SECT_POPUP SECT_POPUP_OPT, iconList + 8, 9, MODULNAME);
- Icon_Register(hInst, SECT_POPUP SECT_POPUP_ACT, iconList + 17, 9, MODULNAME);
+ Icon_Register(g_plugin.getInst(), SECT_POPUP, iconList, 8, MODULNAME);
+ Icon_Register(g_plugin.getInst(), SECT_POPUP SECT_POPUP_OPT, iconList + 8, 9, MODULNAME);
+ Icon_Register(g_plugin.getInst(), SECT_POPUP SECT_POPUP_ACT, iconList + 17, 9, MODULNAME);
}
HICON LoadIconEx(int iconId, bool big)
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp
index aaff53315c..d470ee9d8f 100644
--- a/plugins/Popup/src/main.cpp
+++ b/plugins/Popup/src/main.cpp
@@ -38,6 +38,7 @@ static int OkToExit(WPARAM, LPARAM);
bool OptionLoaded = false;
int hLangpack = 0;
CLIST_INTERFACE *pcli;
+CMPlugin g_plugin;
//===== Global variables ================================================================
HMODULE hUserDll = nullptr;
@@ -63,7 +64,7 @@ static int OptionsInitialize(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS;
odp.szTitle.a = MODULNAME_PLU;
@@ -278,18 +279,25 @@ static int ModulesLoaded(WPARAM, LPARAM)
return 0;
}
-//=== DllMain ===========================================================================
-// DLL entry point, Required to store the instance handle
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
//===== MirandaPluginInfo ===============================================================
// Called by Miranda to get the information associated to this plugin.
// It only returns the PLUGININFOEX structure, without any test on the version
// @param mirandaVersion - The version of the application calling this function
+
+PLUGININFOEX pluginInfoEx =
+{
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {26A9125D-7863-4E01-AF0E-D14EF95C5054}
+ { 0x26a9125d, 0x7863, 0x4e01, { 0xaf, 0xe, 0xd1, 0x4e, 0xf9, 0x5c, 0x50, 0x54 } }
+};
+
MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
@@ -349,7 +357,7 @@ MIRAPI int Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, OkToExit);
HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
- hbmNoAvatar = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_NOAVATAR));
+ hbmNoAvatar = LoadBitmap(g_plugin.getInst(), MAKEINTRESOURCE(IDB_NOAVATAR));
if (!OptionLoaded)
LoadOptions();
@@ -425,12 +433,12 @@ MIRAPI int Unload(void)
PopupHistoryUnload();
SrmmMenu_Unload();
- UnregisterClass(MAKEINTATOM(g_wndClass.cPopupWnd2), hInst);
- UnregisterClass(L"PopupEditBox", hInst);
- UnregisterClass(MAKEINTATOM(g_wndClass.cPopupMenuHostWnd), hInst);
- UnregisterClass(MAKEINTATOM(g_wndClass.cPopupThreadManagerWnd), hInst);
- UnregisterClass(MAKEINTATOM(g_wndClass.cPopupPreviewBoxWndclass), hInst);
- UnregisterClass(MAKEINTATOM(g_wndClass.cPopupPlusDlgBox), hInst);
+ UnregisterClass(MAKEINTATOM(g_wndClass.cPopupWnd2), g_plugin.getInst());
+ UnregisterClass(L"PopupEditBox", g_plugin.getInst());
+ UnregisterClass(MAKEINTATOM(g_wndClass.cPopupMenuHostWnd), g_plugin.getInst());
+ UnregisterClass(MAKEINTATOM(g_wndClass.cPopupThreadManagerWnd), g_plugin.getInst());
+ UnregisterClass(MAKEINTATOM(g_wndClass.cPopupPreviewBoxWndclass), g_plugin.getInst());
+ UnregisterClass(MAKEINTATOM(g_wndClass.cPopupPlusDlgBox), g_plugin.getInst());
UnloadGDIPlus();
diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp
index 3ff5656108..ff66767b68 100644
--- a/plugins/Popup/src/opt_adv.cpp
+++ b/plugins/Popup/src/opt_adv.cpp
@@ -97,7 +97,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
CW_USEDEFAULT, // Height
HWND_DESKTOP, // Parent
nullptr, // menu handle
- hInst, // Instance
+ g_plugin.getInst(), // Instance
(LPVOID)nullptr);
ShowWindow(hwndBox, SW_HIDE);
}
diff --git a/plugins/Popup/src/opt_gen.cpp b/plugins/Popup/src/opt_gen.cpp
index 3747ff1ada..0b7cdeadca 100644
--- a/plugins/Popup/src/opt_gen.cpp
+++ b/plugins/Popup/src/opt_gen.cpp
@@ -308,7 +308,7 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case IDC_CUSTOMPOS:
{
RECT rcButton, rcBox;
- HWND hwndBox = CreateDialog(hInst, MAKEINTRESOURCE(IDD_POSITION), nullptr, PositionBoxDlgProc);
+ HWND hwndBox = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POSITION), nullptr, PositionBoxDlgProc);
GetWindowRect((HWND)lParam, &rcButton);
GetWindowRect(hwndBox, &rcBox);
MoveWindow(hwndBox,
diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp
index dc78a7bab8..5dd0146177 100644
--- a/plugins/Popup/src/opt_skins.cpp
+++ b/plugins/Popup/src/opt_skins.cpp
@@ -37,13 +37,13 @@ void RegisterOptPrevBox()
wcl.style = CS_DROPSHADOW;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hIcon = nullptr;
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = nullptr; // (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = nullptr;
wcl.lpszClassName = BOXPREVIEW_WNDCLASS;
- wcl.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
+ wcl.hIconSm = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
g_wndClass.cPopupPreviewBoxWndclass = RegisterClassEx(&wcl);
err = GetLastError();
if (!g_wndClass.cPopupPreviewBoxWndclass) {
@@ -54,8 +54,8 @@ void RegisterOptPrevBox()
// register custom class for dialog box with drop-shadow attribute
// "#32770" stays for class name of default system dialog box
- GetClassInfoEx(hInst, L"#32770", &wcl);
- wcl.hInstance = hInst;
+ GetClassInfoEx(g_plugin.getInst(), L"#32770", &wcl);
+ wcl.hInstance = g_plugin.getInst();
wcl.lpszClassName = L"PopupPlusDlgBox";
wcl.style |= CS_DROPSHADOW;
g_wndClass.cPopupPlusDlgBox = RegisterClassEx(&wcl);
diff --git a/plugins/Popup/src/opttree.cpp b/plugins/Popup/src/opttree.cpp
index 68a7a9ef7a..9a6c61fd59 100644
--- a/plugins/Popup/src/opttree.cpp
+++ b/plugins/Popup/src/opttree.cpp
@@ -161,7 +161,7 @@ BOOL OptTree_ProcessMessage(HWND hwnd, UINT msg, WPARAM, LPARAM lparam, int *res
TreeView_DeleteAllItems(hwndTree);
hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1);
- ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR | LR_SHARED));
+ ImageList_ReplaceIcon(hImgLst, -1, (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR | LR_SHARED));
ImageList_ReplaceIcon(hImgLst, -1, (HICON)Skin_LoadIcon(SKINICON_OTHER_TICK));
ImageList_ReplaceIcon(hImgLst, -1, (HICON)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
ImageList_ReplaceIcon(hImgLst, -1, (HICON)Skin_LoadIcon(SKINICON_OTHER_TICK));
diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp
index 508bece260..0363613fa0 100644
--- a/plugins/Popup/src/popup_thread.cpp
+++ b/plugins/Popup/src/popup_thread.cpp
@@ -222,13 +222,13 @@ static unsigned __stdcall PopupThread(void *)
wcl.style = 0;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hIcon = nullptr;
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = nullptr;
wcl.lpszClassName = L"PopupThreadManagerWnd";
- wcl.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
+ wcl.hIconSm = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
g_wndClass.cPopupThreadManagerWnd = RegisterClassExW(&wcl);
err = GetLastError();
if (!g_wndClass.cPopupThreadManagerWnd) {
@@ -237,7 +237,7 @@ static unsigned __stdcall PopupThread(void *)
MSGERROR(msg);
}
- gHwndManager = CreateWindow(L"PopupThreadManagerWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, hInst, nullptr);
+ gHwndManager = CreateWindow(L"PopupThreadManagerWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(gHwndManager, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
MSG msg;
@@ -247,7 +247,7 @@ static unsigned __stdcall PopupThread(void *)
}
DestroyWindow(gHwndManager); gHwndManager = nullptr;
- UnregisterClassW(wcl.lpszClassName, hInst);
+ UnregisterClassW(wcl.lpszClassName, g_plugin.getInst());
return 0;
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index 63dab2976a..0f56959886 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -51,11 +51,11 @@ bool LoadPopupWnd2()
WNDCLASSEX wcl = { 0 };
wcl.cbSize = sizeof(wcl);
wcl.lpfnWndProc = PopupWnd2::WindowProc;
- wcl.hInstance = hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszClassName = POPUP_WNDCLASS;
- wcl.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
+ wcl.hIconSm = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
g_wndClass.cPopupWnd2 = RegisterClassEx(&wcl);
DWORD err = GetLastError();
if (!g_wndClass.cPopupWnd2) {
@@ -69,7 +69,7 @@ bool LoadPopupWnd2()
wclw.cbSize = sizeof(wclw);
if (!GetClassInfoEx(nullptr, L"EDIT", &wclw))
MSGERROR(TranslateT("Failed to GetClassInfoExW from EDIT class."));
- wclw.hInstance = hInst;
+ wclw.hInstance = g_plugin.getInst();
wclw.lpszClassName = L"PopupEditBox";
wclw.style |= CS_DROPSHADOW;
g_wndClass.cPopupEditBox = RegisterClassEx(&wclw);
@@ -89,13 +89,13 @@ bool LoadPopupWnd2()
wcl.style = 0;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hIcon = nullptr;
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = nullptr;
wcl.lpszClassName = L"PopupMenuHostWnd";
- wcl.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
+ wcl.hIconSm = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
g_wndClass.cPopupMenuHostWnd = RegisterClassEx(&wcl);
err = GetLastError();
if (!g_wndClass.cPopupMenuHostWnd) {
@@ -105,7 +105,7 @@ bool LoadPopupWnd2()
MSGERROR(msg);
}
- ghwndMenuHost = CreateWindow(L"PopupMenuHostWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, hInst, nullptr);
+ ghwndMenuHost = CreateWindow(L"PopupMenuHostWnd", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(ghwndMenuHost, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_HIDEWINDOW);
INITCOMMONCONTROLSEX iccex;
@@ -175,7 +175,7 @@ void PopupWnd2::create()
CW_USEDEFAULT, // Height
HWND_DESKTOP, // Parent
nullptr, // menu handle
- hInst, // Instance
+ g_plugin.getInst(), // Instance
(LPVOID)this);
// Shadows
@@ -191,7 +191,7 @@ void PopupWnd2::create()
m_hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- m_hwnd, nullptr, hInst, nullptr);
+ m_hwnd, nullptr, g_plugin.getInst(), nullptr);
SetWindowPos(m_hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
m_bWindowCreated = true;
@@ -921,7 +921,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
g_wndClass.cPopupEditBox ? L"PopupEditBox" : L"EDIT",
nullptr,
WS_BORDER | WS_POPUP | WS_VISIBLE | ES_AUTOVSCROLL | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_WANTRETURN,
- rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInst, nullptr);
+ rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, g_plugin.getInst(), nullptr);
ReplyEditData *dat = (ReplyEditData *)mir_alloc(sizeof(ReplyEditData));
dat->oldWndProc = (WNDPROC)GetWindowLongPtr(hwndEditBox, (LONG_PTR)GWLP_WNDPROC);
diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp
index bd912cf115..bef54628c8 100644
--- a/plugins/Popup/src/skin.cpp
+++ b/plugins/Popup/src/skin.cpp
@@ -843,8 +843,6 @@ void PopupSkin::loadSkin(std::wistream &f)
if (!mir_wstrcmp(buf, L"popup-version")) {
f >> m_popup_version;
m_popup_version = PLUGIN_MAKE_VERSION((m_popup_version / 1000000) % 100, (m_popup_version / 10000) % 100, (m_popup_version / 100) % 100, (m_popup_version / 1) % 100);
- if (!isCompatible())
- break;
}
else if (!mir_wstrcmp(buf, L"padding-right")) {
f >> m_right_gap;
@@ -897,8 +895,8 @@ void PopupSkin::loadSkin(LPCTSTR fn)
void PopupSkin::loadSkin(LPCTSTR lpName, LPCTSTR lpType)
{
- HRSRC hRes = FindResource(hInst, lpName, lpType);
- HRSRC hResLoad = (HRSRC)LoadResource(hInst, hRes);
+ HRSRC hRes = FindResource(g_plugin.getInst(), lpName, lpType);
+ HRSRC hResLoad = (HRSRC)LoadResource(g_plugin.getInst(), hRes);
char *lpResLock = (char *)LockResource(hResLoad);
std::wistringstream stream((wchar_t*)_A2T(lpResLock));
loadSkin(stream);
@@ -1154,12 +1152,6 @@ const PopupSkin *Skins::getSkin(LPCTSTR name)
any->skin = new PopupSkin(any->name);
any->skin->load(any->dir);
-
- if (!any->skin->isCompatible())
- MessageBox(nullptr,
- TranslateT("The skin you are trying to load is designed\r\nfor newer version of Popup plus. And will not\r\ndisplay properly.\r\n\r\nPlease choose another skin."),
- MODULNAME_LONG, MB_ICONSTOP | MB_OK);
-
return any->skin;
}
diff --git a/plugins/Popup/src/skin.h b/plugins/Popup/src/skin.h
index 7b410151db..b2c23cf37b 100644
--- a/plugins/Popup/src/skin.h
+++ b/plugins/Popup/src/skin.h
@@ -140,7 +140,6 @@ public:
int useInternalClock() const { return m_internalClock; }
int getLegacyRegionOpacity() const { return m_legacy_region_opacity; }
int getShadowRegionOpacity() const { return m_shadow_region_opacity; }
- bool isCompatible() const { return (DWORD)m_popup_version <= (DWORD)pluginInfoEx.version; }
const LPTSTR getName() const { return m_name; }
diff --git a/plugins/Popup/src/stdafx.h b/plugins/Popup/src/stdafx.h
index 0902fa6e77..ea91428de0 100644
--- a/plugins/Popup/src/stdafx.h
+++ b/plugins/Popup/src/stdafx.h
@@ -60,7 +60,6 @@ https://miranda-ng.org/distr/
#include <malloc.h>
#include <Uxtheme.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <win2k.h>
#include <m_clistint.h>
@@ -97,6 +96,19 @@ https://miranda-ng.org/distr/
#include <m_toptoolbar.h>
#include <m_hpp.h>
+#define PU_MODULCLASS "PopupCLASS" // temp DB modul for this plugin
+#define MODULNAME "Popup"
+#define MODULNAME_LONG L"Popup Plus"
+#define MODULNAME_PLU "Popups"
+#define MODULNAME_PLUW L"Popups"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULNAME)
+ {}
+};
+
#include "resource.h"
#include "defs.h"
#include "version.h"
@@ -128,12 +140,6 @@ https://miranda-ng.org/distr/
#include "avatars_gif.h"
#include "popup_gdiplus.h"
-#define PU_MODULCLASS "PopupCLASS" // temp DB modul for this plugin
-#define MODULNAME "Popup"
-#define MODULNAME_LONG L"Popup Plus"
-#define MODULNAME_PLU "Popups"
-#define MODULNAME_PLUW L"Popups"
-
INT_PTR svcEnableDisableMenuCommand(WPARAM, LPARAM);
#endif //HEADERS_H
diff --git a/plugins/ProfileManager/src/pmanagerEx.cpp b/plugins/ProfileManager/src/pmanagerEx.cpp
index fad24aae35..4cfbce533e 100644
--- a/plugins/ProfileManager/src/pmanagerEx.cpp
+++ b/plugins/ProfileManager/src/pmanagerEx.cpp
@@ -13,10 +13,20 @@ There is no warranty.
#define SRV_CHANGE_PM "Database/ChangePM"
#define SRV_RESTART_ME "System/RestartMe"
-HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+}
+g_plugin;
+
int hLangpack;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -36,14 +46,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
/////////////////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
static INT_PTR ChangePM(WPARAM, LPARAM)
{
wchar_t fn[MAX_PATH];
@@ -85,7 +87,7 @@ extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
- Icon_Register(hInst, LPGEN("Profile manager"), iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), LPGEN("Profile manager"), iconList, _countof(iconList));
CreateServiceFunction(SRV_LOAD_PM, LoadPM);
CreateServiceFunction(SRV_CHANGE_PM, ChangePM);
@@ -107,6 +109,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
diff --git a/plugins/ProfileManager/src/stdafx.h b/plugins/ProfileManager/src/stdafx.h
index 013c87b75b..26b605671a 100644
--- a/plugins/ProfileManager/src/stdafx.h
+++ b/plugins/ProfileManager/src/stdafx.h
@@ -2,7 +2,6 @@
#include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_genmenu.h>
diff --git a/plugins/QuickContacts/src/dialog.cpp b/plugins/QuickContacts/src/dialog.cpp
new file mode 100644
index 0000000000..e51d2734e2
--- /dev/null
+++ b/plugins/QuickContacts/src/dialog.cpp
@@ -0,0 +1,881 @@
+/*
+Copyright (C) 2012-18 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+#define IDC_ICO 12344
+
+#define IDC_ENTER 2000 // Pseudo control to handle enter in the main window
+
+HIMAGELIST hIml;
+
+long main_dialog_open = 0;
+HWND hwndMain = nullptr;
+
+// array where the contacts are put into
+struct c_struct
+{
+ wchar_t szname[120];
+ wchar_t szgroup[50];
+ MCONTACT hcontact;
+ wchar_t proto[20];
+
+ c_struct()
+ {
+ szname[0] = 0;
+ szgroup[0] = 0;
+ hcontact = 0;
+ proto[0] = 0;
+ }
+};
+
+LIST<c_struct> contacts(200);
+long max_proto_width;
+
+
+// Get the name the contact has in list
+// This was not made to be called by more than one thread!
+wchar_t tmp_list_name[120];
+
+wchar_t *GetListName(c_struct *cs)
+{
+ if (opts.group_append && cs->szgroup[0] != '\0') {
+ mir_snwprintf(tmp_list_name, L"%s (%s)", cs->szname, cs->szgroup);
+ return tmp_list_name;
+ }
+ else {
+ return cs->szname;
+ }
+}
+
+
+int lstreq(wchar_t *a, wchar_t *b, size_t len = -1)
+{
+ a = CharLower(wcsdup(a));
+ b = CharLower(wcsdup(b));
+ int ret;
+ if (len > 0)
+ ret = wcsncmp(a, b, len);
+ else
+ ret = mir_wstrcmp(a, b);
+ free(a);
+ free(b);
+ return ret;
+}
+
+
+// simple sorting function to have
+// the contact array in alphabetical order
+void SortArray(void)
+{
+ int loop, doop;
+ c_struct *cs_temp;
+
+ SortedList *sl = (SortedList *)&contacts;
+ for (loop = 0; loop < contacts.getCount(); loop++) {
+ for (doop = loop + 1; doop < contacts.getCount(); doop++) {
+ int cmp = lstreq(contacts[loop]->szname, contacts[doop]->szname);
+ if (cmp > 0) {
+ cs_temp = contacts[loop];
+ sl->items[loop] = contacts[doop];
+ sl->items[doop] = cs_temp;
+ }
+ else if (cmp == 0) {
+ if (lstreq(contacts[loop]->proto, contacts[doop]->proto) > 0) {
+ cs_temp = contacts[loop];
+ sl->items[loop] = contacts[doop];
+ sl->items[doop] = cs_temp;
+ }
+ }
+
+ }
+ }
+}
+
+
+int GetStatus(MCONTACT hContact, char *proto = nullptr)
+{
+ if (proto == nullptr)
+ proto = GetContactProto(hContact);
+
+ if (proto == nullptr)
+ return ID_STATUS_OFFLINE;
+
+ return db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
+}
+
+
+void FreeContacts()
+{
+ for (auto &it : contacts)
+ delete it;
+ contacts.destroy();
+}
+
+
+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, MODULE_NAME, "LastSentTo", -1);
+ SetWindowLongPtr(hwndMain, GWLP_USERDATA, (LONG_PTR)hlastsent);
+
+ // enumerate all contacts and write them to the array
+ // item data of listbox-strings is the array position
+ FreeContacts();
+
+ for (auto &hContact : Contacts()) {
+ char *pszProto = GetContactProto(hContact);
+ if (pszProto == nullptr)
+ continue;
+
+ // Get meta
+ MCONTACT hMeta = NULL;
+ if (metacontactsEnabled) {
+ if ((!show_all && opts.hide_subcontacts) || opts.group_append)
+ hMeta = db_mc_getMeta(hContact);
+ }
+ else if (!mir_strcmp(META_PROTO, pszProto))
+ continue;
+
+ if (!show_all) {
+ // Check if is offline and have to show
+ if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE) {
+ // See if has to show
+ char setting[128];
+ mir_snprintf(setting, "ShowOffline%s", pszProto);
+
+ if (!db_get_b(NULL, MODULE_NAME, setting, FALSE))
+ continue;
+
+ // Check if proto offline
+ else if (opts.hide_from_offline_proto && Proto_GetStatus(pszProto) <= ID_STATUS_OFFLINE)
+ continue;
+
+ }
+
+ // Check if is subcontact
+ if (opts.hide_subcontacts && hMeta != NULL) {
+ if (!opts.keep_subcontacts_from_offline)
+ continue;
+
+ if (GetStatus(hMeta, META_PROTO) > ID_STATUS_OFFLINE)
+ continue;
+
+ char setting[128];
+ mir_snprintf(setting, "ShowOffline%s", META_PROTO);
+ if (db_get_b(NULL, MODULE_NAME, setting, FALSE))
+ continue;
+ }
+ }
+
+ // Add to list
+
+ // Get group
+ c_struct *contact = new c_struct();
+
+ if (opts.group_append) {
+ DBVARIANT dbv;
+ if (db_get_ws(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) {
+ if (dbv.ptszVal != nullptr)
+ mir_wstrncpy(contact->szgroup, dbv.ptszVal, _countof(contact->szgroup));
+
+ db_free(&dbv);
+ }
+ }
+
+ // Make contact name
+ wchar_t *tmp = (wchar_t *)Clist_GetContactDisplayName(hContact);
+ mir_wstrncpy(contact->szname, tmp, _countof(contact->szname));
+
+ PROTOACCOUNT *acc = Proto_GetAccount(pszProto);
+ if (acc != nullptr)
+ mir_wstrncpy(contact->proto, acc->tszAccountName, _countof(contact->proto));
+
+ contact->hcontact = hContact;
+ contacts.insert(contact);
+ }
+
+ SortArray();
+
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_RESETCONTENT, 0, 0);
+ for (int loop = 0; loop < contacts.getCount(); loop++)
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_ADDSTRING, 0, (LPARAM)GetListName(contacts[loop])), loop);
+}
+
+
+// Enable buttons for the selected contact
+void EnableButtons(HWND hwndDlg, MCONTACT hContact)
+{
+ if (hContact == NULL) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_URL), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USERINFO), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HISTORY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MENU), FALSE);
+
+ SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, 0, 0);
+ }
+ else {
+ // Is a meta?
+ MCONTACT hSub = db_mc_getMostOnline(hContact);
+ if (hSub != NULL)
+ hContact = hSub;
+
+ // Get caps
+ INT_PTR caps = 0;
+
+ char *pszProto = GetContactProto(hContact);
+ if (pszProto != nullptr)
+ caps = CallProtoService(pszProto, PS_GETCAPS, PFLAGNUM_1, 0);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), caps & PF1_IMSEND ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), caps & PF1_FILESEND ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_URL), caps & PF1_URLSEND ? TRUE : FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_USERINFO), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HISTORY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_MENU), TRUE);
+
+ HICON ico = ImageList_GetIcon(hIml, Clist_GetContactIcon(hContact), ILD_IMAGE);
+ SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, (WPARAM)ico, 0);
+ }
+}
+
+
+// check if the char(s) entered appears in a contacts name
+int CheckText(HWND hdlg, wchar_t *sztext, BOOL only_enable = FALSE)
+{
+ EnableButtons(hwndMain, NULL);
+
+ if (sztext == nullptr || sztext[0] == '\0')
+ return 0;
+
+ size_t len = mir_wstrlen(sztext);
+
+ if (only_enable) {
+ for (auto &it : contacts) {
+ if (lstreq(sztext, it->szname) == 0 || lstreq(sztext, GetListName(it)) == 0) {
+ EnableButtons(hwndMain, it->hcontact);
+ return 0;
+ }
+ }
+ }
+ else {
+ for (auto &it : contacts) {
+ if (lstreq(sztext, GetListName(it), len) == 0) {
+ SetWindowText(hdlg, GetListName(it));
+ SendMessage(hdlg, EM_SETSEL, (WPARAM)len, (LPARAM)-1);
+ EnableButtons(hwndMain, it->hcontact);
+ return 0;
+ }
+ }
+ }
+
+ EnableButtons(hwndMain, NULL);
+ return 0;
+}
+
+MCONTACT GetSelectedContact(HWND hwndDlg)
+{
+ // First try selection
+ int sel = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
+
+ if (sel != CB_ERR) {
+ int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETITEMDATA, sel, 0);
+ if (pos != CB_ERR)
+ return contacts[pos]->hcontact;
+ }
+
+ // Now try the name
+ wchar_t cname[120] = L"";
+
+ GetDlgItemText(hwndDlg, IDC_USERNAME, cname, _countof(cname));
+
+ for (auto &it : contacts)
+ if (!mir_wstrcmpi(cname, GetListName(it)))
+ return it->hcontact;
+
+ return NULL;
+}
+
+// get array position from handle
+int GetItemPos(MCONTACT hcontact)
+{
+ for (auto &it : contacts)
+ if (hcontact == it->hcontact)
+ return contacts.indexOf(&it);
+
+ return -1;
+}
+
+
+// callback function for edit-box of the listbox
+// without this the autofill function isn't possible
+// this was done like ie does it..as far as spy++ could tell ;)
+LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ switch (msg) {
+ case WM_CHAR:
+ {
+ if (wparam < 32 && wparam != VK_BACK)
+ break;
+
+ wchar_t sztext[120] = L"";
+ DWORD start;
+ DWORD end;
+
+ int ret = SendMessage(hdlg, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
+
+ GetWindowText(hdlg, sztext, _countof(sztext));
+
+ BOOL at_end = (mir_wstrlen(sztext) == (int)end);
+
+ if (ret != -1) {
+ if (wparam == VK_BACK) {
+ if (start > 0)
+ SendMessage(hdlg, EM_SETSEL, (WPARAM)start - 1, (LPARAM)end);
+
+ sztext[0] = 0;
+ }
+ else {
+ sztext[0] = wparam;
+ sztext[1] = 0;
+ }
+
+ SendMessage(hdlg, EM_REPLACESEL, 0, (LPARAM)sztext);
+ GetWindowText(hdlg, sztext, _countof(sztext));
+ }
+
+ CheckText(hdlg, sztext, !at_end);
+
+ return 1;
+ }
+ case WM_KEYUP:
+ {
+ wchar_t sztext[120] = L"";
+
+ if (wparam == VK_RETURN) {
+ switch (SendMessage(GetParent(hdlg), CB_GETDROPPEDSTATE, 0, 0)) {
+ case FALSE:
+ SendMessage(GetParent(GetParent(hdlg)), WM_COMMAND, MAKEWPARAM(IDC_ENTER, STN_CLICKED), 0);
+ break;
+
+ case TRUE:
+ SendMessage(GetParent(hdlg), CB_SHOWDROPDOWN, FALSE, 0);
+ break;
+ }
+ }
+ else if (wparam == VK_DELETE) {
+ GetWindowText(hdlg, sztext, _countof(sztext));
+ CheckText(hdlg, sztext, TRUE);
+ }
+
+ return 0;
+ }
+
+ case WM_GETDLGCODE:
+ return DLGC_WANTCHARS | DLGC_WANTARROWS;
+ }
+
+ return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam);
+}
+
+HACCEL hAcct;
+HHOOK hHook;
+
+// This function filters the message queue and translates
+// the keyboard accelerators
+LRESULT CALLBACK HookProc(int code, WPARAM, LPARAM lparam)
+{
+ if (code != MSGF_DIALOGBOX)
+ return 0;
+
+ MSG *msg = (MSG*)lparam;
+
+ int action = Hotkey_Check(msg, "Quick Contacts");
+ if (action != 0) {
+ SendMessage(hwndMain, WM_COMMAND, action, 0);
+ return 1;
+ }
+
+ if (msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE) {
+ switch (SendDlgItemMessage(hwndMain, IDC_USERNAME, CB_GETDROPPEDSTATE, 0, 0)) {
+ case FALSE:
+ SendMessage(hwndMain, WM_CLOSE, 0, 0);
+ break;
+
+ case TRUE:
+ SendDlgItemMessage(hwndMain, IDC_USERNAME, CB_SHOWDROPDOWN, FALSE, 0);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
+{
+ BOOL ret;
+
+ POINT pt;
+
+ pt.x = lpRect->left;
+ pt.y = lpRect->top;
+
+ ret = ScreenToClient(hWnd, &pt);
+
+ if (!ret) return ret;
+
+ lpRect->left = pt.x;
+ lpRect->top = pt.y;
+
+
+ pt.x = lpRect->right;
+ pt.y = lpRect->bottom;
+
+ ret = ScreenToClient(hWnd, &pt);
+
+ lpRect->right = pt.x;
+ lpRect->bottom = pt.y;
+
+ return ret;
+}
+
+
+BOOL MoveWindow(HWND hWnd, const RECT &rect, BOOL bRepaint)
+{
+ return MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
+}
+
+
+static void FillButton(HWND hwndDlg, int dlgItem, wchar_t *name, wchar_t *key, HICON icon)
+{
+ wchar_t tmp[256];
+ wchar_t *full = tmp;
+
+ if (key == nullptr)
+ full = TranslateW(name);
+ else
+ mir_snwprintf(tmp, L"%s (%s)", TranslateW(name), key);
+
+ SendDlgItemMessage(hwndDlg, dlgItem, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, dlgItem, BUTTONADDTOOLTIP, (LPARAM)full, BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, dlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)icon);
+}
+
+
+static void FillCheckbox(HWND hwndDlg, int dlgItem, wchar_t *name, wchar_t *key)
+{
+ wchar_t tmp[256];
+ wchar_t *full = tmp;
+
+ if (key == nullptr)
+ full = TranslateW(name);
+ else
+ mir_snwprintf(tmp, L"%s (%s)", TranslateW(name), key);
+
+ SetDlgItemText(hwndDlg, dlgItem, full);
+}
+
+
+static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ RECT rc;
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_USERNAME), &rc);
+ ScreenToClient(hwndDlg, &rc);
+
+ CreateWindow(L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE,
+ rc.left - 20, rc.top + (rc.bottom - rc.top - 16) / 2, 16, 16, hwndDlg, (HMENU)IDC_ICO,
+ g_plugin.getInst(), nullptr);
+
+ hHook = SetWindowsHookEx(WH_MSGFILTER, HookProc, nullptr, GetCurrentThreadId());
+
+ // Combo
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, EM_LIMITTEXT, (WPARAM)119, 0);
+ mir_subclassWindow(GetWindow(GetDlgItem(hwndDlg, IDC_USERNAME), GW_CHILD), EditProc);
+
+ // Buttons
+ FillCheckbox(hwndDlg, IDC_SHOW_ALL_CONTACTS, LPGENW("Show all contacts"), NULL);
+ FillButton(hwndDlg, IDC_MESSAGE, LPGENW("Send message"), nullptr, Skin_LoadIcon(SKINICON_EVENT_MESSAGE));
+ FillButton(hwndDlg, IDC_FILE, LPGENW("Send file"), NULL, Skin_LoadIcon(SKINICON_EVENT_FILE));
+ FillButton(hwndDlg, IDC_URL, LPGENW("Send URL"), NULL, Skin_LoadIcon(SKINICON_EVENT_URL));
+ FillButton(hwndDlg, IDC_USERINFO, LPGENW("Open user info"), NULL, Skin_LoadIcon(SKINICON_OTHER_USERDETAILS));
+ FillButton(hwndDlg, IDC_HISTORY, LPGENW("Open history"), NULL, Skin_LoadIcon(SKINICON_OTHER_HISTORY));
+ FillButton(hwndDlg, IDC_MENU, LPGENW("Open contact menu"), NULL, Skin_LoadIcon(SKINICON_OTHER_DOWNARROW));
+
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETEXTENDEDUI, TRUE, 0);
+
+ Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, MODULE_NAME, "window");
+
+ LoadContacts(hwndDlg, FALSE);
+
+ EnableButtons(hwndDlg, NULL);
+ if (db_get_b(NULL, MODULE_NAME, "EnableLastSentTo", 0)) {
+ int pos = GetItemPos((MCONTACT)db_get_dw(NULL, MODULE_NAME, "LastSentTo", -1));
+ if (pos != -1) {
+ SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETCURSEL, (WPARAM)pos, 0);
+ EnableButtons(hwndDlg, contacts[pos]->hcontact);
+ }
+ }
+
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_USERNAME:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
+ EnableButtons(hwndDlg, pos < contacts.getCount() ? contacts[pos]->hcontact : NULL);
+ }
+ break;
+
+ case IDC_ENTER:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL)
+ break;
+
+ Clist_ContactDoubleClicked(hContact);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ }
+ break;
+ case IDC_MESSAGE:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MESSAGE)))
+ break;
+
+ CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ break;
+ }
+
+ case HOTKEY_FILE:
+ case IDC_FILE:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_FILE)))
+ break;
+
+ CallService(MS_FILE_SENDFILE, hContact, 0);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ }
+ break;
+
+ case HOTKEY_URL:
+ case IDC_URL:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_URL)))
+ break;
+
+ CallService(MS_URL_SENDURL, hContact, 0);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ }
+ break;
+
+ case HOTKEY_INFO:
+ case IDC_USERINFO:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_USERINFO)))
+ break;
+
+ CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ }
+ break;
+
+ case HOTKEY_HISTORY:
+ case IDC_HISTORY:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_HISTORY)))
+ break;
+
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ }
+ break;
+
+ case HOTKEY_MENU:
+ case IDC_MENU:
+ {
+ MCONTACT hContact = GetSelectedContact(hwndDlg);
+ if (hContact == NULL) {
+ SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
+ SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+ break;
+ }
+
+ // Is button enabled?
+ if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MENU)))
+ break;
+
+ RECT rc;
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_MENU), &rc);
+ HMENU hMenu = Menu_BuildContactMenu(hContact);
+ int ret = TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, nullptr);
+ DestroyMenu(hMenu);
+
+ if (ret) {
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
+ Clist_MenuProcessCommand(LOWORD(ret), MPCF_CONTACTMENU, hContact);
+ }
+
+ db_set_dw(NULL, MODULE_NAME, "LastSentTo", (DWORD)hContact);
+ }
+ break;
+
+ case HOTKEY_ALL_CONTACTS:
+ case IDC_SHOW_ALL_CONTACTS:
+ {
+ // Get old text
+ HWND hEdit = GetWindow(GetWindow(hwndDlg, GW_CHILD), GW_CHILD);
+ wchar_t sztext[120] = L"";
+
+ if (SendMessage(hEdit, EM_GETSEL, 0, 0) != -1)
+ SendMessage(hEdit, EM_REPLACESEL, 0, (LPARAM)L"");
+
+ GetWindowText(hEdit, sztext, _countof(sztext));
+
+ // Fill combo
+ BOOL all = IsDlgButtonChecked(hwndDlg, IDC_SHOW_ALL_CONTACTS);
+
+ if (LOWORD(wParam) == HOTKEY_ALL_CONTACTS) {
+ // Toggle checkbox
+ all = !all;
+ CheckDlgButton(hwndDlg, IDC_SHOW_ALL_CONTACTS, all ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ LoadContacts(hwndDlg, all);
+
+ // Return selection
+ CheckText(hEdit, sztext);
+ }
+ }
+ break;
+
+ case WM_CLOSE:
+ Utils_SaveWindowPosition(hwndDlg, NULL, MODULE_NAME, "window");
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ UnhookWindowsHookEx(hHook);
+ hwndMain = nullptr;
+ FreeContacts();
+ InterlockedExchange(&main_dialog_open, 0);
+ break;
+
+ case WM_DRAWITEM:
+ {
+ // add icons and protocol to listbox
+ LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
+
+ // Handle contact menu
+ if (lpdis->CtlID != IDC_USERNAME) {
+ if (lpdis->CtlType == ODT_MENU)
+ return Menu_DrawItem(lParam);
+ break;
+ }
+
+ // Handle combo
+ if (lpdis->itemID == -1)
+ break;
+
+ TEXTMETRIC tm;
+ int icon_width = 0, icon_height = 0;
+ RECT rc;
+
+ GetTextMetrics(lpdis->hDC, &tm);
+ ImageList_GetIconSize(hIml, &icon_width, &icon_height);
+
+ COLORREF clrfore = SetTextColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
+ COLORREF clrback = SetBkColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
+
+ FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
+
+ // Draw icon
+ rc.left = lpdis->rcItem.left + 5;
+ rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - icon_height) / 2;
+ ImageList_Draw(hIml, Clist_GetContactIcon(contacts[lpdis->itemData]->hcontact), lpdis->hDC, rc.left, rc.top, ILD_NORMAL);
+
+ // Make rect for text
+ rc.left += icon_width + 5;
+ rc.right = lpdis->rcItem.right - 1;
+ rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
+ rc.bottom = rc.top + tm.tmHeight;
+
+ // Draw Protocol
+ if (opts.num_protos > 1) {
+ if (max_proto_width == 0) {
+ // Has to be done, else the DC isnt the right one
+ // Dont ask me why
+ for (auto &it : contacts) {
+ RECT rcc = { 0, 0, 0x7FFF, 0x7FFF };
+ DrawText(lpdis->hDC, it->proto, -1, &rcc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE | DT_CALCRECT);
+ max_proto_width = max(max_proto_width, rcc.right - rcc.left);
+ }
+
+ // Fix max_proto_width
+ if (opts.group_append && opts.group_column)
+ max_proto_width = min(max_proto_width, (rc.right - rc.left) / 5);
+ else if (opts.group_append)
+ max_proto_width = min(max_proto_width, (rc.right - rc.left) / 4);
+ else
+ max_proto_width = min(max_proto_width, (rc.right - rc.left) / 3);
+ }
+
+ RECT rc_tmp = rc;
+ rc_tmp.left = rc_tmp.right - max_proto_width;
+ DrawText(lpdis->hDC, contacts[lpdis->itemData]->proto, -1, &rc_tmp, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
+ rc.right = rc_tmp.left - 5;
+ }
+
+ // Draw group
+ if (opts.group_append && opts.group_column) {
+ RECT rc_tmp = rc;
+
+ if (opts.group_column_left) {
+ rc_tmp.right = rc_tmp.left + (rc.right - rc.left) / 3;
+ rc.left = rc_tmp.right + 5;
+ }
+ else {
+ rc_tmp.left = rc_tmp.right - (rc.right - rc.left) / 3;
+ rc.right = rc_tmp.left - 5;
+ }
+
+ DrawText(lpdis->hDC, contacts[lpdis->itemData]->szgroup, -1, &rc_tmp, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
+ }
+
+ // Draw text
+ wchar_t *name;
+ if (opts.group_append && !opts.group_column)
+ name = GetListName(contacts[lpdis->itemData]);
+ else
+ name = contacts[lpdis->itemData]->szname;
+
+ DrawText(lpdis->hDC, name, -1, &rc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
+
+ // Restore old colors
+ SetTextColor(lpdis->hDC, clrfore);
+ SetBkColor(lpdis->hDC, clrback);
+ }
+ return TRUE;
+
+ case WM_MEASUREITEM:
+ {
+ LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
+
+ // Handle contact menu
+ if (lpmis->CtlID != IDC_USERNAME) {
+ if (lpmis->CtlType == ODT_MENU)
+ return Menu_MeasureItem(lParam);
+ break;
+ }
+
+ // Handle combo
+
+ TEXTMETRIC tm;
+ int icon_width = 0, icon_height = 0;
+
+ GetTextMetrics(GetDC(hwndDlg), &tm);
+ ImageList_GetIconSize(hIml, &icon_width, &icon_height);
+
+ lpmis->itemHeight = max(icon_height, tm.tmHeight);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+// Show the main dialog
+INT_PTR ShowDialog(WPARAM, LPARAM)
+{
+ // Get the icons for the listbox
+ hIml = Clist_GetImageList();
+
+ if (!main_dialog_open) {
+ InterlockedExchange(&main_dialog_open, 1);
+
+ hwndMain = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MAIN), nullptr, MainDlgProc);
+ }
+
+ // Show it
+ SetForegroundWindow(hwndMain);
+ SetFocus(hwndMain);
+ ShowWindow(hwndMain, SW_SHOW);
+ return 0;
+}
diff --git a/plugins/QuickContacts/src/options.cpp b/plugins/QuickContacts/src/options.cpp
index d018d6a20a..3904fb0756 100644
--- a/plugins/QuickContacts/src/options.cpp
+++ b/plugins/QuickContacts/src/options.cpp
@@ -50,7 +50,7 @@ void LoadOptions()
int InitOptionsCallback(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.w = LPGENW("Contacts");
odp.szTitle.w = LPGENW("Quick Contacts");
odp.pfnDlgProc = OptionsDlgProc;
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index a7330a36fc..006d1397c2 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -22,85 +22,42 @@ Boston, MA 02111-1307, USA.
// Prototypes ///////////////////////////////////////////////////////////////////////////
-PLUGININFOEX pluginInfo = {
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {F93BA59C-4F48-4F2E-8A91-77A2801527A3}
- {0xf93ba59c, 0x4f48, 0x4f2e, {0x8a, 0x91, 0x77, 0xa2, 0x80, 0x15, 0x27, 0xa3}}
-};
-
-HINSTANCE hInst;
-HIMAGELIST hIml;
int hLangpack = 0;
+CMPlugin g_plugin;
HANDLE hModulesLoaded = nullptr;
HANDLE hEventAdded = nullptr;
HANDLE hHotkeyPressed = nullptr;
-long main_dialog_open = 0;
-HWND hwndMain = nullptr;
-
-int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-int EventAdded(WPARAM wparam, LPARAM lparam);
-int HotkeyPressed(WPARAM wParam, LPARAM lParam);
INT_PTR ShowDialog(WPARAM wParam, LPARAM lParam);
void FreeContacts();
int hksModule = 0;
int hksAction = 0;
-BOOL hasNewHotkeyModule = FALSE;
-
-#define IDC_ICO 12344
-
// Functions ////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {F93BA59C-4F48-4F2E-8A91-77A2801527A3}
+ {0xf93ba59c, 0x4f48, 0x4f2e, {0x8a, 0x91, 0x77, 0xa2, 0x80, 0x15, 0x27, 0xa3}}
+};
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-extern "C" __declspec(dllexport) int Load()
-{
- mir_getLP(&pluginInfo);
+/////////////////////////////////////////////////////////////////////////////////////////
- CreateServiceFunction(MS_QC_SHOW_DIALOG, ShowDialog);
-
- // hooks
- hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- hEventAdded = HookEvent(ME_DB_EVENT_ADDED, EventAdded);
-
- return 0;
-}
-
-extern "C" __declspec(dllexport) int Unload(void)
-{
- FreeContacts();
-
- DeInitOptions();
-
- UnhookEvent(hModulesLoaded);
- UnhookEvent(hEventAdded);
-
- return 0;
-}
-
-
-// Called when all the modules are loaded
-int ModulesLoaded(WPARAM, LPARAM)
+static int ModulesLoaded(WPARAM, LPARAM)
{
InitOptions();
@@ -108,8 +65,6 @@ int ModulesLoaded(WPARAM, LPARAM)
Proto_EnumAccounts(&opts.num_protos, nullptr);
// Add hotkey to multiple services
- hasNewHotkeyModule = TRUE;
-
HOTKEYDESC hkd = {};
hkd.dwFlags = HKD_UNICODE;
hkd.pszName = "Quick Contacts/Open dialog";
@@ -168,9 +123,6 @@ int ModulesLoaded(WPARAM, LPARAM)
CallService(MS_SKIN_ADDHOTKEY, 0, (LPARAM)&hk);
}
- // Get the icons for the listbox
- hIml = Clist_GetImageList();
-
// Add menu item
CMenuItem mi;
SET_UID(mi, 0x3a3f768a, 0xcf47, 0x43d5, 0x92, 0x16, 0xe4, 0xeb, 0x93, 0xf6, 0x72, 0xfa);
@@ -182,10 +134,9 @@ int ModulesLoaded(WPARAM, LPARAM)
return 0;
}
-
// called when a message/file/url was sent
// handle of contact is set as window-userdata
-int EventAdded(WPARAM wparam, LPARAM hDbEvent)
+static int EventAdded(WPARAM wparam, LPARAM hDbEvent)
{
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
@@ -198,878 +149,28 @@ int EventAdded(WPARAM wparam, LPARAM hDbEvent)
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-#define IDC_ENTER 2000 // Pseudo control to handle enter in the main window
-
-
-// array where the contacts are put into
-struct c_struct
-{
- wchar_t szname[120];
- wchar_t szgroup[50];
- MCONTACT hcontact;
- wchar_t proto[20];
-
- c_struct()
- {
- szname[0] = 0;
- szgroup[0] = 0;
- hcontact = 0;
- proto[0] = 0;
- }
-};
-
-LIST<c_struct> contacts(200);
-long max_proto_width;
-
-
-// Get the name the contact has in list
-// This was not made to be called by more than one thread!
-wchar_t tmp_list_name[120];
-
-wchar_t *GetListName(c_struct *cs)
-{
- if (opts.group_append && cs->szgroup[0] != '\0') {
- mir_snwprintf(tmp_list_name, L"%s (%s)", cs->szname, cs->szgroup);
- return tmp_list_name;
- }
- else {
- return cs->szname;
- }
-}
-
-
-int lstreq(wchar_t *a, wchar_t *b, size_t len = -1)
-{
- a = CharLower(wcsdup(a));
- b = CharLower(wcsdup(b));
- int ret;
- if (len > 0)
- ret = wcsncmp(a, b, len);
- else
- ret = mir_wstrcmp(a, b);
- free(a);
- free(b);
- return ret;
-}
-
-
-// simple sorting function to have
-// the contact array in alphabetical order
-void SortArray(void)
-{
- int loop, doop;
- c_struct *cs_temp;
-
- SortedList *sl = (SortedList *)&contacts;
- for (loop = 0; loop < contacts.getCount(); loop++) {
- for (doop = loop + 1; doop < contacts.getCount(); doop++) {
- int cmp = lstreq(contacts[loop]->szname, contacts[doop]->szname);
- if (cmp > 0) {
- cs_temp = contacts[loop];
- sl->items[loop] = contacts[doop];
- sl->items[doop] = cs_temp;
- }
- else if (cmp == 0) {
- if (lstreq(contacts[loop]->proto, contacts[doop]->proto) > 0) {
- cs_temp = contacts[loop];
- sl->items[loop] = contacts[doop];
- sl->items[doop] = cs_temp;
- }
- }
-
- }
- }
-}
-
-
-int GetStatus(MCONTACT hContact, char *proto = nullptr)
-{
- if (proto == nullptr)
- proto = GetContactProto(hContact);
-
- if (proto == nullptr)
- return ID_STATUS_OFFLINE;
-
- return db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
-}
-
-
-void FreeContacts()
-{
- for (auto &it : contacts)
- delete it;
- contacts.destroy();
-}
-
-
-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, MODULE_NAME, "LastSentTo", -1);
- SetWindowLongPtr(hwndMain, GWLP_USERDATA, (LONG_PTR)hlastsent);
-
- // enumerate all contacts and write them to the array
- // item data of listbox-strings is the array position
- FreeContacts();
-
- for (auto &hContact : Contacts()) {
- char *pszProto = GetContactProto(hContact);
- if (pszProto == nullptr)
- continue;
-
- // Get meta
- MCONTACT hMeta = NULL;
- if (metacontactsEnabled) {
- if ((!show_all && opts.hide_subcontacts) || opts.group_append)
- hMeta = db_mc_getMeta(hContact);
- }
- else if (!mir_strcmp(META_PROTO, pszProto))
- continue;
-
- if (!show_all) {
- // Check if is offline and have to show
- if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE) {
- // See if has to show
- char setting[128];
- mir_snprintf(setting, "ShowOffline%s", pszProto);
-
- if (!db_get_b(NULL, MODULE_NAME, setting, FALSE))
- continue;
-
- // Check if proto offline
- else if (opts.hide_from_offline_proto && Proto_GetStatus(pszProto) <= ID_STATUS_OFFLINE)
- continue;
-
- }
-
- // Check if is subcontact
- if (opts.hide_subcontacts && hMeta != NULL) {
- if (!opts.keep_subcontacts_from_offline)
- continue;
-
- if (GetStatus(hMeta, META_PROTO) > ID_STATUS_OFFLINE)
- continue;
-
- char setting[128];
- mir_snprintf(setting, "ShowOffline%s", META_PROTO);
- if (db_get_b(NULL, MODULE_NAME, setting, FALSE))
- continue;
- }
- }
-
- // Add to list
-
- // Get group
- c_struct *contact = new c_struct();
-
- if (opts.group_append) {
- DBVARIANT dbv;
- if (db_get_ws(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) {
- if (dbv.ptszVal != nullptr)
- mir_wstrncpy(contact->szgroup, dbv.ptszVal, _countof(contact->szgroup));
-
- db_free(&dbv);
- }
- }
-
- // Make contact name
- wchar_t *tmp = (wchar_t *)Clist_GetContactDisplayName(hContact);
- mir_wstrncpy(contact->szname, tmp, _countof(contact->szname));
-
- PROTOACCOUNT *acc = Proto_GetAccount(pszProto);
- if (acc != nullptr)
- mir_wstrncpy(contact->proto, acc->tszAccountName, _countof(contact->proto));
-
- contact->hcontact = hContact;
- contacts.insert(contact);
- }
-
- SortArray();
-
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_RESETCONTENT, 0, 0);
- for (int loop = 0; loop < contacts.getCount(); loop++)
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_ADDSTRING, 0, (LPARAM)GetListName(contacts[loop])), loop);
-}
-
-
-// Enable buttons for the selected contact
-void EnableButtons(HWND hwndDlg, MCONTACT hContact)
-{
- if (hContact == NULL) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_URL), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_USERINFO), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_HISTORY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_MENU), FALSE);
-
- SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, 0, 0);
- }
- else {
- // Is a meta?
- MCONTACT hSub = db_mc_getMostOnline(hContact);
- if (hSub != NULL)
- hContact = hSub;
-
- // Get caps
- INT_PTR caps = 0;
-
- char *pszProto = GetContactProto(hContact);
- if (pszProto != nullptr)
- caps = CallProtoService(pszProto, PS_GETCAPS, PFLAGNUM_1, 0);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), caps & PF1_IMSEND ? TRUE : FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), caps & PF1_FILESEND ? TRUE : FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_URL), caps & PF1_URLSEND ? TRUE : FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_USERINFO), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_HISTORY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_MENU), TRUE);
-
- HICON ico = ImageList_GetIcon(hIml, Clist_GetContactIcon(hContact), ILD_IMAGE);
- SendDlgItemMessage(hwndDlg, IDC_ICO, STM_SETICON, (WPARAM)ico, 0);
- }
-}
-
-
-// check if the char(s) entered appears in a contacts name
-int CheckText(HWND hdlg, wchar_t *sztext, BOOL only_enable = FALSE)
-{
- EnableButtons(hwndMain, NULL);
-
- if (sztext == nullptr || sztext[0] == '\0')
- return 0;
-
- size_t len = mir_wstrlen(sztext);
-
- if (only_enable) {
- for (auto &it : contacts) {
- if (lstreq(sztext, it->szname) == 0 || lstreq(sztext, GetListName(it)) == 0) {
- EnableButtons(hwndMain, it->hcontact);
- return 0;
- }
- }
- }
- else {
- for (auto &it : contacts) {
- if (lstreq(sztext, GetListName(it), len) == 0) {
- SetWindowText(hdlg, GetListName(it));
- SendMessage(hdlg, EM_SETSEL, (WPARAM)len, (LPARAM)-1);
- EnableButtons(hwndMain, it->hcontact);
- return 0;
- }
- }
- }
-
- EnableButtons(hwndMain, NULL);
- return 0;
-}
-
-MCONTACT GetSelectedContact(HWND hwndDlg)
-{
- // First try selection
- int sel = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
-
- if (sel != CB_ERR) {
- int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETITEMDATA, sel, 0);
- if (pos != CB_ERR)
- return contacts[pos]->hcontact;
- }
-
- // Now try the name
- wchar_t cname[120] = L"";
-
- GetDlgItemText(hwndDlg, IDC_USERNAME, cname, _countof(cname));
-
- for (auto &it : contacts)
- if (!mir_wstrcmpi(cname, GetListName(it)))
- return it->hcontact;
-
- return NULL;
-}
-
-// get array position from handle
-int GetItemPos(MCONTACT hcontact)
-{
- for (auto &it : contacts)
- if (hcontact == it->hcontact)
- return contacts.indexOf(&it);
-
- return -1;
-}
-
-
-// callback function for edit-box of the listbox
-// without this the autofill function isn't possible
-// this was done like ie does it..as far as spy++ could tell ;)
-LRESULT CALLBACK EditProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
-{
- switch (msg) {
- case WM_CHAR:
- {
- if (wparam < 32 && wparam != VK_BACK)
- break;
-
- wchar_t sztext[120] = L"";
- DWORD start;
- DWORD end;
-
- int ret = SendMessage(hdlg, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
-
- GetWindowText(hdlg, sztext, _countof(sztext));
-
- BOOL at_end = (mir_wstrlen(sztext) == (int)end);
-
- if (ret != -1) {
- if (wparam == VK_BACK) {
- if (start > 0)
- SendMessage(hdlg, EM_SETSEL, (WPARAM)start - 1, (LPARAM)end);
-
- sztext[0] = 0;
- }
- else {
- sztext[0] = wparam;
- sztext[1] = 0;
- }
-
- SendMessage(hdlg, EM_REPLACESEL, 0, (LPARAM)sztext);
- GetWindowText(hdlg, sztext, _countof(sztext));
- }
-
- CheckText(hdlg, sztext, !at_end);
-
- return 1;
- }
- case WM_KEYUP:
- {
- wchar_t sztext[120] = L"";
-
- if (wparam == VK_RETURN) {
- switch (SendMessage(GetParent(hdlg), CB_GETDROPPEDSTATE, 0, 0)) {
- case FALSE:
- SendMessage(GetParent(GetParent(hdlg)), WM_COMMAND, MAKEWPARAM(IDC_ENTER, STN_CLICKED), 0);
- break;
-
- case TRUE:
- SendMessage(GetParent(hdlg), CB_SHOWDROPDOWN, FALSE, 0);
- break;
- }
- }
- else if (wparam == VK_DELETE) {
- GetWindowText(hdlg, sztext, _countof(sztext));
- CheckText(hdlg, sztext, TRUE);
- }
-
- return 0;
- }
-
- case WM_GETDLGCODE:
- return DLGC_WANTCHARS | DLGC_WANTARROWS;
- }
-
- return mir_callNextSubclass(hdlg, EditProc, msg, wparam, lparam);
-}
-
-HACCEL hAcct;
-HHOOK hHook;
-
-// This function filters the message queue and translates
-// the keyboard accelerators
-LRESULT CALLBACK HookProc(int code, WPARAM, LPARAM lparam)
+extern "C" __declspec(dllexport) int Load()
{
- if (code != MSGF_DIALOGBOX)
- return 0;
-
- MSG *msg = (MSG*)lparam;
-
- if (hasNewHotkeyModule) {
- int action = Hotkey_Check(msg, "Quick Contacts");
- if (action != 0) {
- SendMessage(hwndMain, WM_COMMAND, action, 0);
- return 1;
- }
- }
- else {
- HWND htemp = msg->hwnd;
- msg->hwnd = hwndMain;
-
- if (TranslateAccelerator(msg->hwnd, hAcct, msg))
- return 1;
-
- msg->hwnd = htemp;
- }
+ mir_getLP(&pluginInfo);
- if (msg->message == WM_KEYDOWN && msg->wParam == VK_ESCAPE) {
- switch (SendDlgItemMessage(hwndMain, IDC_USERNAME, CB_GETDROPPEDSTATE, 0, 0)) {
- case FALSE:
- SendMessage(hwndMain, WM_CLOSE, 0, 0);
- break;
+ CreateServiceFunction(MS_QC_SHOW_DIALOG, ShowDialog);
- case TRUE:
- SendDlgItemMessage(hwndMain, IDC_USERNAME, CB_SHOWDROPDOWN, FALSE, 0);
- break;
- }
- }
+ // hooks
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ hEventAdded = HookEvent(ME_DB_EVENT_ADDED, EventAdded);
return 0;
}
-BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
-{
- BOOL ret;
-
- POINT pt;
-
- pt.x = lpRect->left;
- pt.y = lpRect->top;
-
- ret = ScreenToClient(hWnd, &pt);
-
- if (!ret) return ret;
-
- lpRect->left = pt.x;
- lpRect->top = pt.y;
-
-
- pt.x = lpRect->right;
- pt.y = lpRect->bottom;
-
- ret = ScreenToClient(hWnd, &pt);
-
- lpRect->right = pt.x;
- lpRect->bottom = pt.y;
-
- return ret;
-}
-
-
-BOOL MoveWindow(HWND hWnd, const RECT &rect, BOOL bRepaint)
-{
- return MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
-}
-
-
-static void FillButton(HWND hwndDlg, int dlgItem, wchar_t *name, wchar_t *key, HICON icon)
-{
- wchar_t tmp[256];
- wchar_t *full = tmp;
-
- if (key == nullptr)
- full = TranslateW(name);
- else
- mir_snwprintf(tmp, L"%s (%s)", TranslateW(name), key);
-
- SendDlgItemMessage(hwndDlg, dlgItem, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, dlgItem, BUTTONADDTOOLTIP, (LPARAM)full, BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, dlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)icon);
-}
-
-
-static void FillCheckbox(HWND hwndDlg, int dlgItem, wchar_t *name, wchar_t *key)
-{
- wchar_t tmp[256];
- wchar_t *full = tmp;
-
- if (key == nullptr)
- full = TranslateW(name);
- else
- mir_snwprintf(tmp, L"%s (%s)", TranslateW(name), key);
-
- SetDlgItemText(hwndDlg, dlgItem, full);
-}
-
-
-static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- {
- RECT rc;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_USERNAME), &rc);
- ScreenToClient(hwndDlg, &rc);
-
- CreateWindow(L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_ICON | SS_CENTERIMAGE,
- rc.left - 20, rc.top + (rc.bottom - rc.top - 16) / 2, 16, 16, hwndDlg, (HMENU)IDC_ICO,
- hInst, nullptr);
-
- if (!hasNewHotkeyModule)
- hAcct = LoadAccelerators(hInst, MAKEINTRESOURCE(ACCEL_TABLE));
-
- hHook = SetWindowsHookEx(WH_MSGFILTER, HookProc, nullptr, GetCurrentThreadId());
-
- // Combo
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, EM_LIMITTEXT, (WPARAM)119, 0);
- mir_subclassWindow(GetWindow(GetDlgItem(hwndDlg, IDC_USERNAME), GW_CHILD), EditProc);
-
- // Buttons
- FillCheckbox(hwndDlg, IDC_SHOW_ALL_CONTACTS, LPGENW("Show all contacts"), hasNewHotkeyModule ? NULL : L"Ctrl+A");
- FillButton(hwndDlg, IDC_MESSAGE, LPGENW("Send message"), nullptr, Skin_LoadIcon(SKINICON_EVENT_MESSAGE));
- FillButton(hwndDlg, IDC_FILE, LPGENW("Send file"), hasNewHotkeyModule ? NULL : L"Ctrl+F", Skin_LoadIcon(SKINICON_EVENT_FILE));
- FillButton(hwndDlg, IDC_URL, LPGENW("Send URL"), hasNewHotkeyModule ? NULL : L"Ctrl+U", Skin_LoadIcon(SKINICON_EVENT_URL));
- FillButton(hwndDlg, IDC_USERINFO, LPGENW("Open user info"), hasNewHotkeyModule ? NULL : L"Ctrl+I", Skin_LoadIcon(SKINICON_OTHER_USERDETAILS));
- FillButton(hwndDlg, IDC_HISTORY, LPGENW("Open history"), hasNewHotkeyModule ? NULL : L"Ctrl+H", Skin_LoadIcon(SKINICON_OTHER_HISTORY));
- FillButton(hwndDlg, IDC_MENU, LPGENW("Open contact menu"), hasNewHotkeyModule ? NULL : L"Ctrl+M", Skin_LoadIcon(SKINICON_OTHER_DOWNARROW));
-
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETEXTENDEDUI, TRUE, 0);
-
- Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, MODULE_NAME, "window");
-
- LoadContacts(hwndDlg, FALSE);
-
- EnableButtons(hwndDlg, NULL);
- if (db_get_b(NULL, MODULE_NAME, "EnableLastSentTo", 0)) {
- int pos = GetItemPos((MCONTACT)db_get_dw(NULL, MODULE_NAME, "LastSentTo", -1));
- if (pos != -1) {
- SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_SETCURSEL, (WPARAM)pos, 0);
- EnableButtons(hwndDlg, contacts[pos]->hcontact);
- }
- }
-
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- }
- return TRUE;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_USERNAME:
- if (HIWORD(wParam) == CBN_SELCHANGE) {
- int pos = SendDlgItemMessage(hwndDlg, IDC_USERNAME, CB_GETCURSEL, 0, 0);
- EnableButtons(hwndDlg, pos < contacts.getCount() ? contacts[pos]->hcontact : NULL);
- }
- break;
-
- case IDC_ENTER:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL)
- break;
-
- Clist_ContactDoubleClicked(hContact);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- }
- break;
- case IDC_MESSAGE:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MESSAGE)))
- break;
-
- CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- break;
- }
-
- case HOTKEY_FILE:
- case IDC_FILE:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_FILE)))
- break;
-
- CallService(MS_FILE_SENDFILE, hContact, 0);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- }
- break;
-
- case HOTKEY_URL:
- case IDC_URL:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_URL)))
- break;
-
- CallService(MS_URL_SENDURL, hContact, 0);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- }
- break;
-
- case HOTKEY_INFO:
- case IDC_USERINFO:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_USERINFO)))
- break;
-
- CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- }
- break;
-
- case HOTKEY_HISTORY:
- case IDC_HISTORY:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_HISTORY)))
- break;
-
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0);
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", hContact);
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- }
- break;
-
- case HOTKEY_MENU:
- case IDC_MENU:
- {
- MCONTACT hContact = GetSelectedContact(hwndDlg);
- if (hContact == NULL) {
- SetDlgItemText(hwndDlg, IDC_USERNAME, L"");
- SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
- break;
- }
-
- // Is button enabled?
- if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_MENU)))
- break;
-
- RECT rc;
- GetWindowRect(GetDlgItem(hwndDlg, IDC_MENU), &rc);
- HMENU hMenu = Menu_BuildContactMenu(hContact);
- int ret = TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, nullptr);
- DestroyMenu(hMenu);
-
- if (ret) {
- SendMessage(hwndDlg, WM_CLOSE, 0, 0);
- Clist_MenuProcessCommand(LOWORD(ret), MPCF_CONTACTMENU, hContact);
- }
-
- db_set_dw(NULL, MODULE_NAME, "LastSentTo", (DWORD)hContact);
- }
- break;
-
- case HOTKEY_ALL_CONTACTS:
- case IDC_SHOW_ALL_CONTACTS:
- {
- // Get old text
- HWND hEdit = GetWindow(GetWindow(hwndDlg, GW_CHILD), GW_CHILD);
- wchar_t sztext[120] = L"";
-
- if (SendMessage(hEdit, EM_GETSEL, 0, 0) != -1)
- SendMessage(hEdit, EM_REPLACESEL, 0, (LPARAM)L"");
-
- GetWindowText(hEdit, sztext, _countof(sztext));
-
- // Fill combo
- BOOL all = IsDlgButtonChecked(hwndDlg, IDC_SHOW_ALL_CONTACTS);
-
- if (LOWORD(wParam) == HOTKEY_ALL_CONTACTS) {
- // Toggle checkbox
- all = !all;
- CheckDlgButton(hwndDlg, IDC_SHOW_ALL_CONTACTS, all ? BST_CHECKED : BST_UNCHECKED);
- }
-
- LoadContacts(hwndDlg, all);
-
- // Return selection
- CheckText(hEdit, sztext);
- }
- }
- break;
-
- case WM_CLOSE:
- Utils_SaveWindowPosition(hwndDlg, NULL, MODULE_NAME, "window");
- DestroyWindow(hwndDlg);
- break;
-
- case WM_DESTROY:
- UnhookWindowsHookEx(hHook);
- hwndMain = nullptr;
- FreeContacts();
- InterlockedExchange(&main_dialog_open, 0);
- break;
-
- case WM_DRAWITEM:
- {
- // add icons and protocol to listbox
- LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
-
- // Handle contact menu
- if (lpdis->CtlID != IDC_USERNAME) {
- if (lpdis->CtlType == ODT_MENU)
- return Menu_DrawItem(lParam);
- break;
- }
-
- // Handle combo
- if (lpdis->itemID == -1)
- break;
-
- TEXTMETRIC tm;
- int icon_width = 0, icon_height = 0;
- RECT rc;
-
- GetTextMetrics(lpdis->hDC, &tm);
- ImageList_GetIconSize(hIml, &icon_width, &icon_height);
-
- COLORREF clrfore = SetTextColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
- COLORREF clrback = SetBkColor(lpdis->hDC, GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
-
- FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW));
-
- // Draw icon
- rc.left = lpdis->rcItem.left + 5;
- rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - icon_height) / 2;
- ImageList_Draw(hIml, Clist_GetContactIcon(contacts[lpdis->itemData]->hcontact), lpdis->hDC, rc.left, rc.top, ILD_NORMAL);
-
- // Make rect for text
- rc.left += icon_width + 5;
- rc.right = lpdis->rcItem.right - 1;
- rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
- rc.bottom = rc.top + tm.tmHeight;
-
- // Draw Protocol
- if (opts.num_protos > 1) {
- if (max_proto_width == 0) {
- // Has to be done, else the DC isnt the right one
- // Dont ask me why
- for (auto &it : contacts) {
- RECT rcc = { 0, 0, 0x7FFF, 0x7FFF };
- DrawText(lpdis->hDC, it->proto, -1, &rcc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE | DT_CALCRECT);
- max_proto_width = max(max_proto_width, rcc.right - rcc.left);
- }
-
- // Fix max_proto_width
- if (opts.group_append && opts.group_column)
- max_proto_width = min(max_proto_width, (rc.right - rc.left) / 5);
- else if (opts.group_append)
- max_proto_width = min(max_proto_width, (rc.right - rc.left) / 4);
- else
- max_proto_width = min(max_proto_width, (rc.right - rc.left) / 3);
- }
-
- RECT rc_tmp = rc;
- rc_tmp.left = rc_tmp.right - max_proto_width;
- DrawText(lpdis->hDC, contacts[lpdis->itemData]->proto, -1, &rc_tmp, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
- rc.right = rc_tmp.left - 5;
- }
-
- // Draw group
- if (opts.group_append && opts.group_column) {
- RECT rc_tmp = rc;
-
- if (opts.group_column_left) {
- rc_tmp.right = rc_tmp.left + (rc.right - rc.left) / 3;
- rc.left = rc_tmp.right + 5;
- }
- else {
- rc_tmp.left = rc_tmp.right - (rc.right - rc.left) / 3;
- rc.right = rc_tmp.left - 5;
- }
-
- DrawText(lpdis->hDC, contacts[lpdis->itemData]->szgroup, -1, &rc_tmp, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
- }
-
- // Draw text
- wchar_t *name;
- if (opts.group_append && !opts.group_column)
- name = GetListName(contacts[lpdis->itemData]);
- else
- name = contacts[lpdis->itemData]->szname;
-
- DrawText(lpdis->hDC, name, -1, &rc, DT_END_ELLIPSIS | DT_NOPREFIX | DT_SINGLELINE);
-
- // Restore old colors
- SetTextColor(lpdis->hDC, clrfore);
- SetBkColor(lpdis->hDC, clrback);
- }
- return TRUE;
-
- case WM_MEASUREITEM:
- {
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
-
- // Handle contact menu
- if (lpmis->CtlID != IDC_USERNAME) {
- if (lpmis->CtlType == ODT_MENU)
- return Menu_MeasureItem(lParam);
- break;
- }
-
- // Handle combo
-
- TEXTMETRIC tm;
- int icon_width = 0, icon_height = 0;
-
- GetTextMetrics(GetDC(hwndDlg), &tm);
- ImageList_GetIconSize(hIml, &icon_width, &icon_height);
-
- lpmis->itemHeight = max(icon_height, tm.tmHeight);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
+/////////////////////////////////////////////////////////////////////////////////////////
-// Show the main dialog
-INT_PTR ShowDialog(WPARAM, LPARAM)
+extern "C" __declspec(dllexport) int Unload(void)
{
- if (!main_dialog_open) {
- InterlockedExchange(&main_dialog_open, 1);
-
- hwndMain = CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), nullptr, MainDlgProc);
- }
+ FreeContacts();
- // Show it
- SetForegroundWindow(hwndMain);
- SetFocus(hwndMain);
- ShowWindow(hwndMain, SW_SHOW);
+ DeInitOptions();
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hEventAdded);
return 0;
}
diff --git a/plugins/QuickContacts/src/stdafx.h b/plugins/QuickContacts/src/stdafx.h
index b349233266..842eee329e 100644
--- a/plugins/QuickContacts/src/stdafx.h
+++ b/plugins/QuickContacts/src/stdafx.h
@@ -25,7 +25,6 @@ Boston, MA 02111-1307, USA.
#include <windows.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_protosvc.h>
#include <m_clist.h>
@@ -52,13 +51,14 @@ Boston, MA 02111-1307, USA.
#include "options.h"
#include "version.h"
-#define MODULE_NAME "QuickContacts"
+#define MODULE_NAME "QuickContacts"
-
-// Global Variables
-extern HINSTANCE hInst;
-
-// Copied from "../modernb/clc.h" ///////////////////////////////////////////////////////////////////
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE_NAME)
+ {}
+};
//add a new hotkey so it has a default and can be changed in the options dialog
//wParam=0
@@ -78,6 +78,4 @@ typedef struct {
#define MS_SKIN_ADDHOTKEY "Skin/HotKeys/AddNew"
#define MS_SKIN_PLAYHOTKEY "Skin/HotKeys/Run"
-
-
#endif // __COMMONS_H__
diff --git a/plugins/RemovePersonalSettings/src/rps.cpp b/plugins/RemovePersonalSettings/src/rps.cpp
index b1ec8ef5b2..6038030e57 100644
--- a/plugins/RemovePersonalSettings/src/rps.cpp
+++ b/plugins/RemovePersonalSettings/src/rps.cpp
@@ -28,14 +28,22 @@ Based on work by nullbie
#include "stdafx.h"
-HINSTANCE hInst;
-char gIniFile[MAX_PATH];
-char gMirandaDir[MAX_PATH];
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+}
+g_plugin;
int hLangpack;
+char gIniFile[MAX_PATH];
+char gMirandaDir[MAX_PATH];
-PLUGININFOEX pluginInfo={
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -48,122 +56,221 @@ PLUGININFOEX pluginInfo={
{ 0x60e94b84, 0xa799, 0x4021, { 0x94, 0x49, 0x5b, 0x83, 0x8f, 0xc0, 0x6a, 0x7c } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
-INT_PTR RemoveAllService(WPARAM wParam,LPARAM lParam);
-void SetProtocolsOffline();
-void RemoveUsers();
-void RemoveSettings();
-void ExecuteServices();
-void RemoveDirectories();
-void DisablePlugins();
+/////////////////////////////////////////////////////////////////////////////////////////
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_REMOVEPERSONALSETTINGS, MIID_LAST };
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Ini access functions
-BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue);
-BOOL GetSettings(const char *section, char *buffer, size_t bufferSize);
+BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue)
+{
+ char tmp[16];
+ if (GetPrivateProfileStringA(section, key, defaultValue ? "true" : "false", tmp, sizeof(tmp), gIniFile) == 0)
+ return defaultValue;
-// Utils
-void DeleteFileOrFolder(const char *name);
-void DeleteSetting(const char *setting);
-void DeleteSettingEx(const char *szModule, const char *szSetting);
-BOOL isMetaContact(MCONTACT hContact);
+ return mir_strcmpi(tmp, "true") == 0;
+}
+BOOL GetSettings(const char *section, char *buffer, size_t bufferSize)
+{
+ buffer[0] = '\0\0';
+ return (BOOL)GetPrivateProfileSectionA(section, buffer, (DWORD)bufferSize, gIniFile) != 0;
+}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Utils
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ,LPVOID )
+void DeleteFileOrFolder(const char *name)
{
- hInst=hinstDLL;
- return TRUE;
+ DWORD attibs = GetFileAttributesA(name);
+
+ if (attibs == INVALID_FILE_ATTRIBUTES) { // Not exists
+ // Try to find it
+ char tmp[MAX_PATH];
+ char *strTmp;
+
+ // Delete files
+ WIN32_FIND_DATAA findData;
+ HANDLE hwnd = FindFirstFileA(name, &findData);
+ if (hwnd != INVALID_HANDLE_VALUE) {
+ strncpy(tmp, name, sizeof(tmp) - 1);
+ strTmp = strrchr(tmp, '\\');
+
+ if (strTmp != nullptr) {
+ strTmp++;
+ *strTmp = '\0';
+ }
+ else {
+ mir_strcat(tmp, "\\");
+ strTmp = &tmp[mir_strlen(tmp)];
+ }
+
+ do {
+ if (mir_strcmp(findData.cFileName, ".") && mir_strcmp(findData.cFileName, "..")) {
+ mir_strcpy(strTmp, findData.cFileName);
+ DeleteFileOrFolder(tmp);
+ }
+ } while (FindNextFileA(hwnd, &findData) != 0);
+
+ FindClose(hwnd);
+ }
+ }
+ else if (attibs & FILE_ATTRIBUTE_DIRECTORY) { // Is a directory
+ // Get all files and delete then
+ char tmp[MAX_PATH];
+ mir_snprintf(tmp, "%s\\*.*", name);
+
+ // Delete files
+ WIN32_FIND_DATAA findData;
+ HANDLE hwnd = FindFirstFileA(tmp, &findData);
+ if (hwnd != INVALID_HANDLE_VALUE) {
+ do {
+ if (mir_strcmp(findData.cFileName, ".") && mir_strcmp(findData.cFileName, "..")) {
+ mir_snprintf(tmp, "%s\\%s", name, findData.cFileName);
+ DeleteFileOrFolder(tmp);
+ }
+ } while (FindNextFileA(hwnd, &findData) != 0);
+
+ FindClose(hwnd);
+ }
+
+ // Delete directory
+ RemoveDirectoryA(name);
+ }
+ else { // Is a File
+ SetFileAttributesA(name, FILE_ATTRIBUTE_ARCHIVE);
+ DeleteFileA(name);
+ }
}
+struct DeleteModuleStruct
+{
+ char buffer[10000];
+ size_t pos;
+ const char *filter;
+ size_t lenFilterMinusOne;
+};
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+int EnumProc(const char *szName, void *lParam)
{
- return &pluginInfo;
-}
+ DeleteModuleStruct *dms = (DeleteModuleStruct *)lParam;
+ size_t len = mir_strlen(szName);
+ if (dms->filter != nullptr && dms->lenFilterMinusOne > 0) {
+ if (len >= dms->lenFilterMinusOne) {
+ if (dms->filter[0] == '*') {
+ if (mir_strcmp(&dms->filter[1], &szName[len - dms->lenFilterMinusOne]) != 0)
+ return 0;
+ }
+ else { // if (dms->filter[dms->lenFilterMinusOne] == '*')
+ if (strncmp(dms->filter, szName, dms->lenFilterMinusOne) != 0)
+ return 0;
+ }
+ }
+ }
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_REMOVEPERSONALSETTINGS, MIID_LAST };
+ // Add to the struct
+ if (len > 0 && len < sizeof(dms->buffer) - dms->pos - 2) {
+ mir_strcpy(&dms->buffer[dms->pos], szName);
+ dms->pos += len + 1;
+ }
+ return 0;
+}
-extern "C" int __declspec(dllexport) Load()
+int ModuleEnumProc(const char *szName, void *lParam)
{
- mir_getLP(&pluginInfo);
+ return EnumProc(szName, lParam);
+}
- char *strTmp;
+void DeleteSettingEx(const char *szModule, const char *szSetting)
+{
+ size_t lenModule;
- CMenuItem mi;
- SET_UID(mi, 0x2f9f21df, 0xf33c, 0x4640, 0xb9, 0x63, 0xd3, 0x26, 0x8a, 0xb8, 0xb1, 0xf0);
- mi.position = -0x7FFFFFFF;
- mi.hIcolibItem = Skin_LoadIcon(SKINICON_OTHER_MIRANDA);
- mi.name.a = LPGEN("Remove Personal Settings...");
- mi.pszService="RemovePersonalSettings/RemoveAll";
- Menu_AddMainMenuItem(&mi);
- CreateServiceFunction(mi.pszService, RemoveAllService);
+ if (szModule == nullptr)
+ return;
- // Get ini file name
- gMirandaDir[0] = '\0';
- GetModuleFileNameA(GetModuleHandle(nullptr),gMirandaDir,sizeof(gMirandaDir));
+ lenModule = mir_strlen(szModule);
+ if (szModule[0] == '*' || szModule[lenModule - 1] == '*') {
+ DeleteModuleStruct dms;
+ memset(&dms, 0, sizeof(dms));
- // Remove last name
- strTmp = strrchr(gMirandaDir,'\\');
- if(strTmp != nullptr)
- *strTmp = '\0';
+ dms.filter = szModule;
+ dms.lenFilterMinusOne = lenModule - 1;
- // Set vars
- mir_strcat(gMirandaDir, "\\");
- mir_strcpy(gIniFile, gMirandaDir);
+ db_enum_modules(ModuleEnumProc, &dms);
- // Store last pos
- strTmp = &gIniFile[mir_strlen(gIniFile)];
+ // Delete then
+ szModule = dms.buffer;
+ while (szModule[0] != '\0') {
+ DeleteSettingEx(szModule, szSetting);
- // Lets try fist name
- mir_strcpy(strTmp, INI_FILE_NAME);
+ // Get next one
+ szModule += mir_strlen(szModule) + 1;
+ }
+ }
+ else {
+ size_t lenSetting = szSetting == nullptr ? 0 : mir_strlen(szSetting);
+ if (szSetting == nullptr || szSetting[0] == '*' || szSetting[lenSetting - 1] == '*') {
+ DeleteModuleStruct dms;
+ memset(&dms, 0, sizeof(dms));
+ dms.filter = szSetting;
+ dms.lenFilterMinusOne = lenSetting - 1;
+ db_enum_settings(NULL, EnumProc, szModule, &dms);
- if (_access(gIniFile, 4) != 0) {
- // Not found, lets try the other aproach
- mir_strcpy(strTmp, "plugins\\" INI_FILE_NAME);
+ // Delete then
+ szSetting = dms.buffer;
+ while (szSetting[0] != '\0') {
+ db_unset(NULL, szModule, szSetting);
- if (_access(gIniFile, 4) != 0) {
- // Not found :(
- gIniFile[0] = '\0';
+ // Get next one
+ szSetting += mir_strlen(szSetting) + 1;
+ }
+ }
+ else {
+ db_unset(NULL, szModule, szSetting);
}
}
-
- return 0;
}
-
-extern "C" int __declspec(dllexport) Unload(void)
+void DeleteSetting(const char *setting)
{
- return 0;
-}
+ char *szModule;
+ char *szSetting;
+ if (setting == nullptr || setting[0] == '\0') {
+ return;
+ }
-INT_PTR RemoveAllService(WPARAM, LPARAM)
-{
- if (gIniFile[0] == '\0') {
- MessageBox(nullptr, TranslateT("Configuration file could not be found!"), TranslateW(MSGBOX_TITLE), MB_OK | MB_ICONERROR);
- return -1;
+ // Split setting
+ szModule = strdup(setting);
+ szSetting = strrchr(szModule, '/');
+ if (szSetting != nullptr) {
+ *szSetting = '\0';
+ szSetting++;
}
- if (MessageBox(nullptr, TranslateW(NOTICE_TEXT), TranslateW(MSGBOX_TITLE), MB_YESNO) == IDYES) {
- SetProtocolsOffline();
- RemoveUsers();
- RemoveSettings();
- ExecuteServices();
- RemoveDirectories();
- DisablePlugins();
+ DeleteSettingEx(szModule, szSetting);
- MessageBox(nullptr, TranslateT("Settings are deleted now."), TranslateW(MSGBOX_TITLE), MB_OK | MB_ICONINFORMATION);
- }
+ free(szModule);
+}
- return 0;
+BOOL isMetaContact(MCONTACT hContact)
+{
+ return mir_strcmp(GetContactProto(hContact), METACONTACTS_PROTOCOL_NAME) == 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void SetProtocolsOffline()
{
- if ( GetSettingBool("GlobalSettings", "SetProtocolsOffline", TRUE) ) {
+ if (GetSettingBool("GlobalSettings", "SetProtocolsOffline", TRUE)) {
for (auto &pa : Accounts()) {
if (!pa->bIsEnabled)
continue;
@@ -179,62 +286,28 @@ void SetProtocolsOffline()
}
}
-void RemoveUsers()
-{
- if ( GetSettingBool("GlobalSettings", "RemoveAllUsers", TRUE) ) {
- // To be faster, remove first all metacontacts (because it syncs histories)
- MCONTACT hContact = db_find_first();
- while(hContact != NULL) {
- MCONTACT hContactOld = hContact;
- hContact = db_find_next(hContact);
-
- if (isMetaContact(hContactOld))
- db_delete_contact(hContactOld);
- }
-
- // Now delete all left-overs
- hContact = db_find_first();
- while(hContact != NULL) {
- db_delete_contact(hContact);
-
- hContact = db_find_first();
- }
-
- // Delete events for contacts not in list
- MEVENT hDbEvent = db_event_first(0);
-
- while(hDbEvent != NULL) {
- db_event_delete(0, hDbEvent);
- hDbEvent = db_event_first(0);
- }
-
- // Now delete groups
- DeleteSettingEx("CListGroups", nullptr);
- }
-}
-
void RemoveProtocolSettings(const char * protocolName)
{
char buffer[10000];
// Remove protocol module settings
- if ( GetSettingBool("GlobalSettings", "RemoveWholeProtocolModule", FALSE) ) {
+ if (GetSettingBool("GlobalSettings", "RemoveWholeProtocolModule", FALSE)) {
DeleteSettingEx(protocolName, nullptr);
}
- else if ( GetSettings("ProtocolSettings", buffer, sizeof(buffer)) ) {
+ else if (GetSettings("ProtocolSettings", buffer, sizeof(buffer))) {
char *name;
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Disable it
@@ -247,21 +320,21 @@ void RemoveProtocolSettings(const char * protocolName)
}
// Remove modules by protocol sufixes
- if ( GetSettings("ProtocolModuleSufixes", buffer, sizeof(buffer)) ) {
+ if (GetSettings("ProtocolModuleSufixes", buffer, sizeof(buffer))) {
char *name;
char *value;
char moduleName[256];
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Delete it
@@ -276,12 +349,46 @@ void RemoveProtocolSettings(const char * protocolName)
}
}
+void RemoveUsers()
+{
+ if (GetSettingBool("GlobalSettings", "RemoveAllUsers", TRUE)) {
+ // To be faster, remove first all metacontacts (because it syncs histories)
+ MCONTACT hContact = db_find_first();
+ while (hContact != NULL) {
+ MCONTACT hContactOld = hContact;
+ hContact = db_find_next(hContact);
+
+ if (isMetaContact(hContactOld))
+ db_delete_contact(hContactOld);
+ }
+
+ // Now delete all left-overs
+ hContact = db_find_first();
+ while (hContact != NULL) {
+ db_delete_contact(hContact);
+
+ hContact = db_find_first();
+ }
+
+ // Delete events for contacts not in list
+ MEVENT hDbEvent = db_event_first(0);
+
+ while (hDbEvent != NULL) {
+ db_event_delete(0, hDbEvent);
+ hDbEvent = db_event_first(0);
+ }
+
+ // Now delete groups
+ DeleteSettingEx("CListGroups", nullptr);
+ }
+}
+
void RemoveSettings()
{
char buffer[10000];
// Delete protocol settings
- if ( GetSettingBool("GlobalSettings", "RemoveProtocolSettings", TRUE) ) {
+ if (GetSettingBool("GlobalSettings", "RemoveProtocolSettings", TRUE)) {
for (auto &pa : Accounts()) {
if (!pa->bIsEnabled)
continue;
@@ -298,15 +405,15 @@ void RemoveSettings()
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Disable it
@@ -326,15 +433,15 @@ void RemoveSettings()
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Delete it
@@ -351,26 +458,26 @@ void ExecuteServices()
{
char buffer[10000];
- if ( GetSettings("ExecuteServices", buffer, sizeof(buffer)) ) {
+ if (GetSettings("ExecuteServices", buffer, sizeof(buffer))) {
char *name;
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Disable it
if (name[0] != '\0')
if (ServiceExists(name))
- CallService(name,0,0);
+ CallService(name, 0, 0);
// Get next one
name = value + mir_strlen(value) + 1;
@@ -398,20 +505,20 @@ void RemoveDirectories()
}
// Remove other folders
- if ( GetSettings("RemoveFilesOrFolders", buffer, sizeof(buffer)) ) {
+ if (GetSettings("RemoveFilesOrFolders", buffer, sizeof(buffer))) {
char *name;
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Delete it
@@ -430,27 +537,26 @@ void DisablePlugins()
{
char buffer[10000];
- if ( GetSettings("DisablePlugins", buffer, sizeof(buffer)) ) {
+ if (GetSettings("DisablePlugins", buffer, sizeof(buffer))) {
char *name;
char *value;
name = buffer;
- while(name[0] != '\0') {
+ while (name[0] != '\0') {
value = strchr(name, '=');
if (value == nullptr)
value = &name[mir_strlen(name)];
// Has " ?
- if (*name == '"' && *(value-1) == '"') {
+ if (*name == '"' && *(value - 1) == '"') {
name++;
- *(value-1) = '\0';
+ *(value - 1) = '\0';
}
// Disable it
if (name[0] != '\0') {
CharLowerA(name);
- if (db_get_b(NULL, PLUGINDISABLELIST, name, 0) != 1)
- {
+ if (db_get_b(NULL, PLUGINDISABLELIST, name, 0) != 1) {
db_set_b(NULL, PLUGINDISABLELIST, name, 1);
}
}
@@ -461,211 +567,77 @@ void DisablePlugins()
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
-
-// Ini access functions
-
-BOOL GetSettingBool(const char *section, const char *key, BOOL defaultValue)
-{
- char tmp[16];
- if (GetPrivateProfileStringA(section, key, defaultValue ? "true" : "false", tmp, sizeof(tmp), gIniFile) == 0)
- return defaultValue;
-
- return mir_strcmpi(tmp, "true") == 0;
-}
-
-
-BOOL GetSettings(const char *section, char *buffer, size_t bufferSize)
-{
- buffer[0] = '\0\0';
- return (BOOL)GetPrivateProfileSectionA(section, buffer, (DWORD)bufferSize, gIniFile) != 0;
-}
-
-
-
-// Utils
-
-void DeleteFileOrFolder(const char *name)
+static INT_PTR RemoveAllService(WPARAM, LPARAM)
{
- DWORD attibs = GetFileAttributesA(name);
-
- if (attibs == INVALID_FILE_ATTRIBUTES) { // Not exists
- // Try to find it
- char tmp[MAX_PATH];
- char *strTmp;
-
- // Delete files
- WIN32_FIND_DATAA findData;
- HANDLE hwnd = FindFirstFileA(name, &findData);
- if (hwnd != INVALID_HANDLE_VALUE) {
- strncpy(tmp, name, sizeof(tmp)-1);
- strTmp = strrchr(tmp,'\\');
-
- if(strTmp != nullptr) {
- strTmp++;
- *strTmp = '\0';
- }
- else {
- mir_strcat(tmp, "\\");
- strTmp = &tmp[mir_strlen(tmp)];
- }
-
- do {
- if (mir_strcmp(findData.cFileName, ".") && mir_strcmp(findData.cFileName, "..")) {
- mir_strcpy(strTmp, findData.cFileName);
- DeleteFileOrFolder(tmp);
- }
- }
- while(FindNextFileA(hwnd, &findData) != 0);
-
- FindClose(hwnd);
- }
- }
- else if (attibs & FILE_ATTRIBUTE_DIRECTORY) { // Is a directory
- // Get all files and delete then
- char tmp[MAX_PATH];
- mir_snprintf(tmp, "%s\\*.*", name);
-
- // Delete files
- WIN32_FIND_DATAA findData;
- HANDLE hwnd = FindFirstFileA(tmp, &findData);
- if (hwnd != INVALID_HANDLE_VALUE) {
- do {
- if (mir_strcmp(findData.cFileName, ".") && mir_strcmp(findData.cFileName, "..")) {
- mir_snprintf(tmp, "%s\\%s", name, findData.cFileName);
- DeleteFileOrFolder(tmp);
- }
- }
- while(FindNextFileA(hwnd, &findData) != 0);
-
- FindClose(hwnd);
- }
-
- // Delete directory
- RemoveDirectoryA(name);
- }
- else { // Is a File
- SetFileAttributesA(name, FILE_ATTRIBUTE_ARCHIVE);
- DeleteFileA(name);
+ if (gIniFile[0] == '\0') {
+ MessageBox(nullptr, TranslateT("Configuration file could not be found!"), TranslateW(MSGBOX_TITLE), MB_OK | MB_ICONERROR);
+ return -1;
}
-}
-
-
-BOOL isMetaContact(MCONTACT hContact)
-{
- return mir_strcmp(GetContactProto(hContact), METACONTACTS_PROTOCOL_NAME) == 0;
-}
+ if (MessageBox(nullptr, TranslateW(NOTICE_TEXT), TranslateW(MSGBOX_TITLE), MB_YESNO) == IDYES) {
+ SetProtocolsOffline();
+ RemoveUsers();
+ RemoveSettings();
+ ExecuteServices();
+ RemoveDirectories();
+ DisablePlugins();
-
-typedef struct {
- char buffer[10000];
- size_t pos;
- const char *filter;
- size_t lenFilterMinusOne;
-} DeleteModuleStruct;
-
-
-int EnumProc(const char *szName, void *lParam)
-{
- DeleteModuleStruct *dms = (DeleteModuleStruct *) lParam;
- size_t len = mir_strlen(szName);
-
- if (dms->filter != nullptr && dms->lenFilterMinusOne > 0) {
- if (len >= dms->lenFilterMinusOne) {
- if (dms->filter[0] == '*') {
- if (mir_strcmp(&dms->filter[1], &szName[len - dms->lenFilterMinusOne]) != 0)
- return 0;
- }
- else { // if (dms->filter[dms->lenFilterMinusOne] == '*')
- if (strncmp(dms->filter, szName, dms->lenFilterMinusOne) != 0)
- return 0;
- }
- }
- }
-
- // Add to the struct
- if (len > 0 && len < sizeof(dms->buffer) - dms->pos - 2) {
- mir_strcpy(&dms->buffer[dms->pos], szName);
- dms->pos += len + 1;
+ MessageBox(nullptr, TranslateT("Settings are deleted now."), TranslateW(MSGBOX_TITLE), MB_OK | MB_ICONINFORMATION);
}
return 0;
}
-int ModuleEnumProc(const char *szName, void *lParam)
-{
- return EnumProc(szName, lParam);
-}
-
-void DeleteSettingEx(const char *szModule, const char *szSetting)
+extern "C" int __declspec(dllexport) Load()
{
- size_t lenModule;
+ mir_getLP(&pluginInfo);
- if (szModule == nullptr)
- return;
+ CMenuItem mi;
+ SET_UID(mi, 0x2f9f21df, 0xf33c, 0x4640, 0xb9, 0x63, 0xd3, 0x26, 0x8a, 0xb8, 0xb1, 0xf0);
+ mi.position = -0x7FFFFFFF;
+ mi.hIcolibItem = Skin_LoadIcon(SKINICON_OTHER_MIRANDA);
+ mi.name.a = LPGEN("Remove Personal Settings...");
+ mi.pszService = "RemovePersonalSettings/RemoveAll";
+ Menu_AddMainMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, RemoveAllService);
- lenModule = mir_strlen(szModule);
- if (szModule[0] == '*' || szModule[lenModule-1] == '*') {
- DeleteModuleStruct dms;
- memset(&dms, 0, sizeof(dms));
+ // Get ini file name
+ gMirandaDir[0] = '\0';
+ GetModuleFileNameA(GetModuleHandle(nullptr), gMirandaDir, sizeof(gMirandaDir));
- dms.filter = szModule;
- dms.lenFilterMinusOne = lenModule-1;
+ // Remove last name
+ char *strTmp = strrchr(gMirandaDir, '\\');
+ if (strTmp != nullptr)
+ *strTmp = '\0';
- db_enum_modules(ModuleEnumProc, &dms);
+ // Set vars
+ mir_strcat(gMirandaDir, "\\");
+ mir_strcpy(gIniFile, gMirandaDir);
- // Delete then
- szModule = dms.buffer;
- while(szModule[0] != '\0') {
- DeleteSettingEx(szModule, szSetting);
+ // Store last pos
+ strTmp = &gIniFile[mir_strlen(gIniFile)];
- // Get next one
- szModule += mir_strlen(szModule) + 1;
- }
- }
- else {
- size_t lenSetting = szSetting == nullptr ? 0 : mir_strlen(szSetting);
- if (szSetting == nullptr || szSetting[0] == '*' || szSetting[lenSetting-1] == '*') {
- DeleteModuleStruct dms;
- memset(&dms, 0, sizeof(dms));
- dms.filter = szSetting;
- dms.lenFilterMinusOne = lenSetting-1;
- db_enum_settings(NULL, EnumProc, szModule, &dms);
+ // Lets try fist name
+ mir_strcpy(strTmp, INI_FILE_NAME);
- // Delete then
- szSetting = dms.buffer;
- while(szSetting[0] != '\0') {
- db_unset(NULL, szModule, szSetting);
+ if (_access(gIniFile, 4) != 0) {
+ // Not found, lets try the other aproach
+ mir_strcpy(strTmp, "plugins\\" INI_FILE_NAME);
- // Get next one
- szSetting += mir_strlen(szSetting) + 1;
- }
- }
- else {
- db_unset(NULL, szModule, szSetting);
+ if (_access(gIniFile, 4) != 0) {
+ // Not found :(
+ gIniFile[0] = '\0';
}
}
-}
-void DeleteSetting(const char *setting)
-{
- char *szModule;
- char *szSetting;
-
- if (setting == nullptr || setting[0] == '\0') {
- return;
- }
-
- // Split setting
- szModule = strdup(setting);
- szSetting = strrchr(szModule, '/');
- if (szSetting != nullptr) {
- *szSetting = '\0';
- szSetting ++;
- }
+ return 0;
+}
- DeleteSettingEx(szModule, szSetting);
+/////////////////////////////////////////////////////////////////////////////////////////
- free(szModule);
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ return 0;
}
diff --git a/plugins/RemovePersonalSettings/src/stdafx.h b/plugins/RemovePersonalSettings/src/stdafx.h
index c8a1eef175..574cd69ad1 100644
--- a/plugins/RemovePersonalSettings/src/stdafx.h
+++ b/plugins/RemovePersonalSettings/src/stdafx.h
@@ -23,7 +23,6 @@
#include <io.h>
#include <stdio.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_skin.h>
diff --git a/plugins/Restart/src/restart.cpp b/plugins/Restart/src/restart.cpp
index 08cb470b64..d274593254 100644
--- a/plugins/Restart/src/restart.cpp
+++ b/plugins/Restart/src/restart.cpp
@@ -1,9 +1,18 @@
#include "stdafx.h"
-HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+}
+g_plugin;
+
int hLangpack;
HANDLE hRestartMe;
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -17,17 +26,13 @@ PLUGININFOEX pluginInfo={
{0x61bedf3a, 0xcc2, 0x41a3, {0xb9, 0x80, 0xbb, 0x93, 0x93, 0x36, 0x89, 0x35}}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR RestartMe(WPARAM, LPARAM)
{
CallService(MS_SYSTEM_RESTART, 1, 0);
@@ -41,7 +46,7 @@ extern "C" __declspec(dllexport) int Load(void)
mir_getLP( &pluginInfo );
// IcoLib support
- Icon_Register(hInst, LPGEN("Restart Plugin"), &icon, 1);
+ Icon_Register(g_plugin.getInst(), LPGEN("Restart Plugin"), &icon, 1);
hRestartMe = CreateServiceFunction("System/RestartMe", RestartMe);
@@ -56,6 +61,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
diff --git a/plugins/Restart/src/stdafx.h b/plugins/Restart/src/stdafx.h
index 90e05480bb..13536d7f07 100644
--- a/plugins/Restart/src/stdafx.h
+++ b/plugins/Restart/src/stdafx.h
@@ -3,7 +3,6 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_genmenu.h>
diff --git a/plugins/SMS/src/main.cpp b/plugins/SMS/src/main.cpp
index 37269f9ff7..939ed8ecc0 100644
--- a/plugins/SMS/src/main.cpp
+++ b/plugins/SMS/src/main.cpp
@@ -27,13 +27,16 @@ Enjoy the code and use it smartly!
#include "stdafx.h"
-CLIST_INTERFACE *pcli;
int hLangpack;
-HINSTANCE hInst;
+CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
SMS_SETTINGS ssSMSSettings;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -51,9 +54,42 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfo;
}
-int OnModulesLoaded (WPARAM wParam,LPARAM lParam);
-int OnPreShutdown (WPARAM wParam,LPARAM lParam);
-void VersionConversions();
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void VersionConversions()
+{
+ WCHAR wsztm[MAX_PATH];
+
+ if (DB_SMS_GetStaticStringW(NULL, "UseSignature", wsztm, _countof(wsztm), nullptr))
+ DB_SMS_SetByte(NULL, "UseSignature", (wsztm[0] == '0'));
+ else
+ DB_SMS_SetByte(NULL, "UseSignature", SMS_DEFAULT_USESIGNATURE);
+
+ if (DB_SMS_GetStaticStringW(NULL, "SignaturePos", wsztm, _countof(wsztm), nullptr))
+ DB_SMS_SetByte(NULL, "SignaturePos", (wsztm[0] == '0'));
+ else
+ DB_SMS_SetByte(NULL, "SignaturePos", SMS_DEFAULT_SIGNATUREPOS);
+
+ if (DB_SMS_GetStaticStringW(NULL, "ShowACK", wsztm, _countof(wsztm), nullptr))
+ DB_SMS_SetByte(NULL, "ShowACK", (wsztm[0] == '0'));
+ else
+ DB_SMS_SetByte(NULL, "ShowACK", SMS_DEFAULT_SHOWACK);
+}
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ VersionConversions();
+ LoadModules();
+ return 0;
+}
+
+static int OnPreShutdown(WPARAM, LPARAM)
+{
+ RecvSMSWindowDestroy();
+ SendSMSWindowDestroy();
+ FreeAccountList();
+ return 0;
+}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
@@ -64,9 +100,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
ssSMSSettings.hHeap = HeapCreate(0, 0, 0);
DisableThreadLibraryCalls((HMODULE)hInstance);
break;
+
case DLL_PROCESS_DETACH:
HeapDestroy(ssSMSSettings.hHeap);
ssSMSSettings.hHeap = nullptr;
+
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
@@ -75,6 +113,8 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
return TRUE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -87,49 +127,12 @@ extern "C" int __declspec(dllexport) Load(void)
RecvSMSWindowInitialize();
LoadServices();
-
return 0;
}
-extern "C" int __declspec(dllexport) Unload(void)
-{
- return 0;
-}
-
-int OnModulesLoaded(WPARAM,LPARAM)
-{
- VersionConversions();
-
- LoadModules();
+/////////////////////////////////////////////////////////////////////////////////////////
- return 0;
-}
-
-int OnPreShutdown(WPARAM,LPARAM)
+extern "C" int __declspec(dllexport) Unload(void)
{
- RecvSMSWindowDestroy();
- SendSMSWindowDestroy();
- FreeAccountList();
-
return 0;
}
-
-void VersionConversions()
-{
- WCHAR wsztm[MAX_PATH];
-
- if (DB_SMS_GetStaticStringW(NULL,"UseSignature",wsztm,_countof(wsztm),nullptr))
- DB_SMS_SetByte(NULL,"UseSignature",(wsztm[0]=='0'));
- else
- DB_SMS_SetByte(NULL,"UseSignature",SMS_DEFAULT_USESIGNATURE);
-
- if (DB_SMS_GetStaticStringW(NULL,"SignaturePos",wsztm,_countof(wsztm),nullptr))
- DB_SMS_SetByte(NULL,"SignaturePos",(wsztm[0]=='0'));
- else
- DB_SMS_SetByte(NULL,"SignaturePos",SMS_DEFAULT_SIGNATUREPOS);
-
- if (DB_SMS_GetStaticStringW(NULL,"ShowACK",wsztm,_countof(wsztm),nullptr))
- DB_SMS_SetByte(NULL,"ShowACK",(wsztm[0]=='0'));
- else
- DB_SMS_SetByte(NULL,"ShowACK",SMS_DEFAULT_SHOWACK);
-}
diff --git a/plugins/SMS/src/stdafx.h b/plugins/SMS/src/stdafx.h
index e3747bae9b..e99ea83b45 100644
--- a/plugins/SMS/src/stdafx.h
+++ b/plugins/SMS/src/stdafx.h
@@ -9,7 +9,6 @@
#include <malloc.h>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_clistint.h>
@@ -32,7 +31,12 @@
#include "SMSConstans.h"
#include "senddlg.h"
-extern HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PROTOCOL_NAMEA)
+ {}
+};
// структура содержащая информацию по построению меню или расширенных иконок
struct GUI_DISPLAY_ITEM
@@ -43,12 +47,10 @@ struct GUI_DISPLAY_ITEM
LPVOID lpFunc; // функция вызываемая меню
};
-
#define MAIN_MENU_ITEMS_COUNT 1
#define CONTACT_MENU_ITEMS_COUNT 1
-
-typedef struct
+struct SMS_SETTINGS
{
HANDLE hHeap;
HINSTANCE hInstance;
@@ -61,21 +63,14 @@ typedef struct
PROTOACCOUNT **ppaSMSAccounts;
size_t dwSMSAccountsCount;
-
-} SMS_SETTINGS;
-
-
+};
extern SMS_SETTINGS ssSMSSettings;
-
-
-
#define MEMALLOC(Size) HeapAlloc(ssSMSSettings.hHeap,HEAP_ZERO_MEMORY,(Size+sizeof(size_t)))
#define MEMREALLOC(Mem,Size) HeapReAlloc(ssSMSSettings.hHeap,(HEAP_ZERO_MEMORY),(LPVOID)Mem,(Size+sizeof(size_t)))
#define MEMFREE(Mem) if (Mem) {HeapFree(ssSMSSettings.hHeap,0,(LPVOID)Mem);Mem=NULL;}
-
#define GET_DLG_ITEM_TEXT_LENGTH(hDlg,nIDDlgItem) SendDlgItemMessage(hDlg,nIDDlgItem,WM_GETTEXTLENGTH,NULL,NULL)
#define GET_CURRENT_COMBO_DATA(hWndDlg,ControlID) SendDlgItemMessage(hWndDlg,ControlID,CB_GETITEMDATA,SendDlgItemMessage(hWndDlg,ControlID,CB_GETCURSEL,0,0),0)
@@ -129,4 +124,4 @@ int SmsRebuildContactMenu(WPARAM wParam,LPARAM lParam);
void StartSmsSend(HWND hWndDlg,size_t dwModuleIndex,LPWSTR lpwszPhone,size_t dwPhoneSize,LPWSTR lpwszMessage,size_t dwMessageSize);
-#endif \ No newline at end of file
+#endif
diff --git a/plugins/SeenPlugin/src/history.cpp b/plugins/SeenPlugin/src/history.cpp
index fb0f4f4e12..75b5002c6d 100644
--- a/plugins/SeenPlugin/src/history.cpp
+++ b/plugins/SeenPlugin/src/history.cpp
@@ -284,7 +284,7 @@ void ShowHistory(MCONTACT hContact, BYTE isAlert)
{
HWND hHistoryDlg = WindowList_Find(hWindowList, hContact);
if (hHistoryDlg == nullptr) {
- hHistoryDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_HISTORY), nullptr, HistoryDlgProc, hContact);
+ hHistoryDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HISTORY), nullptr, HistoryDlgProc, hContact);
LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST);
WindowList_Add(hWindowList, hHistoryDlg, hContact);
}
diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp
index 7491080adf..314bb9860f 100644
--- a/plugins/SeenPlugin/src/main.cpp
+++ b/plugins/SeenPlugin/src/main.cpp
@@ -20,14 +20,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-HINSTANCE hInstance;
HANDLE ehmissed = nullptr, ehuserinfo = nullptr, ehmissed_proto = nullptr;
HANDLE g_hShutdownEvent;
MWindowList g_pUserInfo;
int hLangpack;
+CMPlugin g_plugin;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -37,9 +40,16 @@ PLUGININFOEX pluginInfo = {
__AUTHORWEB,
UNICODE_AWARE,
// {2D506D46-C94E-4EF8-8537-F11233A80381}
- { 0x2d506d46, 0xc94e, 0x4ef8, { 0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81 } }
+ { 0x2d506d46, 0xc94e, 0x4ef8, { 0x85, 0x37, 0xf1, 0x12, 0x33, 0xa8, 0x03, 0x81 }}
};
+extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
#define TRANSNUMBER 2
DBVTranslation idleTr[TRANSNUMBER] = {
{ any_to_IdleNotidleUnknown, L"Any to Idle/Not Idle/Unknown", 0 },
@@ -57,7 +67,9 @@ mir_cs csContacts;
void UninitHistoryDialog(void);
-int MainInit(WPARAM, LPARAM)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int MainInit(WPARAM, LPARAM)
{
if (g_bFileActive = db_get_b(NULL, S_MOD, "FileOutput", 0))
InitFileOutput();
@@ -108,10 +120,7 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Unload(void)
{
@@ -127,9 +136,3 @@ extern "C" __declspec(dllexport) int Unload(void)
UninitHistoryDialog();
return 0;
}
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- hInstance = hinst;
- return 1;
-}
diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp
index 15fd50725d..aef95a6350 100644
--- a/plugins/SeenPlugin/src/missed.cpp
+++ b/plugins/SeenPlugin/src/missed.cpp
@@ -114,7 +114,7 @@ int ShowMissed(void)
buf.AppendChar('\n');
}
- CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_MISSED), nullptr, MissedDlgProc, (LPARAM)buf.c_str());
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MISSED), nullptr, MissedDlgProc, (LPARAM)buf.c_str());
return 0;
}
diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp
index 4b4882d5d6..46d9c8b8c6 100644
--- a/plugins/SeenPlugin/src/options.cpp
+++ b/plugins/SeenPlugin/src/options.cpp
@@ -488,7 +488,7 @@ int OptionsInit(WPARAM wparam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_SETTINGS);
odp.szGroup.w = LPGENW("Contacts");
diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h
index f3affdc167..9d91ee93ad 100644
--- a/plugins/SeenPlugin/src/stdafx.h
+++ b/plugins/SeenPlugin/src/stdafx.h
@@ -31,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <malloc.h>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -55,13 +54,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "resource.h"
#include "version.h"
-WCHAR *any_to_IdleNotidleUnknown(MCONTACT hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen);
-WCHAR *any_to_Idle(MCONTACT hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen);
+wchar_t *any_to_IdleNotidleUnknown(MCONTACT hContact, const char *module_name, const char *setting_name, wchar_t *buff, int bufflen);
+wchar_t *any_to_Idle(MCONTACT hContact, const char *module_name, const char *setting_name, wchar_t *buff, int bufflen);
#define NUM100NANOSEC 116444736000000000
#define S_MOD "SeenModule"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(S_MOD)
+ {}
+};
+
//#define UM_CHECKHOOKS (WM_USER+1)
#define debug(a) MessageBox(NULL,a,L"Debug",MB_OK)
@@ -105,7 +111,6 @@ int UserinfoInit(WPARAM,LPARAM);
void InitMenuitem(void);
int UpdateValues(WPARAM, LPARAM);
int ModeChange(WPARAM,LPARAM);
-void SetOffline(void);
int ModeChange_mo(WPARAM,LPARAM);
int CheckIfOnline(void);
void ShowHistory(MCONTACT hContact, BYTE isAlert);
@@ -120,7 +125,6 @@ struct logthread_info
WORD currStatus;
};
-extern HINSTANCE hInstance;
extern DWORD StatusColors15bits[];
extern BOOL includeIdle;
extern HANDLE ehmissed, ehuserinfo, ehmissed_proto;
diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp
index 19d2aebd16..dbfa5232fb 100644
--- a/plugins/SeenPlugin/src/userinfo.cpp
+++ b/plugins/SeenPlugin/src/userinfo.cpp
@@ -70,7 +70,7 @@ int UserinfoInit(WPARAM wparam, LPARAM lparam)
if (IsWatchedProtocol(szProto) && !db_get_b(hContact, szProto, "ChatRoom", false)) {
OPTIONSDIALOGPAGE uip = { sizeof(uip) };
- uip.hInstance = hInstance;
+ uip.hInstance = g_plugin.getInst();
uip.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
uip.szTitle.a = LPGEN("Last seen");
uip.pfnDlgProc = UserinfoDlgProc;
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index f985aec6f4..2945dce91e 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -419,7 +419,7 @@ void CSend::Exit(unsigned int Result)
switch (Result) {
case CSEND_DIALOG:
Skin_PlaySound("FileDone");
- DialogBoxParam(g_hSendSS, MAKEINTRESOURCE(IDD_UResultForm), nullptr, ResultDialogProc, (LPARAM)this);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UResultForm), nullptr, ResultDialogProc, (LPARAM)this);
err = false;
break;
case ACKRESULT_SUCCESS:
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index c7f583cc50..6f34b5c0d8 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -27,14 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
-#include "Main.h"
// Prototypes ///////////////////////////////////////////////////////////////////////////
-CHAT_MANAGER *pci;
-HINSTANCE g_hSendSS;
+
+int hLangpack;
+CMPlugin g_plugin;
+CHAT_MANAGER *pci;
+
MGLOBAL g_myGlobals;
-HNETLIBUSER g_hNetlibUser=nullptr;//!< Netlib Register User
-int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP()
+HNETLIBUSER g_hNetlibUser;
IconItem ICONS[ICO_END_] =
{
@@ -57,7 +58,6 @@ IconItem ICONS_BTN[ICO_BTN_END_] =
{ LPGEN("Update"), "update", IDI_UPDATE },
{ LPGEN("OK"), "ok", IDI_OK },
{ LPGEN("Cancel"), "cancel", IDI_CANCEL },
- // {LPGEN("Apply"),"apply",IDI_APPLY},
{ LPGEN("Edit"), "edit", IDI_EDIT },
{ LPGEN("Edit on"), "editon", IDI_EDITON },
{ LPGEN("Copy"), "copy", IDI_COPY },
@@ -207,13 +207,10 @@ INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam)
return (INT_PTR)result;
}
-// Functions ////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static PLUGININFOEX pluginInfo =
{
- g_hSendSS = hinstDLL;
- return TRUE;
-}
-static const PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -225,11 +222,15 @@ static const PLUGININFOEX pluginInfo = {
// {ED39AF7C-BECD-404E-9499-4D04F711B9CB}
{ 0xed39af7c, 0xbecd, 0x404e, { 0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb } }
};
-DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- return const_cast<PLUGININFOEX*>(&pluginInfo);
+ return &pluginInfo;
}
-/// hooks
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// hooks
+
int hook_ModulesLoaded(WPARAM, LPARAM)
{
g_myGlobals.PopupExist = ServiceExists(MS_POPUP_ADDPOPUPT);
@@ -250,6 +251,7 @@ int hook_ModulesLoaded(WPARAM, LPARAM)
PROFILE_PATHW L"\\" CURRENT_PROFILEW L"\\Screenshots");
return 0;
}
+
int hook_SystemPreShutdown(WPARAM, LPARAM)
{
TfrmAbout::Unload();//crashes if done from "Unload" because of dependencies
@@ -262,7 +264,8 @@ int hook_SystemPreShutdown(WPARAM, LPARAM)
}
ATOM g_clsTargetHighlighter = 0;
-DLL_EXPORT int Load(void)
+
+extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
pci = Chat_GetInterface();
@@ -272,8 +275,8 @@ DLL_EXPORT int Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPreShutdown);
/// icons
- Icon_Register(g_hSendSS, SZ_SENDSS, ICONS, sizeof(ICONS) / sizeof(IconItem), SZ_SENDSS);
- Icon_Register(g_hSendSS, SZ_SENDSS "/" LPGEN("Buttons"), ICONS_BTN, sizeof(ICONS_BTN) / sizeof(IconItem), SZ_SENDSS);
+ Icon_Register(g_plugin.getInst(), SZ_SENDSS, ICONS, sizeof(ICONS) / sizeof(IconItem), SZ_SENDSS);
+ Icon_Register(g_plugin.getInst(), SZ_SENDSS "/" LPGEN("Buttons"), ICONS_BTN, sizeof(ICONS_BTN) / sizeof(IconItem), SZ_SENDSS);
/// services
#define srv_reg(name) do{\
@@ -320,17 +323,17 @@ DLL_EXPORT int Load(void)
/// register highlighter window class
HBRUSH brush = CreateSolidBrush(0x0000FF00);//owned by class
- WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_hSendSS, nullptr, nullptr, brush, nullptr, L"SendSSHighlighter" };
+ WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_plugin.getInst(), nullptr, nullptr, brush, nullptr, L"SendSSHighlighter" };
g_clsTargetHighlighter = RegisterClass(&wndclass);
return 0;
}
-/*---------------------------------------------------------------------------
-* Prepare the plugin to stop
-* Called by Miranda when it will exit or when the plugin gets deselected
-*/
-DLL_EXPORT int Unload(void)
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Prepare the plugin to stop
+
+extern "C" __declspec(dllexport) int Unload(void)
{
if (g_clsTargetHighlighter)
- UnregisterClass((wchar_t*)g_clsTargetHighlighter, g_hSendSS), g_clsTargetHighlighter = 0;
+ UnregisterClass((wchar_t*)g_clsTargetHighlighter, g_plugin.getInst()), g_clsTargetHighlighter = 0;
return 0;
}
diff --git a/plugins/SendScreenshotPlus/src/Main.h b/plugins/SendScreenshotPlus/src/Main.h
deleted file mode 100644
index c9954e237e..0000000000
--- a/plugins/SendScreenshotPlus/src/Main.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
-Copyright (c) 2000-09 Miranda ICQ/IM project,
-
-This file is part of Send Screenshot Plus, a Miranda IM plugin.
-Copyright (c) 2010 Ing.U.Horn
-
-Parts of this file based on original sorce code
-(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef MainH
-#define MainH
-
-#define DLL_EXPORT __declspec(dllexport)
-extern "C"{
-DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion);
-DLL_EXPORT int Load(void);
-DLL_EXPORT int Unload(void);
-}
-#endif
diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
index 6c135e55a4..eda56157eb 100644
--- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
@@ -98,10 +98,10 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM, LPARAM)
CMStringW pszText(_A2W(__COPYRIGHT));
pszText.Append(L"\r\n\r\n");
- HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_LICENSE), L"TEXT");
- DWORD size = SizeofResource(g_hSendSS, hRes);
+ HRSRC hRes = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_LICENSE), L"TEXT");
+ DWORD size = SizeofResource(g_plugin.getInst(), hRes);
char* data = (char*)mir_alloc(size + 1);
- memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size);
+ memcpy(data, LockResource(LoadResource(g_plugin.getInst(), hRes)), size);
data[size] = '\0';
pszText.AppendFormat(L"%S", data);
mir_free(data);
@@ -110,10 +110,10 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM, LPARAM)
// Credit
{
- HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_CREDIT), L"TEXT");
- DWORD size = SizeofResource(g_hSendSS, hRes);
+ HRSRC hRes = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CREDIT), L"TEXT");
+ DWORD size = SizeofResource(g_plugin.getInst(), hRes);
char* data = (char*)mir_alloc(size + 1);
- memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size);
+ memcpy(data, LockResource(LoadResource(g_plugin.getInst(), hRes)), size);
data[size] = '\0';
wchar_t* pszText = mir_a2u(data);
mir_free(data);
@@ -171,7 +171,7 @@ TfrmAbout::TfrmAbout(HWND Owner)
m_hWndOwner = Owner;
m_Page = 1;
// create window
- m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UAboutForm), nullptr, DlgTfrmAbout, (LPARAM)this);
+ m_hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UAboutForm), nullptr, DlgTfrmAbout, (LPARAM)this);
//register object
_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
}
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index 6430995360..145de2c080 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -224,7 +224,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
/// Add a tab for each of the three child dialog boxes.
itab.tcih.pszText = TranslateT("Window");
itab.tcih.iImage = 0;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureWindow);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureWindow);
TabCtrl_InsertItem(m_hwndTab, 0, &itab);
/// get tab boundaries (required after 1st tab)
GetClientRect(m_hwndTab, &rcTab);
@@ -238,7 +238,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
itab.tcih.pszText = TranslateT("Desktop");
itab.tcih.iImage = 1;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureDesktop);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureDesktop);
TabCtrl_InsertItem(m_hwndTab, 1, &itab);
SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0);
@@ -261,7 +261,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
itab.tcih.pszText = TranslateT("File");
itab.tcih.iImage = 2;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureFile), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureFile);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureFile), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureFile);
TabCtrl_InsertItem(m_hwndTab, 2, &itab);
SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0);
@@ -535,7 +535,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM)
static int primarymouse;
if (!m_hTargetHighlighter) {
primarymouse = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON;
- m_hTargetHighlighter = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, (wchar_t*)g_clsTargetHighlighter, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_hSendSS, nullptr);
+ m_hTargetHighlighter = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, (wchar_t*)g_clsTargetHighlighter, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr);
if (!m_hTargetHighlighter) return;
SetLayeredWindowAttributes(m_hTargetHighlighter, 0, 123, LWA_ALPHA);
SetSystemCursor(CopyCursor(GetIcon(ICO_TARGET)), OCR_IBEAM);//text cursor
@@ -808,7 +808,7 @@ void TfrmMain::Init(wchar_t* DestFolder, MCONTACT Contact)
m_hContact = Contact;
// create window
- m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMainForm), nullptr, DlgTfrmMain, (LPARAM)this);
+ m_hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMainForm), nullptr, DlgTfrmMain, (LPARAM)this);
//register object
_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
index 837b792580..37f965e87f 100644
--- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp
+++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
@@ -653,7 +653,7 @@ void CtrlButtonUnloadModule()
{
if (!g_init) return;
g_init = false;
- UnregisterClass(UINFOBUTTONCLASS, g_hSendSS);
+ UnregisterClass(UINFOBUTTONCLASS, g_plugin.getInst());
}
void CtrlButtonLoadModule()/// @fixme : compatibility with UInfoEx is everything but perfect... we get a huge problem if UInfoEx is unloaded...
diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
index fb0d7f9eec..e0a4be0666 100644
--- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
+++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/// SendSS compatibility:
#include "stdafx.h"
-#define ghInst g_hSendSS
+#define ghInst g_plugin.getInst()
#define myGlobals g_myGlobals
#define MODNAME SZ_SENDSS
#define ICO_COMMON_MAIN 0xFFFF
diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h
index 2187b01fa7..6d37f1d4ae 100644
--- a/plugins/SendScreenshotPlus/src/stdafx.h
+++ b/plugins/SendScreenshotPlus/src/stdafx.h
@@ -52,7 +52,6 @@ using namespace std;
#include <msapi/vsstyle.h>
#include <msapi/vssym32.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_button.h>
#include <m_chat_int.h>
@@ -119,8 +118,14 @@ typedef struct _MGLOBAL {
// Miranda Database Key
#define SZ_SENDSS "SendSS"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(SZ_SENDSS)
+ {}
+};
+
extern ATOM g_clsTargetHighlighter;
-extern HINSTANCE g_hSendSS;
extern MGLOBAL g_myGlobals;
extern HNETLIBUSER g_hNetlibUser;
diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp
index d81a8f416c..ec5076eb8f 100644
--- a/plugins/ShellExt/src/main.cpp
+++ b/plugins/ShellExt/src/main.cpp
@@ -1,11 +1,22 @@
#include "stdafx.h"
#include "shlcom.h"
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
+
bool bIsVistaPlus;
-wchar_t tszLogPath[MAX_PATH];
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
+{
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != nullptr;
+ DisableThreadLibraryCalls(hinstDLL);
+ }
+
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
@@ -17,23 +28,9 @@ PLUGININFOEX pluginInfoEx = {
__AUTHORWEB,
UNICODE_AWARE,
// {7993AB24-1FDA-428C-A89B-BE377A10BE3A}
- {0x7993ab24, 0x1fda, 0x428c, {0xa8, 0x9b, 0xbe, 0x37, 0x7a, 0x10, 0xbe, 0x3a}}
+ { 0x7993ab24, 0x1fda, 0x428c, { 0xa8, 0x9b, 0xbe, 0x37, 0x7a, 0x10, 0xbe, 0x3a }}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
-{
- if (fdwReason == DLL_PROCESS_ATTACH) {
- bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != nullptr;
-
- GetTempPath(_countof(tszLogPath), tszLogPath);
- wcscat_s(tszLogPath, _countof(tszLogPath), L"shlext.log");
-
- hInst = hinstDLL;
- DisableThreadLibraryCalls(hinstDLL);
- }
-
- return TRUE;
-}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
@@ -126,7 +123,7 @@ STDAPI DllRegisterServer()
return E_FAIL;
wchar_t tszFileName[MAX_PATH];
- GetModuleFileName(hInst, tszFileName, _countof(tszFileName));
+ GetModuleFileName(g_plugin.getInst(), tszFileName, _countof(tszFileName));
if ( RegSetValueEx(kInprocServer, nullptr, 0, REG_SZ, (LPBYTE)tszFileName, sizeof(wchar_t)*(lstrlen(tszFileName)+1)))
return E_FAIL;
if ( RegSetValueExA(kInprocServer, "ThreadingModel", 0, REG_SZ, (PBYTE)str4, sizeof(str4)))
diff --git a/plugins/ShellExt/src/options.cpp b/plugins/ShellExt/src/options.cpp
index aaa3f77f7f..dee192de91 100644
--- a/plugins/ShellExt/src/options.cpp
+++ b/plugins/ShellExt/src/options.cpp
@@ -115,7 +115,7 @@ int OnOptionsInit(WPARAM wParam, LPARAM)
opt.szTitle.a = LPGEN("Shell context menus");
opt.position = -1066;
opt.pszTemplate = MAKEINTRESOURCEA(IDD_SHLOPTS);
- opt.hInstance = hInst;
+ opt.hInstance = g_plugin.getInst();
opt.pfnDlgProc = OptDialogProc;
Options_AddPage(wParam, &opt);
return 0;
diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp
index 608b35fd86..c20c5ef069 100644
--- a/plugins/ShellExt/src/shlcom.cpp
+++ b/plugins/ShellExt/src/shlcom.cpp
@@ -550,7 +550,7 @@ void CheckUnregisterServer()
if (bIsVistaPlus) {
// launches regsvr to remove the dll under admin.
wchar_t szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
- GetModuleFileName(hInst, szFileName, _countof(szFileName));
+ GetModuleFileName(g_plugin.getInst(), szFileName, _countof(szFileName));
mir_snwprintf(szBuf, L"/s /u \"%s\"", szFileName);
SHELLEXECUTEINFO sei = { sizeof(sei) };
@@ -579,7 +579,7 @@ void CheckRegisterServer()
TranslateT("Shell context menus requires your permission to register with Windows Explorer (one time only)."),
TranslateT("Miranda NG - Shell context menus (shellext.dll)"), MB_OK | MB_ICONINFORMATION);
// /s = silent
- GetModuleFileName(hInst, szFileName, _countof(szFileName));
+ GetModuleFileName(g_plugin.getInst(), szFileName, _countof(szFileName));
mir_snwprintf(szBuf, L"/s \"%s\"", szFileName);
SHELLEXECUTEINFO sei = { sizeof(sei) };
diff --git a/plugins/ShellExt/src/shlext.cpp b/plugins/ShellExt/src/shlext.cpp
index 2e5b77fc91..9d887b03e2 100644
--- a/plugins/ShellExt/src/shlext.cpp
+++ b/plugins/ShellExt/src/shlext.cpp
@@ -633,7 +633,7 @@ typedef HRESULT (__stdcall *pfnDllGetVersion)(DllVersionInfo*);
HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT, UINT _idCmdFirst, UINT, UINT uFlags)
{
- logA("TShellExt[%p]::QueryContextMenu: %p, %d, %d, %08x\n", this, hmenu, indexMenu, _idCmdFirst, uFlags);
+ logA("TShellExt[%p]::QueryContextMenu: %p, %d, %08x\n", this, hmenu, _idCmdFirst, uFlags);
if (((LOWORD(uFlags) & CMF_VERBSONLY) != CMF_VERBSONLY) && ((LOWORD(uFlags) & CMF_DEFAULTONLY) != CMF_DEFAULTONLY)) {
bool bMF_OWNERDRAW = false;
diff --git a/plugins/ShellExt/src/stdafx.h b/plugins/ShellExt/src/stdafx.h
index b01486b518..14bc44366d 100644
--- a/plugins/ShellExt/src/stdafx.h
+++ b/plugins/ShellExt/src/stdafx.h
@@ -8,9 +8,7 @@
#include <string.h>
#include <stddef.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
-
#include <m_system.h>
#include <m_protocols.h>
#include <m_protosvc.h>
@@ -45,10 +43,15 @@ void InvokeThreadServer();
int IsCOMRegistered();
HRESULT RemoveCOMRegistryEntries();
-extern HINSTANCE hInst;
-extern HANDLE hLogger;
-extern bool bIsVistaPlus;
-extern int DllFactoryCount, DllObjectCount;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(SHLExt_Name)
+ {}
+};
+
+extern bool bIsVistaPlus;
+extern int DllFactoryCount, DllObjectCount;
int OnOptionsInit(WPARAM wParam, LPARAM lParam);
@@ -57,7 +60,7 @@ int OnOptionsInit(WPARAM wParam, LPARAM lParam);
#endif
#ifdef LOG_ENABLED
-void logA(const char *format, ...);
+#define logA g_plugin.debugLogA
#else
#define logA(A, ...)
#endif
diff --git a/plugins/ShellExt/src/utils.cpp b/plugins/ShellExt/src/utils.cpp
index 275224388e..131ee01dbb 100644
--- a/plugins/ShellExt/src/utils.cpp
+++ b/plugins/ShellExt/src/utils.cpp
@@ -1,21 +1,5 @@
#include "stdafx.h"
-#ifdef LOG_ENABLED
-extern wchar_t tszLogPath[];
-
-void logA(const char *format, ...)
-{
- FILE *out = _wfopen(tszLogPath, L"a+");
- if (out) {
- va_list args;
- va_start(args, format);
- vfprintf(out, format, args);
- va_end(args);
- fclose(out);
- }
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
UINT murmur_hash(const char *str)
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp
index 5a73931214..2a5c2ffa08 100644
--- a/plugins/SimpleAR/src/Main.cpp
+++ b/plugins/SimpleAR/src/Main.cpp
@@ -16,13 +16,13 @@ Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede
#include "stdafx.h"
+int hLangpack;
+CMPlugin g_plugin;
CLIST_INTERFACE *pcli;
-HINSTANCE hinstance;
HGENMENU hToggle, hEnableMenu;
BOOL gbVarsServiceExist = FALSE;
INT interval;
-int hLangpack;
wchar_t* ptszDefaultMsg[] = {
LPGENW("I am currently away. I will reply to you when I am back."),
@@ -33,7 +33,10 @@ wchar_t* ptszDefaultMsg[] = {
LPGENW("I am having meal right now. I will get back to you very soon.")
};
-PLUGININFOEX pluginInfoEx = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -51,11 +54,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &pluginInfoEx;
}
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- hinstance = hinst;
- return TRUE;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR ToggleEnable(WPARAM, LPARAM)
{
@@ -237,6 +236,8 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
IconItemT iconList[] =
{
{ LPGENW("Disable Auto&reply"), "Disable Auto&reply", IDI_OFF },
@@ -270,11 +271,13 @@ extern "C" int __declspec(dllexport)Load(void)
HookEvent(ME_DB_EVENT_ADDED, addEvent);
HookEvent(ME_SYSTEM_MODULESLOADED, CheckDefaults);
- Icon_RegisterT(hinstance, L"Simple Auto Replier", iconList, _countof(iconList));
+ Icon_RegisterT(g_plugin.getInst(), L"Simple Auto Replier", iconList, _countof(iconList));
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport)int Unload(void)
{
return 0;
diff --git a/plugins/SimpleAR/src/Options.cpp b/plugins/SimpleAR/src/Options.cpp
index 7647b89dd5..e1f0f583ef 100644
--- a/plugins/SimpleAR/src/Options.cpp
+++ b/plugins/SimpleAR/src/Options.cpp
@@ -137,7 +137,7 @@ INT OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = hinstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTION);
odp.szTitle.a = LPGEN("Simple Auto Replier");
odp.szGroup.a = LPGEN("Message sessions");
diff --git a/plugins/SimpleAR/src/stdafx.h b/plugins/SimpleAR/src/stdafx.h
index 26d54bb57a..2ba5c1c970 100644
--- a/plugins/SimpleAR/src/stdafx.h
+++ b/plugins/SimpleAR/src/stdafx.h
@@ -3,7 +3,6 @@
#include <windows.h>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clistint.h>
#include <m_langpack.h>
@@ -23,8 +22,15 @@
#define KEY_HEADING "Heading"
#define KEY_REPEATINTERVAL "RepeatInterval"
-//General
-extern HINSTANCE hinstance;
+// General
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(protocolname)
+ {}
+};
+
extern INT interval;
extern wchar_t *ptszDefaultMsg[6];
extern HGENMENU hEnableMenu;
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp
index ab62e4bd34..6606f86a3d 100644
--- a/plugins/SimpleStatusMsg/src/awaymsg.cpp
+++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp
@@ -183,7 +183,7 @@ static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM)
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
- else CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), nullptr, ReadAwayMsgDlgProc, wParam);
+ else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_READAWAYMSG), nullptr, ReadAwayMsgDlgProc, wParam);
return 0;
}
@@ -288,7 +288,7 @@ static INT_PTR CopyAwayMsgCommand(WPARAM wParam, LPARAM)
SetFocus(hwnd);
}
else
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_COPY), nullptr, CopyAwayMsgDlgProc, wParam);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_COPY), nullptr, CopyAwayMsgDlgProc, wParam);
return 0;
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp
index b2216a2846..1a7dd6631a 100644
--- a/plugins/SimpleStatusMsg/src/main.cpp
+++ b/plugins/SimpleStatusMsg/src/main.cpp
@@ -20,11 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "stdafx.h"
-HINSTANCE g_hInst;
-
int hLangpack;
-PROTOACCOUNTS *accounts;
+CMPlugin g_plugin;
+PROTOACCOUNTS *accounts;
static int g_iIdleTime = -1;
UINT_PTR g_uUpdateMsgTimer = 0, *g_uSetStatusTimer;
static wchar_t *g_ptszWinampSong;
@@ -32,7 +31,10 @@ HANDLE hTTBButton = nullptr, h_statusmodechange;
HWND hwndSAMsgDialog;
static HANDLE *hProtoStatusMenuItem;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -42,51 +44,19 @@ PLUGININFOEX pluginInfo = {
__AUTHORWEB,
UNICODE_AWARE,
// {768CE156-34AC-45A3-B53B-0083C47615C4}
- {0x768ce156, 0x34ac, 0x45a3, {0xb5, 0x3b, 0x0, 0x83, 0xc4, 0x76, 0x15, 0xc4}}
+ { 0x768ce156, 0x34ac, 0x45a3, { 0xb5, 0x3b, 0x0, 0x83, 0xc4, 0x76, 0x15, 0xc4 }}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- g_hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST };
-
-#ifdef _DEBUG
-void log2file(const char *fmt, ...)
-{
- DWORD dwBytesWritten;
- va_list va;
- char szText[1024];
- HANDLE hFile = CreateFileA("simplestatusmsg.log", GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- SetFilePointer(hFile, 0, nullptr, FILE_END);
+/////////////////////////////////////////////////////////////////////////////////////////
- strncpy(szText, "[\0", _countof(szText));
- WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, nullptr);
-
- GetTimeFormatA(LOCALE_USER_DEFAULT, 0, nullptr, nullptr, szText, _countof(szText));
- WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, nullptr);
-
- strncpy(szText, "] \0", _countof(szText));
-
- va_start(va, fmt);
- mir_vsnprintf(szText + mir_strlen(szText), _countof(szText) - mir_strlen(szText), fmt, va);
- va_end(va);
-
- WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, nullptr);
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST };
- strncpy(szText, "\n\0", _countof(szText));
- WriteFile(hFile, szText, (DWORD)mir_strlen(szText), &dwBytesWritten, nullptr);
-
- CloseHandle(hFile);
-}
-#endif
+/////////////////////////////////////////////////////////////////////////////////////////
static wchar_t* GetWinampSong(void)
{
@@ -148,7 +118,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
wchar_t substituteStr[1024], *msg = mir_wstrdup(in);
for (int i = 0; msg[i]; i++) {
- if (msg[i] == 0x0D && db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) {
+ if (msg[i] == 0x0D && db_get_b(NULL, MODULENAME, "RemoveCR", 0)) {
wchar_t *p = msg + i;
if (i + 1 <= 1024 && msg[i + 1]) {
if (msg[i + 1] == 0x0A) {
@@ -174,8 +144,8 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
mir_free(g_ptszWinampSong);
g_ptszWinampSong = mir_wstrdup(ptszWinampTitle);
}
- else if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, L"SimpleStatusMsg")
- && db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1)) {
+ else if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, TEXT(MODULENAME))
+ && db_get_b(NULL, MODULENAME, "AmpLeaveTitle", 1)) {
ptszWinampTitle = mir_wstrdup(g_ptszWinampSong);
}
else
@@ -254,7 +224,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
BOOL rmark[25];
for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
- int maxk = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ int maxk = db_get_b(NULL, MODULENAME, "MaxHist", 10);
if (maxk == 0) rmark[0] = TRUE;
while (!rmark[0]) {
@@ -266,7 +236,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
mir_snprintf(buff, "SMsg%d", k);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg == nullptr)
continue;
@@ -296,7 +266,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
BOOL rmark[25];
for (k = 0; k < _countof(rmark); k++) rmark[k] = FALSE;
- int maxk = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
+ int maxk = db_get_w(NULL, MODULENAME, "DefMsgCount", 0);
if (maxk == 0) rmark[0] = TRUE;
while (!rmark[0]) {
@@ -308,7 +278,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
mir_snprintf(buff, "DefMsg%d", k);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg == nullptr)
continue;
@@ -340,7 +310,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
if (szProto) {
char szSetting[80];
mir_snprintf(szSetting, "Proto%sMaxLen", szProto);
- size_t len = db_get_w(NULL, "SimpleStatusMsg", szSetting, 1024);
+ size_t len = db_get_w(NULL, MODULENAME, szSetting, 1024);
if (len < mir_wstrlen(msg)) {
msg = (wchar_t *)mir_realloc(msg, len * sizeof(wchar_t));
msg[len] = 0;
@@ -352,7 +322,7 @@ wchar_t* InsertBuiltinVarsIntoMsg(wchar_t *in, const char *szProto, int)
wchar_t* InsertVarsIntoMsg(wchar_t *tszMsg, const char *szProto, int iStatus, MCONTACT hContact)
{
- if (ServiceExists(MS_VARS_FORMATSTRING) && db_get_b(NULL, "SimpleStatusMsg", "EnableVariables", 1)) {
+ if (ServiceExists(MS_VARS_FORMATSTRING) && db_get_b(NULL, MODULENAME, "EnableVariables", 1)) {
wchar_t *tszVarsMsg = variables_parse(tszMsg, nullptr, hContact);
if (tszVarsMsg != nullptr) {
wchar_t *format = InsertBuiltinVarsIntoMsg(tszVarsMsg, szProto, iStatus);
@@ -370,7 +340,7 @@ static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto)
wchar_t *format;
mir_snprintf(szSetting, "%sFlags", szProto ? szProto : "");
- int flags = db_get_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
+ int flags = db_get_b(NULL, MODULENAME, StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
if (flags & STATUS_EMPTY_MSG) {
return mir_wstrdup(L"");
@@ -389,11 +359,11 @@ static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto)
else
mir_snprintf(szSetting, "LastMsg");
- char *szLastMsg = db_get_sa(NULL, "SimpleStatusMsg", szSetting);
+ char *szLastMsg = db_get_sa(NULL, MODULENAME, szSetting);
if (szLastMsg == nullptr)
return nullptr; //mir_wstrdup(L"");
- format = db_get_wsa(NULL, "SimpleStatusMsg", szLastMsg);
+ format = db_get_wsa(NULL, MODULENAME, szLastMsg);
mir_free(szLastMsg);
}
else if (flags & STATUS_THIS_MSG) {
@@ -415,9 +385,9 @@ static wchar_t* GetAwayMessageFormat(int iStatus, const char *szProto)
void DBWriteMessage(char *szSetting, wchar_t *tszMsg)
{
if (tszMsg && mir_wstrlen(tszMsg))
- db_set_ws(NULL, "SimpleStatusMsg", szSetting, tszMsg);
+ db_set_ws(NULL, MODULENAME, szSetting, tszMsg);
else
- db_unset(NULL, "SimpleStatusMsg", szSetting);
+ db_unset(NULL, MODULENAME, szSetting);
}
void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat)
@@ -440,9 +410,9 @@ void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat)
DBWriteMessage(szSetting, tszMsg);
#ifdef _DEBUG
if (bIsFormat)
- log2file("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, pa->szModuleName);
+ g_plugin.debugLogA("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, pa->szModuleName);
else
- log2file("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, pa->szModuleName);
+ g_plugin.debugLogA("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, pa->szModuleName);
#endif
}
}
@@ -454,9 +424,9 @@ void SaveMessageToDB(const char *szProto, wchar_t *tszMsg, BOOL bIsFormat)
DBWriteMessage(szSetting, tszMsg);
#ifdef _DEBUG
if (bIsFormat)
- log2file("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, szProto);
+ g_plugin.debugLogA("SaveMessageToDB(): Set \"%S\" status message (without inserted vars) for %s.", tszMsg, szProto);
else
- log2file("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, szProto);
+ g_plugin.debugLogA("SaveMessageToDB(): Set \"%S\" status message for %s.", tszMsg, szProto);
#endif
}
}
@@ -465,7 +435,7 @@ void SaveStatusAsCurrent(const char *szProto, int iStatus)
{
char szSetting[80];
mir_snprintf(szSetting, "Cur%sStatus", szProto);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)iStatus);
+ db_set_w(NULL, MODULENAME, szSetting, (WORD)iStatus);
}
static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVars, MCONTACT hContact)
@@ -475,7 +445,7 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar
if ((!iStatus || iStatus == ID_STATUS_CURRENT) && szProto) {
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ format = db_get_wsa(NULL, MODULENAME, szSetting);
}
else {
if (!iStatus || iStatus == ID_STATUS_CURRENT)
@@ -485,22 +455,17 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar
return nullptr;
mir_snprintf(szSetting, "Proto%sFlags", szProto ? szProto : "");
- int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, MODULENAME, szSetting, PROTO_DEFAULT);
- //if (flags & PROTO_NO_MSG)
- //{
- // format = mir_wstrdup(L"");
- //}
- //else
if (flags & PROTO_THIS_MSG) {
mir_snprintf(szSetting, "Proto%sDefault", szProto);
- format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ format = db_get_wsa(NULL, MODULENAME, szSetting);
if (format == nullptr)
format = mir_wstrdup(L"");
}
else if (flags & PROTO_NOCHANGE && szProto) {
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- format = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ format = db_get_wsa(NULL, MODULENAME, szSetting);
}
else if (flags & PROTO_POPUPDLG)
format = GetAwayMessageFormat(iStatus, szProto);
@@ -508,7 +473,7 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar
format = nullptr;
}
#ifdef _DEBUG
- log2file("GetAwayMessage(): %s has %s status and \"%S\" status message.", szProto, StatusModeToDbSetting(iStatus, ""), format);
+ g_plugin.debugLogA("GetAwayMessage(): %s has %s status and \"%S\" status message.", szProto, StatusModeToDbSetting(iStatus, ""), format);
#endif
if (bInsertVars && format != nullptr) {
@@ -522,7 +487,7 @@ static wchar_t *GetAwayMessage(int iStatus, const char *szProto, BOOL bInsertVar
int CheckProtoSettings(const char *szProto, int iInitialStatus)
{
- int iSetting = db_get_w(NULL, szProto, "LeaveStatus", -1); //GG settings
+ int iSetting = db_get_w(NULL, szProto, "LeaveStatus", -1); //GG settings
if (iSetting != -1)
return iSetting ? iSetting : iInitialStatus;
iSetting = db_get_w(NULL, szProto, "OfflineMessageOption", -1); //TLEN settings
@@ -570,7 +535,7 @@ int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus
{
char szSetting[80];
mir_snprintf(szSetting, "Proto%sFlags", szProto);
- int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, MODULENAME, szSetting, PROTO_DEFAULT);
if (flags & PROTO_NO_MSG) {
Proto_SetStatus(szProto, iInitialStatus, iStatus, nullptr);
@@ -580,7 +545,7 @@ int HasProtoStaticStatusMsg(const char *szProto, int iInitialStatus, int iStatus
}
else if (flags & PROTO_THIS_MSG) {
mir_snprintf(szSetting, "Proto%sDefault", szProto);
- wchar_t *szSimpleStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *szSimpleStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (szSimpleStatusMsg != nullptr) {
SaveMessageToDB(szProto, szSimpleStatusMsg, TRUE);
wchar_t *msg = InsertVarsIntoMsg(szSimpleStatusMsg, szProto, iStatus, NULL);
@@ -654,7 +619,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
{
wchar_t *msg = nullptr;
#ifdef _DEBUG
- log2file("SetStatusMessage(\"%s\", %d, %d, \"%S\", %d)", szProto, iInitialStatus, iStatus, message, bOnStartup);
+ g_plugin.debugLogA("SetStatusMessage(\"%s\", %d, %d, \"%S\", %d)", szProto, iInitialStatus, iStatus, message, bOnStartup);
#endif
if (szProto) {
if (bOnStartup && accounts->statusCount > 1) // TODO not only at startup?
@@ -676,7 +641,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)status, 0);
}
}
- }
+ }
if (message)
msg = InsertVarsIntoMsg(message, szProto, iStatus, NULL);
@@ -689,7 +654,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
Proto_SetStatus(szProto, iInitialStatus, iStatus, msg);
mir_free(msg);
- }
+}
else {
int iProfileStatus = iStatus > ID_STATUS_CURRENT ? iStatus : 0;
BOOL bIsStatusCurrent = iStatus == ID_STATUS_CURRENT;
@@ -731,7 +696,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
if (!(bOnStartup && iStatus == ID_STATUS_OFFLINE) && GetCurrentStatus(pa->szModuleName) != iStatus && iStatus != iInitialStatus) {
CallProtoService(pa->szModuleName, PS_SETSTATUS, (WPARAM)iStatus, 0);
#ifdef _DEBUG
- log2file("SetStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), pa->szModuleName);
+ g_plugin.debugLogA("SetStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), pa->szModuleName);
#endif
}
continue;
@@ -748,7 +713,7 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
Proto_SetStatus(pa->szModuleName, iInitialStatus, iStatus, msg);
mir_free(msg);
- }
+ }
if (GetCurrentStatus(nullptr) != iStatus && !bIsStatusCurrent && !iProfileStatus) {
// not so nice...
@@ -756,8 +721,8 @@ void SetStatusMessage(const char *szProto, int iInitialStatus, int iStatus, wcha
Clist_SetStatusMode(iStatus);
h_statusmodechange = HookEvent(ME_CLIST_STATUSMODECHANGE, ChangeStatusMessage);
}
+ }
}
-}
INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam)
{
@@ -828,7 +793,7 @@ INT_PTR ShowStatusMessageDialogInternal(WPARAM, LPARAM lParam)
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- hwndSAMsgDialog = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
+ hwndSAMsgDialog = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
return 0;
}
@@ -875,7 +840,7 @@ INT_PTR ShowStatusMessageDialog(WPARAM, LPARAM lParam)
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- hwndSAMsgDialog = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
+ hwndSAMsgDialog = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
return 0;
}
@@ -918,7 +883,7 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
char szSetting[80];
mir_snprintf(szSetting, "%sFlags", szProto ? szProto : "");
- int iDlgFlags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
+ int iDlgFlags = db_get_b(NULL, MODULENAME, (char *)StatusModeToDbSetting(iStatus, szSetting), STATUS_DEFAULT);
BOOL bShowDlg = iDlgFlags & STATUS_SHOW_DLG || bOnStartup;
BOOL bScreenSaverRunning = IsScreenSaverRunning();
@@ -936,24 +901,24 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
if (bOnStartup && GetCurrentStatus(szProto) != iStatus) {
CallProtoService(szProto, PS_SETSTATUS, iStatus, 0);
#ifdef _DEBUG
- log2file("ChangeStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), szProto);
+ g_plugin.debugLogA("ChangeStatusMessage(): Set %s status for %s.", StatusModeToDbSetting(iStatus, ""), szProto);
#endif
}
return 0;
}
mir_snprintf(szSetting, "Proto%sFlags", szProto);
- iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ iProtoFlags = db_get_b(NULL, MODULENAME, szSetting, PROTO_DEFAULT);
if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG) {
if (HasProtoStaticStatusMsg(szProto, iStatus, iStatus))
return 1;
}
else if (iProtoFlags & PROTO_NOCHANGE && !bOnStartup) {
mir_snprintf(szSetting, "FCur%sMsg", szProto);
- wchar_t *msg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *msg = db_get_wsa(NULL, MODULENAME, szSetting);
#ifdef _DEBUG
- log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
+ g_plugin.debugLogA("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
#endif
SetStatusMessage(szProto, iStatus, iStatus, msg, FALSE);
if (msg) mir_free(msg);
@@ -963,7 +928,7 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
if (!bShowDlg || bScreenSaverRunning) {
wchar_t *msg = GetAwayMessageFormat(iStatus, szProto);
#ifdef _DEBUG
- log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
+ g_plugin.debugLogA("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, szProto);
#endif
SetStatusMessage(szProto, iStatus, iStatus, msg, FALSE);
if (msg) mir_free(msg);
@@ -988,14 +953,14 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- hwndSAMsgDialog = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
- }
+ hwndSAMsgDialog = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
+ }
else {
// iStatus == ID_STATUS_CURRENT only when bOnStartup == TRUE
if (iStatus == ID_STATUS_OFFLINE || (!(accounts->statusMsgFlags & Proto_Status2Flag(iStatus)) && iStatus != ID_STATUS_CURRENT))
return 0;
- int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
+ int iProtoFlags = db_get_b(NULL, MODULENAME, "ProtoFlags", PROTO_DEFAULT);
if (!bShowDlg || bScreenSaverRunning || (iProtoFlags & PROTO_NOCHANGE && !bOnStartup)) {
for (int i = 0; i < accounts->count; ++i) {
auto *pa = accounts->pa[i];
@@ -1015,19 +980,19 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
wchar_t *msg;
if (iProtoFlags & PROTO_NOCHANGE) {
mir_snprintf(szSetting, "FCur%sMsg", pa->szModuleName);
- msg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ msg = db_get_wsa(NULL, MODULENAME, szSetting);
}
else
msg = GetAwayMessageFormat(iStatus, nullptr);
#ifdef _DEBUG
- log2file("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, pa->szModuleName);
+ g_plugin.debugLogA("ChangeStatusMessage(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), msg, pa->szModuleName);
#endif
SetStatusMessage(pa->szModuleName, iStatus, iStatus, msg, FALSE);
if (msg)
mir_free(msg);
}
return 1;
- }
+ }
MsgBoxInitData *box_data = (MsgBoxInitData*)mir_alloc(sizeof(MsgBoxInitData));
box_data->m_szProto = nullptr;
@@ -1039,10 +1004,10 @@ int ChangeStatusMessage(WPARAM wParam, LPARAM lParam)
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- hwndSAMsgDialog = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
- }
+ hwndSAMsgDialog = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AWAYMSGBOX), nullptr, AwayMsgBoxDlgProc, (LPARAM)box_data);
+ }
return 0;
-}
+ }
static INT_PTR ChangeStatusMsg(WPARAM wParam, LPARAM lParam)
{
@@ -1064,7 +1029,7 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
SaveStatusAsCurrent(ack->szModule, (int)ack->lParam);
#ifdef _DEBUG
- log2file("ProcessProtoAck(): Set %s (%d) status for %s.", StatusModeToDbSetting((int)ack->lParam, ""), (int)ack->lParam, (char *)ack->szModule);
+ g_plugin.debugLogA("ProcessProtoAck(): Set %s (%d) status for %s.", StatusModeToDbSetting((int)ack->lParam, ""), (int)ack->lParam, (char *)ack->szModule);
#endif
return 0;
@@ -1088,7 +1053,7 @@ int SetStartupStatus(int i)
}
mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
- int flags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int flags = db_get_b(NULL, MODULENAME, szSetting, PROTO_DEFAULT);
if (flags & PROTO_NO_MSG || flags & PROTO_THIS_MSG) {
if (HasProtoStaticStatusMsg(pa->szModuleName, ID_STATUS_OFFLINE, iStatus))
return 0;
@@ -1097,13 +1062,13 @@ int SetStartupStatus(int i)
}
else if (flags & PROTO_NOCHANGE) {
mir_snprintf(szSetting, "FCur%sMsg", pa->szModuleName);
- fmsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ fmsg = db_get_wsa(NULL, MODULENAME, szSetting);
}
else
fmsg = GetAwayMessageFormat(iStatus, pa->szModuleName);
#ifdef _DEBUG
- log2file("SetStartupStatus(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), fmsg, pa->szModuleName);
+ g_plugin.debugLogA("SetStartupStatus(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iStatus, ""), fmsg, pa->szModuleName);
#endif
if (fmsg)
@@ -1151,12 +1116,12 @@ VOID CALLBACK SetStartupStatusGlobal(HWND hwnd, UINT, UINT_PTR idEvent, DWORD)
}
// popup status msg dialog at startup?
- if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1) && accounts->statusMsgFlags) {
+ if (db_get_b(NULL, MODULENAME, "StartupPopupDlg", 1) && accounts->statusMsgFlags) {
if (globalstatus)
ChangeStatusMessage(status_mode, (LPARAM)"SimpleStatusMsgGlobalStartupStatus");
else {
// pseudo-currentDesiredStatusMode ;-)
- db_set_w(NULL, "SimpleStatusMsg", "StartupStatus", (WORD)temp_status_mode);
+ db_set_w(NULL, MODULENAME, "StartupStatus", (WORD)temp_status_mode);
ChangeStatusMessage(ID_STATUS_CURRENT, (LPARAM)"SimpleStatusMsgGlobalStartupStatus");
}
return;
@@ -1205,7 +1170,7 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
MIRANDA_IDLE_INFO mii;
Idle_GetInfo(mii);
- if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", 1) && mii.idleType)
+ if (db_get_b(NULL, MODULENAME, "NoUpdateOnIdle", 1) && mii.idleType)
return;
if (!hwndSAMsgDialog) {
@@ -1229,7 +1194,7 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
continue;
mir_snprintf(szBuffer, "FCur%sMsg", pa->szModuleName);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szBuffer);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szBuffer);
if (tszStatusMsg == nullptr)
continue;
@@ -1238,7 +1203,7 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
mir_snprintf(szBuffer, "Cur%sMsg", pa->szModuleName);
- tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szBuffer);
+ tszStatusMsg = db_get_wsa(NULL, MODULENAME, szBuffer);
if ((tszMsg && tszStatusMsg && !mir_wstrcmp(tszMsg, tszStatusMsg)) || (!tszMsg && !tszStatusMsg)) {
mir_free(tszStatusMsg);
mir_free(tszMsg);
@@ -1249,15 +1214,15 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD)
if (tszMsg && mir_wstrlen(tszMsg)) {
#ifdef _DEBUG
- log2file("UpdateMsgTimerProc(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iCurrentStatus, ""), tszMsg, pa->szModuleName);
+ g_plugin.debugLogA("UpdateMsgTimerProc(): Set %s status and \"%S\" status message for %s.", StatusModeToDbSetting(iCurrentStatus, ""), tszMsg, pa->szModuleName);
#endif
Proto_SetStatus(pa->szModuleName, iCurrentStatus, iCurrentStatus, tszMsg);
SaveMessageToDB(pa->szModuleName, tszMsg, FALSE);
}
mir_free(tszMsg);
+ }
}
}
-}
static int AddTopToolbarButton(WPARAM, LPARAM)
{
@@ -1309,7 +1274,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
CMenuItem mi;
mi.flags = CMIF_UNICODE;
- if (!db_get_b(NULL, "SimpleStatusMsg", "ShowStatusMenuItem", 1))
+ if (!db_get_b(NULL, MODULENAME, "ShowStatusMenuItem", 1))
mi.flags |= CMIF_HIDDEN;
mi.hIcolibItem = GetIconHandle(IDI_CSMSG);
mi.pszService = MS_SIMPLESTATUSMSG_SHOWDIALOGINT;
@@ -1336,7 +1301,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
char szSetting[80];
mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
- int iProtoFlags = db_get_b(NULL, "SimpleStatusMsg", szSetting, PROTO_DEFAULT);
+ int iProtoFlags = db_get_b(NULL, MODULENAME, szSetting, PROTO_DEFAULT);
if (iProtoFlags & PROTO_NO_MSG || iProtoFlags & PROTO_THIS_MSG)
continue;
@@ -1356,7 +1321,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM)
static int OnIdleChanged(WPARAM, LPARAM lParam)
{
#ifdef _DEBUG
- log2file("OnIdleChanged()");
+ g_plugin.debugLogA("OnIdleChanged()");
#endif
if (!(lParam & IDF_ISIDLE))
g_iIdleTime = -1;
@@ -1366,7 +1331,7 @@ static int OnIdleChanged(WPARAM, LPARAM lParam)
if (mii.aaStatus == 0) {
#ifdef _DEBUG
- log2file("OnIdleChanged(): AutoAway disabled");
+ g_plugin.debugLogA("OnIdleChanged(): AutoAway disabled");
#endif
return 0;
}
@@ -1404,7 +1369,7 @@ static int OnIdleChanged(WPARAM, LPARAM lParam)
mir_free(tszMsg);
mir_free(tszVarsMsg);
}
- }
+}
return 0;
}
@@ -1430,7 +1395,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
SaveStatusAsCurrent(ps[i]->m_szName, status_mode);
#ifdef _DEBUG
- log2file("CSStatusChange(): Set %s status for %s.", StatusModeToDbSetting(status_mode, ""), ps[i]->m_szName);
+ g_plugin.debugLogA("CSStatusChange(): Set %s status for %s.", StatusModeToDbSetting(status_mode, ""), ps[i]->m_szName);
#endif
// TODO SaveMessageToDB also when NULL?
@@ -1440,17 +1405,17 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
wchar_t *szMsgW = mir_wstrdup(ps[i]->m_szMsg);
#ifdef _DEBUG
- log2file("CSStatusChange(): Set \"%s\" status message for %s.", ps[i]->m_szMsg, ps[i]->m_szName);
+ g_plugin.debugLogA("CSStatusChange(): Set \"%s\" status message for %s.", ps[i]->m_szMsg, ps[i]->m_szName);
#endif
- int max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ int max_hist_msgs = db_get_b(NULL, MODULENAME, "MaxHist", 10);
for (int j = 1; j <= max_hist_msgs; j++) {
mir_snprintf(buff, "SMsg%d", j);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg != nullptr) {
if (!mir_wstrcmp(tszStatusMsg, szMsgW)) {
found = true;
mir_snprintf(szSetting, "Last%sMsg", ps[i]->m_szName);
- db_set_s(NULL, "SimpleStatusMsg", szSetting, buff);
+ db_set_s(NULL, MODULENAME, szSetting, buff);
mir_free(tszStatusMsg);
break;
}
@@ -1462,7 +1427,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
if (!found) {
mir_snprintf(buff, "FCur%sMsg", ps[i]->m_szName);
mir_snprintf(szSetting, "Last%sMsg", ps[i]->m_szName);
- db_set_s(NULL, "SimpleStatusMsg", szSetting, buff);
+ db_set_s(NULL, MODULENAME, szSetting, buff);
}
mir_snprintf(szSetting, "%sMsg", ps[i]->m_szName);
@@ -1474,8 +1439,8 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
SaveMessageToDB(ps[i]->m_szName, msg, FALSE);
mir_free(msg);
- }
}
+}
return 0;
}
@@ -1492,7 +1457,7 @@ static wchar_t *ParseWinampSong(ARGUMENTSINFO *ai)
mir_free(g_ptszWinampSong);
g_ptszWinampSong = mir_wstrdup(ptszWinampTitle);
}
- else if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, L"SimpleStatusMsg") && db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1))
+ else if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, TEXT(MODULENAME)) && db_get_b(NULL, MODULENAME, "AmpLeaveTitle", 1))
ptszWinampTitle = mir_wstrdup(g_ptszWinampSong);
return ptszWinampTitle;
@@ -1526,10 +1491,10 @@ int ICQMsgTypeToStatus(int iMsgType)
static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam)
{
#ifdef _DEBUG
- log2file("OnICQStatusMsgRequest(): UIN: %d on %s", (int)lParam, (char *)lMirParam);
+ g_plugin.debugLogA("OnICQStatusMsgRequest(): UIN: %d on %s", (int)lParam, (char *)lMirParam);
#endif
- if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1))
+ if (db_get_b(NULL, MODULENAME, "NoUpdateOnICQReq", 1))
return 0;
char *szProto = (char *)lMirParam;
@@ -1555,7 +1520,7 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam)
static int OnAccListChanged(WPARAM, LPARAM)
{
#ifdef _DEBUG
- log2file("OnAccListChanged()");
+ g_plugin.debugLogA("OnAccListChanged()");
#endif
accounts->statusFlags = 0;
accounts->statusCount = 0;
@@ -1594,7 +1559,7 @@ static int OnAccListChanged(WPARAM, LPARAM)
static int OnModulesLoaded(WPARAM, LPARAM)
{
#ifdef _DEBUG
- log2file("### Session started ###");
+ g_plugin.debugLogA("### Session started ###");
#endif
OnAccListChanged(0, 0);
@@ -1622,7 +1587,7 @@ static int OnModulesLoaded(WPARAM, LPARAM)
tr.szHelpText = LPGEN("External Applications") "\t" LPGEN("retrieves song name of the song currently playing in Winamp (Simple Status Message compatible)");
CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
- if (db_get_b(NULL, "SimpleStatusMsg", "ExclDateToken", 0) != 0) {
+ if (db_get_b(NULL, MODULENAME, "ExclDateToken", 0) != 0) {
tr.tszTokenString = L"date";
tr.parseFunctionT = ParseDate;
tr.szHelpText = LPGEN("Miranda Related") "\t" LPGEN("get the date (Simple Status Message compatible)");
@@ -1630,12 +1595,12 @@ static int OnModulesLoaded(WPARAM, LPARAM)
}
}
- g_ptszWinampSong = db_get_wsa(NULL, "SimpleStatusMsg", "AmpLastTitle");
+ g_ptszWinampSong = db_get_wsa(NULL, MODULENAME, "AmpLastTitle");
if (g_ptszWinampSong == nullptr)
- g_ptszWinampSong = mir_wstrdup(L"SimpleStatusMsg");
+ g_ptszWinampSong = mir_wstrdup(TEXT(MODULENAME));
- if (db_get_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", 1))
- g_uUpdateMsgTimer = SetTimer(nullptr, 0, db_get_w(NULL, "SimpleStatusMsg", "UpdateMsgInt", 10) * 1000, UpdateMsgTimerProc);
+ if (db_get_b(NULL, MODULENAME, "UpdateMsgOn", 1))
+ g_uUpdateMsgTimer = SetTimer(nullptr, 0, db_get_w(NULL, MODULENAME, "UpdateMsgInt", 10) * 1000, UpdateMsgTimerProc);
HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChange);
@@ -1643,8 +1608,8 @@ static int OnModulesLoaded(WPARAM, LPARAM)
return 0;
if (!ServiceExists(MS_SS_GETPROFILECOUNT)) {
- if (db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1))
- SetTimer(nullptr, 0, db_get_w(NULL, "SimpleStatusMsg", "SetStatusDelay", 300), SetStartupStatusGlobal);
+ if (db_get_b(NULL, MODULENAME, "GlobalStatusDelay", 1))
+ SetTimer(nullptr, 0, db_get_w(NULL, MODULENAME, "SetStatusDelay", 300), SetStartupStatusGlobal);
else {
g_uSetStatusTimer = (UINT_PTR *)mir_alloc(sizeof(UINT_PTR) * accounts->count);
for (int i = 0; i < accounts->count; ++i) {
@@ -1657,7 +1622,7 @@ static int OnModulesLoaded(WPARAM, LPARAM)
char szSetting[80];
mir_snprintf(szSetting, "Set%sStatusDelay", pa->szModuleName);
- g_uSetStatusTimer[i] = SetTimer(nullptr, 0, db_get_w(NULL, "SimpleStatusMsg", szSetting, 300), SetStartupStatusProc);
+ g_uSetStatusTimer[i] = SetTimer(nullptr, 0, db_get_w(NULL, MODULENAME, szSetting, 300), SetStartupStatusProc);
}
}
}
@@ -1679,10 +1644,10 @@ static int OnOkToExit(WPARAM, LPARAM)
continue;
mir_snprintf(szSetting, "Last%sStatus", pa->szModuleName);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, Proto_GetStatus(pa->szModuleName));
+ db_set_w(NULL, MODULENAME, szSetting, Proto_GetStatus(pa->szModuleName));
}
- if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, L"SimpleStatusMsg") /*&& db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1)*/)
+ if (g_ptszWinampSong && mir_wstrcmp(g_ptszWinampSong, TEXT(MODULENAME)) /*&& db_get_b(NULL, MODULENAME, "AmpLeaveTitle", 1)*/)
DBWriteMessage("AmpLastTitle", g_ptszWinampSong);
}
@@ -1710,6 +1675,8 @@ static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam)
return (INT_PTR)GetAwayMessage((int)wParam, (char *)lParam, TRUE, NULL);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -1732,10 +1699,11 @@ extern "C" int __declspec(dllexport) Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
IconsInit();
-
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
UnhookEvent(h_statusmodechange);
@@ -1744,7 +1712,7 @@ extern "C" int __declspec(dllexport) Unload(void)
mir_free(accounts);
#ifdef _DEBUG
- log2file("### Session ended ###");
+ g_plugin.debugLogA("### Session ended ###");
#endif
return 0;
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp
index 9d02ca54c3..70a53b2bd5 100644
--- a/plugins/SimpleStatusMsg/src/msgbox.cpp
+++ b/plugins/SimpleStatusMsg/src/msgbox.cpp
@@ -106,7 +106,7 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr,
WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
- 0, 0, 0, 240, hwndDlg, nullptr, g_hInst, nullptr);
+ 0, 0, 0, 240, hwndDlg, nullptr, g_plugin.getInst(), nullptr);
COMBOBOXEXITEM cbei = { 0 };
if (!(data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS))
@@ -221,7 +221,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
HWND handle = CreateWindowEx(0, WC_COMBOBOXEX, nullptr,
WS_TABSTOP | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST,
- 0, 0, 0, 300, hwndDlg, nullptr, g_hInst, nullptr);
+ 0, 0, 0, 300, hwndDlg, nullptr, g_plugin.getInst(), nullptr);
COMBOBOXEXITEM cbei = { 0 };
if (!(data->m_iDlgFlags & DLG_SHOW_LIST_ICONS))
@@ -229,7 +229,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
else
cbei.mask = CBEIF_LPARAM | CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
- int j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
+ int j = db_get_w(NULL, MODULENAME, "LMMsg", 1);
for (int i = 1; i <= data->max_hist_msgs; ++i) {
// history messages
@@ -238,7 +238,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
mir_snprintf(buff, "SMsg%d", j);
j--;
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg != nullptr) {
if (*tszStatusMsg != '\0') {
found = TRUE;
@@ -332,7 +332,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
for (int i = 1; i <= data->num_def_msgs; ++i) {
// predefined messages
mir_snprintf(buff, "DefMsg%d", i);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg != nullptr) {
if (*tszStatusMsg != '\0') {
cbei.iItem = -1;
@@ -353,7 +353,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
}
}
- if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) {
+ if (db_get_b(NULL, MODULENAME, "PutDefInList", 0)) {
cbei.iItem = -1;
cbei.pszText = (LPTSTR)GetDefaultMessage(data->m_iStatus);
if (data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) {
@@ -391,7 +391,7 @@ HWND WINAPI CreateRecentComboBoxEx(HWND hwndDlg, struct MsgBoxData *data)
VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control)
{
- HMENU hmenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_EDITMENU));
+ HMENU hmenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_EDITMENU));
if (hmenu == nullptr)
return;
@@ -640,9 +640,9 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel)
for (i = 1; i <= data->max_hist_msgs; i++) {
mir_snprintf(text, "SMsg%d", i);
- db_set_ws(NULL, "SimpleStatusMsg", text, L"");
+ db_set_ws(NULL, MODULENAME, text, L"");
}
- db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
+ db_set_s(NULL, MODULENAME, "LastMsg", "");
for (i = 0; i < accounts->count; i++) {
auto *pa = accounts->pa[i];
if (!pa->IsEnabled())
@@ -655,9 +655,9 @@ void ClearHistory(struct MsgBoxData *data, int cur_sel)
continue;
mir_snprintf(buff2, "Last%sMsg", pa->szModuleName);
- db_set_s(NULL, "SimpleStatusMsg", buff2, "");
+ db_set_s(NULL, MODULENAME, buff2, "");
}
- db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)data->max_hist_msgs);
+ db_set_w(NULL, MODULENAME, "LMMsg", (WORD)data->max_hist_msgs);
SendMessage(data->recent_cbex, CB_SETCURSEL, -1, 0);
num_items = SendMessage(data->recent_cbex, CB_GETCOUNT, 0, 0);
if (num_items == CB_ERR)
@@ -685,7 +685,7 @@ void DisplayCharsCount(struct MsgBoxData *dlg_data, HWND hwndDlg)
return;
len = GetDlgItemText(hwndDlg, IDC_EDIT1, msg, _countof(msg));
- if (db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0)) {
+ if (db_get_b(NULL, MODULENAME, "RemoveCR", 0)) {
int index, num_lines = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_GETLINECOUNT, 0, 0);
for (int i = 1; i < num_lines; ++i) {
index = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_LINEINDEX, (WPARAM)i, 0);
@@ -706,7 +706,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
num_start -= data->num_def_msgs + 1;
mir_snprintf(setting, "%sFlags", data->m_szProto ? data->m_szProto : "");
- flags = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(iStatus, setting), STATUS_DEFAULT);
+ flags = db_get_b(NULL, MODULENAME, (char *)StatusModeToDbSetting(iStatus, setting), STATUS_DEFAULT);
if (flags & STATUS_LAST_MSG) {
if (data->m_szProto)
@@ -714,10 +714,10 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
else
mir_snprintf(setting, "LastMsg");
- char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ char *szSetting = db_get_sa(NULL, MODULENAME, setting);
if (szSetting != nullptr) {
if (*szSetting != '\0') {
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg != nullptr) {
if (*tszStatusMsg != '\0') {
SetDlgItemText(hwndDlg, IDC_EDIT1, tszStatusMsg);
@@ -734,7 +734,7 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
else if (flags & STATUS_DEFAULT_MSG) {
SetDlgItemText(hwndDlg, IDC_EDIT1, GetDefaultMessage(iStatus));
- if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0)) {
+ if (db_get_b(NULL, MODULENAME, "PutDefInList", 0)) {
fcursel = SendMessage(data->recent_cbex, CB_FINDSTRINGEXACT, num_start, (LPARAM)GetDefaultMessage(iStatus));
if (fcursel != CB_ERR)
SendMessage(data->recent_cbex, CB_SETCURSEL, (WPARAM)fcursel, 0);
@@ -932,9 +932,9 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SIMPAWAY_SHUTDOWN);
HookEventMessage(ME_SKIN2_ICONSCHANGED, hwndDlg, DM_SIMPAWAY_CHANGEICONS);
- copy_init_data->num_def_msgs = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
- copy_init_data->max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
- copy_init_data->m_iDlgFlags = db_get_b(NULL, "SimpleStatusMsg", "DlgFlags", DLG_SHOW_DEFAULT);
+ copy_init_data->num_def_msgs = db_get_w(NULL, MODULENAME, "DefMsgCount", 0);
+ copy_init_data->max_hist_msgs = db_get_b(NULL, MODULENAME, "MaxHist", 10);
+ copy_init_data->m_iDlgFlags = db_get_b(NULL, MODULENAME, "DlgFlags", DLG_SHOW_DEFAULT);
copy_init_data->m_szProto = init_data->m_szProto;
copy_init_data->m_iStatus = init_data->m_iStatus;
copy_init_data->m_iStatusModes = init_data->m_iStatusModes;
@@ -1045,8 +1045,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
}
}
- if (db_get_b(NULL, "SimpleStatusMsg", "AutoClose", 1) && init_data->m_bOnEvent) {
- copy_init_data->m_iCountdown = db_get_b(NULL, "SimpleStatusMsg", "DlgTime", 5);
+ if (db_get_b(NULL, MODULENAME, "AutoClose", 1) && init_data->m_bOnEvent) {
+ copy_init_data->m_iCountdown = db_get_b(NULL, MODULENAME, "DlgTime", 5);
SendMessage(hwndDlg, WM_TIMER, 0, 0);
SetTimer(hwndDlg, 1, 1000, nullptr);
}
@@ -1068,15 +1068,15 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
mir_free(init_data);
- if (!db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1)) {
+ if (!db_get_b(NULL, MODULENAME, "WinCentered", 1)) {
WINDOWPLACEMENT wp;
int x, y;
wp.length = sizeof(wp);
GetWindowPlacement(hwndDlg, &wp);
- x = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winx", -1);
- y = (int)db_get_dw(NULL, "SimpleStatusMsg", "Winy", -1);
+ x = (int)db_get_dw(NULL, MODULENAME, "Winx", -1);
+ y = (int)db_get_dw(NULL, MODULENAME, "Winy", -1);
if (x != -1) {
OffsetRect(&wp.rcNormalPosition, x - wp.rcNormalPosition.left, y - wp.rcNormalPosition.top);
@@ -1127,13 +1127,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
char szSetting[80];
if (msgbox_data->m_szProto) {
mir_snprintf(szSetting, "Last%sMsg", msgbox_data->m_szProto);
- db_set_s(NULL, "SimpleStatusMsg", szSetting, "");
+ db_set_s(NULL, MODULENAME, szSetting, "");
mir_snprintf(szSetting, "%sMsg", msgbox_data->m_szProto);
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, szSetting), L"");
}
else {
- db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
+ db_set_s(NULL, MODULENAME, "LastMsg", "");
for (int j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
if (!pa->IsEnabled())
@@ -1149,7 +1149,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
continue;
mir_snprintf(szSetting, "Last%sMsg", pa->szModuleName);
- db_set_s(NULL, "SimpleStatusMsg", szSetting, "");
+ db_set_s(NULL, MODULENAME, szSetting, "");
mir_snprintf(szSetting, "%sMsg", pa->szModuleName);
iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName);
@@ -1172,19 +1172,19 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
for (int i = 1; i <= msgbox_data->max_hist_msgs; i++) {
mir_snprintf(buff, "SMsg%d", i);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", buff);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, buff);
if (tszStatusMsg != nullptr) {
if (!mir_wstrcmp(tszStatusMsg, tszMsg)) {
found = true;
if (msgbox_data->m_szProto) {
mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto);
- db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
+ db_set_s(NULL, MODULENAME, buff2, buff);
mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto);
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg);
}
else {
- db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff);
+ db_set_s(NULL, MODULENAME, "LastMsg", buff);
for (int j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
if (!pa->IsEnabled())
@@ -1200,7 +1200,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
continue;
mir_snprintf(buff2, "Last%sMsg", pa->szModuleName);
- db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
+ db_set_s(NULL, MODULENAME, buff2, buff);
mir_snprintf(buff2, "%sMsg", pa->szModuleName);
iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName);
@@ -1215,7 +1215,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
}
if (!found) {
- int last_modified_msg = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", msgbox_data->max_hist_msgs);
+ int last_modified_msg = db_get_w(NULL, MODULENAME, "LMMsg", msgbox_data->max_hist_msgs);
if (last_modified_msg == msgbox_data->max_hist_msgs)
last_modified_msg = 1;
@@ -1223,17 +1223,17 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
last_modified_msg++;
mir_snprintf(buff, "SMsg%d", last_modified_msg);
- db_set_ws(NULL, "SimpleStatusMsg", buff, tszMsg);
+ db_set_ws(NULL, MODULENAME, buff, tszMsg);
if (msgbox_data->m_szProto) {
mir_snprintf(buff2, "Last%sMsg", msgbox_data->m_szProto);
- db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
+ db_set_s(NULL, MODULENAME, buff2, buff);
mir_snprintf(buff2, "%sMsg", msgbox_data->m_szProto);
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(msgbox_data->m_iStatus, buff2), tszMsg);
}
else {
- db_set_s(NULL, "SimpleStatusMsg", "LastMsg", buff);
+ db_set_s(NULL, MODULENAME, "LastMsg", buff);
for (int j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
if (!pa->IsEnabled())
@@ -1249,14 +1249,14 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
continue;
mir_snprintf(buff2, "Last%sMsg", pa->szModuleName);
- db_set_s(NULL, "SimpleStatusMsg", buff2, buff);
+ db_set_s(NULL, MODULENAME, buff2, buff);
mir_snprintf(buff2, "%sMsg", pa->szModuleName);
iStatus = msgbox_data->m_bOnStartup ? GetStartupStatus(pa->szModuleName) : GetCurrentStatus(pa->szModuleName);
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(iStatus, buff2), tszMsg);
}
}
- db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)last_modified_msg);
+ db_set_w(NULL, MODULENAME, "LMMsg", (WORD)last_modified_msg);
}
if (!msgbox_data->m_szProto)
@@ -1387,7 +1387,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
if (LOWORD(histitem.lParam) == HISTORY_MSG) {
char szSetting[16];
mir_snprintf(szSetting, "SMsg%d", (int)HIWORD(histitem.lParam));
- db_set_ws(NULL, "SimpleStatusMsg", szSetting, L"");
+ db_set_ws(NULL, MODULENAME, szSetting, L"");
SendMessage(msgbox_data->recent_cbex, CBEM_DELETEITEM, (WPARAM)msgbox_data->curr_sel_msg, 0);
}
if (LOWORD(histitem.lParam) == PREDEFINED_MSG) {
@@ -1499,7 +1499,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
if (LOWORD(histitem.lParam) == HISTORY_MSG) {
mir_snprintf(buff, "SMsg%d", (int)HIWORD(histitem.lParam));
- db_set_ws(NULL, "SimpleStatusMsg", buff, L"");
+ db_set_ws(NULL, MODULENAME, buff, L"");
}
else if (LOWORD(histitem.lParam) == PREDEFINED_MSG)
msgbox_data->m_bPredefChanged = TRUE;
@@ -1570,8 +1570,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
GetWindowPlacement(hwndDlg, &wp);
- db_set_dw(NULL, "SimpleStatusMsg", "Winx", wp.rcNormalPosition.left);
- db_set_dw(NULL, "SimpleStatusMsg", "Winy", wp.rcNormalPosition.top);
+ db_set_dw(NULL, MODULENAME, "Winx", wp.rcNormalPosition.left);
+ db_set_dw(NULL, MODULENAME, "Winy", wp.rcNormalPosition.top);
if (msgbox_data->m_bPredefChanged) {
int i, num_items, new_num_def_msgs = 0;
@@ -1591,13 +1591,13 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
mir_snprintf(buff, "DefMsg%d", i);
if (LOWORD(cbitem.lParam) == PREDEFINED_MSG) {
new_num_def_msgs++;
- db_set_ws(NULL, "SimpleStatusMsg", buff, text);
+ db_set_ws(NULL, MODULENAME, buff, text);
}
else
- db_unset(NULL, "SimpleStatusMsg", buff);
+ db_unset(NULL, MODULENAME, buff);
num_items--;
}
- db_set_w(NULL, "SimpleStatusMsg", "DefMsgCount", (WORD)new_num_def_msgs);
+ db_set_w(NULL, MODULENAME, "DefMsgCount", (WORD)new_num_def_msgs);
}
ImageList_Destroy(msgbox_data->status_icons);
diff --git a/plugins/SimpleStatusMsg/src/options.cpp b/plugins/SimpleStatusMsg/src/options.cpp
index e83297dcad..9646aac6fd 100644
--- a/plugins/SimpleStatusMsg/src/options.cpp
+++ b/plugins/SimpleStatusMsg/src/options.cpp
@@ -131,7 +131,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SendDlgItemMessage(hwndDlg, IDC_CBOPTSTATUS, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i - ID_STATUS_ONLINE);
- val = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(i, "Flags"), STATUS_DEFAULT);
+ val = db_get_b(NULL, MODULENAME, (char *)StatusModeToDbSetting(i, "Flags"), STATUS_DEFAULT);
data->status_msg[0].flags[i - ID_STATUS_ONLINE] = val;
ptrW text(db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, "Default")));
mir_wstrncpy(data->status_msg[0].msg[i - ID_STATUS_ONLINE], (text == NULL) ? GetDefaultMessage(i) : text, 1024);
@@ -142,7 +142,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
continue;
mir_snprintf(setting, "%sFlags", pa->szModuleName);
- val = db_get_b(NULL, "SimpleStatusMsg", (char *)StatusModeToDbSetting(i, setting), STATUS_DEFAULT);
+ val = db_get_b(NULL, MODULENAME, (char *)StatusModeToDbSetting(i, setting), STATUS_DEFAULT);
data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE] = val;
mir_snprintf(setting, "%sDefault", pa->szModuleName);
text = db_get_wsa(NULL, "SRAway", StatusModeToDbSetting(i, setting));
@@ -174,7 +174,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
if (index != CB_ERR && index != CB_ERRSPACE) {
data->proto_msg[0].msg = nullptr;
- val = db_get_b(NULL, "SimpleStatusMsg", "ProtoFlags", PROTO_DEFAULT);
+ val = db_get_b(NULL, MODULENAME, "ProtoFlags", PROTO_DEFAULT);
data->proto_msg[0].flags = val;
data->proto_msg[0].max_length = 0;
SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, (WPARAM)index, 0);
@@ -193,14 +193,14 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
// SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, index, (LPARAM)i + 1);
if (index != CB_ERR && index != CB_ERRSPACE) {
mir_snprintf(setting, "Proto%sDefault", pa->szModuleName);
- data->proto_msg[i + 1].msg = db_get_wsa(NULL, "SimpleStatusMsg", setting);
+ data->proto_msg[i + 1].msg = db_get_wsa(NULL, MODULENAME, setting);
mir_snprintf(setting, "Proto%sFlags", pa->szModuleName);
- val = db_get_b(NULL, "SimpleStatusMsg", setting, PROTO_DEFAULT);
+ val = db_get_b(NULL, MODULENAME, setting, PROTO_DEFAULT);
data->proto_msg[i + 1].flags = val;
mir_snprintf(setting, "Proto%sMaxLen", pa->szModuleName);
- val = db_get_w(NULL, "SimpleStatusMsg", setting, 1024);
+ val = db_get_w(NULL, MODULENAME, setting, 1024);
data->proto_msg[i + 1].max_length = val;
SendDlgItemMessage(hwndDlg, IDC_CBOPTPROTO, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i + 1);
}
@@ -216,7 +216,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CBOPTPROTO, CBN_SELCHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_CBOPTPROTO));
}
- if (db_get_b(NULL, "SimpleStatusMsg", "PutDefInList", 0))
+ if (db_get_b(NULL, MODULENAME, "PutDefInList", 0))
CheckDlgButton(hwndDlg, IDC_COPTMSG2, BST_CHECKED);
if (ServiceExists(MS_VARS_FORMATSTRING)) {
@@ -417,9 +417,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
- char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ char *szSetting = db_get_sa(NULL, MODULENAME, setting);
if (szSetting) {
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg && mir_wstrlen(tszStatusMsg)) {
if (tszStatusMsg && mir_wstrlen(tszStatusMsg))
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
@@ -554,9 +554,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
- char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ char *szSetting = db_get_sa(NULL, MODULENAME, setting);
if (szSetting != nullptr) {
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
@@ -639,9 +639,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(setting, "LastMsg");
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
- char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ char *szSetting = db_get_sa(NULL, MODULENAME, setting);
if (szSetting != nullptr) {
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
@@ -741,9 +741,9 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, L"");
- char *szSetting = db_get_sa(NULL, "SimpleStatusMsg", setting);
+ char *szSetting = db_get_sa(NULL, MODULENAME, setting);
if (szSetting != nullptr) {
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg) {
if (tszStatusMsg[0])
SetDlgItemText(hwndDlg, IDC_OPTEDIT1, tszStatusMsg);
@@ -908,7 +908,7 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++) {
if (accounts->statusMsgFlags & Proto_Status2Flag(i)) {
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(i, "Default"), data->status_msg[0].msg[i - ID_STATUS_ONLINE]);
- db_set_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(i, "Flags"), (BYTE)data->status_msg[0].flags[i - ID_STATUS_ONLINE]);
+ db_set_b(NULL, MODULENAME, StatusModeToDbSetting(i, "Flags"), (BYTE)data->status_msg[0].flags[i - ID_STATUS_ONLINE]);
for (int j = 0; j < accounts->count; j++) {
auto *pa = accounts->pa[j];
@@ -923,16 +923,16 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
db_set_ws(NULL, "SRAway", StatusModeToDbSetting(i, szSetting), data->status_msg[j + 1].msg[i - ID_STATUS_ONLINE]);
mir_snprintf(szSetting, "%sFlags", pa->szModuleName);
- db_set_b(NULL, "SimpleStatusMsg", StatusModeToDbSetting(i, szSetting), (BYTE)data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE]);
+ db_set_b(NULL, MODULENAME, StatusModeToDbSetting(i, szSetting), (BYTE)data->status_msg[j + 1].flags[i - ID_STATUS_ONLINE]);
}
}
}
}
- db_set_b(NULL, "SimpleStatusMsg", "PutDefInList", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_COPTMSG2) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "PutDefInList", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_COPTMSG2) == BST_CHECKED));
if (data->proto_ok) {
- db_set_b(NULL, "SimpleStatusMsg", "ProtoFlags", (BYTE)data->proto_msg[0].flags);
+ db_set_b(NULL, MODULENAME, "ProtoFlags", (BYTE)data->proto_msg[0].flags);
for (int i = 0; i < accounts->count; i++) {
auto *pa = accounts->pa[i];
@@ -947,15 +947,15 @@ INT_PTR CALLBACK DlgOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
mir_snprintf(szSetting, "Proto%sDefault", pa->szModuleName);
if (data->proto_msg[i + 1].msg && (data->proto_msg[i + 1].flags & PROTO_THIS_MSG))
- db_set_ws(NULL, "SimpleStatusMsg", szSetting, data->proto_msg[i + 1].msg);
+ db_set_ws(NULL, MODULENAME, szSetting, data->proto_msg[i + 1].msg);
// else
- // db_unset(NULL, "SimpleStatusMsg", szSetting);
+ // db_unset(NULL, MODULENAME, szSetting);
mir_snprintf(szSetting, "Proto%sMaxLen", pa->szModuleName);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->proto_msg[i + 1].max_length);
+ db_set_w(NULL, MODULENAME, szSetting, (WORD)data->proto_msg[i + 1].max_length);
mir_snprintf(szSetting, "Proto%sFlags", pa->szModuleName);
- db_set_b(NULL, "SimpleStatusMsg", szSetting, (BYTE)data->proto_msg[i + 1].flags);
+ db_set_b(NULL, MODULENAME, szSetting, (BYTE)data->proto_msg[i + 1].flags);
}
}
RebuildStatusMenu();
@@ -987,16 +987,16 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM
SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_ESECUPDTMSG), 0);
SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_SETRANGE32, 1, 999);
- SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_SETPOS, 0, MAKELONG((short)db_get_w(NULL, "SimpleStatusMsg", "UpdateMsgInt", 10), 0));
+ SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_SETPOS, 0, MAKELONG((short)db_get_w(NULL, MODULENAME, "UpdateMsgInt", 10), 0));
SendDlgItemMessage(hwndDlg, IDC_ESECUPDTMSG, EM_LIMITTEXT, 3, 0);
- CheckDlgButton(hwndDlg, IDC_CUPDATEMSG, db_get_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CNOIDLE, db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CNOICQREQ, db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CLEAVEWINAMP, db_get_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CUPDATEMSG, db_get_b(NULL, MODULENAME, "UpdateMsgOn", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CNOIDLE, db_get_b(NULL, MODULENAME, "NoUpdateOnIdle", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CNOICQREQ, db_get_b(NULL, MODULENAME, "NoUpdateOnICQReq", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CLEAVEWINAMP, db_get_b(NULL, MODULENAME, "AmpLeaveTitle", 1) ? BST_CHECKED : BST_UNCHECKED);
if (ServiceExists(MS_VARS_FORMATSTRING)) {
- CheckDlgButton(hwndDlg, IDC_CVARIABLES, db_get_b(NULL, "SimpleStatusMsg", "EnableVariables", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CDATEPARSING, db_get_b(NULL, "SimpleStatusMsg", "ExclDateToken", 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CVARIABLES, db_get_b(NULL, MODULENAME, "EnableVariables", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CDATEPARSING, db_get_b(NULL, MODULENAME, "ExclDateToken", 0) ? BST_CHECKED : BST_UNCHECKED);
}
else {
EnableWindow(GetDlgItem(hwndDlg, IDC_CVARIABLES), FALSE);
@@ -1046,22 +1046,22 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM
KillTimer(nullptr, g_uUpdateMsgTimer);
int val = SendDlgItemMessage(hwndDlg, IDC_SSECUPDTMSG, UDM_GETPOS, 0, 0);
- db_set_w(NULL, "SimpleStatusMsg", "UpdateMsgInt", (WORD)val);
+ db_set_w(NULL, MODULENAME, "UpdateMsgInt", (WORD)val);
if (IsDlgButtonChecked(hwndDlg, IDC_CUPDATEMSG) == BST_CHECKED && val) {
- db_set_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", (BYTE)1);
+ db_set_b(NULL, MODULENAME, "UpdateMsgOn", (BYTE)1);
g_uUpdateMsgTimer = SetTimer(nullptr, 0, val * 1000, (TIMERPROC)UpdateMsgTimerProc);
}
else {
- db_set_b(NULL, "SimpleStatusMsg", "UpdateMsgOn", (BYTE)0);
+ db_set_b(NULL, MODULENAME, "UpdateMsgOn", (BYTE)0);
}
- db_set_b(NULL, "SimpleStatusMsg", "NoUpdateOnIdle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOIDLE) == BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOICQREQ) == BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "AmpLeaveTitle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CLEAVEWINAMP) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "NoUpdateOnIdle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOIDLE) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "NoUpdateOnICQReq", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CNOICQREQ) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "AmpLeaveTitle", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CLEAVEWINAMP) == BST_CHECKED));
if (ServiceExists(MS_VARS_FORMATSTRING)) {
- db_set_b(NULL, "SimpleStatusMsg", "EnableVariables", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CVARIABLES) == BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "ExclDateToken", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CDATEPARSING) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "EnableVariables", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CVARIABLES) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "ExclDateToken", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CDATEPARSING) == BST_CHECKED));
}
return TRUE;
}
@@ -1073,12 +1073,12 @@ static INT_PTR CALLBACK DlgVariablesOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM
static bool IsHistoryMsgsFound(HWND, int histMax)
{
char szSetting[16];
- int j = db_get_w(NULL, "SimpleStatusMsg", "LMMsg", 1);
+ int j = db_get_w(NULL, MODULENAME, "LMMsg", 1);
for (int i = 1; i <= histMax; ++i, --j) {
if (j < 1)
j = histMax;
mir_snprintf(szSetting, "SMsg%d", j);
- wchar_t *tszStatusMsg = db_get_wsa(NULL, "SimpleStatusMsg", szSetting);
+ wchar_t *tszStatusMsg = db_get_wsa(NULL, MODULENAME, szSetting);
if (tszStatusMsg != nullptr) {
if (*tszStatusMsg != '\0') {
mir_free(tszStatusMsg);
@@ -1110,7 +1110,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
SendDlgItemMessage(hwndDlg, IDC_CBOPTBUTTONS, CB_SETITEMDATA, (WPARAM)i_btndownflat, DLG_SHOW_BUTTONS_FLAT);
SendDlgItemMessage(hwndDlg, IDC_CBOPTBUTTONS, CB_SETITEMDATA, (WPARAM)i_btnlist, DLG_SHOW_BUTTONS_INLIST);
- settingValue = db_get_b(NULL, "SimpleStatusMsg", "DlgFlags", DLG_SHOW_DEFAULT);
+ settingValue = db_get_b(NULL, MODULENAME, "DlgFlags", DLG_SHOW_DEFAULT);
CheckDlgButton(hwndDlg, IDC_CSTATUSLIST, settingValue & DLG_SHOW_STATUS ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CPROFILES, settingValue & DLG_SHOW_STATUS_PROFILES ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CICONS1, settingValue & DLG_SHOW_STATUS_ICONS ? BST_CHECKED : BST_UNCHECKED);
@@ -1139,7 +1139,7 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
}
// Misc.
- settingValue = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ settingValue = db_get_b(NULL, MODULENAME, "MaxHist", 10);
SendDlgItemMessage(hwndDlg, IDC_SMAXHIST, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_EMAXHIST), 0);
SendDlgItemMessage(hwndDlg, IDC_SMAXHIST, UDM_SETRANGE32, 0, 25);
@@ -1150,17 +1150,17 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
EnableWindow(GetDlgItem(hwndDlg, IDC_CICONS2), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTHIST), IsHistoryMsgsFound(hwndDlg, settingValue));
- EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTDEF), db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0) != 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTDEF), db_get_w(NULL, MODULENAME, "DefMsgCount", 0) != 0);
SendDlgItemMessage(hwndDlg, IDC_STIMEOUT, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_ETIMEOUT), 0);
SendDlgItemMessage(hwndDlg, IDC_STIMEOUT, UDM_SETRANGE32, 1, 60);
- SendDlgItemMessage(hwndDlg, IDC_STIMEOUT, UDM_SETPOS, 0, MAKELONG((short)db_get_b(NULL, "SimpleStatusMsg", "DlgTime", 5), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STIMEOUT, UDM_SETPOS, 0, MAKELONG((short)db_get_b(NULL, MODULENAME, "DlgTime", 5), 0));
SendDlgItemMessage(hwndDlg, IDC_ETIMEOUT, EM_LIMITTEXT, 2, 0);
- CheckDlgButton(hwndDlg, IDC_CCLOSEWND, db_get_b(NULL, "SimpleStatusMsg", "AutoClose", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CRPOSWND, !db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CREMOVECR, db_get_b(NULL, "SimpleStatusMsg", "RemoveCR", 0) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CSHOWSMSG, db_get_b(NULL, "SimpleStatusMsg", "ShowStatusMenuItem", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CCLOSEWND, db_get_b(NULL, MODULENAME, "AutoClose", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CRPOSWND, !db_get_b(NULL, MODULENAME, "WinCentered", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CREMOVECR, db_get_b(NULL, MODULENAME, "RemoveCR", 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CSHOWSMSG, db_get_b(NULL, MODULENAME, "ShowStatusMenuItem", 1) ? BST_CHECKED : BST_UNCHECKED);
SendMessage(hwndDlg, WM_USER + 2, 0, 0);
return TRUE;
@@ -1222,14 +1222,14 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- int max_hist_msgs = db_get_b(NULL, "SimpleStatusMsg", "MaxHist", 10);
+ int max_hist_msgs = db_get_b(NULL, MODULENAME, "MaxHist", 10);
for (int i = 1; i <= max_hist_msgs; i++) {
char text[8];
mir_snprintf(text, "SMsg%d", i);
- db_set_ws(NULL, "SimpleStatusMsg", text, L"");
+ db_set_ws(NULL, MODULENAME, text, L"");
}
- db_set_s(NULL, "SimpleStatusMsg", "LastMsg", "");
+ db_set_s(NULL, MODULENAME, "LastMsg", "");
for (int i = 0; i < accounts->count; i++) {
auto *pa = accounts->pa[i];
@@ -1244,9 +1244,9 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
char setting[80];
mir_snprintf(setting, "Last%sMsg", pa->szModuleName);
- db_set_s(NULL, "SimpleStatusMsg", setting, "");
+ db_set_s(NULL, MODULENAME, setting, "");
}
- db_set_w(NULL, "SimpleStatusMsg", "LMMsg", (WORD)max_hist_msgs);
+ db_set_w(NULL, MODULENAME, "LMMsg", (WORD)max_hist_msgs);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTHIST), FALSE);
}
return 0;
@@ -1256,13 +1256,13 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
if (hwndSAMsgDialog)
DestroyWindow(hwndSAMsgDialog);
- int nDefMSgCount = db_get_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
+ int nDefMSgCount = db_get_w(NULL, MODULENAME, "DefMsgCount", 0);
for (int i = 1; i <= nDefMSgCount; i++) {
char szSetting[16];
mir_snprintf(szSetting, "DefMsg%d", i);
- db_unset(NULL, "SimpleStatusMsg", szSetting);
+ db_unset(NULL, MODULENAME, szSetting);
}
- db_set_w(NULL, "SimpleStatusMsg", "DefMsgCount", 0);
+ db_set_w(NULL, MODULENAME, "DefMsgCount", 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BOPTDEF), FALSE);
}
return 0;
@@ -1288,15 +1288,15 @@ static INT_PTR CALLBACK DlgAdvancedOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM w
if (curSel != CB_ERR)
flags |= SendDlgItemMessage(hwndDlg, IDC_CBOPTBUTTONS, CB_GETITEMDATA, (WPARAM)curSel, 0);
- db_set_b(NULL, "SimpleStatusMsg", "DlgFlags", (BYTE)flags);
+ db_set_b(NULL, MODULENAME, "DlgFlags", (BYTE)flags);
// Misc.
- db_set_b(NULL, "SimpleStatusMsg", "MaxHist", (BYTE)GetDlgItemInt(hwndDlg, IDC_EMAXHIST, nullptr, FALSE));
- db_set_b(NULL, "SimpleStatusMsg", "AutoClose", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CCLOSEWND) == BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "DlgTime", (BYTE)GetDlgItemInt(hwndDlg, IDC_ETIMEOUT, nullptr, FALSE));
- db_set_b(NULL, "SimpleStatusMsg", "WinCentered", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CRPOSWND) != BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "RemoveCR", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CREMOVECR) == BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "ShowStatusMenuItem", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CSHOWSMSG) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "MaxHist", (BYTE)GetDlgItemInt(hwndDlg, IDC_EMAXHIST, nullptr, FALSE));
+ db_set_b(NULL, MODULENAME, "AutoClose", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CCLOSEWND) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "DlgTime", (BYTE)GetDlgItemInt(hwndDlg, IDC_ETIMEOUT, nullptr, FALSE));
+ db_set_b(NULL, MODULENAME, "WinCentered", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CRPOSWND) != BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "RemoveCR", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CREMOVECR) == BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "ShowStatusMenuItem", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_CSHOWSMSG) == BST_CHECKED));
RebuildStatusMenu();
return TRUE;
@@ -1335,22 +1335,22 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
if (index != LB_ERR && index != LB_ERRSPACE) {
char setting[80];
mir_snprintf(setting, "Startup%sStatus", pa->szModuleName);
- data->status[i] = db_get_w(NULL, "SimpleStatusMsg", setting, ID_STATUS_CURRENT);
+ data->status[i] = db_get_w(NULL, MODULENAME, setting, ID_STATUS_CURRENT);
mir_snprintf(setting, "Set%sStatusDelay", pa->szModuleName);
- data->setdelay[i] = db_get_w(NULL, "SimpleStatusMsg", setting, 300);
+ data->setdelay[i] = db_get_w(NULL, MODULENAME, setting, 300);
SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
}
SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_SETCURSEL, 0, 0);
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_LISTPROTO, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_LISTPROTO));
- data->setglobaldelay = db_get_w(NULL, "SimpleStatusMsg", "SetStatusDelay", 300);
+ data->setglobaldelay = db_get_w(NULL, MODULENAME, "SetStatusDelay", 300);
SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_ESETSTATUS), 0);
SendDlgItemMessage(hwndDlg, IDC_SSETSTATUS, UDM_SETRANGE32, 0, 9000);
SendDlgItemMessage(hwndDlg, IDC_ESETSTATUS, EM_LIMITTEXT, 4, 0);
- if (!db_get_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", 1)) {
+ if (!db_get_b(NULL, MODULENAME, "GlobalStatusDelay", 1)) {
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_CHECKED);
int i = SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_LISTPROTO, LB_GETCURSEL, 0, 0), 0);
SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setdelay[i], FALSE);
@@ -1360,7 +1360,7 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
SetDlgItemInt(hwndDlg, IDC_ESETSTATUS, data->setglobaldelay, FALSE);
}
- if (db_get_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", 1)) {
+ if (db_get_b(NULL, MODULENAME, "StartupPopupDlg", 1)) {
CheckDlgButton(hwndDlg, IDC_POPUPDLG, BST_CHECKED);
if (IsDlgButtonChecked(hwndDlg, IDC_SPECSET) == BST_CHECKED) {
CheckDlgButton(hwndDlg, IDC_SPECSET, BST_UNCHECKED);
@@ -1499,14 +1499,14 @@ static INT_PTR CALLBACK DlgStatusOptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
char szSetting[80];
mir_snprintf(szSetting, "Startup%sStatus", pa->szModuleName);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->status[i]);
+ db_set_w(NULL, MODULENAME, szSetting, (WORD)data->status[i]);
mir_snprintf(szSetting, "Set%sStatusDelay", pa->szModuleName);
- db_set_w(NULL, "SimpleStatusMsg", szSetting, (WORD)data->setdelay[i]);
+ db_set_w(NULL, MODULENAME, szSetting, (WORD)data->setdelay[i]);
}
- db_set_w(NULL, "SimpleStatusMsg", "SetStatusDelay", (WORD)data->setglobaldelay);
- db_set_b(NULL, "SimpleStatusMsg", "GlobalStatusDelay", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SPECSET) != BST_CHECKED));
- db_set_b(NULL, "SimpleStatusMsg", "StartupPopupDlg", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_POPUPDLG) == BST_CHECKED));
+ db_set_w(NULL, MODULENAME, "SetStatusDelay", (WORD)data->setglobaldelay);
+ db_set_b(NULL, MODULENAME, "GlobalStatusDelay", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_SPECSET) != BST_CHECKED));
+ db_set_b(NULL, MODULENAME, "StartupPopupDlg", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_POPUPDLG) == BST_CHECKED));
return TRUE;
}
break;
@@ -1526,7 +1526,7 @@ int InitOptions(WPARAM wParam, LPARAM)
return 0;
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS;
if (!ServiceExists(MS_SS_GETPROFILECOUNT)) {
diff --git a/plugins/SimpleStatusMsg/src/simplestatusmsg.h b/plugins/SimpleStatusMsg/src/simplestatusmsg.h
index 7b027b8e58..08b03f1d15 100644
--- a/plugins/SimpleStatusMsg/src/simplestatusmsg.h
+++ b/plugins/SimpleStatusMsg/src/simplestatusmsg.h
@@ -21,16 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SIMPLESTATUSMSG_H__
#define SIMPLESTATUSMSG_H__ 1
-typedef struct tagACCOUNTS
+struct PROTOACCOUNTS
{
- PROTOACCOUNT **pa;
- int count;
- int statusCount;
- DWORD statusFlags;
- int statusMsgCount;
- DWORD statusMsgFlags;
-}
-PROTOACCOUNTS;
+ PROTOACCOUNT **pa;
+ int count;
+ int statusCount;
+ DWORD statusFlags;
+ int statusMsgCount;
+ DWORD statusMsgFlags;
+};
extern PROTOACCOUNTS *accounts;
@@ -39,11 +38,11 @@ extern PROTOACCOUNTS *accounts;
#define DLG_SHOW_STATUS 1
#define DLG_SHOW_STATUS_ICONS 2
-#define DLG_SHOW_LIST_ICONS 4
+#define DLG_SHOW_LIST_ICONS 4
#define DLG_SHOW_BUTTONS 8
-#define DLG_SHOW_BUTTONS_INLIST 16
+#define DLG_SHOW_BUTTONS_INLIST 16
#define DLG_SHOW_BUTTONS_FLAT 32
-#define DLG_SHOW_STATUS_PROFILES 64
+#define DLG_SHOW_STATUS_PROFILES 64
//NOTE: MAX 128
#define DLG_SHOW_DEFAULT DLG_SHOW_STATUS | DLG_SHOW_STATUS_ICONS | DLG_SHOW_LIST_ICONS | DLG_SHOW_BUTTONS
@@ -71,7 +70,6 @@ struct MsgBoxInitData
BOOL m_bOnStartup;
};
-extern HINSTANCE g_hInst;
extern HWND hwndSAMsgDialog;
#define MS_SIMPLESTATUSMSG_SHOWDIALOGINT "SimpleStatusMsg/ShowDialogInternal" // internal use ONLY
diff --git a/plugins/SimpleStatusMsg/src/stdafx.h b/plugins/SimpleStatusMsg/src/stdafx.h
index 64928dfee7..4a0082bf49 100644
--- a/plugins/SimpleStatusMsg/src/stdafx.h
+++ b/plugins/SimpleStatusMsg/src/stdafx.h
@@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <windowsx.h>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_clistint.h>
@@ -45,6 +44,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <m_variables.h>
#include <m_simplestatusmsg.h>
+#define MODULENAME "SimpleStatusMsg"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
#include "simplestatusmsg.h"
#include "resource.h"
#include "version.h"
diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp
index 1b046968ff..0c127418ca 100644
--- a/plugins/SimpleStatusMsg/src/utils.cpp
+++ b/plugins/SimpleStatusMsg/src/utils.cpp
@@ -36,7 +36,7 @@ static IconItem iconList[] =
void IconsInit(void)
{
- Icon_Register(g_hInst, LPGEN("Simple Status Message"), iconList, _countof(iconList), "SimpleStatusMsg");
+ Icon_Register(g_plugin.getInst(), LPGEN("Simple Status Message"), iconList, _countof(iconList), MODULENAME);
}
HICON LoadIconEx(const char *name)
@@ -135,7 +135,7 @@ int GetCurrentStatus(const char *szProto)
if (szProto) {
char szSetting[80];
mir_snprintf(szSetting, "Cur%sStatus", szProto);
- return (int)db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_OFFLINE);
+ return (int)db_get_w(NULL, MODULENAME, szSetting, ID_STATUS_OFFLINE);
}
return CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
@@ -148,13 +148,13 @@ int GetStartupStatus(const char *szProto)
char szSetting[80];
mir_snprintf(szSetting, "Startup%sStatus", szProto);
- status_mode = db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_CURRENT);
+ status_mode = db_get_w(NULL, MODULENAME, szSetting, ID_STATUS_CURRENT);
if (status_mode == ID_STATUS_CURRENT) {
// load status used for this proto last time
mir_snprintf(szSetting, "Last%sStatus", szProto);
- status_mode = db_get_w(NULL, "SimpleStatusMsg", szSetting, ID_STATUS_OFFLINE);
+ status_mode = db_get_w(NULL, MODULENAME, szSetting, ID_STATUS_OFFLINE);
}
return status_mode;
}
- return (int)db_get_w(NULL, "SimpleStatusMsg", "StartupStatus", ID_STATUS_OFFLINE);
+ return (int)db_get_w(NULL, MODULENAME, "StartupStatus", ID_STATUS_OFFLINE);
}
diff --git a/plugins/SkypeStatusChange/src/main.cpp b/plugins/SkypeStatusChange/src/main.cpp
index 5bd5d69fa5..94fd2c560a 100644
--- a/plugins/SkypeStatusChange/src/main.cpp
+++ b/plugins/SkypeStatusChange/src/main.cpp
@@ -5,10 +5,22 @@
#pragma comment(lib, "Comctl32.lib")
int hLangpack = 0;
+CMPlugin g_plugin;
int SSC_OptInitialise(WPARAM wp, LPARAM lp);
-PLUGININFOEX g_pluginInfo =
+UINT g_MsgIDSkypeControlAPIAttach = 0;
+UINT g_MsgIDSkypeControlAPIDiscover = 0;
+HWND g_wndMainWindow = nullptr;
+
+bool g_bMirandaIsShutdown = false;
+
+HANDLE g_hThread = nullptr;
+HANDLE g_hEventShutdown = nullptr;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static PLUGININFOEX g_pluginInfo =
{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -17,20 +29,16 @@ PLUGININFOEX g_pluginInfo =
__AUTHOR,
__COPYRIGHT,
__AUTHORWEB,
- UNICODE_AWARE, //not transient
- { 0x2925520b, 0x6677, 0x4658, { 0x8b, 0xad, 0x56, 0x61, 0xd1, 0x3e, 0x46, 0x92 } }
+ UNICODE_AWARE,
+ { 0x2925520b, 0x6677, 0x4658, { 0x8b, 0xad, 0x56, 0x61, 0xd1, 0x3e, 0x46, 0x92 }}
};
-HINSTANCE g_hModule = nullptr;
-
-UINT g_MsgIDSkypeControlAPIAttach = 0;
-UINT g_MsgIDSkypeControlAPIDiscover = 0;
-HWND g_wndMainWindow = nullptr;
-
-HANDLE g_hThread = nullptr;
-HANDLE g_hEventShutdown = nullptr;
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &g_pluginInfo;
+}
-bool g_bMirandaIsShutdown = false;
+/////////////////////////////////////////////////////////////////////////////////////////
enum
{
@@ -84,8 +92,8 @@ private:
size_t m_nStatusIndex;
};
-COptions g_Options;
-CStatusInfo g_CurrStatusInfo;
+COptions g_Options;
+CStatusInfo g_CurrStatusInfo;
mir_cs g_csStatusInfo;
int SSC_OnProtocolAck(WPARAM, LPARAM lParam)
@@ -253,25 +261,12 @@ int SSC_OnPreShutdown(WPARAM/* wParam*/, LPARAM/* lParam*/)
g_wndMainWindow = nullptr;
}
- UnregisterClass(g_pszSkypeWndClassName, g_hModule);
+ UnregisterClass(g_pszSkypeWndClassName, g_plugin.getInst());
return 0;
}
/******************************* INSTALLATION PROCEDURES *****************************/
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
-{
- if (fdwReason == DLL_PROCESS_ATTACH)
- g_hModule = hinstDLL;
-
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &g_pluginInfo;
-}
-
extern "C" int __declspec(dllexport) Load()
{
mir_getLP(&g_pluginInfo);
@@ -284,14 +279,14 @@ extern "C" int __declspec(dllexport) Load()
WNDCLASS oWindowClass = { 0 };
oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
oWindowClass.lpfnWndProc = (WNDPROC)&SkypeAPI_WindowProc;
- oWindowClass.hInstance = g_hModule;
+ oWindowClass.hInstance = g_plugin.getInst();
oWindowClass.lpszClassName = g_pszSkypeWndClassName;
if (!RegisterClass(&oWindowClass))
return 1;
g_wndMainWindow = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
g_pszSkypeWndClassName, L"", WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, 128, 128, nullptr, nullptr, g_hModule, nullptr);
+ CW_USEDEFAULT, CW_USEDEFAULT, 128, 128, nullptr, nullptr, g_plugin.getInst(), nullptr);
if (g_wndMainWindow == nullptr)
return 1;
@@ -306,6 +301,8 @@ extern "C" int __declspec(dllexport) Load()
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void) // Executed on DLL unload
{
return 0;
diff --git a/plugins/SkypeStatusChange/src/options.cpp b/plugins/SkypeStatusChange/src/options.cpp
index b80d7abfb2..fc3e2dfab8 100644
--- a/plugins/SkypeStatusChange/src/options.cpp
+++ b/plugins/SkypeStatusChange/src/options.cpp
@@ -204,7 +204,7 @@ class CImageListWrapper
{
public:
CImageListWrapper()
- : m_hImageList(ImageList_LoadImage(g_hModule,MAKEINTRESOURCE(IDB_TREE_STATE),16,0,RGB(255,255,255),IMAGE_BITMAP,LR_DEFAULTCOLOR))
+ : m_hImageList(ImageList_LoadImage(g_plugin.getInst(),MAKEINTRESOURCE(IDB_TREE_STATE),16,0,RGB(255,255,255),IMAGE_BITMAP,LR_DEFAULTCOLOR))
{
}
@@ -301,7 +301,7 @@ int SSC_OptInitialise(WPARAM wp, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 910000000;
- odp.hInstance = g_hModule;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.a = LPGEN("Change Skype status");
odp.szGroup.a = LPGEN("Plugins");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_SETTINGS);
diff --git a/plugins/SkypeStatusChange/src/stdafx.h b/plugins/SkypeStatusChange/src/stdafx.h
index efe7b97572..d143849cc9 100644
--- a/plugins/SkypeStatusChange/src/stdafx.h
+++ b/plugins/SkypeStatusChange/src/stdafx.h
@@ -5,7 +5,6 @@
#include <assert.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_protocols.h>
@@ -18,6 +17,13 @@
#define MODULENAME "Change Skype Status"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
class COptions
{
enum
@@ -163,7 +169,3 @@ struct CMirandaStatus2SkypeStatus
};
extern const CMirandaStatus2SkypeStatus g_aStatusCode[10];
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-extern HINSTANCE g_hModule; \ No newline at end of file
diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
index 884b323837..674e311427 100644
--- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp
+++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
@@ -155,7 +155,7 @@ int SmileyButtonCreate(WPARAM, LPARAM)
desc.szSection.a = BB_HK_SECTION;
desc.szDescription.a = LPGEN("Smiley selector");
desc.DefHotKey = HOTKEYCODE(HOTKEYF_ALT, 'E');
- desc.lParam = LPARAM(g_hInst);
+ desc.lParam = LPARAM(g_plugin.getInst());
Hotkey_Register(&desc);
BBButton bbd = {};
diff --git a/plugins/SmileyAdd/src/general.cpp b/plugins/SmileyAdd/src/general.cpp
index e23f1e835b..af943b4c4e 100644
--- a/plugins/SmileyAdd/src/general.cpp
+++ b/plugins/SmileyAdd/src/general.cpp
@@ -50,7 +50,7 @@ HICON GetDefaultIcon(bool copy)
{
HICON resIco = IcoLib_GetIcon("SmileyAdd_ButtonSmiley");
if (resIco == nullptr)
- resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON), IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
+ resIco = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SMILINGICON), IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
else if (copy) {
resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0);
IcoLib_Release("SmileyAdd_ButtonSmiley");
diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp
index 05698d2c75..0d936dec12 100644
--- a/plugins/SmileyAdd/src/main.cpp
+++ b/plugins/SmileyAdd/src/main.cpp
@@ -20,11 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
// globals
-HINSTANCE g_hInst;
HANDLE hEvent1;
HGENMENU hContactMenuItem;
int hLangpack;
+CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
static const PLUGININFOEX pluginInfoEx =
{
@@ -45,6 +47,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD /* mira
return (PLUGININFOEX*)&pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
static IconItem icon = { LPGEN("Button smiley"), "SmileyAdd_ButtonSmiley", IDI_SMILINGICON };
static int ModulesLoaded(WPARAM, LPARAM)
@@ -91,7 +95,7 @@ extern "C" __declspec(dllexport) int Load(void)
InitImageCache();
- Icon_Register(g_hInst, MODULENAME, &icon, 1);
+ Icon_Register(g_plugin.getInst(), MODULENAME, &icon, 1);
g_SmileyCategories.SetSmileyPackStore(&g_SmileyPacks);
@@ -125,6 +129,8 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
RemoveDialogBoxHook();
@@ -142,18 +148,3 @@ extern "C" __declspec(dllexport) int Unload(void)
DownloadClose();
return 0;
}
-
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID /*lpvReserved*/)
-{
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- g_hInst = hinstDLL;
- DisableThreadLibraryCalls(hinstDLL);
- break;
-
- case DLL_PROCESS_DETACH:
- break;
- }
-
- return TRUE;
-}
diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp
index de31cf1b8a..9f90a17076 100644
--- a/plugins/SmileyAdd/src/options.cpp
+++ b/plugins/SmileyAdd/src/options.cpp
@@ -655,7 +655,7 @@ int SmileysOptionsInitialize(WPARAM addInfo, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 910000000;
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SMILEYS);
odp.szTitle.a = LPGEN("Smileys");
odp.szGroup.a = LPGEN("Customize");
diff --git a/plugins/SmileyAdd/src/richcall.cpp b/plugins/SmileyAdd/src/richcall.cpp
index a5a81e12cb..ed87211546 100644
--- a/plugins/SmileyAdd/src/richcall.cpp
+++ b/plugins/SmileyAdd/src/richcall.cpp
@@ -107,7 +107,7 @@ static void SetTooltip(long x, long y, HWND hwnd, RichEditData *rdt)
if (needtip != -1) {
if (rdt->tipActive == -1) {
rdt->hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", TTS_NOPREFIX | WS_POPUP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, nullptr, g_hInst, nullptr);
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, nullptr, g_plugin.getInst(), nullptr);
SendMessage(rdt->hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
}
diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp
index d264e314e4..8a74e9d753 100644
--- a/plugins/SmileyAdd/src/smltool.cpp
+++ b/plugins/SmileyAdd/src/smltool.cpp
@@ -552,7 +552,7 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam)
//add tooltips
m_hToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"",
- TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, nullptr, g_hInst, nullptr);
+ TTS_NOPREFIX | WS_POPUP, 0, 0, 0, 0, m_hwndDialog, nullptr, g_plugin.getInst(), nullptr);
TOOLINFO ti = { 0 };
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
@@ -748,7 +748,7 @@ void __cdecl SmileyToolThread(SmileyToolWindowParam *stwp)
wndclass.lpfnWndProc = DlgProcSmileyToolWindow;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 4;
- wndclass.hInstance = g_hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = nullptr;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = CreateSolidBrush(opt.SelWndBkgClr);
@@ -760,7 +760,7 @@ void __cdecl SmileyToolThread(SmileyToolWindowParam *stwp)
CreateWindowEx(WS_EX_TOPMOST | WS_EX_NOPARENTNOTIFY, L"SmileyTool", nullptr,
WS_BORDER | WS_POPUP | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- stwp->hWndParent, nullptr, g_hInst, stwp);
+ stwp->hWndParent, nullptr, g_plugin.getInst(), stwp);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
@@ -769,7 +769,7 @@ void __cdecl SmileyToolThread(SmileyToolWindowParam *stwp)
TranslateMessage(&msg);
DispatchMessage(&msg);
}
- UnregisterClass(L"SmileyTool", g_hInst);
+ UnregisterClass(L"SmileyTool", g_plugin.getInst());
}
delete stwp;
}
diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h
index 22ac7afc7d..94092b9044 100644
--- a/plugins/SmileyAdd/src/stdafx.h
+++ b/plugins/SmileyAdd/src/stdafx.h
@@ -50,7 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define NETLIB_NOLOGGING
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_clist.h>
@@ -88,7 +87,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "smileyroutines.h"
#include "smltool.h"
-extern HINSTANCE g_hInst;
extern HNETLIBUSER hNetlibUser;
extern HANDLE hEvent1;
extern HGENMENU hContactMenuItem;
@@ -98,6 +96,13 @@ extern LIST<void> menuHandleArray;
#define MODULENAME "SmileyAdd"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
#define DM_REMAKELOG (WM_USER + 11)
#define DM_OPTIONSAPPLIED (WM_USER + 14)
#define DM_APPENDTOLOG (WM_USER + 17)