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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/*
Chat module plugin for Miranda IM
Copyright (C) 2003 Jörgen Persson
Copyright 2003-2009 Miranda ICQ/IM project,
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"
// globals
CHAT_MANAGER *pci, saveCI;
HMENU g_hMenu = NULL;
GlobalLogSettings g_Settings;
void LoadModuleIcons(MODULEINFO *mi)
{
HIMAGELIST hList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
int overlayIcon = ImageList_AddIcon(hList, GetCachedIcon("chat_overlay"));
ImageList_SetOverlayImage(hList, overlayIcon, 1);
int index = ImageList_AddIcon(hList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE));
mi->hOnlineIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT);
mi->hOnlineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
index = ImageList_AddIcon(hList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_OFFLINE));
mi->hOfflineIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT);
mi->hOfflineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
ImageList_Destroy(hList);
}
static void OnAddLog(SESSION_INFO *si, int isOk)
{
if (isOk && si->hWnd)
SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
else if (si->hWnd)
SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
}
static void OnSessionDblClick(SESSION_INFO *si)
{
PostMessage(si->hWnd, GC_CLOSEWINDOW, 0, 0);
}
static void OnSessionRemove(SESSION_INFO *si)
{
if (si->hWnd)
SendMessage(si->hWnd, GC_EVENT_CONTROL + WM_USER + 500, SESSION_TERMINATE, 0);
}
static void OnSessionRename(SESSION_INFO *si)
{
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
}
static void OnSessionReplace(SESSION_INFO *si)
{
if (si->hWnd)
RedrawWindow(GetDlgItem(si->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
}
static void OnEventBroadcast(SESSION_INFO *si, GCEVENT *gce)
{
if (pci->SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE) && si->hWnd && si->bInitDone)
SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
else if (si->hWnd && si->bInitDone)
SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
}
static void OnSetStatusBar(SESSION_INFO *si)
{
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
}
static void OnNewUser(SESSION_INFO *si, USERINFO*)
{
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
}
static void OnSetStatus(SESSION_INFO *si, int wStatus)
{
PostMessage(si->hWnd, GC_FIXTABICONS, 0, 0);
}
static void OnFlashWindow(SESSION_INFO *si, int bInactive)
{
if (bInactive && si->hWnd && db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0)
SendMessage(GetParent(si->hWnd), CM_STARTFLASHING, 0, 0);
if (bInactive && si->hWnd)
SendMessage(si->hWnd, GC_SETMESSAGEHIGHLIGHT, 0, 0);
}
static void OnCreateModule(MODULEINFO *mi)
{
LoadModuleIcons(mi);
mi->hOnlineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_ONLINE);
mi->hOfflineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_OFFLINE);
}
static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
{
if (gce->pDest->iType & g_Settings.dwTrayIconFlags)
return saveCI.DoTrayIcon(si, gce);
return TRUE;
}
static BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce)
{
if (gce->pDest->iType & g_Settings.dwPopupFlags)
return saveCI.DoPopup(si, gce);
return TRUE;
}
static void RegisterFonts()
{
ColourIDT colourid = { sizeof(colourid) };
strncpy(colourid.dbSettingsGroup, "Chat", sizeof(colourid.dbSettingsGroup));
_tcsncpy(colourid.group, LPGENT("Messaging")_T("/")LPGENT("Group chats"), SIZEOF(colourid.group));
strncpy(colourid.setting, "ColorLogBG", SIZEOF(colourid.setting));
_tcsncpy(colourid.name, LPGENT("Group chat log background"), SIZEOF(colourid.name));
mir_sntprintf(colourid.group, SIZEOF(colourid.group), _T("%s/%s"), LPGENT("Messaging"), LPGENT("Group chats"));
colourid.defcolour = GetSysColor(COLOR_WINDOW);
ColourRegisterT(&colourid);
strncpy(colourid.setting, "ColorNicklistBG", SIZEOF(colourid.setting));
_tcsncpy(colourid.name, LPGENT("User list background"), SIZEOF(colourid.name));
colourid.defcolour = GetSysColor(COLOR_WINDOW);
ColourRegisterT(&colourid);
strncpy(colourid.setting, "ColorNicklistLines", SIZEOF(colourid.setting));
_tcsncpy(colourid.name, LPGENT("User list lines"), SIZEOF(colourid.name));
colourid.defcolour = GetSysColor(COLOR_INACTIVEBORDER);
ColourRegisterT(&colourid);
strncpy(colourid.setting, "ColorNicklistSelectedBG", SIZEOF(colourid.setting));
_tcsncpy(colourid.name, LPGENT("User list background (selected)"), SIZEOF(colourid.name));
colourid.defcolour = GetSysColor(COLOR_HIGHLIGHT);
ColourRegisterT(&colourid);
}
int Chat_Load()
{
CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENT("Messaging")_T("/")LPGENT("Group chats") };
mir_getCI(&data);
saveCI = *pci;
pci->OnCreateModule = OnCreateModule;
pci->OnNewUser = OnNewUser;
pci->OnSetStatus = OnSetStatus;
pci->OnAddLog = OnAddLog;
pci->OnSessionRemove = OnSessionRemove;
pci->OnSessionRename = OnSessionRename;
pci->OnSessionReplace = OnSessionReplace;
pci->OnSessionDblClick = OnSessionDblClick;
pci->OnEventBroadcast = OnEventBroadcast;
pci->OnSetStatusBar = OnSetStatusBar;
pci->OnFlashWindow = OnFlashWindow;
pci->ShowRoom = ShowRoom;
pci->DoPopup = DoPopup;
pci->DoTrayIcon = DoTrayIcon;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
TranslateMenu(g_hMenu);
return 0;
}
int Chat_Unload(void)
{
db_set_w(NULL, "Chat", "SplitterX", (WORD)g_Settings.iSplitterX);
DestroyMenu(g_hMenu);
*pci = saveCI;
return 0;
}
int Chat_ModulesLoaded(WPARAM wParam,LPARAM lParam)
{
OptionsInit();
return 0;
}
|