summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/userdetails.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Xfire/src/userdetails.cpp')
-rw-r--r--protocols/Xfire/src/userdetails.cpp263
1 files changed, 73 insertions, 190 deletions
diff --git a/protocols/Xfire/src/userdetails.cpp b/protocols/Xfire/src/userdetails.cpp
index 49e2cd2875..aa4de637c3 100644
--- a/protocols/Xfire/src/userdetails.cpp
+++ b/protocols/Xfire/src/userdetails.cpp
@@ -30,7 +30,6 @@
#include "baseProtocol.h"
#include "Xfire_gamelist.h"
-#include <string>
HWND ghwndDlg = NULL;
extern HANDLE XFireWorkingFolder;
@@ -38,20 +37,20 @@ extern Xfire_gamelist xgamelist;
//als funktion, damit es per thread geladen werden kann
-void LoadProfilStatus(void *arg) {
- char *fname = (char*) arg;
+void LoadProfilStatus(void *arg)
+{
+ char *fname = (char*)arg;
if (!fname || !ghwndDlg)
return;
//dl
char url[255];
- mir_snprintf(url, _countof(url),"http://miniprofile.xfire.com/bg/sh/type/1/%s.png",fname);
+ mir_snprintf(url, _countof(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))
- {
+ if (GetWWWContent2(url, NULL, FALSE, &buf, &size)) {
//aus dem buffer ein hicon erzeugen
HBITMAP hbitmap = xgamelist.createHBITMAPfromdata(buf, size);
//speicher freigeben
@@ -65,21 +64,18 @@ void SetItemTxt(HWND hwndDlg, int feldid, char*feld, MCONTACT hcontact, int type
{
DBVARIANT dbv;
if (!db_get(hcontact, protocolname, feld, &dbv)) {
- if (type == 1)
- {
+ if (type == 1) {
char temp[255];
mir_snprintf(temp, _countof(temp), "%i", dbv.wVal);
SetDlgItemTextA(hwndDlg, feldid, temp);
}
- else
- {
+ else {
SetDlgItemTextA(hwndDlg, feldid, dbv.pszVal);
}
db_free(&dbv);
EnableDlgItem(hwndDlg, feldid, TRUE);
}
- else
- {
+ else {
SetDlgItemText(hwndDlg, feldid, TranslateT("<not specified>"));
EnableDlgItem(hwndDlg, feldid, FALSE);
}
@@ -140,10 +136,8 @@ void setGameInfo(HWND listbox, char *mbuf)
memset(&lvitem, 0, sizeof(lvitem));
lvitem.mask = LVIF_TEXT;
- while (*mbuf2 != 0)
- {
- if (*mbuf2 == 1 && mod == 0)
- {
+ while (*mbuf2 != 0) {
+ if (*mbuf2 == 1 && mod == 0) {
temp[ii] = 0;
mod = 1;
lvitem.iItem = item;
@@ -153,8 +147,7 @@ void setGameInfo(HWND listbox, char *mbuf)
item++;
ii = -1;
}
- else if (*mbuf2 == 2 && mod == 1)
- {
+ else if (*mbuf2 == 2 && mod == 1) {
temp[ii] = 0;
mod = 0;
lvitem.iSubItem++;
@@ -179,61 +172,47 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam
static HWND listbox;
LVCOLUMNA pcol;
- switch (msg)
- {
+ 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);
-
+ {
+ 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_CTLCOLORSTATIC:
- {
- break;
- }
case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
-
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
-
+ switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
- {
char* szProto;
MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
uhandle = hContact; //handle sichern
@@ -249,15 +228,12 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam
//alle items aus der liste entfernen
SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0);
- if (hContact)
- {
+ if (hContact) {
DBVARIANT dbv;
- if (!db_get(hContact, protocolname, "Username", &dbv))
- {
+ if (!db_get(hContact, protocolname, "Username", &dbv)) {
int usernamesize = mir_strlen(dbv.pszVal) + 1;
char* username = new char[usernamesize];
- if (username)
- {
+ if (username) {
strcpy_s(username, usernamesize, dbv.pszVal);
mir_forkthread(LoadProfilStatus, (LPVOID)username);
}
@@ -265,8 +241,7 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam
db_free(&dbv);
}
- if (!db_get(hContact, protocolname, "GameInfo", &dbv))
- {
+ if (!db_get(hContact, protocolname, "GameInfo", &dbv)) {
setGameInfo(listbox, dbv.pszVal);
db_free(&dbv);
}
@@ -288,135 +263,43 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam
SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0);
//render icons
- {
- DBVARIANT dbv;
-
- 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);
- }
+ 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);
+ }
- //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
+ 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;
- }
- }
- break;
}
- }
break;
+
case WM_COMMAND:
- {
- switch (wParam)
{
- case IDC_COPYGAME:
- GetIPPortUDetails(uhandle, "ServerIP", "Port");
- break;
- case IDC_COPYVOICE:
- GetIPPortUDetails(uhandle, "VServerIP", "VPort");
- break;
+ switch (wParam) {
+ case IDC_COPYGAME:
+ GetIPPortUDetails(uhandle, "ServerIP", "Port");
+ break;
+ case IDC_COPYVOICE:
+ GetIPPortUDetails(uhandle, "VServerIP", "VPort");
+ break;
+ }
}
}
- }
return FALSE;
}
-/*static BOOL CALLBACK DlgProcUserDetails2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-char profil[2056]="";
-switch (msg)
-{
-case WM_INITDIALOG:
-{
-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;
-
-if (hContact == NULL)
-szProto = protocolname;
-else
-szProto = GetContactProto(hContact);
-
-if (szProto == NULL)
-break;
-
-if (hContact) {
-DBVARIANT dbv;
-
-char img[256]="";
-char username[256]="";
-char nick[256]="";
-char status[256]="";
-char game[512]="";
-if (!db_get(hContact,"ContactPhoto","File",&dbv))
-{
-mir_snprintf(img,_countof(img),"<img src=\"%s\">",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"Username",&dbv))
-{
-mir_snprintf(username,_countof(username),"<b>Username:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"Nick",&dbv))
-{
-mir_snprintf(nick,_countof(nick),"<b>Nick:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"XStatusMsg",&dbv))
-{
-mir_snprintf(status,_countof(status),"<b>Status:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"RGame",&dbv))
-{
-mir_snprintf(game,_countof(game),"<fieldset style='border:1px solid #0091d5;background-color:#0d2c3e;margin-bottom:8px;'><legend>Spiel</legend><table><tr><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'><b><u>%s</u></b></td></tr></table></fieldset>",dbv.pszVal);
-db_free(&dbv);
-}
-mir_snprintf(profil,_countof(profil),"mshtml:<div style='position:absolute;top:0;left:0;border:1px solid #0091d5;background-color:#000;padding:6px;width:334px;height:249px'><table><tr><td valign=top>%s</td><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'>%s%s%s</td></tr><tr><td valign=top colspan=\"2\" style='font-family:Arial;font-size:11px;color:#fff;'>%s%s</td></tr></table></div>",img,username,nick,status,game);
-HWND hWnd = ::CreateWindow("AtlAxWin", profil,
-WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL,
-::GetModuleHandle(NULL), NULL);
-}
-}
-}
-}
-}
-}
-}
-return FALSE;
-}*/
-
int OnDetailsInit(WPARAM wParam, LPARAM lParam)
{
if (!IsXFireContact(lParam))