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
316
|
/*
* Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Based on J. Lawler - BaseProtocol
* Herbert Poul/Beat Wolf - xfirelib
*
* Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
#include "stdafx.h"
#include "baseProtocol.h"
#include "Xfire_gamelist.h"
HWND ghwndDlg = NULL;
extern HANDLE XFireWorkingFolder;
extern Xfire_gamelist xgamelist;
//als funktion, damit es per thread geladen werden kann
void LoadProfilStatus(void *arg)
{
char *fname = (char*)arg;
if (!fname || !ghwndDlg)
return;
//dl
char url[255];
mir_snprintf(url, "http://miniprofile.xfire.com/bg/sh/type/1/%s.png", fname);
char* buf = NULL;
unsigned int size = 0;
//versuche das icon aus dem inet zulasen
if (GetWWWContent2(url, NULL, FALSE, &buf, &size)) {
//aus dem buffer ein hicon erzeugen
HBITMAP hbitmap = xgamelist.createHBITMAPfromdata(buf, size);
//speicher freigeben
delete[] buf;
SendDlgItemMessage(ghwndDlg, IDC_PROFILIMG, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbitmap);
}
delete[] fname;
}
void SetItemTxt(HWND hwndDlg, int feldid, char*feld, MCONTACT hcontact, int type)
{
DBVARIANT dbv;
if (!db_get(hcontact, protocolname, feld, &dbv)) {
if (type == 1) {
char temp[255];
mir_snprintf(temp, "%i", dbv.wVal);
SetDlgItemTextA(hwndDlg, feldid, temp);
}
else {
SetDlgItemTextA(hwndDlg, feldid, dbv.pszVal);
}
db_free(&dbv);
EnableDlgItem(hwndDlg, feldid, TRUE);
}
else {
SetDlgItemText(hwndDlg, feldid, TranslateT("<not specified>"));
EnableDlgItem(hwndDlg, feldid, FALSE);
}
}
static int GetIPPortUDetails(MCONTACT hContact, char* feld1, char* feld2)
{
if (db_get_w(hContact, protocolname, feld2, -1) == 0)
return 0;
DBVARIANT dbv;
if (db_get_s(hContact, protocolname, feld1, &dbv))
return 0;
char temp[255];
mir_snprintf(temp, "%s:%d", dbv.pszVal, db_get_w(hContact, protocolname, feld2, -1));
db_free(&dbv);
if (OpenClipboard(NULL)) {
EmptyClipboard();
HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, mir_strlen(temp) + 1);
char *buffer = (char*)GlobalLock(clipbuffer);
mir_strcpy(buffer, LPCSTR(temp));
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT, clipbuffer);
CloseClipboard();
}
return 0;
}
void addToList(HWND listbox, MCONTACT hContact, char*key, char*val)
{
DBVARIANT dbv;
if (!db_get_s(hContact, protocolname, val, &dbv)) {
LVITEMA lvitem = { 0 };
lvitem.mask = LVIF_TEXT;
lvitem.pszText = key;
SendMessageA(listbox, LVM_INSERTITEM, 0, (LPARAM)&lvitem);
lvitem.iSubItem++;
lvitem.pszText = dbv.pszVal;
SendMessageA(listbox, LVM_SETITEM, 0, (LPARAM)&lvitem);
db_free(&dbv);
}
}
void setGameInfo(HWND listbox, char *mbuf)
{
int ii = 0;
char temp[255];
char mod = 0;
char item = 0;
char *mbuf2 = (char*)mbuf;
LVITEMA lvitem;
memset(&lvitem, 0, sizeof(lvitem));
lvitem.mask = LVIF_TEXT;
while (*mbuf2 != 0) {
if (*mbuf2 == 1 && mod == 0) {
temp[ii] = 0;
mod = 1;
lvitem.iItem = item;
lvitem.iSubItem = 0;
lvitem.pszText = temp;
SendMessageA(listbox, LVM_INSERTITEM, 0, (LPARAM)&lvitem);
item++;
ii = -1;
}
else if (*mbuf2 == 2 && mod == 1) {
temp[ii] = 0;
mod = 0;
lvitem.iSubItem++;
lvitem.pszText = temp;
SendMessageA(listbox, LVM_SETITEM, 0, (LPARAM)&lvitem);
ii = -1;
}
else
temp[ii] = *mbuf2;
mbuf2++;
ii++;
}
}
static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static char path[XFIRE_MAX_STATIC_STRING_LEN] = "";
static WCHAR wpath[256];
static HICON gameicon = 0;
static HICON voiceicon = 0;
static MCONTACT uhandle = 0;
static HWND listbox;
LVCOLUMNA pcol;
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
ghwndDlg = hwndDlg;
listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST);
pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
pcol.pszText = "Key";
pcol.cx = 65;
pcol.fmt = LVCFMT_LEFT;
SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol);
pcol.cx = 80;
pcol.pszText = "Value";
SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol);
HFONT hFont;
LOGFONT lfFont;
memset(&lfFont, 0x00, sizeof(lfFont));
memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
lfFont.lfHeight = 13;
lfFont.lfWeight = FW_BOLD;
lfFont.lfCharSet = ANSI_CHARSET;
lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lfFont.lfQuality = DEFAULT_QUALITY;
// Create the font from the LOGFONT structure passed.
hFont = CreateFontIndirect(&lfFont);
SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE);
}
return TRUE;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
char* szProto;
MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
uhandle = hContact; //handle sichern
if (hContact == NULL)
szProto = protocolname;
else
szProto = GetContactProto(hContact);
if (szProto == NULL)
break;
//alle items aus der liste entfernen
SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0);
if (hContact) {
DBVARIANT dbv;
if (!db_get(hContact, protocolname, "Username", &dbv)) {
int usernamesize = mir_strlen(dbv.pszVal) + 1;
char* username = new char[usernamesize];
if (username) {
strcpy_s(username, usernamesize, dbv.pszVal);
mir_forkthread(LoadProfilStatus, (LPVOID)username);
}
//LoadProfilStatus
db_free(&dbv);
}
if (!db_get(hContact, protocolname, "GameInfo", &dbv)) {
setGameInfo(listbox, dbv.pszVal);
db_free(&dbv);
}
addToList(listbox, hContact, "Servername", "ServerName");
addToList(listbox, hContact, "GameType", "GameType");
addToList(listbox, hContact, "Map", "Map");
addToList(listbox, hContact, "Players", "Players");
SetItemTxt(hwndDlg, IDC_DNICK, "Nick", hContact, 0);
SetItemTxt(hwndDlg, IDC_DUSERNAME, "Username", hContact, 0);
SetItemTxt(hwndDlg, IDC_GIP, "ServerIP", hContact, 0);
SetItemTxt(hwndDlg, IDC_VIP, "VServerIP", hContact, 0);
SetItemTxt(hwndDlg, IDC_GPORT, "Port", hContact, 1);
SetItemTxt(hwndDlg, IDC_VPORT, "VPort", hContact, 1);
SetItemTxt(hwndDlg, IDC_GAME, "RGame", hContact, 0);
SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0);
//render icons
if (!db_get(hContact, protocolname, "GameId", &dbv)) {
SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
db_free(&dbv);
}
if (!db_get(hContact, protocolname, "VoiceId", &dbv)) {
SendDlgItemMessage(hwndDlg, IDC_VOICEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
db_free(&dbv);
}
if (db_get(hContact, protocolname, "ServerIP", &dbv)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE);
db_free(&dbv);
}
if (db_get(hContact, protocolname, "VServerIP", &dbv)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE);
db_free(&dbv);
}
}
}
}
break;
case WM_COMMAND:
{
switch (wParam) {
case IDC_COPYGAME:
GetIPPortUDetails(uhandle, "ServerIP", "Port");
break;
case IDC_COPYVOICE:
GetIPPortUDetails(uhandle, "VServerIP", "VPort");
break;
}
}
}
return FALSE;
}
int OnDetailsInit(WPARAM wParam, LPARAM lParam)
{
if (!IsXFireContact(lParam))
return 0;
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hinstance;
odp.pfnDlgProc = DlgProcUserDetails;
odp.position = -1900000000;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_UD);
odp.pszTitle = LPGEN("XFire");
UserInfo_AddPage(wParam, &odp);
return 0;
}
|