diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 17:09:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 17:09:50 +0300 |
commit | bce8bc74daf1c5f510404c8bdf956b41fb1c10fc (patch) | |
tree | 9879ad5ce5f42087558601af6a6f2827d7df4c39 | |
parent | ba1083b4da33ca44a5ae7d90eabbe3d6d340a81e (diff) |
WinterSpeak, WhoUsesMyFiles, WhenWasIt, wbOSD, Watrack_MPD -> CMPlugin
-rwxr-xr-x | plugins/Watrack_MPD/src/init.cpp | 35 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/main.cpp | 2 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/options.cpp | 2 | ||||
-rwxr-xr-x | plugins/Watrack_MPD/src/stdafx.h | 10 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/WhenWasIt.cpp | 16 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/hooked_events.cpp | 2 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/icons.cpp | 2 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/notifiers.cpp | 4 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/services.cpp | 8 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/stdafx.h | 12 | ||||
-rw-r--r-- | plugins/WhoUsesMyFiles/src/options.cpp | 281 | ||||
-rw-r--r-- | plugins/WhoUsesMyFiles/src/stdafx.h | 13 | ||||
-rw-r--r-- | plugins/WhoUsesMyFiles/src/wumf.cpp | 2 | ||||
-rw-r--r-- | plugins/WhoUsesMyFiles/src/wumfplug.cpp | 387 | ||||
-rw-r--r-- | plugins/WinterSpeak/src/SpeechApi51Lexicon.cpp | 5 | ||||
-rw-r--r-- | plugins/WinterSpeak/src/main.cpp | 29 | ||||
-rw-r--r-- | plugins/WinterSpeak/src/stdafx.h | 8 | ||||
-rw-r--r-- | plugins/wbOSD/src/main.cpp | 20 | ||||
-rw-r--r-- | plugins/wbOSD/src/options.cpp | 4 | ||||
-rw-r--r-- | plugins/wbOSD/src/stdafx.h | 21 | ||||
-rw-r--r-- | plugins/wbOSD/src/wbOSD.cpp | 16 |
21 files changed, 452 insertions, 427 deletions
diff --git a/plugins/Watrack_MPD/src/init.cpp b/plugins/Watrack_MPD/src/init.cpp index 9d28c299ff..b764322a32 100755 --- a/plugins/Watrack_MPD/src/init.cpp +++ b/plugins/Watrack_MPD/src/init.cpp @@ -16,14 +16,18 @@ #include "stdafx.h"
-HINSTANCE hInst;
+int hLangpack;
+CMPlugin g_plugin;
+
BOOL bWatrackService = FALSE;
-int hLangpack = 0;
wchar_t *gbHost, *gbPassword;
WORD gbPort;
HNETLIBUSER ghNetlibUser;
-PLUGININFOEX pluginInfo={
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -33,26 +37,15 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB,
UNICODE_AWARE,
// 692E87D0-6C71-4CDC-9E36-2B69FBDC4C
- {0x692e87d0, 0x6c71, 0x4cdc, {0x9e, 0x36, 0x2b, 0x2d, 0x69, 0xfb, 0xdc, 0x4c}}
+ { 0x692e87d0, 0x6c71, 0x4cdc, {0x9e, 0x36, 0x2b, 0x2d, 0x69, 0xfb, 0xdc, 0x4c }}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
-void InitVars()
-{
- gbPort = db_get_w(NULL, szModuleName, "Port", 6600);
- gbHost = UniGetContactSettingUtf(NULL, szModuleName, "Server", L"127.0.0.1");
- gbPassword = UniGetContactSettingUtf(NULL, szModuleName, "Password", L"");
-}
+/////////////////////////////////////////////////////////////////////////////////////////
static int OnModulesLoaded(WPARAM, LPARAM)
{
@@ -61,11 +54,15 @@ static int OnModulesLoaded(WPARAM, LPARAM) nlu.szDescriptiveName.w = TranslateT("Watrack MPD connection");
nlu.szSettingsModule = __PLUGIN_NAME;
ghNetlibUser = Netlib_RegisterUser(&nlu);
- InitVars();
+
+ gbPort = db_get_w(NULL, szModuleName, "Port", 6600);
+ gbHost = UniGetContactSettingUtf(NULL, szModuleName, "Server", L"127.0.0.1");
+ gbPassword = UniGetContactSettingUtf(NULL, szModuleName, "Password", L"");
+
if (ServiceExists(MS_WAT_PLAYER))
bWatrackService = TRUE;
- RegisterPlayer();
+ RegisterPlayer();
return 0;
}
@@ -78,6 +75,8 @@ extern "C" __declspec(dllexport) int Load() return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
mir_free(gbHost);
diff --git a/plugins/Watrack_MPD/src/main.cpp b/plugins/Watrack_MPD/src/main.cpp index 913bc19f84..ebd5de898f 100755 --- a/plugins/Watrack_MPD/src/main.cpp +++ b/plugins/Watrack_MPD/src/main.cpp @@ -413,4 +413,4 @@ void RegisterPlayer() // player.Icon = //TODO:implement icon support CallService(MS_WAT_PLAYER, WAT_ACT_REGISTER, (LPARAM)&player); } -}
\ No newline at end of file +} diff --git a/plugins/Watrack_MPD/src/options.cpp b/plugins/Watrack_MPD/src/options.cpp index b615ee3826..8d7c28bc6f 100755 --- a/plugins/Watrack_MPD/src/options.cpp +++ b/plugins/Watrack_MPD/src/options.cpp @@ -19,7 +19,7 @@ class COptWaMpdDlg : public CDlgBase { public: - COptWaMpdDlg() : CDlgBase(hInst, IDD_OPT_WA_MPD), + COptWaMpdDlg() : CDlgBase(g_plugin.getInst(), IDD_OPT_WA_MPD), edit_PORT(this, IDC_PORT), edit_SERVER(this, IDC_SERVER), edit_PASSWORD(this, IDC_PASSWORD) {} virtual void OnInitDialog() override diff --git a/plugins/Watrack_MPD/src/stdafx.h b/plugins/Watrack_MPD/src/stdafx.h index 2b17d1d703..161ccb2209 100755 --- a/plugins/Watrack_MPD/src/stdafx.h +++ b/plugins/Watrack_MPD/src/stdafx.h @@ -18,7 +18,6 @@ #include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_netlib.h>
@@ -35,12 +34,17 @@ #define szModuleName "Watrack_MPD"
-extern HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(szModuleName)
+ {}
+};
+
extern HNETLIBUSER ghNetlibUser;
extern BOOL bWatrackService;
extern wchar_t *gbHost, *gbPassword;
extern WORD gbPort;
-extern char *date();
extern int WaMpdOptInit(WPARAM, LPARAM);
extern void RegisterPlayer();
diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp index c395ad5687..87de917e0e 100644 --- a/plugins/WhenWasIt/src/WhenWasIt.cpp +++ b/plugins/WhenWasIt/src/WhenWasIt.cpp @@ -20,15 +20,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-char ModuleName[] = "WhenWasIt";
-HINSTANCE hInstance;
HWND hBirthdaysDlg = nullptr;
HWND hUpcomingDlg = nullptr;
MWindowList hAddBirthdayWndsList = nullptr;
+
+CMPlugin g_plugin;
int hLangpack;
CommonData commonData = { 0 };
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -47,6 +49,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Load(void)
{
Log("%s", "Entering function " __FUNCTION__);
@@ -134,6 +138,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload()
{
Log("%s", "Entering function " __FUNCTION__);
@@ -153,9 +159,3 @@ extern "C" int __declspec(dllexport) Unload() Log("%s", "Leaving function " __FUNCTION__);
return 0;
}
-
-bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInstance = hinstDLL;
- return TRUE;
-}
diff --git a/plugins/WhenWasIt/src/hooked_events.cpp b/plugins/WhenWasIt/src/hooked_events.cpp index c25bcc9eeb..7aa2881a96 100644 --- a/plugins/WhenWasIt/src/hooked_events.cpp +++ b/plugins/WhenWasIt/src/hooked_events.cpp @@ -44,7 +44,7 @@ static int OnOptionsInitialise(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_WWI);
odp.szTitle.w = LPGENW("Birthdays");
odp.szGroup.w = LPGENW("Contacts");
diff --git a/plugins/WhenWasIt/src/icons.cpp b/plugins/WhenWasIt/src/icons.cpp index 9cb6c49b3e..5b2092ced6 100644 --- a/plugins/WhenWasIt/src/icons.cpp +++ b/plugins/WhenWasIt/src/icons.cpp @@ -44,7 +44,7 @@ static HANDLE AddIcon(char *name, char *description, wchar_t *tszPath, int iDefa int AddIcons()
{
wchar_t tszPath[MAX_PATH];
- GetModuleFileName(hInstance, tszPath, _countof(tszPath));
+ GetModuleFileName(g_plugin.getInst(), tszPath, _countof(tszPath));
hCheckMenu = AddIcon("MenuCheck", LPGEN("Check birthdays menu item"), tszPath, IDI_CHECK);
hListMenu = AddIcon("MenuList", LPGEN("List birthdays menu item"), tszPath, IDI_LIST);
diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp index ba5fc70842..ca672632c0 100644 --- a/plugins/WhenWasIt/src/notifiers.cpp +++ b/plugins/WhenWasIt/src/notifiers.cpp @@ -154,7 +154,7 @@ int DialogNotifyBirthday(MCONTACT hContact, int dtb, int age) wchar_t text[1024];
BuildDTBText(dtb, name, text, _countof(text));
if (!hUpcomingDlg) {
- hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), nullptr, DlgProcUpcoming);
+ hUpcomingDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UPCOMING), nullptr, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
}
@@ -176,7 +176,7 @@ int DialogNotifyMissedBirthday(MCONTACT hContact, int dab, int age) wchar_t text[1024];
BuildDABText(dab, name, text, _countof(text));
if (!hUpcomingDlg) {
- hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), nullptr, DlgProcUpcoming);
+ hUpcomingDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UPCOMING), nullptr, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
}
diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp index 4a1c23b575..1790c0c8f6 100644 --- a/plugins/WhenWasIt/src/services.cpp +++ b/plugins/WhenWasIt/src/services.cpp @@ -139,7 +139,7 @@ INT_PTR CheckBirthdaysService(WPARAM, LPARAM lParam) INT_PTR ShowListService(WPARAM, LPARAM)
{
if (!hBirthdaysDlg)
- hBirthdaysDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_BIRTHDAYS), nullptr, DlgProcBirthdays);
+ hBirthdaysDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_BIRTHDAYS), nullptr, DlgProcBirthdays);
ShowWindow(hBirthdaysDlg, SW_SHOW);
return 0;
@@ -149,7 +149,7 @@ INT_PTR AddBirthdayService(WPARAM hContact, LPARAM) {
HWND hWnd = WindowList_Find(hAddBirthdayWndsList, hContact);
if (!hWnd)
- hWnd = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), nullptr, DlgProcAddBirthday, hContact);
+ hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), nullptr, DlgProcAddBirthday, hContact);
return ShowWindow(hWnd, SW_SHOW);
}
@@ -193,7 +193,7 @@ INT_PTR ImportBirthdaysService(WPARAM, LPARAM) wchar_t fileName[1024] = { 0 };
OPENFILENAME of = { 0 };
of.lStructSize = sizeof(OPENFILENAME);
- //of.hInstance = hInstance;
+ //of.g_plugin.getInst() = g_plugin.getInst();
wchar_t filter[MAX_PATH];
mir_snwprintf(filter, L"%s (*" BIRTHDAY_EXTENSION L")%c*" BIRTHDAY_EXTENSION L"%c", TranslateT("Birthdays files"), 0, 0);
of.lpstrFilter = filter;
@@ -218,7 +218,7 @@ INT_PTR ExportBirthdaysService(WPARAM, LPARAM) wchar_t fileName[1024] = { 0 };
OPENFILENAME of = { 0 };
of.lStructSize = sizeof(OPENFILENAME);
- //of.hInstance = hInstance;
+ //of.g_plugin.getInst() = g_plugin.getInst();
wchar_t filter[MAX_PATH];
mir_snwprintf(filter, L"%s (*" BIRTHDAY_EXTENSION L")%c*" BIRTHDAY_EXTENSION L"%c%s (*.*)%c*.*%c", TranslateT("Birthdays files"), 0, 0, TranslateT("All Files"), 0, 0);
of.lpstrFilter = filter;
diff --git a/plugins/WhenWasIt/src/stdafx.h b/plugins/WhenWasIt/src/stdafx.h index a562fb8890..f9bdc75670 100644 --- a/plugins/WhenWasIt/src/stdafx.h +++ b/plugins/WhenWasIt/src/stdafx.h @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <math.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_skin.h>
@@ -62,8 +61,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "dlg_handlers.h"
#include "events.h"
-extern char ModuleName[];
-extern HINSTANCE hInstance;
+#define ModuleName "WhenWasIt"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(ModuleName)
+ {}
+};
+
extern HWND hBirthdaysDlg;
extern HWND hUpcomingDlg;
extern MWindowList hAddBirthdayWndsList;
diff --git a/plugins/WhoUsesMyFiles/src/options.cpp b/plugins/WhoUsesMyFiles/src/options.cpp new file mode 100644 index 0000000000..17808930c8 --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/options.cpp @@ -0,0 +1,281 @@ +/* +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" + +void ShowThePreview() +{ + if (!ServiceExists(MS_POPUP_ADDPOPUPT)) { + MessageBox(nullptr, TranslateT("Popup plugin not found!"), TranslateT("Error"), MB_OK | MB_ICONSTOP); + return; + } + + if (WumfOptions.AlertFolders) { + ShowThePopup(nullptr, L"Guest", L"C:\\My Share"); + Sleep(300); + ShowThePopup(nullptr, L"Guest", L"C:\\My Share\\Photos"); + Sleep(300); + } + ShowThePopup(nullptr, L"Guest", L"C:\\Share\\My Photos\\photo.jpg"); + Sleep(300); + if (WumfOptions.AlertFolders) { + ShowThePopup(nullptr, L"User", L"C:\\My Share"); + Sleep(300); + ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies"); + Sleep(300); + } + ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies\\The Two Towers.avi"); + Sleep(300); + if (WumfOptions.AlertFolders) { + ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives"); + Sleep(300); + ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k"); + Sleep(300); + } + ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k\\setup.exe"); +} + +void DisableDelayOptions(HWND hwndDlg) +{ + CheckDlgButton(hwndDlg, IDC_DELAY_INF,BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_SET,BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_DEF,BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_INF), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SET), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_DEF), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TX_DELAY_SEC), FALSE); +} + +void ChooseFile(HWND hwndDlg) +{ + wchar_t szFile[MAX_PATH]; szFile[0]=0; + + // Initialize OPENFILENAME + OPENFILENAME ofn = {0}; // common dialog box structure + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwndDlg; + ofn.lpstrFile = szFile; + ofn.nMaxFile = _countof(szFile); + ofn.lpstrFilter = L"All files (*.*)\0*.*\0Text files (*.txt)\0*.txt\0Log files (*.log)\0*.log\0\0"; + ofn.nFilterIndex = 2; + ofn.Flags = OFN_CREATEPROMPT; + // Display the Open dialog box. + if (GetSaveFileName(&ofn)) { + HANDLE hf = CreateFile(szFile,GENERIC_WRITE,0,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, nullptr); + if (hf != INVALID_HANDLE_VALUE) { + SetDlgItemText(hwndDlg,IDC_FILE,szFile); + mir_wstrncpy(WumfOptions.LogFile, szFile, MAX_PATH); + CloseHandle(hf); + } + } + else if (CommDlgExtendedError() != 0) { + wchar_t str[256]; + mir_snwprintf(str, TranslateT("Common Dialog Error 0x%lx"), CommDlgExtendedError()); + MessageBox(hwndDlg, str, TranslateT("Error"), MB_OK | MB_ICONSTOP); + } +} + +INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + WORD wControlId = LOWORD(wparam); + WORD wNotifyCode = HIWORD(wparam); + int seconds; + + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg, IDC_COLOR_WIN, WumfOptions.UseWinColor ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_COLOR_DEF, WumfOptions.UseDefColor ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_COLOR_SET, WumfOptions.SelectColor ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK), WumfOptions.SelectColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); + if (WumfOptions.SelectColor) { + SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); + SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); + } + if ( !ServiceExists(MS_POPUP_ADDPOPUPT)) { + DisableDelayOptions(hwndDlg); + break; + } + CheckDlgButton(hwndDlg, IDC_DELAY_INF, WumfOptions.DelayInf ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_DEF, WumfOptions.DelayDef ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_SET, WumfOptions.DelaySet ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); + //Logging & alerts + CheckDlgButton(hwndDlg, IDC_LOG_FOLDER, WumfOptions.LogFolders ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALERT_FOLDER, WumfOptions.AlertFolders ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOG_UNC, WumfOptions.LogUNC ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALERT_UNC, WumfOptions.AlertUNC ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOG_COMP, WumfOptions.LogComp ? BST_CHECKED : BST_UNCHECKED); + + if (WumfOptions.LogToFile) { + CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), TRUE); + SetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile); + } + else { + CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), FALSE); + SetDlgItemText(hwndDlg, IDC_FILE, L""); + } + break; + + case WM_COMMAND: + switch(wNotifyCode) { + case BN_CLICKED : + switch(wControlId) { + case IDC_DELAY_SET: + case IDC_DELAY_DEF: + case IDC_DELAY_INF: + WumfOptions.DelaySet = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_SET) == BST_CHECKED); + WumfOptions.DelayDef = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_DEF) == BST_CHECKED); + WumfOptions.DelayInf = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_INF) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, TRUE); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_COLOR_SET: + case IDC_COLOR_DEF: + case IDC_COLOR_WIN: + WumfOptions.SelectColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_SET) == BST_CHECKED); + WumfOptions.UseDefColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_DEF) == BST_CHECKED); + WumfOptions.UseWinColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_WIN) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK),WumfOptions.SelectColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); + SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); + SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + /* not implemented */ + case IDC_LOG_COMP: + case IDC_ALERT_COMP: + case IDC_LOG_UNC: + case IDC_ALERT_UNC: + MessageBox(nullptr, TranslateT("Not implemented yet..."), L"WUMF", MB_OK | MB_ICONINFORMATION); + break; + /* end */ + case IDC_LOG_INTO_FILE: + WumfOptions.LogToFile = (IsDlgButtonChecked(hwndDlg, IDC_LOG_INTO_FILE) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), WumfOptions.LogToFile); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), WumfOptions.LogToFile); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_SEL_FILE: + ChooseFile(hwndDlg); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_LOG_FOLDER: + WumfOptions.LogFolders = (IsDlgButtonChecked(hwndDlg, IDC_LOG_FOLDER) == BST_CHECKED); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_ALERT_FOLDER: + WumfOptions.AlertFolders = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_FOLDER) == BST_CHECKED); + break; + case IDC_PREVIEW: + ShowThePreview(); + break; + case IDC_CONN: + CallService(MS_WUMF_CONNECTIONSSHOW, 0, 0); + break; + } + break; + + case CPN_COLOURCHANGED: + WumfOptions.ColorText = SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_GETCOLOUR,0,0); + WumfOptions.ColorBack = SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_GETCOLOUR,0,0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case EN_CHANGE: + switch(wControlId) { + case IDC_DELAY_SEC: + seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, nullptr, FALSE); + if (seconds > LIFETIME_MAX) + WumfOptions.DelaySec = LIFETIME_MAX; + else if (seconds < LIFETIME_MIN) + WumfOptions.DelaySec = LIFETIME_MIN; + else if (seconds <= LIFETIME_MAX || seconds >= LIFETIME_MIN) + WumfOptions.DelaySec = seconds; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_FILE: + GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, _countof(WumfOptions.LogFile)); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + case EN_KILLFOCUS: + switch(wControlId) { + case IDC_DELAY_SEC: + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); + break; + } + break; + } + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) { + case 0: + switch (((LPNMHDR)lparam)->code) { + case PSN_RESET: + LoadOptions(); + return TRUE; + + case PSN_APPLY: + db_set_dw(NULL, MODULENAME, COLOR_TEXT, (DWORD)WumfOptions.ColorText); + db_set_dw(NULL, MODULENAME, COLOR_BACK, (DWORD)WumfOptions.ColorBack); + db_set_b(NULL, MODULENAME, COLOR_DEF, (BYTE)WumfOptions.UseDefColor); + db_set_b(NULL, MODULENAME, COLOR_WIN, (BYTE)WumfOptions.UseWinColor); + db_set_b(NULL, MODULENAME, COLOR_SET, (BYTE)WumfOptions.SelectColor ); + db_set_b(NULL, MODULENAME, DELAY_DEF, (BYTE)WumfOptions.DelayDef); + db_set_b(NULL, MODULENAME, DELAY_INF, (BYTE)WumfOptions.DelayInf); + db_set_b(NULL, MODULENAME, DELAY_SET, (BYTE)WumfOptions.DelaySet); + db_set_b(NULL, MODULENAME, DELAY_SEC, (BYTE)WumfOptions.DelaySec); + db_set_b(NULL, MODULENAME, LOG_INTO_FILE, (BYTE)WumfOptions.LogToFile); + db_set_b(NULL, MODULENAME, LOG_FOLDER, (BYTE)WumfOptions.LogFolders); + db_set_b(NULL, MODULENAME, ALERT_FOLDER, (BYTE)WumfOptions.AlertFolders); + db_set_b(NULL, MODULENAME, LOG_UNC, (BYTE)WumfOptions.LogUNC); + db_set_b(NULL, MODULENAME, ALERT_UNC, (BYTE)WumfOptions.AlertUNC); + db_set_b(NULL, MODULENAME, LOG_COMP, (BYTE)WumfOptions.LogComp); + db_set_b(NULL, MODULENAME, ALERT_COMP, (BYTE)WumfOptions.AlertComp); + GetDlgItemText(hwndDlg, IDC_FILE, WumfOptions.LogFile, _countof(WumfOptions.LogFile)); + db_set_ws(NULL, MODULENAME, OPT_FILE, WumfOptions.LogFile); + } + } + break; + } + return 0; +} + +int OptionsInit(WPARAM wparam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.position = 945000000; + odp.hInstance = g_plugin.getInst(); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); + odp.szTitle.a = LPGEN("Who uses my files"); + odp.pfnDlgProc = OptionsDlgProc; + odp.szGroup.a = LPGEN("Services"); + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wparam, &odp); + return 0; +} diff --git a/plugins/WhoUsesMyFiles/src/stdafx.h b/plugins/WhoUsesMyFiles/src/stdafx.h index 4b93df658f..b21584e35a 100644 --- a/plugins/WhoUsesMyFiles/src/stdafx.h +++ b/plugins/WhoUsesMyFiles/src/stdafx.h @@ -6,7 +6,6 @@ #include <locale.h>
#include <shlobj.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_options.h>
#include <m_langpack.h>
@@ -20,7 +19,7 @@ #include "resource.h"
#include "version.h"
-#define MODULENAME "WUMF Plugin"
+#define MODULENAME "WUMF Plugin"
#define LIFETIME_MAX 60
#define LIFETIME_MIN 1
@@ -114,8 +113,14 @@ BOOL del_all (PWumf* l); void mark_all (PWumf* l, BOOL mark);
BOOL del_marked(PWumf* l);
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
extern WUMF_OPTIONS WumfOptions;
-extern HINSTANCE hInst;
extern HANDLE hLogger;
static HANDLE hWumfBut;
extern PWumf list;
@@ -124,6 +129,8 @@ void FreeAll(); VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD);
INT_PTR CALLBACK ConnDlgProc(HWND, UINT, WPARAM, LPARAM);
+void LoadOptions();
+
void ShowThePopup(PWumf w, LPTSTR, LPTSTR);
void ShowWumfPopup(PWumf w);
diff --git a/plugins/WhoUsesMyFiles/src/wumf.cpp b/plugins/WhoUsesMyFiles/src/wumf.cpp index c4c3969081..66a287eea8 100644 --- a/plugins/WhoUsesMyFiles/src/wumf.cpp +++ b/plugins/WhoUsesMyFiles/src/wumf.cpp @@ -108,7 +108,7 @@ INT_PTR CALLBACK ConnDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) break;
case WM_SIZE:
- Utils_ResizeDialog(hWnd, hInst, MAKEINTRESOURCEA(IDD_CONNLIST), DlgResizer);
+ Utils_ResizeDialog(hWnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_CONNLIST), DlgResizer);
Utils_SaveWindowPosition(hWnd, NULL, MODULENAME,"conn");
return TRUE;
diff --git a/plugins/WhoUsesMyFiles/src/wumfplug.cpp b/plugins/WhoUsesMyFiles/src/wumfplug.cpp index d3a30d33fa..9e2398a04c 100644 --- a/plugins/WhoUsesMyFiles/src/wumfplug.cpp +++ b/plugins/WhoUsesMyFiles/src/wumfplug.cpp @@ -1,14 +1,17 @@ #include "stdafx.h"
-HINSTANCE hInst;
WUMF_OPTIONS WumfOptions = { 0 };
HGENMENU hMenuItem = nullptr;
-int hLangpack;
HWND hDlg;
+CMPlugin g_plugin;
+int hLangpack;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static PLUGININFOEX pluginInfo =
{
- sizeof(PLUGININFOEX),
+ sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
@@ -20,13 +23,21 @@ static PLUGININFOEX pluginInfo = {0x80dca515, 0x973a, 0x4a7e, {0x8b, 0x85, 0x5d, 0x8e, 0xc8, 0x8f, 0xc5, 0xa7}}
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int OptionsInit(WPARAM, LPARAM);
+
void LoadOptions()
{
DBVARIANT dbv = { 0 };
dbv.type = DBVT_WCHAR;
memset(&WumfOptions, 0, sizeof(WumfOptions));
- if (db_get_ws(NULL, MODULENAME, OPT_FILE, &dbv) == 0)
- {
+ if (db_get_ws(NULL, MODULENAME, OPT_FILE, &dbv) == 0) {
wcsncpy(WumfOptions.LogFile, dbv.ptszVal, 255);
db_free(&dbv);
}
@@ -39,8 +50,8 @@ void LoadOptions() WumfOptions.UseWinColor = db_get_b(NULL, MODULENAME, COLOR_WIN, FALSE);
WumfOptions.SelectColor = db_get_b(NULL, MODULENAME, COLOR_SET, FALSE);
- WumfOptions.ColorText = db_get_dw(NULL, MODULENAME, COLOR_TEXT, RGB(0,0,0));
- WumfOptions.ColorBack = db_get_dw(NULL, MODULENAME, COLOR_BACK, RGB(255,255,255));
+ WumfOptions.ColorText = db_get_dw(NULL, MODULENAME, COLOR_TEXT, RGB(0, 0, 0));
+ WumfOptions.ColorBack = db_get_dw(NULL, MODULENAME, COLOR_BACK, RGB(255, 255, 255));
WumfOptions.DelayDef = db_get_b(NULL, MODULENAME, DELAY_DEF, TRUE);
WumfOptions.DelayInf = db_get_b(NULL, MODULENAME, DELAY_INF, FALSE);
@@ -62,40 +73,40 @@ void LoadOptions() void ExecuteMenu(HWND hWnd)
{
- HMENU hMenu = CreatePopupMenu();
- if (!hMenu) {
- msg(TranslateT("Error creating menu"));
- return;
- }
- AppendMenu(hMenu, MF_STRING, IDM_ABOUT, L"About\0");
- AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
- AppendMenu(hMenu, MF_STRING, IDM_SHOW, L"Show connections\0");
- AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
- AppendMenu(hMenu, MF_STRING, IDM_EXIT, L"Dismiss popup\0");
-
- POINT point;
- GetCursorPos(&point);
- SetForegroundWindow(hWnd);
- TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, point.x, point.y, 0, hWnd, nullptr);
- PostMessage(hWnd, WM_USER, 0, 0);
- DestroyMenu(hMenu);
+ HMENU hMenu = CreatePopupMenu();
+ if (!hMenu) {
+ msg(TranslateT("Error creating menu"));
+ return;
+ }
+ AppendMenu(hMenu, MF_STRING, IDM_ABOUT, L"About\0");
+ AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
+ AppendMenu(hMenu, MF_STRING, IDM_SHOW, L"Show connections\0");
+ AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);//------------------
+ AppendMenu(hMenu, MF_STRING, IDM_EXIT, L"Dismiss popup\0");
+
+ POINT point;
+ GetCursorPos(&point);
+ SetForegroundWindow(hWnd);
+ TrackPopupMenu(hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, point.x, point.y, 0, hWnd, nullptr);
+ PostMessage(hWnd, WM_USER, 0, 0);
+ DestroyMenu(hMenu);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
+ switch (message) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDM_ABOUT:
break;
case IDM_EXIT:
PUDeletePopup(hWnd);
- break;
+ break;
case IDM_SHOW:
CallService(MS_WUMF_CONNECTIONSSHOW, 0, 0);
return TRUE;
}
-
+
switch (HIWORD(wParam)) {
case STN_CLICKED:
PUDeletePopup(hWnd);
@@ -103,9 +114,9 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA }
break;
- case WM_CONTEXTMENU:
+ case WM_CONTEXTMENU:
CallService(MS_WUMF_CONNECTIONSSHOW, 0, 0);
- break;
+ break;
case UM_FREEPLUGINDATA:
return TRUE; //TRUE or FALSE is the same, it gets ignored.
@@ -125,12 +136,12 @@ void ShowWumfPopup(PWumf w) void ShowThePopup(PWumf w, LPTSTR title, LPTSTR text)
{
- POPUPDATAT ppd = {0};
+ POPUPDATAT ppd = { 0 };
ppd.lchContact = NULL;
- ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_DRIVE));
+ ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DRIVE));
if (WumfOptions.DelayInf)
- ppd.iSeconds = -1;
+ ppd.iSeconds = -1;
else if (WumfOptions.DelayDef)
ppd.iSeconds = 0;
else if (WumfOptions.DelaySet)
@@ -152,332 +163,60 @@ void ShowThePopup(PWumf w, LPTSTR title, LPTSTR text) PUAddPopupT(&ppd);
}
-void ShowThePreview()
-{
- if ( !ServiceExists(MS_POPUP_ADDPOPUPT)) {
- MessageBox(nullptr, TranslateT("Popup plugin not found!"), TranslateT("Error"), MB_OK|MB_ICONSTOP);
- return;
- }
-
- if (WumfOptions.AlertFolders) {
- ShowThePopup(nullptr, L"Guest", L"C:\\My Share");
- Sleep(300);
- ShowThePopup(nullptr, L"Guest", L"C:\\My Share\\Photos");
- Sleep(300);
- }
- ShowThePopup(nullptr, L"Guest", L"C:\\Share\\My Photos\\photo.jpg");
- Sleep(300);
- if (WumfOptions.AlertFolders) {
- ShowThePopup(nullptr, L"User", L"C:\\My Share");
- Sleep(300);
- ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies");
- Sleep(300);
- }
- ShowThePopup(nullptr, L"User", L"C:\\My Share\\Movies\\The Two Towers.avi");
- Sleep(300);
- if (WumfOptions.AlertFolders) {
- ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives");
- Sleep(300);
- ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k");
- Sleep(300);
- }
- ShowThePopup(nullptr, L"Administrator", L"C:\\Distributives\\Win2k\\setup.exe");
-}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
void ThreadProc(LPVOID)
{
if (hDlg) {
- ShowWindow(hDlg, SW_SHOWNORMAL);
+ ShowWindow(hDlg, SW_SHOWNORMAL);
SetForegroundWindow(hDlg);
return;
}
- hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CONNLIST), nullptr, ConnDlgProc);
- SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)));
- ShowWindow(hDlg, SW_SHOW);
+ hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONNLIST), nullptr, ConnDlgProc);
+ SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DRIVE)));
+ ShowWindow(hDlg, SW_SHOW);
MSG msg;
- while(GetMessage(&msg, nullptr, 0, 0) == TRUE) {
+ while (GetMessage(&msg, nullptr, 0, 0) == TRUE) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
hDlg = nullptr;
}
-static INT_PTR WumfShowConnections(WPARAM,LPARAM)
+static INT_PTR WumfShowConnections(WPARAM, LPARAM)
{
mir_forkthread(ThreadProc);
CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hWumfBut, 0);
return 0;
}
-static INT_PTR WumfMenuCommand(WPARAM,LPARAM)
+static INT_PTR WumfMenuCommand(WPARAM, LPARAM)
{
- if (WumfOptions.PopupsEnabled == TRUE) {
+ if (WumfOptions.PopupsEnabled == TRUE) {
WumfOptions.PopupsEnabled = FALSE;
- Menu_ModifyItem(hMenuItem, LPGENW("Enable WUMF popups"), LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP)));
+ Menu_ModifyItem(hMenuItem, LPGENW("Enable WUMF popups"), LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOPOPUP)));
}
else {
WumfOptions.PopupsEnabled = TRUE;
- Menu_ModifyItem(hMenuItem, LPGENW("Disable WUMF popups"), LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP)));
+ Menu_ModifyItem(hMenuItem, LPGENW("Disable WUMF popups"), LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP)));
}
db_set_b(NULL, MODULENAME, POPUPS_ENABLED, (BYTE)WumfOptions.PopupsEnabled);
return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-void DisableDelayOptions(HWND hwndDlg)
-{
- CheckDlgButton(hwndDlg, IDC_DELAY_INF,BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DELAY_SET,BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DELAY_DEF,BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_INF), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SET), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_DEF), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_TX_DELAY_SEC), FALSE);
-}
-
-void ChooseFile(HWND hwndDlg)
-{
- wchar_t szFile[MAX_PATH]; szFile[0]=0;
-
- // Initialize OPENFILENAME
- OPENFILENAME ofn = {0}; // common dialog box structure
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hwndDlg;
- ofn.lpstrFile = szFile;
- ofn.nMaxFile = _countof(szFile);
- ofn.lpstrFilter = L"All files (*.*)\0*.*\0Text files (*.txt)\0*.txt\0Log files (*.log)\0*.log\0\0";
- ofn.nFilterIndex = 2;
- ofn.Flags = OFN_CREATEPROMPT;
- // Display the Open dialog box.
- if (GetSaveFileName(&ofn)) {
- HANDLE hf = CreateFile(szFile,GENERIC_WRITE,0,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hf != INVALID_HANDLE_VALUE) {
- SetDlgItemText(hwndDlg,IDC_FILE,szFile);
- mir_wstrncpy(WumfOptions.LogFile, szFile, MAX_PATH);
- CloseHandle(hf);
- }
- }
- else if (CommDlgExtendedError() != 0) {
- wchar_t str[256];
- mir_snwprintf(str, TranslateT("Common Dialog Error 0x%lx"), CommDlgExtendedError());
- MessageBox(hwndDlg, str, TranslateT("Error"), MB_OK | MB_ICONSTOP);
- }
-}
-
-INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lparam)
-{
- WORD wControlId = LOWORD(wparam);
- WORD wNotifyCode = HIWORD(wparam);
- int seconds;
-
- switch(msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_COLOR_WIN, WumfOptions.UseWinColor ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_COLOR_DEF, WumfOptions.UseDefColor ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_COLOR_SET, WumfOptions.SelectColor ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK), WumfOptions.SelectColor);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor);
- if (WumfOptions.SelectColor) {
- SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack);
- SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText);
- }
- if ( !ServiceExists(MS_POPUP_ADDPOPUPT)) {
- DisableDelayOptions(hwndDlg);
- break;
- }
- CheckDlgButton(hwndDlg, IDC_DELAY_INF, WumfOptions.DelayInf ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DELAY_DEF, WumfOptions.DelayDef ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DELAY_SET, WumfOptions.DelaySet ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet);
- SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE);
- //Logging & alerts
- CheckDlgButton(hwndDlg, IDC_LOG_FOLDER, WumfOptions.LogFolders ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ALERT_FOLDER, WumfOptions.AlertFolders ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_LOG_UNC, WumfOptions.LogUNC ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ALERT_UNC, WumfOptions.AlertUNC ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_LOG_COMP, WumfOptions.LogComp ? BST_CHECKED : BST_UNCHECKED);
-
- if (WumfOptions.LogToFile) {
- CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), TRUE);
- SetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile);
- }
- else {
- CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), FALSE);
- SetDlgItemText(hwndDlg, IDC_FILE, L"");
- }
- break;
-
- case WM_COMMAND:
- switch(wNotifyCode) {
- case BN_CLICKED :
- switch(wControlId) {
- case IDC_DELAY_SET:
- case IDC_DELAY_DEF:
- case IDC_DELAY_INF:
- WumfOptions.DelaySet = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_SET) == BST_CHECKED);
- WumfOptions.DelayDef = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_DEF) == BST_CHECKED);
- WumfOptions.DelayInf = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_INF) == BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet);
- SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, TRUE);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_COLOR_SET:
- case IDC_COLOR_DEF:
- case IDC_COLOR_WIN:
- WumfOptions.SelectColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_SET) == BST_CHECKED);
- WumfOptions.UseDefColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_DEF) == BST_CHECKED);
- WumfOptions.UseWinColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_WIN) == BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK),WumfOptions.SelectColor);
- EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor);
- SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack);
- SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- /* not implemented */
- case IDC_LOG_COMP:
- case IDC_ALERT_COMP:
- case IDC_LOG_UNC:
- case IDC_ALERT_UNC:
- MessageBox(nullptr, TranslateT("Not implemented yet..."), L"WUMF", MB_OK | MB_ICONINFORMATION);
- break;
- /* end */
- case IDC_LOG_INTO_FILE:
- WumfOptions.LogToFile = (IsDlgButtonChecked(hwndDlg, IDC_LOG_INTO_FILE) == BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), WumfOptions.LogToFile);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), WumfOptions.LogToFile);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_SEL_FILE:
- ChooseFile(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_LOG_FOLDER:
- WumfOptions.LogFolders = (IsDlgButtonChecked(hwndDlg, IDC_LOG_FOLDER) == BST_CHECKED);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_ALERT_FOLDER:
- WumfOptions.AlertFolders = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_FOLDER) == BST_CHECKED);
- break;
- case IDC_PREVIEW:
- ShowThePreview();
- break;
- case IDC_CONN:
- CallService(MS_WUMF_CONNECTIONSSHOW, 0, 0);
- break;
- }
- break;
-
- case CPN_COLOURCHANGED:
- WumfOptions.ColorText = SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_GETCOLOUR,0,0);
- WumfOptions.ColorBack = SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_GETCOLOUR,0,0);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case EN_CHANGE:
- switch(wControlId) {
- case IDC_DELAY_SEC:
- seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, nullptr, FALSE);
- if (seconds > LIFETIME_MAX)
- WumfOptions.DelaySec = LIFETIME_MAX;
- else if (seconds < LIFETIME_MIN)
- WumfOptions.DelaySec = LIFETIME_MIN;
- else if (seconds <= LIFETIME_MAX || seconds >= LIFETIME_MIN)
- WumfOptions.DelaySec = seconds;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_FILE:
- GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, _countof(WumfOptions.LogFile));
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- break;
- case EN_KILLFOCUS:
- switch(wControlId) {
- case IDC_DELAY_SEC:
- SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE);
- break;
- }
- break;
- }
- break;
-
- case WM_NOTIFY:
- switch(((LPNMHDR)lparam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lparam)->code) {
- case PSN_RESET:
- LoadOptions();
- return TRUE;
-
- case PSN_APPLY:
- db_set_dw(NULL, MODULENAME, COLOR_TEXT, (DWORD)WumfOptions.ColorText);
- db_set_dw(NULL, MODULENAME, COLOR_BACK, (DWORD)WumfOptions.ColorBack);
- db_set_b(NULL, MODULENAME, COLOR_DEF, (BYTE)WumfOptions.UseDefColor);
- db_set_b(NULL, MODULENAME, COLOR_WIN, (BYTE)WumfOptions.UseWinColor);
- db_set_b(NULL, MODULENAME, COLOR_SET, (BYTE)WumfOptions.SelectColor );
- db_set_b(NULL, MODULENAME, DELAY_DEF, (BYTE)WumfOptions.DelayDef);
- db_set_b(NULL, MODULENAME, DELAY_INF, (BYTE)WumfOptions.DelayInf);
- db_set_b(NULL, MODULENAME, DELAY_SET, (BYTE)WumfOptions.DelaySet);
- db_set_b(NULL, MODULENAME, DELAY_SEC, (BYTE)WumfOptions.DelaySec);
- db_set_b(NULL, MODULENAME, LOG_INTO_FILE, (BYTE)WumfOptions.LogToFile);
- db_set_b(NULL, MODULENAME, LOG_FOLDER, (BYTE)WumfOptions.LogFolders);
- db_set_b(NULL, MODULENAME, ALERT_FOLDER, (BYTE)WumfOptions.AlertFolders);
- db_set_b(NULL, MODULENAME, LOG_UNC, (BYTE)WumfOptions.LogUNC);
- db_set_b(NULL, MODULENAME, ALERT_UNC, (BYTE)WumfOptions.AlertUNC);
- db_set_b(NULL, MODULENAME, LOG_COMP, (BYTE)WumfOptions.LogComp);
- db_set_b(NULL, MODULENAME, ALERT_COMP, (BYTE)WumfOptions.AlertComp);
- GetDlgItemText(hwndDlg, IDC_FILE, WumfOptions.LogFile, _countof(WumfOptions.LogFile));
- db_set_ws(NULL, MODULENAME, OPT_FILE, WumfOptions.LogFile);
- }
- }
- break;
- }
- return 0;
-}
-
-int InitTopToolbar(WPARAM,LPARAM)
+int InitTopToolbar(WPARAM, LPARAM)
{
TTBButton ttb = {};
- ttb.hIconUp = LoadIcon(hInst, MAKEINTRESOURCE(IDI_DRIVE));
+ ttb.hIconUp = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DRIVE));
ttb.pszService = MS_WUMF_CONNECTIONSSHOW;
- ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
ttb.name = ttb.pszTooltipUp = LPGEN("Show connections list");
hWumfBut = TopToolbar_AddButton(&ttb);
return 0;
}
-int OptionsInit(WPARAM wparam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = 945000000;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
- odp.szTitle.a = LPGEN("Who uses my files");
- odp.pfnDlgProc = OptionsDlgProc;
- odp.szGroup.a = LPGEN("Services");
- odp.flags = ODPF_BOLDGROUPS;
- Options_AddPage(wparam, &odp);
- return 0;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Load(void)
{
@@ -492,24 +231,24 @@ extern "C" __declspec(dllexport) int Load(void) SET_UID(mi, 0xcfce6487, 0x907b, 0x4822, 0xb0, 0x49, 0x18, 0x4e, 0x47, 0x17, 0x0, 0x69);
mi.root = Menu_CreateRoot(MO_MAIN, LPGENW("Popups"), 1999990000);
- if (WumfOptions.PopupsEnabled == FALSE) {
+ if (WumfOptions.PopupsEnabled == FALSE) {
mi.name.a = LPGEN("Enable WUMF popups");
- mi.hIcolibItem = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_NOPOPUP));
}
else {
mi.name.a = LPGEN("Disable WUMF popups");
- mi.hIcolibItem = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_POPUP));
}
mi.pszService = MS_WUMF_SWITCHPOPUP;
hMenuItem = Menu_AddMainMenuItem(&mi);
SET_UID(mi, 0xbf93984c, 0xaa05, 0x447c, 0xbd, 0x5c, 0x5f, 0x43, 0x60, 0x92, 0x6a, 0x12);
mi.name.a = LPGEN("WUMF: Show connections");
- mi.hIcolibItem = LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE));
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_DRIVE));
mi.pszService = MS_WUMF_CONNECTIONSSHOW;
Menu_AddMainMenuItem(&mi);
- HookEvent(ME_OPT_INITIALISE,OptionsInit);
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_TTB_MODULELOADED, InitTopToolbar);
if (IsUserAnAdmin())
@@ -519,6 +258,8 @@ extern "C" __declspec(dllexport) int Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
KillTimer(nullptr, 777);
diff --git a/plugins/WinterSpeak/src/SpeechApi51Lexicon.cpp b/plugins/WinterSpeak/src/SpeechApi51Lexicon.cpp index 8762265b4f..17794455fc 100644 --- a/plugins/WinterSpeak/src/SpeechApi51Lexicon.cpp +++ b/plugins/WinterSpeak/src/SpeechApi51Lexicon.cpp @@ -2,9 +2,6 @@ #include "SpeechApi51Lexicon.h"
#include "SpeechApi51.h"
-
-extern HINSTANCE g_hInst;
-
//------------------------------------------------------------------------------
SpeechApi51Lexicon::SpeechApi51Lexicon(HWND window) : m_parent_window(window), m_window(nullptr)
{
@@ -19,7 +16,7 @@ SpeechApi51Lexicon::~SpeechApi51Lexicon() bool SpeechApi51Lexicon::display()
{
/* m_window = CreateDialog(
- g_hInst,
+ g_plugin.getInst(),
MAKEINTRESOURCE(IDD_TTS_LEXICON),
m_parent_window,
dialogEvent);
diff --git a/plugins/WinterSpeak/src/main.cpp b/plugins/WinterSpeak/src/main.cpp index 34b0c95268..cbe678d4c1 100644 --- a/plugins/WinterSpeak/src/main.cpp +++ b/plugins/WinterSpeak/src/main.cpp @@ -1,8 +1,7 @@ #include "stdafx.h"
-HINSTANCE g_hInst;
+CMPlugin g_plugin;
int hLangpack;
-DWORD g_mirandaVersion;
SpeakConfig *g_speak_config = nullptr;
SpeakAnnounce *g_speak_announce = nullptr;
@@ -24,6 +23,11 @@ PLUGININFOEX pluginInfo={ { 0x81e189dc, 0xc251, 0x45f6, { 0x9e, 0xdf, 0xa0, 0xf3, 0xa0, 0x5c, 0x42, 0x48 } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
//-----------------------------------------------------------------------------
// Description : External hook
//-----------------------------------------------------------------------------
@@ -68,7 +72,7 @@ int protocolAck(WPARAM, LPARAM lParam) int dialogOptionsInitialise(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.w = LPGENW("Speak");
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
@@ -95,11 +99,7 @@ int dialogOptionsInitialise(WPARAM wParam, LPARAM) return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
-{
- g_mirandaVersion = mirandaVersion;
- return &pluginInfo;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" __declspec(dllexport) int Load(void)
{
@@ -107,7 +107,7 @@ extern "C" __declspec(dllexport) int Load(void) if (!g_speak_config)
{
- g_speak_config = new SpeakConfig(g_hInst);
+ g_speak_config = new SpeakConfig(g_plugin.getInst());
// expose to allow miranda + plugins to access my speak routines
CreateServiceFunction(MS_SPEAK_STATUS, status);
@@ -116,7 +116,7 @@ extern "C" __declspec(dllexport) int Load(void) if (!g_speak_announce)
{
- g_speak_announce = new SpeakAnnounce(g_hInst);
+ g_speak_announce = new SpeakAnnounce(g_plugin.getInst());
// tap into contact setting change event
g_event_status_change = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, eventStatusChange);
@@ -135,6 +135,8 @@ extern "C" __declspec(dllexport) int Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
UnhookEvent(g_dialog_options_initialise);
@@ -157,10 +159,3 @@ extern "C" __declspec(dllexport) int Unload(void) return 0;
}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- DisableThreadLibraryCalls(hinstDLL);
- g_hInst = hinstDLL;
- return TRUE;
-}
\ No newline at end of file diff --git a/plugins/WinterSpeak/src/stdafx.h b/plugins/WinterSpeak/src/stdafx.h index 79c4a9a1da..44c88cbd35 100644 --- a/plugins/WinterSpeak/src/stdafx.h +++ b/plugins/WinterSpeak/src/stdafx.h @@ -8,7 +8,6 @@ #include <memory>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_database.h>
@@ -46,3 +45,10 @@ #include "Subject.h"
#include "SpeechInterface.h"
#include "SpeakConfig.h"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>("speak_config")
+ {}
+};
diff --git a/plugins/wbOSD/src/main.cpp b/plugins/wbOSD/src/main.cpp index fdae90110a..486b5a7511 100644 --- a/plugins/wbOSD/src/main.cpp +++ b/plugins/wbOSD/src/main.cpp @@ -9,11 +9,11 @@ Distributed under GNU's GPL 2 or later #include "stdafx.h"
-HINSTANCE hI;
+int hLangpack;
+CMPlugin g_plugin;
HWND g_hWnd = nullptr;
-int hLangpack = 0;
-HANDLE hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged;
+HANDLE hHookContactStatusChanged;
void logmsg2(char *str);
int MainInit(WPARAM,LPARAM);
@@ -45,7 +45,7 @@ extern "C" __declspec(dllexport) int Load() mir_getLP(&pluginInfo);
logmsg("Load");
- hHookedInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
return 0;
}
@@ -54,19 +54,7 @@ extern "C" __declspec(dllexport) int Load() extern "C" __declspec(dllexport) int Unload()
{
logmsg("Unload");
- UnhookEvent(hProtoAck);
- UnhookEvent(hContactSettingChanged);
- UnhookEvent(hContactStatusChanged);
- UnhookEvent(hHookedInit);
DestroyHookableEvent(hHookContactStatusChanged);
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
-{
- hI = hinst;
- return TRUE;
-}
diff --git a/plugins/wbOSD/src/options.cpp b/plugins/wbOSD/src/options.cpp index 12ad300dae..0b041ed5d9 100644 --- a/plugins/wbOSD/src/options.cpp +++ b/plugins/wbOSD/src/options.cpp @@ -54,7 +54,7 @@ int selectColor(HWND hwnd, COLORREF *clr) CHOOSECOLOR cc = { 0 };
cc.lStructSize = sizeof(cc);
cc.hwndOwner = hwnd;
- cc.hInstance = (HWND)hI;
+ cc.hInstance = (HWND)g_plugin.getInst();
cc.rgbResult = *clr;
cc.lpCustColors = pencustcolors;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
@@ -411,7 +411,7 @@ int OptionsInit(WPARAM wparam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 150000000;
- odp.hInstance = hI;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG1);
odp.szGroup.w = LPGENW("Plugins");
odp.szTitle.w = LPGENW("OSD");
diff --git a/plugins/wbOSD/src/stdafx.h b/plugins/wbOSD/src/stdafx.h index 6d13b4fb9b..9d261f861d 100644 --- a/plugins/wbOSD/src/stdafx.h +++ b/plugins/wbOSD/src/stdafx.h @@ -13,7 +13,6 @@ Distributed under GNU's GPL 2 or later #include <shlwapi.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_database.h>
@@ -29,7 +28,14 @@ Distributed under GNU's GPL 2 or later #define THIS_MODULE "mirandaosd"
-//SETTINGS DEFAULTS
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(THIS_MODULE)
+ {}
+};
+
+// Settings defaults
#define DEFAULT_FNT_HEIGHT -30
#define DEFAULT_FNT_WIDTH 0
#define DEFAULT_FNT_ESCAPEMENT 0
@@ -69,7 +75,7 @@ Distributed under GNU's GPL 2 or later #define DEFAULT_SHOWMSGWIN 1
#define DEFAULT_SHOWWHEN 0x00000002
-//HOOKS
+// Hooks
#define ME_STATUSCHANGE_CONTACTSTATUSCHANGED "Miranda/StatusChange/ContactStatusChanged"
int ContactStatusChanged(WPARAM wParam, LPARAM lParam);
@@ -77,11 +83,9 @@ int ProtoAck(WPARAM wparam,LPARAM lparam); int ContactSettingChanged(WPARAM wparam,LPARAM lparam);
int HookedNewEvent(WPARAM wParam, LPARAM lParam);
-//ANNOUNCING MESSAGES FROM OUTSIDE ;-)
+// Announcing messages from outside
INT_PTR OSDAnnounce(WPARAM wParam, LPARAM lParam);
-
-
#define ID_STATUS_MIN ID_STATUS_OFFLINE
#define ID_STATUS_MAX ID_STATUS_OUTTOLUNCH
@@ -114,6 +118,5 @@ int OptionsInit(WPARAM wparam,LPARAM lparam); void loadDBSettings(plgsettings *ps);
-extern HINSTANCE hI;
-extern HWND g_hWnd;
-extern HANDLE hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged;
\ No newline at end of file +extern HWND g_hWnd;
+extern HANDLE hHookContactStatusChanged;
diff --git a/plugins/wbOSD/src/wbOSD.cpp b/plugins/wbOSD/src/wbOSD.cpp index 7f10ac8ff3..7b227db5cb 100644 --- a/plugins/wbOSD/src/wbOSD.cpp +++ b/plugins/wbOSD/src/wbOSD.cpp @@ -259,7 +259,7 @@ int MainInit(WPARAM, LPARAM) HookEvent(ME_OPT_INITIALISE, OptionsInit);
WNDCLASSEX wincl;
- wincl.hInstance = hI;
+ wincl.hInstance = g_plugin.getInst();
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
@@ -282,7 +282,7 @@ int MainInit(WPARAM, LPARAM) db_get_dw(NULL, THIS_MODULE, "winypos", DEFAULT_WINYPOS),
db_get_dw(NULL, THIS_MODULE, "winx", DEFAULT_WINX),
db_get_dw(NULL, THIS_MODULE, "winy", DEFAULT_WINY),
- HWND_DESKTOP, nullptr, hI, nullptr);
+ HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(g_hWnd, GWLP_USERDATA, 0);
@@ -293,16 +293,14 @@ int MainInit(WPARAM, LPARAM) HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent);
// try to create ME_STATUSCHANGE_CONTACTSTATUSCHANGED event... I hope it fails when newstatusnotify or equal creates it before ;-)
-
- hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
+ HANDLE hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
if (!hContactStatusChanged) {
hHookContactStatusChanged = CreateHookableEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED);
- hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
-
- hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
+ HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED, ContactStatusChanged);
}
- hProtoAck = HookEvent(ME_PROTO_ACK, ProtoAck);
-
+
+ HookEvent(ME_PROTO_ACK, ProtoAck);
HookEvent(ME_SYSTEM_SHUTDOWN, pluginShutDown);
return 0;
}
|