summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/main.cpp
blob: 63d41a959919531031a28b81fa9716e76f115d94 (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
/*
 * Miranda NG: the free IM client for Microsoft* Windows*
 *
 * Copyright (c) 2000-09 Miranda ICQ/IM project,
 * all portions of this codebase are copyrighted to the people
 * listed in contributors.txt.
 *
 * 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.
 *
 * part of tabSRMM messaging plugin for Miranda.
 *
 * This code is based on and still contains large parts of the the
 * original chat module for Miranda NG, written and copyrighted
 * by Joergen Persson in 2005.
 *
 * (C) 2005-2009 by silvercircle _at_ gmail _dot_ com and contributors
 *
 * chat module exports and functions to load/unload the plugin.
 *
 */

#include "..\commonheaders.h"

HANDLE g_hWindowList;
HMENU  g_hMenu = NULL;

FONTINFO	aFonts[OPTIONS_FONTCOUNT];
HICON	   hIcons[30];
HBRUSH   hListBkgBrush = NULL;

TMUCSettings g_Settings;

TCHAR *pszActiveWndID = 0;
char  *pszActiveWndModule = 0;

/*
 * load the group chat module
 */

int Chat_Load()
{
	g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
	if (CreateServiceFunctions()) {
		HookEvents();
		CreateHookableEvents();
		OptionsInit();
	}
	return 0;
}

/*
 * unload the module. final cleanup
 */

int Chat_Unload(void)
{
	db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
	db_set_w(NULL, "Chat", "splitY", (WORD)g_Settings.iSplitterY);

	CList_SetAllOffline(TRUE, NULL);

	mir_free(pszActiveWndID);
	mir_free(pszActiveWndModule);

	DestroyMenu(g_hMenu);
	DestroyHookableEvents();
	FreeIcons();
	OptionsUnInit();
	UnhookEvents();
	return 0;
}

void LoadLogIcons(void)
{
	ZeroMemory(hIcons, sizeof(HICON) * (ICON_STATUS5 - ICON_ACTION));
	hIcons[ICON_ACTION]     = LoadIconEx(IDI_ACTION, "log_action", 16, 16);
	hIcons[ICON_ADDSTATUS]  = LoadIconEx(IDI_ADDSTATUS, "log_addstatus", 16, 16);
	hIcons[ICON_HIGHLIGHT]  = LoadIconEx(IDI_HIGHLIGHT, "log_highlight", 16, 16);
	hIcons[ICON_INFO]       = LoadIconEx(IDI_INFO, "log_info", 16, 16);
	hIcons[ICON_JOIN]       = LoadIconEx(IDI_JOIN, "log_join", 16, 16);
	hIcons[ICON_KICK]       = LoadIconEx(IDI_KICK, "log_kick", 16, 16);
	hIcons[ICON_MESSAGE]    = LoadIconEx(IDI_MESSAGE, "log_message_in", 16, 16);
	hIcons[ICON_MESSAGEOUT] = LoadIconEx(IDI_MESSAGEOUT, "log_message_out", 16, 16);
	hIcons[ICON_NICK]       = LoadIconEx(IDI_NICK, "log_nick", 16, 16);
	hIcons[ICON_NOTICE]     = LoadIconEx(IDI_NOTICE, "log_notice", 16, 16);
	hIcons[ICON_PART]       = LoadIconEx(IDI_PART, "log_part", 16, 16);
	hIcons[ICON_QUIT]       = LoadIconEx(IDI_QUIT, "log_quit", 16, 16);
	hIcons[ICON_REMSTATUS]  = LoadIconEx(IDI_REMSTATUS, "log_removestatus", 16, 16);
	hIcons[ICON_TOPIC]      = LoadIconEx(IDI_TOPIC, "log_topic", 16, 16);
	hIcons[ICON_STATUS1]    = LoadIconEx(IDI_STATUS1, "status1", 16, 16);
	hIcons[ICON_STATUS2]    = LoadIconEx(IDI_STATUS2, "status2", 16, 16);
	hIcons[ICON_STATUS3]    = LoadIconEx(IDI_STATUS3, "status3", 16, 16);
	hIcons[ICON_STATUS4]    = LoadIconEx(IDI_STATUS4, "status4", 16, 16);
	hIcons[ICON_STATUS0]    = LoadIconEx(IDI_STATUS0, "status0", 16, 16);
	hIcons[ICON_STATUS5]    = LoadIconEx(IDI_STATUS5, "status5", 16, 16);
}

void LoadIcons(void)
{
	for (int i=0; i < 20; i++)
		hIcons[i] = NULL;

	LoadLogIcons();
	g_Settings.hIconOverlay = LoadIconEx(IDI_OVERLAY, "overlay", 16, 16);
	LoadMsgLogBitmaps();
}

void FreeIcons(void)
{
	FreeMsgLogBitmaps();
}