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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
/*
Chat module interface for Miranda NG
Copyright (c) 2014-18 George Hazan
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.
*/
#pragma once
#ifndef M_CHAT_INT_H__
#define M_CHAT_INT_H__ 1
#pragma warning(disable:4512 4275)
#include <time.h>
#ifndef M_CORE_H__
#include <m_core.h>
#endif
#include <m_string.h>
#include <m_chat.h>
#include <m_gui.h>
#include <m_utils.h>
#define OPTIONS_FONTCOUNT 20
#define STATUSICONCOUNT 6
#define CHAT_MODULE "Chat"
#define CHATFONT_MODULE "ChatFonts"
#define GC_FAKE_EVENT MEVENT(0xBABABEDA)
#define TIMERID_FLASHWND 1
#define GCW_TABROOM 10
#define GCW_TABPRIVMSG 11
#define GC_EVENT_HIGHLIGHT 0x1000
#define STATE_TALK 0x0001
#define ICON_ACTION 0
#define ICON_ADDSTATUS 1
#define ICON_HIGHLIGHT 2
#define ICON_INFO 3
#define ICON_JOIN 4
#define ICON_KICK 5
#define ICON_MESSAGE 6
#define ICON_MESSAGEOUT 7
#define ICON_NICK 8
#define ICON_NOTICE 9
#define ICON_PART 10
#define ICON_QUIT 11
#define ICON_REMSTATUS 12
#define ICON_TOPIC 13
#define ICON_STATUS0 14
#define ICON_STATUS1 15
#define ICON_STATUS2 16
#define ICON_STATUS3 17
#define ICON_STATUS4 18
#define ICON_STATUS5 19
//structs
struct SESSION_INFO;
struct MODULEINFO;
struct LOGSTREAMDATA;
class CChatRoomDlg;
struct USERINFO : public MZeroedObject, public MNonCopyable
{
wchar_t* pszNick;
wchar_t* pszUID;
WORD Status;
int iStatusEx;
WORD ContactStatus;
};
struct MIR_APP_EXPORT GCModuleInfoBase : public MZeroedObject, public MNonCopyable
{
GCModuleInfoBase();
~GCModuleInfoBase();
char *pszModule;
wchar_t *ptszModDispName;
char *pszHeader;
bool bBold, bItalics, bUnderline;
bool bColor, bBkgColor;
bool bChanMgr, bAckMsg;
int iMaxText;
};
struct COMMANDINFO
{
char *lpCommand;
COMMANDINFO *last, *next;
};
struct FONTINFO
{
LOGFONT lf;
COLORREF color;
};
struct LOGINFO
{
wchar_t *ptszText;
wchar_t *ptszNick;
wchar_t *ptszUID;
wchar_t *ptszStatus;
wchar_t *ptszUserInfo;
BOOL bIsMe;
BOOL bIsHighlighted;
time_t time;
int iType;
DWORD dwFlags;
LOGINFO *next, *prev;
};
struct STATUSINFO
{
wchar_t *pszGroup;
int iIconIndex;
int iStatus;
STATUSINFO *next;
};
struct MIR_APP_EXPORT GCSessionInfoBase : public MZeroedObject, public MNonCopyable
{
GCSessionInfoBase();
~GCSessionInfoBase();
MCONTACT hContact;
bool bInitDone;
bool bHasToolTip;
bool bTrimmed;
char* pszModule;
wchar_t* ptszID;
wchar_t* ptszName;
wchar_t* ptszStatusbarText;
wchar_t* ptszTopic;
int iType;
int iEventCount;
int iStatusCount;
WORD wStatus;
WORD wState;
WORD wCommandsNum;
void* pItemData;
time_t LastTime;
int currentHovered;
CChatRoomDlg *pDlg;
COMMANDINFO *lpCommands, *lpCurrentCommand;
LOGINFO *pLog, *pLogEnd;
USERINFO *pMe;
STATUSINFO *pStatuses;
MODULEINFO *pMI;
GCSessionInfoBase *pParent;
OBJLIST<USERINFO> arUsers;
wchar_t pszLogFileName[MAX_PATH];
__forceinline USERINFO* getMe() const
{ return (pParent != nullptr) ? pParent->pMe : pMe;
}
__forceinline OBJLIST<USERINFO>& getUserList()
{ return (pParent != nullptr) ? pParent->arUsers : arUsers;
}
};
struct GCLogStreamDataBase
{
char* buffer;
int bufferOffset, bufferLen;
HWND hwnd;
LOGINFO* lin;
BOOL bStripFormat;
BOOL bRedraw;
SESSION_INFO *si;
};
struct GlobalLogSettingsBase
{
bool bShowTime;
bool bShowTimeIfChanged;
bool bLoggingEnabled;
bool bFlashWindow, bFlashWindowHighlight;
bool bHighlightEnabled;
bool bLogIndentEnabled;
bool bStripFormat;
bool bSoundsFocus;
bool bPopupInactiveOnly;
bool bTrayIconInactiveOnly;
bool bAddColonToAutoComplete;
bool bLogLimitNames;
bool bTimeStampEventColour;
bool bShowContactStatus;
bool bContactStatusFirst;
bool bDoubleClick4Privat; // send a private message on dblclick in a nick list
DWORD dwIconFlags;
DWORD dwTrayIconFlags;
DWORD dwPopupFlags;
int LogIconSize;
int LogTextIndent;
int LoggingLimit;
int iEventLimit;
int iPopupStyle;
int iPopupTimeout;
int iWidth;
int iHeight;
wchar_t *pszTimeStamp;
wchar_t *pszTimeStampLog;
wchar_t *pszIncomingNick;
wchar_t *pszOutgoingNick;
wchar_t *pszHighlightWords;
wchar_t *pszLogDir;
HFONT UserListFont;
HFONT UserListHeadingsFont;
HFONT NameFont;
COLORREF crLogBackground;
COLORREF crUserListColor;
COLORREF crUserListBGColor;
COLORREF crUserListSelectedBGColor;
COLORREF crUserListHeadingsColor;
COLORREF crPUTextColour;
COLORREF crPUBkgColour;
};
/////////////////////////////////////////////////////////////////////////////////////////
#define FONTMODE_USE 1
#define FONTMODE_SKIP 2
#define FONTMODE_ALTER 3
struct CHAT_MANAGER_INITDATA
{
GlobalLogSettingsBase *pSettings;
int cbModuleInfo, cbSession;
wchar_t *szFontGroup;
int iFontMode;
HPLUGIN pPlugin;
};
typedef BOOL (*pfnDoTrayIcon)(SESSION_INFO *si, GCEVENT *gce);
typedef BOOL (*pfnDoPopup)(SESSION_INFO *si, GCEVENT *gce);
struct CHAT_MANAGER
{
CHAT_MANAGER();
void (*SetActiveSession)(SESSION_INFO *si);
SESSION_INFO* (*GetActiveSession)(void);
SESSION_INFO* (*SM_CreateSession)(void);
SESSION_INFO* (*SM_FindSession)(const wchar_t *pszID, const char *pszModule);
HICON (*SM_GetStatusIcon)(SESSION_INFO *si, USERINFO * ui);
BOOL (*SM_BroadcastMessage)(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync);
void (*SM_AddCommand)(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand);
char* (*SM_GetPrevCommand)(const wchar_t *pszID, const char *pszModule);
char* (*SM_GetNextCommand)(const wchar_t *pszID, const char *pszModule);
int (*SM_GetCount)(const char *pszModule);
SESSION_INFO* (*SM_FindSessionByIndex)(const char *pszModule, int iItem);
USERINFO* (*SM_GetUserFromIndex)(const wchar_t *pszID, const char *pszModule, int index);
void (*SM_InvalidateLogDirectories)(void);
MODULEINFO* (*MM_CreateModule)(void);
void (*MM_FontsChanged)(void);
void (*MM_IconsChanged)(void);
BOOL (*MM_RemoveAll)(void);
STATUSINFO* (*TM_FindStatus)(STATUSINFO *pStatusList, const wchar_t *pszStatus);
wchar_t* (*TM_WordToString)(STATUSINFO *pStatusList, WORD Status);
BOOL (*TM_RemoveAll)(STATUSINFO** pStatusList);
int (*UM_CompareItem)(const USERINFO *u1, const USERINFO *u2);
USERINFO* (*UM_AddUser)(SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus);
USERINFO* (*UM_FindUser)(SESSION_INFO *si, const wchar_t *pszUID);
USERINFO* (*UM_FindUserFromIndex)(SESSION_INFO *si, int index);
USERINFO* (*UM_GiveStatus)(SESSION_INFO *si, const wchar_t *pszUID, WORD status);
USERINFO* (*UM_SetContactStatus)(SESSION_INFO *si, const wchar_t *pszUID, WORD status);
USERINFO* (*UM_TakeStatus)(SESSION_INFO *si, const wchar_t *pszUID, WORD status);
wchar_t* (*UM_FindUserAutoComplete)(SESSION_INFO *si, const wchar_t* pszOriginal, const wchar_t* pszCurrent);
BOOL (*UM_RemoveUser)(SESSION_INFO *si, const wchar_t *pszUID);
LOGINFO* (*LM_AddEvent)(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd);
BOOL (*LM_TrimLog)(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd, int iCount);
BOOL (*LM_RemoveAll)(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd);
BOOL (*SetOffline)(MCONTACT hContact, BOOL bHide);
BOOL (*SetAllOffline)(BOOL bHide, const char *pszModule);
BOOL (*AddEvent)(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...);
MCONTACT (*FindRoom)(const char *pszModule, const wchar_t *pszRoom);
char* (*Log_CreateRTF)(LOGSTREAMDATA *streamData);
char* (*Log_CreateRtfHeader)(void);
void (*LoadMsgDlgFont)(int i, LOGFONT *lf, COLORREF *color);
wchar_t* (*MakeTimeStamp)(wchar_t *pszStamp, time_t time);
BOOL (*DoSoundsFlashPopupTrayStuff)(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
BOOL (*DoTrayIcon)(SESSION_INFO *si, GCEVENT *gce);
BOOL (*DoPopup)(SESSION_INFO *si, GCEVENT *gce);
int (*ShowPopup)(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
BOOL (*LogToFile)(SESSION_INFO *si, GCEVENT *gce);
wchar_t* (*GetChatLogsFilename)(SESSION_INFO *si, time_t tTime);
char* (*Log_SetStyle)(int style);
bool (*IsHighlighted)(SESSION_INFO *si, GCEVENT *pszText);
wchar_t* (*RemoveFormatting)(const wchar_t *pszText);
void (*ReloadSettings)(void);
int (*DoRtfToTags)(CMStringW &pszText, int iNumColors, COLORREF *pColors);
int logPixelSY, logPixelSX;
char *szActiveWndModule;
wchar_t *szActiveWndID;
HICON hIcons[30];
HBRUSH hListBkgBrush, hListSelectedBkgBrush;
HANDLE hevWinPopup, hevPreCreate;
FONTINFO aFonts[OPTIONS_FONTCOUNT];
LIST<SESSION_INFO> &arSessions;
char **pLogIconBmpBits;
// user-defined custom callbacks
void (*OnCreateModule)(MODULEINFO*);
void (*OnDestroyModule)(MODULEINFO*);
void (*OnCreateSession)(SESSION_INFO*, MODULEINFO*);
void (*OnOfflineSession)(SESSION_INFO*);
void (*OnReplaceSession)(SESSION_INFO*);
void (*ShowRoom)(SESSION_INFO*);
void (*OnGetLogName)(SESSION_INFO*, const wchar_t*);
void (*OnEventBroadcast)(SESSION_INFO *si, GCEVENT *gce);
void (*OnSetTopic)(SESSION_INFO*);
void (*OnAddUser)(SESSION_INFO*, USERINFO*);
void (*OnNewUser)(SESSION_INFO*, USERINFO*);
void (*OnRemoveUser)(SESSION_INFO*, USERINFO*);
void (*OnChangeNick)(SESSION_INFO*);
void (*OnAddStatus)(SESSION_INFO*, STATUSINFO*);
void (*OnSetStatus)(SESSION_INFO*, int);
void (*OnLoadSettings)(void);
void (*OnFlashWindow)(SESSION_INFO*, int bInactive);
void (*OnFlashHighlight)(SESSION_INFO*, int bInactive);
};
extern MIR_APP_EXPORT CHAT_MANAGER g_chatApi;
EXTERN_C MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pData);
/////////////////////////////////////////////////////////////////////////////////////////
// receives LOGSTREAMDATA* as the first parameter
EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
// sends a message to all SRMM windows
EXTERN_C MIR_APP_DLL(void) Srmm_Broadcast(UINT, WPARAM, LPARAM);
// finds a SRMM window using hContact
EXTERN_C MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact);
// updates options for all windows
EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions();
// runs ME_GC_EVENT with the parameters passed
EXTERN_C MIR_APP_DLL(BOOL) Chat_DoEventHook(SESSION_INFO *si, int iType, const USERINFO *pUser, const wchar_t* pszText, INT_PTR dwItem);
// chat menu creation / destruction
EXTERN_C MIR_APP_DLL(UINT) Chat_CreateGCMenu(HWND hwnd, HMENU hMenu, POINT pt, SESSION_INFO *si, const wchar_t *pszUID, const wchar_t *pszWordText);
EXTERN_C MIR_APP_DLL(void) Chat_DestroyGCMenu(HMENU hMenu, int iIndex);
// calculates width or height of a string
EXTERN_C MIR_APP_DLL(int) Chat_GetTextPixelSize(const wchar_t *pszText, HFONT hFont, bool bWidth);
// message procedures' stubs
EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK stubLogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK stubMessageProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK stubNicklistProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
/////////////////////////////////////////////////////////////////////////////////////////
#include <chat_resource.h>
class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase
{
CSrmmBaseDialog(const CSrmmBaseDialog&) = delete;
CSrmmBaseDialog& operator=(const CSrmmBaseDialog&) = delete;
protected:
CSrmmBaseDialog(CMPluginBase&, int idDialog, SESSION_INFO *si = nullptr);
bool OnInitDialog() override;
void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
int NotifyEvent(int code);
bool ProcessHotkeys(int key, bool bShift, bool bCtrl, bool bAlt);
void RefreshButtonStatus(void);
void RunUserMenu(HWND hwndOwner, USERINFO *ui, const POINT &pt);
protected:
CCtrlRichEdit m_message, m_log;
SESSION_INFO *m_si;
COLORREF m_clrInputBG, m_clrInputFG;
time_t m_iLastEnterTime;
CCtrlListBox m_nickList;
CCtrlButton m_btnColor, m_btnBkColor;
CCtrlButton m_btnBold, m_btnItalic, m_btnUnderline;
CCtrlButton m_btnHistory, m_btnChannelMgr, m_btnNickList, m_btnFilter;
void onClick_BIU(CCtrlButton*);
void onClick_Color(CCtrlButton*);
void onClick_BkColor(CCtrlButton*);
void onClick_ChanMgr(CCtrlButton*);
void onClick_History(CCtrlButton*);
void onDblClick_List(CCtrlListBox*);
public:
MCONTACT m_hContact;
int m_iLogFilterFlags;
bool m_bFilterEnabled, m_bNicklistEnabled;
bool m_bFGSet, m_bBGSet;
bool m_bInMenu;
COLORREF m_iFG, m_iBG;
void ClearLog();
void RedrawLog2();
void ShowColorChooser(int iCtrlId);
virtual void AddLog();
virtual void CloseTab() {}
virtual bool IsActive() const PURE;
virtual void LoadSettings() PURE;
virtual void RedrawLog() {}
virtual void ScrollToBottom() {}
virtual void SetStatusText(const wchar_t*, HICON) {}
virtual void ShowFilterMenu() {}
virtual void StreamInEvents(LOGINFO*, bool) {}
virtual void UpdateNickList() {}
virtual void UpdateOptions() {}
virtual void UpdateStatusBar() {}
virtual void UpdateTitle() PURE;
virtual LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam);
virtual LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam);
virtual LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam);
__forceinline bool isChat() const { return m_si != nullptr; }
__inline void* operator new(size_t size){ return calloc(1, size); }
__inline void operator delete(void* p) { free(p); }
};
#endif // M_CHAT_INT_H__
|