diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-11-27 19:00:38 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-11-27 19:00:38 +0000 |
commit | 5cd55bf98d402791990db77399eb9be54f70ddbd (patch) | |
tree | 1478a4a4690c3916941308f42c167b22ce39a2ba /protocols | |
parent | fe7d09b9df2514c587376b924379ae1ccb1ff7a6 (diff) |
Xfire: code cleanup. Plugin must be rewritten.
git-svn-id: http://svn.miranda-ng.org/main/trunk@11120 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Xfire/src/Xfire_avatar_loader.cpp | 167 | ||||
-rw-r--r-- | protocols/Xfire/src/options.cpp | 2268 | ||||
-rw-r--r-- | protocols/Xfire/src/tools.cpp | 2116 |
3 files changed, 2277 insertions, 2274 deletions
diff --git a/protocols/Xfire/src/Xfire_avatar_loader.cpp b/protocols/Xfire/src/Xfire_avatar_loader.cpp index b27b755059..72805b0b7c 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.cpp +++ b/protocols/Xfire/src/Xfire_avatar_loader.cpp @@ -1,87 +1,82 @@ -#include "stdafx.h"
-#include "Xfire_avatar_loader.h"
-
-Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) {
- threadrunning=FALSE;
- this->client=client;
- InitializeCriticalSection(&this->avatarMutex);
-}
-
-Xfire_avatar_loader::~Xfire_avatar_loader() {
- //liste leeren, damit der laufende thread abgebrochen wird
- list.clear();
- //warten bis der thread geschlossen wurde
- EnterCriticalSection(&this->avatarMutex);
- LeaveCriticalSection(&this->avatarMutex);
- //critical section entfernen
- DeleteCriticalSection(&this->avatarMutex);
-}
-
-void Xfire_avatar_loader::loadThread(LPVOID lparam) {
- Xfire_avatar_loader* loader=(Xfire_avatar_loader*)lparam;
-
- //kein loader, dann abbruch
- if (!lparam)
- return;
-
- if (loader) {
- EnterCriticalSection(&loader->avatarMutex);
- loader->threadrunning=TRUE;
- }
-
- while(1){
- //keinen avatarload auftrag mehr
- if (!loader->list.size())
- break;
-
- //letzten load process holen
- Xfire_avatar_process process=loader->list.back();
-
- //buddyinfo abfragen
- GetBuddyInfo buddyinfo;
- buddyinfo.userid=process.userid;
- if (loader->client)
- if (loader->client->connected)
- {
- loader->client->send(&buddyinfo);
- }
- else //nicht mehr verbunden? dann liste leeren und schleife abbrechen
- {
- loader->list.clear();
- break;
- }
-
- //auftrag entfernen
- loader->list.pop_back();
-
- Sleep(1000);
- }
-
- if (loader)
- {
- loader->threadrunning=FALSE;
- LeaveCriticalSection(&loader->avatarMutex);
- }
-
- return;
-}
-
-BOOL Xfire_avatar_loader::loadAvatar(MCONTACT hcontact,char*username,unsigned int userid)
-{
- Xfire_avatar_process process={0};
-
- //struktur füllen
- process.hcontact = hcontact;
- if (username)
- strcpy_s(process.username,128,username);
- process.userid=userid;
-
- //Avataranfrage an die liste übergeben
- this->list.push_back(process);
-
- if (!threadrunning && client!=NULL) {
- mir_forkthread(Xfire_avatar_loader::loadThread,(LPVOID)this);
- }
-
- return TRUE;
+#include "stdafx.h" +#include "Xfire_avatar_loader.h" + +Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) { + threadrunning=FALSE; + this->client=client; + InitializeCriticalSection(&this->avatarMutex); +} + +Xfire_avatar_loader::~Xfire_avatar_loader() { + //liste leeren, damit der laufende thread abgebrochen wird + list.clear(); + //warten bis der thread geschlossen wurde + EnterCriticalSection(&this->avatarMutex); + LeaveCriticalSection(&this->avatarMutex); + //critical section entfernen + DeleteCriticalSection(&this->avatarMutex); +} + +void Xfire_avatar_loader::loadThread(LPVOID lparam) { + Xfire_avatar_loader *loader=(Xfire_avatar_loader*)lparam; + + //kein loader, dann abbruch + if (!loader) + return; + + EnterCriticalSection(&loader->avatarMutex); + loader->threadrunning=TRUE; + + while(1){ + //keinen avatarload auftrag mehr + if (!loader->list.size()) + break; + + //letzten load process holen + Xfire_avatar_process process=loader->list.back(); + + //buddyinfo abfragen + GetBuddyInfo buddyinfo; + buddyinfo.userid=process.userid; + if (loader->client) + if (loader->client->connected) + { + loader->client->send(&buddyinfo); + } + else //nicht mehr verbunden? dann liste leeren und schleife abbrechen + { + loader->list.clear(); + break; + } + + //auftrag entfernen + loader->list.pop_back(); + + Sleep(1000); + } + + loader->threadrunning=FALSE; + LeaveCriticalSection(&loader->avatarMutex); + + return; +} + +BOOL Xfire_avatar_loader::loadAvatar(MCONTACT hcontact,char*username,unsigned int userid) +{ + Xfire_avatar_process process={0}; + + //struktur füllen + process.hcontact = hcontact; + if (username) + strcpy_s(process.username,128,username); + process.userid=userid; + + //Avataranfrage an die liste übergeben + this->list.push_back(process); + + if (!threadrunning && client!=NULL) { + mir_forkthread(Xfire_avatar_loader::loadThread,(LPVOID)this); + } + + return TRUE; }
\ No newline at end of file diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index 559c1ed0c7..7465327d41 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -1,1133 +1,1137 @@ -/*
- * 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 "m_variables.h"
-#include "recvprefspacket.h"
-#include "Xfire_gamelist.h"
-#include "addgamedialog.h"
-#include "variables.h"
-
-extern HANDLE XFireWorkingFolder;
-extern HANDLE XFireIconFolder;
-extern xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS];
-extern Xfire_gamelist xgamelist;
-
-struct mytreeitem {
- TCHAR 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[] = {
- {LPGENT("Avatars"),"",1,0},
- {LPGENT("Disable avatars"),"noavatars",0,0},
- {LPGENT("Don't download avatars of clan members"),"noclanavatars",0,0},
- {LPGENT("Use alternate way for Avatar download"),"specialavatarload",0,0},
- {LPGENT("General"),"",1,0},
- {LPGENT("Automatically reconnect on protocol version changes"),"recprotoverchg",0,0},
- {LPGENT("No IP/Port in StatusMsg"),"noipportinstatus",0,0},
- {LPGENT("Use Online status for unsupported global statuses"),"oninsteadafk",0,0},
- {LPGENT("Don't move friends to clan groups"),"skipfriendsgroups",0,0},
- {LPGENT("GameServerQuery support"),"gsqsupport",0,0},
- {LPGENT("No custom away message"),"nocustomaway",0,0},
- {LPGENT("Remove friend of friend buddies from database"),"fofdbremove",0,0},
- /*{"Show usernames only","onlyusername",0},*/
- {LPGENT("Hide yourself in buddylist"),"skipmyself",0,0},
- {LPGENT("Don't display game search results"),"dontdisresults",0,0},
- {LPGENT("Don't display game search status window"),"dontdissstatus",0,0},
- {LPGENT("Display popup if someone starts a game"),"gamepopup",0,0},
- {LPGENT("Don't automatically create clan groups"),"noclangroups",0,0},
- {LPGENT("Enable MBot support"),"mbotsupport",0,0},
- {LPGENT("Game detection"),"",1,0},
- /*{"Scan for games on every Miranda start","scanalways",0},*/
- {LPGENT("Disable game detection"),"nogamedetect",0,0},
- /*{"Enable server IP/Port detection","ipportdetec",0},*/
- /*{"Enable TeamSpeak2/Ventrilo detection","",0},*/
- {LPGENT("Use TSRemote.dll to get TeamSpeak server info"),"ts2useremote",0,0},
- {LPGENT("Disable popups when ingame"),"nopopups",0,0},
- {LPGENT("Disable sound events when ingame"),"nosoundev",0,0},
- {LPGENT("Files"),"",1,0},
- {LPGENT("Automatically update xfire_games.ini (pro-laming.de)"),"autoiniupdate",0,0},
- {LPGENT("Automatically update icons.dll (pro-laming.de)"),"autoicodllupdate",0,0},
- {LPGENT("Download missing game icons from Xfire website"),"xfiresitegameico",0,0},
- {LPGENT("No backup on update"),"nobackupini",0,0},
- {LPGENT("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)
- {
- SendDlgItemMessageA( (HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting);
- }
- EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE);
- return 0;
-}
-
-//damit die änderungen sofort sichtbar sind
-static INT_PTR 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);
- SetWindowLongPtr(hwndTree,GWL_STYLE,GetWindowLongPtr(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
- SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0);
-
- strcpy(inipath, XFireGetFoldersPath ("IniFile"));
- 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;
- }
-
- strcpy(inipath, XFireGetFoldersPath ("IconsFile"));
- strcat(inipath, "icons.dll");
-
- f = fopen(inipath,"r");
- if (f!=NULL)
- {
- fclose(f);
- CheckDlgButton(hwndDlg,IDC_CHKI,1);
- dllfound = TRUE;
- }
- else
- dllfound = FALSE;
-
- if (!db_get(NULL,protocolname,"login",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_LOGIN,dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(NULL,protocolname,"Nick",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(NULL,protocolname,"password",&dbv)) {
- //bit of a security hole here, since it's easy to extract a password from an edit box
- SetDlgItemTextA(hwndDlg,IDC_PASSWORD,dbv.pszVal);
- db_free(&dbv);
- }
-
- char temp[255]="";
- mir_snprintf(temp, SIZEOF(temp), "%d", db_get_b(NULL, protocolname, "protover", 0x5b));
- SetDlgItemTextA(hwndDlg,IDC_PVER,temp);
-
- EnableWindow(GetDlgItem(hwndDlg,IDC_LASTGAME),FALSE);
- if (!db_get(NULL,protocolname,"LastGame",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_LASTGAME,dbv.pszVal);
- db_free(&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;i<size;i++)
- {
- EnableDlgItem(hwndDlg, xfireconfigitems[i].id, TRUE);
- if (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset==0)
- {
- CheckDlgButton(hwndDlg,xfireconfigitems[i].id,1);
- }
- else
- {
- CheckDlgButton(hwndDlg,xfireconfigitems[i].id,0);
- }
- }
- //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren
- if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 ))
- {
- CheckDlgButton(hwndDlg,IDC_KONFIG_2,0);
- CheckDlgButton(hwndDlg,IDC_KONFIG_3,0);
- EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE);
- EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE);
- }
- }
-
- return TRUE;
- }
-
-
-
- case WM_COMMAND:
- if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 ))
- {
- CheckDlgButton(hwndDlg,IDC_KONFIG_2,0);
- CheckDlgButton(hwndDlg,IDC_KONFIG_3,0);
- EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE);
- EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE);
- }
- else
- {
- EnableDlgItem(hwndDlg, IDC_KONFIG_2, TRUE);
- EnableDlgItem(hwndDlg, IDC_KONFIG_3, TRUE);
- }
- if ( LOWORD( wParam ) == IDC_URLNEWACC ) {
- CallService(MS_UTILS_OPENURL, 1, ( LPARAM )"http://www.xfire.com/register/" );
- return TRUE;
- }
- if ( LOWORD( wParam ) == IDC_LOSTPW ) {
- CallService(MS_UTILS_OPENURL, 1, ( LPARAM )"https://secure.xfire.com/lost_password/" );
- return TRUE;
- }
-
- if ((LOWORD(wParam) == 19901 || LOWORD(wParam) == 25466 || LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_PIP || LOWORD(wParam) == IDC_PPORT || LOWORD(wParam) == IDC_NICK || 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[128];
- DBVARIANT dbv;
-
- GetDlgItemTextA(hwndDlg,IDC_LOGIN,login,sizeof(login));
- dbv.pszVal=NULL;
- if (db_get(NULL,protocolname,"login",&dbv) || strcmp(login,dbv.pszVal))
- reconnectRequired=1;
- if (dbv.pszVal!=NULL) db_free(&dbv);
-
- //den login lowercasen
- int size=strlen(login);
- BOOL mustlowercase=FALSE;
- for(int i=0;i<size;i++)
- {
- if (login[i]>='A'&&login[i]<='Z')
- mustlowercase=TRUE;
- login[i]=tolower(login[i]);
- }
- if (mustlowercase) {
- MessageBox(NULL,TranslateT("The username must be lowercase, so it will be lowercased saved."),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION);
- SetDlgItemTextA(hwndDlg,IDC_LOGIN,login);
- }
-
- db_set_s(NULL,protocolname,"login",login);
- db_set_s(NULL,protocolname,"Username",login);
-
- //nur wenn der nick erfolgreich übertragen wurde
- GetDlgItemTextA(hwndDlg,IDC_NICK,login,sizeof(login));
- dbv.pszVal=NULL;
- if (db_get(NULL,protocolname,"Nick",&dbv) || strcmp(login,dbv.pszVal))
- {
- if (CallService(XFIRE_SET_NICK,0,(WPARAM)login))
- db_set_s(NULL,protocolname,"Nick",login);
- }
- if (dbv.pszVal!=NULL) db_free(&dbv);
-
- GetDlgItemTextA(hwndDlg,IDC_PASSWORD,str,sizeof(str));
- dbv.pszVal = NULL;
- if (db_get(NULL,protocolname,"password",&dbv) || strcmp(str,dbv.pszVal))
- reconnectRequired=1;
- if (dbv.pszVal!=NULL) db_free(&dbv);
- db_set_s(NULL,protocolname,"password",str);
- GetDlgItemTextA(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<size;i++)
- {
- if (!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id))
- {
- db_set_b(NULL,protocolname,xfireconfigitems[i].dbentry,0);
- xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=1;
- xfireconfig[xfireconfigitems[i].xfireconfigid].data[0]=1;
- xfireconfig[xfireconfigitems[i].xfireconfigid].data[1]=1;
- xfireconfig[xfireconfigitems[i].xfireconfigid].data[2]=0;
- xfireconfig[xfireconfigitems[i].xfireconfigid].data[3]=0x30;
- }
- else
- {
- xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=0;
- db_set_b(NULL,protocolname,xfireconfigitems[i].dbentry,1);
- }
- }
- CallService(XFIRE_SEND_PREFS,0,0);
- }
-
- //protocolversion wird autoamtisch vergeben
- //GetDlgItemTextA(hwndDlg,IDC_PVER,str,sizeof(str));
- //db_set_b(NULL,protocolname,"protover",(char)atoi(str));
-
- if (reconnectRequired) MessageBox(hwndDlg,TranslateT("The changes you have made require you to reconnect to the XFire network before they take effect"),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION);
- return TRUE;
- }
-
- }
- break;
- }
- }
- return FALSE;
-}
-
-static INT_PTR CALLBACK DlgProcOpts3(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:
- {
- TranslateDialogDefault(hwndDlg);
-
- hwndTree = GetDlgItem(hwndDlg, IDC_TREE);
-
- SetWindowLongPtr(hwndTree,GWL_STYLE,GetWindowLongPtr(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES);
-
- SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0);
-
- SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Hidden" ));
- SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Message box" ));
- SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup" ));
-
- //scanalways
- SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("No" ));
- SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("On every start" ));
- SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("Daily" ));
-
- SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_SETCURSEL, db_get_b(NULL,protocolname,"scanalways",0), 0);
-
- SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_SETCURSEL, nomsgboxsel[db_get_b(NULL,protocolname,"nomsgbox",0)], 0);
-
- /* Gruppen raussuchen */
- {
- int gruppen_id=0;
- char temp[8];
- DBVARIANT dbv;
-
- SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" ));
- SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" ));
-
- mir_snprintf(temp, SIZEOF(temp), "%d", gruppen_id);
- while(!db_get_s(NULL,"CListGroups",temp,&dbv))
- {
- gruppen_id++;
- mir_snprintf(temp, SIZEOF(temp), "%d", gruppen_id);
-
- if (dbv.pszVal!=NULL) {
- SendDlgItemMessageA( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]);
- SendDlgItemMessageA( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]);
- db_free(&dbv);
- }
- }
- SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_SETCURSEL, db_get_b(NULL,protocolname,"mainclangroup",0), 0);
- SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_SETCURSEL, db_get_b(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;i<size;i++)
- {
- tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
- tvis.item.iImage = -1;
- tvis.item.stateMask = TVIS_EXPANDED;
- tvis.item.state = TVIS_EXPANDED;
- tvis.hParent = lastSec;
- if ( mytree[i].parent ) {
- tvis.hParent = NULL;
- tvis.item.lParam = -1;
- tvis.item.pszText = TranslateTS(mytree[i].name);
- tvis.hParent = tvis.item.hItem = TreeView_InsertItem( hwndTree, &tvis );
- lastSec=tvis.hParent;
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(0);
- TreeView_SetItem( hwndTree, &tvis.item );
- }
- else
- {
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(db_get_b(NULL,protocolname,mytree[i].dbentry,0)==1?2:1);
- tvis.item.lParam = 0;
- tvis.item.pszText = TranslateTS(mytree[i].name);
- mytree[i].hitem=TreeView_InsertItem( hwndTree, &tvis );
- }
- }
- }
- {
- TVITEM tvi;
- tvi.hItem = TreeView_GetRoot(hwndTree);
- while ( tvi.hItem != NULL ) {
- tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
- TreeView_GetItem(hwndTree, &tvi);
- if ( tvi.lParam == -1 )
- TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
-
- tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem);
- }
- }
-
-
- ShowWindow(hwndTree, SW_SHOW);
-
- break;
-
- 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 (HIWORD(wParam) == CBN_SELCHANGE)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return 0;
- }
-
- if ((LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == 1013 || LOWORD(wParam) == 1015 || LOWORD(wParam) == 3 || LOWORD(wParam) == IDC_NICK || 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)->idFrom)
- {
- 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<sizeof(mytree)/sizeof(mytreeitem);i++)
- {
- TVITEM tvic;
- if (mytree[i].parent==0)
- {
- tvic.hItem=mytree[i].hitem;
- tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE;
-
- TreeView_GetItem(hwndTree, &tvic);
- if ((( tvic.state & TVIS_STATEIMAGEMASK ) >> 12 == 2 ))
- db_set_b(NULL,protocolname,mytree[i].dbentry,1);
- else
- db_set_b(NULL,protocolname,mytree[i].dbentry,0);
- }
- }
-
- db_set_b(NULL,protocolname,"nomsgbox",(BYTE)nomsgboxsel[SendDlgItemMessage(hwndDlg, IDC_NOMSG, CB_GETCURSEL, 0, 0)]);
-
- ccc=SendDlgItemMessage(hwndDlg, IDC_CLANGROUP, CB_GETCURSEL, 0, 0);
- db_set_b(NULL,protocolname,"mainclangroup",(BYTE)ccc);
- ccc=SendDlgItemMessage(hwndDlg, IDC_FOFGROUP, CB_GETCURSEL, 0, 0);
- db_set_b(NULL,protocolname,"fofgroup",(BYTE)ccc);
- ccc=SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_GETCURSEL, 0, 0);
- db_set_b(NULL,protocolname,"scanalways",(BYTE)ccc);
-
- //protocolversion wird autoamtisch vergeben
- //GetDlgItemTextA(hwndDlg,IDC_PVER,str,sizeof(str));
- //db_set_b(NULL,protocolname,"protover",(char)atoi(str));
-
- if (reconnectRequired) MessageBox(hwndDlg,TranslateT("The changes you have made require you to reconnect to the XFire network before they take effect"),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION);
- return TRUE;
- }
-
- }
- break;
- }
- }
- return FALSE;
-}
-
-static INT_PTR 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);
-
- strcpy(inipath, XFireGetFoldersPath ("IniFile"));
- 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;
- }
-
- strcpy(inipath, XFireGetFoldersPath ("IconsFile"));
- 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));
-
- strcpy(inipath, XFireGetFoldersPath ("IniFile"));
- SetDlgItemTextA(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
- {
- SendDlgItemMessageA(hwndDlg, IDC_BLOCKUSER, LB_GETTEXT, sel, (LPARAM)temp);
- SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_DELETESTRING, sel, 0);
- db_unset(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 INT_PTR CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- DBVARIANT dbv;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg,IDC_ENABLESTSMSG,db_get_b(NULL,protocolname,"autosetstatusmsg",0));
- CheckDlgButton(hwndDlg,IDC_CHGSTATUS,db_get_b(NULL,protocolname,"statuschgtype",0));
- CheckDlgButton(hwndDlg,IDC_DNDFIRST,db_get_b(NULL,protocolname,"dndfirst",0));
- if (!db_get(NULL,protocolname,"setstatusmsg",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_STATUSMSG,dbv.pszVal);
- db_free(&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];
-
- GetDlgItemTextA(hwndDlg,IDC_STATUSMSG,str,sizeof(str));
- db_set_s(NULL,protocolname, "setstatusmsg", str);
-
- db_set_b(NULL,protocolname, "autosetstatusmsg", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG));
- db_set_b(NULL,protocolname, "statuschgtype", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHGSTATUS));
- db_set_b(NULL,protocolname, "dndfirst", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DNDFIRST));
-
- return TRUE;
- }
-
- }
- break;
- }
- }
- return FALSE;
-}
-
-static INT_PTR 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=db_get_w(NULL,protocolname,"foundgames",0);
- char temp[XFIRE_MAXSIZEOFGAMENAME];
- for(int i=0;i<found;i++)
- {
- //id auslesen
- mir_snprintf(temp, SIZEOF(temp), "gameid_%d", i);
- int gameid=db_get_w(NULL,protocolname,temp,0);
- //spielnamen auslesen
- xgamelist.getGamename(gameid,temp,XFIRE_MAXSIZEOFGAMENAME);
- //eintrag einfügen
- int idx=SendDlgItemMessageA( (HWND)hwndDlg, IDC_LGAMELIST, LB_ADDSTRING, 0, (LPARAM)temp);
- //id an das element übergeben
- SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_SETITEMDATA, idx, gameid);
- }
- return TRUE;
- }
- case WM_COMMAND:
- {
- if (LOWORD(wParam)==IDC_REMOVE)
- {
- int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0);
-
- //was ausgewählt in der liste?
- if (idx!=LB_ERR) {
- //user fragen ob er das game wirklich löschen will
- if (MessageBox(hwndDlg,TranslateT("Are you sure you want to remove this game?"),TranslateT("XFire Options"),MB_YESNO|MB_ICONQUESTION)==IDYES) {
- //gameliste blocken
- xgamelist.Block(TRUE);
- //spielid auslesen
- int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0);
- //spiel per gameid entfernen
- xgamelist.Removegame(gameid);
- //db säubern
- xgamelist.clearDatabase(TRUE);
- //derzeitige gameliste in die datenbank eintragen
- xgamelist.writeDatabase();
- //startmenu leeren
- xgamelist.clearStartmenu();
- //startmenu neuerzeugen
- xgamelist.createStartmenu();
- //gameliste unblocken
- xgamelist.Block(FALSE);
- //gamelist neu füllen
- SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
- //erstes vorauswählen
- SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_SETCURSEL, 0, 0);
- //liste refresh
- SendMessage(hwndDlg,WM_COMMAND,MAKELONG(IDC_LGAMELIST,LBN_SELCHANGE),0);
- }
- }
- else
- MessageBox(hwndDlg,TranslateT("Please select a game."),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
-
- }
- else
- if (LOWORD(wParam)==IDC_ADDGAME)
- {
- //gameliste blocken
- xgamelist.Block(TRUE);
- //if (DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAME),hwndDlg,DlgAddGameProc)) {
- AddGameDialog(hwndDlg);
- //gameliste unblocken
- xgamelist.Block(FALSE);
- //gamelist neu füllen
- SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
- }
- //copy gamelist to clipboard button entfernt
- /*else if (LOWORD(wParam)==IDC_CREATETXTLIST) //gameliste als textform für debugging erstellen
- {
- //gameliste blocken
- xgamelist.Block(TRUE);
-
- //alle games durchgehen
- Xfire_game* nextgame;
- //output string
- char* out=new char[10];
- xgamelist.setString("Xfire-gamelist:\r\n",&out);
- while(xgamelist.getnextGame(&nextgame))
- {
- if (nextgame->name)
- {
- 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,TranslateT("Error: unknown game ID."),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
- //gameliste unblocken
- xgamelist.Block(FALSE);
- //gamelist neu füllen
- SendMessage(hwndDlg,WM_FILLGAMELIST,0,0);
- }
- else
- MessageBox(hwndDlg,TranslateT("Please select a game."),TranslateT("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];
- SendDlgItemMessageA(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text);
- SetDlgItemTextA(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]="";
- mir_snprintf(temp, SIZEOF(temp), "gameskip_%d", gameid);
- CheckDlgButton(hwndDlg,IDC_DONTDETECT,db_get_b(NULL,protocolname,temp,0));
- mir_snprintf(temp, SIZEOF(temp), "gamenostatus_%d", gameid);
- CheckDlgButton(hwndDlg,IDC_NOSTATUSMSG,db_get_b(NULL,protocolname,temp,0));
- mir_snprintf(temp, SIZEOF(temp), "notinstartmenu_%d", gameid);
- CheckDlgButton(hwndDlg,IDC_NOTINSTARTMENU,db_get_b(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);
- mir_snprintf(temp, SIZEOF(temp), "gameextraparams_%d", gameid);
- DBVARIANT dbv;
- if (!db_get(NULL,protocolname,temp,&dbv))
- {
- SetDlgItemTextA(hwndDlg,IDC_EXTRAPARAMS,dbv.pszVal);
- db_free(&dbv);
- }
- else
- SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,_T(""));
- }
- else
- {
- EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE);
- SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,TranslateT("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]="";
- GetDlgItemTextA(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,TranslateT("Configuration saved!"));
- }
- else
- {
- SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Game not found?!"));
- }
- }
- else
- {
- SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Game not found?!"));
- }
-
- //gamelist unblocken
- xgamelist.Block(FALSE);
- }
- }
- break;
- }
-
- case WM_NOTIFY:
- {
- break;
- }
- }
- return FALSE;
-}
-
-int OptInit(WPARAM wParam,LPARAM)
-{
- ghwndDlg2 = NULL;
-
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.hInstance = hinstance;
- odp.ptszTitle = LPGENT("XFire");
- odp.ptszGroup = LPGENT("Network");
- odp.flags = ODPF_BOLDGROUPS| ODPF_TCHAR;
-
- odp.pfnDlgProc = DlgProcOpts2;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTLOGIN);
- odp.ptszTab = LPGENT("Account");
- Options_AddPage(wParam, &odp);
-
- odp.pfnDlgProc = DlgProcOpts3;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT);
- odp.ptszTab = LPGENT("Features");
- Options_AddPage(wParam, &odp);
-
- odp.pfnDlgProc = DlgProcOpts4;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT2);
- odp.ptszTab = LPGENT("Blocklist / Games");
- Options_AddPage(wParam, &odp);
-
- odp.pfnDlgProc = DlgProcOpts5;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT3);
- odp.ptszTab = LPGENT("StatusMsg");
- Options_AddPage(wParam, &odp);
-
- odp.pfnDlgProc = DlgProcOpts6;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT4);
- odp.ptszTab = LPGENT("Games");
- Options_AddPage(wParam, &odp);
- return 0;
+/* + * 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 "m_variables.h" +#include "recvprefspacket.h" +#include "Xfire_gamelist.h" +#include "addgamedialog.h" +#include "variables.h" + +extern HANDLE XFireWorkingFolder; +extern HANDLE XFireIconFolder; +extern xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; +extern Xfire_gamelist xgamelist; + +struct mytreeitem { + TCHAR 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[] = { + {LPGENT("Avatars"),"",1,0}, + {LPGENT("Disable avatars"),"noavatars",0,0}, + {LPGENT("Don't download avatars of clan members"),"noclanavatars",0,0}, + {LPGENT("Use alternate way for Avatar download"),"specialavatarload",0,0}, + {LPGENT("General"),"",1,0}, + {LPGENT("Automatically reconnect on protocol version changes"),"recprotoverchg",0,0}, + {LPGENT("No IP/Port in StatusMsg"),"noipportinstatus",0,0}, + {LPGENT("Use Online status for unsupported global statuses"),"oninsteadafk",0,0}, + {LPGENT("Don't move friends to clan groups"),"skipfriendsgroups",0,0}, + {LPGENT("GameServerQuery support"),"gsqsupport",0,0}, + {LPGENT("No custom away message"),"nocustomaway",0,0}, + {LPGENT("Remove friend of friend buddies from database"),"fofdbremove",0,0}, + /*{"Show usernames only","onlyusername",0},*/ + {LPGENT("Hide yourself in buddylist"),"skipmyself",0,0}, + {LPGENT("Don't display game search results"),"dontdisresults",0,0}, + {LPGENT("Don't display game search status window"),"dontdissstatus",0,0}, + {LPGENT("Display popup if someone starts a game"),"gamepopup",0,0}, + {LPGENT("Don't automatically create clan groups"),"noclangroups",0,0}, + {LPGENT("Enable MBot support"),"mbotsupport",0,0}, + {LPGENT("Game detection"),"",1,0}, + /*{"Scan for games on every Miranda start","scanalways",0},*/ + {LPGENT("Disable game detection"),"nogamedetect",0,0}, + /*{"Enable server IP/Port detection","ipportdetec",0},*/ + /*{"Enable TeamSpeak2/Ventrilo detection","",0},*/ + {LPGENT("Use TSRemote.dll to get TeamSpeak server info"),"ts2useremote",0,0}, + {LPGENT("Disable popups when ingame"),"nopopups",0,0}, + {LPGENT("Disable sound events when ingame"),"nosoundev",0,0}, + {LPGENT("Files"),"",1,0}, + {LPGENT("Automatically update xfire_games.ini (pro-laming.de)"),"autoiniupdate",0,0}, + {LPGENT("Automatically update icons.dll (pro-laming.de)"),"autoicodllupdate",0,0}, + {LPGENT("Download missing game icons from Xfire website"),"xfiresitegameico",0,0}, + {LPGENT("No backup on update"),"nobackupini",0,0}, + {LPGENT("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) + { + SendDlgItemMessageA( (HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting); + } + EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE); + return 0; +} + +//damit die änderungen sofort sichtbar sind +static INT_PTR 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); + SetWindowLongPtr(hwndTree,GWL_STYLE,GetWindowLongPtr(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); + + strcpy(inipath, XFireGetFoldersPath ("IniFile")); + 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; + } + + strcpy(inipath, XFireGetFoldersPath ("IconsFile")); + strcat(inipath, "icons.dll"); + + f = fopen(inipath,"r"); + if (f!=NULL) + { + fclose(f); + CheckDlgButton(hwndDlg,IDC_CHKI,1); + dllfound = TRUE; + } + else + dllfound = FALSE; + + if (!db_get(NULL,protocolname,"login",&dbv)) { + SetDlgItemTextA(hwndDlg,IDC_LOGIN,dbv.pszVal); + db_free(&dbv); + } + if (!db_get(NULL,protocolname,"Nick",&dbv)) { + SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal); + db_free(&dbv); + } + if (!db_get(NULL,protocolname,"password",&dbv)) { + //bit of a security hole here, since it's easy to extract a password from an edit box + SetDlgItemTextA(hwndDlg,IDC_PASSWORD,dbv.pszVal); + db_free(&dbv); + } + + char temp[255]=""; + mir_snprintf(temp, SIZEOF(temp), "%d", db_get_b(NULL, protocolname, "protover", 0x5b)); + SetDlgItemTextA(hwndDlg,IDC_PVER,temp); + + EnableWindow(GetDlgItem(hwndDlg,IDC_LASTGAME),FALSE); + if (!db_get(NULL,protocolname,"LastGame",&dbv)) { + SetDlgItemTextA(hwndDlg,IDC_LASTGAME,dbv.pszVal); + db_free(&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;i<size;i++) + { + EnableDlgItem(hwndDlg, xfireconfigitems[i].id, TRUE); + if (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset==0) + { + CheckDlgButton(hwndDlg,xfireconfigitems[i].id,1); + } + else + { + CheckDlgButton(hwndDlg,xfireconfigitems[i].id,0); + } + } + //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren + if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 )) + { + CheckDlgButton(hwndDlg,IDC_KONFIG_2,0); + CheckDlgButton(hwndDlg,IDC_KONFIG_3,0); + EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); + EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); + } + } + + return TRUE; + } + + + + case WM_COMMAND: + if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 )) + { + CheckDlgButton(hwndDlg,IDC_KONFIG_2,0); + CheckDlgButton(hwndDlg,IDC_KONFIG_3,0); + EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); + EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); + } + else + { + EnableDlgItem(hwndDlg, IDC_KONFIG_2, TRUE); + EnableDlgItem(hwndDlg, IDC_KONFIG_3, TRUE); + } + if ( LOWORD( wParam ) == IDC_URLNEWACC ) { + CallService(MS_UTILS_OPENURL, 1, ( LPARAM )"http://www.xfire.com/register/" ); + return TRUE; + } + if ( LOWORD( wParam ) == IDC_LOSTPW ) { + CallService(MS_UTILS_OPENURL, 1, ( LPARAM )"https://secure.xfire.com/lost_password/" ); + return TRUE; + } + + if ((LOWORD(wParam) == 19901 || LOWORD(wParam) == 25466 || LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == IDC_PIP || LOWORD(wParam) == IDC_PPORT || LOWORD(wParam) == IDC_NICK || 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[128]; + DBVARIANT dbv; + + GetDlgItemTextA(hwndDlg,IDC_LOGIN,login,sizeof(login)); + dbv.pszVal = NULL; + if (db_get(NULL,protocolname,"login",&dbv) || lstrcmpA(login, dbv.pszVal)) + reconnectRequired = 1; + if (dbv.pszVal != NULL) + db_free(&dbv); + + //den login lowercasen + int size = lstrlenA(login); + BOOL mustlowercase = FALSE; + for(int i = 0; i < size; i ++) + { + if (login[i]>='A'&&login[i]<='Z') + mustlowercase=TRUE; + login[i]=tolower(login[i]); + } + if (mustlowercase) { + MessageBox(NULL,TranslateT("The username must be lowercase, so it will be lowercased saved."),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION); + SetDlgItemTextA(hwndDlg,IDC_LOGIN,login); + } + + db_set_s(NULL,protocolname,"login",login); + db_set_s(NULL,protocolname,"Username",login); + + //nur wenn der nick erfolgreich übertragen wurde + GetDlgItemTextA(hwndDlg,IDC_NICK,login,sizeof(login)); + dbv.pszVal = NULL; + if (db_get(NULL,protocolname,"Nick",&dbv) || lstrcmpA(login, dbv.pszVal)) + { + if (CallService(XFIRE_SET_NICK,0,(WPARAM)login)) + db_set_s(NULL,protocolname,"Nick",login); + } + if (dbv.pszVal != NULL) + db_free(&dbv); + + GetDlgItemTextA(hwndDlg,IDC_PASSWORD,str,sizeof(str)); + dbv.pszVal = NULL; + if (db_get(NULL,protocolname,"password",&dbv) || lstrcmpA(str, dbv.pszVal)) + reconnectRequired=1; + if (dbv.pszVal != NULL) + db_free(&dbv); + db_set_s(NULL,protocolname,"password",str); + GetDlgItemTextA(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<size;i++) + { + if (!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id)) + { + db_set_b(NULL,protocolname,xfireconfigitems[i].dbentry,0); + xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[0]=1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[1]=1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[2]=0; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[3]=0x30; + } + else + { + xfireconfig[xfireconfigitems[i].xfireconfigid].wasset=0; + db_set_b(NULL,protocolname,xfireconfigitems[i].dbentry,1); + } + } + CallService(XFIRE_SEND_PREFS,0,0); + } + + //protocolversion wird autoamtisch vergeben + //GetDlgItemTextA(hwndDlg,IDC_PVER,str,sizeof(str)); + //db_set_b(NULL,protocolname,"protover",(char)atoi(str)); + + if (reconnectRequired) + MessageBox(hwndDlg,TranslateT("The changes you have made require you to reconnect to the XFire network before they take effect"),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION); + return TRUE; + } + + } + break; + } + } + return FALSE; +} + +static INT_PTR CALLBACK DlgProcOpts3(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: + { + TranslateDialogDefault(hwndDlg); + + hwndTree = GetDlgItem(hwndDlg, IDC_TREE); + + SetWindowLongPtr(hwndTree,GWL_STYLE,GetWindowLongPtr(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + + SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); + + SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Hidden" )); + SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Message box" )); + SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup" )); + + //scanalways + SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("No" )); + SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("On every start" )); + SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_ADDSTRING, 0, (LPARAM)TranslateT("Daily" )); + + SendDlgItemMessage( hwndDlg, IDC_SCANUPDATECB, CB_SETCURSEL, db_get_b(NULL,protocolname,"scanalways",0), 0); + + SendDlgItemMessage( hwndDlg, IDC_NOMSG, CB_SETCURSEL, nomsgboxsel[db_get_b(NULL,protocolname,"nomsgbox",0)], 0); + + /* Gruppen raussuchen */ + { + int gruppen_id=0; + char temp[8]; + DBVARIANT dbv; + + SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" )); + SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)TranslateT("<Root Group>" )); + + mir_snprintf(temp, SIZEOF(temp), "%d", gruppen_id); + while(!db_get_s(NULL,"CListGroups",temp,&dbv)) + { + gruppen_id++; + mir_snprintf(temp, SIZEOF(temp), "%d", gruppen_id); + + if (dbv.pszVal!=NULL) { + SendDlgItemMessageA( hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); + SendDlgItemMessageA( hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); + db_free(&dbv); + } + } + SendDlgItemMessage( hwndDlg, IDC_CLANGROUP, CB_SETCURSEL, db_get_b(NULL,protocolname,"mainclangroup",0), 0); + SendDlgItemMessage( hwndDlg, IDC_FOFGROUP, CB_SETCURSEL, db_get_b(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;i<size;i++) + { + tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; + tvis.item.iImage = -1; + tvis.item.stateMask = TVIS_EXPANDED; + tvis.item.state = TVIS_EXPANDED; + tvis.hParent = lastSec; + if ( mytree[i].parent ) { + tvis.hParent = NULL; + tvis.item.lParam = -1; + tvis.item.pszText = TranslateTS(mytree[i].name); + tvis.hParent = tvis.item.hItem = TreeView_InsertItem( hwndTree, &tvis ); + lastSec=tvis.hParent; + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + tvis.item.state = INDEXTOSTATEIMAGEMASK(0); + TreeView_SetItem( hwndTree, &tvis.item ); + } + else + { + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + tvis.item.state = INDEXTOSTATEIMAGEMASK(db_get_b(NULL,protocolname,mytree[i].dbentry,0)==1?2:1); + tvis.item.lParam = 0; + tvis.item.pszText = TranslateTS(mytree[i].name); + mytree[i].hitem=TreeView_InsertItem( hwndTree, &tvis ); + } + } + } + { + TVITEM tvi; + tvi.hItem = TreeView_GetRoot(hwndTree); + while ( tvi.hItem != NULL ) { + tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; + TreeView_GetItem(hwndTree, &tvi); + if ( tvi.lParam == -1 ) + TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK); + + tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); + } + } + + + ShowWindow(hwndTree, SW_SHOW); + + break; + + 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 (HIWORD(wParam) == CBN_SELCHANGE) + { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return 0; + } + + if ((LOWORD(wParam) == IDC_LOGIN || LOWORD(wParam) == 1013 || LOWORD(wParam) == 1015 || LOWORD(wParam) == 3 || LOWORD(wParam) == IDC_NICK || 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)->idFrom) + { + 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<sizeof(mytree)/sizeof(mytreeitem);i++) + { + TVITEM tvic; + if (mytree[i].parent==0) + { + tvic.hItem=mytree[i].hitem; + tvic.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; + + TreeView_GetItem(hwndTree, &tvic); + if ((( tvic.state & TVIS_STATEIMAGEMASK ) >> 12 == 2 )) + db_set_b(NULL,protocolname,mytree[i].dbentry,1); + else + db_set_b(NULL,protocolname,mytree[i].dbentry,0); + } + } + + db_set_b(NULL,protocolname,"nomsgbox",(BYTE)nomsgboxsel[SendDlgItemMessage(hwndDlg, IDC_NOMSG, CB_GETCURSEL, 0, 0)]); + + ccc=SendDlgItemMessage(hwndDlg, IDC_CLANGROUP, CB_GETCURSEL, 0, 0); + db_set_b(NULL,protocolname,"mainclangroup",(BYTE)ccc); + ccc=SendDlgItemMessage(hwndDlg, IDC_FOFGROUP, CB_GETCURSEL, 0, 0); + db_set_b(NULL,protocolname,"fofgroup",(BYTE)ccc); + ccc=SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_GETCURSEL, 0, 0); + db_set_b(NULL,protocolname,"scanalways",(BYTE)ccc); + + //protocolversion wird autoamtisch vergeben + //GetDlgItemTextA(hwndDlg,IDC_PVER,str,sizeof(str)); + //db_set_b(NULL,protocolname,"protover",(char)atoi(str)); + + if (reconnectRequired) MessageBox(hwndDlg,TranslateT("The changes you have made require you to reconnect to the XFire network before they take effect"),TranslateT("XFire Options"),MB_OK|MB_ICONINFORMATION); + return TRUE; + } + + } + break; + } + } + return FALSE; +} + +static INT_PTR 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); + + strcpy(inipath, XFireGetFoldersPath ("IniFile")); + 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; + } + + strcpy(inipath, XFireGetFoldersPath ("IconsFile")); + 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)); + + strcpy(inipath, XFireGetFoldersPath ("IniFile")); + SetDlgItemTextA(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 + { + SendDlgItemMessageA(hwndDlg, IDC_BLOCKUSER, LB_GETTEXT, sel, (LPARAM)temp); + SendDlgItemMessage(hwndDlg, IDC_BLOCKUSER, LB_DELETESTRING, sel, 0); + db_unset(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 INT_PTR CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + CheckDlgButton(hwndDlg,IDC_ENABLESTSMSG,db_get_b(NULL,protocolname,"autosetstatusmsg",0)); + CheckDlgButton(hwndDlg,IDC_CHGSTATUS,db_get_b(NULL,protocolname,"statuschgtype",0)); + CheckDlgButton(hwndDlg,IDC_DNDFIRST,db_get_b(NULL,protocolname,"dndfirst",0)); + if (!db_get(NULL,protocolname,"setstatusmsg",&dbv)) { + SetDlgItemTextA(hwndDlg,IDC_STATUSMSG,dbv.pszVal); + db_free(&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]; + + GetDlgItemTextA(hwndDlg,IDC_STATUSMSG,str,sizeof(str)); + db_set_s(NULL,protocolname, "setstatusmsg", str); + + db_set_b(NULL,protocolname, "autosetstatusmsg", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)); + db_set_b(NULL,protocolname, "statuschgtype", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CHGSTATUS)); + db_set_b(NULL,protocolname, "dndfirst", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DNDFIRST)); + + return TRUE; + } + + } + break; + } + } + return FALSE; +} + +static INT_PTR 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=db_get_w(NULL,protocolname,"foundgames",0); + char temp[XFIRE_MAXSIZEOFGAMENAME]; + for(int i=0;i<found;i++) + { + //id auslesen + mir_snprintf(temp, SIZEOF(temp), "gameid_%d", i); + int gameid=db_get_w(NULL,protocolname,temp,0); + //spielnamen auslesen + xgamelist.getGamename(gameid,temp,XFIRE_MAXSIZEOFGAMENAME); + //eintrag einfügen + int idx=SendDlgItemMessageA( (HWND)hwndDlg, IDC_LGAMELIST, LB_ADDSTRING, 0, (LPARAM)temp); + //id an das element übergeben + SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_SETITEMDATA, idx, gameid); + } + return TRUE; + } + case WM_COMMAND: + { + if (LOWORD(wParam)==IDC_REMOVE) + { + int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + + //was ausgewählt in der liste? + if (idx!=LB_ERR) { + //user fragen ob er das game wirklich löschen will + if (MessageBox(hwndDlg,TranslateT("Are you sure you want to remove this game?"),TranslateT("XFire Options"),MB_YESNO|MB_ICONQUESTION)==IDYES) { + //gameliste blocken + xgamelist.Block(TRUE); + //spielid auslesen + int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + //spiel per gameid entfernen + xgamelist.Removegame(gameid); + //db säubern + xgamelist.clearDatabase(TRUE); + //derzeitige gameliste in die datenbank eintragen + xgamelist.writeDatabase(); + //startmenu leeren + xgamelist.clearStartmenu(); + //startmenu neuerzeugen + xgamelist.createStartmenu(); + //gameliste unblocken + xgamelist.Block(FALSE); + //gamelist neu füllen + SendMessage(hwndDlg,WM_FILLGAMELIST,0,0); + //erstes vorauswählen + SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_SETCURSEL, 0, 0); + //liste refresh + SendMessage(hwndDlg,WM_COMMAND,MAKELONG(IDC_LGAMELIST,LBN_SELCHANGE),0); + } + } + else + MessageBox(hwndDlg,TranslateT("Please select a game."),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION); + + } + else + if (LOWORD(wParam)==IDC_ADDGAME) + { + //gameliste blocken + xgamelist.Block(TRUE); + //if (DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAME),hwndDlg,DlgAddGameProc)) { + AddGameDialog(hwndDlg); + //gameliste unblocken + xgamelist.Block(FALSE); + //gamelist neu füllen + SendMessage(hwndDlg,WM_FILLGAMELIST,0,0); + } + //copy gamelist to clipboard button entfernt + /*else if (LOWORD(wParam)==IDC_CREATETXTLIST) //gameliste als textform für debugging erstellen + { + //gameliste blocken + xgamelist.Block(TRUE); + + //alle games durchgehen + Xfire_game* nextgame; + //output string + char* out=new char[10]; + xgamelist.setString("Xfire-gamelist:\r\n",&out); + while(xgamelist.getnextGame(&nextgame)) + { + if (nextgame->name) + { + 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,TranslateT("Error: unknown game ID."),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION); + //gameliste unblocken + xgamelist.Block(FALSE); + //gamelist neu füllen + SendMessage(hwndDlg,WM_FILLGAMELIST,0,0); + } + else + MessageBox(hwndDlg,TranslateT("Please select a game."),TranslateT("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]; + SendDlgItemMessageA(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text); + SetDlgItemTextA(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]=""; + mir_snprintf(temp, SIZEOF(temp), "gameskip_%d", gameid); + CheckDlgButton(hwndDlg,IDC_DONTDETECT,db_get_b(NULL,protocolname,temp,0)); + mir_snprintf(temp, SIZEOF(temp), "gamenostatus_%d", gameid); + CheckDlgButton(hwndDlg,IDC_NOSTATUSMSG,db_get_b(NULL,protocolname,temp,0)); + mir_snprintf(temp, SIZEOF(temp), "notinstartmenu_%d", gameid); + CheckDlgButton(hwndDlg,IDC_NOTINSTARTMENU,db_get_b(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); + mir_snprintf(temp, SIZEOF(temp), "gameextraparams_%d", gameid); + DBVARIANT dbv; + if (!db_get(NULL,protocolname,temp,&dbv)) + { + SetDlgItemTextA(hwndDlg,IDC_EXTRAPARAMS,dbv.pszVal); + db_free(&dbv); + } + else + SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,_T("")); + } + else + { + EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); + SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,TranslateT("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]=""; + GetDlgItemTextA(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,TranslateT("Configuration saved!")); + } + else + { + SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Game not found?!")); + } + } + else + { + SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Game not found?!")); + } + + //gamelist unblocken + xgamelist.Block(FALSE); + } + } + break; + } + + case WM_NOTIFY: + { + break; + } + } + return FALSE; +} + +int OptInit(WPARAM wParam,LPARAM) +{ + ghwndDlg2 = NULL; + + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.hInstance = hinstance; + odp.ptszTitle = LPGENT("XFire"); + odp.ptszGroup = LPGENT("Network"); + odp.flags = ODPF_BOLDGROUPS| ODPF_TCHAR; + + odp.pfnDlgProc = DlgProcOpts2; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTLOGIN); + odp.ptszTab = LPGENT("Account"); + Options_AddPage(wParam, &odp); + + odp.pfnDlgProc = DlgProcOpts3; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT); + odp.ptszTab = LPGENT("Features"); + Options_AddPage(wParam, &odp); + + odp.pfnDlgProc = DlgProcOpts4; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT2); + odp.ptszTab = LPGENT("Blocklist / Games"); + Options_AddPage(wParam, &odp); + + odp.pfnDlgProc = DlgProcOpts5; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT3); + odp.ptszTab = LPGENT("StatusMsg"); + Options_AddPage(wParam, &odp); + + odp.pfnDlgProc = DlgProcOpts6; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTFEAT4); + odp.ptszTab = LPGENT("Games"); + Options_AddPage(wParam, &odp); + return 0; }
\ No newline at end of file diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index f05b35f91e..5418a51f7b 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -1,1057 +1,1061 @@ -/*
- * 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 <winsock2.h>
-#include "tools.h"
-#include "xdebug.h"
-
-extern HANDLE hNetlib;
-//convert buf to hexstring
-/*char* tohex(unsigned char*buf,int size) {
- static char buffer[1024*10]="";
-
- strcpy(buffer,"");
-
- for(int i=0;i<size;i++)
- {
- if (i%16==0&&i!=0)
- mir_snprintf(buffer, SIZEOF(buffer), "%s\n%02x ", buffer, buf[i]);
- else
- mir_snprintf(buffer, SIZEOF(buffer), "%s%02x ", buffer, buf[i]);
- }
-
- return buffer;
-}*/
-
-//von icqproto kopiert
-void EnableDlgItem(HWND hwndDlg, UINT control, int state)
-{
- EnableWindow(GetDlgItem(hwndDlg, control), state);
-}
-
-
-//eigene string replace funktion, da die von der std:string klasse immer abstürzt
-BOOL str_replace(char*src,char*find,char*rep)
-{
- string strpath = src;
- int pos = strpath.find(find);
-
- if (pos>-1)
- {
- char *temp=new char[strlen(src)+strlen(rep)+1];
-
- strcpy(temp,src);
- *(temp+pos)=0;
-
- strcat(temp,rep);
- strcat(temp,(src+pos+strlen(find)));
- strcpy(src,temp);
-
- delete temp;
-
- return TRUE;
- }
- return FALSE;
-}
-
-/* popup darstellen */
-int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hicon)
-{
- static signed char bUsePopups = -1;
- static BOOL bIconsNotLoaded = TRUE;
-
- static HICON hicNotify = NULL, hicWarning = NULL, hicError = NULL;
-
- if ((uType & MB_TYPEMASK) == MB_OK) {
- POPUPDATAT ppd = { 0 };
- ppd.lchIcon = hicon;
-
- if (bIconsNotLoaded) {
- hicNotify = Skin_GetIcon("popup_notify");
- hicWarning = Skin_GetIcon("popup_warning");
- hicError = Skin_GetIcon("popup_error");
- bIconsNotLoaded = FALSE;
- }
-
- lstrcpyn(ppd.lptzContactName, _A2T(lpCaption), SIZEOF(ppd.lptzContactName));
- lstrcpyn(ppd.lptzText, _A2T(lpText), SIZEOF(ppd.lptzText));
-
- if ((uType & MB_ICONMASK) == MB_ICONSTOP) {
- ppd.lchIcon = hicError;
- ppd.colorBack = RGB(191,0,0);
- ppd.colorText = RGB(255,245,225);
- }
- else if ((uType & MB_ICONMASK) == MB_ICONWARNING) {
- ppd.lchIcon = hicWarning;
- ppd.colorBack = RGB(210,210,150);
- ppd.colorText = RGB(0,0,0);
- }
- else {
- ppd.lchIcon = hicNotify;
- ppd.colorBack = RGB(230,230,230);
- ppd.colorText = RGB(0,0,0);
- }
-
- PUAddPopupT(&ppd);
- }
-
- return IDOK;
-}
-
-char*menuitemtext(char*mtext)
-{
- static char temp[256]="";
- int anz=0;
- int j=0;
-
- if (!mtext)
- return NULL;
-
- int size=strlen(mtext);
-
- if (!size || size>255)
- return mtext;
-
- //alle & zeichen zählen
- for(int i=0;i<size;i++,j++)
- {
- temp[j]=mtext[i];
- if (mtext[i]=='&')
- {
- j++;
- temp[j]='&';
- }
- }
- //terminieren
- temp[j]=0;
-
- return temp;
-}
-
-void Message(LPVOID msg)
-{
- switch(db_get_b(NULL,protocolname,"nomsgbox",0))
- {
- case 1:
- return;
- case 2:
- displayPopup(NULL, (LPCSTR)msg, PLUGIN_TITLE, MB_OK);
- return;
- }
-
- MSGBOXPARAMSA mbp;
- mbp.cbSize=sizeof(mbp);
- mbp.hwndOwner=NULL;
- mbp.hInstance=hinstance;
- mbp.lpszText=(char*)msg;
- mbp.lpszCaption = PLUGIN_TITLE;
- mbp.dwStyle=MB_USERICON;
- mbp.lpszIcon=MAKEINTRESOURCEA(IDI_TM);
- mbp.dwContextHelpId=NULL;
- mbp.lpfnMsgBoxCallback=NULL;
- mbp.dwLanguageId=LANG_ENGLISH;
- MessageBoxIndirectA(&mbp);
- //MessageBoxA(0,(char*)msg,PLUGIN_TITLE,MB_OK|MB_ICONINFORMATION);
-}
-
-void MessageE(LPVOID msg)
-{
- static BOOL already=FALSE;
- switch(db_get_b(NULL,protocolname,"nomsgbox",0))
- {
- case 0:
- if (!already)
- {
- already=TRUE; //keine doppelte fehlernachrichten
- Message(msg);
- already=FALSE;
- }
- break;
- case 2:
- displayPopup(NULL, (LPCSTR)msg, PLUGIN_TITLE, MB_OK | MB_ICONSTOP);
- break;
- }
-}
-
-//funktion soll pfad erkennen und zurückgeben
-char* GetLaunchPath(char*launch)
-{
- static char temp[XFIRE_MAX_STATIC_STRING_LEN]="";
- char find[]=".exe "; //gesucht wird
- char * p = temp;
- char * f = find;
-
- if (launch==NULL)
- return temp;
-
- strcpy(temp,launch);
-
- while(*p!=0&&*f!=0)
- {
- if (tolower(*p)==*f)
- {
- f++;
- }
- else
- f=find;
-
- p++;
- }
-
- if (*f==0)
- {
- *p=0;
- }
- else
- return temp;
-
- if (strrchr(temp,'\\'))
- {
- *(strrchr(temp,'\\'))=0;
- }
-
- return temp;
-}
-//roll bits, vllt ein tickschneller als die funktionen von winsock
-unsigned short r(unsigned short data)
-{
- #if defined(_WIN64)
- return ((data & 0xFF) << 8) + (data >> 8);
- #else
- _asm {
- mov ax,data
- rol ax,8
- mov data,ax
- }
- return data;
- #endif
-}
-
-//simple und hoffetnlich schnelle teamspeakdetection
-BOOL FindTeamSpeak(DWORD*pid,int*vid) {
- BOOL found=FALSE;
- if (pid==NULL)
- return FALSE;
-
- HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
- PROCESSENTRY32* processInfo = new PROCESSENTRY32;
- processInfo->dwSize = sizeof ( PROCESSENTRY32);
-
-// XFireLog("Scanning for voiceprograms...");
-
-
- while ( Process32Next ( hSnapShot,processInfo ) != FALSE)
- {
- if (processInfo->th32ProcessID!=0) {
- int size=_tcslen(processInfo->szExeFile);
-
- if (size==13)
- {
- if ((processInfo->szExeFile[0]=='T'||processInfo->szExeFile[0]=='t')&&
- processInfo->szExeFile[1]=='e'&&
- processInfo->szExeFile[2]=='a'&&
- processInfo->szExeFile[3]=='m'&&
- processInfo->szExeFile[4]=='S'&&
- processInfo->szExeFile[5]=='p'&&
- processInfo->szExeFile[6]=='e'&&
- processInfo->szExeFile[7]=='a'&&
- processInfo->szExeFile[8]=='k')
- {
- *pid=processInfo->th32ProcessID;
- found=TRUE;
- *vid=32;
- break;
- }
- }
- else if (size==12)
- {
- if ((processInfo->szExeFile[0]=='V'||processInfo->szExeFile[0]=='v')&&
- processInfo->szExeFile[1]=='e'&&
- processInfo->szExeFile[2]=='n'&&
- processInfo->szExeFile[3]=='t'&&
- processInfo->szExeFile[4]=='r'&&
- processInfo->szExeFile[5]=='i'&&
- processInfo->szExeFile[6]=='l'&&
- processInfo->szExeFile[7]=='o')
- {
- *pid=processInfo->th32ProcessID;
- found=TRUE;
- *vid=33;
- break;
- }
- }
- else if (size==10)
- {
- if ((processInfo->szExeFile[0]=='m'||processInfo->szExeFile[0]=='M')&&
- processInfo->szExeFile[1]=='u'&&
- processInfo->szExeFile[2]=='m'&&
- processInfo->szExeFile[3]=='b'&&
- processInfo->szExeFile[4]=='l'&&
- processInfo->szExeFile[5]=='e')
- {
- *pid=processInfo->th32ProcessID;
- found=TRUE;
- *vid=34;
- break;
- }
- }
- }
- }
- CloseHandle ( hSnapShot);
- return found;
-}
-
-#include <vector>
-
-#define maxuppackets 4
-
-//funktion liefer ip/port einer verbindung
-BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port)
-{
- static std::vector<int> localport;
- static const int hdrInclude = 1;
- static int lastip=0;
- static int lastport=0;
- static int lastpid=0;
-
- //DUMP("***Suche IP/Port***","");
-
- if (pid!=lastpid)
- {
- lastip=lastport=0;
- lastpid=pid;
- }
-
- DWORD size=0;
- MIB_UDPTABLE_OWNER_PID * ptab=NULL;
-
- GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
- ptab=(MIB_UDPTABLE_OWNER_PID*)malloc(size);
- int ret = GetExtendedUdpTable(ptab, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
- //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen
- if (ret==NO_ERROR)
- {
- BOOL notfound=TRUE;
- for(unsigned int i=0;i<ptab->dwNumEntries;i++)
- {
- if (ptab->table[i].dwOwningPid==pid) //spiel gefunden
- {
- localport.push_back(ptab->table[i].dwLocalPort);
- //DUMP("Localport: %d",ptab->table[i].dwLocalPort);
- //localport=; //port wird gesichert
- //break; //wir brauchen nicht mehr suchen
- notfound=FALSE;
- }
- }
- if (notfound) //kein port gefunden
- {
- //DUMP("Kein Localport gefunden","");
- XFireLog("no local port found");
- return FALSE; //dann erstmal schluss
- }
- }
- else
- {
- XFireLog("GetExtendedUdpTable error!");
- return FALSE;
- }
-
- if (ptab) delete ptab; //speicher frei machn
-
-
- //socker erstellen
- SOCKET s;
- s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
- if (s==INVALID_SOCKET)
- {
- //DUMP("Kann Rawsocket nicht erstellen. Error: %d",WSAGetLastError());
- XFireLog("unable to create raw socket %d",WSAGetLastError());
- closesocket(s);
- return FALSE;
- }
-
- static struct sockaddr_in msockaddr;
- memset(&msockaddr,0,sizeof(msockaddr));
- msockaddr.sin_addr.s_addr = localaddr;
- msockaddr.sin_family = AF_INET;
- msockaddr.sin_port = 0;
-
- //socket an nw binden
- if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR)
- {
- //DUMP("Kann Rawsocket nicht binden. Error: %d",WSAGetLastError());
- XFireLog("unable to bind raw socket %d",WSAGetLastError());
- closesocket(s);
- return FALSE;
- }
-
- //wir wollen alles was da reinkommt haben
- static int I = 1;
- static DWORD b;
- if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR)
- {
- //DUMP("IOCTL Error","");
- /*closesocket(s);
- return FALSE;*/
- XFireLog("IOCTL error %d",WSAGetLastError());
- //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen
- }
-
- //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt
- //DUMP("timeout>>>","");
- static int timeout=200;
- if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout) == SOCKET_ERROR))
- {
- XFireLog("setsockopt(SO_RCVTIMEO) error %d",WSAGetLastError());
- }
-
- //updstruct, nur mit wichtigen sachen
- struct mpacket {
- unsigned char ipv;
- char dmp[11]; //dummy
- //srcip, serverip
- unsigned char ip1;
- unsigned char ip2;
- unsigned char ip3;
- unsigned char ip4;
- //unsere nw
- unsigned int ipdst;
- char temp[1024];
- };
- struct mpacket2 {
- unsigned char ipv;
- char dmp[11]; //dummy
- //srcip, serverip
- unsigned long srcip;
- //server ip
- unsigned char ip1;
- unsigned char ip2;
- unsigned char ip3;
- unsigned char ip4;
- char temp[1024];
- };
- struct udp {
- //srcport
- u_short srcport;
- //dstport
- u_short dstport;
- };
-
- mpacket temp={0}; //empfamngsbuffer
- udp * temp2;
- char * temp3;
- mpacket2 * temp4;
-
- for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht
- {
- int msize=recv(s,(char*)&temp,sizeof(mpacket),0);
- if (msize) //empfangen
- {
- /*DUMP("Packet empfangen","");
- DUMP("Dump Full packet##############","");
- DUMP(tohex((unsigned char*)&temp,msize),"");
- DUMP("Dump Full packet##############","");
-
- DUMP("Headersize: %d",(temp.ipv & 0x0f)*4);*/
-
- temp3=(char*)&temp;
- temp3+=(temp.ipv & 0x0f)*4;
- temp2=(udp*)temp3;
- temp4=(mpacket2*)&temp;
-
- /*DUMP("Dump Udp##############","");
- DUMP(tohex((unsigned char*)temp2,sizeof(udp)),"");
- DUMP("Dump Udp##############","");*/
-
-
- for(unsigned int i = 0 ; i < localport.size() ; i++)
- {
- //DUMP("destport %d ==",temp2->dstport);
- //DUMP("== %d",localport.at(i));
- if (temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels
- {
- *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln
- *ip1=temp.ip1;
- *ip2=temp.ip2;
- *ip3=temp.ip3;
- *ip4=temp.ip4;
- closesocket(s); //socket zumachn
-
- //DUMP("SourceIP %d",temp4->srcip);
- //DUMP("SourcePort %d",temp2->srcport);
- if (lastip!=temp4->srcip||temp2->srcport!=lastport)
- {
- lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden
- lastip=temp4->srcip;
- closesocket(s);
- //DUMP("IP gefunden","");
- XFireLog("got ip!");
- return TRUE;
- }
-
- XFireLog("no serverip found!");
- return FALSE;
- }
- /* else if (temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets
- {
- *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln
- *ip1=temp4->ip1;
- *ip2=temp4->ip2;
- *ip3=temp4->ip3;
- *ip4=temp4->ip4;
- closesocket(s); //socket zumachn
- return TRUE;
- }*/
- }
- }
- else if (msize==SOCKET_ERROR)
- {
- XFireLog("recv() error %d",WSAGetLastError());
- }
- }
- closesocket(s); //socket zumachn
- lastip=0;
- lastport=0;
- return TRUE;
-}
-
-//funktion liefert ip/port einer verbindung, dupliziert für teamspeak/ventrilo, wegen static vals
-//TODO: eventuell umbauen, damit es für beide genutzt werden kann
-BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port)
-{
- static std::vector<int> localport;
- static const int hdrInclude = 1;
- static int lastip=0;
- static int lastpid=0;
- static int lastport=0;
-
- if (pid!=lastpid)
- {
- lastip=lastport=0;
- lastpid=pid;
- }
-
- DWORD size=0;
- MIB_UDPTABLE_OWNER_PID * ptab=NULL;
-
- GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
- ptab=(MIB_UDPTABLE_OWNER_PID*)malloc(size);
- int ret = GetExtendedUdpTable(ptab, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0);
- //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen
- if (ret==NO_ERROR)
- {
- BOOL notfound=TRUE;
- for(unsigned int i=0;i<ptab->dwNumEntries;i++)
- {
- if (ptab->table[i].dwOwningPid==pid) //spiel gefunden
- {
- localport.push_back(ptab->table[i].dwLocalPort);
- //localport=; //port wird gesichert
- //break; //wir brauchen nicht mehr suchen
- notfound=FALSE;
- }
- }
- if (notfound) //kein port gefunden
- {
- if (lastip!=0)
- {
- lastip=0;
- lastport=0;
- return TRUE;
- }
- return FALSE; //dann erstmal schluss
- }
- }
- else
- return FALSE;
-
- if (ptab) delete ptab; //speicher frei machn
-
-
- //socker erstellen
- SOCKET s;
- s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
-
- static struct sockaddr_in msockaddr;
- memset(&msockaddr,0,sizeof(msockaddr));
- msockaddr.sin_addr.s_addr = localaddr;
- msockaddr.sin_family = AF_INET;
- msockaddr.sin_port = 0;
-
- //socket an nw binden
- if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR)
- {
- closesocket(s);
- return FALSE;
- }
-
- //wir wollen alles was da reinkommt haben
- static int I = 1;
- DWORD b;
- if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR)
- {
- /*closesocket(s);
- return FALSE;*/
- //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen
- }
-
- //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt
- //DUMP("timeout>>>","");
- static int timeout=200;
- setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout));
-
- //updstruct, nur mit wichtigen sachen
- struct mpacket {
- unsigned char ipv;
- char dmp[11]; //dummy
- //srcip, serverip
- unsigned char ip1;
- unsigned char ip2;
- unsigned char ip3;
- unsigned char ip4;
- //unsere nw
- unsigned int ipdst;
- char temp[1024];
- };
- struct mpacket2 {
- unsigned char ipv;
- char dmp[11]; //dummy
- //srcip, serverip
- unsigned long srcip;
- //server ip
- unsigned char ip1;
- unsigned char ip2;
- unsigned char ip3;
- unsigned char ip4;
- char temp[1024];
- };
- struct udp {
- //srcport
- u_short srcport;
- //dstport
- u_short dstport;
- };
-
- mpacket temp={0}; //empfamngsbuffer
- udp * temp2;
- char * temp3;
- mpacket2 * temp4;
-
- for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht
- {
- int msize=recv(s,(char*)&temp,sizeof(mpacket),0);
- if (msize) //empfangen
- {
- temp3=(char*)&temp;
- temp3+=(temp.ipv & 0x0f)*4;
- temp2=(udp*)temp3;
- temp4=(mpacket2*)&temp;
-
- for(unsigned int i = 0 ; i < localport.size() ; i++)
- if (temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels
- {
- *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln
- *ip1=temp.ip1;
- *ip2=temp.ip2;
- *ip3=temp.ip3;
- *ip4=temp.ip4;
- closesocket(s); //socket zumachn
-
- if (lastip!=temp4->srcip||temp2->srcport!=lastport)
- {
- lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden
- lastip=temp4->srcip;
- return TRUE;
- }
-
- return FALSE;
- }
- /* else if (temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets
- {
- *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln
- *ip1=temp4->ip1;
- *ip2=temp4->ip2;
- *ip3=temp4->ip3;
- *ip4=temp4->ip4;
- closesocket(s); //socket zumachn
- return TRUE;
- }*/
- }
- }
- closesocket(s); //socket zumachn
- lastip=0;
- lastport=0;
- return TRUE;
-}
-
-
-char * getItem(char * string,char delim,int count)
-{
- static char item[255];
- char i=0;
-
- while(*string!='\0'&&count>0)
- {
- if (*string==delim)
- {
- item[i]=0;
- i=0;
- count--;
- string++;
- }
- else {
- item[i]=*string;
- i++;
- string++;
- }
- }
- if (*string=='\0')
- item[i]=0;
- if (count>1)
- item[0]=0;
-
- for(unsigned int i=0;i<strlen(item);i++)
- {
- item[i]=tolower(item[i]);
- }
-
- return item;
-}
-
-// soll commandline der spiele prüfen
-//
-// TRUE bedeutet, entweder ok, oder konnte wegen systemfehler nicht geprüft werden
-// FALSE bedeutet beinhaltet nicht das, was es soll
-//
-// get process comamndline quelle hier:
-// http://forum.sysinternals.com/forum_posts.asp?TID=6510
-#define cb 1024
-
-pZwQueryInformationProcess _ZwQueryInformationProcess = NULL;
-//pZwClose _ZwClose = NULL;
-pZwReadVirtualMemory _ZwReadVirtualMemory = NULL;
-
-BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain)
-{
- WCHAR * buffer;
- char * buffer2;
- PPEB peb = NULL;
- PPROCESS_PARAMETERS proc_params = NULL;
- PVOID UserPool = (PVOID)LocalAlloc(LPTR, 8192);
- PROCESS_BASIC_INFORMATION ProcessInfo;
-
- //strings leer abbruch
- if (!mustcontain&&!mustnotcontain)
- return TRUE;
-
- //prüfe und lade nötige funktionen
- if (_ZwQueryInformationProcess==NULL)
- {
- _ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwQueryInformationProcess");
- if (_ZwQueryInformationProcess==NULL)
- {
- return TRUE;
- }
- }
- if (_ZwReadVirtualMemory==NULL)
- {
- _ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwReadVirtualMemory");
- if (_ZwReadVirtualMemory==NULL)
- {
- return TRUE;
- }
- }
-
- //commandline bekommen, siehe link oben
- ULONG rc = _ZwQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessInfo,sizeof(ProcessInfo),NULL);
-
- rc = _ZwReadVirtualMemory(hProcess,ProcessInfo.PebBaseAddress, UserPool, sizeof(PEB), NULL);
-
- peb = (PPEB)UserPool;
- rc = _ZwReadVirtualMemory(hProcess,peb->ProcessParameters,UserPool,sizeof(PROCESS_PARAMETERS),NULL);
-
- proc_params = (PPROCESS_PARAMETERS)UserPool;
- ULONG uSize = 0;
- LPVOID pBaseAddress = NULL;
-
- uSize = proc_params->CommandLine.Length;
- pBaseAddress = proc_params->CommandLine.Buffer;
-
- //keine commandline?!
- if (uSize==0||pBaseAddress==NULL)
- {
- LocalFree(UserPool);
- return FALSE;
- }
-
- buffer=(WCHAR*)new char[uSize];
-
- rc = _ZwReadVirtualMemory(hProcess, pBaseAddress, buffer, uSize, NULL);
-
- //in ansi umwandeln
- int correctsize=WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, NULL, 0, NULL, NULL);
-
- if (correctsize==0)
- {
- LocalFree(UserPool);
- return FALSE;
- }
-
- buffer2=new char[correctsize];
- WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, buffer2,correctsize,NULL,NULL);
- buffer2[correctsize-1]=0;
-
-
- for(unsigned int i=0;i<strlen(buffer2);i++)
- {
- buffer2[i]=tolower(buffer2[i]);
- }
-
- //lowercase mustcontain/mustnotcontain
- if (mustcontain)
- for(unsigned int i=0;i<strlen(mustcontain);i++)
- {
- mustcontain[i]=tolower(mustcontain[i]);
- }
- if (mustnotcontain)
- for(unsigned int i=0;i<strlen(mustnotcontain);i++)
- {
- mustnotcontain[i]=tolower(mustnotcontain[i]);
- }
-
- string cmdline=buffer2;
-
- if (mustcontain)
- if (cmdline.find(mustcontain)!=string::npos)
- {
- delete[] buffer;
- delete[] buffer2;
- LocalFree(UserPool);
- return TRUE;
- }
- else
- {
- delete[] buffer;
- delete[] buffer2;
- LocalFree(UserPool);
- return FALSE;
- }
-
- int count=1;
- if (mustnotcontain)
- {
- char*str=getItem(mustnotcontain,';',count);
- do {
- if (cmdline.find(str)!=string::npos)
- {
- delete[] buffer;
- delete[] buffer2;
- LocalFree(UserPool);
- return FALSE;
- }
- count++;
- str=getItem(mustnotcontain,';',count);
- }
- while(*str!=0);
- }
-
- //_ZwClose(hProcess);
- LocalFree(UserPool);
- delete[] buffer;
- delete[] buffer2;
-
- return TRUE;
-}
-
-#define RECV_BUFFER_SIZE 6144
-
-BOOL CheckWWWContent(char*address) {
- Netlib_Logf(hNetlib,"Check Url %s ...",address);
-
- //netlib request
- NETLIBHTTPREQUEST nlhr={0};
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_HEAD;
- nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
- nlhr.szUrl = address;
-
- NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
-
- if (nlhrReply) {
- //nicht auf dem server
- Netlib_Logf(hNetlib,"Resultcode %d ...",nlhrReply->resultCode);
- if (nlhrReply->resultCode != 200) {
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- return FALSE;
- }
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- }
- else
- return FALSE;
-
- return TRUE;
-}
-
-
-BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf,unsigned int* size) {
- if (dontoverwrite==TRUE)
- {
- if (GetFileAttributesA(filename)!=0xFFFFFFFF)
- {
- Netlib_Logf(hNetlib,"%s already exists, no overwrite.",filename);
- return TRUE;
- }
- }
- Netlib_Logf(hNetlib,"Download Url %s ...",address);
-
- //netlib request
- NETLIBHTTPREQUEST nlhr={0};
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_GET;
- nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
- nlhr.szUrl = address;
-
- NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
-
- if (nlhrReply) {
- //nicht auf dem server
- if (nlhrReply->resultCode != 200) {
- Netlib_Logf(hNetlib,"Bad statuscode: %d",nlhrReply->resultCode);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- return FALSE;
- }
- //keine daten für mich
- else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL)
- {
- Netlib_Logf(hNetlib,"No data received.");
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- return FALSE;
- }
- else
- {
- if (tobuf==NULL)
- {
- FILE * f = fopen(filename,"wb");
- if (f==NULL)
- {
- Netlib_Logf(hNetlib,"Cannot open %s for binary write mode.",filename);
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- return FALSE;
- }
- fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f);
- fclose(f);
- }
- else
- {
- if (*tobuf==NULL)
- {
- *tobuf=new char[nlhrReply->dataLength+1];
- memcpy_s(*tobuf,nlhrReply->dataLength,nlhrReply->pData,nlhrReply->dataLength);
- //0 terminieren
- (*tobuf)[nlhrReply->dataLength]=0;
- //größe zurückliefern, wenn gewollt
- if (size)
- *size=nlhrReply->dataLength+1;
- }
- }
- }
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
- }
- else
- {
- Netlib_Logf(hNetlib,"No valid Netlib Request.",filename);
- return FALSE;
- }
- return TRUE;
-}
-//eigener www downloader, da winet exceptions erzeugt
-BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite) {
- char add[1024]="http://";
- strcat(add,host);
- strcat(add,request);
-
- return GetWWWContent2(add,filename,dontoverwrite);
-}
-
-unsigned int getfilesize(char*path)
-{
- FILE *f=fopen(path,"rb");
- if (f==NULL)
- return 0;
- fseek (f, 0, SEEK_END);
- int size=ftell (f);
- fclose (f);
- return size;
-}
-
-//funktion soll erst in der userini suchen, danach in der xfire_games.ini
-DWORD xfire_GetPrivateProfileString(__in LPCSTR lpAppName, __in LPCSTR lpKeyName, __in LPCSTR lpDefault, __out LPSTR lpReturnedString, __in DWORD nSize, __in LPCSTR lpFileName) {
- //xfire_games.ini
- int size=strlen(lpFileName);
- if (size>15)
- {
- char*file=(char*)lpFileName;
- int ret=0;
- *(file+size-14)='u';
- *(file+size-13)='s';
- *(file+size-12)='e';
- *(file+size-11)='r';
- ret = GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
- if (ret)
- {
- return ret;
- }
- else
- {
- *(file+size-14)='f';
- *(file+size-13)='i';
- *(file+size-12)='r';
- *(file+size-11)='e';
- return GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
- }
- }
- return GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName);
-}
-
-
-BOOL mySleep(int ms,HANDLE evt) {
- switch(WaitForSingleObject(evt,ms))
- {
- case WAIT_TIMEOUT:
- return FALSE;
- case WAIT_ABANDONED:
- //MessageBoxA(NULL,"Abbruch","Abbruch",0);
- return TRUE;
- default:
- return TRUE;
- }
-
- return FALSE;
+/* + * 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 <winsock2.h> +#include "tools.h" +#include "xdebug.h" + +extern HANDLE hNetlib; +//convert buf to hexstring +/*char* tohex(unsigned char*buf,int size) { + static char buffer[1024*10]=""; + + strcpy(buffer,""); + + for(int i=0;i<size;i++) + { + if (i%16==0&&i!=0) + mir_snprintf(buffer, SIZEOF(buffer), "%s\n%02x ", buffer, buf[i]); + else + mir_snprintf(buffer, SIZEOF(buffer), "%s%02x ", buffer, buf[i]); + } + + return buffer; +}*/ + +//von icqproto kopiert +void EnableDlgItem(HWND hwndDlg, UINT control, int state) +{ + EnableWindow(GetDlgItem(hwndDlg, control), state); +} + + +//eigene string replace funktion, da die von der std:string klasse immer abstürzt +BOOL str_replace(char*src,char*find,char*rep) +{ + string strpath = src; + int pos = strpath.find(find); + + if (pos>-1) + { + char *temp=new char[strlen(src)+strlen(rep)+1]; + + strcpy(temp,src); + *(temp+pos)=0; + + strcat(temp,rep); + strcat(temp,(src+pos+strlen(find))); + strcpy(src,temp); + + delete temp; + + return TRUE; + } + return FALSE; +} + +/* popup darstellen */ +int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hicon) +{ + static signed char bUsePopups = -1; + static BOOL bIconsNotLoaded = TRUE; + + static HICON hicNotify = NULL, hicWarning = NULL, hicError = NULL; + + if ((uType & MB_TYPEMASK) == MB_OK) { + POPUPDATAT ppd = { 0 }; + ppd.lchIcon = hicon; + + if (bIconsNotLoaded) { + hicNotify = Skin_GetIcon("popup_notify"); + hicWarning = Skin_GetIcon("popup_warning"); + hicError = Skin_GetIcon("popup_error"); + bIconsNotLoaded = FALSE; + } + + lstrcpyn(ppd.lptzContactName, _A2T(lpCaption), SIZEOF(ppd.lptzContactName)); + lstrcpyn(ppd.lptzText, _A2T(lpText), SIZEOF(ppd.lptzText)); + + if ((uType & MB_ICONMASK) == MB_ICONSTOP) { + ppd.lchIcon = hicError; + ppd.colorBack = RGB(191,0,0); + ppd.colorText = RGB(255,245,225); + } + else if ((uType & MB_ICONMASK) == MB_ICONWARNING) { + ppd.lchIcon = hicWarning; + ppd.colorBack = RGB(210,210,150); + ppd.colorText = RGB(0,0,0); + } + else { + ppd.lchIcon = hicNotify; + ppd.colorBack = RGB(230,230,230); + ppd.colorText = RGB(0,0,0); + } + + PUAddPopupT(&ppd); + } + + return IDOK; +} + +char*menuitemtext(char*mtext) +{ + static char temp[256]=""; + int anz=0; + int j=0; + + if (!mtext) + return NULL; + + int size=strlen(mtext); + + if (!size || size>255) + return mtext; + + //alle & zeichen zählen + for(int i=0;i<size;i++,j++) + { + temp[j]=mtext[i]; + if (mtext[i]=='&') + { + j++; + temp[j]='&'; + } + } + //terminieren + temp[j]=0; + + return temp; +} + +void Message(LPVOID msg) +{ + switch(db_get_b(NULL,protocolname,"nomsgbox",0)) + { + case 1: + return; + case 2: + displayPopup(NULL, (LPCSTR)msg, PLUGIN_TITLE, MB_OK); + return; + } + + MSGBOXPARAMSA mbp; + mbp.cbSize=sizeof(mbp); + mbp.hwndOwner=NULL; + mbp.hInstance=hinstance; + mbp.lpszText=(char*)msg; + mbp.lpszCaption = PLUGIN_TITLE; + mbp.dwStyle=MB_USERICON; + mbp.lpszIcon=MAKEINTRESOURCEA(IDI_TM); + mbp.dwContextHelpId=NULL; + mbp.lpfnMsgBoxCallback=NULL; + mbp.dwLanguageId=LANG_ENGLISH; + MessageBoxIndirectA(&mbp); + //MessageBoxA(0,(char*)msg,PLUGIN_TITLE,MB_OK|MB_ICONINFORMATION); +} + +void MessageE(LPVOID msg) +{ + static BOOL already=FALSE; + switch(db_get_b(NULL,protocolname,"nomsgbox",0)) + { + case 0: + if (!already) + { + already=TRUE; //keine doppelte fehlernachrichten + Message(msg); + already=FALSE; + } + break; + case 2: + displayPopup(NULL, (LPCSTR)msg, PLUGIN_TITLE, MB_OK | MB_ICONSTOP); + break; + } +} + +//funktion soll pfad erkennen und zurückgeben +char* GetLaunchPath(char*launch) +{ + static char temp[XFIRE_MAX_STATIC_STRING_LEN]=""; + char find[]=".exe "; //gesucht wird + char * p = temp; + char * f = find; + + if (launch==NULL) + return temp; + + strcpy(temp,launch); + + while(*p!=0&&*f!=0) + { + if (tolower(*p)==*f) + { + f++; + } + else + f=find; + + p++; + } + + if (*f==0) + { + *p=0; + } + else + return temp; + + if (strrchr(temp,'\\')) + { + *(strrchr(temp,'\\'))=0; + } + + return temp; +} +//roll bits, vllt ein tickschneller als die funktionen von winsock +unsigned short r(unsigned short data) +{ + #if defined(_WIN64) + return ((data & 0xFF) << 8) + (data >> 8); + #else + _asm { + mov ax,data + rol ax,8 + mov data,ax + } + return data; + #endif +} + +//simple und hoffetnlich schnelle teamspeakdetection +BOOL FindTeamSpeak(DWORD*pid,int*vid) { + BOOL found=FALSE; + if (pid==NULL) + return FALSE; + + HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0); + PROCESSENTRY32* processInfo = new PROCESSENTRY32; + processInfo->dwSize = sizeof ( PROCESSENTRY32); + +// XFireLog("Scanning for voiceprograms..."); + + + while ( Process32Next ( hSnapShot,processInfo ) != FALSE) + { + if (processInfo->th32ProcessID!=0) { + int size=_tcslen(processInfo->szExeFile); + + if (size==13) + { + if ((processInfo->szExeFile[0]=='T'||processInfo->szExeFile[0]=='t')&& + processInfo->szExeFile[1]=='e'&& + processInfo->szExeFile[2]=='a'&& + processInfo->szExeFile[3]=='m'&& + processInfo->szExeFile[4]=='S'&& + processInfo->szExeFile[5]=='p'&& + processInfo->szExeFile[6]=='e'&& + processInfo->szExeFile[7]=='a'&& + processInfo->szExeFile[8]=='k') + { + *pid=processInfo->th32ProcessID; + found=TRUE; + *vid=32; + break; + } + } + else if (size==12) + { + if ((processInfo->szExeFile[0]=='V'||processInfo->szExeFile[0]=='v')&& + processInfo->szExeFile[1]=='e'&& + processInfo->szExeFile[2]=='n'&& + processInfo->szExeFile[3]=='t'&& + processInfo->szExeFile[4]=='r'&& + processInfo->szExeFile[5]=='i'&& + processInfo->szExeFile[6]=='l'&& + processInfo->szExeFile[7]=='o') + { + *pid=processInfo->th32ProcessID; + found=TRUE; + *vid=33; + break; + } + } + else if (size==10) + { + if ((processInfo->szExeFile[0]=='m'||processInfo->szExeFile[0]=='M')&& + processInfo->szExeFile[1]=='u'&& + processInfo->szExeFile[2]=='m'&& + processInfo->szExeFile[3]=='b'&& + processInfo->szExeFile[4]=='l'&& + processInfo->szExeFile[5]=='e') + { + *pid=processInfo->th32ProcessID; + found=TRUE; + *vid=34; + break; + } + } + } + } + CloseHandle ( hSnapShot); + return found; +} + +#include <vector> + +#define maxuppackets 4 + +//funktion liefer ip/port einer verbindung +BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port) +{ + static std::vector<int> localport; + static const int hdrInclude = 1; + static int lastip=0; + static int lastport=0; + static int lastpid=0; + + //DUMP("***Suche IP/Port***",""); + + if (pid!=lastpid) + { + lastip=lastport=0; + lastpid=pid; + } + + DWORD size=0; + MIB_UDPTABLE_OWNER_PID *ptab; + + GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); + ptab = (MIB_UDPTABLE_OWNER_PID*)malloc(size); + if (ptab == NULL) + return FALSE; + int ret = GetExtendedUdpTable(ptab, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); + //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen + if (ret==NO_ERROR) + { + BOOL notfound=TRUE; + for(unsigned int i=0;i<ptab->dwNumEntries;i++) + { + if (ptab->table[i].dwOwningPid==pid) //spiel gefunden + { + localport.push_back(ptab->table[i].dwLocalPort); + //DUMP("Localport: %d",ptab->table[i].dwLocalPort); + //localport=; //port wird gesichert + //break; //wir brauchen nicht mehr suchen + notfound=FALSE; + } + } + if (notfound) //kein port gefunden + { + //DUMP("Kein Localport gefunden",""); + XFireLog("no local port found"); + return FALSE; //dann erstmal schluss + } + } + else + { + XFireLog("GetExtendedUdpTable error!"); + return FALSE; + } + + free(ptab); //speicher frei machn + + + //socker erstellen + SOCKET s; + s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); + if (s==INVALID_SOCKET) + { + //DUMP("Kann Rawsocket nicht erstellen. Error: %d",WSAGetLastError()); + XFireLog("unable to create raw socket %d",WSAGetLastError()); + closesocket(s); + return FALSE; + } + + static struct sockaddr_in msockaddr; + memset(&msockaddr,0,sizeof(msockaddr)); + msockaddr.sin_addr.s_addr = localaddr; + msockaddr.sin_family = AF_INET; + msockaddr.sin_port = 0; + + //socket an nw binden + if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) + { + //DUMP("Kann Rawsocket nicht binden. Error: %d",WSAGetLastError()); + XFireLog("unable to bind raw socket %d",WSAGetLastError()); + closesocket(s); + return FALSE; + } + + //wir wollen alles was da reinkommt haben + static int I = 1; + static DWORD b; + if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) + { + //DUMP("IOCTL Error",""); + /*closesocket(s); + return FALSE;*/ + XFireLog("IOCTL error %d",WSAGetLastError()); + //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + } + + //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt + //DUMP("timeout>>>",""); + static int timeout=200; + if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout) == SOCKET_ERROR)) + { + XFireLog("setsockopt(SO_RCVTIMEO) error %d",WSAGetLastError()); + } + + //updstruct, nur mit wichtigen sachen + struct mpacket { + unsigned char ipv; + char dmp[11]; //dummy + //srcip, serverip + unsigned char ip1; + unsigned char ip2; + unsigned char ip3; + unsigned char ip4; + //unsere nw + unsigned int ipdst; + char temp[1024]; + }; + struct mpacket2 { + unsigned char ipv; + char dmp[11]; //dummy + //srcip, serverip + unsigned long srcip; + //server ip + unsigned char ip1; + unsigned char ip2; + unsigned char ip3; + unsigned char ip4; + char temp[1024]; + }; + struct udp { + //srcport + u_short srcport; + //dstport + u_short dstport; + }; + + mpacket temp={0}; //empfamngsbuffer + udp * temp2; + char * temp3; + mpacket2 * temp4; + + for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht + { + int msize=recv(s,(char*)&temp,sizeof(mpacket),0); + if (msize) //empfangen + { + /*DUMP("Packet empfangen",""); + DUMP("Dump Full packet##############",""); + DUMP(tohex((unsigned char*)&temp,msize),""); + DUMP("Dump Full packet##############",""); + + DUMP("Headersize: %d",(temp.ipv & 0x0f)*4);*/ + + temp3=(char*)&temp; + temp3+=(temp.ipv & 0x0f)*4; + temp2=(udp*)temp3; + temp4=(mpacket2*)&temp; + + /*DUMP("Dump Udp##############",""); + DUMP(tohex((unsigned char*)temp2,sizeof(udp)),""); + DUMP("Dump Udp##############","");*/ + + + for(unsigned int i = 0 ; i < localport.size() ; i++) + { + //DUMP("destport %d ==",temp2->dstport); + //DUMP("== %d",localport.at(i)); + if (temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels + { + *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln + *ip1=temp.ip1; + *ip2=temp.ip2; + *ip3=temp.ip3; + *ip4=temp.ip4; + closesocket(s); //socket zumachn + + //DUMP("SourceIP %d",temp4->srcip); + //DUMP("SourcePort %d",temp2->srcport); + if (lastip!=temp4->srcip||temp2->srcport!=lastport) + { + lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden + lastip=temp4->srcip; + closesocket(s); + //DUMP("IP gefunden",""); + XFireLog("got ip!"); + return TRUE; + } + + XFireLog("no serverip found!"); + return FALSE; + } + /* else if (temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets + { + *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln + *ip1=temp4->ip1; + *ip2=temp4->ip2; + *ip3=temp4->ip3; + *ip4=temp4->ip4; + closesocket(s); //socket zumachn + return TRUE; + }*/ + } + } + else if (msize==SOCKET_ERROR) + { + XFireLog("recv() error %d",WSAGetLastError()); + } + } + closesocket(s); //socket zumachn + lastip=0; + lastport=0; + return TRUE; +} + +//funktion liefert ip/port einer verbindung, dupliziert für teamspeak/ventrilo, wegen static vals +//TODO: eventuell umbauen, damit es für beide genutzt werden kann +BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port) +{ + static std::vector<int> localport; + static const int hdrInclude = 1; + static int lastip=0; + static int lastpid=0; + static int lastport=0; + + if (pid!=lastpid) + { + lastip=lastport=0; + lastpid=pid; + } + + DWORD size=0; + MIB_UDPTABLE_OWNER_PID *ptab; + + GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); + ptab = (MIB_UDPTABLE_OWNER_PID*)malloc(size); + if (ptab == NULL) + return FALSE; + int ret = GetExtendedUdpTable(ptab, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); + //alle grad geöffnet updverb nach der pid vom spiel suchen, um an den port ranzukommen + if (ret==NO_ERROR) + { + BOOL notfound=TRUE; + for(unsigned int i=0;i<ptab->dwNumEntries;i++) + { + if (ptab->table[i].dwOwningPid==pid) //spiel gefunden + { + localport.push_back(ptab->table[i].dwLocalPort); + //localport=; //port wird gesichert + //break; //wir brauchen nicht mehr suchen + notfound=FALSE; + } + } + if (notfound) //kein port gefunden + { + if (lastip!=0) + { + lastip=0; + lastport=0; + return TRUE; + } + return FALSE; //dann erstmal schluss + } + } + else + return FALSE; + + free(ptab); //speicher frei machn + + + //socker erstellen + SOCKET s; + s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); + + static struct sockaddr_in msockaddr; + memset(&msockaddr,0,sizeof(msockaddr)); + msockaddr.sin_addr.s_addr = localaddr; + msockaddr.sin_family = AF_INET; + msockaddr.sin_port = 0; + + //socket an nw binden + if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) + { + closesocket(s); + return FALSE; + } + + //wir wollen alles was da reinkommt haben + static int I = 1; + DWORD b; + if (WSAIoctl(s, _WSAIOW(IOC_VENDOR,1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) + { + /*closesocket(s); + return FALSE;*/ + //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen + } + + //socket soll timeout auswerfen, wenn nix kommt, damit der gamethread nicht hängt + //DUMP("timeout>>>",""); + static int timeout=200; + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(char*)&timeout, sizeof(timeout)); + + //updstruct, nur mit wichtigen sachen + struct mpacket { + unsigned char ipv; + char dmp[11]; //dummy + //srcip, serverip + unsigned char ip1; + unsigned char ip2; + unsigned char ip3; + unsigned char ip4; + //unsere nw + unsigned int ipdst; + char temp[1024]; + }; + struct mpacket2 { + unsigned char ipv; + char dmp[11]; //dummy + //srcip, serverip + unsigned long srcip; + //server ip + unsigned char ip1; + unsigned char ip2; + unsigned char ip3; + unsigned char ip4; + char temp[1024]; + }; + struct udp { + //srcport + u_short srcport; + //dstport + u_short dstport; + }; + + mpacket temp={0}; //empfamngsbuffer + udp * temp2; + char * temp3; + mpacket2 * temp4; + + for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht + { + int msize=recv(s,(char*)&temp,sizeof(mpacket),0); + if (msize) //empfangen + { + temp3=(char*)&temp; + temp3+=(temp.ipv & 0x0f)*4; + temp2=(udp*)temp3; + temp4=(mpacket2*)&temp; + + for(unsigned int i = 0 ; i < localport.size() ; i++) + if (temp2->dstport==localport.at(i)/*FIX: für XP SP3 ->*/&&temp4->srcip!=localaddr) //ist das ziel des packets, gleich dem port des spiels + { + *port=r(temp2->srcport); //ja dann serverdaten an gamethread übermitteln + *ip1=temp.ip1; + *ip2=temp.ip2; + *ip3=temp.ip3; + *ip4=temp.ip4; + closesocket(s); //socket zumachn + + if (lastip!=temp4->srcip||temp2->srcport!=lastport) + { + lastport=temp2->srcport; //fixed port wechsel, damit dieser auch mitgetielt wird, wenn zb vorher nur serverinfos angefordert wurden + lastip=temp4->srcip; + return TRUE; + } + + return FALSE; + } + /* else if (temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets + { + *port=r(temp2->dstport); //ja dann serverdaten an gamethread übermitteln + *ip1=temp4->ip1; + *ip2=temp4->ip2; + *ip3=temp4->ip3; + *ip4=temp4->ip4; + closesocket(s); //socket zumachn + return TRUE; + }*/ + } + } + closesocket(s); //socket zumachn + lastip=0; + lastport=0; + return TRUE; +} + + +char * getItem(char * string,char delim,int count) +{ + static char item[255]; + char i=0; + + while(*string!='\0'&&count>0) + { + if (*string==delim) + { + item[i]=0; + i=0; + count--; + string++; + } + else { + item[i]=*string; + i++; + string++; + } + } + if (*string=='\0') + item[i]=0; + if (count>1) + item[0]=0; + + for(unsigned int i=0;i<strlen(item);i++) + { + item[i]=tolower(item[i]); + } + + return item; +} + +// soll commandline der spiele prüfen +// +// TRUE bedeutet, entweder ok, oder konnte wegen systemfehler nicht geprüft werden +// FALSE bedeutet beinhaltet nicht das, was es soll +// +// get process comamndline quelle hier: +// http://forum.sysinternals.com/forum_posts.asp?TID=6510 +#define cb 1024 + +pZwQueryInformationProcess _ZwQueryInformationProcess = NULL; +//pZwClose _ZwClose = NULL; +pZwReadVirtualMemory _ZwReadVirtualMemory = NULL; + +BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) +{ + WCHAR * buffer; + char * buffer2; + PPEB peb = NULL; + PPROCESS_PARAMETERS proc_params = NULL; + PVOID UserPool = (PVOID)LocalAlloc(LPTR, 8192); + PROCESS_BASIC_INFORMATION ProcessInfo; + + //strings leer abbruch + if (!mustcontain&&!mustnotcontain) + return TRUE; + + //prüfe und lade nötige funktionen + if (_ZwQueryInformationProcess==NULL) + { + _ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwQueryInformationProcess"); + if (_ZwQueryInformationProcess==NULL) + { + return TRUE; + } + } + if (_ZwReadVirtualMemory==NULL) + { + _ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwReadVirtualMemory"); + if (_ZwReadVirtualMemory==NULL) + { + return TRUE; + } + } + + //commandline bekommen, siehe link oben + ULONG rc = _ZwQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessInfo,sizeof(ProcessInfo),NULL); + + rc = _ZwReadVirtualMemory(hProcess,ProcessInfo.PebBaseAddress, UserPool, sizeof(PEB), NULL); + + peb = (PPEB)UserPool; + rc = _ZwReadVirtualMemory(hProcess,peb->ProcessParameters,UserPool,sizeof(PROCESS_PARAMETERS),NULL); + + proc_params = (PPROCESS_PARAMETERS)UserPool; + ULONG uSize = 0; + LPVOID pBaseAddress = NULL; + + uSize = proc_params->CommandLine.Length; + pBaseAddress = proc_params->CommandLine.Buffer; + + //keine commandline?! + if (uSize==0||pBaseAddress==NULL) + { + LocalFree(UserPool); + return FALSE; + } + + buffer=(WCHAR*)new char[uSize]; + + rc = _ZwReadVirtualMemory(hProcess, pBaseAddress, buffer, uSize, NULL); + + //in ansi umwandeln + int correctsize=WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, NULL, 0, NULL, NULL); + + if (correctsize==0) + { + LocalFree(UserPool); + return FALSE; + } + + buffer2=new char[correctsize]; + WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, buffer2,correctsize,NULL,NULL); + buffer2[correctsize-1]=0; + + + for(unsigned int i=0;i<strlen(buffer2);i++) + { + buffer2[i]=tolower(buffer2[i]); + } + + //lowercase mustcontain/mustnotcontain + if (mustcontain) + for(unsigned int i=0;i<strlen(mustcontain);i++) + { + mustcontain[i]=tolower(mustcontain[i]); + } + if (mustnotcontain) + for(unsigned int i=0;i<strlen(mustnotcontain);i++) + { + mustnotcontain[i]=tolower(mustnotcontain[i]); + } + + string cmdline=buffer2; + + if (mustcontain) + if (cmdline.find(mustcontain)!=string::npos) + { + delete[] buffer; + delete[] buffer2; + LocalFree(UserPool); + return TRUE; + } + else + { + delete[] buffer; + delete[] buffer2; + LocalFree(UserPool); + return FALSE; + } + + int count=1; + if (mustnotcontain) + { + char*str=getItem(mustnotcontain,';',count); + do { + if (cmdline.find(str)!=string::npos) + { + delete[] buffer; + delete[] buffer2; + LocalFree(UserPool); + return FALSE; + } + count++; + str=getItem(mustnotcontain,';',count); + } + while(*str!=0); + } + + //_ZwClose(hProcess); + LocalFree(UserPool); + delete[] buffer; + delete[] buffer2; + + return TRUE; +} + +#define RECV_BUFFER_SIZE 6144 + +BOOL CheckWWWContent(char*address) { + Netlib_Logf(hNetlib,"Check Url %s ...",address); + + //netlib request + NETLIBHTTPREQUEST nlhr={0}; + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType= REQUEST_HEAD; + nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER; + nlhr.szUrl = address; + + NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr); + + if (nlhrReply) { + //nicht auf dem server + Netlib_Logf(hNetlib,"Resultcode %d ...",nlhrReply->resultCode); + if (nlhrReply->resultCode != 200) { + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + return FALSE; + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + } + else + return FALSE; + + return TRUE; +} + + +BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf,unsigned int* size) { + if (dontoverwrite==TRUE) + { + if (GetFileAttributesA(filename)!=0xFFFFFFFF) + { + Netlib_Logf(hNetlib,"%s already exists, no overwrite.",filename); + return TRUE; + } + } + Netlib_Logf(hNetlib,"Download Url %s ...",address); + + //netlib request + NETLIBHTTPREQUEST nlhr={0}; + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType= REQUEST_GET; + nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER; + nlhr.szUrl = address; + + NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr); + + if (nlhrReply) { + //nicht auf dem server + if (nlhrReply->resultCode != 200) { + Netlib_Logf(hNetlib,"Bad statuscode: %d",nlhrReply->resultCode); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + return FALSE; + } + //keine daten für mich + else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) + { + Netlib_Logf(hNetlib,"No data received."); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + return FALSE; + } + else + { + if (tobuf==NULL) + { + FILE * f = fopen(filename,"wb"); + if (f==NULL) + { + Netlib_Logf(hNetlib,"Cannot open %s for binary write mode.",filename); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + return FALSE; + } + fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f); + fclose(f); + } + else + { + if (*tobuf==NULL) + { + *tobuf=new char[nlhrReply->dataLength+1]; + memcpy_s(*tobuf,nlhrReply->dataLength,nlhrReply->pData,nlhrReply->dataLength); + //0 terminieren + (*tobuf)[nlhrReply->dataLength]=0; + //größe zurückliefern, wenn gewollt + if (size) + *size=nlhrReply->dataLength+1; + } + } + } + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + } + else + { + Netlib_Logf(hNetlib,"No valid Netlib Request.",filename); + return FALSE; + } + return TRUE; +} +//eigener www downloader, da winet exceptions erzeugt +BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite) { + char add[1024]="http://"; + strcat(add,host); + strcat(add,request); + + return GetWWWContent2(add,filename,dontoverwrite); +} + +unsigned int getfilesize(char*path) +{ + FILE *f=fopen(path,"rb"); + if (f==NULL) + return 0; + fseek (f, 0, SEEK_END); + int size=ftell (f); + fclose (f); + return size; +} + +//funktion soll erst in der userini suchen, danach in der xfire_games.ini +DWORD xfire_GetPrivateProfileString(__in LPCSTR lpAppName, __in LPCSTR lpKeyName, __in LPCSTR lpDefault, __out LPSTR lpReturnedString, __in DWORD nSize, __in LPCSTR lpFileName) { + //xfire_games.ini + int size=strlen(lpFileName); + if (size>15) + { + char*file=(char*)lpFileName; + int ret=0; + *(file+size-14)='u'; + *(file+size-13)='s'; + *(file+size-12)='e'; + *(file+size-11)='r'; + ret = GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName); + if (ret) + { + return ret; + } + else + { + *(file+size-14)='f'; + *(file+size-13)='i'; + *(file+size-12)='r'; + *(file+size-11)='e'; + return GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName); + } + } + return GetPrivateProfileStringA( lpAppName,lpKeyName,lpDefault,lpReturnedString,nSize,lpFileName); +} + + +BOOL mySleep(int ms,HANDLE evt) { + switch(WaitForSingleObject(evt,ms)) + { + case WAIT_TIMEOUT: + return FALSE; + case WAIT_ABANDONED: + //MessageBoxA(NULL,"Abbruch","Abbruch",0); + return TRUE; + default: + return TRUE; + } + + return FALSE; }
\ No newline at end of file |