/* * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network. * * Copyright (C) 2010 by * dufte * * 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 "m_variables.h" #include "recvprefspacket.h" #include "Xfire_gamelist.h" #include "addgamedialog.h" extern HANDLE XFireWorkingFolder; extern HANDLE XFireIconFolder; extern xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; extern Xfire_gamelist xgamelist; struct mytreeitem { char name[256]; char dbentry[256]; int parent; int icon; HTREEITEM hitem; }; extern int bpStatus; BOOL alreadyInit=FALSE; HWND ghwndDlg2; HWND addgameDialog=NULL; xfireconfigitem xfireconfigitems[XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS] = { {IDC_KONFIG_1,1,"sendgamestatus"}, {IDC_KONFIG_2,3,"hideprofile"}, {IDC_KONFIG_3,2,"ipportdetec"}, {IDC_KONFIG_4,0xa,"shownicks"}, {IDC_KONFIG_5,0xb,"ts2detection"}, {IDC_KONFIG_6,0xc,"sendtyping"}, {IDC_KONFIG_7,8,"friendsoffriends"}, }; #define NUM_ICONS 4 static mytreeitem mytree[] = { {"Avatars","",1,0}, {"Disable avatars","noavatars",0,0}, {"Dont download avatars of clan members","noclanavatars",0,0}, {"Use alternate way for Avatar download","specialavatarload",0,0}, {"General","",1,0}, {"Use UTF8 for messaging and nick's (beta)","useutf8",0,0}, {"Automatically reconnect on protocol version changes","recprotoverchg",0,0}, {"No Ip/Port in StatusMsg","noipportinstatus",0,0}, {"Use Online status for unsupported global statuses","oninsteadafk",0,0}, {"Dont move friends to clan groups","skipfriendsgroups",0,0}, {"GameServerQuery support","gsqsupport",0,0}, {"No custom away message","nocustomaway",0,0}, {"Remove friend of friend buddies from database","fofdbremove",0,0}, /*{"Show usernames only","onlyusername",0},*/ {"Hide yourself in buddylist","skipmyself",0,0}, {"Dont display game search results","dontdisresults",0,0}, {"Dont display game search status window","dontdissstatus",0,0}, {"Display popup, if someone start a game","gamepopup",0,0}, {"Dont automatically create clan groups","noclangroups",0,0}, {"Enable MBot support","mbotsupport",0,0}, {"Gamedetection","",1,0}, /*{"Scan for games on every Miranda start","scanalways",0},*/ {"Disable game detection","nogamedetect",0,0}, /*{"Enable server IP/Port detection","ipportdetec",0},*/ /*{"Enable TeamSpeak2/Ventrilo detection","",0},*/ {"Use TSRemote.dll to get teamspeak server info","ts2useremote",0,0}, {"Disable popups when ingame","nopopups",0,0}, {"Disable sound events when ingame","nosoundev",0,0}, {"Files","",1,0}, {"Automatically update xfire_games.ini (pro-laming.de)","autoiniupdate",0,0}, {"Automatically update icons.dll (pro-laming.de)","autoicodllupdate",0,0}, {"Download missing game icons from Xfire website","xfiresitegameico",0,0}, {"No backup on update","nobackupini",0,0}, {"Background updating","dontaskforupdate",0,0}, }; //funktion zum auslesen aller einträge unter XFireBlock static int enumSettingsProc(const char *szSetting,LPARAM lParam) { if(strlen(szSetting)>0) { SendDlgItemMessage( (HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting); } EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE); return 0; } //damit die änderungen sofort sichtbar sind static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { char inipath[XFIRE_MAX_STATIC_STRING_LEN]=""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; static int nomsgboxsel[] = {1,0,2}; static HWND hwndTree = NULL; static char login[128]; switch (msg) { case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_INITDIALOG: { DBVARIANT dbv; TranslateDialogDefault(hwndDlg); ghwndDlg2=hwndDlg; hwndTree = GetDlgItem(hwndDlg, IDC_TREE); SetWindowLong(hwndTree,GWL_STYLE,GetWindowLong(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" ); strcat(inipath,"\\"); strcat(inipath,"xfire_games.ini"); FILE * f = fopen(inipath,"r"); if(f!=NULL) { fclose(f); CheckDlgButton(hwndDlg,IDC_CHKG,1); inifound = TRUE; } else { EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); inifound = FALSE; } FoldersGetCustomPath( XFireIconFolder, inipath, 1024, "" ); strcat(inipath,"\\"); strcat(inipath,"icons.dll"); f = fopen(inipath,"r"); if(f!=NULL) { fclose(f); CheckDlgButton(hwndDlg,IDC_CHKI,1); dllfound = TRUE; } else dllfound = FALSE; if(!DBGetContactSetting(NULL,protocolname,"login",&dbv)) { SetDlgItemText(hwndDlg,IDC_LOGIN,dbv.pszVal); DBFreeVariant(&dbv); } if(!DBGetContactSetting(NULL,protocolname,"Nick",&dbv)) { SetDlgItemText(hwndDlg,IDC_NICK,dbv.pszVal); DBFreeVariant(&dbv); } if(!DBGetContactSetting(NULL,protocolname,"password",&dbv)) { //bit of a security hole here, since it's easy to extract a password from an edit box CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,(LPARAM)dbv.pszVal); SetDlgItemText(hwndDlg,IDC_PASSWORD,dbv.pszVal); DBFreeVariant(&dbv); } char temp[255]=""; sprintf(temp,"%d",DBGetContactSettingByte(NULL,protocolname,"protover",0x5b)); SetDlgItemText(hwndDlg,IDC_PVER,temp); EnableWindow(GetDlgItem(hwndDlg,IDC_LASTGAME),FALSE); if(!DBGetContactSetting(NULL,protocolname,"LastGame",&dbv)) { SetDlgItemText(hwndDlg,IDC_LASTGAME,dbv.pszVal); DBFreeVariant(&dbv); } if(bpStatus==ID_STATUS_OFFLINE&&bpStatus!=ID_STATUS_CONNECTING) { EnableDlgItem(hwndDlg, IDC_NICK, FALSE); } else { int size=sizeof(xfireconfigitems)/sizeof(xfireconfigitem); for(int i=0;icode) { case PSN_APPLY: { int reconnectRequired=0; char str[128]; DBVARIANT dbv; GetDlgItemText(hwndDlg,IDC_LOGIN,login,sizeof(login)); dbv.pszVal=NULL; if(DBGetContactSetting(NULL,protocolname,"login",&dbv) || strcmp(login,dbv.pszVal)) reconnectRequired=1; if(dbv.pszVal!=NULL) DBFreeVariant(&dbv); //den login lowercasen int size=strlen(login); BOOL mustlowercase=FALSE; for(int i=0;i='A'&&login[i]<='Z') mustlowercase=TRUE; login[i]=tolower(login[i]); } if(mustlowercase) { MessageBoxA(NULL,Translate("The username must be lowercase, so it will be lowercased saved."),Translate("XFire Options"),MB_OK|MB_ICONINFORMATION); SetDlgItemText(hwndDlg,IDC_LOGIN,login); } DBWriteContactSettingString(NULL,protocolname,"login",login); DBWriteContactSettingString(NULL,protocolname,"Username",login); //nur wenn der nick erfolgreich übertragen wurde GetDlgItemText(hwndDlg,IDC_NICK,login,sizeof(login)); dbv.pszVal=NULL; if(DBGetContactSetting(NULL,protocolname,"Nick",&dbv) || strcmp(login,dbv.pszVal)) { if(CallService(XFIRE_SET_NICK,0,(WPARAM)login)) DBWriteContactSettingString(NULL,protocolname,"Nick",login); } if(dbv.pszVal!=NULL) DBFreeVariant(&dbv); GetDlgItemText(hwndDlg,IDC_PASSWORD,str,sizeof(str)); CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),(LPARAM)str); dbv.pszVal=NULL; if(DBGetContactSetting(NULL,protocolname,"password",&dbv) || strcmp(str,dbv.pszVal)) reconnectRequired=1; if(dbv.pszVal!=NULL) DBFreeVariant(&dbv); DBWriteContactSettingString(NULL,protocolname,"password",str); GetDlgItemText(hwndDlg,IDC_SERVER,str,sizeof(str)); //neue preferencen sichern if(bpStatus!=ID_STATUS_OFFLINE&&bpStatus!=ID_STATUS_CONNECTING) { int size=sizeof(xfireconfigitems)/sizeof(xfireconfigitem); for(int i=0;i" )); SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("" )); sprintf_s(temp,8,"%d",gruppen_id); while(!DBGetContactSettingString(NULL,"CListGroups",temp,&dbv)) { gruppen_id++; sprintf_s(temp,8,"%d",gruppen_id); if(dbv.pszVal!=NULL) { SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); DBFreeVariant(&dbv); } } SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"mainclangroup",0), 0); SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_SETCURSEL, DBGetContactSettingByte(NULL,protocolname,"fofgroup",0), 0); } return TRUE; } case DM_REBUILD_TREE: //baue optionsmenü auf TreeView_SelectItem(hwndTree, NULL); ShowWindow(hwndTree, SW_HIDE); TreeView_DeleteAllItems(hwndTree); { TVINSERTSTRUCT tvis; HTREEITEM lastSec = NULL; tvis.hParent = NULL; tvis.hInsertAfter = TVI_SORT; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; int size=sizeof(mytree)/sizeof(mytreeitem); for(int i=0;iidFrom) { case IDC_TREE: { switch(((NMHDR*)lParam)->code) { //wenn was geändert wurde, apply aktivieren case TVN_SELCHANGEDA: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case TVN_KEYDOWN: //tastatursteuerung { NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam; if (ptkd&&ptkd->wVKey==VK_SPACE&&TreeView_GetSelection(ptkd->hdr.hwndFrom)) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } case NM_CLICK: //wenn was geklickt wurde, apply aktivieren { TVHITTESTINFO hti; hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) if (hti.flags&TVHT_ONITEM) if(hti.flags&TVHT_ONITEMSTATEICON) if (TreeView_GetParent(hwndTree, hti.hItem)!=NULL) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } } } } switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { int reconnectRequired=0; int ccc; hwndTree = GetDlgItem(hwndDlg, IDC_TREE); //optionen speichern for(int i=0;i> 12 == 2 )) DBWriteContactSettingByte(NULL,protocolname,mytree[i].dbentry,1); else DBWriteContactSettingByte(NULL,protocolname,mytree[i].dbentry,0); } } DBWriteContactSettingByte(NULL,protocolname,"nomsgbox",(BYTE)nomsgboxsel[SendDlgItemMessage(hwndDlg, IDC_NOMSG, CB_GETCURSEL, 0, 0)]); ccc=SendDlgItemMessage(hwndDlg, IDC_CBVICO, CB_GETCURSEL, 0, 0); DBWriteContactSettingByte(NULL,protocolname,"voiceico",(BYTE)ccc); ccc=SendDlgItemMessage(hwndDlg, IDC_CBGICO, CB_GETCURSEL, 0, 0); DBWriteContactSettingByte(NULL,protocolname,"gameico",(BYTE)ccc); ccc=SendDlgItemMessage(hwndDlg, IDC_CLANGROUP, CB_GETCURSEL, 0, 0); DBWriteContactSettingByte(NULL,protocolname,"mainclangroup",(BYTE)ccc); ccc=SendDlgItemMessage(hwndDlg, IDC_FOFGROUP, CB_GETCURSEL, 0, 0); DBWriteContactSettingByte(NULL,protocolname,"fofgroup",(BYTE)ccc); ccc=SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_GETCURSEL, 0, 0); DBWriteContactSettingByte(NULL,protocolname,"scanalways",(BYTE)ccc); //protocolversion wird autoamtisch vergeben //GetDlgItemText(hwndDlg,IDC_PVER,str,sizeof(str)); //DBWriteContactSettingByte(NULL,protocolname,"protover",(char)atoi(str)); if(reconnectRequired) MessageBox(hwndDlg,Translate("The changes you have made require you to reconnect to the XFire network before they take effect"),Translate("XFire Options"),MB_OK|MB_ICONINFORMATION); return TRUE; } } break; } } return FALSE; } static BOOL CALLBACK DlgProcOpts4(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { char inipath[XFIRE_MAX_STATIC_STRING_LEN]=""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; static int nomsgboxsel[] = {1,0,2}; static HWND hwndTree = NULL; switch (msg) { case WM_INITDIALOG: { //addgamedia auf 0 setzen TranslateDialogDefault(hwndDlg); FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" ); strcat(inipath,"\\"); strcat(inipath,"xfire_games.ini"); FILE * f = fopen(inipath,"r"); if(f!=NULL) { fclose(f); CheckDlgButton(hwndDlg,IDC_CHKG,1); inifound = TRUE; } else { EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); inifound = FALSE; } FoldersGetCustomPath( XFireIconFolder, inipath, 1024, "" ); strcat(inipath,"\\"); strcat(inipath,"icons.dll"); f = fopen(inipath,"r"); if(f!=NULL) { fclose(f); CheckDlgButton(hwndDlg,IDC_CHKI,1); dllfound = TRUE; } else dllfound = FALSE; //alle blockierten nutzer in die liste einfügen DBCONTACTENUMSETTINGS dbces; // enum all setting the contact has for the module dbces.pfnEnumProc = enumSettingsProc; dbces.szModule = "XFireBlock"; dbces.lParam = (LPARAM)hwndDlg; CallService(MS_DB_CONTACT_ENUMSETTINGS, 0,(LPARAM)&dbces); SendMessage(GetDlgItem(hwndDlg,IDC_REMUSER),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_DELETE)); FoldersGetCustomPath( XFireWorkingFolder, inipath, 1024, "" ); SetDlgItemText(hwndDlg,IDC_FILESSHOULDBE,inipath); EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE); return TRUE; } case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_COMMAND: CheckDlgButton(hwndDlg,IDC_CHKI,dllfound); CheckDlgButton(hwndDlg,IDC_CHKG,inifound); if(LOWORD(wParam) == IDC_REMUSER) //nutzer soll aus der blockierliste raus { char temp[255]; int sel=SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETCURSEL, 0, 0); if(sel!=LB_ERR) //nur wenn was ausgewählt wurde { SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETTEXT, sel, (LPARAM)temp); SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_DELETESTRING, sel, 0); DBDeleteContactSetting(NULL,"XFireBlock",temp); if(SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_GETCOUNT, 0, 0)==0) EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE); } } if ((LOWORD(wParam) == 9508 || LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_SETUPGAMES || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) ) return 0; break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { return TRUE; } } break; } } return FALSE; } static BOOL CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg,IDC_ENABLESTSMSG,DBGetContactSettingByte(NULL,protocolname,"autosetstatusmsg",0)); CheckDlgButton(hwndDlg,IDC_CHGSTATUS,DBGetContactSettingByte(NULL,protocolname,"statuschgtype",0)); CheckDlgButton(hwndDlg,IDC_DNDFIRST,DBGetContactSettingByte(NULL,protocolname,"dndfirst",0)); if(!DBGetContactSetting(NULL,protocolname,"setstatusmsg",&dbv)) { SetDlgItemText(hwndDlg,IDC_STATUSMSG,dbv.pszVal); DBFreeVariant(&dbv); } if(!IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)) { EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); } /* if(!ServiceExists(MS_VARS_FORMATSTRING)) { EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); EnableDlgItem(hwndDlg, IDC_ENABLESTSMSG, FALSE); EnableDlgItem(hwndDlg, IDC_CHGSTATUS, FALSE); EnableDlgItem(hwndDlg, IDC_DNDFIRST, FALSE); }*/ return TRUE; } case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_COMMAND: if ( IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG) ) { EnableDlgItem(hwndDlg, IDC_STATUSMSG, TRUE); } else { EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); } if ((LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_STATUSMSG || LOWORD(wParam) == IDC_PASSWORD) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) ) return 0; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { int reconnectRequired=0; char str[512]; GetDlgItemText(hwndDlg,IDC_STATUSMSG,str,sizeof(str)); DBWriteContactSettingString(NULL,protocolname,"setstatusmsg",str); DBWriteContactSettingByte(NULL,protocolname, "autosetstatusmsg", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)); DBWriteContactSettingByte(NULL,protocolname, "statuschgtype", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHGSTATUS)); DBWriteContactSettingByte(NULL,protocolname, "dndfirst", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DNDFIRST)); return TRUE; } } break; } } return FALSE; } static BOOL CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { addgameDialog=NULL; TranslateDialogDefault(hwndDlg); //elemente erstmal abstellen EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE); EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE); EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE); EnableDlgItem(hwndDlg, IDC_APPLY, FALSE); EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); //gamelist füllen SendMessage(hwndDlg,WM_FILLGAMELIST,0,0); //SendMessage(GetDlgItem(hwndDlg,IDC_CREATETXTLIST),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS)); return TRUE; } case WM_FILLGAMELIST: { //spielliste leeren SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_RESETCONTENT, 0, 0); //spiele auslesen und in die liste einfügen int found=DBGetContactSettingWord(NULL,protocolname,"foundgames",0); char temp[XFIRE_MAXSIZEOFGAMENAME]; for(int i=0;iname) { xgamelist.appendString("\r\nName: ",&out); xgamelist.appendString(nextgame->name,&out); } if(nextgame->path) { xgamelist.appendString("\r\nPath: ",&out); xgamelist.appendString(nextgame->path,&out); } if(nextgame->launchparams) { xgamelist.appendString("\r\nLaunch: ",&out); xgamelist.appendString(nextgame->launchparams,&out); } char temp[10]; _itoa(nextgame->id,temp,10); xgamelist.appendString("\r\nId: ",&out); xgamelist.appendString(temp,&out); _itoa(nextgame->send_gameid,temp,10); xgamelist.appendString("\r\nSend-Id: ",&out); xgamelist.appendString(temp,&out); if(nextgame->skip) { xgamelist.appendString("\r\nThis game will be skipped in game detection!",&out); } xgamelist.appendString("\r\n",&out); } if(OpenClipboard(NULL)) { HGLOBAL clipbuffer; char* buffer; EmptyClipboard(); clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(out)+1); buffer = (char*)GlobalLock(clipbuffer); strcpy(buffer, LPCSTR(out)); GlobalUnlock(clipbuffer); SetClipboardData(CF_TEXT, clipbuffer); CloseClipboard(); } if(out!=NULL) delete[] out; //gameliste unblocken xgamelist.Block(FALSE); }*/ else if(LOWORD(wParam)==IDC_EDITGAME) { int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); //was ausgewählt in der liste? if(idx!=LB_ERR) { //gameliste blocken xgamelist.Block(TRUE); //gameid der aktuellen auswahl auslesen int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); //spielobject holen Xfire_game* tempgame=xgamelist.getGamebyGameid(gameid); //gültiger verweis? if(tempgame) { //editmodus des addgamedialog AddGameDialog(hwndDlg,tempgame); //elemente wieder unsichtbar machen EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE); EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE); EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE); EnableDlgItem(hwndDlg, IDC_APPLY, FALSE); EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); } else MessageBox(hwndDlg,Translate("Error unknown game id."),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION); //gameliste unblocken xgamelist.Block(FALSE); //gamelist neu füllen SendMessage(hwndDlg,WM_FILLGAMELIST,0,0); } else MessageBox(hwndDlg,Translate("Please select a game."),Translate("XFire Options"),MB_OK|MB_ICONEXCLAMATION); }else //wurde ein spiel aus der liste gewählt? if(HIWORD(wParam)==LBN_SELCHANGE && LOWORD(wParam)==IDC_LGAMELIST) { int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); //es wurde was ausgewählt? if(idx!=LB_ERR) { //textlänge auslesen int size=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0); //textbuffer anlegen char* text=new char[size+1]; SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text); SetDlgItemText(hwndDlg,IDC_GAMENAME,text); //textbuffer löschen if(text!=NULL) { delete text; text=NULL; } //id des spielsbekommen int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); HICON hicon=xgamelist.iconmngr.getGameIcon(gameid); //iconhandle holen und setzen if(hicon) SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,(WPARAM)hicon,0); else SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,0,0); //elemente aktivieren EnableDlgItem(hwndDlg, IDC_DONTDETECT, TRUE); EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, TRUE); EnableDlgItem(hwndDlg, IDC_APPLY, TRUE); EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, TRUE); EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid); if(xgtemp && xgtemp->custom) { ShowWindow(GetDlgItem(hwndDlg,IDC_MANADDED),SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_SHOW); } else { ShowWindow(GetDlgItem(hwndDlg,IDC_MANADDED),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); } //gameskip wert setzen char temp[64]=""; sprintf_s(temp,64,"gameskip_%d",gameid); CheckDlgButton(hwndDlg,IDC_DONTDETECT,DBGetContactSettingByte(NULL,protocolname,temp,0)); sprintf_s(temp,64,"gamenostatus_%d",gameid); CheckDlgButton(hwndDlg,IDC_NOSTATUSMSG,DBGetContactSettingByte(NULL,protocolname,temp,0)); sprintf_s(temp,64,"notinstartmenu_%d",gameid); CheckDlgButton(hwndDlg,IDC_NOTINSTARTMENU,DBGetContactSettingByte(NULL,protocolname,temp,0)); //extra parameter auslesen, aber nur, wenn das spiel auch sowas unterstützt if(xgtemp && xgtemp->haveExtraGameArgs()) { EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); sprintf_s(temp,64,"gameextraparams_%d",gameid); DBVARIANT dbv; if(!DBGetContactSetting(NULL,protocolname,temp,&dbv)) { SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,dbv.pszVal); DBFreeVariant(&dbv); } else SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,""); } else { EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,Translate("Not supported")); } } } else if(LOWORD(wParam)==IDC_APPLY) { //auswahl speichern int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); //es wurde was ausgewählt? if(idx!=LB_ERR) { int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); int dbid; //gamelist blocken xgamelist.Block(TRUE); if(xgamelist.Gameinlist(gameid,&dbid)) { Xfire_game* game=xgamelist.getGame(dbid); if(game) { game->skip=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT); game->noicqstatus=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG); game->notinstartmenu=(BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU); //extra parameter auslesen und das gameobj schreiben char str[128]=""; GetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,str,sizeof(str)); if(str[0]!=0) { //extra parameter sind gesetzt, zuweisen game->setString(str,&game->extraparams); } else { //extra parameter leer, wenn gesetzt entfernen/freigeben if(game->extraparams) { delete[] game->extraparams; game->extraparams=NULL; } } game->refreshMenuitem(); game->writeToDB(dbid); SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Configuration saved!")); } else { SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Game not found?!")); } } else { SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,Translate("Game not found?!")); } //gamelist unblocken xgamelist.Block(FALSE); } } break; } case WM_NOTIFY: { break; } } return FALSE; } static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_INITDIALOG: { HWND hwndTab,hPage; TCITEMA tci = {0}; int iTotal; RECT rcClient; hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB); TabCtrl_DeleteAllItems(hwndTab); GetClientRect(GetParent(hwndTab), &rcClient); hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTLOGIN), hwndDlg, DlgProcOpts2); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.lParam = (LPARAM)hPage; tci.pszText = Translate("Account"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1); iTotal++; hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT), hwndDlg, DlgProcOpts3); ShowWindow(hPage,FALSE); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.lParam = (LPARAM)hPage; tci.pszText = Translate("Features"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1); iTotal++; hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT2), hwndDlg, DlgProcOpts4); ShowWindow(hPage,FALSE); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.lParam = (LPARAM)hPage; tci.pszText = Translate("Blocklist / Games"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1); iTotal++; hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT3), hwndDlg, DlgProcOpts5); ShowWindow(hPage,FALSE); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.lParam = (LPARAM)hPage; tci.pszText = Translate("StatusMsg"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1); iTotal++; hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_OPTFEAT4), hwndDlg, DlgProcOpts6); ShowWindow(hPage,FALSE); iTotal = TabCtrl_GetItemCount(hwndTab); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.lParam = (LPARAM)hPage; tci.pszText = Translate("Games"); SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci); MoveWindow(hPage, 3, 24, rcClient.right - 6, rcClient.bottom - 28, 1); iTotal++; TabCtrl_SetCurSel(hwndTab, 0); return TRUE; } case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { TCITEM tci; int i,count; tci.mask = TCIF_PARAM; count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg,IDC_OPTIONSTAB)); for (i=0; icode) { case TCN_SELCHANGING: { TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); } break; case TCN_SELCHANGE: { TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci); ShowWindow((HWND)tci.lParam,SW_SHOW); } break; } break; } } break; } return FALSE; } int OptInit(WPARAM wParam,LPARAM lParam) { OPTIONSDIALOGPAGE odp; ghwndDlg2=NULL; ZeroMemory(&odp,sizeof(odp)); odp.cbSize=sizeof(odp); //odp.position=-790000000; odp.hInstance=hinstance; odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT); odp.pszTitle=Translate("XFire"); odp.pszGroup = Translate("Network"); odp.flags=ODPF_BOLDGROUPS; //odp.nIDBottomSimpleControl=IDC_GROUPMAIN; odp.pfnDlgProc=DlgProcOpts; Options_AddPage(wParam, &odp); return 0; }