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
|
#include "headers.h"
tstring &GetDlgItemString(HWND hwnd, int id)
{
HWND h = GetDlgItem(hwnd, id);
int len = GetWindowTextLength(h);
TCHAR * buf = new TCHAR[len + 1];
GetWindowText(h, buf, len + 1);
static tstring s;
s = buf;
delete []buf;
return s;
}
bool IsExistMyMessage(HANDLE hContact)
{
DBEVENTINFO dbei = { 0 };
HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
while(hDbEvent){
ZeroMemory(&dbei, sizeof(dbei));
dbei.cbSize = sizeof(dbei);
if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) break;
if(dbei.flags & DBEF_SENT){
// mark contact as Answered
DBWriteContactSettingByte(hContact, pluginName, answeredSetting, 1);
// ...let the event go its way
return true;
}
hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
}
return false;
}
void SetDlgItemString(HWND hwndDlg, UINT idItem, std::string const &str)
{
SetDlgItemTextA(hwndDlg, idItem, str.c_str());
}
void SetDlgItemString(HWND hwndDlg, UINT idItem, std::wstring const &str)
{
SetDlgItemTextW(hwndDlg, idItem, str.c_str());
}
tstring variables_parse(tstring const &tstrFormat, HANDLE hContact){
if (ServiceExists(MS_VARS_FORMATSTRING)) {
FORMATINFO fi;
tstring tstrResult;
ZeroMemory(&fi, sizeof(fi));
fi.cbSize = sizeof(fi);
fi.tszFormat = _tcsdup(tstrFormat.c_str());
fi.hContact = hContact;
fi.flags |= FIF_TCHAR;
TCHAR *tszParsed = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
free(fi.tszFormat);
if (tszParsed) {
tstrResult = tszParsed;
mir_free(tszParsed);
return tstrResult;
}
}
return tstrFormat;
}
tstring trim(const tstring &tstr, const tstring& trimChars)
{
size_t s = tstr.find_first_not_of(trimChars);
size_t e = tstr.find_last_not_of (trimChars);
if ((tstring::npos == s) || ( tstring::npos == e))
return _T("");
else
return tstr.substr(s, e - s + 1);
}
|