summaryrefslogtreecommitdiff
path: root/plugins/SeenPlugin/src/main.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-03-02 17:24:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-03-02 17:24:43 +0000
commit20cc2883a8790563b18e7ba2985b6e92b27073af (patch)
tree9a7fb043b04465a9df88434ffc0f60e438bfe7c1 /plugins/SeenPlugin/src/main.cpp
parent2c65784dd4a3c4bfdca6487244291926b9ff9132 (diff)
- much more effective protocol filter;
- support for server-side LastSeen requests; - interception of LastSeen writes from another modules; - code cleaning; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12300 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SeenPlugin/src/main.cpp')
-rw-r--r--plugins/SeenPlugin/src/main.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp
index c59b7927e7..ad6f81bfad 100644
--- a/plugins/SeenPlugin/src/main.cpp
+++ b/plugins/SeenPlugin/src/main.cpp
@@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
HINSTANCE hInstance;
HANDLE ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL;
-HANDLE g_hShutdownEvent;
+HANDLE g_hShutdownEvent, g_pUserInfo;
int hLangpack;
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -37,25 +37,36 @@ 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 } }
};
#define TRANSNUMBER 2
-DBVTranslation idleTr[TRANSNUMBER]={
- {any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"),0},
- {any_to_Idle, _T("Any to /Idle or empty"),0}
+DBVTranslation idleTr[TRANSNUMBER] = {
+ { any_to_IdleNotidleUnknown, _T("Any to Idle/Not Idle/Unknown"), 0 },
+ { any_to_Idle, _T("Any to /Idle or empty"), 0 }
};
+static int CompareProtos(const char *p1, const char *p2)
+{ return mir_strcmp(p1, p2);
+}
+
BOOL includeIdle;
+LIST<char> arWatchedProtos(10, CompareProtos);
LIST<logthread_info> arContacts(16, NumericKeySortT);
-CRITICAL_SECTION csContacts;
+mir_cs csContacts;
void UninitHistoryDialog(void);
-int MainInit(WPARAM,LPARAM)
+int MainInit(WPARAM, LPARAM)
{
- if ( ServiceExists(MS_TIPPER_ADDTRANSLATION))
- for (int i=0; i < TRANSNUMBER; i++)
+ if (db_get_b(NULL, S_MOD, "MenuItem", 1))
+ InitMenuitem();
+
+ if (db_get_b(NULL, S_MOD, "UserinfoTab", 1))
+ ehuserinfo = HookEvent(ME_USERINFO_INITIALISE, UserinfoInit);
+
+ if (ServiceExists(MS_TIPPER_ADDTRANSLATION))
+ for (int i = 0; i < TRANSNUMBER; i++)
CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]);
return 0;
@@ -71,28 +82,24 @@ extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
- g_hShutdownEvent = CreateEvent(0, TRUE, FALSE, 0);
- InitializeCriticalSection(&csContacts);
+ g_pUserInfo = WindowList_Create();
+ g_hShutdownEvent = CreateEvent(0, TRUE, FALSE, 0);
HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UpdateValues);
- HookEvent(ME_PROTO_ACK,ModeChange);
+ HookEvent(ME_PROTO_ACK, ModeChange);
- includeIdle = (BOOL )db_get_b(NULL,S_MOD,"IdleSupport",1);
-
- if ( db_get_b(NULL,S_MOD,"MenuItem",1))
- InitMenuitem();
-
- if ( db_get_b(NULL,S_MOD,"UserinfoTab",1))
- ehuserinfo = HookEvent(ME_USERINFO_INITIALISE,UserinfoInit);
+ includeIdle = (BOOL)db_get_b(NULL, S_MOD, "IdleSupport", 1);
- if ( db_get_b(NULL,S_MOD,"FileOutput",0))
+ if (db_get_b(NULL, S_MOD, "FileOutput", 0))
InitFileOutput();
- if ( db_get_b(NULL,S_MOD,"MissedOnes",0))
- ehmissed_proto = HookEvent(ME_PROTO_ACK,ModeChange_mo);
+ if (db_get_b(NULL, S_MOD, "MissedOnes", 0))
+ ehmissed_proto = HookEvent(ME_PROTO_ACK, ModeChange_mo);
+
+ LoadWatchedProtos();
SkinAddNewSoundExT("LastSeenTrackedStatusChange", LPGENT("LastSeen"), LPGENT("User status change"));
SkinAddNewSoundExT("LastSeenTrackedStatusOnline", LPGENT("LastSeen"), LPGENT("Changed to Online"));
@@ -108,10 +115,13 @@ extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD)
extern "C" __declspec(dllexport) int Unload(void)
{
+ UnloadWatchedProtos();
+
+ WindowList_Destroy(g_pUserInfo);
+
if (ehmissed)
UnhookEvent(ehmissed);
- DeleteCriticalSection(&csContacts);
CloseHandle(g_hShutdownEvent);
UninitHistoryDialog();
return 0;
@@ -119,6 +129,6 @@ extern "C" __declspec(dllexport) int Unload(void)
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
- hInstance=hinst;
+ hInstance = hinst;
return 1;
}