summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/VypressChat/main.c
blob: ccf295017d99c6890452a13ffef35e2269d9b35f (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
129
130
131
132
/*
 * Miranda-IM Vypress Chat/quickChat plugins
 * Copyright (C) Saulius Menkevicius
 *
 * 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
 *
 * $Id: main.c,v 1.11 2005/03/09 14:44:22 bobas Exp $
 */

#include "miranda.h"
#include "main.h"
#include "service.h"
#include "user.h"
#include "userlist.h"
#include "chatroom.h"
#include "msghandler.h"
#include "options.h"
#include "skin.h"

/* forward references
 */

/* global data
 */
HINSTANCE	g_hDllInstance;	/* plugin dll instance */
HANDLE		g_hMainThread;

PLUGINLINK	* pluginLink;

/* exported routines
 */
BOOL WINAPI
DllMain(HINSTANCE hInstanceDLL, DWORD fwReason, LPVOID lpvReserved)
{
	g_hDllInstance = hInstanceDLL;
	return TRUE;
}

PLUGININFO pluginInfo = {
	sizeof(PLUGININFO),
	VQCHAT_PROTO_NAME " Protocol",
	PLUGIN_MAKE_VERSION(VQCHAT_VER_MAJ0, VQCHAT_VER_MAJ1, VQCHAT_VER_MIN0, VQCHAT_VER_MIN1),
	"Adds support for " VQCHAT_PROTO_NAME " networks.",
	"Saulius Menkevicius",
	"bobas@sourceforge.net",
	"(C) 2005 Saulius Menkevicius",
	"http://sourceforge.net/projects/miranda-vqchat/",
	0,		// NOT transient
	0		// doesn't replace anything builtin
};

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

__declspec(dllexport) int
Load(PLUGINLINK * link)
{
	PROTOCOLDESCRIPTOR pd;
	INITCOMMONCONTROLSEX iccs;

	/* setup static data */
	pluginLink = link;

	/* get main thread handle */
	DuplicateHandle(
		GetCurrentProcess(), GetCurrentThread(),
		GetCurrentProcess(), &g_hMainThread,
		THREAD_SET_CONTEXT, FALSE, 0);
	
	/* init common controls library (for the IP adress entries to work)
	 */
	memset(&iccs, 0, sizeof(iccs));
	iccs.dwSize = sizeof(iccs);
	iccs.dwICC = ICC_INTERNET_CLASSES;
	InitCommonControlsEx(&iccs);

	/* init vqp_link module */
	vqp_init(NULL, NULL);

	/* register this module with miranda */
	memset(&pd, 0, sizeof(pd));
	pd.cbSize = sizeof(pd);
	pd.szName = VQCHAT_PROTO;
	pd.type = PROTOTYPE_PROTOCOL;
	CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);

	/* init our modules */
	options_init();
	msghandler_init();
	skin_init();
	user_init();
	userlist_init();
	chatroom_init();

	/* register protocol services */
	service_register_services();
	service_hook_all();

	return 0;
}

__declspec(dllexport) int
Unload(void)
{
	service_uninit();
	user_uninit();
	userlist_uninit();
	chatroom_uninit();
	msghandler_uninit();
	options_uninit();
	skin_uninit();

	vqp_uninit();

	return 0;
}