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
|
/*
Miranda NG SmileyAdd Plugin
Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org)
Copyright (C) 2005-11 Boris Krasnovskiy All Rights Reserved
Copyright (C) 2003-04 Rein-Peter de Boer
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 version 2
of the License.
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SMILEYADD_SMILEYS_H_
#define SMILEYADD_SMILEYS_H_
#define MS_SMILEYADD_CUSTOMCATMENU "SmileyAdd/CustomCatMenu"
const unsigned HiddenSmiley = 1;
const unsigned RegExSmiley = 2;
const unsigned ServiceSmiley = 4;
const unsigned TextSmiley = 8;
const unsigned SoundSmiley = 16;
class SmileyType
{
LIST<ISmileyBase> m_arSmileys;
protected:
unsigned m_flags;
int m_index;
SIZE m_size;
HICON m_SmileyIcon;
ImageBase *m_xepimg;
CMStringW m_filepath;
void SetFlagsBit(unsigned flag, bool set)
{
if (set) m_flags |= flag; else m_flags &= ~flag;
}
public:
CMStringW m_TriggerText;
CMStringW m_ToolText;
CMStringW m_InsertText;
SmileyType();
~SmileyType();
const CMStringW& GetTriggerText(void) const { return m_TriggerText; }
const CMStringW& GetToolText(void) const { return m_ToolText; }
const CMStringW& GetInsertText(void) const { return m_InsertText; }
const CMStringW& GetFilePath(void) const { return m_filepath; }
bool IsHidden(void) const { return (m_flags & HiddenSmiley) != 0; }
bool IsRegEx(void) const { return (m_flags & RegExSmiley) != 0; }
bool IsService(void) const { return (m_flags & ServiceSmiley) != 0; }
bool IsSound(void) const { return (m_flags & SoundSmiley) != 0; }
bool IsText(void) const { return (m_flags & TextSmiley) != 0; }
bool IsFileFound(void) { return _waccess(m_filepath.c_str(), 0) == 0; }
bool IsValid(void) { return m_size.cx != 0; }
ImageBase* CreateCachedImage(void);
void GetSize(SIZE &size);
HICON GetIcon(void);
HICON GetIconDup(void);
HBITMAP GetBitmap(COLORREF bkgClr, int sizeX, int sizeY);
void SetFrameDelay(void);
void MoveToNextFrame(void);
void AddObject(ISmileyBase *pObject);
void RemoveObject(ISmileyBase *pObject);
void SetHidden(bool hid) { SetFlagsBit(HiddenSmiley, hid); }
void SetRegEx(bool regex) { SetFlagsBit(RegExSmiley, regex); }
void SetService(bool service) { SetFlagsBit(ServiceSmiley, service); }
void SetSound(bool sound) { SetFlagsBit(SoundSmiley, sound); }
void SetText(bool text) { SetFlagsBit(TextSmiley, text); }
void SetImList(HIMAGELIST hImLst, long i);
bool LoadFromResource(const CMStringW &file, const int index);
bool LoadFromImage(IStream *pStream);
};
template<class T> struct SMOBJLIST : public OBJLIST<T>
{
SMOBJLIST() : OBJLIST<T>(5) {};
SMOBJLIST<T>& operator=(const SMOBJLIST<T>& lst)
{
OBJLIST<T>::destroy();
return operator+=(lst);
}
SMOBJLIST<T>& operator+=(const SMOBJLIST<T>& lst)
{
for (auto &it : lst)
insert(new T(*it));
return *this;
}
void splice(SMOBJLIST<T> &lst)
{
for (auto &it : lst)
insert(it);
lst.LIST<T>::destroy();
}
};
class SmileyLookup
{
MRegexp16 m_pattern;
int m_ind;
CMStringW m_text;
bool m_valid;
public:
struct SmileyLocType
{
size_t pos, len;
SmileyLocType(size_t p, size_t l) : pos(p), len(l) {}
};
typedef SMOBJLIST<SmileyLocType> SmileyLocVecType;
SmileyLookup() : m_pattern(L"") { m_ind = 0; m_valid = false; m_pattern = nullptr; };
SmileyLookup(const CMStringW &str, const bool regexs, const int ind, const CMStringW &smpt);
~SmileyLookup();
void Find(const CMStringW &str, SmileyLocVecType &smlcur, bool firstOnly);
int GetIndex(void) const { return m_ind; }
bool IsValid(void) const { return m_valid; }
};
class SmileyPackType
{
CMStringW m_Filename; //used as identification
CMStringW m_Name;
CMStringW m_Author;
CMStringW m_Date;
CMStringW m_Version;
CMStringW m_ButtonSmiley;
HIMAGELIST m_hSmList;
int m_VisibleCount;
typedef SMOBJLIST<SmileyType> SmileyVectorType;
SmileyVectorType m_SmileyList;
typedef SMOBJLIST<SmileyLookup> SmileyLookupType;
SmileyLookupType m_SmileyLookup;
bool errorFound;
void AddTriggersToSmileyLookup(void);
void ReplaceAllSpecials(const CMStringW &Input, CMStringW &Output);
public:
SmileyPackType();
~SmileyPackType();
POINT selec, win;
SmileyVectorType& GetSmileyList(void) { return m_SmileyList; }
SmileyLookupType* GetSmileyLookup(void) { return &m_SmileyLookup; }
const CMStringW& GetFilename(void) const { return m_Filename; }
const CMStringW& GetName(void) const { return m_Name; }
const CMStringW& GetAuthor(void) const { return m_Author; }
const CMStringW& GetDate(void) const { return m_Date; }
const CMStringW& GetVersion(void) const { return m_Version; }
int SmileyCount(void) const { return m_SmileyList.getCount(); }
int VisibleSmileyCount(void) const { return m_VisibleCount; }
SmileyType* GetSmiley(unsigned index);
const wchar_t* GetButtonSmiley(void) const { return m_ButtonSmiley.c_str(); }
bool LoadSmileyFile(const CMStringW &filename, const CMStringW &packname, bool onlyInfo, bool noerr = false);
bool LoadSmileyFileMSL(const CMStringW &filename, bool bOnlyInfo, CMStringW &modPath);
bool LoadSmileyFileXEP(const CMStringW &filename, bool bOnlyInfo);
void Clear(void);
};
class SmileyPackListType
{
typedef SMOBJLIST<SmileyPackType> SmileyPackVectorType;
SmileyPackVectorType m_SmileyPacks;
public:
int NumberOfSmileyPacks(void) { return m_SmileyPacks.getCount(); }
bool AddSmileyPack(CMStringW &filename, CMStringW &packname);
void ClearAndFreeAll(void);
SmileyPackType* GetSmileyPack(CMStringW &filename);
};
typedef enum
{
smcNone,
smcStd,
smcProto,
smcVirtualProto,
smcTransportProto,
smcPhysProto,
smcCustom,
smcExt
} SmcType;
class SmileyCategoryType
{
CMStringW m_Name;
CMStringW m_DisplayName;
CMStringW m_Filename; //functions as identification
SmcType type;
SmileyPackListType* m_pSmileyPackStore;
bool visible;
public:
SmileyCategoryType() { type = smcNone; m_pSmileyPackStore = nullptr; visible = true; };
SmileyCategoryType(SmileyPackListType *pSPS, const CMStringW &name, const CMStringW &displayName, const CMStringW &defaultFilename, SmcType typ);
const CMStringW& GetDisplayName(void) const { return m_DisplayName; }
const CMStringW& GetName(void) const { return m_Name; }
const CMStringW& GetFilename(void) const { return m_Filename; }
bool IsCustom(void) { return type == smcCustom; }
bool IsProto(void) { return type == smcProto || type == smcPhysProto || type == smcTransportProto || type == smcVirtualProto; }
bool IsAcc(void) { return type == smcProto; }
bool IsVirtual(void) { return type == smcVirtualProto; }
bool IsPhysProto(void) { return type == smcPhysProto; }
bool IsTransportProto(void) { return type == smcTransportProto; }
bool IsExt(void) { return type == smcExt; }
bool IsVisible(void) { return visible; }
SmcType GetType(void) { return type; }
SmileyPackType* GetSmileyPack(void);
void SetFilename(const CMStringW& name) { m_Filename = name; }
void SetDisplayName(const CMStringW& name) { m_DisplayName = name; }
void SetVisible(bool vis) { visible = vis; }
void ClearFilename(void) { m_Filename.Empty(); }
void SaveSettings(void);
void Load(void);
};
class SmileyCategoryListType
{
typedef SMOBJLIST<SmileyCategoryType> SmileyCategoryVectorType;
SmileyCategoryVectorType m_SmileyCategories;
SmileyPackListType *m_pSmileyPackStore;
public:
void SetSmileyPackStore(SmileyPackListType *pSPS) { m_pSmileyPackStore = pSPS; }
SmileyCategoryType* GetSmileyCategory(const CMStringW &name);
SmileyCategoryType* GetSmileyCategory(unsigned index);
SmileyPackType* GetSmileyPack(const CMStringW &name);
SmileyCategoryVectorType* GetSmileyCategoryList(void) { return &m_SmileyCategories; };
int NumberOfSmileyCategories(void) { return m_SmileyCategories.getCount(); }
void AddCategory(const CMStringW &name, const CMStringW &displayName, SmcType typ, const CMStringW &defaultFilename = L"");
void AddAndLoad(const CMStringW &name, const CMStringW &displayName);
void AddAllProtocolsAsCategory(void);
void AddAccountAsCategory(PROTOACCOUNT *acc, const CMStringW &defaultFile);
void AddProtoAsCategory(char *acc, const CMStringW &defaultFile);
void AddContactTransportAsCategory(MCONTACT hContact, const CMStringW &defaultFile);
void ClearAndLoadAll(void);
void ClearAll(void)
{
m_pSmileyPackStore->ClearAndFreeAll(); m_SmileyCategories.destroy();
}
bool DeleteCustomCategory(int index);
void DeleteAccountAsCategory(PROTOACCOUNT *acc);
void SaveSettings(void);
};
extern SmileyPackListType g_SmileyPacks;
extern SmileyCategoryListType g_SmileyCategories;
#endif //SMILEYADD_SMILEYS_H_
|