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
|
/*
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org)
Copyright (c) 2000-08 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.
*/
#ifndef M_SRMM_INT_H__
#define M_SRMM_INT_H__ 1
#include <m_gui.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// toolbar button internal representation
#define MIN_CBUTTONID 4000
#define MAX_CBUTTONID 5000
#define BBSF_IMBUTTON (1<<0)
#define BBSF_CHATBUTTON (1<<1)
#define BBSF_CANBEHIDDEN (1<<2)
#define BBSF_NTBSWAPED (1<<3)
#define BBSF_NTBDESTRUCT (1<<4)
struct CustomButtonData : public MZeroedObject
{
~CustomButtonData()
{}
int m_dwPosition; // default order pos of button, counted from window edge (left or right)
int m_dwButtonID; // id of button used while button creation and to store button info in DB
ptrA m_pszModuleName; // module name without spaces and underline symbols (e.g. "tabsrmm")
int m_dwButtonCID; // button's control id
int m_dwArrowCID; // only use with BBBF_ISARROWBUTTON flag
ptrW m_pwszText; // button's text
ptrW m_pwszTooltip; // button's tooltip
int m_iButtonWidth; // must be 22 for regular button and 33 for button with arrow
HANDLE m_hIcon; // Handle to icolib registred icon
bool m_bIMButton, m_bChatButton;
bool m_bCanBeHidden, m_bCantBeHidden, m_bHidden, m_bSeparator, m_bDisabled, m_bPushButton;
bool m_bRSided;
uint8_t m_opFlags;
HPLUGIN m_pPlugin;
uint32_t m_dwOrigPosition;
struct THotkeyItem *m_hotkey;
struct {
bool bit1 : 1, bit2 : 1, bit3 : 1, bit4 : 1;
} m_dwOrigFlags;
};
// gets the required button or NULL, if i is out of boundaries
EXTERN_C MIR_APP_DLL(CustomButtonData*) Srmm_GetNthButton(int i);
// retrieves total number of toolbar buttons
EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonCount(void);
// emulates a click on a toolbar button
EXTERN_C MIR_APP_DLL(void) Srmm_ClickToolbarIcon(MCONTACT hContact, int idFrom, HWND hwndFrom, BOOL code);
// these messages are sent to the message windows if toolbar buttons are changed
#define WM_CBD_FIRST (WM_USER+0x600)
// wParam = 0 (ignored)
// lParam = (CustomButtonData*)pointer to button or null if any button can be changed
#define WM_CBD_UPDATED (WM_CBD_FIRST+1)
// wParam = button id
// lParam = (CustomButtonData*)pointer to button
#define WM_CBD_REMOVED (WM_CBD_FIRST+2)
// wParam = 0 (ignored)
// lParam = 0 (ignored)
#define WM_CBD_LOADICONS (WM_CBD_FIRST+3)
// wParam = 0 (ignored)
// lParam = 0 (ignored)
#define WM_CBD_RECREATE (WM_CBD_FIRST+4)
/////////////////////////////////////////////////////////////////////////////////////////
// SRMM log window container
class CMsgDialog;
class MIR_APP_EXPORT CSrmmLogWindow
{
CSrmmLogWindow(const CSrmmLogWindow &) = delete;
CSrmmLogWindow &operator=(const CSrmmLogWindow &) = delete;
protected:
CMsgDialog &m_pDlg;
CSrmmLogWindow(CMsgDialog &pDlg) :
m_pDlg(pDlg)
{}
public:
virtual ~CSrmmLogWindow() {}
virtual void Attach() = 0;
virtual void Detach() = 0;
virtual bool AtBottom() = 0;
virtual void Clear() = 0;
virtual int GetType() = 0;
virtual HWND GetHwnd() = 0;
virtual wchar_t* GetSelection() = 0;
virtual void LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) = 0;
virtual void LogEvents(struct LOGINFO *, bool) = 0;
virtual void Resize() = 0;
virtual void ScrollToBottom() = 0;
virtual void UpdateOptions() {};
virtual INT_PTR Notify(WPARAM, LPARAM) { return 0; }
};
typedef CSrmmLogWindow *(MIR_CDECL *pfnSrmmLogCreator)(CMsgDialog &pDlg);
EXTERN_C MIR_APP_DLL(HANDLE) RegisterSrmmLog(CMPlugin *pPlugin, const char *pszShortName, const wchar_t *pwszScreenName, pfnSrmmLogCreator fnBuilder);
EXTERN_C MIR_APP_DLL(void) UnregisterSrmmLog(HANDLE);
/////////////////////////////////////////////////////////////////////////////////////////
// Standard built-in RTF logger class
class MIR_APP_EXPORT CRtfLogWindow : public CSrmmLogWindow
{
protected:
CCtrlRichEdit &m_rtf;
public:
CRtfLogWindow(CMsgDialog &pDlg);
~CRtfLogWindow() override;
virtual INT_PTR WndProc(UINT msg, WPARAM wParam, LPARAM lParam);
////////////////////////////////////////////////////////////////////////////////////////
void Attach() override;
void Detach() override;
bool AtBottom() override;
void Clear() override;
HWND GetHwnd() override;
wchar_t* GetSelection() override;
int GetType() override;
void Resize() override;
void ScrollToBottom() override;
INT_PTR Notify(WPARAM, LPARAM) override;
};
/////////////////////////////////////////////////////////////////////////////////////////
// Basic SRMM window dialog
#include <chat_resource.h>
// 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);
class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase
{
friend class CRtfLogWindow;
CSrmmBaseDialog(const CSrmmBaseDialog &) = delete;
CSrmmBaseDialog &operator=(const CSrmmBaseDialog &) = delete;
protected:
CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, struct SESSION_INFO *si = nullptr);
bool OnInitDialog() override;
void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
bool AllowTyping() const;
int NotifyEvent(int code);
#ifdef _WINDOWS
bool ProcessFileDrop(HDROP hDrop, MCONTACT hContact);
bool PasteFilesAsURL(HDROP hDrop);
#endif
bool ProcessHotkeys(int key, bool bShift, bool bCtrl, bool bAlt);
void RefreshButtonStatus(void);
void RunUserMenu(HWND hwndOwner, struct USERINFO *ui, const POINT &pt);
protected:
CSrmmLogWindow *m_pLog = nullptr;
CCtrlRichEdit m_message;
SESSION_INFO *m_si;
COLORREF m_clrInputBG, m_clrInputFG;
// user typing support;
uint32_t m_nLastTyping = 0;
uint8_t m_bShowTyping = 0;
int m_nTypeSecs = 0, m_nTypeMode = 0;
const USERINFO* m_pUserTyping = nullptr;
CCtrlListBox m_nickList;
CCtrlButton m_btnColor, m_btnBkColor, m_btnOk;
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;
CTimer timerFlash, timerType;
void ClearLog();
void RedrawLog();
void ShowColorChooser(int iCtrlId);
virtual void AddLog();
virtual void CloseTab() {}
virtual bool IsActive() const PURE;
virtual void LoadSettings() PURE;
virtual void SetStatusText(const wchar_t *, HICON) {}
virtual void ShowFilterMenu() {}
virtual void UpdateNickList() {}
virtual void UpdateOptions();
virtual void UpdateStatusBar() {}
virtual void UpdateTitle() PURE;
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; }
__forceinline SESSION_INFO *getChat() const { return m_si; }
__forceinline CSrmmLogWindow *log() const { return m_pLog; }
__forceinline void setTyping(int nSecs, const USERINFO* pUser = nullptr) {
m_pUserTyping = pUser;
m_nTypeSecs = nSecs;
}
__inline void* operator new(size_t size) { return calloc(1, size); }
__inline void operator delete(void *p) { free(p); }
};
#ifndef SRMM_OWN_STRUCTURES
class CMsgDialog : public CSrmmBaseDialog {};
#endif
/////////////////////////////////////////////////////////////////////////////////////////
// receives LOGSTREAMDATA* as the first parameter
#ifdef _WINDOWS
EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, uint8_t *pbBuff, LONG cb, LONG *pcb);
#endif
/////////////////////////////////////////////////////////////////////////////////////////
// sends a message to all SRMM windows
EXTERN_C MIR_APP_DLL(void) Srmm_Broadcast(UINT, WPARAM, LPARAM);
/////////////////////////////////////////////////////////////////////////////////////////
// creates plugin-specific hot key for sending messages
EXTERN_C MIR_APP_DLL(void) Srmm_CreateHotkey(const char *pszSection, const char *pszDescription);
/////////////////////////////////////////////////////////////////////////////////////////
// finds a SRMM window using hContact
EXTERN_C MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact);
EXTERN_C MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact);
#endif // M_MESSAGE_H__
|