summaryrefslogtreecommitdiff
path: root/xframes/xframes.cpp
blob: fae3cef898fdce23049e1dee4fef52820814b6d4 (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
// xframes.cpp : Defines the entry point for the DLL application.
//

#include "common.h"
#include "xframes.h"
#include "options.h"
#include "frames.h"

HINSTANCE hInst;
PLUGINLINK *pluginLink;

HANDLE mainThread;

bool metacontacts_installed;
bool unicode_system;

int code_page = CP_ACP;

HANDLE popupWindowList;

DWORD focusTimerId = 0;

PLUGININFO pluginInfo={
	sizeof(PLUGININFO),
	"XFrames",
	PLUGIN_MAKE_VERSION(0,0,1,2),
	"External frames support",
	"Scott Ellis",
	"mail@scottellis.com.au",
	"© 2005 Scott Ellis",
	"http://www.scottellis.com.au/",
	0,		//not transient
	0		//doesn't replace anything built-in
};


extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
	hInst=hinstDLL;
	DisableThreadLibraryCalls(hInst);
	return TRUE;
}

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

int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
	if(ServiceExists(MS_UPDATE_REGISTER)) {
		// register with updater
		Update update = {0};
		char szVersion[16];

		update.cbSize = sizeof(Update);

		update.szComponentName = pluginInfo.shortName;
		update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
		update.cpbVersion = strlen((char *)update.pbVersion);

		update.szUpdateURL = UPDATER_AUTOREGISTER;

		update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/xframes.zip";
		update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_xframes.html";
		update.pbBetaVersionPrefix = (BYTE *)"XFrames version ";		
		update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);

		CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
	}

	return 0;
}

int OnPreShutdown(WPARAM wParam, LPARAM lParam) {
	return 0;
}

extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
	if(GetModuleHandle(_T("clist_modern")) || GetModuleHandle(_T("clist_nicer")) || GetModuleHandle(_T("clist_mw")))
		return 1;

	pluginLink = link;
	DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );

	char szVer[128];
	unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode"));
	if(ServiceExists(MS_LANGPACK_GETCODEPAGE)) code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);

	// Ensure that the common control DLL is loaded (for listview)
	INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icex.dwICC  = ICC_LISTVIEW_CLASSES;
	InitCommonControlsEx(&icex); 	

	LoadOptions();
	InitFrames();

	HookEvent(ME_OPT_INITIALISE, OptInit);
	HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);

	return 0;
}

extern "C" int __declspec(dllexport) Unload(void)
{
	DeinitFrames();
	return 0;
}