diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-16 13:42:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-16 13:42:25 +0300 |
commit | 51f216f7e0feb67ad21387219c1b90e42b14658d (patch) | |
tree | 2ce37e615bf4f82320fe01babc37401fa4a56ca3 /src/core/stduseronline | |
parent | 2e8582832fe56c89bb422b82e884ddaf67a8dbb3 (diff) |
Core plugins => CMPlugin
Diffstat (limited to 'src/core/stduseronline')
-rw-r--r-- | src/core/stduseronline/src/main.cpp | 8 | ||||
-rw-r--r-- | src/core/stduseronline/src/stdafx.h | 11 | ||||
-rw-r--r-- | src/core/stduseronline/src/useronline.cpp | 22 |
3 files changed, 20 insertions, 21 deletions
diff --git a/src/core/stduseronline/src/main.cpp b/src/core/stduseronline/src/main.cpp index 2d4a395103..3273f7f579 100644 --- a/src/core/stduseronline/src/main.cpp +++ b/src/core/stduseronline/src/main.cpp @@ -23,8 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc., int LoadUserOnlineModule(void);
+CMPlugin g_plugin;
CLIST_INTERFACE* pcli;
-HINSTANCE hInst;
int hLangpack;
PLUGININFOEX pluginInfo = {
@@ -40,12 +40,6 @@ PLUGININFOEX pluginInfo = { { 0x251c78d7, 0xf6e0, 0x4083, {0x92, 0xdc, 0x25, 0x2d, 0xcb, 0x3b, 0xe7, 0x24}}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
diff --git a/src/core/stduseronline/src/stdafx.h b/src/core/stduseronline/src/stdafx.h index c29da6dc6f..9fae72e8ed 100644 --- a/src/core/stduseronline/src/stdafx.h +++ b/src/core/stduseronline/src/stdafx.h @@ -40,9 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <direct.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
-
#include <m_system.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -66,4 +64,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../mir_app/src/resource.h"
-extern HINSTANCE hInst;
+#define MODULENAME "UserOnline"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
diff --git a/src/core/stduseronline/src/useronline.cpp b/src/core/stduseronline/src/useronline.cpp index 148eada919..54063cb44c 100644 --- a/src/core/stduseronline/src/useronline.cpp +++ b/src/core/stduseronline/src/useronline.cpp @@ -33,23 +33,23 @@ static int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
int newStatus = cws->value.wVal;
- int oldStatus = db_get_w(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE);
- db_set_w(hContact, "UserOnline", "OldStatus", (WORD)newStatus);
+ int oldStatus = db_get_w(hContact, MODULENAME, "OldStatus", ID_STATUS_OFFLINE);
+ db_set_w(hContact, MODULENAME, "OldStatus", (WORD)newStatus);
if (CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_USERONLINE)) return 0;
if (db_get_b(hContact, "CList", "Hidden", 0)) return 0;
if (newStatus == ID_STATUS_OFFLINE && oldStatus != ID_STATUS_OFFLINE) {
// Remove the event from the queue if it exists since they are now offline
- int lastEvent = (int)db_get_dw(hContact, "UserOnline", "LastEvent", 0);
+ int lastEvent = (int)db_get_dw(hContact, MODULENAME, "LastEvent", 0);
if (lastEvent) {
pcli->pfnRemoveEvent(hContact, lastEvent);
- db_set_dw(hContact, "UserOnline", "LastEvent", 0);
+ db_set_dw(hContact, MODULENAME, "LastEvent", 0);
}
}
if ((newStatus == ID_STATUS_ONLINE || newStatus == ID_STATUS_FREECHAT) &&
oldStatus != ID_STATUS_ONLINE && oldStatus != ID_STATUS_FREECHAT) {
{
- DWORD ticked = db_get_dw(NULL, "UserOnline", cws->szModule, GetTickCount());
+ DWORD ticked = db_get_dw(NULL, MODULENAME, cws->szModule, GetTickCount());
// only play the sound (or show event) if this event happens at least 10 secs after the proto went from offline
if (GetTickCount() - ticked > (1000*10)) {
wchar_t tooltip[256];
@@ -64,8 +64,8 @@ static int UserOnlineSettingChanged(WPARAM hContact, LPARAM lParam) cle.szTooltip.w = tooltip;
pcli->pfnAddEvent(&cle);
IcoLib_ReleaseIcon(cle.hIcon, 0);
- db_set_dw(cle.hContact, "UserOnline", "LastEvent", (DWORD)cle.hDbEvent);
- Skin_PlaySound("UserOnline");
+ db_set_dw(cle.hContact, MODULENAME, "LastEvent", (DWORD)cle.hDbEvent);
+ Skin_PlaySound(MODULENAME);
}
}
}
@@ -77,7 +77,7 @@ static int UserOnlineAck(WPARAM, LPARAM lParam) ACKDATA * ack = (ACKDATA*) lParam;
if (ack != nullptr && ack->szModule && ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS && ack->hProcess == (HANDLE)ID_STATUS_OFFLINE) {
// if going from offline to any other mode, remember when it happened.
- db_set_dw(NULL, "UserOnline", ack->szModule, GetTickCount());
+ db_set_dw(NULL, MODULENAME, ack->szModule, GetTickCount());
}
return 0;
}
@@ -86,7 +86,7 @@ static int UserOnlineModulesLoaded(WPARAM, LPARAM) {
for (auto &pa : Accounts())
if (pa->IsEnabled())
- db_set_dw(NULL, "UserOnline", pa->szModuleName, GetTickCount());
+ db_set_dw(NULL, MODULENAME, pa->szModuleName, GetTickCount());
return 0;
}
@@ -100,7 +100,7 @@ static int UserOnlineAccountsChanged(WPARAM eventCode, LPARAM lParam) case PRAC_CHECKED:
// reset the counter
if (pa->IsEnabled())
- db_set_dw(NULL, "UserOnline", pa->szModuleName, GetTickCount());
+ db_set_dw(NULL, MODULENAME, pa->szModuleName, GetTickCount());
break;
}
return 0;
@@ -112,6 +112,6 @@ int LoadUserOnlineModule(void) HookEvent(ME_PROTO_ACK, UserOnlineAck);
HookEvent(ME_SYSTEM_MODULESLOADED, UserOnlineModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, UserOnlineAccountsChanged);
- Skin_AddSound("UserOnline", LPGENW("Alerts"), LPGENW("Online"));
+ Skin_AddSound(MODULENAME, LPGENW("Alerts"), LPGENW("Online"));
return 0;
}
|