summaryrefslogtreecommitdiff
path: root/plugins/Toaster/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Toaster/src')
-rw-r--r--plugins/Toaster/src/main.cpp64
-rw-r--r--plugins/Toaster/src/options.cpp2
-rw-r--r--plugins/Toaster/src/stdafx.h10
3 files changed, 37 insertions, 39 deletions
diff --git a/plugins/Toaster/src/main.cpp b/plugins/Toaster/src/main.cpp
index f48c47ea20..406bd52180 100644
--- a/plugins/Toaster/src/main.cpp
+++ b/plugins/Toaster/src/main.cpp
@@ -1,8 +1,9 @@
#include "stdafx.h"
int hLangpack;
+CMPlugin g_plugin;
-HINSTANCE g_hInstance;
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo =
{
@@ -18,67 +19,60 @@ PLUGININFOEX pluginInfo =
{ 0x1fdbd8f0, 0x3929, 0x41bc, { 0x92, 0xd1, 0x2, 0x7, 0x79, 0x46, 0x7, 0x69 } }
};
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- if (!IsWinVer8Plus())
- {
+ if (!IsWinVer8Plus()) {
MessageBox(nullptr, TranslateT("This plugin requires Windows 8 or higher"), _T(MODULE), MB_OK | MB_ICONERROR);
return nullptr;
}
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int OnPreShutdown(WPARAM, LPARAM)
+{
+ CleanupClasses();
+
+ SHFILEOPSTRUCT file_op = {
+ nullptr,
+ FO_DELETE,
+ wszTempDir,
+ L"",
+ FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION,
+ false,
+ nullptr,
+ L""
+ };
+ SHFileOperation(&file_op);
+
+ return 0;
+}
+
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized);
HookEvent(ME_SYSTEM_PRESHUTDOWN, &OnPreShutdown);
-
+
InitServices();
- if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0)
- {
+ if (GetEnvironmentVariableW(L"TEMP", wszTempDir, MAX_PATH) != 0) {
wcscat_s(wszTempDir, L"\\Miranda.Toaster");
DWORD dwAttributes = GetFileAttributes(wszTempDir);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
CreateDirectoryTreeW(wszTempDir);
}
- else
- {
- MessageBox(nullptr, TranslateT("Failed to create temporary directory"), _T(MODULE), MB_OK | MB_ICONERROR);
- }
+ else MessageBox(nullptr, TranslateT("Failed to create temporary directory"), _T(MODULE), MB_OK | MB_ICONERROR);
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
}
-
-int OnPreShutdown(WPARAM, LPARAM)
-{
- CleanupClasses();
-
- SHFILEOPSTRUCT file_op = {
- nullptr,
- FO_DELETE,
- wszTempDir,
- L"",
- FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION,
- false,
- nullptr,
- L""
- };
- SHFileOperation(&file_op);
-
- return 0;
-} \ No newline at end of file
diff --git a/plugins/Toaster/src/options.cpp b/plugins/Toaster/src/options.cpp
index 9d0c0d4034..7b0f3b5995 100644
--- a/plugins/Toaster/src/options.cpp
+++ b/plugins/Toaster/src/options.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
COptions::COptions()
- : CDlgBase(g_hInstance, IDD_OPTIONS_MAIN),
+ : CDlgBase(g_plugin.getInst(), IDD_OPTIONS_MAIN),
m_shortcut(this, IDC_SHORTCUT),
m_preview(this, IDC_PREVIEW),
m_enabled(this, IDC_CHECK_ENABLED)
diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h
index 925a04f86d..1d337c7cf8 100644
--- a/plugins/Toaster/src/stdafx.h
+++ b/plugins/Toaster/src/stdafx.h
@@ -10,7 +10,6 @@
#include <memory>
#include <map>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_system_cpp.h>
#include <m_langpack.h>
@@ -33,8 +32,14 @@ const wchar_t AppUserModelID[] = L"MirandaNG";
#define MODULE "Toaster"
#define CHECKHR(x) if (FAILED(x)) return x;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
+
class ToastNotification;
-extern HINSTANCE g_hInstance;
extern mir_cs csNotifications;
extern wchar_t wszTempDir[MAX_PATH];
extern OBJLIST<ToastNotification> lstNotifications;
@@ -47,7 +52,6 @@ extern OBJLIST<ToastNotification> lstNotifications;
void CleanupClasses();
void InitServices();
-int OnPreShutdown(WPARAM, LPARAM);
void __stdcall HideAllToasts(void*);
int OnOptionsInitialized(WPARAM wParam, LPARAM);