summaryrefslogtreecommitdiff
path: root/nohtml/nohtml.cpp
blob: caacecbcc0f442c76a1d4b1416af38404300ef7c (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
/* Replace "dll.h" with the name of your header */
#include "common.h"
#include "version.h"
#include "resource.h"
#include "options.h"
#include "filter.h"

///////////////////////////////////////////////
// Common Plugin Stuff
///////////////////////////////////////////////
HINSTANCE hInst;
PLUGINLINK *pluginLink;
DWORD mirandaVer;
int codepage;

PLUGININFOEX pluginInfo={
	sizeof(PLUGININFOEX),
	//META_PROTO,
	__PLUGIN_NAME,		// altered here and on file listing, so as not to match original
	PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
	__DESC,
	__AUTHOR,
	__AUTHOREMAIL,
	__COPYRIGHT,
	__AUTHORWEB,
	UNICODE_AWARE,		//not transient
	0,
	// TODO: generate your own GUID!!
	{ 0xD78C8249, 0xE8DB, 0x46B1, { 0x92, 0xF3, 0x88, 0xE6, 0xDC, 0x96, 0x4E, 0x8D } }	
};


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

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

extern "C" __declspec (dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) {
	mirandaVer = mirandaVersion;
	pluginInfo.cbSize = sizeof(PLUGININFO);
	return (PLUGININFO*)&pluginInfo;
}

static const MUUID interfaces[] = {MIID_NOHTML, MIID_LAST};
extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
{
	return interfaces;
}

int ModulesLoaded(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.szBetaChangelogURL = "https://server.scottellis.com.au/wsvn/mim_plugs/nohtml/?op=log&rev=0&sc=0&isdir=1";

		update.szUpdateURL = UPDATER_AUTOREGISTER;
		
		// these are the three lines that matter - the archive, the page containing the version string, and the text (or data) 
		// before the version that we use to locate it on the page
		// (note that if the update URL and the version URL point to standard file listing entries, the backend xml
		// data will be used to check for updates rather than the actual web page - this is not true for beta urls)
		update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/nohtml.zip";
		update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_nohtml.html";
		update.pbBetaVersionPrefix = (BYTE *)"No HTML version ";
		
		update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);

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

#ifdef _DEBUG
	// show miranda version
	char str[20];
	str[0] = '0';
	str[1] = 'x';
	_itoa(mirandaVer, str+2, 16);
	PUShowMessage(str, SM_NOTIFY);
#endif

	return 0;
}

HANDLE hModulesLoaded;
extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) {
	pluginLink=link;

	codepage = (int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
	InitOptions();

	/////////////
	////// init filter
	RegisterFilter();
	CreateFilterServices();
	AddFilterToContacts();	

	// hook modules loaded
	hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
	return 0;
}

extern "C" __declspec (dllexport) int Unload(void) {
	UnhookEvent(hModulesLoaded);
	DeinitFilter();
	DeinitOptions();

	return 0;
}