summaryrefslogtreecommitdiff
path: root/plugins/SeenPlugin/src/main.cpp
blob: 98391ee155a532cef0a9f35f80a263d625efcf32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
"Last Seen mod" plugin for Miranda IM
Copyright ( C ) 2002-03  micron-x
Copyright ( C ) 2005-07  Y.B.

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; either version 2
of the License, or ( at your option ) any later version.

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "seen.h"

HINSTANCE hInstance;
HANDLE ehmissed = NULL, ehuserinfo = NULL, ehmissed_proto = NULL;
HANDLE g_hShutdownEvent;

int hLangpack;

PLUGININFOEX pluginInfo={
	sizeof(PLUGININFOEX),
	__PLUGIN_NAME,
	PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
	__DESCRIPTION,
	__AUTHOR,
	__AUTHOREMAIL,
	__COPYRIGHT,
	__AUTHORWEB,
	UNICODE_AWARE,
	// {2D506D46-C94E-4EF8-8537-F11233A80381}
	{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}
};

BOOL includeIdle;
LIST<logthread_info> arContacts(16, LIST<logthread_info>::FTSortFunc(HandleKeySortT));

int MainInit(WPARAM wparam,LPARAM lparam)
{
	includeIdle = (BOOL )db_get_b(NULL,S_MOD,"IdleSupport",1);
	HookEvent(ME_OPT_INITIALISE, OptionsInit);
	
	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 ( 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);

	HookEvent(ME_DB_CONTACT_SETTINGCHANGED, UpdateValues);
	HookEvent(ME_PROTO_ACK,ModeChange);

	SkinAddNewSoundExT("LastSeenTrackedStatusChange", LPGENT("LastSeen"), LPGENT("User status change"));
	SkinAddNewSoundExT("LastSeenTrackedStatusOnline", LPGENT("LastSeen"), LPGENT("Changed to Online"));
	SkinAddNewSoundExT("LastSeenTrackedStatusOffline", LPGENT("LastSeen"), LPGENT("User Logged Off"));
	SkinAddNewSoundExT("LastSeenTrackedStatusFromOffline", LPGENT("LastSeen"), LPGENT("User Logged In"));
	
	// known modules list
	if (ServiceExists("DBEditorpp/RegisterSingleModule"))
		CallService("DBEditorpp/RegisterSingleModule", (WPARAM)S_MOD, 0);
	db_set_s(NULL,"Uninstall",Translate("Last seen"),S_MOD);

	if ( ServiceExists(MS_TIPPER_ADDTRANSLATION))
		for (int i=0; i < TRANSNUMBER; i++)
			CallService(MS_TIPPER_ADDTRANSLATION, 0, (LPARAM)&idleTr[i]);

	return 0;
}

static int OnShutdown(WPARAM, LPARAM)
{
	SetEvent(g_hShutdownEvent);
	return 0;
}

extern "C" __declspec(dllexport) int Load(void)
{
	mir_getLP(&pluginInfo);

	g_hShutdownEvent = CreateEvent(0, TRUE, FALSE, 0); 

	HookEvent(ME_SYSTEM_MODULESLOADED, MainInit);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
	return 0;
}

extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion)
{
	return &pluginInfo;
}

extern "C" __declspec(dllexport) int Unload(void)
{
	if (ehmissed)
		UnhookEvent(ehmissed);

	arContacts.destroy();
	CloseHandle(g_hShutdownEvent);
	return 0;
}

BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
	hInstance=hinst;
	return 1;
}