summaryrefslogtreecommitdiff
path: root/plugins/Bonsai/Bonsai.cpp
blob: 7952b0e3348d7265daede29a71c6bc77c9270715 (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
126
127
128
/*
Bonsai plugin for Miranda IM

Copyright © 2006 Cristian Libotean

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 "commonheaders.h"

#define ICON_SIZE 16

char ModuleName[] = "Bonsai";
HINSTANCE hInstance;
int bUseANSIStrings = 0;

HBITMAP hbModified = NULL;
HBITMAP hbUnmodified = NULL;
HBITMAP hbHidden = NULL;
HBITMAP hbNewlyModified = NULL;
HIMAGELIST imgList = NULL;

PLUGINLINK *pluginLink;
int hLangpack;
struct MM_INTERFACE mmi;

PLUGININFOEX pluginInfo = {
	sizeof(PLUGININFOEX),
	__PLUGIN_DISPLAY_NAME,
	VERSION,
	__DESC,
	__AUTHOR,
	__AUTHOREMAIL,
	__COPYRIGHT,
	__AUTHORWEB,
	UNICODE_AWARE, //unicode aware
	0,
	{0x2fe47261, 0x7f38, 0x45f4, {0x8f, 0xac, 0xb8, 0x7e, 0x97, 0x4a, 0x13, 0x50}} //{2fe47261-7f38-45f4-8fac-b87e974a1350}
};

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

static const MUUID interfaces[] = {MIID_BONSAI, MIID_LAST};

extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces()
{
	return interfaces;
}

extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
	INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icex.dwICC = ICC_LISTVIEW_CLASSES;
	
	InitCommonControls();

	LogInit();
	
	pluginLink = link;
	mir_getMMI(&mmi);
	mir_getLP(&pluginInfo);
	
	InitServices();
	
	HookEvents();
	
	hbModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MODIFIED));
	hbUnmodified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNMODIFIED));
	hbHidden = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HIDDEN));
	hbNewlyModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_NEWLYMODIFIED));
	imgList = ImageList_Create(ICON_SIZE, ICON_SIZE, ILC_COLORDDB | ILC_MASK, 2, 1);
	ImageList_AddMasked(imgList, hbUnmodified, RGB(255, 0, 255));
	ImageList_AddMasked(imgList, hbModified, RGB(255, 0, 255));
	ImageList_AddMasked(imgList, hbHidden, RGB(255, 0, 255));
	ImageList_AddMasked(imgList, hbNewlyModified, RGB(255, 0, 255));
	
	//are we running on Windows 98 ?
	OSVERSIONINFO vi = {0};
	vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&vi);
	bUseANSIStrings = (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 0 : 1;
	char mirVer[512];
	CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(mirVer), (LPARAM) mirVer);
	_strlwr(mirVer);
	bUseANSIStrings = (strstr(mirVer, "unicode") == NULL) ? 1 : bUseANSIStrings;
	Log("Windows 98 ? %d", bUseANSIStrings);
	
	return 0;
}

extern "C" int __declspec(dllexport) Unload()
{
	DestroyServices();

	UnhookEvents();
	
	ImageList_Destroy(imgList);
	
	return 0;
}

bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
	hInstance = hinstDLL;
	if (fdwReason == DLL_PROCESS_ATTACH)
		{
			DisableThreadLibraryCalls(hinstDLL);
		}
		
	return TRUE;
}