summaryrefslogtreecommitdiff
path: root/plugins/MirFox/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirFox/src')
-rw-r--r--plugins/MirFox/src/MirandaInterface.cpp70
-rw-r--r--plugins/MirFox/src/MirandaOptions.cpp9
-rw-r--r--plugins/MirFox/src/MirfoxMiranda.cpp10
-rw-r--r--plugins/MirFox/src/common.h15
4 files changed, 43 insertions, 61 deletions
diff --git a/plugins/MirFox/src/MirandaInterface.cpp b/plugins/MirFox/src/MirandaInterface.cpp
index b4f2f6ef0b..e744018012 100644
--- a/plugins/MirFox/src/MirandaInterface.cpp
+++ b/plugins/MirFox/src/MirandaInterface.cpp
@@ -2,8 +2,8 @@
#include "version.h"
#include "mirandaInterface.h"
-//Miranda - handle from DllMain
-HINSTANCE hInst;
+// Miranda - handle from DllMain
+CMPlugin g_plugin;
//Miranda - Langpack
int hLangpack;
@@ -18,7 +18,10 @@ HANDLE hPopupError;
//main add-on's object
CMirfoxMiranda mirfoxMiranda;
-PLUGININFOEX pluginInfo={
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -30,21 +33,12 @@ PLUGININFOEX pluginInfo={
{ 0xe99a09b2, 0xe05b, 0x4633, { 0xaa, 0x3a, 0x5c, 0x83, 0xef, 0x1c, 0xba, 0xb6 } }
};
-
-extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
-
- hInst = hinstDLL;
- return TRUE;
-}
-
-
-extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
+extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
return &pluginInfo;
}
-
-
-
+/////////////////////////////////////////////////////////////////////////////////////////
static int __cdecl onAccListChanged(WPARAM wParam, LPARAM lParam)
{
@@ -70,8 +64,8 @@ static int __cdecl onContactDeleted(WPARAM wParam, LPARAM)
return 0;
}
-static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam){
-
+static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam)
+{
if (mirfoxMiranda.getMirfoxData().Plugin_Terminated)
return 0;
if (hContact == NULL || lParam == NULL)
@@ -95,15 +89,13 @@ static int __cdecl onContactSettingChanged(WPARAM hContact, LPARAM lParam){
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// hook on ME_SYSTEM_MODULESLOADED at Load()
-
-/*
- * hook on ME_SYSTEM_MODULESLOADED at Load()
- */
static int onModulesLoaded(WPARAM, LPARAM)
{
//init popup classes
- POPUPCLASS puc = {0};
+ POPUPCLASS puc = { 0 };
puc.cbSize = sizeof(puc);
puc.flags = PCF_TCHAR;
@@ -112,7 +104,7 @@ static int onModulesLoaded(WPARAM, LPARAM)
puc.colorBack = RGB(173, 206, 247); //light blue
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.iSeconds = 3;
- puc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_PN));
+ puc.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_PN));
hPopupNotify = Popup_RegisterClass(&puc);
puc.pszName = "MirFox_Error";
@@ -120,7 +112,7 @@ static int onModulesLoaded(WPARAM, LPARAM)
puc.colorBack = RGB(255, 128, 128); //light red
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.iSeconds = 20;
- puc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_PE));
+ puc.hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_PE));
hPopupError = Popup_RegisterClass(&puc);
@@ -142,6 +134,7 @@ static int OnShutdown(WPARAM, LPARAM)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load(void)
{
@@ -152,8 +145,8 @@ extern "C" int __declspec(dllexport) Load(void)
hProtoAck = HookEvent(ME_PROTO_ACK, MirandaUtils::onProtoAck);
- //Ensure that the common control DLL is loaded. needed to use ICC_LISTVIEW_CLASSES control in options TODO move to InitOptions();?
- INITCOMMONCONTROLSEX icex = {0};
+ // Ensure that the common control DLL is loaded. needed to use ICC_LISTVIEW_CLASSES control in options TODO move to InitOptions();?
+ INITCOMMONCONTROLSEX icex = { 0 };
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
@@ -162,42 +155,35 @@ extern "C" int __declspec(dllexport) Load(void)
mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_INIT);
mirfoxMiranda.onMirandaInterfaceLoad();
InitOptions();
-
- if (mirfoxMiranda.getMirfoxData().getPluginState() != MFENUM_PLUGIN_STATE_ERROR){
+
+ if (mirfoxMiranda.getMirfoxData().getPluginState() != MFENUM_PLUGIN_STATE_ERROR)
mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_WORK);
- } /*else {
- mirfoxMiranda.onMirandaInterfaceUnload();
- DeinitOptions();
- } */ //TODO
-
+
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec (dllexport) int Unload(void) {
-
+extern "C" __declspec (dllexport) int Unload(void)
+{
MFLogger::getInstance()->log(L"Unload: start");
-
- //wait for csmThread, msgQueueThread and userActionThread's end
+ // wait for csmThread, msgQueueThread and userActionThread's end
mirfoxMiranda.getMirfoxData().Plugin_Terminated = true;
UnhookEvent(hProtoAck);
int counter = 0;
const int UNLOAD_WAIT_TIME = 50; //[ms]
const int MAX_UNLOAD_WAIT_COUNTER = 10; //10 * 50ms = 0,5s
- while (mirfoxMiranda.getMirfoxData().workerThreadsCount > 0 ){
+ while (mirfoxMiranda.getMirfoxData().workerThreadsCount > 0) {
MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d > 0, waiting. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
SleepEx(UNLOAD_WAIT_TIME, TRUE);
counter++;
}
- MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
-
+ MFLogger::getInstance()->log_p(L"Unload: workerThreadsCount=%d. counter=%d", mirfoxMiranda.getMirfoxData().workerThreadsCount, counter);
MFLogger::getInstance()->log(L"Unload: last log");
mirfoxMiranda.onMirandaInterfaceUnload();
DeinitOptions();
-
return 0;
}
-
diff --git a/plugins/MirFox/src/MirandaOptions.cpp b/plugins/MirFox/src/MirandaOptions.cpp
index 8831b932da..b339b885c8 100644
--- a/plugins/MirFox/src/MirandaOptions.cpp
+++ b/plugins/MirFox/src/MirandaOptions.cpp
@@ -1,10 +1,7 @@
#include "common.h"
#include "MirandaOptions.h"
-
extern CMirfoxMiranda mirfoxMiranda;
-extern HINSTANCE hInst;
-
/*
* callback function for tab 1 options page
@@ -340,8 +337,8 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
hIml = ImageList_Create(smCx,smCy,((LOBYTE(LOWORD(GetVersion()))>=5 && LOWORD(GetVersion())!=5) ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 4, 4);
//load icons (direct)
- icoHandle_ICON_OFF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_OFF));
- icoHandle_ICON_FF = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_FF));
+ icoHandle_ICON_OFF = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_OFF));
+ icoHandle_ICON_FF = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON_FF));
//add icons to ImageList list
ImageList_AddIcon(hIml, icoHandle_ICON_OFF);
@@ -674,7 +671,7 @@ int OptInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szTitle.a = LPGEN(PLUGIN_OPTIONS_NAME);
odp.szGroup.a = LPGEN("Services");
odp.flags = ODPF_BOLDGROUPS;
diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp
index 176929461c..e855537f5b 100644
--- a/plugins/MirFox/src/MirfoxMiranda.cpp
+++ b/plugins/MirFox/src/MirfoxMiranda.cpp
@@ -1,9 +1,6 @@
#include "common.h"
#include "MirfoxMiranda.h"
-
-
-
CMirfoxMiranda::CMirfoxMiranda()
: sharedMemoryUtils(SharedMemoryUtils::getInstance())
, mirandaUtils(MirandaUtils::getInstance())
@@ -17,15 +14,16 @@ CMirfoxMiranda::~CMirfoxMiranda()
{
}
-MirfoxData& CMirfoxMiranda::getMirfoxData(){
+MirfoxData& CMirfoxMiranda::getMirfoxData()
+{
return mirfoxData;
}
-SharedMemoryUtils& CMirfoxMiranda::getSharedMemoryUtils(){
+SharedMemoryUtils& CMirfoxMiranda::getSharedMemoryUtils()
+{
return *sharedMemoryUtils;
}
-
int CMirfoxMiranda::onMirandaInterfaceLoad()
{
diff --git a/plugins/MirFox/src/common.h b/plugins/MirFox/src/common.h
index aa36678281..95b80f9861 100644
--- a/plugins/MirFox/src/common.h
+++ b/plugins/MirFox/src/common.h
@@ -2,12 +2,10 @@
#include "MirFoxCommons_pch.h"
-
#pragma comment(lib, "comctl32.lib")
#include <commctrl.h>
// Miranda headers
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_system.h>
@@ -21,12 +19,15 @@
#include <m_extraicons.h>
#include <m_protocols.h>
+#define PLUGIN_DB_ID "MirFox"
+#define PLUGIN_OPTIONS_NAME "MirFox"
-#define PLUGIN_DB_ID "MirFox"
-#define PLUGIN_OPTIONS_NAME "MirFox"
-
-
-
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PLUGIN_DB_ID)
+ {}
+};
//for MirandaUtils.h and MirfoxData.h and MirfoxMiranda.h
#include "MirFoxCommons_logger.h"