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
|
#include "headers.h"
void copyModule(char* module, MCONTACT hContactFrom, MCONTACT hContactTo)
{
ModuleSettingLL msll;
EnumSettings(hContactFrom, module, &msll);
ModSetLinkLinkItem *setting = msll.first;
while (setting) {
DBVARIANT dbv;
if (!GetSetting(hContactFrom, module, setting->name, &dbv)) {
switch (dbv.type) {
case DBVT_BYTE:
db_set_b(hContactTo, module, setting->name, dbv.bVal);
break;
case DBVT_WORD:
db_set_w(hContactTo, module, setting->name, dbv.wVal);
break;
case DBVT_DWORD:
db_set_dw(hContactTo, module, setting->name, dbv.dVal);
break;
case DBVT_ASCIIZ:
db_set_s(hContactTo, module, setting->name, dbv.pszVal);
break;
case DBVT_UTF8:
db_set_utf(hContactTo, module, setting->name, dbv.pszVal);
break;
case DBVT_BLOB:
db_set_blob(hContactTo, module, setting->name, dbv.pbVal, dbv.cpbVal);
break;
}
}
db_free(&dbv);
setting = setting->next;
}
FreeModuleSettingLL(&msll);
}
INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
if (msg == WM_INITDIALOG)
{
int index, loaded;
char szProto[256];
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
loaded = IsProtocolLoaded(szProto);
else
loaded = 0;
// filter
if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED))
continue;
// contacts name
DBVARIANT dbv ={0};
WCHAR nick[256];
WCHAR protoW[256]; // unicode proto
if (szProto[0])
a2u(szProto, protoW, SIZEOF(protoW));
else
protoW[0] = 0;
if (!szProto[0] || !loaded) {
if (protoW) {
if (Order)
mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)");
else
mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
}
else wcscpy(nick, nick_unknownW);
}
else {
if (Order)
mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1));
else
mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW);
}
index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick);
SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact);
}
index = (int)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_INSERTSTRING, 0, (LPARAM)(char*)Translate("Settings"));
SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, 0);
SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETCURSEL, index, 0);
SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam);
TranslateDialogDefault(hwnd);
}
else if (msg == WM_COMMAND)
{
switch(LOWORD(wParam)) {
case CHK_COPY2ALL:
EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL));
break;
case IDOK:
if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) {
MCONTACT hContact = (MCONTACT)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0);
copyModule(mac->module, mac->hContact, hContact);
}
else {
SetCursor(LoadCursor(NULL,IDC_WAIT));
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
copyModule(mac->module, mac->hContact, hContact);
SetCursor(LoadCursor(NULL,IDC_ARROW));
}
mir_free(mac);
refreshTree(1);
DestroyWindow(hwnd);
break;
case IDCANCEL:
mir_free(mac);
DestroyWindow(hwnd);
break;
}
}
return 0;
}
void copyModuleMenuItem(char* module, MCONTACT hContact)
{
ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact));
mac->hContact = hContact;
strncpy(mac->module, module, 255);
CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac);
}
|