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
|
#include "headers.h"
tstring DBGetContactSettingStringPAN(HANDLE hContact, char const * szModule, char const * szSetting, tstring errorValue)
{
DBVARIANT dbv;
//if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
if(DBGetContactSettingTString(hContact, szModule, szSetting, &dbv))
return errorValue;
// if(DBVT_TCHAR == dbv.type )
errorValue = dbv.ptszVal;
DBFreeVariant(&dbv);
return errorValue;
}
std::string DBGetContactSettingStringPAN_A(HANDLE hContact, char const * szModule, char const * szSetting, std::string errorValue)
{
DBVARIANT dbv;
//if(DBGetContactSetting(hContact, szModule, szSetting, &dbv))
if(DBGetContactSettingString(hContact, szModule, szSetting, &dbv))
return errorValue;
// if(DBVT_ASCIIZ == dbv.type )
errorValue = dbv.pszVal;
DBFreeVariant(&dbv);
return errorValue;
}
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;
}
std::string &GetProtoList()
{
static std::string s;
return s = DBGetContactSettingStringPAN_A(NULL, pluginName, "protoList", "ICQ\r\n");
}
bool ProtoInList(std::string proto)
{
return std::string::npos != GetProtoList().find(proto + "\r\n");
}
int CreateCListGroup(TCHAR* szGroupName)
{
int hGroup;
CLIST_INTERFACE *clint = NULL;
if (ServiceExists(MS_CLIST_RETRIEVE_INTERFACE))
clint = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, 0);
hGroup = CallService(MS_CLIST_GROUPCREATE, 0, 0);
TCHAR* usTmp = szGroupName;
clint->pfnRenameGroup(hGroup, usTmp);
return hGroup;
}
void RemoveExcludedUsers()
{
HANDLE hContact;
HANDLE ToRemove[4096];
int i = 0;
int a = 0;
hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
if(hContact)
{
do
{
if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
{
ToRemove[i] = hContact;
i++;
}
}
while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0));
ToRemove[i] = INVALID_HANDLE_VALUE;
while(ToRemove[a] != INVALID_HANDLE_VALUE)
{
CallService(MS_DB_CONTACT_DELETE, (WPARAM)ToRemove[a], 0);
a++;
}
}
}
|