diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-11-28 20:39:37 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-11-28 20:39:37 +0000 |
commit | 92beff959051eec8d60e4e146aa3d8a13bee9fea (patch) | |
tree | b06ceb3079028d38f6d0f2481a5ab62b05e83e80 | |
parent | 8ef64da1b7cc3ef5026ab2dc80e7e0fd88971d59 (diff) |
XFire: Reformat sources
git-svn-id: http://svn.miranda-ng.org/main/trunk@11134 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
35 files changed, 4859 insertions, 4855 deletions
diff --git a/protocols/Xfire/src/Xfire_avatar_loader.cpp b/protocols/Xfire/src/Xfire_avatar_loader.cpp index 72805b0b7c..44f69dce4b 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.cpp +++ b/protocols/Xfire/src/Xfire_avatar_loader.cpp @@ -2,8 +2,8 @@ #include "Xfire_avatar_loader.h" Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) { - threadrunning=FALSE; - this->client=client; + threadrunning = FALSE; + this->client = client; InitializeCriticalSection(&this->avatarMutex); } @@ -18,30 +18,30 @@ Xfire_avatar_loader::~Xfire_avatar_loader() { } void Xfire_avatar_loader::loadThread(LPVOID lparam) { - Xfire_avatar_loader *loader=(Xfire_avatar_loader*)lparam; - + Xfire_avatar_loader *loader = (Xfire_avatar_loader*)lparam; + //kein loader, dann abbruch if (!loader) return; EnterCriticalSection(&loader->avatarMutex); - loader->threadrunning=TRUE; + loader->threadrunning = TRUE; - while(1){ + while (1){ //keinen avatarload auftrag mehr if (!loader->list.size()) break; //letzten load process holen - Xfire_avatar_process process=loader->list.back(); + Xfire_avatar_process process = loader->list.back(); //buddyinfo abfragen GetBuddyInfo buddyinfo; - buddyinfo.userid=process.userid; + buddyinfo.userid = process.userid; if (loader->client) if (loader->client->connected) { - loader->client->send(&buddyinfo); + loader->client->send(&buddyinfo); } else //nicht mehr verbunden? dann liste leeren und schleife abbrechen { @@ -55,27 +55,27 @@ void Xfire_avatar_loader::loadThread(LPVOID lparam) { Sleep(1000); } - loader->threadrunning=FALSE; + loader->threadrunning = FALSE; LeaveCriticalSection(&loader->avatarMutex); return; } -BOOL Xfire_avatar_loader::loadAvatar(MCONTACT hcontact,char*username,unsigned int userid) +BOOL Xfire_avatar_loader::loadAvatar(MCONTACT hcontact, char*username, unsigned int userid) { - Xfire_avatar_process process={0}; + Xfire_avatar_process process = { 0 }; //struktur füllen process.hcontact = hcontact; if (username) - strcpy_s(process.username,128,username); - process.userid=userid; + 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); + if (!threadrunning && client != NULL) { + mir_forkthread(Xfire_avatar_loader::loadThread, (LPVOID)this); } return TRUE; diff --git a/protocols/Xfire/src/Xfire_avatar_loader.h b/protocols/Xfire/src/Xfire_avatar_loader.h index 92b89184e1..3a7419f688 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.h +++ b/protocols/Xfire/src/Xfire_avatar_loader.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2009 by
* dufte <dufte@justmail.de>
@@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -50,7 +50,7 @@ private: public:
vector<Xfire_avatar_process> list;
BOOL threadrunning;
- BOOL loadAvatar(MCONTACT hcontact,char*username,unsigned int userid);
+ BOOL loadAvatar(MCONTACT hcontact, char*username, unsigned int userid);
Xfire_avatar_loader(xfirelib::Client* client);
~Xfire_avatar_loader();
};
diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp index 080f0d31ae..6363c0e0dd 100644 --- a/protocols/Xfire/src/Xfire_base.cpp +++ b/protocols/Xfire/src/Xfire_base.cpp @@ -5,15 +5,15 @@ //rechnet die einzelnen chars des strings zusammen
BYTE Xfire_base::accStringByte(char* str){
- BYTE temp=0;
+ BYTE temp = 0;
//keins tirng? bye bye
- if (str==NULL)
+ if (str == NULL)
return 0;
- for(unsigned int i=0;i<(int)strlen(str);i++)
+ for (unsigned int i = 0; i < (int)strlen(str); i++)
{
- temp+=str[i];
+ temp += str[i];
}
return temp;
@@ -23,26 +23,26 @@ BYTE Xfire_base::accStringByte(char* str){ void Xfire_base::strtolower(char*str)
{
//keins tirng? bye bye
- if (str==NULL)
+ if (str == NULL)
return;
//lowercase it :)
- for(unsigned int i=0;i<(int)strlen(str);i++)
+ for (unsigned int i = 0; i < (int)strlen(str); i++)
{
- str[i]=tolower(str[i]);
+ str[i] = tolower(str[i]);
}
}
void Xfire_base::strtolowerT(TCHAR*str)
{
//keins tirng? bye bye
- if (str==NULL)
+ if (str == NULL)
return;
//lowercase it :)
- for(unsigned int i=0;i<(int)_tcslen(str);i++)
+ for (unsigned int i = 0; i < (int)_tcslen(str); i++)
{
- str[i]=tolower(str[i]);
+ str[i] = tolower(str[i]);
}
}
@@ -50,128 +50,128 @@ void Xfire_base::strtolowerT(TCHAR*str) void Xfire_base::strtoupper(char*str)
{
//keins tirng? bye bye
- if (str==NULL)
+ if (str == NULL)
return;
//lowercase it :)
- for(unsigned int i=0;i<(int)strlen(str);i++)
+ for (unsigned int i = 0; i < (int)strlen(str); i++)
{
- str[i]=toupper(str[i]);
+ str[i] = toupper(str[i]);
}
}
//setzt einen string
-void Xfire_base::setString(char*from,char**to)
+void Xfire_base::setString(char*from, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (from==NULL||to==NULL)
+ if (from == NULL || to == NULL)
return;
//stringgröße auslesen
- int size=strlen(from);
+ int size = strlen(from);
//bestehenden zielpointer leeren
- if (*to!=NULL)
- delete[] *to;
+ if (*to != NULL)
+ delete[] * to;
//neuen string anlegen
- *to=new char[size+1];
+ *to = new char[size + 1];
//string in neues array kopieren
- strcpy_s(*to,size+1,from);
+ strcpy_s(*to, size + 1, from);
}
//setzt einen string
-void Xfire_base::appendString(char*from,char**to)
+void Xfire_base::appendString(char*from, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (from==NULL||to==NULL||*to==NULL)
+ if (from == NULL || to == NULL || *to == NULL)
return;
//stringgröße auslesen
- int size=strlen(from);
- int size2=strlen(*to);
+ int size = strlen(from);
+ int size2 = strlen(*to);
//temporären pointer anlegen
- char* append=new char[size+size2+1];
+ char* append = new char[size + size2 + 1];
//string in neues array kopieren
- strcpy_s(append,size+size2+1,*to);
+ strcpy_s(append, size + size2 + 1, *to);
//zusätzlichen stirng anhängen
- strcat_s(append,size+size2+1,from);
+ strcat_s(append, size + size2 + 1, from);
//altes to entfernen
- delete[] *to;
+ delete[] * to;
//appendstring zuordnen
- *to=append;
+ *to = append;
}
//liest einen stringval aus der db und setzt einen string für
-void Xfire_base::readStringfromDB(char*name,unsigned int dbid,char**to)
+void Xfire_base::readStringfromDB(char*name, unsigned int dbid, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||to==NULL)
+ if (name == NULL || to == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i", name, dbid);
- if (!db_get_s(NULL, protocolname, temp,&dbv))
+ if (!db_get_s(NULL, protocolname, temp, &dbv))
{
//string setzen
- setString(dbv.pszVal,to);
+ setString(dbv.pszVal, to);
//dbval wieder freigeben
db_free(&dbv);
}
}
//liest einen stringval aus der db welches unterid hat und setzt einen string für
-void Xfire_base::readStringfromDB(char*name,unsigned int dbid,int id,char**to)
+void Xfire_base::readStringfromDB(char*name, unsigned int dbid, int id, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||to==NULL)
+ if (name == NULL || to == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id);
- if (!db_get_s(NULL, protocolname, temp,&dbv))
+ if (!db_get_s(NULL, protocolname, temp, &dbv))
{
//string setzen
- setString(dbv.pszVal,to);
+ setString(dbv.pszVal, to);
//dbval wieder freigeben
db_free(&dbv);
}
}
//liest einen stringval aus der db und setzt einen string für
-void Xfire_base::readUtf8StringfromDB(char*name,unsigned int dbid,char**to)
+void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||to==NULL)
+ if (name == NULL || to == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i", name, dbid);
- if (!db_get_utf(NULL, protocolname, temp,&dbv))
+ if (!db_get_utf(NULL, protocolname, temp, &dbv))
{
//string setzen
- setString(dbv.pszVal,to);
+ setString(dbv.pszVal, to);
//dbval wieder freigeben
db_free(&dbv);
}
}
//liest einen stringval aus der db welches unterid hat und setzt einen string für
-void Xfire_base::readUtf8StringfromDB(char*name,unsigned int dbid,int id,char**to)
+void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, int id, char**to)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||to==NULL)
+ if (name == NULL || to == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id);
- if (!db_get_utf(NULL, protocolname, temp,&dbv))
+ if (!db_get_utf(NULL, protocolname, temp, &dbv))
{
//string setzen
- setString(dbv.pszVal,to);
+ setString(dbv.pszVal, to);
//dbval wieder freigeben
db_free(&dbv);
}
@@ -179,59 +179,59 @@ void Xfire_base::readUtf8StringfromDB(char*name,unsigned int dbid,int id,char**t //schreibt einen stringval in die db welche unterid hat
-void Xfire_base::writeStringtoDB(char*name,unsigned int dbid,int id,char*val)
+void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, int id, char*val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||val==NULL)
+ if (name == NULL || val == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id);
- db_set_s(NULL, protocolname, temp,val);
+ db_set_s(NULL, protocolname, temp, val);
}
//schreibt einen stringval in die db welche unterid hat
-void Xfire_base::writeStringtoDB(char*name,unsigned int dbid,char*val)
+void Xfire_base::writeStringtoDB(char*name, unsigned int dbid, char*val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||val==NULL)
+ if (name == NULL || val == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i", name, dbid);
- db_set_s(NULL, protocolname, temp,val);
+ db_set_s(NULL, protocolname, temp, val);
}
//schreibt einen stringval in die db welche unterid hat
-void Xfire_base::writeUtf8StringtoDB(char*name,unsigned int dbid,int id,char*val)
+void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, int id, char*val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||val==NULL)
+ if (name == NULL || val == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id);
- db_set_utf(NULL, protocolname, temp,val);
+ db_set_utf(NULL, protocolname, temp, val);
}
//schreibt einen stringval in die db welche unterid hat
-void Xfire_base::writeUtf8StringtoDB(char*name,unsigned int dbid,char*val)
+void Xfire_base::writeUtf8StringtoDB(char*name, unsigned int dbid, char*val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL||val==NULL)
+ if (name == NULL || val == NULL)
return;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i", name, dbid);
- db_set_utf(NULL, protocolname, temp,val);
+ db_set_utf(NULL, protocolname, temp, val);
}
//schreibt einen bytewert in die db
-void Xfire_base::writeBytetoDB(char*name,unsigned int dbid,int val)
+void Xfire_base::writeBytetoDB(char*name, unsigned int dbid, int val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL)
+ if (name == NULL)
return;
//wert aus der dblesen
@@ -240,10 +240,10 @@ void Xfire_base::writeBytetoDB(char*name,unsigned int dbid,int val) }
//schreibt einen wordwert in die db
-void Xfire_base::writeWordtoDB(char*name,unsigned int dbid,int val)
+void Xfire_base::writeWordtoDB(char*name, unsigned int dbid, int val)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL)
+ if (name == NULL)
return;
//wert aus der dblesen
@@ -253,10 +253,10 @@ void Xfire_base::writeWordtoDB(char*name,unsigned int dbid,int val) //liest einen byteval aus der db und gibt es zurück
-unsigned char Xfire_base::readBytefromDB(char*name,unsigned int dbid,int defaultval)
+unsigned char Xfire_base::readBytefromDB(char*name, unsigned int dbid, int defaultval)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL)
+ if (name == NULL)
return 0;
//wert aus der dblesen
@@ -265,10 +265,10 @@ unsigned char Xfire_base::readBytefromDB(char*name,unsigned int dbid,int default }
//liest einen wordval aus der db und gibt es zurück
-unsigned int Xfire_base::readWordfromDB(char*name,unsigned int dbid,int defaultval)
+unsigned int Xfire_base::readWordfromDB(char*name, unsigned int dbid, int defaultval)
{
//keine quelle, kein ziel? dann nix machen
- if (name==NULL)
+ if (name == NULL)
return 0;
//wert aus der dblesen
@@ -277,17 +277,17 @@ unsigned int Xfire_base::readWordfromDB(char*name,unsigned int dbid,int defaultv }
//entfernt einen dbeintrag
-BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid)
+BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid)
{
//kein name?
- if (name==NULL)
+ if (name == NULL)
return 0;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i", name, dbid);
-
+
//eintrag entfernen
- if (!db_get(NULL, protocolname, temp,&dbv))
+ if (!db_get(NULL, protocolname, temp, &dbv))
{
db_free(&dbv);
db_unset(NULL, protocolname, temp);
@@ -298,17 +298,17 @@ BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid) }
//entfernt einen dbeintrag welche unterid's hat
-BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid,int id)
+BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid, int id)
{
//kein name?
- if (name==NULL)
+ if (name == NULL)
return 0;
//wert aus der dblesen
mir_snprintf(temp, 128, "%s_%i_%i", name, dbid, id);
-
+
//eintrag entfernen
- if (!db_get(NULL, protocolname, temp,&dbv))
+ if (!db_get(NULL, protocolname, temp, &dbv))
{
db_free(&dbv);
db_unset(NULL, protocolname, temp);
@@ -319,55 +319,55 @@ BOOL Xfire_base::removeDBEntry(char*name,unsigned int dbid,int id) }
//sucht innerhalb eines strings ein anderen string und liefert true zurück wenn gefunden
-BOOL Xfire_base::inString(char*str,char*search,char**pos) {
+BOOL Xfire_base::inString(char*str, char*search, char**pos) {
//leere pointer?, dann FALSE zurück
- if (str==NULL||search==NULL)
+ if (str == NULL || search == NULL)
{
//poszeiger, falls übergeben, auf NULL setzen
- if (pos) *pos=NULL;
+ if (pos) *pos = NULL;
return FALSE;
}
//ist der gesuchte string größer, wie der string wo gesucht werden soll? dann FALSE zurück
- unsigned int sizeofsearch=strlen(search);
- if (sizeofsearch>strlen(str))
+ unsigned int sizeofsearch = strlen(search);
+ if (sizeofsearch > strlen(str))
{
//poszeiger, falls übergeben, auf NULL setzen
- if (pos) *pos=NULL;
+ if (pos) *pos = NULL;
return FALSE;
}
- char* src=str;
- char* s=search;
+ char* src = str;
+ char* s = search;
- while(*src!=0)
+ while (*src != 0)
{
- if (*src==*s) //gleich, dann zum nächsten buchstaben springen
+ if (*src == *s) //gleich, dann zum nächsten buchstaben springen
s++;
- else if (*s==0) //string ende erreicht? dann true
+ else if (*s == 0) //string ende erreicht? dann true
{
//poszeiger mit aktueller pos füllen, da position gefunden
- if (pos) *pos=src-sizeofsearch;
+ if (pos) *pos = src - sizeofsearch;
return TRUE;
}
else //anderer biuchstabe? dann wieder zurück zum anfangsbuchstaben
- s=search;
+ s = search;
src++;
}
- if (*s==0) //string ende erreicht? dann true
+ if (*s == 0) //string ende erreicht? dann true
{
//poszeiger mit aktueller pos füllen, da position gefunden
- if (pos) *pos=src-sizeofsearch;
+ if (pos) *pos = src - sizeofsearch;
return TRUE;
}
//poszeiger, falls übergeben, auf NULL setzen
- if (pos) *pos=NULL;
+ if (pos) *pos = NULL;
//nix gefunden, FALSE
return FALSE;
}
-void Xfire_base::strreplace(char*search,char*replace,char**data) {
+void Xfire_base::strreplace(char*search, char*replace, char**data) {
if (replace == NULL)
replace = "";
@@ -377,82 +377,82 @@ void Xfire_base::strreplace(char*search,char*replace,char**data) { return;
}
- char* pos=NULL;
+ char* pos = NULL;
//gesuchten string suchen
- if (this->inString(*data,search,&pos))
+ if (this->inString(*data, search, &pos))
{
//gefunden? dann replace
- *pos=0;
- char* newdata=NULL;
+ *pos = 0;
+ char* newdata = NULL;
//alles vorm gefunden anhängen
- this->setString(*data,&newdata);
+ this->setString(*data, &newdata);
//ersetzendes anhängen
- this->appendString(replace,&newdata);
+ this->appendString(replace, &newdata);
//poszeiger um die größe des zusuchenden strings erhöhen
- pos+=strlen(search);
+ pos += strlen(search);
//rest anhängen
- this->appendString(pos,&newdata);
+ this->appendString(pos, &newdata);
//alten string löschen
- delete[] *data;
- *data=NULL;
+ delete[] * data;
+ *data = NULL;
//neuen auf diesen setzen
- this->setString(newdata,data);
+ this->setString(newdata, data);
//temporären newdata löschen
delete[] newdata;
}
}
//stringvergleich mit wildcards
-BOOL Xfire_base::wildcmp(const TCHAR *search,const TCHAR *text) {
+BOOL Xfire_base::wildcmp(const TCHAR *search, const TCHAR *text) {
//keine gültigen strings, dann abbruch
- if (search==NULL || text==NULL || *text==0 || *search==0)
+ if (search == NULL || text == NULL || *text == 0 || *search == 0)
return FALSE;
//wildcardmodus
- int wildc=0;
+ int wildc = 0;
do {
//wilcard gefunden?
- if (*search=='*')
+ if (*search == '*')
{
//wildcardmodus an
- wildc=1;
+ wildc = 1;
//nächsten suchzeichen
search++;
//wenn searchzeichen 0, dann 1 zurückgeben, da der rest des searchstings egal ist
- if (*search==0)
+ if (*search == 0)
return TRUE;
}
//prüfe searchzeichen mit textzeichen, aber nut wenn kein wildcardmodus aktiv ist
- if (*search!=*text && !wildc)
+ if (*search != *text && !wildc)
return FALSE;
//kein wildcardmodus
if (!wildc)
- {
+ {
//nächstes suchzeichen
search++;
}
//wenn suchzeichen und textzeichen gleich ist
- else if (*search==*text)
+ else if (*search == *text)
{
//den wildcardmodus abschalten
- wildc=0;
+ wildc = 0;
//nächstes suchzeichen
search++;
}
//nächstes textzeichen
text++;
//wenn textende erreicht und suchzeichen noch vorhanden, dann 0 zurückgegebn
- if (*text==0 && *search!=0)
+ if (*text == 0 && *search != 0)
return FALSE;
}
//solange weiter bis kein suchzeichen mehr vorhanden is
- while(*search!=0);
+ while (*search != 0);
//textzeichen übrig 0 zurück
- if (*text!=0)
+ if (*text != 0)
return FALSE;
//volle übereinstimmung
@@ -460,13 +460,13 @@ BOOL Xfire_base::wildcmp(const TCHAR *search,const TCHAR *text) { }
//wrapper wenn nur gameid angegeben
-BOOL Xfire_base::getIniValue(unsigned int gameid,const char* valname,char*out,int sizeofout) {
- return Xfire_base::getIniValue(gameid,0,valname,out,sizeofout);
+BOOL Xfire_base::getIniValue(unsigned int gameid, const char* valname, char*out, int sizeofout) {
+ return Xfire_base::getIniValue(gameid, 0, valname, out, sizeofout);
}
//läd einen eintrag aus der ini
-BOOL Xfire_base::getIniValue(unsigned int gameid,unsigned int subid,const char* valname,char*out,int sizeofout) {
+BOOL Xfire_base::getIniValue(unsigned int gameid, unsigned int subid, const char* valname, char*out, int sizeofout) {
//kein ziel oder kein variablenname, dann FALSE zurück
if (!out || !valname)
return FALSE;
@@ -478,7 +478,7 @@ BOOL Xfire_base::getIniValue(unsigned int gameid,unsigned int subid,const char* if (!getIniPath(path))
return FALSE; //kein pfad bug?!?!
- if (subid==0) {
+ if (subid == 0) {
mir_snprintf(idstring, 15, "%d", gameid);
if (xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path))
@@ -492,15 +492,15 @@ BOOL Xfire_base::getIniValue(unsigned int gameid,unsigned int subid,const char* if (xfire_GetPrivateProfileString(idstring, valname, "", out, sizeofout, path))
return TRUE;
- return FALSE;
+ return FALSE;
}
BOOL Xfire_base::getIniPath(char*path) {
//kein ziel abbruch
if (!path)
return FALSE;
- strcpy(path, XFireGetFoldersPath ("IniFile"));
- strcat_s(path,MAX_PATH,"xfire_games.ini");
+ strcpy(path, XFireGetFoldersPath("IniFile"));
+ strcat_s(path, MAX_PATH, "xfire_games.ini");
return TRUE;
}
@@ -508,22 +508,22 @@ BOOL Xfire_base::getIconPath(char*path) { //kein ziel abbruch
if (!path)
return FALSE;
- strcpy(path, XFireGetFoldersPath ("IconsFile"));
+ strcpy(path, XFireGetFoldersPath("IconsFile"));
return TRUE;
}
-BOOL Xfire_base::getGamename(unsigned int gameid,char* out,int outsize){
+BOOL Xfire_base::getGamename(unsigned int gameid, char* out, int outsize){
//kein ziel
if (!out)
return FALSE;
- if (!getIniValue(gameid,"LongName",out,outsize))
+ if (!getIniValue(gameid, "LongName", out, outsize))
{
//customnamen laden, wenn vorhanden
DBVARIANT dbv;
- char dbstr[80]="";
+ char dbstr[80] = "";
mir_snprintf(dbstr, XFIRE_MAXSIZEOFGAMENAME, "customgamename_%d", gameid);
- if (!db_get(NULL,protocolname,dbstr,&dbv)) {
+ if (!db_get(NULL, protocolname, dbstr, &dbv)) {
mir_snprintf(out, outsize, "%s", dbv.pszVal);
db_free(&dbv);
return TRUE;
@@ -535,18 +535,18 @@ BOOL Xfire_base::getGamename(unsigned int gameid,char* out,int outsize){ }
//wandelt einen buffer mit größe in ein hicon mit hilfe von gdi+ um
-HICON Xfire_base::createHICONfromdata(LPVOID data,unsigned int size) {
+HICON Xfire_base::createHICONfromdata(LPVOID data, unsigned int size) {
//zielspeichern anlegen
- HGLOBAL buffer=GlobalAlloc(GMEM_MOVEABLE, size);
+ HGLOBAL buffer = GlobalAlloc(GMEM_MOVEABLE, size);
if (buffer) {
- LPVOID data2=GlobalLock(buffer);
+ LPVOID data2 = GlobalLock(buffer);
if (data2) {
- CopyMemory(data2, data, size);
-
- IStream* stream=NULL;
- if (CreateStreamOnHGlobal(data2,FALSE,&stream)== S_OK)
+ CopyMemory(data2, data, size);
+
+ IStream* stream = NULL;
+ if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK)
{
- HICON hicon=NULL;
+ HICON hicon = NULL;
Gdiplus::Bitmap image(stream);
image.GetHICON(&hicon);
@@ -565,21 +565,21 @@ HICON Xfire_base::createHICONfromdata(LPVOID data,unsigned int size) { }
//wandelt einen buffer mit größe in ein hicon mit hilfe von gdi+ um
-HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data,unsigned int size) {
+HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data, unsigned int size) {
//zielspeichern anlegen
- HGLOBAL buffer=GlobalAlloc(GMEM_MOVEABLE, size);
+ HGLOBAL buffer = GlobalAlloc(GMEM_MOVEABLE, size);
if (buffer) {
- LPVOID data2=GlobalLock(buffer);
+ LPVOID data2 = GlobalLock(buffer);
if (data2) {
- CopyMemory(data2, data, size);
-
- IStream* stream=NULL;
- if (CreateStreamOnHGlobal(data2,FALSE,&stream)== S_OK)
+ CopyMemory(data2, data, size);
+
+ IStream* stream = NULL;
+ if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK)
{
- HBITMAP hbitmap=NULL;
+ HBITMAP hbitmap = NULL;
Gdiplus::Bitmap image(stream);
- image.GetHBITMAP(0,&hbitmap);
+ image.GetHBITMAP(0, &hbitmap);
stream->Release();
GlobalUnlock(buffer);
@@ -596,20 +596,20 @@ HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data,unsigned int size) { //prüft ob processid noch gültig is
BOOL Xfire_base::isValidPid(DWORD pid) {
- DWORD aProcesses[1024],cbNeeded,cProcesses;
+ DWORD aProcesses[1024], cbNeeded, cProcesses;
- if (pid==NULL)
+ if (pid == NULL)
return FALSE;
- if (!EnumProcesses(aProcesses,sizeof(aProcesses),&cbNeeded))
+ if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
return FALSE;
cProcesses = cbNeeded / sizeof(DWORD);
- for ( unsigned int i = 0; i < cProcesses; i++ )
- if (aProcesses[i]==pid)
+ for (unsigned int i = 0; i < cProcesses; i++)
+ if (aProcesses[i] == pid)
{
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -617,19 +617,19 @@ BOOL Xfire_base::isValidPid(DWORD pid) { //sucht nach einen process und liefert die pid
BOOL Xfire_base::getPidByProcessName(TCHAR *name, DWORD *pid) {
- if (pid==NULL||name==NULL)
+ if (pid == NULL || name == NULL)
return FALSE;
- HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
+ HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
PROCESSENTRY32* processInfo = new PROCESSENTRY32;
- processInfo->dwSize = sizeof ( PROCESSENTRY32);
+ processInfo->dwSize = sizeof(PROCESSENTRY32);
- while ( Process32Next ( hSnapShot,processInfo ) != FALSE)
+ while (Process32Next(hSnapShot, processInfo) != FALSE)
{
- if (processInfo->th32ProcessID!=0) {
- if (_tcsicmp(processInfo->szExeFile,name)==0)
+ if (processInfo->th32ProcessID != 0) {
+ if (_tcsicmp(processInfo->szExeFile, name) == 0)
{
- *pid=processInfo->th32ProcessID;
+ *pid = processInfo->th32ProcessID;
CloseHandle(hSnapShot);
return TRUE;
}
diff --git a/protocols/Xfire/src/Xfire_base.h b/protocols/Xfire/src/Xfire_base.h index 94f52a820f..717bf38fac 100644 --- a/protocols/Xfire/src/Xfire_base.h +++ b/protocols/Xfire/src/Xfire_base.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -19,14 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
/*
Beinhaltet Basisfunktionen
-*/
+ */
#ifndef _XFIRE_BASE
#define _XFIRE_BASE
@@ -45,42 +45,42 @@ private: public:
char temp[128];
//funktionen/tools
- void setString(char*from,char**to);
- void appendString(char*from,char**to);
- void readStringfromDB(char*name,unsigned int dbid,char**to);
- void readStringfromDB(char*name,unsigned int dbid,int id,char**to);
- void readUtf8StringfromDB(char*name,unsigned int dbid,char**to);
- void readUtf8StringfromDB(char*name,unsigned int dbid,int id,char**to);
- unsigned char readBytefromDB(char*name,unsigned int dbid,int defaultval=0);
- unsigned int readWordfromDB(char*name,unsigned int dbid,int defaultval=0);
- BOOL removeDBEntry(char*name,unsigned int dbid);
- BOOL removeDBEntry(char*name,unsigned int dbid,int id2);
- void writeStringtoDB(char*name,unsigned int dbid,int id,char*val);
- void writeStringtoDB(char*name,unsigned int dbid,char*val);
- void writeUtf8StringtoDB(char*name,unsigned int dbid,int id,char*val);
- void writeUtf8StringtoDB(char*name,unsigned int dbid,char*val);
- void writeBytetoDB(char*name,unsigned int dbid,int val);
- void writeWordtoDB(char*name,unsigned int dbid,int val);
+ void setString(char*from, char**to);
+ void appendString(char*from, char**to);
+ void readStringfromDB(char*name, unsigned int dbid, char**to);
+ void readStringfromDB(char*name, unsigned int dbid, int id, char**to);
+ void readUtf8StringfromDB(char*name, unsigned int dbid, char**to);
+ void readUtf8StringfromDB(char*name, unsigned int dbid, int id, char**to);
+ unsigned char readBytefromDB(char*name, unsigned int dbid, int defaultval = 0);
+ unsigned int readWordfromDB(char*name, unsigned int dbid, int defaultval = 0);
+ BOOL removeDBEntry(char*name, unsigned int dbid);
+ BOOL removeDBEntry(char*name, unsigned int dbid, int id2);
+ void writeStringtoDB(char*name, unsigned int dbid, int id, char*val);
+ void writeStringtoDB(char*name, unsigned int dbid, char*val);
+ void writeUtf8StringtoDB(char*name, unsigned int dbid, int id, char*val);
+ void writeUtf8StringtoDB(char*name, unsigned int dbid, char*val);
+ void writeBytetoDB(char*name, unsigned int dbid, int val);
+ void writeWordtoDB(char*name, unsigned int dbid, int val);
void strtolower(char*);
void strtolowerT(TCHAR*);
void strtoupper(char*);
- void strreplace(char*search,char*replace,char**data);
+ void strreplace(char*search, char*replace, char**data);
BYTE accStringByte(char*);
- BOOL inString(char*str,char*search,char**pos=NULL);
- BOOL wildcmp(const TCHAR *search,const TCHAR *text);
+ BOOL inString(char*str, char*search, char**pos = NULL);
+ BOOL wildcmp(const TCHAR *search, const TCHAR *text);
// ini funktionen
- BOOL getIniValue(unsigned int gameid,const char* valname,char*out,int sizeofout=255);
- BOOL getIniValue(unsigned int gameid,unsigned int subid,const char* valname,char*out,int sizeofout=255);
+ BOOL getIniValue(unsigned int gameid, const char* valname, char*out, int sizeofout = 255);
+ BOOL getIniValue(unsigned int gameid, unsigned int subid, const char* valname, char*out, int sizeofout = 255);
BOOL getIniPath(char*path);
BOOL getIconPath(char*path);
// gamename
- BOOL getGamename(unsigned int gameid,char* out,int outsize=255);
+ BOOL getGamename(unsigned int gameid, char* out, int outsize = 255);
//gdi+
- HICON createHICONfromdata(LPVOID data,unsigned int size);
- HBITMAP createHBITMAPfromdata(LPVOID data,unsigned int size);
+ HICON createHICONfromdata(LPVOID data, unsigned int size);
+ HBITMAP createHBITMAPfromdata(LPVOID data, unsigned int size);
//processzeugs
BOOL isValidPid(DWORD pid);
- BOOL getPidByProcessName(TCHAR *name,DWORD *pid);
+ BOOL getPidByProcessName(TCHAR *name, DWORD *pid);
};
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/Xfire_game.cpp b/protocols/Xfire/src/Xfire_game.cpp index b41fc14143..1486ecaf16 100644 --- a/protocols/Xfire/src/Xfire_game.cpp +++ b/protocols/Xfire/src/Xfire_game.cpp @@ -10,103 +10,103 @@ BOOL Xfire_game::haveExtraGameArgs() { return FALSE;
//wenn platzhalter vorhanden, dann TRUE zurück
- if (this->inString(this->launchparams,"%UA_LAUNCHER_EXTRA_ARGS%"))
+ if (this->inString(this->launchparams, "%UA_LAUNCHER_EXTRA_ARGS%"))
return TRUE;
return FALSE;
}
//startes das spiel
-BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) {
+BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) {
//launchparam prüfen ob gefüllt?
- if (this->launchparams==NULL)
+ if (this->launchparams == NULL)
return FALSE;
//ist launchparam großgenug für eibne urlprüfung?
- if (strlen(this->launchparams)>5)
+ if (strlen(this->launchparams) > 5)
{
//launchparams ne url? dann openurl funktion von miranda verwenden
- if (this->launchparams[0]=='h'&&
- this->launchparams[1]=='t'&&
- this->launchparams[2]=='t'&&
- this->launchparams[3]=='p'&&
- this->launchparams[4]==':')
+ if (this->launchparams[0] == 'h'&&
+ this->launchparams[1] == 't'&&
+ this->launchparams[2] == 't'&&
+ this->launchparams[3] == 'p'&&
+ this->launchparams[4] == ':')
{
- return CallService(MS_UTILS_OPENURL, 1, (LPARAM)this->launchparams );
+ return CallService(MS_UTILS_OPENURL, 1, (LPARAM)this->launchparams);
}
}
//spiel hat netwerkparameter?
- int networksize=0;
- char* mynetworkparams=NULL;
+ int networksize = 0;
+ char* mynetworkparams = NULL;
if (this->networkparams)
{
if (ip)
{
- char portstr[6]="";
- int pwsize=255;
+ char portstr[6] = "";
+ int pwsize = 255;
//größe des netzwerparams berechnen
if (this->pwparams)
- pwsize+=strlen(this->pwparams);
+ pwsize += strlen(this->pwparams);
- mynetworkparams=new char[strlen(this->networkparams)+pwsize];
- strcpy_s(mynetworkparams,strlen(this->networkparams)+pwsize,this->networkparams);
+ mynetworkparams = new char[strlen(this->networkparams) + pwsize];
+ strcpy_s(mynetworkparams, strlen(this->networkparams) + pwsize, this->networkparams);
//port begrenzen
- port=port%65535;
+ port = port % 65535;
//port in string wandeln
- mir_snprintf(portstr,6,"%d",port);
+ mir_snprintf(portstr, 6, "%d", port);
- str_replace(mynetworkparams,"%UA_GAME_HOST_NAME%",ip);
- str_replace(mynetworkparams,"%UA_GAME_HOST_PORT%",portstr);
+ str_replace(mynetworkparams, "%UA_GAME_HOST_NAME%", ip);
+ str_replace(mynetworkparams, "%UA_GAME_HOST_PORT%", portstr);
//passwort dialog, nur wenn SHIFT gehalten wird beim join, da sonst immer gefragt wird
if (GetAsyncKeyState(VK_LSHIFT) && this->pwparams){
- char password[256]=""; //passwort maximal 255 zeichen
+ char password[256] = ""; //passwort maximal 255 zeichen
if (ShowPwdDlg(password)) {
- char* mypwargs=new char[pwsize];
+ char* mypwargs = new char[pwsize];
//speicher frei?
- if (mypwargs!=NULL) {
- strcpy_s(mypwargs,pwsize,this->pwparams);
+ if (mypwargs != NULL) {
+ strcpy_s(mypwargs, pwsize, this->pwparams);
str_replace(mypwargs, "%UA_GAME_HOST_PASSWORD%", password);
- str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%",mypwargs);
+ str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", mypwargs);
delete[] mypwargs;
}
else
- str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+ str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", "");
}
else
{
- str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+ str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", "");
}
}
else
- str_replace(mynetworkparams,"%UA_LAUNCHER_PASSWORD_ARGS%","");
+ str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", "");
//bestimmte felder erstmal leer ersetzen
- str_replace(mynetworkparams,"%UA_LAUNCHER_RCON_ARGS%","");
+ str_replace(mynetworkparams, "%UA_LAUNCHER_RCON_ARGS%", "");
}
if (mynetworkparams)
- networksize=strlen(mynetworkparams)+strlen(this->networkparams);
+ networksize = strlen(mynetworkparams) + strlen(this->networkparams);
}
//extra parameter
- int extraparamssize=0;
+ int extraparamssize = 0;
if (this->extraparams)
{
- extraparamssize=strlen(this->extraparams);
+ extraparamssize = strlen(this->extraparams);
}
//temporäres array anlegen
- char*temp=NULL;
- temp=new char[strlen(this->launchparams)+networksize+extraparamssize+1];
+ char*temp = NULL;
+ temp = new char[strlen(this->launchparams) + networksize + extraparamssize + 1];
- if (temp==NULL)
+ if (temp == NULL)
{
//wenn nwparams gesetzt, leeren
if (mynetworkparams)
@@ -116,21 +116,21 @@ BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) { }
//launcherstring ins temporäre array
- strcpy_s(temp,strlen(this->launchparams)+1,this->launchparams);
+ strcpy_s(temp, strlen(this->launchparams) + 1, this->launchparams);
//netzwerkparameter ?
if (mynetworkparams)
{
- str_replace(temp,"%UA_LAUNCHER_NETWORK_ARGS%",mynetworkparams);
+ str_replace(temp, "%UA_LAUNCHER_NETWORK_ARGS%", mynetworkparams);
delete[] mynetworkparams;
}
else
- str_replace(temp,"%UA_LAUNCHER_NETWORK_ARGS%","");
+ str_replace(temp, "%UA_LAUNCHER_NETWORK_ARGS%", "");
if (this->extraparams)
- str_replace(temp,"%UA_LAUNCHER_EXTRA_ARGS%",this->extraparams);
+ str_replace(temp, "%UA_LAUNCHER_EXTRA_ARGS%", this->extraparams);
else
- str_replace(temp,"%UA_LAUNCHER_EXTRA_ARGS%","");
+ str_replace(temp, "%UA_LAUNCHER_EXTRA_ARGS%", "");
//auf createprocess umgebaut
STARTUPINFOA si = { sizeof(si) };
@@ -139,30 +139,30 @@ BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) { // MessageBoxA(NULL,temp,temp,0);
//starten
- if (CreateProcessA(0, temp, 0, 0, FALSE, 0, 0, GetLaunchPath(temp) , &si, &pi)==0)
+ if (CreateProcessA(0, temp, 0, 0, FALSE, 0, 0, GetLaunchPath(temp), &si, &pi) == 0)
{
//schlug fehl, dann runas methode verwenden
- char*exe=strrchr(temp,'\\');
- if (exe==0)
+ char*exe = strrchr(temp, '\\');
+ if (exe == 0)
{
delete[] temp;
return FALSE;
}
- *exe=0;
+ *exe = 0;
exe++;
- char*params=strchr(exe,'.');
- if (params!=0)
+ char*params = strchr(exe, '.');
+ if (params != 0)
{
- params=strchr(params,' ');
- if (params!=0)
+ params = strchr(params, ' ');
+ if (params != 0)
{
- *params=0;
+ *params = 0;
params++;
}
}
- SHELLEXECUTEINFOA sei = {0};
+ SHELLEXECUTEINFOA sei = { 0 };
sei.cbSize = sizeof(sei);
sei.hwnd = NULL;
sei.lpVerb = "runas";
@@ -171,7 +171,7 @@ BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) { sei.lpDirectory = temp;
sei.nShow = SW_SHOWNORMAL;
ShellExecuteExA(&sei);
- }
+ }
delete[] temp;
return TRUE;
}
@@ -180,48 +180,48 @@ BOOL Xfire_game::start_game(char*ip,unsigned int port,char*pw) { BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo)
{
//gibts net, weg mit dir
- if (this->path==NULL)
+ if (this->path == NULL)
return FALSE;
//versuche ein processhandle des speils zubekommen
- HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, processInfo->th32ProcessID);
+ HANDLE op = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processInfo->th32ProcessID);
if (op)
{
//varaibele wohin der pfad eingelesen wird
- TCHAR fpath[MAX_PATH]=_T("");
+ TCHAR fpath[MAX_PATH] = _T("");
//lese den pfad des spiels aus
- GetModuleFileNameEx(op,NULL,fpath,sizeof(fpath));
+ GetModuleFileNameEx(op, NULL, fpath, sizeof(fpath));
//8.3 pfade umwandeln, nur wenn sich eine tilde im string befindet
- if (_tcschr(fpath,'~'))
- GetLongPathName(fpath,fpath,sizeof(fpath));
+ if (_tcschr(fpath, '~'))
+ GetLongPathName(fpath, fpath, sizeof(fpath));
//alles in kelinbuchstaben umwandeln
this->strtolowerT(fpath);
- if (this->wildcmp(_A2T(this->path),fpath))
- //if (strcmp(this->path,fpath)==0)
+ if (this->wildcmp(_A2T(this->path), fpath))
+ //if (strcmp(this->path,fpath)==0)
{
//pfad stimmt überein, commandline prüfen
- if (checkCommandLine(op,this->mustcontain,this->notcontain))
+ if (checkCommandLine(op, this->mustcontain, this->notcontain))
{
//handle zuamachen
CloseHandle(op);
//positive antwort an die gamedetection
return TRUE;
- }
+ }
}
else //prüfe den multipfad
{
- int size=mpath.size();
- for(int j=0;j<size;j++)
+ int size = mpath.size();
+ for (int j = 0; j < size; j++)
{
- if (_tcsicmp(_A2T(mpath.at(j)),fpath)==0)
+ if (_tcsicmp(_A2T(mpath.at(j)), fpath) == 0)
{
//pfad stimmt überein, commandline prüfen
- if (checkCommandLine(op,this->mustcontain,this->notcontain))
+ if (checkCommandLine(op, this->mustcontain, this->notcontain))
{
//handle zumachen
CloseHandle(op);
@@ -236,31 +236,31 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) }
else //if (this->mustcontain==NULL&&this->notcontain==NULL) //spiele die was bestimmtes im pfad benötigen skippen
{
- char* exename=strrchr(this->path,'\\')+1;
+ char* exename = strrchr(this->path, '\\') + 1;
//kleiner fix bei fehlerhaften pfaden kann keine exe ermittelt werden also SKIP
- if ((unsigned int)exename==0x1)
+ if ((unsigned int)exename == 0x1)
return FALSE;
//vergleich die exenamen
- if (_stricmp(exename,_T2A(processInfo->szExeFile))==0)
+ if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0)
{
return TRUE;
}
else //anderen pfade des games noch durchprüfen
{
- int size=mpath.size();
- for(int j=0;j<size;j++)
+ int size = mpath.size();
+ for (int j = 0; j < size; j++)
{
//exenamen rausfischen
- char* exename=strrchr(mpath.at(j),'\\')+1;
+ char* exename = strrchr(mpath.at(j), '\\') + 1;
//mhn keien exe, nächsten pfad prüfen
- if ((unsigned int)exename==0x1)
+ if ((unsigned int)exename == 0x1)
continue;
//exe vergleichen
- if (_stricmp(exename,_T2A(processInfo->szExeFile))==0)
+ if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0)
{
//positive antwort an die gamedetection
return TRUE;
@@ -274,66 +274,66 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) }
//icondaten setzen
-void Xfire_game::setIcon(HICON hicon,HANDLE handle) {
- this->hicon=hicon;
- this->iconhandl=handle;
+void Xfire_game::setIcon(HICON hicon, HANDLE handle) {
+ this->hicon = hicon;
+ this->iconhandl = handle;
}
//liest gamewerte aus der db
void Xfire_game::readFromDB(unsigned dbid)
{
//lese alle string werte aus der db und befülle die passenden variablen damit
- this->readStringfromDB("gamepath",dbid,&this->path);
+ this->readStringfromDB("gamepath", dbid, &this->path);
//8.3 fix, prüfe auf ~ pfad, wenn ja pfad var umwalnd in longname
if (this->path)
{
- BOOL found=FALSE;
- for(unsigned int i=0;i<strlen(this->path);i++)
+ BOOL found = FALSE;
+ for (unsigned int i = 0; i < strlen(this->path); i++)
{
if (this->path[i] == '~')
{
- found=TRUE;
+ found = TRUE;
break;
}
}
//gefunden? dann stirng wandeln und in pfad speichern
if (found) {
- char ctemp[MAX_PATH]="";
- strcpy_s(ctemp,MAX_PATH,this->path);
- GetLongPathNameA(ctemp,ctemp,sizeof(ctemp));
+ char ctemp[MAX_PATH] = "";
+ strcpy_s(ctemp, MAX_PATH, this->path);
+ GetLongPathNameA(ctemp, ctemp, sizeof(ctemp));
this->strtolower(ctemp);
- this->setString(ctemp,&this->path);
+ this->setString(ctemp, &this->path);
}
}
- this->readStringfromDB("gamelaunch",dbid,&this->launchparams);
- this->readStringfromDB("gamenetargs",dbid,&this->networkparams);
- this->readStringfromDB("gamepwargs",dbid,&this->pwparams);
- this->readStringfromDB("gameuserargs",dbid,&this->userparams);
- this->readStringfromDB("gamecmdline",dbid,&this->mustcontain);
- this->readStringfromDB("gamencmdline",dbid,&this->notcontain);
+ this->readStringfromDB("gamelaunch", dbid, &this->launchparams);
+ this->readStringfromDB("gamenetargs", dbid, &this->networkparams);
+ this->readStringfromDB("gamepwargs", dbid, &this->pwparams);
+ this->readStringfromDB("gameuserargs", dbid, &this->userparams);
+ this->readStringfromDB("gamecmdline", dbid, &this->mustcontain);
+ this->readStringfromDB("gamencmdline", dbid, &this->notcontain);
//alle sonstigen werte
- this->id=this->readWordfromDB("gameid",dbid);
- this->send_gameid=this->readWordfromDB("gamesendid",dbid);
- if (this->send_gameid==0)
- this->send_gameid=this->id;
- this->setstatusmsg=this->readWordfromDB("gamesetsmsg",dbid,0);
- this->custom=this->readBytefromDB("gamecustom",dbid,0);
- this->skip=this->readBytefromDB("gameskip",this->id,0);
- this->notinstartmenu=this->readBytefromDB("notinstartmenu",this->id,0);
- this->noicqstatus=this->readBytefromDB("gamenostatus",this->id,0);
- this->readStringfromDB("gameextraparams",this->id,&this->extraparams);
- this->readStringfromDB("customgamename",this->id,&this->customgamename);
- this->readUtf8StringfromDB("statusmsg",this->id,&this->statusmsg);
+ this->id = this->readWordfromDB("gameid", dbid);
+ this->send_gameid = this->readWordfromDB("gamesendid", dbid);
+ if (this->send_gameid == 0)
+ this->send_gameid = this->id;
+ this->setstatusmsg = this->readWordfromDB("gamesetsmsg", dbid, 0);
+ this->custom = this->readBytefromDB("gamecustom", dbid, 0);
+ this->skip = this->readBytefromDB("gameskip", this->id, 0);
+ this->notinstartmenu = this->readBytefromDB("notinstartmenu", this->id, 0);
+ this->noicqstatus = this->readBytefromDB("gamenostatus", this->id, 0);
+ this->readStringfromDB("gameextraparams", this->id, &this->extraparams);
+ this->readStringfromDB("customgamename", this->id, &this->customgamename);
+ this->readUtf8StringfromDB("statusmsg", this->id, &this->statusmsg);
//mehrere pfade
- int size=this->readWordfromDB("gamemulti",dbid,0);
- for(int j=0;j<size;j++)
+ int size = this->readWordfromDB("gamemulti", dbid, 0);
+ for (int j = 0; j < size; j++)
{
- char* tpath=NULL;
- this->readStringfromDB("gamepath",dbid,j,&tpath);
+ char* tpath = NULL;
+ this->readStringfromDB("gamepath", dbid, j, &tpath);
if (tpath)
{
@@ -350,17 +350,17 @@ void Xfire_game::setNameandIcon() {
if (this->customgamename)
{
- this->setString(this->customgamename,&this->name);
+ this->setString(this->customgamename, &this->name);
}
else
{
//std::string game=GetGame(this->id,0,&this->iconhandl,&this->hicon,TRUE);
//zielbuffer für den namen
- char buf[XFIRE_MAXSIZEOFGAMENAME]="Unknown Game";
+ char buf[XFIRE_MAXSIZEOFGAMENAME] = "Unknown Game";
//name des spiels auslesen
- this->getGamename(this->id,buf,XFIRE_MAXSIZEOFGAMENAME);
+ this->getGamename(this->id, buf, XFIRE_MAXSIZEOFGAMENAME);
//namen setzen
- this->setString(buf,&this->name);
+ this->setString(buf, &this->name);
}
}
@@ -368,88 +368,88 @@ void Xfire_game::setNameandIcon() void Xfire_game::writeToDB(unsigned dbid)
{
//alle stringwerte schreiben
- this->writeStringtoDB("gamepath",dbid,this->path);
- this->writeStringtoDB("gamelaunch",dbid,this->launchparams);
- this->writeStringtoDB("gamenetargs",dbid,this->networkparams);
- this->writeStringtoDB("gamepwargs",dbid,this->pwparams);
- this->writeStringtoDB("gameuserargs",dbid,this->userparams);
- this->writeStringtoDB("gamecmdline",dbid,this->mustcontain);
- this->writeStringtoDB("gamencmdline",dbid,this->notcontain);
+ this->writeStringtoDB("gamepath", dbid, this->path);
+ this->writeStringtoDB("gamelaunch", dbid, this->launchparams);
+ this->writeStringtoDB("gamenetargs", dbid, this->networkparams);
+ this->writeStringtoDB("gamepwargs", dbid, this->pwparams);
+ this->writeStringtoDB("gameuserargs", dbid, this->userparams);
+ this->writeStringtoDB("gamecmdline", dbid, this->mustcontain);
+ this->writeStringtoDB("gamencmdline", dbid, this->notcontain);
//alle sonstigen werte
- this->writeWordtoDB("gameid",dbid,this->id);
- if (this->send_gameid!=0&&this->send_gameid!=this->id) this->writeWordtoDB("gamesendid",dbid,this->send_gameid);
- if (this->setstatusmsg!=0) this->writeWordtoDB("gamesetsmsg",dbid,this->setstatusmsg);
- if (this->custom!=0) this->writeBytetoDB("gamecustom",dbid,this->custom);
+ this->writeWordtoDB("gameid", dbid, this->id);
+ if (this->send_gameid != 0 && this->send_gameid != this->id) this->writeWordtoDB("gamesendid", dbid, this->send_gameid);
+ if (this->setstatusmsg != 0) this->writeWordtoDB("gamesetsmsg", dbid, this->setstatusmsg);
+ if (this->custom != 0) this->writeBytetoDB("gamecustom", dbid, this->custom);
//wenn gesetzt, dann eintrag machen
- if (this->skip!=0)
- this->writeBytetoDB("gameskip",this->id,this->skip);
+ if (this->skip != 0)
+ this->writeBytetoDB("gameskip", this->id, this->skip);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("gameskip",this->id);
- if (this->notinstartmenu!=0)
- this->writeBytetoDB("notinstartmenu",this->id,this->notinstartmenu);
+ this->removeDBEntry("gameskip", this->id);
+ if (this->notinstartmenu != 0)
+ this->writeBytetoDB("notinstartmenu", this->id, this->notinstartmenu);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("notinstartmenu",this->id);
- if (this->noicqstatus!=0)
- this->writeBytetoDB("gamenostatus",this->id,this->noicqstatus);
+ this->removeDBEntry("notinstartmenu", this->id);
+ if (this->noicqstatus != 0)
+ this->writeBytetoDB("gamenostatus", this->id, this->noicqstatus);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("gamenostatus",this->id);
- if (this->extraparams!=0)
- this->writeStringtoDB("gameextraparams",this->id,this->extraparams);
+ this->removeDBEntry("gamenostatus", this->id);
+ if (this->extraparams != 0)
+ this->writeStringtoDB("gameextraparams", this->id, this->extraparams);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("gameextraparams",this->id);
- if (this->customgamename!=0)
- this->writeStringtoDB("customgamename",this->id,this->customgamename);
+ this->removeDBEntry("gameextraparams", this->id);
+ if (this->customgamename != 0)
+ this->writeStringtoDB("customgamename", this->id, this->customgamename);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("customgamename",this->id);
- if (this->statusmsg!=0)
- this->writeUtf8StringtoDB("statusmsg",this->id,this->statusmsg);
+ this->removeDBEntry("customgamename", this->id);
+ if (this->statusmsg != 0)
+ this->writeUtf8StringtoDB("statusmsg", this->id, this->statusmsg);
else //wenn nicht eintrag aus db löschen
- this->removeDBEntry("statusmsg",this->id);
+ this->removeDBEntry("statusmsg", this->id);
//mehrere pfade
- int size=mpath.size();
- if (size>0)
+ int size = mpath.size();
+ if (size > 0)
{
- this->writeWordtoDB("gamemulti",dbid,mpath.size());
- for(int j=0;j<size;j++)
+ this->writeWordtoDB("gamemulti", dbid, mpath.size());
+ for (int j = 0; j < size; j++)
{
- this->writeStringtoDB("gamepath",dbid,j,mpath.at(j));
+ this->writeStringtoDB("gamepath", dbid, j, mpath.at(j));
}
}
-
+
//sendid 0 dann standard id reinladen
- if (this->send_gameid==0)
- this->send_gameid=this->id;
+ if (this->send_gameid == 0)
+ this->send_gameid = this->id;
}
//erzeugt ein menüpunkt
-void Xfire_game::createMenuitem(unsigned int pos,int dbid)
+void Xfire_game::createMenuitem(unsigned int pos, int dbid)
{
char servicefunction[100];
strcpy(servicefunction, protocolname);
strcat(servicefunction, "StartGame%d");
- if (dbid<0)
- dbid=pos;
-
+ if (dbid < 0)
+ dbid = pos;
+
CLISTMENUITEM mi = { sizeof(mi) };
mi.popupPosition = 500084000;
mi.pszPopupName = Translate("Start game");
- mi.pszContactOwner=protocolname;
+ mi.pszContactOwner = protocolname;
mir_snprintf(temp, SIZEOF(temp), servicefunction, this->id);
//wenn die servicefunktion schon exisitert vernichten, hehe
- if (ServiceExists(temp))
+ if (ServiceExists(temp))
DestroyServiceFunction(temp);
- CreateServiceFunctionParam(temp,StartGame,this->id);
+ CreateServiceFunctionParam(temp, StartGame, this->id);
mi.pszService = temp;
- mi.position = 500090002+pos;
- mi.hIcon = this->hicon?this->hicon:LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.position = 500090002 + pos;
+ mi.hIcon = this->hicon ? this->hicon : LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
mi.pszName = menuitemtext(this->name);
- this->menuhandle=Menu_AddMainMenuItem(&mi);
+ this->menuhandle = Menu_AddMainMenuItem(&mi);
//menu aktualisieren ob hidden
this->refreshMenuitem();
@@ -458,10 +458,10 @@ void Xfire_game::createMenuitem(unsigned int pos,int dbid) //entfernt menüpunkt
void Xfire_game::remoteMenuitem()
{
- if (menuhandle!=NULL)
+ if (menuhandle != NULL)
{
- CallService(MO_REMOVEMENUITEM, (WPARAM)menuhandle, 0 );
- menuhandle=NULL;
+ CallService(MO_REMOVEMENUITEM, (WPARAM)menuhandle, 0);
+ menuhandle = NULL;
}
}
diff --git a/protocols/Xfire/src/Xfire_game.h b/protocols/Xfire/src/Xfire_game.h index 8be3428983..1e817ce503 100644 --- a/protocols/Xfire/src/Xfire_game.h +++ b/protocols/Xfire/src/Xfire_game.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -19,14 +19,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
/*
Beinhaltet alle Funktionen und Informationen des Spiels
-*/
+ */
#ifndef _XFIRE_GAME
#define _XFIRE_GAME
@@ -37,158 +37,158 @@ using namespace std;
//externe funktion die das spielstarten steuern
-extern INT_PTR StartGame(WPARAM wParam, LPARAM lParam,LPARAM fParam);
+extern INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam);
class Xfire_game : public Xfire_base {
public:
- //id des spiels
- unsigned int id;
- //handle des menuitems
- HGENMENU menuhandle;
- //spiel soll bei der detection übersprungen werden
- BOOL skip;
- //voicehat?
- BOOL voicechat;
- //es soll kein icq und co status gesetzt werden
- BOOL noicqstatus;
- //handelt es sich um ein "custom" spiel
- BOOL custom;
- //soll ein spez. status gesetzt werden
- BOOL setstatusmsg;
- //iconhandle von miranda
- HANDLE iconhandl;
- //hicon vom icon des spiels
- HICON hicon;
- //dont show in startmenü
- BOOL notinstartmenu;
+ //id des spiels
+ unsigned int id;
+ //handle des menuitems
+ HGENMENU menuhandle;
+ //spiel soll bei der detection übersprungen werden
+ BOOL skip;
+ //voicehat?
+ BOOL voicechat;
+ //es soll kein icq und co status gesetzt werden
+ BOOL noicqstatus;
+ //handelt es sich um ein "custom" spiel
+ BOOL custom;
+ //soll ein spez. status gesetzt werden
+ BOOL setstatusmsg;
+ //iconhandle von miranda
+ HANDLE iconhandl;
+ //hicon vom icon des spiels
+ HICON hicon;
+ //dont show in startmenü
+ BOOL notinstartmenu;
- //pfad des spiels wenn es laufen sollte
- char* path;
- //startparameter des spiels
- char* launchparams;
- //netzwerkparameter
- char* networkparams;
- //username parameter
- char* userparams;
- //passwort paramter
- char* pwparams;
- //mustcontain parameter
- char* mustcontain;
- //notcontain parameter
- char* notcontain;
- //spielname
- char* name;
- //extraparameter
- char* extraparams;
- //custom gamename
- char* customgamename;
- //custom statusmsg for xfire
- char* statusmsg;
+ //pfad des spiels wenn es laufen sollte
+ char* path;
+ //startparameter des spiels
+ char* launchparams;
+ //netzwerkparameter
+ char* networkparams;
+ //username parameter
+ char* userparams;
+ //passwort paramter
+ char* pwparams;
+ //mustcontain parameter
+ char* mustcontain;
+ //notcontain parameter
+ char* notcontain;
+ //spielname
+ char* name;
+ //extraparameter
+ char* extraparams;
+ //custom gamename
+ char* customgamename;
+ //custom statusmsg for xfire
+ char* statusmsg;
- //mehrere pfade
- vector<char*> mpath;
+ //mehrere pfade
+ vector<char*> mpath;
- //zu sende gameid
- signed short send_gameid;
+ //zu sende gameid
+ signed short send_gameid;
- //konstruktor
- Xfire_game() {
- //vars leer setzen
- path=NULL;
- launchparams=NULL;
- networkparams=NULL;
- userparams=NULL;
- pwparams=NULL;
- mustcontain=NULL;
- notcontain=NULL;
- name=NULL;
- menuhandle=NULL;
- iconhandl=NULL;
- hicon=NULL;
- extraparams=NULL;
- customgamename=NULL;
- statusmsg=NULL;
- id=skip=noicqstatus=custom=setstatusmsg=send_gameid=notinstartmenu=voicechat=0;
+ //konstruktor
+ Xfire_game() {
+ //vars leer setzen
+ path = NULL;
+ launchparams = NULL;
+ networkparams = NULL;
+ userparams = NULL;
+ pwparams = NULL;
+ mustcontain = NULL;
+ notcontain = NULL;
+ name = NULL;
+ menuhandle = NULL;
+ iconhandl = NULL;
+ hicon = NULL;
+ extraparams = NULL;
+ customgamename = NULL;
+ statusmsg = NULL;
+ id = skip = noicqstatus = custom = setstatusmsg = send_gameid = notinstartmenu = voicechat = 0;
+ }
+ //dekonstruktor
+ ~Xfire_game() {
+ //entferne dyn arrays
+ if (path)
+ {
+ delete[] path;
+ path = NULL;
+ }
+ if (launchparams)
+ {
+ delete[] launchparams;
+ launchparams = NULL;
+ }
+ if (networkparams)
+ {
+ delete[] networkparams;
+ networkparams = NULL;
+ }
+ if (userparams)
+ {
+ delete[] userparams;
+ userparams = NULL;
+ }
+ if (pwparams)
+ {
+ delete[] pwparams;
+ pwparams = NULL;
+ }
+ if (mustcontain)
+ {
+ delete[] mustcontain;
+ mustcontain = NULL;
+ }
+ if (notcontain)
+ {
+ delete[] notcontain;
+ notcontain = NULL;
+ }
+ if (name)
+ {
+ delete[] name;
+ name = NULL;
+ }
+ if (extraparams)
+ {
+ delete[] extraparams;
+ extraparams = NULL;
+ }
+ if (customgamename)
+ {
+ delete[] customgamename;
+ customgamename = NULL;
+ }
+ if (statusmsg)
+ {
+ delete[] statusmsg;
+ statusmsg = NULL;
}
- //dekonstruktor
- ~Xfire_game() {
- //entferne dyn arrays
- if (path)
- {
- delete[] path;
- path=NULL;
- }
- if (launchparams)
- {
- delete[] launchparams;
- launchparams=NULL;
- }
- if (networkparams)
- {
- delete[] networkparams;
- networkparams=NULL;
- }
- if (userparams)
- {
- delete[] userparams;
- userparams=NULL;
- }
- if (pwparams)
- {
- delete[] pwparams;
- pwparams=NULL;
- }
- if (mustcontain)
- {
- delete[] mustcontain;
- mustcontain=NULL;
- }
- if (notcontain)
- {
- delete[] notcontain;
- notcontain=NULL;
- }
- if (name)
- {
- delete[] name;
- name=NULL;
- }
- if (extraparams)
- {
- delete[] extraparams;
- extraparams=NULL;
- }
- if (customgamename)
- {
- delete[] customgamename;
- customgamename=NULL;
- }
- if (statusmsg)
- {
- delete[] statusmsg;
- statusmsg=NULL;
- }
-
- for(unsigned int i = 0 ; i < mpath.size() ; i ++) {
- if (mpath.at(i)!=NULL)
- delete mpath.at(i);
- }
- mpath.clear();
- remoteMenuitem();
+ for (unsigned int i = 0; i < mpath.size(); i++) {
+ if (mpath.at(i) != NULL)
+ delete mpath.at(i);
}
+ mpath.clear();
+
+ remoteMenuitem();
+ }
- //funktionen
- void readFromDB(unsigned dbid);
- void writeToDB(unsigned dbid);
- void createMenuitem(unsigned int pos,int dbid=-1);
- void refreshMenuitem();
- void remoteMenuitem();
- void setNameandIcon();
- void setIcon(HICON hicon,HANDLE handle);
- BOOL checkpath(PROCESSENTRY32* processInfo);
- BOOL start_game(char*ip=NULL,unsigned int port=0,char*pw=NULL);
- BOOL haveExtraGameArgs();
+ //funktionen
+ void readFromDB(unsigned dbid);
+ void writeToDB(unsigned dbid);
+ void createMenuitem(unsigned int pos, int dbid = -1);
+ void refreshMenuitem();
+ void remoteMenuitem();
+ void setNameandIcon();
+ void setIcon(HICON hicon, HANDLE handle);
+ BOOL checkpath(PROCESSENTRY32* processInfo);
+ BOOL start_game(char*ip = NULL, unsigned int port = 0, char*pw = NULL);
+ BOOL haveExtraGameArgs();
};
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/Xfire_gamelist.cpp b/protocols/Xfire/src/Xfire_gamelist.cpp index cf028c358a..728c9c7bb9 100644 --- a/protocols/Xfire/src/Xfire_gamelist.cpp +++ b/protocols/Xfire/src/Xfire_gamelist.cpp @@ -5,7 +5,7 @@ //liefert bestimmtes game zurück
Xfire_game* Xfire_gamelist::getGame(unsigned int dbid)
{
- if (dbid<gamelist.size())
+ if (dbid < gamelist.size())
{
return gamelist.at(dbid);
}
@@ -15,9 +15,9 @@ Xfire_game* Xfire_gamelist::getGame(unsigned int dbid) //liefert bestimmtes game zurück
Xfire_game* Xfire_gamelist::getGamebyGameid(unsigned int gameid)
{
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
- if (game->id==gameid)
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
+ if (game->id == gameid)
return game;
}
return NULL;
@@ -25,17 +25,17 @@ Xfire_game* Xfire_gamelist::getGamebyGameid(unsigned int gameid) void Xfire_gamelist::readGamelist(int anz) {
//spiele einzeln einlesen
- for(int i=0;i<anz;i++)
+ for (int i = 0; i < anz; i++)
{
//erzeuge gameobject
- Xfire_game* game=new Xfire_game();
+ Xfire_game* game = new Xfire_game();
if (game) {
//lese das spiel ein
game->readFromDB(i);
//icons laden
- Xfire_icon_cache icon=this->iconmngr.getGameIconEntry(game->id);
- game->setIcon(icon.hicon,icon.handle);
+ Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(game->id);
+ game->setIcon(icon.hicon, icon.handle);
//in die liste einfügen
gamelist.push_back(game);
}
@@ -45,20 +45,20 @@ void Xfire_gamelist::readGamelist(int anz) { //setzt den ingamestatus
void Xfire_gamelist::SetGameStatus(BOOL status)
{
- ingame=status;
+ ingame = status;
}
Xfire_gamelist::Xfire_gamelist()
{
- nextgameid=0;
- ingame=FALSE;
+ nextgameid = 0;
+ ingame = FALSE;
InitializeCriticalSection(&gamlistMutex);
}
//dekonstruktor
Xfire_gamelist::~Xfire_gamelist() {
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game) delete game;
}
gamelist.clear();
@@ -69,17 +69,17 @@ Xfire_gamelist::~Xfire_gamelist() { BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame)
{
//kein pointer dann false zurückliefern
- if (currentgame==NULL)
+ if (currentgame == NULL)
return FALSE;
//is die derzeitige id kleiner wie die anzahl an games, dann passendes game zurückliefern
- if (nextgameid<gamelist.size())
+ if (nextgameid < gamelist.size())
{
- *currentgame=gamelist.at(nextgameid);
+ *currentgame = gamelist.at(nextgameid);
nextgameid++;
//muss das spiel geskippt werden, dann nochmal funktion aufrufen um das nächste game zubekommen
- if ((*currentgame)->skip||(*currentgame)->id==32||(*currentgame)->id==33||(*currentgame)->id==34||(*currentgame)->id==35)
+ if ((*currentgame)->skip || (*currentgame)->id == 32 || (*currentgame)->id == 33 || (*currentgame)->id == 34 || (*currentgame)->id == 35)
{
return getnextGame(currentgame);
}
@@ -89,7 +89,7 @@ BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame) else
{
//liste durchgearbeitet, nextid wieder auf 0 setzen
- nextgameid=0;
+ nextgameid = 0;
return FALSE;
}
}
@@ -106,8 +106,8 @@ void Xfire_gamelist::Block(BOOL block) void Xfire_gamelist::Addgame(Xfire_game* newgame)
{
//spielicon auslesen
- Xfire_icon_cache icon=this->iconmngr.getGameIconEntry(newgame->id);
- newgame->setIcon(icon.hicon,icon.handle);
+ Xfire_icon_cache icon = this->iconmngr.getGameIconEntry(newgame->id);
+ newgame->setIcon(icon.hicon, icon.handle);
gamelist.push_back(newgame);
}
@@ -116,7 +116,7 @@ void Xfire_gamelist::Addgame(Xfire_game* newgame) BOOL Xfire_gamelist::Removegame(int id)
{
std::vector<Xfire_game *>::iterator i = gamelist.begin();
- while( i != gamelist.end() ) {
+ while (i != gamelist.end()) {
if ((*i)->id == id) {
(*i)->remoteMenuitem();
gamelist.erase(i);
@@ -131,48 +131,47 @@ BOOL Xfire_gamelist::Removegame(int id) int Xfire_gamelist::CurrentGame()
{
this->SetGameStatus(TRUE);
- return nextgameid-1;
+ return nextgameid - 1;
}
//erzeugt das menu der gameliste
void Xfire_gamelist::createStartmenu()
{
//keine games in der internen liste? abbruch
- if (gamelist.size()==0)
+ if (gamelist.size() == 0)
return;
//sortierarray
- int* sorttemp=new int[gamelist.size()];
+ int* sorttemp = new int[gamelist.size()];
//zuordnungen setzen
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++)
- sorttemp[i]=i;
+ for (unsigned int i = 0; i < gamelist.size(); i++)
+ sorttemp[i] = i;
//sortiert mit bubblesortalgo
- BOOL changed=FALSE;
+ BOOL changed = FALSE;
do
{
- changed=FALSE;
- for(unsigned int i = 1 ; i < gamelist.size() ; i ++)
+ changed = FALSE;
+ for (unsigned int i = 1; i < gamelist.size(); i++)
{
- Xfire_game* game=(Xfire_game*)gamelist.at(sorttemp[i-1]);
- Xfire_game* game2=(Xfire_game*)gamelist.at(sorttemp[i]);
+ Xfire_game* game = (Xfire_game*)gamelist.at(sorttemp[i - 1]);
+ Xfire_game* game2 = (Xfire_game*)gamelist.at(sorttemp[i]);
//sortieren
- if (strcmp(game->name,game2->name)>0)
+ if (strcmp(game->name, game2->name) > 0)
{
- int tempi=sorttemp[i-1];
- sorttemp[i-1]=sorttemp[i];
- sorttemp[i]=tempi;
- changed=TRUE;
+ int tempi = sorttemp[i - 1];
+ sorttemp[i - 1] = sorttemp[i];
+ sorttemp[i] = tempi;
+ changed = TRUE;
}
}
- }
- while(changed);
+ } while (changed);
//menüpunkte anlegen
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(sorttemp[i]);
- game->createMenuitem(i,sorttemp[i]);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(sorttemp[i]);
+ game->createMenuitem(i, sorttemp[i]);
}
//entferne sortarray
@@ -185,8 +184,8 @@ void Xfire_gamelist::createStartmenu() //schreibt derzeitige gameliste in die db
void Xfire_gamelist::writeDatabase()
{
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game) game->writeToDB(i);
}
@@ -195,17 +194,17 @@ void Xfire_gamelist::writeDatabase() }
//prüft ob ein game schon in der liste is
-BOOL Xfire_gamelist::Gameinlist(int id,int*dbid)
+BOOL Xfire_gamelist::Gameinlist(int id, int*dbid)
{
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game)
{
- if (game->id==id)
+ if (game->id == id)
{
//soll eine dbid zurückgeliefert werden? dann setzen
if (dbid)
- *dbid=i;
+ *dbid = i;
return TRUE;
}
@@ -227,8 +226,8 @@ void Xfire_gamelist::clearStartmenu() createDummyMenuItem();
//einzelene menüpunkte entfernen
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game) game->remoteMenuitem();
}
}
@@ -236,8 +235,8 @@ void Xfire_gamelist::clearStartmenu() //dekonstruktor
void Xfire_gamelist::clearGamelist() {
createDummyMenuItem();
- for(unsigned int i = 0 ; i < gamelist.size() ; i ++) {
- Xfire_game* game=(Xfire_game*)gamelist.at(i);
+ for (unsigned int i = 0; i < gamelist.size(); i++) {
+ Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game) delete game;
}
gamelist.clear();
@@ -249,36 +248,36 @@ void Xfire_gamelist::createDummyMenuItem() CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 500090001;
mi.pszName = Translate("Please wait...");
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
mi.popupPosition = 500084000;
mi.pszPopupName = Translate("Start game");
- mi.pszContactOwner=protocolname;
+ mi.pszContactOwner = protocolname;
dummymenuitem = Menu_AddMainMenuItem(&mi);
}
//entfernt dummymenueintrag
void Xfire_gamelist::removeDummyMenuItem()
{
- CallService(MO_REMOVEMENUITEM, (WPARAM)dummymenuitem, 0 );
+ CallService(MO_REMOVEMENUITEM, (WPARAM)dummymenuitem, 0);
}
//säubert die datenbank spiel einträge udn trägt custom spiele vorher nach
void Xfire_gamelist::clearDatabase(BOOL dontaddcustom)
{
- BOOL somethingfound=TRUE;
- int i3=0;
+ BOOL somethingfound = TRUE;
+ int i3 = 0;
//db durchsuchen
- while(somethingfound) {
- somethingfound=FALSE;
+ while (somethingfound) {
+ somethingfound = FALSE;
//customeintrag? dann ab in die gameliste damit
- if (this->readBytefromDB("gamecustom",i3)==1)
+ if (this->readBytefromDB("gamecustom", i3) == 1)
{
//customgame nur in die liste adden wenn es gewollt is
if (!dontaddcustom)
{
//erzeuge gameobject
- Xfire_game* game=new Xfire_game();
+ Xfire_game* game = new Xfire_game();
//lese das spiel ein
game->readFromDB(i3);
//spielicon auslesen
@@ -290,21 +289,21 @@ void Xfire_gamelist::clearDatabase(BOOL dontaddcustom) }
}
- if (this->removeDBEntry("gamecustom",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gameid",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamepath",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamepwargs",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gameuserargs",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamecmdline",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamencmdline",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamelaunch",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamenetargs",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamemulti",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamesendid",i3)) somethingfound=TRUE;
- if (this->removeDBEntry("gamesetsmsg",i3)) somethingfound=TRUE;
-
- for(int i2=0;i2<10;i2++)
- if (this->removeDBEntry("gamepath",i3,i2)) somethingfound=TRUE;
+ if (this->removeDBEntry("gamecustom", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gameid", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamepath", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamepwargs", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gameuserargs", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamecmdline", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamencmdline", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamelaunch", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamenetargs", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamemulti", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamesendid", i3)) somethingfound = TRUE;
+ if (this->removeDBEntry("gamesetsmsg", i3)) somethingfound = TRUE;
+
+ for (int i2 = 0; i2 < 10; i2++)
+ if (this->removeDBEntry("gamepath", i3, i2)) somethingfound = TRUE;
i3++;
}
}
\ No newline at end of file diff --git a/protocols/Xfire/src/Xfire_gamelist.h b/protocols/Xfire/src/Xfire_gamelist.h index 2d134bbb9a..3cdf8eb9a9 100644 --- a/protocols/Xfire/src/Xfire_gamelist.h +++ b/protocols/Xfire/src/Xfire_gamelist.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -27,7 +27,7 @@ /*
Klasse soll die Gameliste verwalten. Dazu gehört das dynamische Einfügen/Löschen/Verändern von Games.
Erstellen/Sortieren der Menüpunkte...
-*/
+ */
#ifndef _XFIRE_GAMELIST
#define _XFIRE_GAMELIST
@@ -55,16 +55,16 @@ public: void clearGamelist();
void createStartmenu();
void clearStartmenu();
- void clearDatabase(BOOL dontaddcustom=FALSE);
+ void clearDatabase(BOOL dontaddcustom = FALSE);
void writeDatabase();
- BOOL Gameinlist(int id,int*dbid=NULL);
+ BOOL Gameinlist(int id, int*dbid = NULL);
void Addgame(Xfire_game* newgame);
BOOL Xfire_gamelist::Removegame(int id);
int countGames();
~Xfire_gamelist();
Xfire_gamelist();
BOOL getnextGame(Xfire_game**currentgame);
- BOOL Ingame(){return ingame;}
+ BOOL Ingame(){ return ingame; }
void SetGameStatus(BOOL ingame);
int CurrentGame();
Xfire_game* getGame(unsigned int dbid);
diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp index 1d551a1f3d..74028196f2 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.cpp +++ b/protocols/Xfire/src/Xfire_icon_mng.cpp @@ -3,10 +3,10 @@ //liefert den handle eines icons zurück
HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid) {
- Xfire_icon_cache entry={0};
+ Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
- if (getIconfromCache(gameid,&entry))
+ if (getIconfromCache(gameid, &entry))
return entry.handle;
//ansonsten gameicon laden
@@ -15,9 +15,9 @@ HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid) { //liefert den index des icons zurück
unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) {
- for(unsigned int i=0;i<iconcache.size();i++)
+ for (unsigned int i = 0; i < iconcache.size(); i++)
{
- if (iconcache.at(i).gameid==gameid)
+ if (iconcache.at(i).gameid == gameid)
{
return i;
}
@@ -28,7 +28,7 @@ unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) { //gameicon mit hilfe von id zurückliefern
HICON Xfire_icon_mng::getGameIconFromId(unsigned int id) {
//id nur im bereich zurückliefern
- if (id<0 || id>iconcache.size()-1)
+ if (id<0 || id>iconcache.size() - 1)
return NULL;
return iconcache.at(id).hicon;
@@ -36,10 +36,10 @@ HICON Xfire_icon_mng::getGameIconFromId(unsigned int id) { //liefert das hicon zurück
HICON Xfire_icon_mng::getGameIcon(unsigned int gameid) {
- Xfire_icon_cache entry={0};
+ Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
- if (getIconfromCache(gameid,&entry))
+ if (getIconfromCache(gameid, &entry))
return entry.hicon;
return this->LoadGameIcon(gameid).hicon;
@@ -47,26 +47,26 @@ HICON Xfire_icon_mng::getGameIcon(unsigned int gameid) { //liefert den icon eintrag zurück
Xfire_icon_cache Xfire_icon_mng::getGameIconEntry(unsigned int gameid) {
- Xfire_icon_cache entry={0};
+ Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
- if (getIconfromCache(gameid,&entry))
+ if (getIconfromCache(gameid, &entry))
return entry;
return this->LoadGameIcon(gameid);
}
//sucht nach dem spielicon im cache
-BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid,Xfire_icon_cache* out) {
+BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid, Xfire_icon_cache* out) {
//kein ziel, keine prüfung
- if (out==NULL)
+ if (out == NULL)
return FALSE;
- for(unsigned int i=0;i<iconcache.size();i++)
+ for (unsigned int i = 0; i < iconcache.size(); i++)
{
- if (iconcache.at(i).gameid==gameid)
+ if (iconcache.at(i).gameid == gameid)
{
- *out=iconcache.at(i);
+ *out = iconcache.at(i);
return TRUE;
}
}
@@ -78,12 +78,12 @@ BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid,Xfire_icon_cache* out) //dekonstruktor
Xfire_icon_mng::~Xfire_icon_mng() {
//geladene icons wieder freigeben
- for(unsigned int i=0;i<iconcache.size();i++)
+ for (unsigned int i = 0; i < iconcache.size(); i++)
{
if (iconcache.at(i).hicon)
{
DestroyIcon(iconcache.at(i).hicon);
- iconcache.at(i).hicon=NULL;
+ iconcache.at(i).hicon = NULL;
}
}
iconcache.clear();
@@ -91,13 +91,13 @@ Xfire_icon_mng::~Xfire_icon_mng() { //Icons.dll wieder freigeben
if (hIconDll) {
FreeLibrary(hIconDll);
- hIconDll=NULL;
+ hIconDll = NULL;
}
}
//konstruktor
Xfire_icon_mng::Xfire_icon_mng() {
- hIconDll=NULL;
+ hIconDll = NULL;
}
//erzeugt aus HICON ein Handle, welches in Miranda in der Clist angewendet werden kann
@@ -110,49 +110,49 @@ HANDLE Xfire_icon_mng::createIconHandle(HICON hicon) { //eigentliche laderoutine
Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) {
- Xfire_icon_cache entry={0};
+ Xfire_icon_cache entry = { 0 };
//shortname
- char shortname[255]="";
+ char shortname[255] = "";
- if (!getIniValue(gameid,"ShortName",shortname))
+ if (!getIniValue(gameid, "ShortName", shortname))
return entry;
//spielid zuweisen
- entry.gameid=gameid;
+ entry.gameid = gameid;
//Icons.dll noch nicht geladen?!?
if (!hIconDll)
{
//versuch die Icons.dll zuladen
- char path[MAX_PATH]="";
+ char path[MAX_PATH] = "";
if (!getIconPath(path))
return entry;
- strcat_s(path,MAX_PATH,IconsdllName);
+ strcat_s(path, MAX_PATH, IconsdllName);
hIconDll = LoadLibraryA(path);
}
//dll konnte geladen werden
if (hIconDll) {
- char resourcename[255]="";
+ char resourcename[255] = "";
//kurznamen des spiels uppercasen und .ICO anhängen
- mir_snprintf(resourcename,255,"XF_%s.ICO",shortname);
+ mir_snprintf(resourcename, 255, "XF_%s.ICO", shortname);
Xfire_base::strtoupper(resourcename);
//versuche die resource zufinden
- HRSRC hrsrc = FindResourceA(hIconDll,resourcename,"ICONS");
+ HRSRC hrsrc = FindResourceA(hIconDll, resourcename, "ICONS");
if (hrsrc) {
//aus der resource ein HICON erstellen
- int size=SizeofResource(hIconDll,hrsrc);
+ int size = SizeofResource(hIconDll, hrsrc);
//iconresource laden
- HGLOBAL hglobal=LoadResource(hIconDll,hrsrc);
+ HGLOBAL hglobal = LoadResource(hIconDll, hrsrc);
if (hglobal) {
//lock
- LPVOID data=LockResource(hglobal);
+ LPVOID data = LockResource(hglobal);
if (data) {
//erzeuge ein handle für das icon und ab in den cache damit
- entry.hicon=this->createHICONfromdata(data,size);
+ entry.hicon = this->createHICONfromdata(data, size);
UnlockResource(hglobal);
}
FreeResource(hglobal);
@@ -162,12 +162,12 @@ Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) { //kein icon in der dll, dann aus dem internet laden
if (!entry.hicon)
- entry.hicon=downloadIcon(shortname);
+ entry.hicon = downloadIcon(shortname);
//wenn ein hicon erzeugt wurde, dann handle erstellen und in den cache laden
if (entry.hicon)
- entry.handle=this->createIconHandle(entry.hicon);
-
+ entry.handle = this->createIconHandle(entry.hicon);
+
//eintrag in den cache, selbst wenn kein icon geladen werden konnte
this->iconcache.push_back(entry);
@@ -177,26 +177,26 @@ Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) { //icon vom xfire server laden
HICON Xfire_icon_mng::downloadIcon(char* shortname) {
//nur vom internetladen, wenn die option aktiv ist
- if (!db_get_b(NULL,protocolname,"xfiresitegameico",0))
+ if (!db_get_b(NULL, protocolname, "xfiresitegameico", 0))
return NULL;
-
- //keinen namen angegeben?
+
+ //keinen namen angegeben?
if (!shortname)
return NULL;
//buffer
- char*buf=NULL;
- unsigned int size=0;
+ char*buf = NULL;
+ unsigned int size = 0;
- char url[255]="http://media.xfire.com/xfire/xf/images/icons/";
- strcat_s(url,255,shortname);
- strcat_s(url,255,".gif");
+ char url[255] = "http://media.xfire.com/xfire/xf/images/icons/";
+ strcat_s(url, 255, shortname);
+ strcat_s(url, 255, ".gif");
//verscuhe das icon aus dem inet zulasen
- if (GetWWWContent2(url,NULL,FALSE,&buf,&size))
+ if (GetWWWContent2(url, NULL, FALSE, &buf, &size))
{
//aus dem buffer ein hicon erzeugen
- HICON hicon=this->createHICONfromdata(buf,size);
+ HICON hicon = this->createHICONfromdata(buf, size);
//speicher freigeben
delete[] buf;
@@ -208,9 +208,9 @@ HICON Xfire_icon_mng::downloadIcon(char* shortname) { //setzt alle handles der icons neu
int Xfire_icon_mng::resetIconHandles() {
- for(unsigned int i=0;i<iconcache.size();i++)
+ for (unsigned int i = 0; i < iconcache.size(); i++)
{
- iconcache.at(i).handle=this->createIconHandle(iconcache.at(i).hicon);
+ iconcache.at(i).handle = this->createIconHandle(iconcache.at(i).hicon);
}
return 0;
}
\ No newline at end of file diff --git a/protocols/Xfire/src/Xfire_icon_mng.h b/protocols/Xfire/src/Xfire_icon_mng.h index ddf531814b..682215d2ec 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.h +++ b/protocols/Xfire/src/Xfire_icon_mng.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2009 by
* dufte <dufte@justmail.de>
@@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -32,7 +32,7 @@ #include "Xfire_base.h"
#include <vector>
-const char IconsdllName[]="Icons.dll";
+const char IconsdllName[] = "Icons.dll";
#pragma comment(lib,"ole32.lib")
@@ -49,7 +49,7 @@ struct Xfire_icon_cache { class Xfire_icon_mng : public Xfire_base {
private:
vector<Xfire_icon_cache> iconcache;
- BOOL getIconfromCache(unsigned int gameid,Xfire_icon_cache* out);
+ BOOL getIconfromCache(unsigned int gameid, Xfire_icon_cache* out);
Xfire_icon_cache LoadGameIcon(unsigned int gameid);
HANDLE createIconHandle(HICON hicon);
HICON downloadIcon(char* shortname);
diff --git a/protocols/Xfire/src/Xfire_proxy.cpp b/protocols/Xfire/src/Xfire_proxy.cpp index 366cb891d2..fad6e879fe 100644 --- a/protocols/Xfire/src/Xfire_proxy.cpp +++ b/protocols/Xfire/src/Xfire_proxy.cpp @@ -3,51 +3,50 @@ #include "Xfire_proxy.h"
extern HANDLE hNetlib;
-HANDLE hBindPort=NULL;
-HANDLE netlibcon=NULL;
+HANDLE hBindPort = NULL;
+HANDLE netlibcon = NULL;
void FromServerToClient(LPVOID lParam) {
- char buf[1024]={0};
+ char buf[1024] = { 0 };
- HANDLE hConnection=(HANDLE)lParam;
+ HANDLE hConnection = (HANDLE)lParam;
do {
if (!hBindPort) return;
int cbRead = Netlib_Recv(netlibcon, buf, sizeof(buf), 0);
- if ( cbRead == SOCKET_ERROR)
+ if (cbRead == SOCKET_ERROR)
break;
if (cbRead) {
Netlib_Send(hConnection, buf, cbRead, 0);
}
- }
- while(1);
+ } while (1);
}
//xfireclient baut verbindung auf
-void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra )
+void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra)
{
- char buf[1024]={0};
+ char buf[1024] = { 0 };
//verbindung zum richtigen xfire server aufbauen
NETLIBOPENCONNECTION ncon = { 0 };
ncon.cbSize = sizeof(ncon);
ncon.szHost = "206.220.42.147";
ncon.wPort = (WORD)atol("25999");
- ncon.timeout=5;
- netlibcon = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
+ ncon.timeout = 5;
+ netlibcon = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlib, (LPARAM)& ncon);
if (!netlibcon) {
Netlib_CloseHandle(hConnection);
}
- mir_forkthread(FromServerToClient,(LPVOID)hConnection);
+ mir_forkthread(FromServerToClient, (LPVOID)hConnection);
//schleife behandelt empfangende daten
do {
int cbRead = Netlib_Recv(hConnection, buf, sizeof(buf), 0);
- if ( cbRead == SOCKET_ERROR)
+ if (cbRead == SOCKET_ERROR)
{
Netlib_CloseHandle(hConnection);
Netlib_CloseHandle(netlibcon);
@@ -62,26 +61,25 @@ void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra ) break;
}
}
- }
- while(1);
+ } while (1);
}
//inits nachdem alle module geladen wurden
int AfterSystemModulesLoaded(WPARAM wParam, LPARAM lParam)
{
//init netlib handle
- NETLIBUSER nlu = {0};
+ NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_INCOMING;
nlu.szSettingsModule = protocolname;
nlu.szDescriptiveName = "XFire server connection";
- hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+ hNetlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)& nlu);
//init socket server
NETLIBBIND nb = { sizeof(nb) };
nb.pfnNewConnectionV2 = XfireclientConnecting;
nb.wPort = 25999;
- hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)hNetlib,(LPARAM) &nb);
+ hBindPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)hNetlib, (LPARAM)&nb);
return 0;
}
diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp index bae2d4a2d1..66454c026e 100644 --- a/protocols/Xfire/src/Xfire_voicechat.cpp +++ b/protocols/Xfire/src/Xfire_voicechat.cpp @@ -4,10 +4,10 @@ //konstruktor
Xfire_voicechat::Xfire_voicechat() {
this->resetCurrentvoicestatus();
- ipport=NULL;
- tsrDLL=NULL;
- tsrGetServerInfo=NULL;
- pid=0;
+ ipport = NULL;
+ tsrDLL = NULL;
+ tsrGetServerInfo = NULL;
+ pid = 0;
}
//dekonstruktor
@@ -16,7 +16,7 @@ Xfire_voicechat::~Xfire_voicechat() //geladene tsr remote dll freigeben
if (tsrDLL) {
FreeLibrary(tsrDLL);
- tsrDLL=NULL;
+ tsrDLL = NULL;
}
}
@@ -24,21 +24,21 @@ Xfire_voicechat::~Xfire_voicechat() void Xfire_voicechat::initVoicechat()
{
//tsremotedll laden
- tsrDLL=this->loadTSR();
+ tsrDLL = this->loadTSR();
}
//prüft ob das paket schonmal versendet wurde, soll unnötigen nwtraffic reduzieren, *ÜBERLEGUNG* ob wirklich notwendig
BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) {
- if (packet==NULL)
+ if (packet == NULL)
return FALSE;
-
+
if (packet->ip[3] != lastpacket.ip[3] ||
- packet->ip[2] != lastpacket.ip[2] ||
- packet->ip[1] != lastpacket.ip[1] ||
- packet->ip[0] != lastpacket.ip[0] ||
- packet->port != lastpacket.port) {
- lastpacket=*packet;
- return TRUE;
+ packet->ip[2] != lastpacket.ip[2] ||
+ packet->ip[1] != lastpacket.ip[1] ||
+ packet->ip[0] != lastpacket.ip[0] ||
+ packet->port != lastpacket.port) {
+ lastpacket = *packet;
+ return TRUE;
}
return FALSE;
@@ -47,66 +47,66 @@ BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) { //prüft nach laufenden voicechat anwendungen
BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) {
//kein gültiger verweis?
- if (packet==NULL)
+ if (packet == NULL)
return FALSE;
//jeh nach letzten status handeln
- switch(currentvoice) {
- case XFIREVOICECHAT_TS2:
- if (checkforTS2(packet)) {
- return alreadySend(packet);
- }
- else
- {
- //kein ts2 mehr? dann paket restten
- resetSendGameStatus2Packet(packet);
- resetCurrentvoicestatus();
- //in db schreiben
- writeToDatabase(packet);
- return TRUE;
- }
- break;
- case XFIREVOICECHAT_TS3:
- if (checkforTS3(packet)) {
- return alreadySend(packet);
- }
- else
- {
- //kein ts3 mehr? dann paket restten
- resetSendGameStatus2Packet(packet);
- resetCurrentvoicestatus();
- //in db schreiben
- writeToDatabase(packet);
- return TRUE;
- }
- break;
- case XFIREVOICECHAT_MUMBLE:
- if (checkforMumble(packet)) {
- return alreadySend(packet);
- }
- else
- {
- //kein mumble mehr? dann paket restten
- resetSendGameStatus2Packet(packet);
- resetCurrentvoicestatus();
- //in db schreiben
- writeToDatabase(packet);
- return TRUE;
- }
- break;
- default:
- //prüfe nach ts3
- if (checkforTS3(packet)) {
- return alreadySend(packet);
- }
- //prüfe nach ts2
- else if (checkforTS2(packet)) {
- return alreadySend(packet);
- }
- //prüfe nach mumble
- else if (checkforMumble(packet)) {
- return alreadySend(packet);
- }
- break;
+ switch (currentvoice) {
+ case XFIREVOICECHAT_TS2:
+ if (checkforTS2(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein ts2 mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ case XFIREVOICECHAT_TS3:
+ if (checkforTS3(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein ts3 mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ case XFIREVOICECHAT_MUMBLE:
+ if (checkforMumble(packet)) {
+ return alreadySend(packet);
+ }
+ else
+ {
+ //kein mumble mehr? dann paket restten
+ resetSendGameStatus2Packet(packet);
+ resetCurrentvoicestatus();
+ //in db schreiben
+ writeToDatabase(packet);
+ return TRUE;
+ }
+ break;
+ default:
+ //prüfe nach ts3
+ if (checkforTS3(packet)) {
+ return alreadySend(packet);
+ }
+ //prüfe nach ts2
+ else if (checkforTS2(packet)) {
+ return alreadySend(packet);
+ }
+ //prüfe nach mumble
+ else if (checkforMumble(packet)) {
+ return alreadySend(packet);
+ }
+ break;
};
return FALSE;
@@ -114,70 +114,70 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) { //setzte currentvoice auf 0 zurück, falls es einen disconnect gab
void Xfire_voicechat::resetCurrentvoicestatus() {
- currentvoice=XFIREVOICECHAT_NOVOICE;
- lastpacket.ip[3]=0;
- lastpacket.ip[2]=0;
- lastpacket.ip[1]=0;
- lastpacket.ip[0]=0;
- lastpacket.port=0;
- pid=0;
+ currentvoice = XFIREVOICECHAT_NOVOICE;
+ lastpacket.ip[3] = 0;
+ lastpacket.ip[2] = 0;
+ lastpacket.ip[1] = 0;
+ lastpacket.ip[0] = 0;
+ lastpacket.port = 0;
+ pid = 0;
}
//resettet das packet auf 0
void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet) {
- if (packet==NULL)
+ if (packet == NULL)
return;
//voiceid
- packet->gameid=XFIREVOICECHAT_NOVOICE;
+ packet->gameid = XFIREVOICECHAT_NOVOICE;
//ip zuweisen
- packet->ip[3]=0;
- packet->ip[2]=0;
- packet->ip[1]=0;
- packet->ip[0]=0;
+ packet->ip[3] = 0;
+ packet->ip[2] = 0;
+ packet->ip[1] = 0;
+ packet->ip[0] = 0;
//port zuweisen
- packet->port=0;
+ packet->port = 0;
}
//schreibt derzetigen status in die mirandadb für variables usw
void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) {
//für sprintf
- char temp[32]="";
+ char temp[32] = "";
- if (packet==NULL || packet->gameid==XFIREVOICECHAT_NOVOICE) {
+ if (packet == NULL || packet->gameid == XFIREVOICECHAT_NOVOICE) {
//einträge aus der db entfernen
- db_unset(NULL,protocolname, "VServerIP");
- db_unset(NULL,protocolname, "currentvoicename");
+ db_unset(NULL, protocolname, "VServerIP");
+ db_unset(NULL, protocolname, "currentvoicename");
//zurück
return;
}
//ip speichern
- mir_snprintf(temp,32,"%d.%d.%d.%d:%d",(unsigned char)packet->ip[3],(unsigned char)packet->ip[2],(unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ mir_snprintf(temp, 32, "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0], packet->port);
db_set_s(NULL, protocolname, "VServerIP", temp);
//namen jeh nach id schreiben
- switch(packet->gameid) {
- case XFIREVOICECHAT_TS3:
- db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak 3");
- break;
- case XFIREVOICECHAT_TS2:
- db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak 2");
- break;
- case XFIREVOICECHAT_MUMBLE:
- db_set_s(NULL, protocolname, "currentvoicename", "Mumble");
- break;
- case XFIREVOICECHAT_VENTRILO:
- db_set_s(NULL, protocolname, "currentvoicename", "Ventrilo");
- break;
+ switch (packet->gameid) {
+ case XFIREVOICECHAT_TS3:
+ db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak 3");
+ break;
+ case XFIREVOICECHAT_TS2:
+ db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak 2");
+ break;
+ case XFIREVOICECHAT_MUMBLE:
+ db_set_s(NULL, protocolname, "currentvoicename", "Mumble");
+ break;
+ case XFIREVOICECHAT_VENTRILO:
+ db_set_s(NULL, protocolname, "currentvoicename", "Ventrilo");
+ break;
};
}
//versucht die TSR zuladen
-HMODULE Xfire_voicechat::loadTSR(char* path,BOOL nolocaltest) {
+HMODULE Xfire_voicechat::loadTSR(char* path, BOOL nolocaltest) {
TCHAR pathtotsr[MAX_PATH] = _T("");
/*if (path)
; was tun*/
- _tcscat_s(pathtotsr,MAX_PATH,_T("TSRemote.dll"));
-
+ _tcscat_s(pathtotsr, MAX_PATH, _T("TSRemote.dll"));
+
//versuche dll zuladen
HMODULE tsrDLL = LoadLibrary(pathtotsr);
//konnte nicht geladen werden
@@ -193,22 +193,22 @@ HMODULE Xfire_voicechat::loadTSR(char* path,BOOL nolocaltest) { if (!tsrDLL) {
XFireLog("TSRemote.dll load faild (using standard installationpath)!");
-
+
//deutsches sys?
tsrDLL = LoadLibrary(_T("C:\\Programme\\Teamspeak2_RC2\\client_sdk\\TSRemote.dll"));
if (!tsrDLL)
XFireLog("TSRemote.dll load failed (using standard installationpath2)!");
-
- //aufgeben
- return NULL;
+
+ //aufgeben
+ return NULL;
}
}
XFireLog("TSRemote.dll successfully loaded!");
//getserverinfo funktion holen
- tsrGetServerInfo = (LPtsrGetServerInfo)GetProcAddress(tsrDLL,"tsrGetServerInfo");
+ tsrGetServerInfo = (LPtsrGetServerInfo)GetProcAddress(tsrDLL, "tsrGetServerInfo");
return tsrDLL;
}
@@ -216,9 +216,9 @@ HMODULE Xfire_voicechat::loadTSR(char* path,BOOL nolocaltest) { //teamspeak 3 detection, benötigt ts3plugin
BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) {
- ts3IPPORT* ipport=NULL;
+ ts3IPPORT* ipport = NULL;
//kein gültiger verweis?
- if (packet==NULL)
+ if (packet == NULL)
return FALSE;
//existiert ein filemap?
HANDLE hMapObject = OpenFileMappingA(FILE_MAP_READ, FALSE, "$ts3info4xfire$");
@@ -226,16 +226,16 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) { if (hMapObject == NULL)
return FALSE;
//versuch ipport zubesorgen
- ipport = (ts3IPPORT *) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, sizeof(ts3IPPORT));
+ ipport = (ts3IPPORT *)MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, sizeof(ts3IPPORT));
//fehler beim zugriff auf filemap?
- if (ipport==NULL)
+ if (ipport == NULL)
{
CloseHandle(hMapObject);
return FALSE;
}
//wenn kein port, dann stimmt was mit der ip nicht, paket resetten
- if (ipport->port==0) {
+ if (ipport->port == 0) {
//packet resetten
resetSendGameStatus2Packet(packet);
//in db schreiben
@@ -244,30 +244,30 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet* packet) { }
//voiceid zuweisen
- this->currentvoice=XFIREVOICECHAT_TS3;
- packet->gameid=XFIREVOICECHAT_TS3;
+ this->currentvoice = XFIREVOICECHAT_TS3;
+ packet->gameid = XFIREVOICECHAT_TS3;
//ip zuweisen
- packet->ip[3]=ipport->ip[3];
- packet->ip[2]=ipport->ip[2];
- packet->ip[1]=ipport->ip[1];
- packet->ip[0]=ipport->ip[0];
+ packet->ip[3] = ipport->ip[3];
+ packet->ip[2] = ipport->ip[2];
+ packet->ip[1] = ipport->ip[1];
+ packet->ip[0] = ipport->ip[0];
//port zuweisen
- packet->port=ipport->port;
+ packet->port = ipport->port;
//unmap, handle schließem
UnmapViewOfFile(ipport);
CloseHandle(hMapObject);
//in db schreiben
writeToDatabase(packet);
//ts3 gefunden
- return TRUE;
+ return TRUE;
}
//teamspeak 2 detection mit hilfe der tsr
BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) {
- TtsrServerInfo serverinfo={0};
+ TtsrServerInfo serverinfo = { 0 };
//get funktion ist nicht initialisiert
- if (this->tsrGetServerInfo==NULL || packet==NULL)
+ if (this->tsrGetServerInfo == NULL || packet == NULL)
{
return FALSE;
}
@@ -276,29 +276,29 @@ BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) { this->tsrGetServerInfo(&serverinfo);
//auswerten wenn serverip gesetzt
- if (serverinfo.ServerIp[0]!=0)
+ if (serverinfo.ServerIp[0] != 0)
{
- char * pos=strrchr(serverinfo.ServerIp,':');
- if (pos==0)
+ char * pos = strrchr(serverinfo.ServerIp, ':');
+ if (pos == 0)
{
return FALSE;
}
- *pos=0;
- unsigned int ip=inet_addr(serverinfo.ServerIp);
+ *pos = 0;
+ unsigned int ip = inet_addr(serverinfo.ServerIp);
pos++;
- int port=atoi(pos);
+ int port = atoi(pos);
//port zuweisen
- packet->port=port;
+ packet->port = port;
//ip zuweisen
- packet->ip[3]=LOBYTE(LOWORD(ip));
- packet->ip[2]=HIBYTE(LOWORD(ip));
- packet->ip[1]=LOBYTE(HIWORD(ip));
- packet->ip[0]=HIBYTE(HIWORD(ip));
+ packet->ip[3] = LOBYTE(LOWORD(ip));
+ packet->ip[2] = HIBYTE(LOWORD(ip));
+ packet->ip[1] = LOBYTE(HIWORD(ip));
+ packet->ip[0] = HIBYTE(HIWORD(ip));
//gameid/voice zuweisen
- packet->gameid=XFIREVOICECHAT_TS2;
- this->currentvoice=XFIREVOICECHAT_TS2;
+ packet->gameid = XFIREVOICECHAT_TS2;
+ this->currentvoice = XFIREVOICECHAT_TS2;
//ab in die db
writeToDatabase(packet);
@@ -311,47 +311,47 @@ BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) { //detection für mumble
BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) {
//kein gültiger verweis?
- if (packet==NULL)
+ if (packet == NULL)
return FALSE;
//gültige pid
- if (this->pid!=0 && !this->isValidPid(this->pid))
+ if (this->pid != 0 && !this->isValidPid(this->pid))
{
- this->pid=0;
+ this->pid = 0;
return FALSE;
}
else {
- if (!this->getPidByProcessName(_T("mumble.exe"),&this->pid)) {
+ if (!this->getPidByProcessName(_T("mumble.exe"), &this->pid)) {
return FALSE;
}
}
- DWORD size=0;
- MIB_TCPTABLE_OWNER_PID* ptab=NULL;
+ DWORD size = 0;
+ MIB_TCPTABLE_OWNER_PID* ptab = NULL;
//tcptabelle holen
GetExtendedTcpTable(NULL, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0);
//überhaupt was drin?
if (size) {
- ptab=(MIB_TCPTABLE_OWNER_PID*)malloc(size);
+ ptab = (MIB_TCPTABLE_OWNER_PID*)malloc(size);
//liste auslesen
if (GetExtendedTcpTable(ptab, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0) == NO_ERROR)
{
- for(unsigned int i=0;i<ptab->dwNumEntries;i++)
+ for (unsigned int i = 0; i < ptab->dwNumEntries; i++)
{
- if (ptab->table[i].dwOwningPid==this->pid && ptab->table[i].dwLocalAddr!=ptab->table[i].dwRemoteAddr) //verbindung gefunden, hoffentlich
+ if (ptab->table[i].dwOwningPid == this->pid && ptab->table[i].dwLocalAddr != ptab->table[i].dwRemoteAddr) //verbindung gefunden, hoffentlich
{
- unsigned char*rip=(unsigned char*)&ptab->table[i].dwRemoteAddr;
- XFireLog("IP %x,%x",ptab->table[i].dwRemoteAddr,ptab->table[i].dwRemotePort);
+ unsigned char*rip = (unsigned char*)&ptab->table[i].dwRemoteAddr;
+ XFireLog("IP %x,%x", ptab->table[i].dwRemoteAddr, ptab->table[i].dwRemotePort);
//ipzuweisen
- packet->ip[3]=rip[0];
- packet->ip[2]=rip[1];
- packet->ip[1]=rip[2];
- packet->ip[0]=rip[3];
+ packet->ip[3] = rip[0];
+ packet->ip[2] = rip[1];
+ packet->ip[1] = rip[2];
+ packet->ip[0] = rip[3];
//portzuweisen
- packet->port=r(ptab->table[i].dwRemotePort);
+ packet->port = r(ptab->table[i].dwRemotePort);
//mumble
- packet->gameid=XFIREVOICECHAT_MUMBLE;
- this->currentvoice=XFIREVOICECHAT_MUMBLE;
+ packet->gameid = XFIREVOICECHAT_MUMBLE;
+ this->currentvoice = XFIREVOICECHAT_MUMBLE;
//table wieder freigeben
delete ptab;
//mumble läuft + ip gefunden also TRUE
diff --git a/protocols/Xfire/src/Xfire_voicechat.h b/protocols/Xfire/src/Xfire_voicechat.h index 5240c389a4..2a1a43a4ed 100644 --- a/protocols/Xfire/src/Xfire_voicechat.h +++ b/protocols/Xfire/src/Xfire_voicechat.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2009 by
* dufte <dufte@justmail.de>
@@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -56,7 +56,7 @@ struct TtsrServerInfo int PlayerCount;
};
-typedef int (__stdcall *LPtsrGetServerInfo)(TtsrServerInfo *tsrServerInfo);
+typedef int(__stdcall *LPtsrGetServerInfo)(TtsrServerInfo *tsrServerInfo);
/* klassen definitionen */
struct ts3IPPORT {
@@ -66,11 +66,11 @@ struct ts3IPPORT { enum XFIREVOICECHATTYPE {
XFIREVOICECHAT_NOVOICE,
- XFIREVOICECHAT_TS3=35,
- XFIREVOICECHAT_TS2=32,
- XFIREVOICECHAT_MUMBLE=34,
- XFIREVOICECHAT_VENTRILO=33,
- XFIREVOICECHAT_IPDETECT=999
+ XFIREVOICECHAT_TS3 = 35,
+ XFIREVOICECHAT_TS2 = 32,
+ XFIREVOICECHAT_MUMBLE = 34,
+ XFIREVOICECHAT_VENTRILO = 33,
+ XFIREVOICECHAT_IPDETECT = 999
};
using namespace xfirelib;
@@ -97,7 +97,7 @@ public: void resetSendGameStatus2Packet(SendGameStatus2Packet* packet);
void resetCurrentvoicestatus();
void writeToDatabase(SendGameStatus2Packet* packet);
- HMODULE loadTSR(char* path=NULL,BOOL nolocaltest=FALSE);
+ HMODULE loadTSR(char* path = NULL, BOOL nolocaltest = FALSE);
BOOL checkVoicechat(SendGameStatus2Packet* packet);
BOOL alreadySend(SendGameStatus2Packet* packet);
diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp index ae8ae1a438..26297e3bd6 100644 --- a/protocols/Xfire/src/addgamedialog.cpp +++ b/protocols/Xfire/src/addgamedialog.cpp @@ -7,36 +7,36 @@ extern HANDLE XFireWorkingFolder; extern Xfire_gamelist xgamelist;
char inipath[MAX_PATH];
-char* buffer=NULL;
-BOOL dontClose=FALSE;
+char* buffer = NULL;
+BOOL dontClose = FALSE;
vector<lbInicache> Inicache;
-Xfire_game* editgame=NULL;
+Xfire_game* editgame = NULL;
-HWND hwndTab,hPage;
+HWND hwndTab, hPage;
-void AddGameDialog(HWND hwndDlg,Xfire_game* game) {
+void AddGameDialog(HWND hwndDlg, Xfire_game* game) {
//übergebendes game, dem editgame zuordnen, damit wechselt es in den editmodus
- editgame=game;
- if (DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAMEMAIN),hwndDlg,DlgAddGameProcMain)) {
+ editgame = game;
+ if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_ADDGAMEMAIN), hwndDlg, DlgAddGameProcMain)) {
}
//wieder auf NULL setzen
- editgame=NULL;
+ editgame = NULL;
}
-static void FillGameList( LPVOID hwndDlg ) {
+static void FillGameList(LPVOID hwndDlg) {
//liste.,suche und suchlabel unsichtbar machen
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_GAMELIST),SW_HIDE);
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_SEARCH),SW_HIDE);
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_STC14),SW_HIDE);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_GAMELIST), SW_HIDE);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_SEARCH), SW_HIDE);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_STC14), SW_HIDE);
//handle von progressbar holen
- HWND hwndPB=GetDlgItem((HWND)hwndDlg,IDC_PROGRESS);
+ HWND hwndPB = GetDlgItem((HWND)hwndDlg, IDC_PROGRESS);
//das schließen des dialogs verhindern
- dontClose=TRUE;
+ dontClose = TRUE;
- if (Inicache.size()==0)
+ if (Inicache.size() == 0)
{
//temp xfirebaseob für strlower
Xfire_base tempxfire;
@@ -44,112 +44,112 @@ static void FillGameList( LPVOID hwndDlg ) { vector<DWORD> dublBuffer;
//Cache ist leer, Cache füllen
- strcpy(inipath, XFireGetFoldersPath ("IniFile"));
+ strcpy(inipath, XFireGetFoldersPath("IniFile"));
strcat_s(inipath, MAX_PATH, "xfire_games.ini");
//ini soll in den RAM geladen werden, fürs schnellere ausparsen
- FILE* f=fopen(inipath,"rb");
+ FILE* f = fopen(inipath, "rb");
//wenn ini nicht aufrufbar, abbrechen
- if (f==NULL)
+ if (f == NULL)
return;
//ans ende der datei springen
- fseek(f,0,SEEK_END);
+ fseek(f, 0, SEEK_END);
//aktuelle position im filepoitner als größe zwischenspeichern
- int size=ftell(f);
+ int size = ftell(f);
//buffer anelgen
- buffer=new char[size+1];
+ buffer = new char[size + 1];
//wenn nicht genug ram, abbruch
- if (buffer==NULL)
+ if (buffer == NULL)
return;
//buffer nullen
- memset(buffer,0,size+1);
+ memset(buffer, 0, size + 1);
//zum anfang springen
- fseek(f,0,SEEK_SET);
+ fseek(f, 0, SEEK_SET);
//ini komplett in den ram lesen
- fread(buffer,size,1,f);
+ fread(buffer, size, 1, f);
//datei schließen
fclose(f);
//parse einzelne sections aus
//pointer vom buffer
- char*p=buffer;
+ char*p = buffer;
//zahlenbufer1 und pointer
- char zahlbuffer[10]="";
- char*z=zahlbuffer;
+ char zahlbuffer[10] = "";
+ char*z = zahlbuffer;
//zahlenbuffer2 uznd pointer
- char zahlbuffer2[10]="";
- char*z2=zahlbuffer2;
+ char zahlbuffer2[10] = "";
+ char*z2 = zahlbuffer2;
//progressbar auf bytegröße anpassen
- SendMessage(hwndPB, PBM_SETRANGE32, 0,size);
+ SendMessage(hwndPB, PBM_SETRANGE32, 0, size);
//solange bis wir bei 0 angekommen sind
- if (*p!=0)
+ if (*p != 0)
p++;
- while(*p!=0)
+ while (*p != 0)
{
- if (*p=='['&&*(p-1)=='\n')
+ if (*p == '['&&*(p - 1) == '\n')
{
- z=zahlbuffer;
- z2=zahlbuffer2;
+ z = zahlbuffer;
+ z2 = zahlbuffer2;
p++;
- while(*p>='0'&&*p<='9'&&p!=0)
+ while (*p >= '0'&&*p <= '9'&&p != 0)
{
- *z=*p;
+ *z = *p;
p++;
z++;
}
- *z=0;
- if (*p=='_') {
+ *z = 0;
+ if (*p == '_') {
p++;
- while(*p>='0'&&*p<='9'&&p!=0)
+ while (*p >= '0'&&*p <= '9'&&p != 0)
{
- *z2=*p;
+ *z2 = *p;
p++;
z2++;
}
- *z2=0;
+ *z2 = 0;
}
-
+
//erste zahl gefunden
- if (z!=zahlbuffer)
+ if (z != zahlbuffer)
{
- int gameid=atoi(zahlbuffer);
+ int gameid = atoi(zahlbuffer);
//prüfe ob das game schon in der gameliste ist
if (!xgamelist.Gameinlist(gameid))
{
- char*name=p;
+ char*name = p;
lbInicache listentry;
- char gameidtemp[10]="";
+ char gameidtemp[10] = "";
char ret[512];
- DWORD uniqid=0;
- BYTE accLaunch=0;
- BYTE accDetect=0;
+ DWORD uniqid = 0;
+ BYTE accLaunch = 0;
+ BYTE accDetect = 0;
//bis zum nächsten isgleich springen
- while(*name!='=')
+ while (*name != '=')
name++;
name++;
//jetzt den umbruch suchen
- p=name;
- while(*p!='\n'&&*p!='\r') p++;
- *p=0;
+ p = name;
+ while (*p != '\n'&&*p != '\r') p++;
+ *p = 0;
p++;
-
+
//spielnamen in den listentry einfügen
- strcpy_s(listentry.name,255,name);
+ strcpy_s(listentry.name, 255, name);
- if (z2!=zahlbuffer2)
+ if (z2 != zahlbuffer2)
{
- listentry.gameid=MAKELONG(gameid,atoi(zahlbuffer2));
- mir_snprintf(gameidtemp,10,"%d_%d",gameid,atoi(zahlbuffer2));
+ listentry.gameid = MAKELONG(gameid, atoi(zahlbuffer2));
+ mir_snprintf(gameidtemp, 10, "%d_%d", gameid, atoi(zahlbuffer2));
}
else
{
- listentry.gameid=gameid;
- mir_snprintf(gameidtemp,10,"%d",gameid);
+ listentry.gameid = gameid;
+ mir_snprintf(gameidtemp, 10, "%d", gameid);
}
@@ -157,53 +157,53 @@ static void FillGameList( LPVOID hwndDlg ) { //lower launchstring
tempxfire.strtolower(ret);
//einzelnen ziechen zusammenrechnen
- if (z2!=zahlbuffer2)
+ if (z2 != zahlbuffer2)
{
//wenn pfad, dann exe vorher rausziehen
- if (strrchr(ret,'\\'))
- accLaunch=tempxfire.accStringByte(strrchr(ret,'\\'));
+ if (strrchr(ret, '\\'))
+ accLaunch = tempxfire.accStringByte(strrchr(ret, '\\'));
else
- accLaunch=tempxfire.accStringByte(ret);
+ accLaunch = tempxfire.accStringByte(ret);
}
//Steam.exe als launcher?
- if ((ret[0]=='s')&&
- ret[1]=='t'&&
- ret[2]=='e'&&
- ret[3]=='a'&&
- ret[4]=='m'&&
- ret[5]=='.'&&
- ret[6]=='e'&&
- ret[7]=='x'&&
- ret[8]=='e')
+ if ((ret[0] == 's') &&
+ ret[1] == 't'&&
+ ret[2] == 'e'&&
+ ret[3] == 'a'&&
+ ret[4] == 'm'&&
+ ret[5] == '.'&&
+ ret[6] == 'e'&&
+ ret[7] == 'x'&&
+ ret[8] == 'e')
{
- strcat_s(listentry.name,255," (Steam)");
+ strcat_s(listentry.name, 255, " (Steam)");
}
}
- if (z2!=zahlbuffer2) {
+ if (z2 != zahlbuffer2) {
if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
//lower launchstring
tempxfire.strtolower(ret);
//einzelnen ziechen zusammenrechnen
//wenn pfad, dann exe vorher rausziehen
- if (strrchr(ret,'\\'))
- accDetect=tempxfire.accStringByte(strrchr(ret,'\\'));
+ if (strrchr(ret, '\\'))
+ accDetect = tempxfire.accStringByte(strrchr(ret, '\\'));
else
- accDetect=tempxfire.accStringByte(ret);
+ accDetect = tempxfire.accStringByte(ret);
}
}
//standardmäßig TRUE
- BOOL addtolist=TRUE;
+ BOOL addtolist = TRUE;
//schon ein eintrag vorhanden?
- if (z2!=zahlbuffer2) {
+ if (z2 != zahlbuffer2) {
//uniq id zusammen bauen aus spielid sowie zusammengerechneten launchstring und detectstring
- uniqid=MAKELONG(gameid,MAKEWORD(accLaunch,accDetect));
- for(uint i = 0 ; i < dublBuffer.size() ; i ++) {
- if (dublBuffer.at(i)==uniqid)
+ uniqid = MAKELONG(gameid, MAKEWORD(accLaunch, accDetect));
+ for (uint i = 0; i < dublBuffer.size(); i++) {
+ if (dublBuffer.at(i) == uniqid)
{
- addtolist=FALSE;
+ addtolist = FALSE;
break;
}
}
@@ -212,13 +212,13 @@ static void FillGameList( LPVOID hwndDlg ) { //nur eintragen, wenn kein doppelter gefunden wurde
if (addtolist) {
//eintrag einfügen
- int idx=SendDlgItemMessageA( (HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)listentry.name);
- SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, listentry.gameid);
+ int idx = SendDlgItemMessageA((HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)listentry.name);
+ SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, listentry.gameid);
//eintrag in den buffer für die dublikateprüfung
dublBuffer.push_back(uniqid);
//und eintrag in den cache
Inicache.push_back(listentry);
- SendMessage(hwndPB, PBM_SETPOS, (WPARAM)(p-buffer), 0);
+ SendMessage(hwndPB, PBM_SETPOS, (WPARAM)(p - buffer), 0);
}
}
}
@@ -230,46 +230,46 @@ static void FillGameList( LPVOID hwndDlg ) { else
{
//liste mit dem cache aufbauen
- for(uint i = 0 ; i < Inicache.size() ; i ++) {
+ for (uint i = 0; i < Inicache.size(); i++) {
//spielid in der liste spielliste?
if (!xgamelist.Gameinlist(LOWORD(Inicache.at(i).gameid)))
{
//eintrag in die listeeinfügen
- int idx=SendDlgItemMessageA( (HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)Inicache.at(i).name);
+ int idx = SendDlgItemMessageA((HWND)hwndDlg, IDC_GAMELIST, LB_ADDSTRING, 0, (LPARAM)Inicache.at(i).name);
//gameid zuweisen
- SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, Inicache.at(i).gameid);
+ SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_SETITEMDATA, idx, Inicache.at(i).gameid);
}
}
}
//progressbar unsichtbar
- ShowWindow(hwndPB,SW_HIDE);
+ ShowWindow(hwndPB, SW_HIDE);
//liste sichtbar machen
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_GAMELIST),SW_SHOW);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_GAMELIST), SW_SHOW);
//suche und suchlabel sichtbar machen
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_SEARCH),SW_SHOW);
- ShowWindow(GetDlgItem((HWND)hwndDlg,IDC_STC14),SW_SHOW);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_SEARCH), SW_SHOW);
+ ShowWindow(GetDlgItem((HWND)hwndDlg, IDC_STC14), SW_SHOW);
- dontClose=FALSE;
+ dontClose = FALSE;
}
-BOOL OpenFileDialog(HWND hwndDlg,OPENFILENAMEA*ofn,char*exe) {
+BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) {
//pointer zum exenamen
- char* exename=NULL;
+ char* exename = NULL;
//buffer vom pfad
- static char szFile[260]=""; //static damit noch nach dem aufruf lesbar bleibt
+ static char szFile[260] = ""; //static damit noch nach dem aufruf lesbar bleibt
//buffer vom filter
- char szFilter[260]="";
+ char szFilter[260] = "";
//backslash suchen
- exename=strrchr(exe,'\\')+1;
+ exename = strrchr(exe, '\\') + 1;
//kein backslash dann normal ret als exenamen verwenden
- if ((int)exename==1) exename=exe;
+ if ((int)exename == 1) exename = exe;
//filterstring aufbauen
mir_snprintf(szFilter, SIZEOF(szFilter), "%s|%s|%s|*.*|", exename, exename, Translate("All Files"));
//umbruch in 0 wandeln
- unsigned int sizeFilter=strlen(szFilter);
- for(unsigned int i=0;i<sizeFilter;i++)
- if (szFilter[i]=='|') szFilter[i]=0;
+ unsigned int sizeFilter = strlen(szFilter);
+ for (unsigned int i = 0; i < sizeFilter; i++)
+ if (szFilter[i] == '|') szFilter[i] = 0;
//openfiledia vorbereiten
ZeroMemory(ofn, sizeof(OPENFILENAMEA));
ofn->lStructSize = sizeof(OPENFILENAMEA);
@@ -286,579 +286,579 @@ BOOL OpenFileDialog(HWND hwndDlg,OPENFILENAMEA*ofn,char*exe) { return GetOpenFileNameA(ofn);
}
-INT_PTR CALLBACK DlgAddGameProc (HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
+INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ )
{
switch (uMsg) {
- case WM_INITDIALOG:
- {
- //übersetzen lassen
- TranslateDialogDefault(hwndDlg);
+ case WM_INITDIALOG:
+ {
+ //übersetzen lassen
+ TranslateDialogDefault(hwndDlg);
-
- //per thread liste füllen
- mir_forkthread(FillGameList,hwndDlg);
- }
- break;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam)==EN_CHANGE)
+
+ //per thread liste füllen
+ mir_forkthread(FillGameList, hwndDlg);
+ }
+ break;
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE)
+ {
+ char temp[256];
+ //eingabe bei der suche auslesen
+ GetDlgItemTextA(hwndDlg, IDC_SEARCH, temp, 256);
+ //eingabe in der liste suchen
+ int idx = SendDlgItemMessageA(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp);
+ //gefunden?
+ if (idx != LB_ERR)
{
- char temp[256];
- //eingabe bei der suche auslesen
- GetDlgItemTextA(hwndDlg,IDC_SEARCH,temp,256);
- //eingabe in der liste suchen
- int idx=SendDlgItemMessageA(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp);
- //gefunden?
- if (idx!=LB_ERR)
- {
- //als aktiv setzen
- SendDlgItemMessage(hwndDlg, IDC_GAMELIST,LB_SETCURSEL,idx,0);
- }
+ //als aktiv setzen
+ SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_SETCURSEL, idx, 0);
+ }
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ //nicht schließen, wenn noch der thread läuft
+ if (dontClose) {
+ MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ return FALSE;
}
- else if (LOWORD(wParam) == IDCANCEL)
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
+ }
+ else if (LOWORD(wParam) == IDC_CUSTOM)
+ {
+ int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if (idx == LB_ERR) {
+ MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ }
+ else
{
- //nicht schließen, wenn noch der thread läuft
- if (dontClose) {
- MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
+ char ret[512] = "";
+ char gameidtemp[10] = "";
+
+ int gameids = SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
+ //gameid splitten
+ int gameid1 = LOWORD(gameids);
+ int gameid2 = HIWORD(gameids);
+
+ if (gameid2 != 0)
+ mir_snprintf(gameidtemp, 10, "%d_%d", gameid1, gameid2);
+ else
+ mir_snprintf(gameidtemp, 10, "%d", gameid1);
+
+ //spielnamen holen
+ if (xfire_GetPrivateProfileString(gameidtemp, "LongName", "", ret, 512, inipath)) {
+ mir_snprintf(gameidtemp, 10, "%d", gameid1);
+
+ //einige felder vorbelegen
+ SetDlgItemTextA(hPage, IDC_ADD_NAME, ret);
+ SetDlgItemText(hPage, IDC_ADD_DETECTEXE, _T(""));
+ SetDlgItemText(hPage, IDC_ADD_LAUNCHEREXE, _T(""));
+ SetDlgItemTextA(hPage, IDC_ADD_ID, gameidtemp);
+ SetDlgItemText(hPage, IDC_ADD_STATUSMSG, _T(""));
+ SetDlgItemText(hPage, IDC_ADD_CUSTOMPARAMS, _T(""));
+ SetDlgItemTextA(hPage, IDC_ADD_SENDID, gameidtemp);
+
+ //auf customeintrag edit tab wechseln
+ TabCtrl_SetCurSel(hwndTab, 1);
+ ShowWindow(hwndDlg, SW_HIDE);
+ ShowWindow(hPage, SW_SHOW);
}
- return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
}
- else if (LOWORD(wParam) == IDC_CUSTOM)
+ }
+ else if (LOWORD(wParam) == IDOK)
+ {
+ int idx = SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
+ //es wurde was ausgewählt?
+ if (idx == LB_ERR) {
+ MessageBox(hwndDlg, TranslateT("Please choose one game in the list!"), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ }
+ else
{
- int idx=SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
- //es wurde was ausgewählt?
- if (idx==LB_ERR) {
- MessageBox(hwndDlg,TranslateT("Please choose one game in the list!"),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
- }
+ //datei öffnen dialog
+ OPENFILENAMEA ofn;
+ //listdata auslesen, wo die gameid gespeihcert ist
+ int gameids = SendDlgItemMessage((HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
+ //gameid splitten
+ int gameid1 = LOWORD(gameids);
+ int gameid2 = HIWORD(gameids);
+ char gameidtemp[10] = "";
+ char ret[512];
+
+ if (gameid2 != 0)
+ mir_snprintf(gameidtemp, 10, "%d_%d", gameid1, gameid2);
else
- {
- char ret[512]="";
- char gameidtemp[10]="";
-
- int gameids=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
- //gameid splitten
- int gameid1=LOWORD(gameids);
- int gameid2=HIWORD(gameids);
+ mir_snprintf(gameidtemp, 10, "%d", gameid1);
- if (gameid2!=0)
- mir_snprintf(gameidtemp,10,"%d_%d",gameid1,gameid2);
+ //neuen gameeintrag anlegen
+ Xfire_game* newgame = new Xfire_game();
+ //gameid und sendid setzen
+ newgame->id = gameid1;
+ newgame->send_gameid = gameid1;
+ //es handelt sich um einen customeintrag, man staune xD
+ newgame->custom = 1;
+
+ //launcherexe abfragen
+ if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if (OpenFileDialog(hwndDlg, &ofn, ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile, &newgame->launchparams);
+ }
else
- mir_snprintf(gameidtemp,10,"%d",gameid1);
-
- //spielnamen holen
- if (xfire_GetPrivateProfileString(gameidtemp, "LongName", "", ret, 512, inipath)) {
- mir_snprintf(gameidtemp,10,"%d",gameid1);
-
- //einige felder vorbelegen
- SetDlgItemTextA(hPage,IDC_ADD_NAME,ret);
- SetDlgItemText(hPage,IDC_ADD_DETECTEXE,_T(""));
- SetDlgItemText(hPage,IDC_ADD_LAUNCHEREXE,_T(""));
- SetDlgItemTextA(hPage,IDC_ADD_ID,gameidtemp);
- SetDlgItemText(hPage,IDC_ADD_STATUSMSG,_T(""));
- SetDlgItemText(hPage,IDC_ADD_CUSTOMPARAMS,_T(""));
- SetDlgItemTextA(hPage,IDC_ADD_SENDID,gameidtemp);
-
- //auf customeintrag edit tab wechseln
- TabCtrl_SetCurSel(hwndTab, 1);
- ShowWindow(hwndDlg,SW_HIDE);
- ShowWindow(hPage,SW_SHOW);
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
}
- }
- }
- else if (LOWORD(wParam) == IDOK)
- {
- int idx=SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_GETCURSEL, 0, 0);
- //es wurde was ausgewählt?
- if (idx==LB_ERR) {
- MessageBox(hwndDlg,TranslateT("Please choose one game in the list!"),TranslateT("XFire Options"),MB_OK|MB_ICONEXCLAMATION);
}
- else
- {
- //datei öffnen dialog
- OPENFILENAMEA ofn;
- //listdata auslesen, wo die gameid gespeihcert ist
- int gameids=SendDlgItemMessage( (HWND)hwndDlg, IDC_GAMELIST, LB_GETITEMDATA, idx, 0);
- //gameid splitten
- int gameid1=LOWORD(gameids);
- int gameid2=HIWORD(gameids);
- char gameidtemp[10]="";
- char ret[512];
-
- if (gameid2!=0)
- mir_snprintf(gameidtemp,10,"%d_%d",gameid1,gameid2);
+
+ //detectexe abfragen
+ if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if (OpenFileDialog(hwndDlg, &ofn, ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile, &newgame->path);
+ }
else
- mir_snprintf(gameidtemp,10,"%d",gameid1);
-
- //neuen gameeintrag anlegen
- Xfire_game* newgame=new Xfire_game();
- //gameid und sendid setzen
- newgame->id=gameid1;
- newgame->send_gameid=gameid1;
- //es handelt sich um einen customeintrag, man staune xD
- newgame->custom=1;
-
- //launcherexe abfragen
- if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
- //datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg,&ofn,ret))
- {
- //lowercase pfad
- newgame->strtolower(ofn.lpstrFile);
- //pfad dem spiel zuordnen
- newgame->setString(ofn.lpstrFile,&newgame->launchparams);
- }
- else
- {
- //speicher freigeben
- delete newgame;
- return FALSE;
- }
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
}
-
- //detectexe abfragen
- if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
- //datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg,&ofn,ret))
- {
- //lowercase pfad
- newgame->strtolower(ofn.lpstrFile);
- //pfad dem spiel zuordnen
- newgame->setString(ofn.lpstrFile,&newgame->path);
- }
- else
- {
- //speicher freigeben
- delete newgame;
- return FALSE;
- }
- } //MatchExe abfragen
- else if (xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) {
- //datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg,&ofn,ret))
- {
- //lowercase pfad
- newgame->strtolower(ofn.lpstrFile);
- //pfad dem spiel zuordnen
- newgame->setString(ofn.lpstrFile,&newgame->path);
- }
- else
- {
- //speicher freigeben
- delete newgame;
- return FALSE;
- }
+ } //MatchExe abfragen
+ else if (xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) {
+ //datei vom user öffnen lassen
+ if (OpenFileDialog(hwndDlg, &ofn, ret))
+ {
+ //lowercase pfad
+ newgame->strtolower(ofn.lpstrFile);
+ //pfad dem spiel zuordnen
+ newgame->setString(ofn.lpstrFile, &newgame->path);
+ }
+ else
+ {
+ //speicher freigeben
+ delete newgame;
+ return FALSE;
}
+ }
- //prüfe ob schon ein launchstring festgelegt wurde, wenn nicht die detectexe nehmen
- if (!newgame->launchparams&&newgame->path) {
- newgame->setString(newgame->path,&newgame->launchparams);
- }
+ //prüfe ob schon ein launchstring festgelegt wurde, wenn nicht die detectexe nehmen
+ if (!newgame->launchparams&&newgame->path) {
+ newgame->setString(newgame->path, &newgame->launchparams);
+ }
- //prüfe ob schon ein detectexe festgelegt wurde, wenn nicht die launchstring nehmen
- if (newgame->launchparams&&!newgame->path) {
- newgame->setString(newgame->launchparams,&newgame->path);
- }
-
- //LauncherUrl wird der launcherstring überschrieben
- if (xfire_GetPrivateProfileString(gameidtemp, "LauncherUrl", "", ret, 512, inipath)) {
- newgame->setString(ret,&newgame->launchparams);
- }
- else if (xfire_GetPrivateProfileString(gameidtemp, "Launch", "", ret, 512, inipath)) {
- str_replace(ret,"%UA_LAUNCHER_EXE_PATH%",""); //erstmal unwichtige sachen entfernen
- //str_replace(ret,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
- str_replace(ret,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
-
- //ein leerzeichen anfügen
- newgame->appendString(" ",&newgame->launchparams);
- //nun commandline des launchstringes dranhängen
- newgame->appendString(ret,&newgame->launchparams);
- }
+ //prüfe ob schon ein detectexe festgelegt wurde, wenn nicht die launchstring nehmen
+ if (newgame->launchparams&&!newgame->path) {
+ newgame->setString(newgame->launchparams, &newgame->path);
+ }
- //restliche wichtige felder einfügen
- if (xfire_GetPrivateProfileString(gameidtemp, "LauncherPasswordArgs", "", ret, 512, inipath))
- newgame->setString(ret,&newgame->pwparams);
- if (xfire_GetPrivateProfileString(gameidtemp, "LauncherNetworkArgs", "", ret, 512, inipath))
- newgame->setString(ret,&newgame->networkparams);
- if (xfire_GetPrivateProfileString(gameidtemp, "CommandLineMustContain[0]", "", ret, 512, inipath))
- newgame->setString(ret,&newgame->mustcontain);
- if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSendId", "", ret, 512, inipath))
- newgame->send_gameid=atoi(ret);
- if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSetStatusMsg", "", ret, 512, inipath))
- newgame->setstatusmsg=atoi(ret);
-
- //namen setzen und icon laden
- newgame->setNameandIcon();
- //spiel in die gameliste einfügen
- xgamelist.Addgame(newgame);
- //derzeitige gameliste in die datenbank eintragen
- xgamelist.writeDatabase();
- //startmenu leeren
- xgamelist.clearStartmenu();
- //startmenu neuerzeugen
- xgamelist.createStartmenu();
-
- return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ //LauncherUrl wird der launcherstring überschrieben
+ if (xfire_GetPrivateProfileString(gameidtemp, "LauncherUrl", "", ret, 512, inipath)) {
+ newgame->setString(ret, &newgame->launchparams);
}
+ else if (xfire_GetPrivateProfileString(gameidtemp, "Launch", "", ret, 512, inipath)) {
+ str_replace(ret, "%UA_LAUNCHER_EXE_PATH%", ""); //erstmal unwichtige sachen entfernen
+ //str_replace(ret,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
+ str_replace(ret, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen
+
+ //ein leerzeichen anfügen
+ newgame->appendString(" ", &newgame->launchparams);
+ //nun commandline des launchstringes dranhängen
+ newgame->appendString(ret, &newgame->launchparams);
+ }
+
+ //restliche wichtige felder einfügen
+ if (xfire_GetPrivateProfileString(gameidtemp, "LauncherPasswordArgs", "", ret, 512, inipath))
+ newgame->setString(ret, &newgame->pwparams);
+ if (xfire_GetPrivateProfileString(gameidtemp, "LauncherNetworkArgs", "", ret, 512, inipath))
+ newgame->setString(ret, &newgame->networkparams);
+ if (xfire_GetPrivateProfileString(gameidtemp, "CommandLineMustContain[0]", "", ret, 512, inipath))
+ newgame->setString(ret, &newgame->mustcontain);
+ if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSendId", "", ret, 512, inipath))
+ newgame->send_gameid = atoi(ret);
+ if (xfire_GetPrivateProfileString(gameidtemp, "XUSERSetStatusMsg", "", ret, 512, inipath))
+ newgame->setstatusmsg = atoi(ret);
+
+ //namen setzen und icon laden
+ newgame->setNameandIcon();
+ //spiel in die gameliste einfügen
+ xgamelist.Addgame(newgame);
+ //derzeitige gameliste in die datenbank eintragen
+ xgamelist.writeDatabase();
+ //startmenu leeren
+ xgamelist.clearStartmenu();
+ //startmenu neuerzeugen
+ xgamelist.createStartmenu();
+
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
}
- break;
- case WM_CLOSE:
- //nicht schließen, wenn noch der thread läuft
- if (dontClose) {
- MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
- //hauptfenster schließen
- SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
- break;
+ }
+ break;
+ case WM_CLOSE:
+ //nicht schließen, wenn noch der thread läuft
+ if (dontClose) {
+ MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ return FALSE;
+ }
+ //hauptfenster schließen
+ SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
+ break;
}
return FALSE;
}
-INT_PTR CALLBACK DlgAddGameProc2 (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
- case WM_INITDIALOG:
- //ein spiel wurde zum editieren geöffnet, felder alle vorbelegen
- if (editgame) {
- //add augf übernehmen umstellen
- SetDlgItemText(hwndDlg,IDOK,TranslateT("Apply"));
-
- //namen vorbelegen
- if (editgame->customgamename)
- SetDlgItemTextA(hwndDlg,IDC_ADD_NAME,editgame->customgamename);
- else if (editgame->name)
- SetDlgItemTextA(hwndDlg,IDC_ADD_NAME,editgame->name);
-
- //gameid setzen und feld schreibschützen
- char gameid[10]="";
- _itoa_s(editgame->id,gameid,10,10);
- SetDlgItemTextA(hwndDlg,IDC_ADD_ID,gameid);
- EnableWindow(GetDlgItem(hwndDlg,IDC_ADD_ID),FALSE);
-
- //sendgameid setzen, bei -1 leer lassen
- if (editgame->send_gameid!=-1)
- {
- _itoa_s(editgame->send_gameid,gameid,10,10);
- SetDlgItemTextA(hwndDlg,IDC_ADD_SENDID,gameid);
- }
+ case WM_INITDIALOG:
+ //ein spiel wurde zum editieren geöffnet, felder alle vorbelegen
+ if (editgame) {
+ //add augf übernehmen umstellen
+ SetDlgItemText(hwndDlg, IDOK, TranslateT("Apply"));
+
+ //namen vorbelegen
+ if (editgame->customgamename)
+ SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->customgamename);
+ else if (editgame->name)
+ SetDlgItemTextA(hwndDlg, IDC_ADD_NAME, editgame->name);
+
+ //gameid setzen und feld schreibschützen
+ char gameid[10] = "";
+ _itoa_s(editgame->id, gameid, 10, 10);
+ SetDlgItemTextA(hwndDlg, IDC_ADD_ID, gameid);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_ID), FALSE);
+
+ //sendgameid setzen, bei -1 leer lassen
+ if (editgame->send_gameid != -1)
+ {
+ _itoa_s(editgame->send_gameid, gameid, 10, 10);
+ SetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, gameid);
+ }
- //launcherstring
- if (editgame->launchparams) {
- SetDlgItemTextA(hwndDlg,IDC_ADD_LAUNCHEREXE,editgame->launchparams);
- }
+ //launcherstring
+ if (editgame->launchparams) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, editgame->launchparams);
+ }
- //detectstring
- if (editgame->path) {
- SetDlgItemTextA(hwndDlg,IDC_ADD_DETECTEXE,editgame->path);
- }
+ //detectstring
+ if (editgame->path) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, editgame->path);
+ }
- //statusmsg
- if (editgame->statusmsg) {
- SetDlgItemTextA(hwndDlg,IDC_ADD_STATUSMSG,editgame->statusmsg);
- }
+ //statusmsg
+ if (editgame->statusmsg) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, editgame->statusmsg);
+ }
- //mustcontain parameter
- if (editgame->mustcontain) {
- SetDlgItemTextA(hwndDlg,IDC_ADD_CUSTOMPARAMS,editgame->mustcontain);
- }
+ //mustcontain parameter
+ if (editgame->mustcontain) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, editgame->mustcontain);
}
- //dialog übersetzen
- TranslateDialogDefault(hwndDlg);
+ }
+ //dialog übersetzen
+ TranslateDialogDefault(hwndDlg);
- return TRUE;
+ return TRUE;
- case WM_COMMAND:
+ case WM_COMMAND:
+ {
+ if (LOWORD(wParam) == IDC_SENDIDHELP)
{
- if (LOWORD(wParam) == IDC_SENDIDHELP)
+ MessageBox(hwndDlg, TranslateT("If you add a mod of an Xfire supported game, then you can specify what game ID will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game ID and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK);
+ }
+ else if (LOWORD(wParam) == IDC_GAMEIDHELP)
+ {
+ MessageBox(hwndDlg, TranslateT("Every game in Xfire needs an ID. Use a number above the last used ID to avoid problems with used IDs. Every number above 10000 should be save. This ID will not be sent to Xfire, when you start a game."), TranslateT("XFire Options"), MB_OK | MB_ICONASTERISK);
+ }
+ else if (LOWORD(wParam) == IDC_ADD_BROWSEDETECT)
+ {
+ OPENFILENAMEA ofn;
+ if (OpenFileDialog(hwndDlg, &ofn, "*.exe"))
{
- MessageBox(hwndDlg, TranslateT("If you add a mod of an Xfire supported game, then you can specify what game ID will be sent to Xfire. So if you add a Half-Life mod, you can set the Half-Life game ID and if you start the game, your Xfire buddies will see the Half-Life game icon next to your name and the game time will be tracked."), TranslateT("XFire Options"), MB_OK|MB_ICONASTERISK);
+ SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, ofn.lpstrFile);
}
- else if (LOWORD(wParam) == IDC_GAMEIDHELP)
+ }
+ else if (LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER)
+ {
+ OPENFILENAMEA ofn;
+ if (OpenFileDialog(hwndDlg, &ofn, "*.exe"))
{
- MessageBox(hwndDlg, TranslateT("Every game in Xfire needs an ID. Use a number above the last used ID to avoid problems with used IDs. Every number above 10000 should be save. This ID will not be sent to Xfire, when you start a game."), TranslateT("XFire Options"), MB_OK|MB_ICONASTERISK);
+ SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, ofn.lpstrFile);
}
- else if (LOWORD(wParam) == IDC_ADD_BROWSEDETECT)
- {
- OPENFILENAMEA ofn;
- if (OpenFileDialog(hwndDlg,&ofn,"*.exe"))
- {
- SetDlgItemTextA(hwndDlg,IDC_ADD_DETECTEXE,ofn.lpstrFile);
- }
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ //nicht schließen, wenn noch der thread läuft
+ if (dontClose) {
+ MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ return FALSE;
}
- else if (LOWORD(wParam) == IDC_ADD_BROWSELAUNCHER)
- {
- OPENFILENAMEA ofn;
- if (OpenFileDialog(hwndDlg,&ofn,"*.exe"))
- {
- SetDlgItemTextA(hwndDlg,IDC_ADD_LAUNCHEREXE,ofn.lpstrFile);
- }
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
+ }
+ else if (LOWORD(wParam) == IDOK)
+ {
+ char temp[256];
+
+ //fillgames sucht noch
+ if (dontClose) {
+ MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ return FALSE;
}
- else if (LOWORD(wParam) == IDCANCEL)
+
+ //neuen gameeintrag anlegen
+ Xfire_game* newgame = NULL;
+
+ if (editgame)
+ newgame = editgame;
+ else
+ newgame = new Xfire_game();
+
+ //Spielname
+ GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, 256);
+ if (!strlen(temp))
{
- //nicht schließen, wenn noch der thread läuft
- if (dontClose) {
- MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
- return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
+ if (!editgame) delete newgame;
+ return MessageBox(hwndDlg, TranslateT("Please enter a game name."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
}
- else if (LOWORD(wParam) == IDOK)
+ else
{
- char temp[256];
-
- //fillgames sucht noch
- if (dontClose) {
- MessageBox(hwndDlg, TranslateT("Please wait, game.ini will be currently parsed..."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- return FALSE;
- }
-
- //neuen gameeintrag anlegen
- Xfire_game* newgame=NULL;
-
- if (editgame)
- newgame=editgame;
- else
- newgame=new Xfire_game();
-
- //Spielname
- GetDlgItemTextA(hwndDlg,IDC_ADD_NAME,temp,256);
+ //spielname zuordnen
+ newgame->setString(temp, &newgame->customgamename);
+ //spielnamen fürs menü
+ newgame->setString(temp, &newgame->name);
+ }
+ //spielid nur setzen/prüfen, wenn kein editgame
+ if (!editgame) {
+ GetDlgItemTextA(hwndDlg, IDC_ADD_ID, temp, 256);
if (!strlen(temp))
{
if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please enter a game name."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
}
else
{
- //spielname zuordnen
- newgame->setString(temp,&newgame->customgamename);
- //spielnamen fürs menü
- newgame->setString(temp,&newgame->name);
- }
- //spielid nur setzen/prüfen, wenn kein editgame
- if (!editgame) {
- GetDlgItemTextA(hwndDlg,IDC_ADD_ID,temp,256);
- if (!strlen(temp))
+ int gameid = atoi(temp);
+ //negative gameid blocken
+ if (gameid < 1)
{
if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
+ return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
}
- else
+ //gameid auf uniq prüfen
+ else if (xgamelist.getGamebyGameid(gameid))
{
- int gameid=atoi(temp);
- //negative gameid blocken
- if (gameid<1)
- {
- if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- }
- //gameid auf uniq prüfen
- else if (xgamelist.getGamebyGameid(gameid))
- {
- if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- }
- //gameid zuordnen
- newgame->id=gameid;
- //standardmäßig wird bei einem customeintrag keine id versendet
- newgame->send_gameid=-1;
+ if (!editgame) delete newgame;
+ return MessageBox(hwndDlg, TranslateT("This game ID is already in use."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
}
- }
- //zu sendene spielid
- GetDlgItemTextA(hwndDlg,IDC_ADD_SENDID,temp,256);
- if (strlen(temp))
- {
+ //gameid zuordnen
+ newgame->id = gameid;
//standardmäßig wird bei einem customeintrag keine id versendet
- int sendid=atoi(temp);
- if (sendid>0)
- newgame->send_gameid=sendid;
+ newgame->send_gameid = -1;
}
+ }
+ //zu sendene spielid
+ GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, 256);
+ if (strlen(temp))
+ {
+ //standardmäßig wird bei einem customeintrag keine id versendet
+ int sendid = atoi(temp);
+ if (sendid > 0)
+ newgame->send_gameid = sendid;
+ }
- //launcher exe
- GetDlgItemTextA(hwndDlg,IDC_ADD_LAUNCHEREXE,temp,256);
- if (strlen(temp))
- {
- //lowercase pfad
- newgame->strtolower(temp);
- //detect exe
- newgame->setString(temp,&newgame->launchparams);
- }
- //detectexe
- GetDlgItemTextA(hwndDlg,IDC_ADD_DETECTEXE,temp,256);
- if (!strlen(temp))
- {
- if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please select a game exe. Note: If you don't select a launcher exe, the game exe will be used in the game start menu."), TranslateT("XFire Options"), MB_OK|MB_ICONEXCLAMATION);
- }
- else
- {
- //lowercase pfad
- newgame->strtolower(temp);
- //detect exe
- newgame->setString(temp,&newgame->path);
- //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen
- if (!newgame->launchparams)
- newgame->setString(temp,&newgame->launchparams);
-
- }
- //mustcontain parameter
- GetDlgItemTextA(hwndDlg,IDC_ADD_CUSTOMPARAMS,temp,256);
- if (strlen(temp))
- {
- newgame->setString(temp,&newgame->mustcontain);
- }
- //statusmsg speichern
- GetDlgItemTextA(hwndDlg,IDC_ADD_STATUSMSG,temp,256);
- if (strlen(temp))
- {
- newgame->setString(temp,&newgame->statusmsg);
- newgame->setstatusmsg=1;
- }
- //custom eintrag aktivieren
- newgame->custom=1;
- //spiel in die gameliste einfügen, aber nur im nicht editmodus
- if (!editgame)
- xgamelist.Addgame(newgame);
- //derzeitige gameliste in die datenbank eintragen
- xgamelist.writeDatabase();
- //startmenu leeren
- xgamelist.clearStartmenu();
- //startmenu neuerzeugen
- xgamelist.createStartmenu();
+ //launcher exe
+ GetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, temp, 256);
+ if (strlen(temp))
+ {
+ //lowercase pfad
+ newgame->strtolower(temp);
+ //detect exe
+ newgame->setString(temp, &newgame->launchparams);
+ }
+ //detectexe
+ GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, 256);
+ if (!strlen(temp))
+ {
+ if (!editgame) delete newgame;
+ return MessageBox(hwndDlg, TranslateT("Please select a game exe. Note: If you don't select a launcher exe, the game exe will be used in the game start menu."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ }
+ else
+ {
+ //lowercase pfad
+ newgame->strtolower(temp);
+ //detect exe
+ newgame->setString(temp, &newgame->path);
+ //wenn kein launcher exe/pfad angeben wurde, dann den gamepath nehmen
+ if (!newgame->launchparams)
+ newgame->setString(temp, &newgame->launchparams);
- return SendMessage(GetParent(hwndDlg),WM_CLOSE,0,0);
}
- break;
+ //mustcontain parameter
+ GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, 256);
+ if (strlen(temp))
+ {
+ newgame->setString(temp, &newgame->mustcontain);
+ }
+ //statusmsg speichern
+ GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, 256);
+ if (strlen(temp))
+ {
+ newgame->setString(temp, &newgame->statusmsg);
+ newgame->setstatusmsg = 1;
+ }
+ //custom eintrag aktivieren
+ newgame->custom = 1;
+ //spiel in die gameliste einfügen, aber nur im nicht editmodus
+ if (!editgame)
+ xgamelist.Addgame(newgame);
+ //derzeitige gameliste in die datenbank eintragen
+ xgamelist.writeDatabase();
+ //startmenu leeren
+ xgamelist.clearStartmenu();
+ //startmenu neuerzeugen
+ xgamelist.createStartmenu();
+
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
}
+ break;
+ }
}
return FALSE;
}
-INT_PTR CALLBACK DlgAddGameProcMain (HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-)
+INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ )
{
switch (uMsg)
{
- case WM_INITDIALOG:
- {
- TCITEMA tci = {0};
- int iTotal;
- RECT rcClient;
+ case WM_INITDIALOG:
+ {
+ TCITEMA tci = { 0 };
+ int iTotal;
+ RECT rcClient;
- //icon des dialogs setzen
- SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ //icon des dialogs setzen
+ SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
- hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
- TabCtrl_DeleteAllItems(hwndTab);
- GetClientRect(GetParent(hwndTab), &rcClient);
+ hwndTab = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+ TabCtrl_DeleteAllItems(hwndTab);
+ GetClientRect(GetParent(hwndTab), &rcClient);
- hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc);
-
- //bei editgame keine spiellisteauswahl
- if (!editgame)
- {
- iTotal = TabCtrl_GetItemCount(hwndTab);
- tci.mask = TCIF_PARAM|TCIF_TEXT;
- tci.lParam = (LPARAM)hPage;
- tci.pszText = Translate("Supported Games");
- SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
- MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1);
- iTotal++;
- }
- else
- ShowWindow(hPage,FALSE);
+ hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc);
- hPage=CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2);
+ //bei editgame keine spiellisteauswahl
+ if (!editgame)
+ {
iTotal = TabCtrl_GetItemCount(hwndTab);
- tci.mask = TCIF_PARAM|TCIF_TEXT;
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = (LPARAM)hPage;
- tci.pszText = Translate("Custom game");
+ tci.pszText = Translate("Supported Games");
SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1);
iTotal++;
-
- //bei editgame 2. registerkarte aktiv schalten
- if (!editgame) {
- ShowWindow(hPage,FALSE);
- TabCtrl_SetCurSel(hwndTab, 0);
- }
+ }
+ else
+ ShowWindow(hPage, FALSE);
+
+ hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME2), hwndDlg, DlgAddGameProc2);
+ iTotal = TabCtrl_GetItemCount(hwndTab);
+ tci.mask = TCIF_PARAM | TCIF_TEXT;
+ tci.lParam = (LPARAM)hPage;
+ tci.pszText = Translate("Custom game");
+ SendMessageA(hwndTab, TCM_INSERTITEMA, iTotal, (WPARAM)&tci);
+ MoveWindow(hPage, 3, 24, rcClient.right - 10, rcClient.bottom - 28, 1);
+ iTotal++;
+
+ //bei editgame 2. registerkarte aktiv schalten
+ if (!editgame) {
+ ShowWindow(hPage, FALSE);
+ TabCtrl_SetCurSel(hwndTab, 0);
+ }
- return TRUE;
+ return TRUE;
+ }
+ case WM_CLOSE:
+ //nicht schließen, wenn noch der thread läuft
+ if (dontClose) return FALSE;
+ //buffer leeren
+ if (buffer)
+ {
+ delete[] buffer;
+ buffer = NULL;
}
- case WM_CLOSE:
- //nicht schließen, wenn noch der thread läuft
- if (dontClose) return FALSE;
- //buffer leeren
- if (buffer)
+ EndDialog(hwndDlg, 0);
+ break;
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
{
- delete[] buffer;
- buffer=NULL;
- }
- EndDialog(hwndDlg,0);
- break;
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
+ case PSN_APPLY:
+ {
+ TCITEM tci;
+ int i, count;
+
+ tci.mask = TCIF_PARAM;
+ count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_OPTIONSTAB));
+ for (i = 0; i < count; i++)
{
- TCITEM tci;
- int i,count;
-
- tci.mask = TCIF_PARAM;
- count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg,IDC_OPTIONSTAB));
- for (i=0; i<count; i++)
- {
- TabCtrl_GetItem(GetDlgItem(hwndDlg,IDC_OPTIONSTAB),i,&tci);
- SendMessage((HWND)tci.lParam,WM_NOTIFY,0,lParam);
- }
- break;
+ TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), i, &tci);
+ SendMessage((HWND)tci.lParam, WM_NOTIFY, 0, lParam);
}
- }
- break;
+ break;
+ }
+ }
+ break;
- case IDC_OPTIONSTAB:
- {
- HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
+ case IDC_OPTIONSTAB:
+ {
+ HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
- switch (((LPNMHDR)lParam)->code)
- {
- case TCN_SELCHANGING:
- {
- TCITEM tci;
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case TCN_SELCHANGING:
+ {
+ TCITEM tci;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
- ShowWindow((HWND)tci.lParam, SW_HIDE);
- }
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam, SW_HIDE);
+ }
break;
- case TCN_SELCHANGE:
- {
- TCITEM tci;
+ case TCN_SELCHANGE:
+ {
+ TCITEM tci;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
- ShowWindow((HWND)tci.lParam,SW_SHOW);
- }
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
+ ShowWindow((HWND)tci.lParam, SW_SHOW);
+ }
break;
- }
- break;
}
- }
- break;
+ break;
+ }
+ }
+ break;
}
return FALSE;
}
\ No newline at end of file diff --git a/protocols/Xfire/src/addgamedialog.h b/protocols/Xfire/src/addgamedialog.h index 3795df1ed5..597b0ad985 100644 --- a/protocols/Xfire/src/addgamedialog.h +++ b/protocols/Xfire/src/addgamedialog.h @@ -5,17 +5,17 @@ #include "Xfire_gamelist.h"
//dialog funktion
-INT_PTR CALLBACK DlgAddGameProc (HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-);
+INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ );
-INT_PTR CALLBACK DlgAddGameProcMain (HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
-);
+INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ );
//struct für den cache
struct lbInicache {
@@ -23,6 +23,6 @@ struct lbInicache { unsigned int gameid;
};
-void AddGameDialog(HWND hwndDlg,Xfire_game* game=NULL);
+void AddGameDialog(HWND hwndDlg, Xfire_game* game = NULL);
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp index 7ded77640a..f09d3526a8 100644 --- a/protocols/Xfire/src/all_statusmsg.cpp +++ b/protocols/Xfire/src/all_statusmsg.cpp @@ -15,61 +15,61 @@ using namespace std; #include "xdebug.h"
//vector beinhaltet statusmessages
-vector<string> *olstatusmsg=NULL;
-vector<string> *protoname=NULL;
-vector<unsigned int> *olstatus=NULL;
-vector<unsigned int> *oltostatus=NULL;
+vector<string> *olstatusmsg = NULL;
+vector<string> *protoname = NULL;
+vector<unsigned int> *olstatus = NULL;
+vector<unsigned int> *oltostatus = NULL;
PROTOACCOUNT **temp;
-int anz,statusid;
+int anz, statusid;
int statustype;
BOOL BackupStatusMsg() {
DBVARIANT dbv;
- statustype=db_get_b(NULL,protocolname,"statuschgtype",0);
+ statustype = db_get_b(NULL, protocolname, "statuschgtype", 0);
XFireLog("Backup Status Message...");
//alten vector löschen
- if (olstatusmsg!=NULL)
+ if (olstatusmsg != NULL)
{
delete olstatusmsg;
- olstatusmsg=NULL;
+ olstatusmsg = NULL;
}
- if (protoname!=NULL)
+ if (protoname != NULL)
{
delete protoname;
- protoname=NULL;
+ protoname = NULL;
}
- if (olstatus!=NULL)
+ if (olstatus != NULL)
{
delete olstatus;
- olstatus=NULL;
+ olstatus = NULL;
}
- if (oltostatus!=NULL)
+ if (oltostatus != NULL)
{
delete oltostatus;
- oltostatus=NULL;
+ oltostatus = NULL;
}
- olstatusmsg=new vector<string>;
- protoname=new vector<string>;
- olstatus=new vector<unsigned int>;
- oltostatus=new vector<unsigned int>;
+ olstatusmsg = new vector < string > ;
+ protoname = new vector < string > ;
+ olstatus = new vector < unsigned int > ;
+ oltostatus = new vector < unsigned int > ;
//alle protokolle durchgehen und den status in den vector sichern
- CallService(MS_PROTO_ENUMACCOUNTS,(WPARAM)&anz,(LPARAM)&temp);
- for(int i=0;i<anz;i++)
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&anz, (LPARAM)&temp);
+ for (int i = 0; i < anz; i++)
{
- statusid=CallProtoService(temp[i]->szModuleName,PS_GETSTATUS,0,0);
- XFireLog("Get Status of %s ...",temp[i]->szModuleName);
+ statusid = CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0);
+ XFireLog("Get Status of %s ...", temp[i]->szModuleName);
- char ttemp[128]="";
- mir_snprintf(ttemp,128,"%s%s",temp[i]->szModuleName,PS_SETAWAYMSG);
+ char ttemp[128] = "";
+ mir_snprintf(ttemp, 128, "%s%s", temp[i]->szModuleName, PS_SETAWAYMSG);
//xfire wird geskipped, offline prots und invs prots auch, und locked status prots auch
- if (!temp[i]->bIsEnabled||statusid==ID_STATUS_INVISIBLE||statusid==ID_STATUS_OFFLINE||!lstrcmpiA( temp[i]->szModuleName, protocolname )||!ServiceExists(ttemp)||db_get_b(NULL,temp[i]->szModuleName,"LockMainStatus",0)==1)
+ if (!temp[i]->bIsEnabled || statusid == ID_STATUS_INVISIBLE || statusid == ID_STATUS_OFFLINE || !lstrcmpiA(temp[i]->szModuleName, protocolname) || !ServiceExists(ttemp) || db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1)
{
- XFireLog("-> Skip %s.",temp[i]->szModuleName);
+ XFireLog("-> Skip %s.", temp[i]->szModuleName);
olstatus->push_back(-1);
olstatusmsg->push_back("");
@@ -81,69 +81,69 @@ BOOL BackupStatusMsg() { if (statustype)
{
int dummystatusid = -1;
-
+
if (statusid != 0)
- {
+ {
int caps = CallProtoService(temp[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
- bool dndFirst = db_get_b(NULL,protocolname,"dndfirst",0) > 0;
+ bool dndFirst = db_get_b(NULL, protocolname, "dndfirst", 0) > 0;
if (dndFirst ? caps&PF2_HEAVYDND : caps&PF2_LIGHTDND)
- {
+ {
dummystatusid = dndFirst ? ID_STATUS_DND : ID_STATUS_OCCUPIED;
- XFireLog("%s supports %s.",temp[i]->szModuleName, dndFirst ? "DND" : "OCCUPIED");
+ XFireLog("%s supports %s.", temp[i]->szModuleName, dndFirst ? "DND" : "OCCUPIED");
}
else if (dndFirst ? caps&PF2_LIGHTDND : caps&PF2_HEAVYDND)
{
dummystatusid = dndFirst ? ID_STATUS_OCCUPIED : ID_STATUS_DND;
- XFireLog("%s supports %s.",temp[i]->szModuleName, dndFirst ? "OCCUPIED" : "DND");
+ XFireLog("%s supports %s.", temp[i]->szModuleName, dndFirst ? "OCCUPIED" : "DND");
}
else if (caps&PF2_SHORTAWAY)
{
dummystatusid = ID_STATUS_AWAY;
- XFireLog("%s supports AWAY.",temp[i]->szModuleName);
+ XFireLog("%s supports AWAY.", temp[i]->szModuleName);
}
else
- {
+ {
dummystatusid = statusid;
- XFireLog("%s no Away???.",temp[i]->szModuleName);
- }
+ XFireLog("%s no Away???.", temp[i]->szModuleName);
+ }
}
-
+
oltostatus->push_back(dummystatusid);
}
- switch(statusid)
+ switch (statusid)
{
case ID_STATUS_ONLINE:
- if (db_get(NULL,"SRAway","OnMsg",&dbv))
+ if (db_get(NULL, "SRAway", "OnMsg", &dbv))
olstatusmsg->push_back(Translate("Yep, I'm here."));
break;
case ID_STATUS_AWAY:
- if (db_get(NULL,"SRAway","AwayMsg",&dbv))
+ if (db_get(NULL, "SRAway", "AwayMsg", &dbv))
olstatusmsg->push_back(Translate("I've been away since %time%."));
break;
case ID_STATUS_NA:
- if (db_get(NULL,"SRAway","NaMsg",&dbv))
+ if (db_get(NULL, "SRAway", "NaMsg", &dbv))
olstatusmsg->push_back(Translate("Give it up, I'm not in!"));
break;
case ID_STATUS_OCCUPIED:
- if (db_get(NULL,"SRAway","OccupiedMsg",&dbv))
+ if (db_get(NULL, "SRAway", "OccupiedMsg", &dbv))
olstatusmsg->push_back(Translate("Not right now."));
break;
case ID_STATUS_DND:
- if (db_get(NULL,"SRAway","DndMsg",&dbv))
+ if (db_get(NULL, "SRAway", "DndMsg", &dbv))
olstatusmsg->push_back(Translate("Give a guy some peace, would ya?"));
break;
case ID_STATUS_FREECHAT:
- if (db_get(NULL,"SRAway","FreeChatMsg",&dbv))
+ if (db_get(NULL, "SRAway", "FreeChatMsg", &dbv))
olstatusmsg->push_back(Translate("Well, I would talk to you if Miranda ICQ supported chat"));
break;
case ID_STATUS_ONTHEPHONE:
- if (db_get(NULL,"SRAway","OtpMsg",&dbv))
+ if (db_get(NULL, "SRAway", "OtpMsg", &dbv))
olstatusmsg->push_back(Translate("That'll be the phone."));
break;
case ID_STATUS_OUTTOLUNCH:
- if (db_get(NULL,"SRAway","OtlMsg",&dbv))
+ if (db_get(NULL, "SRAway", "OtlMsg", &dbv))
olstatusmsg->push_back(Translate("Mmm... food."));
break;
default:
@@ -156,7 +156,7 @@ BOOL BackupStatusMsg() { //ab in den vector
olstatus->push_back(statusid);
- if (olstatus->size()>olstatusmsg->size())
+ if (olstatus->size() > olstatusmsg->size())
{
olstatusmsg->push_back(string(dbv.pszVal));
protoname->push_back(temp[i]->szModuleName);
@@ -183,18 +183,18 @@ BOOL SetGameStatusMsg() //zusetzende statusmsg erstellen
if (ServiceExists(MS_VARS_FORMATSTRING))
{
- ptrT statusMsgT( db_get_tsa(NULL, protocolname, "setstatusmsg"));
+ ptrT statusMsgT(db_get_tsa(NULL, protocolname, "setstatusmsg"));
//direkte funktionen verwenden
statusMsgT = variables_parse(statusMsgT, NULL, 0);
if (statusMsgT == NULL)
return FALSE;
-
+
statusMsg = _T2A(statusMsgT);
}
else
{
//alternativ zweig ohne variables
- ptrA statusMsg( db_get_sa(NULL, protocolname, "setstatusmsg"));
+ ptrA statusMsg(db_get_sa(NULL, protocolname, "setstatusmsg"));
if (statusMsg == NULL)
return FALSE;
@@ -208,7 +208,7 @@ BOOL SetGameStatusMsg() //derzeitiges spiel
tmp = db_get_sa(NULL, protocolname, "currentgamename");
- xgamelist.strreplace("%myxfiregame%", tmp, &statusmsg);
+ xgamelist.strreplace("%myxfiregame%", tmp, &statusmsg);
//derzeitiges voiceprogram
tmp = db_get_sa(NULL, protocolname, "currentvoicename");
@@ -225,56 +225,56 @@ BOOL SetGameStatusMsg() statusMsg = statusmsg;
}
- CallService(MS_PROTO_ENUMACCOUNTS,(WPARAM)&anz,(LPARAM)&temp);
- for(int i=0;i<anz;i++)
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&anz, (LPARAM)&temp);
+ for (int i = 0; i < anz; i++)
{
- if (olstatus->at(i)!=-1)
+ if (olstatus->at(i) != -1)
{
if (statustype)
{
//newawaysys
if (ServiceExists("NewAwaySystem/SetStateA"))
{
- XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateA.",protoname->at(i).c_str());
+ XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateA.", protoname->at(i).c_str());
- NAS_PROTOINFO npi = {0};
- npi.cbSize=sizeof(NAS_PROTOINFO);
- npi.szProto=(char*)protoname->at(i).c_str();
- npi.status=oltostatus->at(i);
- npi.szMsg=mir_strdup(statusMsg);
+ NAS_PROTOINFO npi = { 0 };
+ npi.cbSize = sizeof(NAS_PROTOINFO);
+ npi.szProto = (char*)protoname->at(i).c_str();
+ npi.status = oltostatus->at(i);
+ npi.szMsg = mir_strdup(statusMsg);
CallService("NewAwaySystem/SetStateA", (WPARAM)&npi, 1);
}
else if (ServiceExists("NewAwaySystem/SetStateW")) {
- XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateW.",protoname->at(i).c_str());
+ XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateW.", protoname->at(i).c_str());
- NAS_PROTOINFO npi = {0};
- npi.cbSize=sizeof(NAS_PROTOINFO);
- npi.szProto=(char*)protoname->at(i).c_str();
- npi.status=oltostatus->at(i);
- npi.szMsg=mir_strdup(statusMsg);
+ NAS_PROTOINFO npi = { 0 };
+ npi.cbSize = sizeof(NAS_PROTOINFO);
+ npi.szProto = (char*)protoname->at(i).c_str();
+ npi.status = oltostatus->at(i);
+ npi.szMsg = mir_strdup(statusMsg);
CallService("NewAwaySystem/SetStateW", (WPARAM)&npi, 1);
}
else
{
- XFireLog("-> SetStatusMsg of %s with Miranda with occupied status.",protoname->at(i).c_str());
+ XFireLog("-> SetStatusMsg of %s with Miranda with occupied status.", protoname->at(i).c_str());
//statusmsg für beschäftigt setzen
- CallProtoService(temp[i]->szModuleName,PS_SETAWAYMSG,oltostatus->at(i),(LPARAM)statusMsg);
+ CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), (LPARAM)statusMsg);
//status auf beschäftigt wechseln
- CallProtoService(temp[i]->szModuleName,PS_SETSTATUS,oltostatus->at(i),0);
+ CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, oltostatus->at(i), 0);
//statusmsg für beschäftigt setzen
- if (CallProtoService(temp[i]->szModuleName,PS_GETSTATUS,0,0)!=oltostatus->at(i))
+ if (CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0) != oltostatus->at(i))
{
XFireLog("Set StatusMsg again, Status was not succesfully set.");
- CallProtoService(temp[i]->szModuleName,PS_SETAWAYMSG,oltostatus->at(i),(LPARAM)statusMsg);
+ CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), (LPARAM)statusMsg);
}
}
}
else
{
- XFireLog("-> SetStatusMsg of %s.",protoname->at(i).c_str());
+ XFireLog("-> SetStatusMsg of %s.", protoname->at(i).c_str());
- CallProtoService(temp[i]->szModuleName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)statusMsg);
+ CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)statusMsg);
}
}
}
@@ -285,50 +285,50 @@ BOOL SetGameStatusMsg() BOOL SetOldStatusMsg()
{
//prüfe ob vector leer
- if (olstatusmsg==NULL)
+ if (olstatusmsg == NULL)
return FALSE;
- CallService(MS_PROTO_ENUMACCOUNTS,(WPARAM)&anz,(LPARAM)&temp);
- for(int i=0;i<anz;i++)
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&anz, (LPARAM)&temp);
+ for (int i = 0; i < anz; i++)
{
- if (olstatus->at(i)!=-1)
+ if (olstatus->at(i) != -1)
{
if (statustype)
{
//alten status setzen
- CallProtoService(temp[i]->szModuleName,PS_SETSTATUS,olstatus->at(i),0);
+ CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, olstatus->at(i), 0);
//status wurde nicht gewechselt, dann statusmsg nachträglich setzen
- if (CallProtoService(temp[i]->szModuleName,PS_GETSTATUS,0,0)!=olstatus->at(i))
- CallProtoService(temp[i]->szModuleName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)olstatusmsg->at(i).c_str());
+ if (CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0) != olstatus->at(i))
+ CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)olstatusmsg->at(i).c_str());
}
else
{
- CallProtoService(temp[i]->szModuleName,PS_SETSTATUS,olstatus->at(i),0);
- CallProtoService(temp[i]->szModuleName,PS_SETAWAYMSG,olstatus->at(i),(LPARAM)olstatusmsg->at(i).c_str());
+ CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, olstatus->at(i), 0);
+ CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)olstatusmsg->at(i).c_str());
}
}
}
//alten vector löschen
- if (protoname!=NULL)
+ if (protoname != NULL)
{
delete protoname;
- protoname=NULL;
+ protoname = NULL;
}
- if (olstatusmsg!=NULL)
+ if (olstatusmsg != NULL)
{
delete olstatusmsg;
- olstatusmsg=NULL;
+ olstatusmsg = NULL;
}
- if (olstatus!=NULL)
+ if (olstatus != NULL)
{
delete olstatus;
- olstatus=NULL;
+ olstatus = NULL;
}
- if (oltostatus!=NULL)
+ if (oltostatus != NULL)
{
delete olstatus;
- olstatus=NULL;
+ olstatus = NULL;
}
return TRUE;
diff --git a/protocols/Xfire/src/baseProtocol.h b/protocols/Xfire/src/baseProtocol.h index 920633eb25..7723cc1aa7 100644 --- a/protocols/Xfire/src/baseProtocol.h +++ b/protocols/Xfire/src/baseProtocol.h @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -21,7 +21,7 @@ * Based on J. Lawler - BaseProtocol
* Herbert Poul/Beat Wolf - xfirelib
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -59,30 +59,30 @@ INT_PTR TMLoadIcon(WPARAM wParam, LPARAM lParam); INT_PTR SetNickName(WPARAM newnick, LPARAM lparam);
BOOL IsXFireContact(MCONTACT h);
-int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hhicon=NULL);
+int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, HICON hhicon = NULL);
BOOL CreateToolTip(int toolID, HWND hDlg, CHAR* pText);
void EnableDlgItem(HWND hwndDlg, UINT control, int state);
-BOOL str_replace(char*src,char*find,char*rep);
+BOOL str_replace(char*src, char*find, char*rep);
extern void Message(LPVOID msg);
extern void MessageE(LPVOID msg);
char* GetLaunchPath(char*launch);
unsigned short r(unsigned short data);
-BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
-BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1,char*ip2,char*ip3,char*ip4,long*port);
-BOOL FindTeamSpeak(DWORD*pid,int*vid);
+BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*ip1, char*ip2, char*ip3, char*ip4, long*port);
+BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char*ip1, char*ip2, char*ip3, char*ip4, long*port);
+BOOL FindTeamSpeak(DWORD*pid, int*vid);
char*menuitemtext(char*mtext);
-BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain);
-char * getItem(char * string,char delim,int count);
-BOOL GetWWWContent(char*host,char* request,char*filename,BOOL dontoverwrite);
-BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf=NULL,unsigned int* size=NULL);
+BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain);
+char * getItem(char * string, char delim, int count);
+BOOL GetWWWContent(char*host, char* request, char*filename, BOOL dontoverwrite);
+BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf = NULL, unsigned int* size = NULL);
BOOL CheckWWWContent(char*address);
unsigned int getfilesize(char*path);
void UpdateMyXFireIni(LPVOID dummy);
void UpdateMyIcons(LPVOID dummy);
BOOL IsContactMySelf(std::string buddyusername);
DWORD xfire_GetPrivateProfileString(__in LPCSTR lpAppName, __in LPCSTR lpKeyName, __in LPCSTR lpDefault, __out LPSTR lpReturnedString, __in DWORD nSize, __in LPCSTR lpFileName);
-BOOL mySleep(int ms,HANDLE evt);
-void __stdcall XFireLog( const char* fmt, ... );
+BOOL mySleep(int ms, HANDLE evt);
+void __stdcall XFireLog(const char* fmt, ...);
#define ID_STATUS_RECONNECT ID_STATUS_OFFLINE-1
@@ -193,13 +193,13 @@ typedef struct { WCHAR *wszMsg;
TCHAR *tszMsg;
}; // pointer to the status message _format_ (i.e. it's an unparsed message containing variables, in any case. NAS takes care of parsing) (may be NULL - means that there's no specific message for this protocol - then the global status message will be used)
-/*
- Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's
- memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE
- expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg.
-*/
+ /*
+ Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's
+ memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE
+ expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg.
+ */
WORD status; // status mode. 0 means current (NAS will overwrite 0 with the current status mode)
-// for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message.
+ // for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message.
int Flags;
} NAS_PROTOINFO;
diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp index 8a91df0ccc..2f8ebe6ea9 100644 --- a/protocols/Xfire/src/iniupdater.cpp +++ b/protocols/Xfire/src/iniupdater.cpp @@ -13,35 +13,35 @@ INT_PTR CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR {
switch (msg)
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
- char*buf=NULL; //leeren zeiger für den empfangen buffer
- GetWWWContent2(INI_WHATSNEW,NULL,FALSE,&buf);
+ char*buf = NULL; //leeren zeiger für den empfangen buffer
+ GetWWWContent2(INI_WHATSNEW, NULL, FALSE, &buf);
- if (buf!=NULL)
- {
- SetDlgItemTextA(hwndDlg,IDC_UPDATEGAMES,buf);
- delete[] buf;
- }
+ if (buf != NULL)
+ {
+ SetDlgItemTextA(hwndDlg, IDC_UPDATEGAMES, buf);
+ delete[] buf;
+ }
- SetFocus(GetDlgItem(hwndDlg,IDOK));
+ SetFocus(GetDlgItem(hwndDlg, IDOK));
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ EndDialog(hwndDlg, IDOK);
+ return TRUE;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
return TRUE;
}
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDOK:
- EndDialog(hwndDlg,IDOK);
- return TRUE;
-
- case IDCANCEL:
- EndDialog(hwndDlg,IDCANCEL);
- return TRUE;
- }
- break;
+ break;
}
return FALSE;
@@ -54,32 +54,32 @@ void UpdateMyXFireIni(LPVOID dummy) { char file3[1024];
//ini pfad rausbekommen
- strcpy(file, XFireGetFoldersPath ("IniFile"));
- strcpy(file2,file);
- strcpy(file3,file);
- strcat(file,"xfire_games.new");
- strcat(file2,"xfire_games.ini");
- strcat(file3,"xfire_games.old");
+ strcpy(file, XFireGetFoldersPath("IniFile"));
+ strcpy(file2, file);
+ strcpy(file3, file);
+ strcat(file, "xfire_games.new");
+ strcat(file2, "xfire_games.ini");
+ strcat(file3, "xfire_games.old");
- mir_snprintf(request,1024,"%s%d",INI_URLREQUEST,getfilesize(file2));
+ mir_snprintf(request, 1024, "%s%d", INI_URLREQUEST, getfilesize(file2));
if (CheckWWWContent(request))
{
- if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==1||DialogBox(hinstance,MAKEINTRESOURCE(IDD_UPDATE),NULL,DlgUpdateDialogProc)==IDOK)
+ if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 1 || DialogBox(hinstance, MAKEINTRESOURCE(IDD_UPDATE), NULL, DlgUpdateDialogProc) == IDOK)
{
- if (GetWWWContent2(request,file,FALSE))
+ if (GetWWWContent2(request, file, FALSE))
{
//altes backup löschen
remove(file3);
//derzeitige ini und sichern
- rename(file2,file3);
+ rename(file2, file3);
//lösche .old, wenn aktiv
- if (db_get_b(NULL,protocolname,"nobackupini",0))
+ if (db_get_b(NULL, protocolname, "nobackupini", 0))
remove(file3);
//neue aktiv schalten
- rename(file,file2);
-
- if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The xfire_games.ini was updated."));
+ rename(file, file2);
+
+ if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 0) MSGBOX(Translate("The xfire_games.ini was updated."));
}
else
MSGBOX(Translate("Error during xfire_games.ini update."));
@@ -94,31 +94,31 @@ void UpdateMyIcons(LPVOID dummy) { char file3[1024];
//ini pfad rausbekommen
- strcpy(file,XFireGetFoldersPath ("IconsFile"));
- strcpy(file2,file);
- strcpy(file3,file);
- strcat(file,"icons.new");
- strcat(file2,"icons.dll");
- strcat(file3,"icons.old");
+ strcpy(file, XFireGetFoldersPath("IconsFile"));
+ strcpy(file2, file);
+ strcpy(file3, file);
+ strcat(file, "icons.new");
+ strcat(file2, "icons.dll");
+ strcat(file3, "icons.old");
- mir_snprintf(request,1024,"%s%d",ICO_URLREQUEST,getfilesize(file2));
+ mir_snprintf(request, 1024, "%s%d", ICO_URLREQUEST, getfilesize(file2));
if (CheckWWWContent(request))
{
- if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==1||MessageBox(NULL,TranslateT("There is a new Icons.dll online, do you want to update now?"),TranslateT(PLUGIN_TITLE),MB_YESNO|MB_ICONQUESTION)==IDYES)
+ if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 1 || MessageBox(NULL, TranslateT("There is a new Icons.dll online, do you want to update now?"), TranslateT(PLUGIN_TITLE), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
- if (GetWWWContent2(request,file,FALSE)) {
+ if (GetWWWContent2(request, file, FALSE)) {
//altes backup löschen
remove(file3);
//derzeitige ini und sichern
- rename(file2,file3);
+ rename(file2, file3);
//lösche .old, wenn aktiv
- if (db_get_b(NULL,protocolname,"nobackupini",0))
+ if (db_get_b(NULL, protocolname, "nobackupini", 0))
remove(file3);
//neue aktiv schalten
- rename(file,file2);
-
- if (db_get_b(NULL,protocolname,"dontaskforupdate",0)==0) MSGBOX(Translate("The Icons.dll was updated."));
+ rename(file, file2);
+
+ if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 0) MSGBOX(Translate("The Icons.dll was updated."));
}
else
MSGBOX(Translate("Error during Icons.dll Update."));
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index ef46e4020b..d89f87e923 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -99,8 +99,8 @@ HINSTANCE hinstance = NULL; int hLangpack;
HANDLE hExtraIcon1, hExtraIcon2;
HANDLE heventXStatusIconChanged;
-HGENMENU copyipport,gotoclansite,vipport,joingame,startthisgame,removefriend,blockfriend;
-int foundgames=0;
+HGENMENU copyipport, gotoclansite, vipport, joingame, startthisgame, removefriend, blockfriend;
+int foundgames = 0;
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
@@ -112,21 +112,21 @@ CRITICAL_SECTION modeMsgsMutex; CRITICAL_SECTION avatarMutex;
CRITICAL_SECTION connectingMutex;
-DWORD pid=NULL; //processid des gefunden spiels
-DWORD ts2pid=NULL; // processid vom teamspeak/ventrilo
+DWORD pid = NULL; //processid des gefunden spiels
+DWORD ts2pid = NULL; // processid vom teamspeak/ventrilo
HANDLE XFireAvatarFolder = NULL;
HANDLE XFireWorkingFolder = NULL;
HANDLE XFireIconFolder = NULL;
HANDLE hookgamestart = NULL;
char statusmessage[2][1024];
-BOOL sendonrecieve=FALSE;
-HANDLE hNetlib=NULL;
+BOOL sendonrecieve = FALSE;
+HANDLE hNetlib = NULL;
extern LPtsrGetServerInfo tsrGetServerInfo;
//eventhandles
-HANDLE hGameDetection = CreateEvent(NULL,FALSE,FALSE,NULL);
-HANDLE hConnectionClose = CreateEvent(NULL,TRUE,FALSE,NULL);
+HANDLE hGameDetection = CreateEvent(NULL, FALSE, FALSE, NULL);
+HANDLE hConnectionClose = CreateEvent(NULL, TRUE, FALSE, NULL);
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -139,7 +139,7 @@ PLUGININFOEX pluginInfo = { __AUTHORWEB,
UNICODE_AWARE,
// {9B8E1735-970D-4ce0-930C-A561956BDCA2}
- {0x9b8e1735, 0x970d, 0x4ce0, {0x93, 0xc, 0xa5, 0x61, 0x95, 0x6b, 0xdc, 0xa2}}
+ { 0x9b8e1735, 0x970d, 0x4ce0, { 0x93, 0xc, 0xa5, 0x61, 0x95, 0x6b, 0xdc, 0xa2 } }
};
static IconItem icon = { LPGEN("Protocol icon"), "XFIRE_main", IDI_TM };
@@ -148,18 +148,18 @@ INT_PTR RecvMessage(WPARAM wParam, LPARAM lParam); INT_PTR SendMessage(WPARAM wParam, LPARAM lParam);
int FillList(WPARAM wParam, LPARAM lParam);
-MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan);
-MCONTACT CList_FindContact (int uid);
+MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline, int clan);
+MCONTACT CList_FindContact(int uid);
void CList_MakeAllOffline();
static INT_PTR UserIsTyping(WPARAM wParam, LPARAM lParam);
-HANDLE LoadGameIcon(char* g, int id, HICON* ico,BOOL onyico=FALSE,char * gamename=NULL,int*uu=NULL);
-BOOL GetAvatar(char* username,XFireAvatar* av);
+HANDLE LoadGameIcon(char* g, int id, HICON* ico, BOOL onyico = FALSE, char * gamename = NULL, int*uu = NULL);
+BOOL GetAvatar(char* username, XFireAvatar* av);
//void SetAvatar(MCONTACT hContact, char* username);
static void SetAvatar(LPVOID lparam);
-static INT_PTR GetIPPort(WPARAM /*wParam*/,LPARAM lParam);
-static INT_PTR GetVIPPort(WPARAM /*wParam*/,LPARAM lParam);
-int RebuildContactMenu( WPARAM wParam, LPARAM lParam );
-int doneQuery( WPARAM wParam, LPARAM lParam );
+static INT_PTR GetIPPort(WPARAM /*wParam*/, LPARAM lParam);
+static INT_PTR GetVIPPort(WPARAM /*wParam*/, LPARAM lParam);
+int RebuildContactMenu(WPARAM wParam, LPARAM lParam);
+int doneQuery(WPARAM wParam, LPARAM lParam);
static INT_PTR GotoProfile(WPARAM wParam, LPARAM lParam);
static INT_PTR GotoProfileAct(WPARAM wParam, LPARAM lParam);
@@ -169,15 +169,15 @@ static INT_PTR SetNickDlg(WPARAM wParam, LPARAM lParam); static INT_PTR CustomGameSetup(WPARAM wParam, LPARAM lParam);
#ifndef NO_PTHREAD
- void *gamedetectiont(void *ptr);
- void *inigamedetectiont(void *ptr);
- pthread_t gamedetection;
+void *gamedetectiont(void *ptr);
+void *inigamedetectiont(void *ptr);
+pthread_t gamedetection;
#else
- void inigamedetectiont(LPVOID lParam);
- void gamedetectiont(LPVOID lparam);
+void inigamedetectiont(LPVOID lParam);
+void gamedetectiont(LPVOID lparam);
#endif
-INT_PTR AddtoList( WPARAM wParam, LPARAM lParam );
+INT_PTR AddtoList(WPARAM wParam, LPARAM lParam);
INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam);
INT_PTR GetAvatarInfo(WPARAM wParam, LPARAM lParam); //GAIR_NOAVATAR
INT_PTR SearchAddtoList(WPARAM wParam, LPARAM lParam);
@@ -187,13 +187,13 @@ INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam); INT_PTR GetXStatusIcon(WPARAM wParam, LPARAM lParam);
static INT_PTR GotoProfile2(WPARAM wParam, LPARAM lParam);
-MCONTACT handlingBuddys(BuddyListEntry *entry, int clan=0,char* group=NULL,BOOL dontscan=FALSE);
+MCONTACT handlingBuddys(BuddyListEntry *entry, int clan = 0, char* group = NULL, BOOL dontscan = FALSE);
int StatusIcon(WPARAM wParam, LPARAM lParam);
-void CreateGroup(char*grpn,char*field); //void CreateGroup(char*grp);
-int ContactDeleted(WPARAM wParam,LPARAM /*lParam*/);
+void CreateGroup(char*grpn, char*field); //void CreateGroup(char*grp);
+int ContactDeleted(WPARAM wParam, LPARAM /*lParam*/);
INT_PTR JoinGame(WPARAM wParam, LPARAM lParam);
-extern void Scan4Games( LPVOID lparam );
+extern void Scan4Games(LPVOID lparam);
INT_PTR RemoveFriend(WPARAM wParam, LPARAM lParam);
INT_PTR BlockFriend(WPARAM wParam, LPARAM lParam);
INT_PTR StartThisGame(WPARAM wParam, LPARAM lParam);
@@ -206,41 +206,41 @@ using namespace xfirelib; class XFireClient : public PacketListener {
- public:
- Client* client;
+public:
+ Client* client;
Xfire_avatar_loader* avatarloader;
- XFireClient(string username, string password,char protover,int useproxy=0,string proxyip="",int proxyport=0);
- ~XFireClient();
- void run();
+ XFireClient(string username, string password, char protover, int useproxy = 0, string proxyip = "", int proxyport = 0);
+ ~XFireClient();
+ void run();
- void Status(string s);
+ void Status(string s);
- void receivedPacket(XFirePacket *packet);
+ void receivedPacket(XFirePacket *packet);
void getBuddyList();
- void sendmsg(char*usr,char*msg);
+ void sendmsg(char*usr, char*msg);
void setNick(char*nnick);
void handlingBuddy(MCONTACT handle);
void CheckAvatar(BuddyListEntry* entry);
- private:
- vector<string> explodeString(string s, string e);
- string joinString(vector<string> s, int startindex, int endindex=-1, string delimiter=" ");
- void BuddyList();
+private:
+ vector<string> explodeString(string s, string e);
+ string joinString(vector<string> s, int startindex, int endindex = -1, string delimiter = " ");
+ void BuddyList();
- string *lastInviteRequest;
+ string *lastInviteRequest;
- string username;
- string password;
+ string username;
+ string password;
string proxyip;
int useproxy;
int proxyport;
BOOL connected;
unsigned int myuid;
- };
+};
-XFireClient* myClient=NULL;
+XFireClient* myClient = NULL;
void XFireClient::CheckAvatar(BuddyListEntry* entry) {
//kein entry, zurück
@@ -248,13 +248,13 @@ void XFireClient::CheckAvatar(BuddyListEntry* entry) { return;
//keine avatars?
- if (db_get_b(NULL,protocolname,"noavatars",-1)==0)
+ if (db_get_b(NULL, protocolname, "noavatars", -1) == 0)
{
//avatar gelocked?
- if (db_get_b(entry->hcontact, "ContactPhoto", "Locked", -1)!=1)
+ if (db_get_b(entry->hcontact, "ContactPhoto", "Locked", -1) != 1)
{
//avatar lade auftrag übergeben
- this->avatarloader->loadAvatar(entry->hcontact,(char*)entry->username.c_str(),entry->userid);
+ this->avatarloader->loadAvatar(entry->hcontact, (char*)entry->username.c_str(), entry->userid);
}
}
}
@@ -262,11 +262,11 @@ void XFireClient::CheckAvatar(BuddyListEntry* entry) { void XFireClient::handlingBuddy(MCONTACT handle)
{
vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
- for(uint i = 0 ; i < entries->size() ; i ++) {
+ for (uint i = 0; i < entries->size(); i++) {
BuddyListEntry *entry = entries->at(i);
if (entry->hcontact == handle)
{
- handlingBuddys(entry,0,NULL);
+ handlingBuddys(entry, 0, NULL);
break;
}
}
@@ -278,470 +278,470 @@ void XFireClient::setNick(char*nnick) { return;*/
SendNickChangePacket nick;
nick.nick = nnick;
- client->send( &nick );
+ client->send(&nick);
}
-void XFireClient::sendmsg(char*usr,char*cmsg) {
- SendMessagePacket msg;
+void XFireClient::sendmsg(char*usr, char*cmsg) {
+ SendMessagePacket msg;
// if (strlen(cmsg)>255)
// *(cmsg+255)=0;
- msg.init(client, usr, cmsg);
- client->send( &msg );
- }
+ msg.init(client, usr, cmsg);
+ client->send(&msg);
+}
- XFireClient::XFireClient(string username_,string password_,char protover,int useproxy,string proxyip,int proxyport)
- : username(username_), password(password_) {
- client = new Client();
- client->setGameResolver( new DummyXFireGameResolver() );
- client->protocolVersion=protover;
+XFireClient::XFireClient(string username_, string password_, char protover, int useproxy, string proxyip, int proxyport)
+ : username(username_), password(password_) {
+ client = new Client();
+ client->setGameResolver(new DummyXFireGameResolver());
+ client->protocolVersion = protover;
avatarloader = new Xfire_avatar_loader(client);
- this->useproxy=useproxy;
- this->proxyip=proxyip;
- this->proxyport=proxyport;
+ this->useproxy = useproxy;
+ this->proxyip = proxyip;
+ this->proxyport = proxyport;
- avatarloader=new Xfire_avatar_loader(client);
+ avatarloader = new Xfire_avatar_loader(client);
- lastInviteRequest = NULL;
+ lastInviteRequest = NULL;
connected = FALSE;
- }
+}
- XFireClient::~XFireClient() {
- if (client!=NULL) {
+XFireClient::~XFireClient() {
+ if (client != NULL) {
client->disconnect();
delete client;
}
if (avatarloader) {
delete avatarloader;
- avatarloader=NULL;
- }
- if (lastInviteRequest!=NULL) delete lastInviteRequest;
- }
-
- void XFireClient::run() {
- client->connect(username,password,useproxy,proxyip,proxyport);
- client->addPacketListener(this);
- }
-
- void XFireClient::Status(string s) {
- //da bei xfire statusmsg nur 100bytes länge unterstützt werden, wird gecutted
- if (!client->gotBudduyList)
- return;
-
- s = s.substr(0, 100);
-
- SendStatusMessagePacket *packet = new SendStatusMessagePacket();
-
- packet->awaymsg = ptrA( mir_utf8encode(s.c_str()));
- client->send( packet );
- delete packet;
- }
-
- void XFireClient::receivedPacket(XFirePacket *packet) {
- XFirePacketContent *content = packet->getContent();
-
- switch(content->getPacketId())
- {
- /*case XFIRE_RECVBUDDYCHANGEDNICK:
- {
- RecvBuddyChangedNick *changednick = (RecvBuddyChangedNick*)content;
- if (changednick) {
- handlingBuddys((BuddyListEntry*)changednick->entry,0,NULL);
- }
- break;
- }*/
- //Konfigpacket empfangen
- case XFIRE_RECVPREFSPACKET:
- {
- //Konfigarray leeren
- memset(&xfireconfig,0,sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS);
- RecvPrefsPacket *config = (RecvPrefsPacket*)content;
- //konfigs in array speichern
- if (config!=NULL)
- {
- //ins preferenes array sichern
- for(int i=0;i<XFIRE_RECVPREFSPACKET_MAXCONFIGS;i++)
- {
- xfireconfig[i]=config->config[i];
- }
- //datenbank einträge durchführen
- for(int i=0;i<XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS;i++)
- {
- char temp=1;
- if (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset==1)
- {
- temp=0;
- }
- db_set_b(NULL,protocolname,xfireconfigitems[i].dbentry,temp);
- }
- }
- break;
- }
- case XFIRE_FOUNDBUDDYS_ID:
- {
- PROTOSEARCHRESULT psr;
- ZeroMemory(&psr, sizeof(psr));
- psr.cbSize = sizeof(psr);
- psr.flags = PSR_TCHAR;
-
- XFireFoundBuddys *fb = (XFireFoundBuddys*)content;
- for(uint i = 0 ; i < fb->usernames->size() ; i++) {
- if ((char*)fb->usernames->at(i).c_str()!=NULL)
- psr.nick = _A2T((char*)fb->usernames->at(i).c_str());
- if ((char*)fb->fname->at(i).c_str()!=NULL)
- psr.firstName = _A2T((char*)fb->fname->at(i).c_str());
- if ((char*)fb->lname->at(i).c_str()!=NULL)
- psr.lastName = _A2T((char*)fb->lname->at(i).c_str());
- ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE) 1, (LPARAM) & psr);
- }
-
- ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
- break;
- }
- case XFIRE_BUDDYINFO:
- {
- BuddyInfoPacket *buddyinfo = (BuddyInfoPacket*)content;
- BuddyListEntry *entry = client->getBuddyList()->getBuddyById( buddyinfo->userid );
-
- //wenn die uid die gleiche wie die eigene ist, dann avatar auch selbst zuweisen
- if (buddyinfo->userid==this->myuid) {
- ProcessBuddyInfo(buddyinfo,NULL,"myxfireavatar");
- }
-
- if (entry)
- ProcessBuddyInfo(buddyinfo,entry->hcontact,(char*)entry->username.c_str());
-
- break;
- }
- case XFIRE_CLANINVITATION_ID:
- {
- ClanInvitationPacket *claninv = (ClanInvitationPacket*)content;
- for(int i=0;i<claninv->numberOfInv;i++)
- {
- char msg[XFIRE_MAX_STATIC_STRING_LEN];
- mir_snprintf(msg, SIZEOF(msg), Translate("%s (Nickname: %s) has invited you to join the %s clan. Message: %s%sPlease go to the XFire clan site to accept the Invitation."),claninv->invitefromusername[i].c_str(),
- claninv->invitefrom[i].c_str(),
- claninv->clanname[i].c_str(),
- claninv->invitemsg[i].c_str(),"\n");
- MSGBOX(msg);
- }
- break;
- }
- case XFIRE_GAMEINFO_ID:
- {
- GameInfoPacket *gameinfo = (GameInfoPacket*)content;
- for(uint i = 0 ; i < gameinfo->sids->size() ; i++) {
- BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( gameinfo->sids->at(i) );
- if (entry){
- entry->gameinfo = gameinfo->gameinfo->at(i);
- handlingBuddys(entry,0,NULL);
- }
- }
- break;
- }
- case XFIRE_RECVREMOVEBUDDYPACKET:
- {
- RecvRemoveBuddyPacket *remove = (RecvRemoveBuddyPacket*)content;
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) remove->handle, 1 );
- break;
- }
- case XFIRE_BUDDYS_NAMES_ID:
- {
- //status nachricht nach der buddylist senden
- client->gotBudduyList=TRUE;
- if (sendonrecieve)
- {
- if (myClient!=NULL)
- {
- if (myClient->client->connected)
- {
- //
- if (bpStatus == ID_STATUS_AWAY)
- myClient->Status(statusmessage[1]);
- else
- myClient->Status(statusmessage[0]);
- }
- }
- sendonrecieve=FALSE;
- }
- sendonrecieve=FALSE;
+ avatarloader = NULL;
+ }
+ if (lastInviteRequest != NULL) delete lastInviteRequest;
+}
-/* GetBuddyInfo buddyinfo;
+void XFireClient::run() {
+ client->connect(username, password, useproxy, proxyip, proxyport);
+ client->addPacketListener(this);
+}
- vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
- for(uint i = 0 ; i < entries->size() ; i ++) {
- BuddyListEntry *entry = entries->at(i);
- handlingBuddys(entry,0,NULL);
- }*/
- break;
- }
- /* case XFIRE_CLAN_BUDDYS_NAMES_ID:
- {
- vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntriesClan();
+void XFireClient::Status(string s) {
+ //da bei xfire statusmsg nur 100bytes länge unterstützt werden, wird gecutted
+ if (!client->gotBudduyList)
+ return;
- char temp[255];
- char * dummy;
- ClanBuddyListNamesPacket *clan = (ClanBuddyListNamesPacket*)content;
- mir_snprintf(temp, SIZEOF(temp), "Clan_%d", clan->clanid);
+ s = s.substr(0, 100);
- DBVARIANT dbv;
- if (!db_get(NULL,protocolname,temp,&dbv))
+ SendStatusMessagePacket *packet = new SendStatusMessagePacket();
+
+ packet->awaymsg = ptrA(mir_utf8encode(s.c_str()));
+ client->send(packet);
+ delete packet;
+}
+
+void XFireClient::receivedPacket(XFirePacket *packet) {
+ XFirePacketContent *content = packet->getContent();
+
+ switch (content->getPacketId())
+ {
+ /*case XFIRE_RECVBUDDYCHANGEDNICK:
+ {
+ RecvBuddyChangedNick *changednick = (RecvBuddyChangedNick*)content;
+ if (changednick) {
+ handlingBuddys((BuddyListEntry*)changednick->entry,0,NULL);
+ }
+ break;
+ }*/
+ //Konfigpacket empfangen
+ case XFIRE_RECVPREFSPACKET:
+ {
+ //Konfigarray leeren
+ memset(&xfireconfig, 0, sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS);
+ RecvPrefsPacket *config = (RecvPrefsPacket*)content;
+ //konfigs in array speichern
+ if (config != NULL)
+ {
+ //ins preferenes array sichern
+ for (int i = 0; i < XFIRE_RECVPREFSPACKET_MAXCONFIGS; i++)
+ {
+ xfireconfig[i] = config->config[i];
+ }
+ //datenbank einträge durchführen
+ for (int i = 0; i < XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS; i++)
+ {
+ char temp = 1;
+ if (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset == 1)
{
- dummy=dbv.pszVal;
+ temp = 0;
}
- else
- dummy=NULL;
+ db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, temp);
+ }
+ }
+ break;
+ }
+ case XFIRE_FOUNDBUDDYS_ID:
+ {
+ PROTOSEARCHRESULT psr;
+ ZeroMemory(&psr, sizeof(psr));
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+
+ XFireFoundBuddys *fb = (XFireFoundBuddys*)content;
+ for (uint i = 0; i < fb->usernames->size(); i++) {
+ if ((char*)fb->usernames->at(i).c_str() != NULL)
+ psr.nick = _A2T((char*)fb->usernames->at(i).c_str());
+ if ((char*)fb->fname->at(i).c_str() != NULL)
+ psr.firstName = _A2T((char*)fb->fname->at(i).c_str());
+ if ((char*)fb->lname->at(i).c_str() != NULL)
+ psr.lastName = _A2T((char*)fb->lname->at(i).c_str());
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
+ }
- for(uint i = 0 ; i < entries->size() ; i ++) {
- BuddyListEntry *entry = entries->at(i);
- if (entry->clanid==clan->clanid) {
- handlingBuddys(entry,clan->clanid,dummy);
- }
- }
- break;
- }*/
- case XFIRE_FRIENDS_BUDDYS_NAMES_ID:
- {
- for(uint i = 0 ; i < ((FriendsBuddyListNamesPacket*)content)->userids->size() ; i++) {
- BuddyListEntry *entry = client->getBuddyList()->getBuddyById( ((FriendsBuddyListNamesPacket*)content)->userids->at(i) );
- if (entry) {
- char fofname[128]=LPGEN("Friends of Friends Playing");
- DBVARIANT dbv;
- //gruppennamen überladen
- if (!db_get(NULL,protocolname,"overload_fofgroupname",&dbv))
- {
- strcpy_s(fofname,128,dbv.pszVal);
- db_free(&dbv);
- }
- CreateGroup(Translate(fofname),"fofgroup");
- MCONTACT hc=handlingBuddys(entry,-1,Translate(fofname));
- if (hc)
- {
- CheckAvatar(entry);
- db_set_b(hc,protocolname,"friendoffriend",1);
- }
- }
- }
- break;
- }
- /*case XFIRE_BUDDYS_ONLINE_ID:
- {
- for(uint i = 0 ; i < ((BuddyListOnlinePacket*)content)->userids->size() ; i++) {
- BuddyListEntry *entry = client->getBuddyList()->getBuddyById( ((BuddyListOnlinePacket*)content)->userids->at(i) );
- if (entry){
- handlingBuddys(entry,0,NULL);
- }
- }
- break;
- }*/
- /*case XFIRE_RECV_STATUSMESSAGE_PACKET_ID:
- {
- for(uint i=0;i<((RecvStatusMessagePacket*)content)->sids->size();i++)
- {
- BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((RecvStatusMessagePacket*)content)->sids->at(i) );
- if (entry) //crashbug entfernt
- setBuddyStatusMsg(entry); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das
- //das problem der fehlenden statusmsg
- //handlingBuddys(entry,0,NULL);
- }
- break;
- }*/
- case XFIRE_BUDDYS_GAMES_ID:
- {
- vector<char *> *sids=NULL; //dieses array dient zu zwischensicherung von unbekannten sids
- for(uint i=0;i<((BuddyListGamesPacket*)content)->sids->size();i++)
- {
- BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((BuddyListGamesPacket*)content)->sids->at(i) );
- if (entry!=NULL)
- {
- //wir haben einen unbekannten user
- if (entry->username.length()==0)
- {
- //sid array ist noch nicht init
- if (sids==NULL)
- {
- sids = new vector<char *>;
- }
- //kopie der sid anlegen
- char *sid = new char[16];
- memcpy(sid,((BuddyListGamesPacket*)content)->sids->at(i),16);
- //ab ins array damit
- sids->push_back(sid);
- }
- else
- {
- if (entry->game == 0 && entry->hcontact != 0 && db_get_b(entry->hcontact,protocolname,"friendoffriend",0)==1)
- db_set_w(entry->hcontact,protocolname,"Status",ID_STATUS_OFFLINE);
- else
- handlingBuddys(entry,0,NULL);
- }
- }
- }
- //sid anfragen nur senden, wenn das sids array init wurde
- if (sids)
- {
- SendSidPacket sp;
- sp.sids=sids;
- client->send( &sp );
- delete sids;
- }
- break;
- }
- case XFIRE_BUDDYS_GAMES2_ID:
- {
- for(uint i=0;i<((BuddyListGames2Packet*)content)->sids->size();i++)
- {
- BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((BuddyListGames2Packet*)content)->sids->at(i) );
- if (entry!=NULL) handlingBuddys(entry,0,NULL);
- }
- break;
- }
- case XFIRE_PACKET_INVITE_REQUEST_PACKET: //friend request
- {
- InviteRequestPacket *invite = (InviteRequestPacket*)content;
-
- //nur nich blockierte buddy's durchlassen
- if (!db_get_b(NULL,"XFireBlock",(char*)invite->name.c_str(),0))
- {
- XFireContact xfire_newc;
- xfire_newc.username=(char*)invite->name.c_str();
- xfire_newc.nick=(char*)invite->nick.c_str();
- xfire_newc.id=0;
-
- MCONTACT handle = CList_AddContact(xfire_newc,TRUE,TRUE,0);
- if (handle) { // invite nachricht mitsenden
- string str = (char*)invite->msg.c_str();
-
- PROTORECVEVENT pre;
- pre.flags = 0;
- pre.timestamp = time(NULL);
- pre.szMessage = (char*)mir_utf8decode((char*)str.c_str(),NULL);
- //invite nachricht konnte nicht zugewiesen werden?!?!?!
- if (!pre.szMessage)
- pre.szMessage=(char*)str.c_str();
- pre.lParam = 0;
- ProtoChainRecvMsg(handle, &pre);
- }
- }
- else
- {
- SendDenyInvitationPacket deny;
- deny.name = invite->name;
- client->send( &deny );
- }
- break;
- }
- case XFIRE_CLAN_PACKET:
- {
- char temp[100];
- XFireClanPacket *clan = (XFireClanPacket*)content;
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ break;
+ }
+ case XFIRE_BUDDYINFO:
+ {
+ BuddyInfoPacket *buddyinfo = (BuddyInfoPacket*)content;
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById(buddyinfo->userid);
- for(int i=0;i<clan->count;i++)
+ //wenn die uid die gleiche wie die eigene ist, dann avatar auch selbst zuweisen
+ if (buddyinfo->userid == this->myuid) {
+ ProcessBuddyInfo(buddyinfo, NULL, "myxfireavatar");
+ }
+
+ if (entry)
+ ProcessBuddyInfo(buddyinfo, entry->hcontact, (char*)entry->username.c_str());
+
+ break;
+ }
+ case XFIRE_CLANINVITATION_ID:
+ {
+ ClanInvitationPacket *claninv = (ClanInvitationPacket*)content;
+ for (int i = 0; i < claninv->numberOfInv; i++)
+ {
+ char msg[XFIRE_MAX_STATIC_STRING_LEN];
+ mir_snprintf(msg, SIZEOF(msg), Translate("%s (Nickname: %s) has invited you to join the %s clan. Message: %s%sPlease go to the XFire clan site to accept the Invitation."), claninv->invitefromusername[i].c_str(),
+ claninv->invitefrom[i].c_str(),
+ claninv->clanname[i].c_str(),
+ claninv->invitemsg[i].c_str(), "\n");
+ MSGBOX(msg);
+ }
+ break;
+ }
+ case XFIRE_GAMEINFO_ID:
+ {
+ GameInfoPacket *gameinfo = (GameInfoPacket*)content;
+ for (uint i = 0; i < gameinfo->sids->size(); i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid(gameinfo->sids->at(i));
+ if (entry){
+ entry->gameinfo = gameinfo->gameinfo->at(i);
+ handlingBuddys(entry, 0, NULL);
+ }
+ }
+ break;
+ }
+ case XFIRE_RECVREMOVEBUDDYPACKET:
+ {
+ RecvRemoveBuddyPacket *remove = (RecvRemoveBuddyPacket*)content;
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)remove->handle, 1);
+ break;
+ }
+ case XFIRE_BUDDYS_NAMES_ID:
+ {
+ //status nachricht nach der buddylist senden
+ client->gotBudduyList = TRUE;
+ if (sendonrecieve)
+ {
+ if (myClient != NULL)
{
- mir_snprintf(temp, SIZEOF(temp), "Clan_%d", clan->clanid[i]);
- db_set_s(NULL, protocolname, temp, (char*)clan->name[i].c_str());
+ if (myClient->client->connected)
+ {
+ //
+ if (bpStatus == ID_STATUS_AWAY)
+ myClient->Status(statusmessage[1]);
+ else
+ myClient->Status(statusmessage[0]);
+ }
+ }
+ sendonrecieve = FALSE;
+ }
+ sendonrecieve = FALSE;
- mir_snprintf(temp, SIZEOF(temp), "ClanUrl_%d", clan->clanid[i]);
- db_set_s(NULL, protocolname, temp, (char*)clan->url[i].c_str());
+ /* GetBuddyInfo buddyinfo;
- if (!db_get_b(NULL,protocolname,"noclangroups",0)) {
- CreateGroup((char*)clan->name[i].c_str(),"mainclangroup");
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ handlingBuddys(entry,0,NULL);
+ }*/
+ break;
+ }
+ /* case XFIRE_CLAN_BUDDYS_NAMES_ID:
+ {
+ vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntriesClan();
+
+ char temp[255];
+ char * dummy;
+ ClanBuddyListNamesPacket *clan = (ClanBuddyListNamesPacket*)content;
+ mir_snprintf(temp, SIZEOF(temp), "Clan_%d", clan->clanid);
+
+ DBVARIANT dbv;
+ if (!db_get(NULL,protocolname,temp,&dbv))
+ {
+ dummy=dbv.pszVal;
+ }
+ else
+ dummy=NULL;
+
+ for(uint i = 0 ; i < entries->size() ; i ++) {
+ BuddyListEntry *entry = entries->at(i);
+ if (entry->clanid==clan->clanid) {
+ handlingBuddys(entry,clan->clanid,dummy);
+ }
+ }
+ break;
+ }*/
+ case XFIRE_FRIENDS_BUDDYS_NAMES_ID:
+ {
+ for (uint i = 0; i < ((FriendsBuddyListNamesPacket*)content)->userids->size(); i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById(((FriendsBuddyListNamesPacket*)content)->userids->at(i));
+ if (entry) {
+ char fofname[128] = LPGEN("Friends of Friends Playing");
+ DBVARIANT dbv;
+ //gruppennamen überladen
+ if (!db_get(NULL, protocolname, "overload_fofgroupname", &dbv))
+ {
+ strcpy_s(fofname, 128, dbv.pszVal);
+ db_free(&dbv);
+ }
+ CreateGroup(Translate(fofname), "fofgroup");
+ MCONTACT hc = handlingBuddys(entry, -1, Translate(fofname));
+ if (hc)
+ {
+ CheckAvatar(entry);
+ db_set_b(hc, protocolname, "friendoffriend", 1);
}
}
- break;
}
- case XFIRE_LOGIN_FAILED_ID:
- MSGBOXE(Translate("Login failed."));
- SetStatus(ID_STATUS_OFFLINE,NULL);
- break;
- case XFIRE_LOGIN_SUCCESS_ID: //login war erfolgreich
+ break;
+ }
+ /*case XFIRE_BUDDYS_ONLINE_ID:
{
- LoginSuccessPacket *login = (LoginSuccessPacket*)content;
- char * temp = mir_utf8decode((char*)login->nick.c_str(),NULL);
- //nick speichern
- db_set_s(NULL,protocolname,"Nick",temp);
- //uid speichern
- db_set_dw(NULL,protocolname,"myuid",login->myuid);
- this->myuid=login->myuid;
- //avatar auslesen
- GetBuddyInfo* buddyinfo=new GetBuddyInfo();
- buddyinfo->userid=login->myuid;
- mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
- break;
+ for(uint i = 0 ; i < ((BuddyListOnlinePacket*)content)->userids->size() ; i++) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyById( ((BuddyListOnlinePacket*)content)->userids->at(i) );
+ if (entry){
+ handlingBuddys(entry,0,NULL);
}
-
- case XFIRE_RECV_OLDVERSION_PACKET_ID:
+ }
+ break;
+ }*/
+ /*case XFIRE_RECV_STATUSMESSAGE_PACKET_ID:
{
- RecvOldVersionPacket *version = (RecvOldVersionPacket*)content;
- char temp[255];
-
- if ((unsigned int)client->protocolVersion<(unsigned int)version->newversion)
+ for(uint i=0;i<((RecvStatusMessagePacket*)content)->sids->size();i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid( ((RecvStatusMessagePacket*)content)->sids->at(i) );
+ if (entry) //crashbug entfernt
+ setBuddyStatusMsg(entry); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das
+ //das problem der fehlenden statusmsg
+ //handlingBuddys(entry,0,NULL);
+ }
+ break;
+ }*/
+ case XFIRE_BUDDYS_GAMES_ID:
+ {
+ vector<char *> *sids = NULL; //dieses array dient zu zwischensicherung von unbekannten sids
+ for (uint i = 0; i < ((BuddyListGamesPacket*)content)->sids->size(); i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid(((BuddyListGamesPacket*)content)->sids->at(i));
+ if (entry != NULL)
{
- db_set_b(NULL,protocolname,"protover",version->newversion);
- //recprotoverchg
- if (db_get_w(NULL,protocolname,"recprotoverchg",0)==0)
+ //wir haben einen unbekannten user
+ if (entry->username.length() == 0)
{
- mir_snprintf(temp, SIZEOF(temp), Translate("The protocol version is too old. Changed current version from %d to %d. You can reconnect now."),client->protocolVersion,version->newversion);
- MSGBOXE(temp);
+ //sid array ist noch nicht init
+ if (sids == NULL)
+ {
+ sids = new vector < char * > ;
+ }
+ //kopie der sid anlegen
+ char *sid = new char[16];
+ memcpy(sid, ((BuddyListGamesPacket*)content)->sids->at(i), 16);
+ //ab ins array damit
+ sids->push_back(sid);
}
else
{
- SetStatus(ID_STATUS_RECONNECT,NULL);
- return;
+ if (entry->game == 0 && entry->hcontact != 0 && db_get_b(entry->hcontact, protocolname, "friendoffriend", 0) == 1)
+ db_set_w(entry->hcontact, protocolname, "Status", ID_STATUS_OFFLINE);
+ else
+ handlingBuddys(entry, 0, NULL);
}
}
- else
+ }
+ //sid anfragen nur senden, wenn das sids array init wurde
+ if (sids)
+ {
+ SendSidPacket sp;
+ sp.sids = sids;
+ client->send(&sp);
+ delete sids;
+ }
+ break;
+ }
+ case XFIRE_BUDDYS_GAMES2_ID:
+ {
+ for (uint i = 0; i < ((BuddyListGames2Packet*)content)->sids->size(); i++)
+ {
+ BuddyListEntry *entry = this->client->getBuddyList()->getBuddyBySid(((BuddyListGames2Packet*)content)->sids->at(i));
+ if (entry != NULL) handlingBuddys(entry, 0, NULL);
+ }
+ break;
+ }
+ case XFIRE_PACKET_INVITE_REQUEST_PACKET: //friend request
+ {
+ InviteRequestPacket *invite = (InviteRequestPacket*)content;
+
+ //nur nich blockierte buddy's durchlassen
+ if (!db_get_b(NULL, "XFireBlock", (char*)invite->name.c_str(), 0))
+ {
+ XFireContact xfire_newc;
+ xfire_newc.username = (char*)invite->name.c_str();
+ xfire_newc.nick = (char*)invite->nick.c_str();
+ xfire_newc.id = 0;
+
+ MCONTACT handle = CList_AddContact(xfire_newc, TRUE, TRUE, 0);
+ if (handle) { // invite nachricht mitsenden
+ string str = (char*)invite->msg.c_str();
+
+ PROTORECVEVENT pre;
+ pre.flags = 0;
+ pre.timestamp = time(NULL);
+ pre.szMessage = (char*)mir_utf8decode((char*)str.c_str(), NULL);
+ //invite nachricht konnte nicht zugewiesen werden?!?!?!
+ if (!pre.szMessage)
+ pre.szMessage = (char*)str.c_str();
+ pre.lParam = 0;
+ ProtoChainRecvMsg(handle, &pre);
+ }
+ }
+ else
+ {
+ SendDenyInvitationPacket deny;
+ deny.name = invite->name;
+ client->send(&deny);
+ }
+ break;
+ }
+ case XFIRE_CLAN_PACKET:
+ {
+ char temp[100];
+ XFireClanPacket *clan = (XFireClanPacket*)content;
+
+ for (int i = 0; i < clan->count; i++)
+ {
+ mir_snprintf(temp, SIZEOF(temp), "Clan_%d", clan->clanid[i]);
+ db_set_s(NULL, protocolname, temp, (char*)clan->name[i].c_str());
+
+ mir_snprintf(temp, SIZEOF(temp), "ClanUrl_%d", clan->clanid[i]);
+ db_set_s(NULL, protocolname, temp, (char*)clan->url[i].c_str());
+
+ if (!db_get_b(NULL, protocolname, "noclangroups", 0)) {
+ CreateGroup((char*)clan->name[i].c_str(), "mainclangroup");
+ }
+ }
+ break;
+ }
+ case XFIRE_LOGIN_FAILED_ID:
+ MSGBOXE(Translate("Login failed."));
+ SetStatus(ID_STATUS_OFFLINE, NULL);
+ break;
+ case XFIRE_LOGIN_SUCCESS_ID: //login war erfolgreich
+ {
+ LoginSuccessPacket *login = (LoginSuccessPacket*)content;
+ char * temp = mir_utf8decode((char*)login->nick.c_str(), NULL);
+ //nick speichern
+ db_set_s(NULL, protocolname, "Nick", temp);
+ //uid speichern
+ db_set_dw(NULL, protocolname, "myuid", login->myuid);
+ this->myuid = login->myuid;
+ //avatar auslesen
+ GetBuddyInfo* buddyinfo = new GetBuddyInfo();
+ buddyinfo->userid = login->myuid;
+ mir_forkthread(SetAvatar2, (LPVOID)buddyinfo);
+ break;
+ }
+
+ case XFIRE_RECV_OLDVERSION_PACKET_ID:
+ {
+ RecvOldVersionPacket *version = (RecvOldVersionPacket*)content;
+ char temp[255];
+
+ if ((unsigned int)client->protocolVersion < (unsigned int)version->newversion)
+ {
+ db_set_b(NULL, protocolname, "protover", version->newversion);
+ //recprotoverchg
+ if (db_get_w(NULL, protocolname, "recprotoverchg", 0) == 0)
{
- mir_snprintf(temp, SIZEOF(temp), Translate("The protocol version is too old. Cannot detect a new version number."));
+ mir_snprintf(temp, SIZEOF(temp), Translate("The protocol version is too old. Changed current version from %d to %d. You can reconnect now."), client->protocolVersion, version->newversion);
MSGBOXE(temp);
- SetStatus(ID_STATUS_OFFLINE,NULL);
}
- break;
+ else
+ {
+ SetStatus(ID_STATUS_RECONNECT, NULL);
+ return;
+ }
+ }
+ else
+ {
+ mir_snprintf(temp, SIZEOF(temp), Translate("The protocol version is too old. Cannot detect a new version number."));
+ MSGBOXE(temp);
+ SetStatus(ID_STATUS_OFFLINE, NULL);
}
+ break;
+ }
- case XFIRE_OTHER_LOGIN:
- MSGBOXE(Translate("Someone logged in with your account. Disconnect."));
- SetStatus(ID_STATUS_OFFLINE,NULL);
- break;
+ case XFIRE_OTHER_LOGIN:
+ MSGBOXE(Translate("Someone logged in with your account. Disconnect."));
+ SetStatus(ID_STATUS_OFFLINE, NULL);
+ break;
//ne nachricht für mich, juhu
- case XFIRE_MESSAGE_ID: {
- string str;
+ case XFIRE_MESSAGE_ID: {
+ string str;
- if ( (( MessagePacket*)content)->getMessageType() == 0){
- BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( ((MessagePacket*)content)->getSid() );
- if (entry!=NULL)
- {
- str=((MessagePacket*)content)->getMessage();
+ if (((MessagePacket*)content)->getMessageType() == 0){
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid(((MessagePacket*)content)->getSid());
+ if (entry != NULL)
+ {
+ str = ((MessagePacket*)content)->getMessage();
- PROTORECVEVENT pre = { 0 };
- pre.timestamp = time(NULL);
- pre.szMessage = (char*)str.c_str();
- pre.flags = PREF_UTF;
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = time(NULL);
+ pre.szMessage = (char*)str.c_str();
+ pre.flags = PREF_UTF;
- CallService(MS_PROTO_CONTACTISTYPING,(WPARAM)entry->hcontact,PROTOTYPE_CONTACTTYPING_OFF);
- ProtoChainRecvMsg(entry->hcontact, &pre);
- }
- }
- else if ( (( MessagePacket*)content)->getMessageType() == 3) {
- BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid( ((MessagePacket*)content)->getSid() );
- if (entry!=NULL)
- CallService(MS_PROTO_CONTACTISTYPING,(WPARAM)entry->hcontact,5);
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, PROTOTYPE_CONTACTTYPING_OFF);
+ ProtoChainRecvMsg(entry->hcontact, &pre);
}
-
- break;
}
+ else if (((MessagePacket*)content)->getMessageType() == 3) {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyBySid(((MessagePacket*)content)->getSid());
+ if (entry != NULL)
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, 5);
+ }
+
+ break;
+ }
- //refresh buddy's
- /* if (content->getPacketId()==XFIRE_RECV_STATUSMESSAGE_PACKET_ID||
- content->getPacketId()==XFIRE_BUDDYS_GAMES_ID||
- content->getPacketId()==XFIRE_BUDDYS_GAMES2_ID)
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)-1, (LPARAM)FU_TBREDRAW | FU_FMREDRAW);*/
- }
+ //refresh buddy's
+ /* if (content->getPacketId()==XFIRE_RECV_STATUSMESSAGE_PACKET_ID||
+ content->getPacketId()==XFIRE_BUDDYS_GAMES_ID||
+ content->getPacketId()==XFIRE_BUDDYS_GAMES2_ID)
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)-1, (LPARAM)FU_TBREDRAW | FU_FMREDRAW);*/
+ }
- //
- }
+ //
+}
//=====================================================
@@ -777,22 +777,22 @@ extern "C" __declspec(dllexport) int Unload(void) return 0;
}
-void __stdcall XFireLog( const char* fmt, ... )
+void __stdcall XFireLog(const char* fmt, ...)
{
va_list vararg;
- va_start( vararg, fmt );
- char* str = ( char* )alloca( 32000 );
- mir_vsnprintf( str, 32000, fmt, vararg );
- va_end( vararg );
+ va_start(vararg, fmt);
+ char* str = (char*)alloca(32000);
+ mir_vsnprintf(str, 32000, fmt, vararg);
+ va_end(vararg);
- CallService(MS_NETLIB_LOG, ( WPARAM )hNetlib, ( LPARAM )str );
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)str);
}
//=====================================================
// WINAPI DllMain
//=====================================================
-BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
hinstance = hinst;
//AtlAxWinInit();
@@ -805,61 +805,61 @@ void StartIniUpdateAndDetection(LPVOID dummy) EnterCriticalSection(&connectingMutex);
//ini/ico updater, nur wenn aktiv
- if (db_get_b(NULL,protocolname,"autoiniupdate",0))
+ if (db_get_b(NULL, protocolname, "autoiniupdate", 0))
UpdateMyXFireIni(NULL);
- if (db_get_b(NULL,protocolname,"autoicodllupdate",0))
+ if (db_get_b(NULL, protocolname, "autoicodllupdate", 0))
UpdateMyIcons(NULL);
#ifndef NO_PTHREAD
void* (*func)(void*) = &inigamedetectiont;
pthread_create( &gamedetection, NULL, func , NULL);
#else
- mir_forkthread(inigamedetectiont,NULL);
+ mir_forkthread(inigamedetectiont, NULL);
#endif
LeaveCriticalSection(&connectingMutex);
}
-INT_PTR UrlCall(WPARAM wparam,LPARAM lparam) {
+INT_PTR UrlCall(WPARAM wparam, LPARAM lparam) {
//lparam!=0?
if (lparam) {
//nach dem doppelpunkt suchen
- char*type=strchr((char*)lparam,':');
+ char*type = strchr((char*)lparam, ':');
//gefunden, dann anch fragezeichen suchen
if (type)
{
type++;
- char*q=strchr(type,'?');
+ char*q = strchr(type, '?');
//gefunden? dann urltype ausschneiden
if (q)
{
//abschneiden
- *q=0;
+ *q = 0;
//ein addfriend url request?
- if (strcmp("add_friend",type)==0)
+ if (strcmp("add_friend", type) == 0)
{
q++;
//nach = suchen
- char*g=strchr(q,'=');
+ char*g = strchr(q, '=');
//gefunden? dann abschneiden
if (g)
{
- *g=0;
+ *g = 0;
g++;
//user parameter?
- if (strcmp("user",q)==0)
+ if (strcmp("user", q) == 0)
{
//tempbuffer für die frage and en user
char temp[100];
- if (strlen(g)>25) //zugroße abschneiden
- *(g+25)=0;
+ if (strlen(g) > 25) //zugroße abschneiden
+ *(g + 25) = 0;
- mir_snprintf(temp, SIZEOF(temp), Translate("Do you really want to add %s to your friend list?"),g);
+ mir_snprintf(temp, SIZEOF(temp), Translate("Do you really want to add %s to your friend list?"), g);
//Nutzer vorher fragen, ob er wirklich user xyz adden möchte
if (MessageBoxA(NULL, temp, Translate(PLUGIN_TITLE), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
{
if (myClient->client->connected)
{
@@ -889,24 +889,24 @@ static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam) /*NETLIB***********************************/
NETLIBUSER nlu;
ZeroMemory(&nlu, sizeof(nlu));
- nlu.cbSize = sizeof(nlu);
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
- nlu.szSettingsModule = protocolname;
- nlu.szDescriptiveName = "XFire server connection";
- hNetlib = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM) & nlu);
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = protocolname;
+ nlu.szDescriptiveName = "XFire server connection";
+ hNetlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)& nlu);
/*NETLIB***********************************/
HookEvent(ME_USERINFO_INITIALISE, OnDetailsInit);
HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
//hook das queryplugin
- HookEvent("GameServerQuery/doneQuery" , doneQuery);
+ HookEvent("GameServerQuery/doneQuery", doneQuery);
CreateProtoServiceFunction(protocolname, PS_SETAWAYMSG, SetAwayMsg);
// Variables support
if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
- TOKENREGISTER tr = {0};
+ TOKENREGISTER tr = { 0 };
tr.cbSize = sizeof(TOKENREGISTER);
tr.memType = TR_MEM_MIRANDA;
tr.flags = TRF_FREEMEM | TRF_PARSEFUNC | TRF_FIELD;
@@ -914,61 +914,61 @@ static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam) tr.szTokenString = "xfiregame";
tr.parseFunction = Varxfiregame;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("Current Game");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "myxfiregame";
tr.parseFunction = Varmyxfiregame;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("My Current Game");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "xfireserverip";
tr.parseFunction = Varxfireserverip;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("ServerIP");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "myxfireserverip";
tr.parseFunction = Varmyxfireserverip;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("My Current ServerIP");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "xfirevoice";
tr.parseFunction = Varxfirevoice;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("Voice");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "myxfirevoice";
tr.parseFunction = Varmyxfirevoice;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("My Current Voice");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "xfirevoiceip";
tr.parseFunction = Varxfirevoiceip;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("Voice ServerIP");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
tr.szTokenString = "myxfirevoiceip";
tr.parseFunction = Varmyxfirevoiceip;
tr.szHelpText = LPGEN("XFire")"\t"LPGEN("My Voice ServerIP");
- CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM) &tr);
+ CallService(MS_VARS_REGISTERTOKEN, 0, (LPARAM)&tr);
}
//File Association Manager support
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
{
- AssocMgr_AddNewUrlType("xfire:",Translate("Xfire Link Protocol"),hinstance,IDI_TM,XFIRE_URLCALL,0);
+ AssocMgr_AddNewUrlType("xfire:", Translate("Xfire Link Protocol"), hinstance, IDI_TM, XFIRE_URLCALL, 0);
}
//sound einfügen
- SkinAddNewSoundEx("xfirebstartgame",protocolname,LPGEN("Buddy start a game"));
+ SkinAddNewSoundEx("xfirebstartgame", protocolname, LPGEN("Buddy start a game"));
//hook für mbot einfügen, nur wenn mbot option aktiv
- if (db_get_b(NULL,protocolname,"mbotsupport",0))
+ if (db_get_b(NULL, protocolname, "mbotsupport", 0))
HookEvent(XFIRE_INGAMESTATUSHOOK, mBotNotify);
//initialisiere teamspeak und co detection
voicechat.initVoicechat();
- mir_forkthread(StartIniUpdateAndDetection,NULL);
+ mir_forkthread(StartIniUpdateAndDetection, NULL);
return 0;
}
@@ -980,13 +980,13 @@ static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam) /*placebo funktionen*/
/*PROTO_INTERFACE* xfireProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
{
- Xfire_m8 m8=new Xfire_m8();
- return m8;
+Xfire_m8 m8=new Xfire_m8();
+return m8;
}
/*placebo funktionen*/
/*static int xfireProtoUninit( void* ppro )
{
- return 0;
+return 0;
}
*/
@@ -1011,10 +1011,10 @@ int ExtraImageApply1(WPARAM wparam, LPARAM lparam) int ExtraImageApply2(WPARAM wparam, LPARAM lparam)
{
- MCONTACT hContact=(MCONTACT)wparam;
+ MCONTACT hContact = (MCONTACT)wparam;
// TODO: maybe need to fix extra icons
char *szProto = GetContactProto(hContact);
- if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ) && db_get_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) {
+ if (szProto != NULL && !lstrcmpiA(szProto, protocolname) && db_get_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
int gameid = db_get_w(hContact, protocolname, "VoiceId", 0);
if (gameid != 0)
ExtraIcon_SetIcon(hExtraIcon2, hContact, xgamelist.iconmngr.getGameIconHandle(gameid));
@@ -1035,20 +1035,20 @@ extern "C" __declspec(dllexport) int Load(void) Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
//keine protoversion in der db, dann wohl der erste start von xfire
- if (db_get_b(NULL,protocolname,"protover",0)==0)
+ if (db_get_b(NULL, protocolname, "protover", 0) == 0)
{
- db_set_b(NULL,protocolname,"protover",0x84);
- db_set_w(NULL,protocolname,"avatarloadlatency",1000);
- db_set_b(NULL,protocolname,"gameico",0);
- db_set_b(NULL,protocolname,"voiceico",1);
- db_set_b(NULL,protocolname,"specialavatarload",1);
- db_set_b(NULL,protocolname,"xfiresitegameico",1);
- db_set_b(NULL,protocolname,"recprotoverchg",1);
+ db_set_b(NULL, protocolname, "protover", 0x84);
+ db_set_w(NULL, protocolname, "avatarloadlatency", 1000);
+ db_set_b(NULL, protocolname, "gameico", 0);
+ db_set_b(NULL, protocolname, "voiceico", 1);
+ db_set_b(NULL, protocolname, "specialavatarload", 1);
+ db_set_b(NULL, protocolname, "xfiresitegameico", 1);
+ db_set_b(NULL, protocolname, "recprotoverchg", 1);
if (MessageBox(NULL, TranslateT("It seems that is the first time you use this plugin. Do you want to automatically download the latest available xfire_games.ini and icons.dll?\r\nWithout the xfire_games.ini Xfire can't detect any games on your computer."), TranslateT(PLUGIN_TITLE), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
- db_set_b(NULL,protocolname,"autoiniupdate",1);
- db_set_b(NULL,protocolname,"autoicodllupdate",1);
+ db_set_b(NULL, protocolname, "autoiniupdate", 1);
+ db_set_b(NULL, protocolname, "autoicodllupdate", 1);
}
}
@@ -1056,22 +1056,22 @@ extern "C" __declspec(dllexport) int Load(void) XDEBUGS("-----------------------------------------------------\n");
//statusmessages setzen
- strcpy(statusmessage[0],"");
+ strcpy(statusmessage[0], "");
mir_snprintf(statusmessage[1], SIZEOF(statusmessage[1]), "(AFK) %s", Translate("Away from Keyboard"));
-
+
HookEvent(ME_OPT_INITIALISE, OptInit);
HookEvent(ME_SYSTEM_MODULESLOADED, OnSystemModulesLoaded);
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
pd.szName = protocolname;
pd.type = PROTOTYPE_PROTOCOL;
- CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
- hLogEvent=CreateHookableEvent("XFireProtocol/Log");
+ hLogEvent = CreateHookableEvent("XFireProtocol/Log");
CList_MakeAllOffline();
-
+
CreateProtoServiceFunction(protocolname, PS_GETCAPS, GetCaps);
CreateProtoServiceFunction(protocolname, PS_GETNAME, GetName);
CreateProtoServiceFunction(protocolname, PS_LOADICON, TMLoadIcon);
@@ -1088,28 +1088,28 @@ extern "C" __declspec(dllexport) int Load(void) hookgamestart = CreateHookableEvent(XFIRE_INGAMESTATUSHOOK);
CreateProtoServiceFunction(protocolname, PS_BASICSEARCH, BasicSearch);
- CreateProtoServiceFunction( protocolname, PSS_MESSAGE, SendMessage );
- CreateProtoServiceFunction( protocolname, PSS_USERISTYPING, UserIsTyping );
- CreateProtoServiceFunction( protocolname, PSR_MESSAGE, RecvMessage );
- CreateProtoServiceFunction( protocolname, XFIRE_URLCALL, UrlCall );
+ CreateProtoServiceFunction(protocolname, PSS_MESSAGE, SendMessage);
+ CreateProtoServiceFunction(protocolname, PSS_USERISTYPING, UserIsTyping);
+ CreateProtoServiceFunction(protocolname, PSR_MESSAGE, RecvMessage);
+ CreateProtoServiceFunction(protocolname, XFIRE_URLCALL, UrlCall);
///CreateProtoServiceFunction( protocolname, PSS_GETAWAYMSG, GetAwayMsg );
- CreateProtoServiceFunction( protocolname, XFIRE_SET_NICK, SetNickName );
- CreateProtoServiceFunction( protocolname, XFIRE_SEND_PREFS, SendPrefs );
+ CreateProtoServiceFunction(protocolname, XFIRE_SET_NICK, SetNickName);
+ CreateProtoServiceFunction(protocolname, XFIRE_SEND_PREFS, SendPrefs);
//für mtipper, damit man das statusico übertragen kann
- CreateProtoServiceFunction( protocolname, PS_GETCUSTOMSTATUSICON, GetXStatusIcon );
+ CreateProtoServiceFunction(protocolname, PS_GETCUSTOMSTATUSICON, GetXStatusIcon);
- char AvatarsFolder[MAX_PATH]= "";
+ char AvatarsFolder[MAX_PATH] = "";
char CurProfileF[MAX_PATH] = "";
char CurProfile[MAX_PATH] = "";
- CallService(MS_DB_GETPROFILEPATH, (WPARAM) MAX_PATH, (LPARAM)AvatarsFolder);
+ CallService(MS_DB_GETPROFILEPATH, (WPARAM)MAX_PATH, (LPARAM)AvatarsFolder);
strcat(AvatarsFolder, "\\");
- CallService(MS_DB_GETPROFILENAME, (WPARAM) MAX_PATH, (LPARAM)CurProfileF);
+ CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)CurProfileF);
int i;
for (i = MAX_PATH; 5; i--){
- if (CurProfileF[i] == 't' && CurProfileF[i-3] == '.'){
- i = i-3;
+ if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.'){
+ i = i - 3;
break;
}
}
@@ -1119,12 +1119,12 @@ extern "C" __declspec(dllexport) int Load(void) strcat(AvatarsFolder, "XFire");
XFireWorkingFolder = FoldersRegisterCustomPath(protocolname, "Working Folder", AvatarsFolder);
- if ( !(XFireIconFolder = FoldersRegisterCustomPath(protocolname, "Game Icon Folder", AvatarsFolder)))
+ if (!(XFireIconFolder = FoldersRegisterCustomPath(protocolname, "Game Icon Folder", AvatarsFolder)))
CreateDirectoryA(AvatarsFolder, NULL);
strcat(AvatarsFolder, "\\Avatars");
- if ( !(XFireAvatarFolder = FoldersRegisterCustomPath(protocolname, "Avatars", AvatarsFolder)))
- CreateDirectoryA(AvatarsFolder,NULL);
+ if (!(XFireAvatarFolder = FoldersRegisterCustomPath(protocolname, "Avatars", AvatarsFolder)))
+ CreateDirectoryA(AvatarsFolder, NULL);
//erweiterte Kontextmenüpunkte
CLISTMENUITEM mi = { sizeof(mi) };
@@ -1136,140 +1136,140 @@ extern "C" __declspec(dllexport) int Load(void) //gotoprofilemenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "GotoProfile");
- CreateServiceFunction(servicefunction,GotoProfile);
+ CreateServiceFunction(servicefunction, GotoProfile);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.pszContactOwner=protocolname;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
mi.ptszName = LPGENT("&XFire Online Profile");
Menu_AddContactMenuItem(&mi);
//gotoxfireclansitemenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "GotoXFireClanSite");
- CreateServiceFunction(servicefunction,GotoXFireClanSite);
+ CreateServiceFunction(servicefunction, GotoXFireClanSite);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.pszContactOwner=protocolname;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
mi.ptszName = LPGENT("XFire &Clan Site");
- gotoclansite=Menu_AddContactMenuItem(&mi);
+ gotoclansite = Menu_AddContactMenuItem(&mi);
//kopiermenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "GetIPPort");
- CreateServiceFunction(servicefunction,GetIPPort);
+ CreateServiceFunction(servicefunction, GetIPPort);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("C&opy Server Address and Port");
- copyipport=Menu_AddContactMenuItem(&mi);
+ copyipport = Menu_AddContactMenuItem(&mi);
//kopiermenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "VoiceIPPort");
- CreateServiceFunction(servicefunction,GetVIPPort);
+ CreateServiceFunction(servicefunction, GetVIPPort);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Cop&y Voice Server Address and Port");
- vipport=Menu_AddContactMenuItem(&mi);
+ vipport = Menu_AddContactMenuItem(&mi);
//joinmenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "JoinGame");
- CreateServiceFunction(servicefunction,JoinGame);
+ CreateServiceFunction(servicefunction, JoinGame);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Join &Game...");
- joingame=Menu_AddContactMenuItem(&mi);
+ joingame = Menu_AddContactMenuItem(&mi);
//joinmenüpunkt
strcpy(servicefunction, protocolname);
strcat(servicefunction, "StartThisGame");
- CreateServiceFunction(servicefunction,StartThisGame);
+ CreateServiceFunction(servicefunction, StartThisGame);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Play this game...");
- startthisgame=Menu_AddContactMenuItem(&mi);
+ startthisgame = Menu_AddContactMenuItem(&mi);
//remove friend
strcpy(servicefunction, protocolname);
strcat(servicefunction, "RemoveFriend");
- CreateServiceFunction(servicefunction,RemoveFriend);
+ CreateServiceFunction(servicefunction, RemoveFriend);
mi.pszService = servicefunction;
mi.position = 2000070000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Remove F&riend...");
- removefriend=Menu_AddContactMenuItem(&mi);
+ removefriend = Menu_AddContactMenuItem(&mi);
//block user
strcpy(servicefunction, protocolname);
strcat(servicefunction, "BlockFriend");
- CreateServiceFunction(servicefunction,BlockFriend);
+ CreateServiceFunction(servicefunction, BlockFriend);
mi.pszService = servicefunction;
mi.position = 2000070000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Block U&ser...");
- blockfriend=Menu_AddContactMenuItem(&mi);
+ blockfriend = Menu_AddContactMenuItem(&mi);
//my fire profile
strcpy(servicefunction, protocolname);
strcat(servicefunction, "GotoProfile2");
- CreateServiceFunction(servicefunction,GotoProfile2);
+ CreateServiceFunction(servicefunction, GotoProfile2);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("&My XFire Online Profile");
Menu_AddMainMenuItem(&mi);
//my activity protocol
strcpy(servicefunction, protocolname);
strcat(servicefunction, "GotoProfileAct");
- CreateServiceFunction(servicefunction,GotoProfileAct);
+ CreateServiceFunction(servicefunction, GotoProfileAct);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("&Activity Report");
Menu_AddMainMenuItem(&mi);
//rescan my games
strcpy(servicefunction, protocolname);
strcat(servicefunction, "ReScanMyGames");
- CreateServiceFunction(servicefunction,ReScanMyGames);
+ CreateServiceFunction(servicefunction, ReScanMyGames);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("&Rescan my games...");
Menu_AddMainMenuItem(&mi);
strcpy(servicefunction, protocolname);
strcat(servicefunction, "SetNick");
- CreateServiceFunction(servicefunction,SetNickDlg);
+ CreateServiceFunction(servicefunction, SetNickDlg);
mi.pszService = servicefunction;
mi.position = 500090000;
- mi.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(ID_OP));
- mi.pszContactOwner=protocolname;
+ mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(ID_OP));
+ mi.pszContactOwner = protocolname;
mi.ptszName = LPGENT("Set &Nickname");
Menu_AddMainMenuItem(&mi);
- HookEvent( ME_CLIST_PREBUILDCONTACTMENU, RebuildContactMenu );
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, RebuildContactMenu);
- if (db_get_b(NULL,protocolname,"ipportdetec",0))
+ if (db_get_b(NULL, protocolname, "ipportdetec", 0))
{
//MessageBoxA(0,"GetExtendedUdpTable not found. ServerIP/Port detection feature will be disabled.",PLUGIN_TITLE,MB_OK|MB_ICONINFORMATION);
- db_set_b(NULL,protocolname,"ipportdetec",0);
+ db_set_b(NULL, protocolname, "ipportdetec", 0);
XFireLog("Wasn't able to get GetExtendedUdpTable function");
}
@@ -1284,13 +1284,13 @@ extern "C" __declspec(dllexport) int Load(void) INT_PTR GetXStatusIcon(WPARAM wParam, LPARAM lParam) {
if (lParam == LR_SHARED)
{
- if (wParam>1)
- return (int)xgamelist.iconmngr.getGameIconFromId(wParam-2); //icocache[(int)wParam-2].hicon;
+ if (wParam > 1)
+ return (int)xgamelist.iconmngr.getGameIconFromId(wParam - 2); //icocache[(int)wParam-2].hicon;
}
else
{
- if (wParam>1)
- return (int)CopyIcon((HICON)xgamelist.iconmngr.getGameIconFromId(wParam-2)/*icocache[(int)wParam-2].hicon*/);
+ if (wParam > 1)
+ return (int)CopyIcon((HICON)xgamelist.iconmngr.getGameIconFromId(wParam - 2)/*icocache[(int)wParam-2].hicon*/);
}
return 0;
@@ -1298,63 +1298,63 @@ INT_PTR GetXStatusIcon(WPARAM wParam, LPARAM lParam) { INT_PTR RecvMessage(WPARAM wParam, LPARAM lParam)
{
- CCSDATA *ccs = ( CCSDATA* )lParam;
- db_unset(ccs->hContact, "CList", "Hidden");
+ CCSDATA *ccs = (CCSDATA*)lParam;
+ db_unset(ccs->hContact, "CList", "Hidden");
char *szProto = GetContactProto(ccs->hContact);
- if ( szProto != NULL && !lstrcmpiA( szProto, protocolname ))
- return CallService(MS_PROTO_RECVMSG, wParam, lParam );
+ if (szProto != NULL && !lstrcmpiA(szProto, protocolname))
+ return CallService(MS_PROTO_RECVMSG, wParam, lParam);
return 1;
}
-static void SetMeAFK( LPVOID param )
+static void SetMeAFK(LPVOID param)
{
- if (bpStatus==ID_STATUS_ONLINE)
+ if (bpStatus == ID_STATUS_ONLINE)
{
- SetStatus(ID_STATUS_AWAY,(LPARAM)param);
+ SetStatus(ID_STATUS_AWAY, (LPARAM)param);
}
}
-static void SetStatusLate( LPVOID param )
+static void SetStatusLate(LPVOID param)
{
Sleep(1000);
- if (bpStatus==ID_STATUS_OFFLINE)
+ if (bpStatus == ID_STATUS_OFFLINE)
{
- SetStatus((WPARAM)param,0);
+ SetStatus((WPARAM)param, 0);
}
}
-static void SendAck( LPVOID param )
+static void SendAck(LPVOID param)
{
- ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+ ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
-static void SendBadAck( LPVOID param )
+static void SendBadAck(LPVOID param)
{
- ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE) 0, LPARAM(Translate("XFire does not support offline messaging!")));
+ ProtoBroadcastAck(protocolname, (MCONTACT)param, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)0, LPARAM(Translate("XFire does not support offline messaging!")));
}
static INT_PTR UserIsTyping(WPARAM hContact, LPARAM lParam)
{
DBVARIANT dbv;
- if (lParam==PROTOTYPE_SELFTYPING_ON)
+ if (lParam == PROTOTYPE_SELFTYPING_ON)
{
- if (db_get_b(NULL,protocolname,"sendtyping",1)==1)
+ if (db_get_b(NULL, protocolname, "sendtyping", 1) == 1)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
- if (!db_get_s(hContact, protocolname, "Username",&dbv))
+ if (!db_get_s(hContact, protocolname, "Username", &dbv))
{
- SendTypingPacket typing;
- typing.init(myClient->client, dbv.pszVal);
- myClient->client->send( &typing );
- db_free(&dbv);
+ SendTypingPacket typing;
+ typing.init(myClient->client, dbv.pszVal);
+ myClient->client->send(&typing);
+ db_free(&dbv);
}
}
}
- else if (lParam==PROTOTYPE_SELFTYPING_OFF)
+ else if (lParam == PROTOTYPE_SELFTYPING_OFF)
{
}
@@ -1363,23 +1363,23 @@ static INT_PTR UserIsTyping(WPARAM hContact, LPARAM lParam) INT_PTR SendMessage(WPARAM wParam, LPARAM lParam)
{
- CCSDATA *ccs = (CCSDATA *) lParam;
+ CCSDATA *ccs = (CCSDATA *)lParam;
PROTORECVEVENT* pre = (PROTORECVEVENT*)ccs->lParam;
DBVARIANT dbv;
- int sended=0;
+ int sended = 0;
- db_get_s(ccs->hContact, protocolname, "Username",&dbv);
- if (myClient!=NULL)
- if (myClient->client->connected&&db_get_w(ccs->hContact, protocolname, "Status", -1)!=ID_STATUS_OFFLINE)
+ db_get_s(ccs->hContact, protocolname, "Username", &dbv);
+ if (myClient != NULL)
+ if (myClient->client->connected&&db_get_w(ccs->hContact, protocolname, "Status", -1) != ID_STATUS_OFFLINE)
{
- myClient->sendmsg(dbv.pszVal, ptrA( mir_utf8encode((char*)ccs->lParam)));
- mir_forkthread(SendAck, (void*)ccs->hContact);
- sended=1;
+ myClient->sendmsg(dbv.pszVal, ptrA(mir_utf8encode((char*)ccs->lParam)));
+ mir_forkthread(SendAck, (void*)ccs->hContact);
+ sended = 1;
}
else mir_forkthread(SendBadAck, (void*)ccs->hContact);
- db_free(&dbv);
- return sended;
+ db_free(&dbv);
+ return sended;
}
//=======================================================
@@ -1388,19 +1388,19 @@ INT_PTR SendMessage(WPARAM wParam, LPARAM lParam) INT_PTR GetCaps(WPARAM wParam, LPARAM lParam)
{
- if (wParam==PFLAGNUM_1)
- return PF1_BASICSEARCH|PF1_MODEMSG|PF1_IM/*|PF1_SERVERCLIST*/;
- else if (wParam==PFLAGNUM_2)
- return PF2_ONLINE|PF2_SHORTAWAY; // add the possible statuses here.
- else if (wParam==PFLAGNUM_3)
- return PF2_ONLINE|(db_get_b(NULL,protocolname,"nocustomaway",0)==1?0:PF2_SHORTAWAY);
- else if (wParam==PFLAGNUM_4)
- return PF4_SUPPORTTYPING|PF4_AVATARS;
- else if (wParam==PFLAG_UNIQUEIDTEXT)
+ if (wParam == PFLAGNUM_1)
+ return PF1_BASICSEARCH | PF1_MODEMSG | PF1_IM/*|PF1_SERVERCLIST*/;
+ else if (wParam == PFLAGNUM_2)
+ return PF2_ONLINE | PF2_SHORTAWAY; // add the possible statuses here.
+ else if (wParam == PFLAGNUM_3)
+ return PF2_ONLINE | (db_get_b(NULL, protocolname, "nocustomaway", 0) == 1 ? 0 : PF2_SHORTAWAY);
+ else if (wParam == PFLAGNUM_4)
+ return PF4_SUPPORTTYPING | PF4_AVATARS;
+ else if (wParam == PFLAG_UNIQUEIDTEXT)
return (INT_PTR)Translate("Username");
- else if (wParam==PFLAG_UNIQUEIDSETTING)
+ else if (wParam == PFLAG_UNIQUEIDSETTING)
return (INT_PTR)"Username";
- else if (wParam==PFLAG_MAXLENOFMESSAGE)
+ else if (wParam == PFLAG_MAXLENOFMESSAGE)
return 3996; //255;
return 0;
}
@@ -1410,7 +1410,7 @@ INT_PTR GetCaps(WPARAM wParam, LPARAM lParam) //=======================================================
INT_PTR GetName(WPARAM wParam, LPARAM lParam)
{
- lstrcpynA((char*)lParam,"XFire",wParam);
+ lstrcpynA((char*)lParam, "XFire", wParam);
return 0;
}
@@ -1419,10 +1419,10 @@ INT_PTR GetName(WPARAM wParam, LPARAM lParam) //=======================================================
INT_PTR TMLoadIcon(WPARAM wParam, LPARAM lParam)
{
- if (LOWORD( wParam ) == PLI_PROTOCOL) {
+ if (LOWORD(wParam) == PLI_PROTOCOL) {
if (wParam & PLIF_ICOLIB)
return (int)Skin_GetIcon("XFIRE_main");
- return (int)CopyIcon( Skin_GetIcon("XFIRE_main"));
+ return (int)CopyIcon(Skin_GetIcon("XFIRE_main"));
}
return NULL;
}
@@ -1430,11 +1430,11 @@ INT_PTR TMLoadIcon(WPARAM wParam, LPARAM lParam) static void ConnectingThread(LPVOID params)
{
- WPARAM wParam=(WPARAM)params;
+ WPARAM wParam = (WPARAM)params;
EnterCriticalSection(&connectingMutex);
- if (myClient!=NULL&&myClient->client!=NULL)
+ if (myClient != NULL&&myClient->client != NULL)
myClient->run();
else
{
@@ -1444,19 +1444,19 @@ static void ConnectingThread(LPVOID params) if (myClient->client->connected)
{
- sendonrecieve=TRUE;
+ sendonrecieve = TRUE;
}
else
{
- if (db_get_w(NULL,protocolname,"noconnectfailedbox",0)==0) MSGBOXE(Translate("Unable to connect to XFire."));
- wParam =ID_STATUS_OFFLINE;
+ if (db_get_w(NULL, protocolname, "noconnectfailedbox", 0) == 0) MSGBOXE(Translate("Unable to connect to XFire."));
+ wParam = ID_STATUS_OFFLINE;
}
int oldStatus;
oldStatus = bpStatus;
bpStatus = wParam;
- ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam);
LeaveCriticalSection(&connectingMutex);
}
@@ -1470,18 +1470,18 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) oldStatus = bpStatus;
- if (bpStatus==ID_STATUS_CONNECTING)
+ if (bpStatus == ID_STATUS_CONNECTING)
return 0;
- if (wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE&&wParam!=ID_STATUS_AWAY&&wParam!=ID_STATUS_RECONNECT)
- if (db_get_b(NULL,protocolname,"oninsteadafk",0)==0)
- wParam=ID_STATUS_AWAY; //protokoll auf away schalten
+ if (wParam != ID_STATUS_ONLINE&&wParam != ID_STATUS_OFFLINE&&wParam != ID_STATUS_AWAY&&wParam != ID_STATUS_RECONNECT)
+ if (db_get_b(NULL, protocolname, "oninsteadafk", 0) == 0)
+ wParam = ID_STATUS_AWAY; //protokoll auf away schalten
else
- wParam=ID_STATUS_ONLINE; //protokoll auf online schalten
+ wParam = ID_STATUS_ONLINE; //protokoll auf online schalten
if (
- (wParam == ID_STATUS_ONLINE && bpStatus!=ID_STATUS_ONLINE) || // offline --> online
- (wParam == ID_STATUS_AWAY && bpStatus==ID_STATUS_OFFLINE) // offline --> away
+ (wParam == ID_STATUS_ONLINE && bpStatus != ID_STATUS_ONLINE) || // offline --> online
+ (wParam == ID_STATUS_AWAY && bpStatus == ID_STATUS_OFFLINE) // offline --> away
)
{
if (bpStatus == ID_STATUS_AWAY) // away --> online
@@ -1494,34 +1494,34 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
DBVARIANT dbv2;
- if (db_get(NULL,protocolname,"login",&dbv))
+ if (db_get(NULL, protocolname, "login", &dbv))
{
MSGBOXE(Translate("No Login name is set!"));
- wParam=ID_STATUS_OFFLINE;
+ wParam = ID_STATUS_OFFLINE;
}
- else if (db_get(NULL,protocolname,"password",&dbv2))
+ else if (db_get(NULL, protocolname, "password", &dbv2))
{
MSGBOXE(Translate("No Password is set!"));
- wParam=ID_STATUS_OFFLINE;
+ wParam = ID_STATUS_OFFLINE;
}
else
{
- if (myClient!=NULL)
+ if (myClient != NULL)
delete myClient;
- myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,db_get_b(NULL,protocolname,"protover",0));
+ myClient = new XFireClient(dbv.pszVal, dbv2.pszVal, db_get_b(NULL, protocolname, "protover", 0));
//verbindung als thread
bpStatus = ID_STATUS_CONNECTING;
- ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,ID_STATUS_CONNECTING);
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, ID_STATUS_CONNECTING);
- mir_forkthread(ConnectingThread,(LPVOID)wParam);
+ mir_forkthread(ConnectingThread, (LPVOID)wParam);
//für die vars
- db_unset(NULL,protocolname,"currentgamename");
- db_unset(NULL,protocolname,"currentvoicename");
- db_unset(NULL,protocolname,"VServerIP");
- db_unset(NULL,protocolname,"ServerIP");
+ db_unset(NULL, protocolname, "currentgamename");
+ db_unset(NULL, protocolname, "currentvoicename");
+ db_unset(NULL, protocolname, "VServerIP");
+ db_unset(NULL, protocolname, "ServerIP");
db_free(&dbv);
db_free(&dbv2);
@@ -1529,41 +1529,41 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) }
}
}
- else if (wParam == ID_STATUS_AWAY && bpStatus!=ID_STATUS_AWAY)
+ else if (wParam == ID_STATUS_AWAY && bpStatus != ID_STATUS_AWAY)
{
if (bpStatus == ID_STATUS_OFFLINE) // nix
{
}
- else if (myClient!=NULL&&myClient->client->connected) // online --> afk
+ else if (myClient != NULL&&myClient->client->connected) // online --> afk
{
//setze bei aktivem nocustomaway die alte awaystatusmsg zurück, bugfix
- if (db_get_b(NULL,protocolname,"nocustomaway",0))
+ if (db_get_b(NULL, protocolname, "nocustomaway", 0))
mir_snprintf(statusmessage[1], SIZEOF(statusmessage[1]), "(AFK) %s", Translate("Away from Keyboard"));
myClient->Status(statusmessage[1]);
}
}
- else if ((wParam == ID_STATUS_OFFLINE || wParam == ID_STATUS_RECONNECT) && bpStatus!=ID_STATUS_OFFLINE) // * --> offline
+ else if ((wParam == ID_STATUS_OFFLINE || wParam == ID_STATUS_RECONNECT) && bpStatus != ID_STATUS_OFFLINE) // * --> offline
{
SetEvent(hConnectionClose);
// the status has been changed to offline (maybe run some more code)
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
myClient->client->disconnect();
CList_MakeAllOffline();
//teamspeak/ventrilo pid sowie gamepid auf NULL setzen, damit bei einem reconnect die neuerkannt werden
- pid=NULL;
- ts2pid=NULL;
- db_set_w(NULL,protocolname,"currentgame",0);
- db_set_w(NULL,protocolname,"currentvoice",0);
- db_unset(NULL,protocolname, "VServerIP");
- db_unset(NULL,protocolname, "ServerIP");
+ pid = NULL;
+ ts2pid = NULL;
+ db_set_w(NULL, protocolname, "currentgame", 0);
+ db_set_w(NULL, protocolname, "currentvoice", 0);
+ db_unset(NULL, protocolname, "VServerIP");
+ db_unset(NULL, protocolname, "ServerIP");
if (wParam == ID_STATUS_RECONNECT)
{
- mir_forkthread(SetStatusLate,(LPVOID)oldStatus);
+ mir_forkthread(SetStatusLate, (LPVOID)oldStatus);
wParam = ID_STATUS_OFFLINE;
}
}
@@ -1573,7 +1573,7 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) }
//broadcast the message
bpStatus = wParam;
- ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam);
return 0;
@@ -1594,7 +1594,7 @@ INT_PTR GetStatus(WPARAM wParam, LPARAM lParam) return ID_STATUS_OFFLINE;
}
-MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan)
+MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline, int clan)
{
MCONTACT hContact;
@@ -1602,19 +1602,20 @@ MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan return 0;
// here we create a new one since no one is to be found
- hContact = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
- if ( hContact ) {
+ hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (hContact) {
CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)protocolname);
- if ( InList )
+ if (InList)
db_unset(hContact, "CList", "NotOnList");
else
db_set_b(hContact, "CList", "NotOnList", 1);
db_unset(hContact, "CList", "Hidden");
- if (strlen(xfc.nick)>0) {
+ if (strlen(xfc.nick) > 0) {
db_set_utf(hContact, protocolname, "Nick", xfc.nick);
- } else if (strlen(xfc.username)>0) {
+ }
+ else if (strlen(xfc.username) > 0) {
db_set_s(hContact, protocolname, "Nick", xfc.username);
}
@@ -1623,20 +1624,20 @@ MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan //db_set_s(hContact, protocolname, "Screenname", xfc.nick);
db_set_dw(hContact, protocolname, "UserId", xfc.id);
- if (clan>0)
+ if (clan > 0)
db_set_dw(hContact, protocolname, "Clan", clan);
- db_set_w(hContact, protocolname, "Status", SetOnline ? ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ db_set_w(hContact, protocolname, "Status", SetOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
- if (db_get_b(NULL,protocolname,"noavatars",-1)==0)
+ if (db_get_b(NULL, protocolname, "noavatars", -1) == 0)
{
- if (!db_get_b(NULL,protocolname,"specialavatarload",0))
+ if (!db_get_b(NULL, protocolname, "specialavatarload", 0))
{
- XFire_SetAvatar* xsa=new XFire_SetAvatar;
- xsa->hContact=hContact;
- xsa->username=new char[strlen(xfc.username)+1];
- strcpy(xsa->username,xfc.username);
- mir_forkthread(SetAvatar,(LPVOID)xsa);
+ XFire_SetAvatar* xsa = new XFire_SetAvatar;
+ xsa->hContact = hContact;
+ xsa->username = new char[strlen(xfc.username) + 1];
+ strcpy(xsa->username, xfc.username);
+ mir_forkthread(SetAvatar, (LPVOID)xsa);
}
else
{
@@ -1645,18 +1646,18 @@ MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline,int clan getestet mit clanbuddy's >270 members
mit hilfe der buddyinfos kann man den avatar laden und screenshot infos etc bekommt man auch
- */
- GetBuddyInfo* buddyinfo=new GetBuddyInfo();
- buddyinfo->userid=xfc.id;
- mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
+ */
+ GetBuddyInfo* buddyinfo = new GetBuddyInfo();
+ buddyinfo->userid = xfc.id;
+ mir_forkthread(SetAvatar2, (LPVOID)buddyinfo);
}
}
- if (xfc.id==0) {
- db_set_b( hContact, "CList", "NotOnList", 1 );
- db_set_b( hContact, "CList", "Hidden", 1 );
+ if (xfc.id == 0) {
+ db_set_b(hContact, "CList", "NotOnList", 1);
+ db_set_b(hContact, "CList", "Hidden", 1);
}
return hContact;
@@ -1673,10 +1674,10 @@ BOOL IsXFireContact(MCONTACT hContact) return FALSE;
}
-MCONTACT CList_FindContact (int uid)
+MCONTACT CList_FindContact(int uid)
{
for (MCONTACT hContact = db_find_first(protocolname); hContact; hContact = db_find_next(hContact, protocolname))
- if ( db_get_dw(hContact, protocolname, "UserId", -1) == uid)
+ if (db_get_dw(hContact, protocolname, "UserId", -1) == uid)
return hContact;
return 0;
@@ -1688,7 +1689,7 @@ void CList_MakeAllOffline() for (MCONTACT hContact = db_find_first(protocolname); hContact; hContact = db_find_next(hContact, protocolname)) {
//freunde von freunden in eine seperate liste setzen
//nur wenn das nicht abgestellt wurde
- if (db_get_b(hContact,protocolname,"friendoffriend",0)==1 && db_get_b(NULL,protocolname,"fofdbremove",0)==1)
+ if (db_get_b(hContact, protocolname, "friendoffriend", 0) == 1 && db_get_b(NULL, protocolname, "fofdbremove", 0) == 1)
fhandles.push_back(hContact);
db_unset(hContact, "CList", "StatusMsg");
@@ -1704,7 +1705,7 @@ void CList_MakeAllOffline() db_unset(hContact, protocolname, "XStatusId");
db_unset(hContact, protocolname, "XStatusName");
- if (db_get_b(NULL,protocolname,"noavatars",-1)==1)
+ if (db_get_b(NULL, protocolname, "noavatars", -1) == 1)
{
db_unset(hContact, "ContactPhoto", "File");
db_unset(hContact, "ContactPhoto", "RFile");
@@ -1718,10 +1719,10 @@ void CList_MakeAllOffline() {
//prüf ob der avatar noch existiert
DBVARIANT dbv;
- if (!db_get_s(hContact, "ContactPhoto", "File",&dbv))
+ if (!db_get_s(hContact, "ContactPhoto", "File", &dbv))
{
- FILE*f=fopen(dbv.pszVal,"r");
- if (f==NULL)
+ FILE*f = fopen(dbv.pszVal, "r");
+ if (f == NULL)
{
db_unset(hContact, "ContactPhoto", "File");
db_unset(hContact, "ContactPhoto", "RFile");
@@ -1736,33 +1737,33 @@ void CList_MakeAllOffline() db_free(&dbv);
}
}
- db_set_w(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
+ db_set_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE);
}
//alle gefundenen handles lsöchen
- for(uint i=0; i < fhandles.size(); i++)
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) fhandles.at(i), 0);
+ for (uint i = 0; i < fhandles.size(); i++)
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)fhandles.at(i), 0);
}
void SetAvatar2(LPVOID lparam) {
- static int lasttime=0;
- int sleep=db_get_w(NULL,protocolname,"avatarloadlatency",1000);
- lasttime+=sleep;
+ static int lasttime = 0;
+ int sleep = db_get_w(NULL, protocolname, "avatarloadlatency", 1000);
+ lasttime += sleep;
- if (mySleep(lasttime,hConnectionClose))
+ if (mySleep(lasttime, hConnectionClose))
{
delete lparam;
- lasttime-=sleep;
+ lasttime -= sleep;
return;
}
- GetBuddyInfo* buddyinfo=(GetBuddyInfo*)lparam;
- if (myClient!=NULL)
+ GetBuddyInfo* buddyinfo = (GetBuddyInfo*)lparam;
+ if (myClient != NULL)
if (myClient->client->connected)
- myClient->client->send( buddyinfo );
+ myClient->client->send(buddyinfo);
delete lparam;
- lasttime-=sleep;
+ lasttime -= sleep;
}
void SetAvatar(LPVOID lparam)
@@ -1770,77 +1771,77 @@ void SetAvatar(LPVOID lparam) {
//EnterCriticalSection(&avatarMutex);
//WaitForSingleObject(hMutex, INFINITE);
- static int lasttime=0;
- int sleep=db_get_w(NULL,protocolname,"avatarloadlatency",250);
+ static int lasttime = 0;
+ int sleep = db_get_w(NULL, protocolname, "avatarloadlatency", 250);
- if (bpStatus==ID_STATUS_OFFLINE)
+ if (bpStatus == ID_STATUS_OFFLINE)
return;
- lasttime+=sleep;
+ lasttime += sleep;
//Sleep(lasttime);
- if (mySleep(lasttime,hConnectionClose))
+ if (mySleep(lasttime, hConnectionClose))
{
delete lparam;
- lasttime-=sleep;
+ lasttime -= sleep;
return;
}
- if (bpStatus==ID_STATUS_OFFLINE)
+ if (bpStatus == ID_STATUS_OFFLINE)
return;
XFireAvatar av;
- XFire_SetAvatar* xsa=(XFire_SetAvatar*)lparam;
+ XFire_SetAvatar* xsa = (XFire_SetAvatar*)lparam;
- if (xsa->hContact==NULL)
+ if (xsa->hContact == NULL)
return;
- if (GetAvatar(xsa->username,&av))
- {
- PROTO_AVATAR_INFORMATIONT AI;
- AI.cbSize = sizeof(AI);
- AI.format = av.type;
- AI.hContact = xsa->hContact;
- lstrcpy(AI.filename, _A2T(av.file));
- ProtoBroadcastAck(protocolname, xsa->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS,(HANDLE) &AI, 0);
- }
+ if (GetAvatar(xsa->username, &av))
+ {
+ PROTO_AVATAR_INFORMATIONT AI;
+ AI.cbSize = sizeof(AI);
+ AI.format = av.type;
+ AI.hContact = xsa->hContact;
+ lstrcpy(AI.filename, _A2T(av.file));
+ ProtoBroadcastAck(protocolname, xsa->hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&AI, 0);
+ }
delete(xsa);
//ReleaseMutex(hMutex);
- lasttime-=sleep;
+ lasttime -= sleep;
}
-BOOL GetAvatar(char* username,XFireAvatar* av)
+BOOL GetAvatar(char* username, XFireAvatar* av)
{
- BOOL status=FALSE;
+ BOOL status = FALSE;
- if (av==NULL||username==NULL)
+ if (av == NULL || username == NULL)
return FALSE;
- char address[256]="http://www.xfire.com/profile/";
- strcat_s(address,256,username);
- strcat_s(address,256,"/");
+ char address[256] = "http://www.xfire.com/profile/";
+ strcat_s(address, 256, username);
+ strcat_s(address, 256, "/");
//netlib request
- NETLIBHTTPREQUEST nlhr={0},*nlhrReply;
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType= REQUEST_GET;
- nlhr.flags = NLHRF_NODUMP|NLHRF_GENERATEHOST|NLHRF_SMARTAUTHHEADER;
- nlhr.szUrl = address;
+ NETLIBHTTPREQUEST nlhr = { 0 }, *nlhrReply;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_NODUMP | NLHRF_GENERATEHOST | NLHRF_SMARTAUTHHEADER;
+ nlhr.szUrl = address;
- nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlib,(LPARAM)&nlhr);
+ nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlib, (LPARAM)&nlhr);
if (nlhrReply) {
//nicht auf dem server
if (nlhrReply->resultCode != 200) {
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
return FALSE;
}
//keine daten für mich
else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL)
{
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
return FALSE;
}
else
@@ -1848,75 +1849,75 @@ BOOL GetAvatar(char* username,XFireAvatar* av) //fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f);
//id wo angefangen wird, die adresse "rauszuschneiden"
- char avatarid[]="m_user_avatar_img_wrapper";
- char* pointer_av=avatarid;
+ char avatarid[] = "m_user_avatar_img_wrapper";
+ char* pointer_av = avatarid;
//ende des datenbuffers
- char* deathend=nlhrReply->pData+nlhrReply->dataLength;
- char* pointer=nlhrReply->pData;
+ char* deathend = nlhrReply->pData + nlhrReply->dataLength;
+ char* pointer = nlhrReply->pData;
//status ob gefunden oder nich
- BOOL found=FALSE;
+ BOOL found = FALSE;
- while(pointer<deathend&&*pointer_av!=0)
+ while (pointer < deathend&&*pointer_av != 0)
{
- if (*pointer_av==*pointer)
+ if (*pointer_av == *pointer)
{
pointer_av++;
- if (pointer_av-avatarid>4)
- found=TRUE;
+ if (pointer_av - avatarid > 4)
+ found = TRUE;
}
else
- pointer_av=avatarid;
+ pointer_av = avatarid;
pointer++;
}
//was gefunden, nun das bild raustrennen
- if (*pointer_av==0)
+ if (*pointer_av == 0)
{
char * pos = NULL;
- pos=strchr(pointer,'/');
- pos-=5;
- pointer=pos;
+ pos = strchr(pointer, '/');
+ pos -= 5;
+ pointer = pos;
- pos=strchr(pointer,' ');
+ pos = strchr(pointer, ' ');
if (pos)
{
pos--;
- *pos=0;
+ *pos = 0;
//analysieren, welchent typ das bild hat
- pos=strrchr(pointer,'.');
+ pos = strrchr(pointer, '.');
if (pos)
{
char filename[512];
- strcpy(filename, XFireGetFoldersPath ("Avatar"));
+ strcpy(filename, XFireGetFoldersPath("Avatar"));
strcat(filename, username);
pos++;
//gif?!?!
- if (*pos=='g'&&
- *(pos+1)=='i'&&
- *(pos+2)=='f')
+ if (*pos == 'g'&&
+ *(pos + 1) == 'i'&&
+ *(pos + 2) == 'f')
{
- av->type=PA_FORMAT_GIF;
- strcat(filename,".gif");
+ av->type = PA_FORMAT_GIF;
+ strcat(filename, ".gif");
}
else//dann kanns nur jpg sein
{
- av->type=PA_FORMAT_JPEG;
- strcat(filename,".jpg");
+ av->type = PA_FORMAT_JPEG;
+ strcat(filename, ".jpg");
}
//verusch das bild runterladen
- if (GetWWWContent2(pointer,filename,FALSE))
+ if (GetWWWContent2(pointer, filename, FALSE))
{
- strcpy_s(av->file,256,filename); //setzte dateinamen
- status=TRUE; //avatarladen hat geklappt, cool :)
+ strcpy_s(av->file, 256, filename); //setzte dateinamen
+ status = TRUE; //avatarladen hat geklappt, cool :)
}
}
}
}
}
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
}
return status;
@@ -1924,11 +1925,11 @@ BOOL GetAvatar(char* username,XFireAvatar* av) static INT_PTR GetIPPort(WPARAM hContact, LPARAM lParam)
{
- if (db_get_w(hContact, protocolname, "Port", -1)==0)
+ if (db_get_w(hContact, protocolname, "Port", -1) == 0)
return 0;
DBVARIANT dbv;
- if (db_get_s(hContact, protocolname, "ServerIP",&dbv))
+ if (db_get_s(hContact, protocolname, "ServerIP", &dbv))
return 0;
char temp[XFIRE_MAX_STATIC_STRING_LEN];
@@ -1938,7 +1939,7 @@ static INT_PTR GetIPPort(WPARAM hContact, LPARAM lParam) if (OpenClipboard(NULL)) {
EmptyClipboard();
- HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp) + 1);
char *buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(temp));
GlobalUnlock(clipbuffer);
@@ -1952,11 +1953,11 @@ static INT_PTR GetIPPort(WPARAM hContact, LPARAM lParam) static INT_PTR GetVIPPort(WPARAM hContact, LPARAM lParam)
{
- if (db_get_w(hContact, protocolname, "VPort", -1)==0)
+ if (db_get_w(hContact, protocolname, "VPort", -1) == 0)
return 0;
DBVARIANT dbv;
- if (db_get_s(hContact, protocolname, "VServerIP",&dbv))
+ if (db_get_s(hContact, protocolname, "VServerIP", &dbv))
return 0;
char temp[XFIRE_MAX_STATIC_STRING_LEN];
@@ -1966,7 +1967,7 @@ static INT_PTR GetVIPPort(WPARAM hContact, LPARAM lParam) if (OpenClipboard(NULL)) {
EmptyClipboard();
- HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp) + 1);
char *buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(temp));
GlobalUnlock(clipbuffer);
@@ -1981,12 +1982,12 @@ static INT_PTR GetVIPPort(WPARAM hContact, LPARAM lParam) static INT_PTR GotoProfile(WPARAM hContact, LPARAM lParam)
{
DBVARIANT dbv;
- if (db_get_s(hContact, protocolname, "Username",&dbv))
+ if (db_get_s(hContact, protocolname, "Username", &dbv))
return 0;
char temp[64];
- strcpy(temp,"http://xfire.com/profile/");
- strcat_s(temp,64,dbv.pszVal);
+ strcpy(temp, "http://xfire.com/profile/");
+ strcat_s(temp, 64, dbv.pszVal);
db_free(&dbv);
CallService(MS_UTILS_OPENURL, 1, (LPARAM)temp);
@@ -1997,16 +1998,16 @@ static INT_PTR GotoProfile(WPARAM hContact, LPARAM lParam) static INT_PTR GotoXFireClanSite(WPARAM hContact, LPARAM lParam)
{
DBVARIANT dbv;
- char temp[64]="";
+ char temp[64] = "";
- int clanid=db_get_dw(hContact, protocolname, "Clan",-1);
+ int clanid = db_get_dw(hContact, protocolname, "Clan", -1);
mir_snprintf(temp, SIZEOF(temp), "ClanUrl_%d", clanid);
- if (db_get_s(NULL, protocolname, temp,&dbv))
+ if (db_get_s(NULL, protocolname, temp, &dbv))
return 0;
- strcpy(temp,"http://xfire.com/clans/");
- strcat_s(temp,64,dbv.pszVal);
+ strcpy(temp, "http://xfire.com/clans/");
+ strcat_s(temp, 64, dbv.pszVal);
db_free(&dbv);
CallService(MS_UTILS_OPENURL, 1, (LPARAM)temp);
@@ -2017,11 +2018,11 @@ static INT_PTR GotoXFireClanSite(WPARAM hContact, LPARAM lParam) static INT_PTR GotoProfile2(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
- if (db_get_s(NULL, protocolname, "login",&dbv))
+ if (db_get_s(NULL, protocolname, "login", &dbv))
return 0;
char temp[64];
- strcpy(temp,"http://xfire.com/profile/");
+ strcpy(temp, "http://xfire.com/profile/");
strcat_s(temp, 64, dbv.pszVal);
db_free(&dbv);
@@ -2032,13 +2033,13 @@ static INT_PTR GotoProfile2(WPARAM wParam, LPARAM lParam) static INT_PTR GotoProfileAct(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
- char temp[64]="";
+ char temp[64] = "";
- if (db_get_s(NULL, protocolname, "login",&dbv))
+ if (db_get_s(NULL, protocolname, "login", &dbv))
return 0;
- strcpy(temp,"http://www.xfire.com/?username=");
- strcat_s(temp,64,dbv.pszVal);
+ strcpy(temp, "http://www.xfire.com/?username=");
+ strcat_s(temp, 64, dbv.pszVal);
db_free(&dbv);
CallService(MS_UTILS_OPENURL, 1, (LPARAM)temp);
@@ -2065,13 +2066,13 @@ int RebuildContactMenu(WPARAM hContact, LPARAM lParam) Menu_ShowItem(vipport, bEnabled);
//clansite nur bei clanmembern anbieten
- Menu_ShowItem(gotoclansite, db_get_dw(hContact, protocolname, "Clan",0) != 0);
+ Menu_ShowItem(gotoclansite, db_get_dw(hContact, protocolname, "Clan", 0) != 0);
//NotOnList
- Menu_ShowItem(blockfriend, db_get_dw(hContact, "CList", "NotOnList",0) != 0);
+ Menu_ShowItem(blockfriend, db_get_dw(hContact, "CList", "NotOnList", 0) != 0);
//speichere gameid ab
- int gameid = db_get_w(hContact, protocolname, "GameId",0);
+ int gameid = db_get_w(hContact, protocolname, "GameId", 0);
//spiel in xfirespieliste?
bEnabled = bEnabled2 = true;
if (!xgamelist.Gameinlist(gameid)) {
@@ -2080,12 +2081,12 @@ int RebuildContactMenu(WPARAM hContact, LPARAM lParam) }
else {
//gameobject holen
- Xfire_game* game=xgamelist.getGamebyGameid(gameid);
+ Xfire_game* game = xgamelist.getGamebyGameid(gameid);
//hat das spiel netzwerkparameter?
if (game) {
if (game->networkparams) {
//is beim buddy ein port hinterlegt, also spielt er im internet?
- if ( !db_get_dw(hContact, protocolname, "Port",0)) {
+ if (!db_get_dw(hContact, protocolname, "Port", 0)) {
//nein, dann join button auch ausblenden
bEnabled = false;
}
@@ -2099,7 +2100,7 @@ int RebuildContactMenu(WPARAM hContact, LPARAM lParam) Menu_ShowItem(startthisgame, bEnabled2);
//remove freind nur bei noramlen buddies
- Menu_ShowItem(removefriend, db_get_b(hContact, protocolname, "friendoffriend",0) != 1);
+ Menu_ShowItem(removefriend, db_get_b(hContact, protocolname, "friendoffriend", 0) != 1);
return 0;
}
@@ -2121,19 +2122,19 @@ void inigamedetectiont(LPVOID lParam) void SetXFireGameStatusMsg(Xfire_game* game)
{
- char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
- static char statusmsg[100]="";
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ static char statusmsg[100] = "";
//kein gameobject, dann abbrechen
if (!game) return;
if (!game->statusmsg)
- xgamelist.getIniValue(game->id,"XUSERStatusMsg",statusmsg,100);
+ xgamelist.getIniValue(game->id, "XUSERStatusMsg", statusmsg, 100);
else
- strcpy_s(statusmsg,100,game->statusmsg);
+ strcpy_s(statusmsg, 100, game->statusmsg);
- if (statusmsg[0]!=0)
- if (myClient!=NULL)
+ if (statusmsg[0] != 0)
+ if (myClient != NULL)
if (myClient->client->connected)
myClient->Status(statusmsg);
}
@@ -2145,34 +2146,34 @@ void gamedetectiont(LPVOID lparam) #endif
{
DWORD ec; //exitcode der processid
- int ts2port=0;
- int vid=0;
- char ts2ip[4]={0,0,0,0};
+ int ts2port = 0;
+ int vid = 0;
+ char ts2ip[4] = { 0, 0, 0, 0 };
char temp[200];
- Xfire_game* currentgame=NULL;
- BOOL disabledsound=FALSE;
- BOOL disabledpopups=FALSE;
+ Xfire_game* currentgame = NULL;
+ BOOL disabledsound = FALSE;
+ BOOL disabledpopups = FALSE;
//vaiable zum spielzeit messen
time_t t1;
- if (db_get_b(NULL,protocolname,"nogamedetect",0))
+ if (db_get_b(NULL, protocolname, "nogamedetect", 0))
#ifndef NO_PTHREAD
return ptr;
#else
return;
#endif
- DWORD lowpids=db_get_b(NULL,protocolname,"skiplowpid",100);
+ DWORD lowpids = db_get_b(NULL, protocolname, "skiplowpid", 100);
//XFireLog("XFire Gamedetectionthread started...","");
- while(1)
+ while (1)
{
//Sleep(12000);
//XFireLog("12 Sek warten...","");
- if (mySleep(12000,hGameDetection))
+ if (mySleep(12000, hGameDetection))
{
#ifndef NO_PTHREAD
return ptr;
@@ -2188,27 +2189,27 @@ void gamedetectiont(LPVOID lparam) return;
#endif
- if (myClient!=NULL)
+ if (myClient != NULL)
if (!myClient->client->connected)
{
- //XFireLog("PID und TSPID resett...","");
- ts2pid=pid=0;
- //voicechat internen status zurücksetzen
- voicechat.resetCurrentvoicestatus();
+ //XFireLog("PID und TSPID resett...","");
+ ts2pid = pid = 0;
+ //voicechat internen status zurücksetzen
+ voicechat.resetCurrentvoicestatus();
}
- /*
- else*/
+ /*
+ else*/
{
//erstmal nach TS2 suchen
//XFireLog("Teamspeak detection...","");
- if (db_get_b(NULL,protocolname,"ts2detection",0))
+ if (db_get_b(NULL, protocolname, "ts2detection", 0))
{
SendGameStatus2Packet *packet = new SendGameStatus2Packet();
if (voicechat.checkVoicechat(packet)) {
- if (myClient!=NULL)
+ if (myClient != NULL)
{
XFireLog("Send voicechat infos...");
- myClient->client->send( packet );
+ myClient->client->send(packet);
}
}
delete packet;
@@ -2220,121 +2221,121 @@ void gamedetectiont(LPVOID lparam) //wenn remote feature aktiviert, darüber ip erkennen
/*if (db_get_b(NULL,protocolname,"ts2useremote",0))
{
- //ipholen
- SendGameStatus2Packet *packet = new SendGameStatus2Packet();
- if (TSSetupPacket(packet,&ts2pid,&ts2port))
- {
- db_set_w(NULL,protocolname,"currentvoice",packet->gameid);
+ //ipholen
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if (TSSetupPacket(packet,&ts2pid,&ts2port))
+ {
+ db_set_w(NULL,protocolname,"currentvoice",packet->gameid);
- if (packet->ip[3]!=0)
- {
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0],packet->port);
- db_set_s(NULL, protocolname, "VServerIP", temp);
- db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak");
- }
- else
- {
- db_unset(NULL,protocolname, "VServerIP");
- db_unset(NULL,protocolname, "currentvoicename");
- }
+ if (packet->ip[3]!=0)
+ {
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0],packet->port);
+ db_set_s(NULL, protocolname, "VServerIP", temp);
+ db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak");
+ }
+ else
+ {
+ db_unset(NULL,protocolname, "VServerIP");
+ db_unset(NULL,protocolname, "currentvoicename");
+ }
- if (myClient!=NULL)
- myClient->client->send( packet );
- }
- delete packet;
+ if (myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ delete packet;
}
else
{
- if (!ts2pid)
- {
- if (FindTeamSpeak(&ts2pid,&vid))
- {
- //gefunden, serverdaten scannen
- SendGameStatus2Packet *packet = new SendGameStatus2Packet();
- if (myClient!=NULL)
- if (GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
- {
- if (packet->port!=0)
- {
- packet->gameid=vid;
+ if (!ts2pid)
+ {
+ if (FindTeamSpeak(&ts2pid,&vid))
+ {
+ //gefunden, serverdaten scannen
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if (myClient!=NULL)
+ if (GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
+ {
+ if (packet->port!=0)
+ {
+ packet->gameid=vid;
- if (vid==32)
- db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak");
- else if (vid==33)
- db_set_s(NULL, protocolname, "currentvoicename", "Ventrilo");
- else if (vid==34)
- db_set_s(NULL, protocolname, "currentvoicename", "Mumble");
+ if (vid==32)
+ db_set_s(NULL, protocolname, "currentvoicename", "Teamspeak");
+ else if (vid==33)
+ db_set_s(NULL, protocolname, "currentvoicename", "Ventrilo");
+ else if (vid==34)
+ db_set_s(NULL, protocolname, "currentvoicename", "Mumble");
- db_set_w(NULL,protocolname,"currentvoice",vid);
+ db_set_w(NULL,protocolname,"currentvoice",vid);
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
- db_set_s(NULL, protocolname, "VServerIP", temp);
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ db_set_s(NULL, protocolname, "VServerIP", temp);
- if (myClient!=NULL)
- myClient->client->send( packet );
- }
- }
- delete packet;
- }
- }
- else
- {
- //HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ts2pid);
- //if (op!=NULL) GetExitCodeProcess(op,&ec);
+ if (myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ }
+ delete packet;
+ }
+ }
+ else
+ {
+ //HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ts2pid);
+ //if (op!=NULL) GetExitCodeProcess(op,&ec);
- //if (ec!=STILL_ACTIVE) //nicht mehr offen
- if (GetProcessVersion(ts2pid) == 0)
- {
- SendGameStatus2Packet *packet = new SendGameStatus2Packet();
- packet->gameid=0;
- db_set_w(NULL,protocolname,"currentvoice",0);
- db_unset(NULL,protocolname, "VServerIP");
- db_unset(NULL,protocolname, "currentvoicename");
-
- if (myClient!=NULL)
- myClient->client->send( packet );
- ts2pid=0;
- delete packet;
- }
- else
- {
- SendGameStatus2Packet *packet = new SendGameStatus2Packet();
- if (myClient!=NULL)
- if (GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
- {
- if (packet->port!=0)
- {
- packet->gameid=vid;
- db_set_w(NULL,protocolname,"currentvoice",vid);
+ //if (ec!=STILL_ACTIVE) //nicht mehr offen
+ if (GetProcessVersion(ts2pid) == 0)
+ {
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ packet->gameid=0;
+ db_set_w(NULL,protocolname,"currentvoice",0);
+ db_unset(NULL,protocolname, "VServerIP");
+ db_unset(NULL,protocolname, "currentvoicename");
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
- db_set_s(NULL, protocolname, "VServerIP", temp);
+ if (myClient!=NULL)
+ myClient->client->send( packet );
+ ts2pid=0;
+ delete packet;
+ }
+ else
+ {
+ SendGameStatus2Packet *packet = new SendGameStatus2Packet();
+ if (myClient!=NULL)
+ if (GetServerIPPort2(ts2pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
+ {
+ if (packet->port!=0)
+ {
+ packet->gameid=vid;
+ db_set_w(NULL,protocolname,"currentvoice",vid);
- if (myClient!=NULL)
- myClient->client->send( packet );
- }
- }
- delete packet;
- }
- //if (op!=NULL) CloseHandle(op);
- }
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1],(unsigned char)packet->ip[0],packet->port);
+ db_set_s(NULL, protocolname, "VServerIP", temp);
+
+ if (myClient!=NULL)
+ myClient->client->send( packet );
+ }
+ }
+ delete packet;
+ }
+ //if (op!=NULL) CloseHandle(op);
+ }
}*/
}
- if (currentgame!=NULL)
+ if (currentgame != NULL)
{
//XFireLog("XFire Gamedetection - Game still running...","");
//prüf ob das spiel noch offen
- ec=0;
+ ec = 0;
//HANDLE op=OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
//if (op!=NULL) GetExitCodeProcess(op,&ec);
//if (GetLastError()==5) //anwendung ist noch offen und der zugriff wird noch darauf blockiert
//{
- //
+ //
//}
//else if (ec!=STILL_ACTIVE) //nicht mehr offen
@@ -2342,62 +2343,62 @@ void gamedetectiont(LPVOID lparam) {
//XFireLog("XFire Gamedetection - Game was closed ID: %i",currentgame);
SendGameStatusPacket *packet = new SendGameStatusPacket();
- packet->gameid=0;
- if (db_get_b(NULL,protocolname,"sendgamestatus",1))
- if (myClient!=NULL)
- myClient->client->send( packet );
+ packet->gameid = 0;
+ if (db_get_b(NULL, protocolname, "sendgamestatus", 1))
+ if (myClient != NULL)
+ myClient->client->send(packet);
//spielzeit messen
- time_t t2=time(NULL);
- time_t t3=t2-t1;
- tm * mytm=gmtime(&t3);
+ time_t t2 = time(NULL);
+ time_t t3 = t2 - t1;
+ tm * mytm = gmtime(&t3);
//statusmsg von xfire zurücksetzen
if (currentgame->setstatusmsg)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
- if (bpStatus==ID_STATUS_ONLINE)
+ if (bpStatus == ID_STATUS_ONLINE)
myClient->Status(statusmessage[0]);
- else if (bpStatus==ID_STATUS_AWAY)
+ else if (bpStatus == ID_STATUS_AWAY)
myClient->Status(statusmessage[1]);
}
mir_snprintf(temp, SIZEOF(temp), Translate("Last game: %s playtime: %.2d:%.2d:%.2d"), currentgame->name, mytm->tm_hour, mytm->tm_min, mytm->tm_sec);
db_set_s(NULL, protocolname, "LastGame", temp);
- if (currentgame->noicqstatus!=TRUE&&db_get_b(NULL,protocolname,"autosetstatusmsg",0))
+ if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0))
SetOldStatusMsg();
- db_set_w(NULL,protocolname,"currentgame",0);
- db_unset(NULL,protocolname,"currentgamename");
+ db_set_w(NULL, protocolname, "currentgame", 0);
+ db_unset(NULL, protocolname, "currentgamename");
//popup wieder aktivieren, menuservice funk aufrufen, nur wenn popups vorher abgestellt wurden
if (disabledpopups)
- if (db_get_b(NULL,protocolname,"nopopups",0))
+ if (db_get_b(NULL, protocolname, "nopopups", 0))
{
- if (ServiceExists("Popup/EnableDisableMenuCommand"))
- {
- CallService("Popup/EnableDisableMenuCommand",NULL,NULL);
- }
- disabledpopups=FALSE;
+ if (ServiceExists("Popup/EnableDisableMenuCommand"))
+ {
+ CallService("Popup/EnableDisableMenuCommand", NULL, NULL);
+ }
+ disabledpopups = FALSE;
}
//sound wieder aktivieren, nur wenn es vorher abgestellt wurde
if (disabledsound)
- if (db_get_b(NULL,protocolname,"nosoundev",0))
+ if (db_get_b(NULL, protocolname, "nosoundev", 0))
{
- db_set_b(NULL,"Skin","UseSound",1);
- disabledsound=FALSE;
+ db_set_b(NULL, "Skin", "UseSound", 1);
+ disabledsound = FALSE;
}
//bug beseitigt, wenn spiel beendet, alte ip entfernen
- db_unset(NULL,protocolname, "ServerIP");
+ db_unset(NULL, protocolname, "ServerIP");
- pid=NULL;
- currentgame=NULL;
+ pid = NULL;
+ currentgame = NULL;
xgamelist.SetGameStatus(FALSE);
- NotifyEventHooks(hookgamestart,0,0);
+ NotifyEventHooks(hookgamestart, 0, 0);
delete packet;
}
@@ -2405,38 +2406,39 @@ void gamedetectiont(LPVOID lparam) {
//XFireLog("Spiel noch offen...","");
//nur nwspiele nach ip/port scannen
- if (db_get_b(NULL,protocolname,"ipportdetec",0))
- if (currentgame->networkparams!=NULL&¤tgame->send_gameid>0)
+ if (db_get_b(NULL, protocolname, "ipportdetec", 0))
+ if (currentgame->networkparams != NULL&¤tgame->send_gameid > 0)
{
- SendGameStatusPacket *packet = new SendGameStatusPacket();
- //verscueh serverip und port zu scannen
+ SendGameStatusPacket *packet = new SendGameStatusPacket();
+ //verscueh serverip und port zu scannen
- XFireLog("IPPort detection...","");
- if (GetServerIPPort(pid,myClient->client->localaddr,myClient->client->llocaladdr,&packet->ip[3],&packet->ip[2],&packet->ip[1],&packet->ip[0],&packet->port))
- {
+ XFireLog("IPPort detection...", "");
+ if (GetServerIPPort(pid, myClient->client->localaddr, myClient->client->llocaladdr, &packet->ip[3], &packet->ip[2], &packet->ip[1], &packet->ip[0], &packet->port))
+ {
- if (packet->ip[3]!=0)
- {
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0], packet->port);
- db_set_s(NULL, protocolname, "ServerIP", temp);
- XFireLog("Got IPPort: %s",temp);
- }
- else {
- db_unset(NULL,protocolname, "ServerIP");
- XFireLog("NO IPPort","");
- }
+ if (packet->ip[3] != 0)
+ {
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d:%d", (unsigned char)packet->ip[3], (unsigned char)packet->ip[2], (unsigned char)packet->ip[1], (unsigned char)packet->ip[0], packet->port);
+ db_set_s(NULL, protocolname, "ServerIP", temp);
+ XFireLog("Got IPPort: %s", temp);
+ }
+ else {
+ db_unset(NULL, protocolname, "ServerIP");
+ XFireLog("NO IPPort", "");
+ }
- packet->gameid=currentgame->send_gameid;
- if (db_get_b(NULL,protocolname,"sendgamestatus",1))
- if (myClient!=NULL)
- myClient->client->send( packet );
+ packet->gameid = currentgame->send_gameid;
+ if (db_get_b(NULL, protocolname, "sendgamestatus", 1))
+ if (myClient != NULL)
+ myClient->client->send(packet);
- if (currentgame->noicqstatus!=TRUE&&db_get_b(NULL,protocolname,"autosetstatusmsg",0))
- SetGameStatusMsg();
- } else {
- XFireLog("GetServerIPPort failed","");
- }
- delete packet;
+ if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0))
+ SetGameStatusMsg();
+ }
+ else {
+ XFireLog("GetServerIPPort failed", "");
+ }
+ delete packet;
}
//XFireLog("fertig...","");
//packet->=xf[currentgame].gameid2;
@@ -2448,9 +2450,9 @@ void gamedetectiont(LPVOID lparam) {
//XFireLog("nach spiel suchen...","");
//hardcoded game detection
- HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0);
+ HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
PROCESSENTRY32* processInfo = new PROCESSENTRY32;
- processInfo->dwSize = sizeof ( PROCESSENTRY32);
+ processInfo->dwSize = sizeof(PROCESSENTRY32);
XFireLog("XFire Gamedetection - Suche laufende Spiele...");
@@ -2458,73 +2460,73 @@ void gamedetectiont(LPVOID lparam) xgamelist.Block(TRUE);
- while ( Process32Next ( hSnapShot,processInfo ) != FALSE && currentgame==NULL)
+ while (Process32Next(hSnapShot, processInfo) != FALSE && currentgame == NULL)
{
//überspringe niedrige pids
- if (processInfo->th32ProcessID<lowpids)
+ if (processInfo->th32ProcessID < lowpids)
continue;
Xfire_game* nextgame;
- while(xgamelist.getnextGame(&nextgame))
+ while (xgamelist.getnextGame(&nextgame))
{
if (nextgame->checkpath(processInfo))
{
- SendGameStatusPacket *packet = new SendGameStatusPacket() ;
+ SendGameStatusPacket *packet = new SendGameStatusPacket();
- XFireLog("XFire Gamedetection - Spiel gefunden: %i",nextgame->id);
+ XFireLog("XFire Gamedetection - Spiel gefunden: %i", nextgame->id);
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
{
- currentgame=nextgame;
- pid=processInfo->th32ProcessID;
- db_set_w(NULL,protocolname,"currentgame",currentgame->id);
- db_set_s(NULL,protocolname,"currentgamename",currentgame->name);
- packet->gameid=currentgame->send_gameid;
- t1=time(NULL);
-
- if (db_get_b(NULL,protocolname,"sendgamestatus",1))
+ currentgame = nextgame;
+ pid = processInfo->th32ProcessID;
+ db_set_w(NULL, protocolname, "currentgame", currentgame->id);
+ db_set_s(NULL, protocolname, "currentgamename", currentgame->name);
+ packet->gameid = currentgame->send_gameid;
+ t1 = time(NULL);
+
+ if (db_get_b(NULL, protocolname, "sendgamestatus", 1))
+ {
+ XFireLog("XFire Gamedetection - Sendgame-ID: %i", currentgame->send_gameid);
+ if (currentgame->send_gameid > 0)
{
- XFireLog("XFire Gamedetection - Sendgame-ID: %i",currentgame->send_gameid);
- if (currentgame->send_gameid>0)
- {
- XFireLog("XFire Gamedetection - Setzte Status für XFire");
- myClient->client->send( packet );
- }
+ XFireLog("XFire Gamedetection - Setzte Status für XFire");
+ myClient->client->send(packet);
}
+ }
- xgamelist.SetGameStatus(TRUE);
+ xgamelist.SetGameStatus(TRUE);
- //eventhook triggern
- NotifyEventHooks(hookgamestart,1,0);
+ //eventhook triggern
+ NotifyEventHooks(hookgamestart, 1, 0);
- //statusmsg für xfire setzen
- if (currentgame->setstatusmsg)
- {
- SetXFireGameStatusMsg(currentgame);
- }
+ //statusmsg für xfire setzen
+ if (currentgame->setstatusmsg)
+ {
+ SetXFireGameStatusMsg(currentgame);
+ }
- if (currentgame->noicqstatus!=TRUE&&db_get_b(NULL,protocolname,"autosetstatusmsg",0))
- {
- BackupStatusMsg();
- SetGameStatusMsg();
- }
- //popup abschalten, menuservice funk aufrufen
- if (db_get_b(NULL,protocolname,"nopopups",0))
- {
- if (ServiceExists("Popup/EnableDisableMenuCommand")&&db_get_b(NULL,"Popup","ModuleIsEnabled",0)==1) /**/
- {
- disabledpopups=TRUE;
- CallService("Popup/EnableDisableMenuCommand",NULL,NULL);
- }
- }
- //sound abschalten
- if (db_get_b(NULL,protocolname,"nosoundev",0)&&db_get_b(NULL,"Skin","UseSound",0)==1)
+ if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0))
+ {
+ BackupStatusMsg();
+ SetGameStatusMsg();
+ }
+ //popup abschalten, menuservice funk aufrufen
+ if (db_get_b(NULL, protocolname, "nopopups", 0))
+ {
+ if (ServiceExists("Popup/EnableDisableMenuCommand") && db_get_b(NULL, "Popup", "ModuleIsEnabled", 0) == 1) /**/
{
- db_set_b(NULL,"Skin","UseSound",0);
- disabledsound=TRUE;
+ disabledpopups = TRUE;
+ CallService("Popup/EnableDisableMenuCommand", NULL, NULL);
}
}
+ //sound abschalten
+ if (db_get_b(NULL, protocolname, "nosoundev", 0) && db_get_b(NULL, "Skin", "UseSound", 0) == 1)
+ {
+ db_set_b(NULL, "Skin", "UseSound", 0);
+ disabledsound = TRUE;
+ }
+ }
delete packet;
@@ -2532,7 +2534,7 @@ void gamedetectiont(LPVOID lparam) }
}
}
- CloseHandle ( hSnapShot);
+ CloseHandle(hSnapShot);
//gamelist unblocken
xgamelist.Block(FALSE);
@@ -2545,7 +2547,7 @@ static INT_PTR ReScanMyGames(WPARAM wParam, LPARAM lParam) {
db_unset(NULL, protocolname, "foundgames");
- mir_forkthread(Scan4Games,NULL);
+ mir_forkthread(Scan4Games, NULL);
return 0;
}
@@ -2557,13 +2559,13 @@ static INT_PTR CustomGameSetup(WPARAM wParam, LPARAM lParam) }
void setBuddyStatusMsg(BuddyListEntry *entry)
-{
+{
if (entry == NULL)
return;
if (IsContactMySelf(entry->username))
return;
-
+
if (entry->game)
{
ostringstream xstatus;
@@ -2581,7 +2583,7 @@ void setBuddyStatusMsg(BuddyListEntry *entry) xstatus << dbv.pszVal;
db_free(&dbv);
}
- else if (!db_get_s(entry->hcontact,protocolname, "ServerIP",&dbv))
+ else if (!db_get_s(entry->hcontact, protocolname, "ServerIP", &dbv))
{
xstatus << "(" << dbv.pszVal << ":" << db_get_w(entry->hcontact, protocolname, "Port", 0) << ")";
db_free(&dbv);
@@ -2590,7 +2592,7 @@ void setBuddyStatusMsg(BuddyListEntry *entry) db_set_utf(entry->hcontact, protocolname, "XStatusMsg", xstatus.str().c_str());
}
else
- {
+ {
//db_set_b(entry->hcontact, protocolname, "XStatusId", 1);
db_unset(entry->hcontact, protocolname, "XStatusId");
db_unset(entry->hcontact, protocolname, "XStatusName");
@@ -2599,9 +2601,9 @@ void setBuddyStatusMsg(BuddyListEntry *entry) string afk = entry->statusmsg.substr(0, 5);
int status_id = (afk == "(AFK)" || afk == "(ABS)") ? ID_STATUS_AWAY : ID_STATUS_ONLINE;
-
+
db_set_w(entry->hcontact, protocolname, "Status", status_id);
-
+
if (!entry->statusmsg.empty())
db_set_utf(entry->hcontact, "CList", "StatusMsg", entry->statusmsg.c_str());
else
@@ -2610,369 +2612,347 @@ void setBuddyStatusMsg(BuddyListEntry *entry) /*void CheckAvatar(void *ventry)
{
- BuddyListEntry* entry=(BuddyListEntry*)ventry;
- DBVARIANT dbv;
- if (entry==NULL)
- return;
- if (db_get_b(NULL,protocolname,"noavatars",-1)==0)
- {
- if (db_get_b(entry->hcontact, "ContactPhoto", "Locked", -1)!=1)
- {
- if (!db_get_b(NULL,protocolname,"specialavatarload",0))
- {
- if (db_get(entry->hcontact,"ContactPhoto", "File",&dbv))
- {
- XFire_SetAvatar* xsa=new XFire_SetAvatar;
- xsa->hContact=entry->hcontact;
- xsa->username=new char[strlen(entry->username.c_str())+1];
- strcpy(xsa->username,entry->username.c_str());
+BuddyListEntry* entry=(BuddyListEntry*)ventry;
+DBVARIANT dbv;
+if (entry==NULL)
+return;
+if (db_get_b(NULL,protocolname,"noavatars",-1)==0)
+{
+if (db_get_b(entry->hcontact, "ContactPhoto", "Locked", -1)!=1)
+{
+if (!db_get_b(NULL,protocolname,"specialavatarload",0))
+{
+if (db_get(entry->hcontact,"ContactPhoto", "File",&dbv))
+{
+XFire_SetAvatar* xsa=new XFire_SetAvatar;
+xsa->hContact=entry->hcontact;
+xsa->username=new char[strlen(entry->username.c_str())+1];
+strcpy(xsa->username,entry->username.c_str());
- mir_forkthread(SetAvatar,(LPVOID)xsa);
- }
- }
- else
- {
- /*
- scheinbar unterpricht xfire bei zu agressiven nachfragen der buddyinfos die verbindung , deshalb erstmal auskommentiert
- getestet mit clanbuddy's >270 members
+mir_forkthread(SetAvatar,(LPVOID)xsa);
+}
+}
+else
+{
+/*
+scheinbar unterpricht xfire bei zu agressiven nachfragen der buddyinfos die verbindung , deshalb erstmal auskommentiert
+getestet mit clanbuddy's >270 members
- mit hilfe der buddyinfos kann man den avatar laden und screenshot infos etc bekommt man auch
- */
+mit hilfe der buddyinfos kann man den avatar laden und screenshot infos etc bekommt man auch
+*/
/* GetBuddyInfo* buddyinfo=new GetBuddyInfo();
buddyinfo->userid=entry->userid;
mir_forkthread(SetAvatar2,(LPVOID)buddyinfo);
- }
- }
- }
-}*/
+ }
+ }
+ }
+ }*/
-MCONTACT handlingBuddys(BuddyListEntry *entry, int clan,char*group,BOOL dontscan)
+MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontscan)
{
- MCONTACT hContact;
- string game;
+ MCONTACT hContact;
+ string game;
- if (entry==NULL)
- return NULL;
+ if (entry == NULL)
+ return NULL;
- //wenn der buddy ich selbst ist, dann ignorieren
- if (IsContactMySelf(entry->username))
+ //wenn der buddy ich selbst ist, dann ignorieren
+ if (IsContactMySelf(entry->username))
return NULL;
- if (entry->hcontact==NULL)
+ if (entry->hcontact == NULL)
+ {
+ entry->hcontact = CList_FindContact(entry->userid);
+ if (entry->hcontact&&clan == -1)
{
- entry->hcontact=CList_FindContact(entry->userid);
- if (entry->hcontact&&clan==-1)
- {
- db_set_w(entry->hcontact, protocolname, "Status", ID_STATUS_ONLINE);
- db_set_s(entry->hcontact, protocolname, "MirVer", "xfire");
- }
+ db_set_w(entry->hcontact, protocolname, "Status", ID_STATUS_ONLINE);
+ db_set_s(entry->hcontact, protocolname, "MirVer", "xfire");
}
+ }
- if (entry->hcontact==NULL)
- {
- XFireContact xfire_newc;
- xfire_newc.username=(char*)entry->username.c_str();
- xfire_newc.nick=(char*)entry->nick.c_str();
- xfire_newc.id=entry->userid;
+ if (entry->hcontact == NULL)
+ {
+ XFireContact xfire_newc;
+ xfire_newc.username = (char*)entry->username.c_str();
+ xfire_newc.nick = (char*)entry->nick.c_str();
+ xfire_newc.id = entry->userid;
+
+ entry->hcontact = CList_AddContact(xfire_newc, TRUE, entry->isOnline() ? TRUE : FALSE, clan);
+ }
- entry->hcontact=CList_AddContact(xfire_newc,TRUE,entry->isOnline()?TRUE:FALSE,clan);
- }
+ hContact = entry->hcontact;
- hContact=entry->hcontact;
+ if (hContact != 0)
+ {
+ if (!entry->nick.empty() && db_get_b(NULL, protocolname, "shownicks", 1)) {
+ db_set_utf(hContact, protocolname, "Nick", entry->nick.c_str());
+ }
+ else {
+ db_set_s(hContact, protocolname, "Nick", entry->username.c_str());
+ }
- if (hContact!=0)
+ if (!entry->isOnline())
{
- if (!entry->nick.empty() && db_get_b(NULL, protocolname, "shownicks", 1)) {
- db_set_utf(hContact, protocolname, "Nick", entry->nick.c_str());
- } else {
- db_set_s(hContact, protocolname, "Nick", entry->username.c_str());
- }
+ db_set_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE);
+ db_unset(hContact, protocolname, "XStatusMsg");
+ db_unset(hContact, protocolname, "XStatusId");
+ db_unset(hContact, protocolname, "XStatusName");
+ db_unset(hContact, "CList", "StatusMsg");
+ //db_set_utf(hContact, protocolname, "XStatusName", "");
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
+ db_unset(hContact, protocolname, "VServerIP");
+ db_unset(hContact, protocolname, "VPort");
+ db_unset(hContact, protocolname, "RVoice");
+ db_unset(hContact, protocolname, "RGame");
+ db_unset(hContact, protocolname, "GameId");
+ db_unset(hContact, protocolname, "VoiceId");
+ db_unset(hContact, protocolname, "GameInfo");
+ }
+ else if (entry->game > 0 || entry->game2 > 0)
+ {
+ char temp[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char gname[255] = "";
+
+ DummyXFireGame *gameob;
+
+ if (strlen(entry->gameinfo.c_str()) > 0)
+ db_set_s(hContact, protocolname, "GameInfo", entry->gameinfo.c_str());
- if (!entry->isOnline())
+ //beim voicechat foglendes machn
+ if (entry->game2 > 0)
+ {
+ gameob = (DummyXFireGame*)entry->game2Obj; //obj wo ip und port sind auslesen
+
+ xgamelist.getGamename(entry->game2, gname, 255);
+
+ db_set_s(hContact, protocolname, "RVoice", gname);
+
+ if (gameob)
+ {
+ if ((unsigned char)gameob->ip[3] != 0) // wenn ip, dann speichern
+ {
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]);
+ db_set_s(hContact, protocolname, "VServerIP", temp);
+ db_set_w(hContact, protocolname, "VPort", (unsigned long)gameob->port);
+ }
+ else
+ {
+ db_unset(hContact, protocolname, "VServerIP");
+ db_unset(hContact, protocolname, "VPort");
+ }
+ }
+
+ db_set_w(hContact, protocolname, "VoiceId", entry->game2);
+
+ ExtraIcon_SetIcon(hExtraIcon2, hContact, xgamelist.iconmngr.getGameIconHandle(entry->game2));
+ }
+ else
{
- db_set_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE);
- db_unset(hContact, protocolname, "XStatusMsg");
- db_unset(hContact, protocolname, "XStatusId");
- db_unset(hContact, protocolname, "XStatusName");
- db_unset(hContact, "CList", "StatusMsg");
- //db_set_utf(hContact, protocolname, "XStatusName", "");
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
db_unset(hContact, protocolname, "VServerIP");
db_unset(hContact, protocolname, "VPort");
db_unset(hContact, protocolname, "RVoice");
- db_unset(hContact, protocolname, "RGame");
- db_unset(hContact, protocolname, "GameId");
db_unset(hContact, protocolname, "VoiceId");
- db_unset(hContact, protocolname, "GameInfo");
+ ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
}
- else if (entry->game>0||entry->game2>0)
+
+ //beim game folgendes machen
+ if (entry->game > 0)
{
- char temp[XFIRE_MAX_STATIC_STRING_LEN]="";
- char gname[255]="";
+ HICON hicongame = xgamelist.iconmngr.getGameIcon(entry->game);
- DummyXFireGame *gameob;
+ xgamelist.getGamename(entry->game, gname, 255);
- if (strlen(entry->gameinfo.c_str())>0)
- db_set_s(hContact, protocolname, "GameInfo", entry->gameinfo.c_str());
+ db_set_s(hContact, protocolname, "RGame", gname);
- //beim voicechat foglendes machn
- if (entry->game2>0)
- {
- gameob=(DummyXFireGame*)entry->game2Obj; //obj wo ip und port sind auslesen
+ //beinhaltet ip und port
+ gameob = (DummyXFireGame*)entry->gameObj;
- xgamelist.getGamename(entry->game2,gname,255);
+ //popup, wenn jemand was spielt
+ if (db_get_b(NULL, protocolname, "gamepopup", 0) == 1) {
+ char temp[256] = "";
- db_set_s(hContact, protocolname, "RVoice", gname);
+ mir_snprintf(temp, SIZEOF(temp), Translate("%s is playing %s."),
+ //ist ein nick gesetzt?
+ (entry->nick.length() == 0 ?
+ //nein dann username
+ entry->username.c_str() :
+ //klar, dann nick nehmen
+ entry->nick.c_str())
+ , gname);
if (gameob)
{
- if ((unsigned char)gameob->ip[3]!=0) // wenn ip, dann speichern
- {
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]);
- db_set_s(hContact, protocolname, "VServerIP", temp);
- db_set_w(hContact, protocolname, "VPort", (unsigned long)gameob->port);
- }
- else
+ if ((unsigned char)gameob->ip[3] != 0)
{
- db_unset(hContact, protocolname, "VServerIP");
- db_unset(hContact, protocolname, "VPort");
- }
- }
-
- db_set_w(hContact, protocolname, "VoiceId", entry->game2);
-
- ExtraIcon_SetIcon(hExtraIcon2, hContact, xgamelist.iconmngr.getGameIconHandle(entry->game2));
- }
- else
- {
- db_unset(hContact, protocolname, "VServerIP");
- db_unset(hContact, protocolname, "VPort");
- db_unset(hContact, protocolname, "RVoice");
- db_unset(hContact, protocolname, "VoiceId");
- ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
- }
-
- //beim game folgendes machen
- if (entry->game>0)
- {
- HICON hicongame=xgamelist.iconmngr.getGameIcon(entry->game);
-
- xgamelist.getGamename(entry->game,gname,255);
-
- db_set_s(hContact, protocolname, "RGame", gname);
-
- //beinhaltet ip und port
- gameob=(DummyXFireGame*)entry->gameObj;
-
- //popup, wenn jemand was spielt
- if (db_get_b(NULL,protocolname,"gamepopup",0)==1) {
- char temp[256]="";
-
- mir_snprintf(temp, SIZEOF(temp), Translate("%s is playing %s."),
- //ist ein nick gesetzt?
- (entry->nick.length()==0?
+ mir_snprintf(temp, SIZEOF(temp), Translate("%s is playing %s on server %d.%d.%d.%d:%d."),
+ //ist ein nick gesetzt?
+ (entry->nick.length() == 0 ?
//nein dann username
- entry->username.c_str():
+ entry->username.c_str() :
//klar, dann nick nehmen
entry->nick.c_str())
- ,gname);
-
- if (gameob)
- {
- if ((unsigned char)gameob->ip[3]!=0)
- {
- mir_snprintf(temp, SIZEOF(temp), Translate("%s is playing %s on server %d.%d.%d.%d:%d."),
- //ist ein nick gesetzt?
- (entry->nick.length()==0?
- //nein dann username
- entry->username.c_str():
- //klar, dann nick nehmen
- entry->nick.c_str())
- ,gname,(unsigned char)gameob->ip[3],(unsigned char)gameob->ip[2],(unsigned char)gameob->ip[1],(unsigned char)gameob->ip[0],(unsigned long)gameob->port);
- }
+ , gname, (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0], (unsigned long)gameob->port);
}
+ }
- /*
- POPUP-Filter
- Nur Popups anzeigen die noch nicht angezeigt wurden
+ /*
+ POPUP-Filter
+ Nur Popups anzeigen die noch nicht angezeigt wurden
*/
- if (entry->lastpopup==NULL)
+ if (entry->lastpopup == NULL)
+ {
+ //größe des popupstrings
+ int size = strlen(temp) + 1;
+ //popup darstellen
+ displayPopup(NULL, temp, PLUGIN_TITLE, 0, hicongame);
+ //letzten popup definieren
+ entry->lastpopup = new char[size];
+ //string kopieren
+ strcpy_s(entry->lastpopup, size, temp);
+ }
+ else
+ {
+ if (strcmp(entry->lastpopup, temp) != 0)
{
+ delete[] entry->lastpopup;
+ entry->lastpopup = NULL;
+
//größe des popupstrings
- int size=strlen(temp)+1;
+ int size = strlen(temp) + 1;
//popup darstellen
displayPopup(NULL, temp, PLUGIN_TITLE, 0, hicongame);
//letzten popup definieren
- entry->lastpopup=new char[size];
+ entry->lastpopup = new char[size];
//string kopieren
- strcpy_s(entry->lastpopup,size,temp);
+ strcpy_s(entry->lastpopup, size, temp);
}
- else
- {
- if (strcmp(entry->lastpopup,temp)!=0)
+ }
+ }
+
+ if (gameob)
+ {
+ if ((unsigned char)gameob->ip[3] != 0)
+ {
+ //ip und port in kontakt speichern
+ mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]);
+ db_set_s(hContact, protocolname, "ServerIP", temp);
+ db_set_w(hContact, protocolname, "Port", (unsigned long)gameob->port);
+
+ //lass das query arbeiten
+ if (dontscan == FALSE)
+ if (ServiceExists("GameServerQuery/Query") && db_get_b(NULL, protocolname, "gsqsupport", 0))
{
- delete[] entry->lastpopup;
- entry->lastpopup=NULL;
-
- //größe des popupstrings
- int size=strlen(temp)+1;
- //popup darstellen
- displayPopup(NULL, temp, PLUGIN_TITLE, 0, hicongame);
- //letzten popup definieren
- entry->lastpopup=new char[size];
- //string kopieren
- strcpy_s(entry->lastpopup,size,temp);
+ GameServerQuery_query gsqq = { 0 };
+ gsqq.port = gameob->port;
+ gsqq.xfiregameid = entry->game;
+ strcpy(gsqq.ip, temp);
+ CallService("GameServerQuery/Query", (WPARAM)entry, (LPARAM)&gsqq);
}
- }
}
-
- if (gameob)
+ else
{
- if ((unsigned char)gameob->ip[3]!=0)
- {
- //ip und port in kontakt speichern
- mir_snprintf(temp, SIZEOF(temp), "%d.%d.%d.%d", (unsigned char)gameob->ip[3], (unsigned char)gameob->ip[2], (unsigned char)gameob->ip[1], (unsigned char)gameob->ip[0]);
- db_set_s(hContact, protocolname, "ServerIP", temp);
- db_set_w(hContact, protocolname, "Port", (unsigned long)gameob->port);
-
- //lass das query arbeiten
- if (dontscan==FALSE)
- if (ServiceExists("GameServerQuery/Query")&&db_get_b(NULL,protocolname,"gsqsupport",0))
- {
- GameServerQuery_query gsqq={0};
- gsqq.port=gameob->port;
- gsqq.xfiregameid=entry->game;
- strcpy(gsqq.ip,temp);
- CallService("GameServerQuery/Query" , (WPARAM) entry, (LPARAM)&gsqq);
- }
- }
- else
- {
- db_unset(hContact, protocolname, "ServerName");
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
- }
+ db_unset(hContact, protocolname, "ServerName");
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
}
+ }
- ExtraIcon_SetIcon(hExtraIcon1, hContact, xgamelist.iconmngr.getGameIconHandle(entry->game));
-
- //db_unset(hContact, "CList", "StatusMsg");
- db_set_w(hContact, protocolname, "Status", ID_STATUS_ONLINE);
- db_set_utf(hContact, protocolname, "XStatusName", Translate("Playing"));
- setBuddyStatusMsg(entry);
- db_set_b(hContact, protocolname, "XStatusId", xgamelist.iconmngr.getGameIconId(entry->game)+2);
-
- //buddy vorher ein spielgestartet, wenn nicht sound spielen?
- if (!db_get_w(hContact, protocolname, "GameId",0))
- SkinPlaySound("xfirebstartgame");
+ ExtraIcon_SetIcon(hExtraIcon1, hContact, xgamelist.iconmngr.getGameIconHandle(entry->game));
- db_set_w(hContact, protocolname, "GameId", entry->game);
- }
- else
- {
- ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
- db_unset(hContact, protocolname, "XStatusMsg");
- db_unset(hContact, protocolname, "XStatusId");
- db_unset(hContact, protocolname, "XStatusName");
- db_unset(hContact, protocolname, "RGame");
- db_unset(hContact, protocolname, "GameId");
- setBuddyStatusMsg(entry);
- }
- }
- else if (!entry->statusmsg.empty())
- {
+ //db_unset(hContact, "CList", "StatusMsg");
+ db_set_w(hContact, protocolname, "Status", ID_STATUS_ONLINE);
+ db_set_utf(hContact, protocolname, "XStatusName", Translate("Playing"));
setBuddyStatusMsg(entry);
+ db_set_b(hContact, protocolname, "XStatusId", xgamelist.iconmngr.getGameIconId(entry->game) + 2);
- ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
- ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
-
- // RM: test fix to remove xstatus when finished playing...
- db_unset(hContact, protocolname, "XStatusMsg");
- db_unset(hContact, protocolname, "XStatusId");
- db_unset(hContact, protocolname, "XStatusName");
- // ---
+ //buddy vorher ein spielgestartet, wenn nicht sound spielen?
+ if (!db_get_w(hContact, protocolname, "GameId", 0))
+ SkinPlaySound("xfirebstartgame");
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
- db_unset(hContact, protocolname, "VServerIP");
- db_unset(hContact, protocolname, "VPort");
- db_unset(hContact, protocolname, "RVoice");
- db_unset(hContact, protocolname, "RGame");
- db_unset(hContact, protocolname, "GameId");
- db_unset(hContact, protocolname, "VoiceId");
+ db_set_w(hContact, protocolname, "GameId", entry->game);
}
else
{
- if (db_get_w(entry->hcontact, protocolname, "Status", -1)==ID_STATUS_OFFLINE)
- {
- if (db_get_b(NULL, protocolname, "noclanavatars", 0)==1&&clan>0)
- ;
- else
- if (myClient) myClient->CheckAvatar(entry);
- }
-
ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
- ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
-
- db_set_w(hContact, protocolname, "Status", ID_STATUS_ONLINE);
- db_set_s(entry->hcontact, protocolname, "MirVer", "xfire");
- if (clan>0) db_set_dw(hContact, protocolname, "Clan", clan);
- //db_set_utf(hContact, "CList", "StatusMsg", "");
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
db_unset(hContact, protocolname, "XStatusMsg");
db_unset(hContact, protocolname, "XStatusId");
db_unset(hContact, protocolname, "XStatusName");
- db_unset(hContact, "CList", "StatusMsg");
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
- db_unset(hContact, protocolname, "VServerIP");
- db_unset(hContact, protocolname, "VPort");
- db_unset(hContact, protocolname, "RVoice");
db_unset(hContact, protocolname, "RGame");
db_unset(hContact, protocolname, "GameId");
- db_unset(hContact, protocolname, "VoiceId");
+ setBuddyStatusMsg(entry);
}
}
- if (group!=NULL)
+ else if (!entry->statusmsg.empty())
{
- if (!db_get_b(NULL,protocolname,"noclangroups",0))
+ setBuddyStatusMsg(entry);
+
+ ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
+ ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
+
+ // RM: test fix to remove xstatus when finished playing...
+ db_unset(hContact, protocolname, "XStatusMsg");
+ db_unset(hContact, protocolname, "XStatusId");
+ db_unset(hContact, protocolname, "XStatusName");
+ // ---
+
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
+ db_unset(hContact, protocolname, "VServerIP");
+ db_unset(hContact, protocolname, "VPort");
+ db_unset(hContact, protocolname, "RVoice");
+ db_unset(hContact, protocolname, "RGame");
+ db_unset(hContact, protocolname, "GameId");
+ db_unset(hContact, protocolname, "VoiceId");
+ }
+ else
+ {
+ if (db_get_w(entry->hcontact, protocolname, "Status", -1) == ID_STATUS_OFFLINE)
{
- if (clan>0)
- {
- int val=db_get_b(NULL,protocolname,"mainclangroup",0);
+ if (db_get_b(NULL, protocolname, "noclanavatars", 0) == 1 && clan > 0)
+ ;
+ else
+ if (myClient) myClient->CheckAvatar(entry);
+ }
- if ( db_get_b(NULL,protocolname,"skipfriendsgroups",0)==0 ||
- (db_get_b(NULL,protocolname,"skipfriendsgroups",0)==1&&
- db_get_b(entry->hcontact, protocolname, "isfriend", 0)==0)
- )
- {
- if (val==0)
- {
- db_set_s(entry->hcontact, "CList", "Group", group);
- }
- else
- {
- char temp[256];
- DBVARIANT dbv;
- mir_snprintf(temp, SIZEOF(temp), "%d", val - 1);
- db_get_s(NULL,"CListGroups",temp,&dbv);
- if (dbv.pszVal!=NULL)
- {
- mir_snprintf(temp, SIZEOF(temp), "%s\\%s", &dbv.pszVal[1], group);
- db_set_s(entry->hcontact, "CList", "Group", temp);
- db_free(&dbv);
- }
- }
- }
- }
- else if (clan==-1)//hauptgruppe für fof
- {
- int val=db_get_b(NULL,protocolname,"fofgroup",0);
+ ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
+ ExtraIcon_SetIcon(hExtraIcon2, hContact, INVALID_HANDLE_VALUE);
+
+ db_set_w(hContact, protocolname, "Status", ID_STATUS_ONLINE);
+ db_set_s(entry->hcontact, protocolname, "MirVer", "xfire");
+ if (clan > 0) db_set_dw(hContact, protocolname, "Clan", clan);
+ //db_set_utf(hContact, "CList", "StatusMsg", "");
+ db_unset(hContact, protocolname, "XStatusMsg");
+ db_unset(hContact, protocolname, "XStatusId");
+ db_unset(hContact, protocolname, "XStatusName");
+ db_unset(hContact, "CList", "StatusMsg");
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
+ db_unset(hContact, protocolname, "VServerIP");
+ db_unset(hContact, protocolname, "VPort");
+ db_unset(hContact, protocolname, "RVoice");
+ db_unset(hContact, protocolname, "RGame");
+ db_unset(hContact, protocolname, "GameId");
+ db_unset(hContact, protocolname, "VoiceId");
+ }
+ }
+ if (group != NULL)
+ {
+ if (!db_get_b(NULL, protocolname, "noclangroups", 0))
+ {
+ if (clan > 0)
+ {
+ int val = db_get_b(NULL, protocolname, "mainclangroup", 0);
- if (val==0)
+ if (db_get_b(NULL, protocolname, "skipfriendsgroups", 0) == 0 ||
+ (db_get_b(NULL, protocolname, "skipfriendsgroups", 0) == 1 &&
+ db_get_b(entry->hcontact, protocolname, "isfriend", 0) == 0)
+ )
+ {
+ if (val == 0)
{
db_set_s(entry->hcontact, "CList", "Group", group);
}
@@ -2981,8 +2961,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan,char*group,BOOL dontscan char temp[256];
DBVARIANT dbv;
mir_snprintf(temp, SIZEOF(temp), "%d", val - 1);
- db_get_s(NULL,"CListGroups",temp,&dbv);
- if (dbv.pszVal!=NULL)
+ db_get_s(NULL, "CListGroups", temp, &dbv);
+ if (dbv.pszVal != NULL)
{
mir_snprintf(temp, SIZEOF(temp), "%s\\%s", &dbv.pszVal[1], group);
db_set_s(entry->hcontact, "CList", "Group", temp);
@@ -2991,34 +2971,57 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan,char*group,BOOL dontscan }
}
}
+ else if (clan == -1)//hauptgruppe für fof
+ {
+ int val = db_get_b(NULL, protocolname, "fofgroup", 0);
+
+ if (val == 0)
+ {
+ db_set_s(entry->hcontact, "CList", "Group", group);
+ }
+ else
+ {
+ char temp[256];
+ DBVARIANT dbv;
+ mir_snprintf(temp, SIZEOF(temp), "%d", val - 1);
+ db_get_s(NULL, "CListGroups", temp, &dbv);
+ if (dbv.pszVal != NULL)
+ {
+ mir_snprintf(temp, SIZEOF(temp), "%s\\%s", &dbv.pszVal[1], group);
+ db_set_s(entry->hcontact, "CList", "Group", temp);
+ db_free(&dbv);
+ }
+ }
+ }
}
- else
- {
- db_set_b(entry->hcontact, protocolname, "isfriend", 1);
- }
+ }
+ else
+ {
+ db_set_b(entry->hcontact, protocolname, "isfriend", 1);
+ }
return hContact;
}
-INT_PTR AddtoList( WPARAM wParam, LPARAM lParam ) {
- CCSDATA* ccs = (CCSDATA*)lParam;
+INT_PTR AddtoList(WPARAM wParam, LPARAM lParam) {
+ CCSDATA* ccs = (CCSDATA*)lParam;
- if (ccs->hContact)
- {
+ if (ccs->hContact)
+ {
DBVARIANT dbv2;
- if (!db_get(ccs->hContact,protocolname,"Username",&dbv2)) {
+ if (!db_get(ccs->hContact, protocolname, "Username", &dbv2)) {
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
{
- SendAcceptInvitationPacket accept;
- accept.name = dbv2.pszVal;
- myClient->client->send(&accept );
+ SendAcceptInvitationPacket accept;
+ accept.name = dbv2.pszVal;
+ myClient->client->send(&accept);
}
//temporären buddy entfernen, da eh ein neues packet kommt
db_set_b(ccs->hContact, protocolname, "DontSendDenyPacket", 1);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) ccs->hContact, 0);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)ccs->hContact, 0);
}
}
return 0;
@@ -3027,27 +3030,27 @@ INT_PTR AddtoList( WPARAM wParam, LPARAM lParam ) { static void __cdecl AckBasicSearch(void * pszNick)
{
- if (pszNick!=NULL)
+ if (pszNick != NULL)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
{
- SearchBuddy search;
- search.searchfor(( char* )pszNick);
- myClient->client->send(&search );
+ SearchBuddy search;
+ search.searchfor((char*)pszNick);
+ myClient->client->send(&search);
}
}
}
INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam) {
static char buf[50];
- if ( lParam ) {
- if (myClient!=NULL)
+ if (lParam) {
+ if (myClient != NULL)
if (myClient->client->connected)
{
- lstrcpynA(buf, (const char *)lParam, 50);
- mir_forkthread(AckBasicSearch, &buf );
- return 1;
+ lstrcpynA(buf, (const char *)lParam, 50);
+ mir_forkthread(AckBasicSearch, &buf);
+ return 1;
}
}
@@ -3058,56 +3061,56 @@ INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam) { INT_PTR SearchAddtoList(WPARAM wParam, LPARAM lParam)
{
- PROTOSEARCHRESULT *psr = ( PROTOSEARCHRESULT* ) lParam;
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
- if ( psr->cbSize != sizeof( PROTOSEARCHRESULT ))
+ if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
return 0;
- if ((int)wParam==0)
- if (myClient!=NULL)
+ if ((int)wParam == 0)
+ if (myClient != NULL)
if (myClient->client->connected)
{
- InviteBuddyPacket invite;
- invite.addInviteName( std::string(_T2A(psr->nick)), Translate("Add me to your friends list."));
- myClient->client->send(&invite );
+ InviteBuddyPacket invite;
+ invite.addInviteName(std::string(_T2A(psr->nick)), Translate("Add me to your friends list."));
+ myClient->client->send(&invite);
}
return -1;
}
-void CreateGroup(char*grpn,char*field) {
- DBVARIANT dbv;
+void CreateGroup(char*grpn, char*field) {
+ DBVARIANT dbv;
char* grp[255];
- int val=db_get_b(NULL,protocolname,field,0);
+ int val = db_get_b(NULL, protocolname, field, 0);
- if (val==0)
+ if (val == 0)
{
- strcpy_s((char*)grp,255,grpn);//((char*)clan->name[i].c_str());
+ strcpy_s((char*)grp, 255, grpn);//((char*)clan->name[i].c_str());
}
else
{
char temp[255];
DBVARIANT dbv;
mir_snprintf(temp, SIZEOF(temp), "%d", val - 1);
- db_get_s(NULL,"CListGroups",temp,&dbv);
- if (dbv.pszVal!=NULL)
+ db_get_s(NULL, "CListGroups", temp, &dbv);
+ if (dbv.pszVal != NULL)
{
mir_snprintf((char*)grp, 255, "%s\\%s", &dbv.pszVal[1], (char*)grpn);
db_free(&dbv);
}
else //gruppe existiert nciht mehr, auf root alles legen
{
- strcpy_s((char*)grp,255,grpn);
- db_set_b(NULL,protocolname,field,0);
+ strcpy_s((char*)grp, 255, grpn);
+ db_set_b(NULL, protocolname, field, 0);
}
}
- char group[255]="";
+ char group[255] = "";
char temp[10];
- int i=0;
+ int i = 0;
for (i = 0;; i++)
{
mir_snprintf(temp, SIZEOF(temp), "%d", i);
@@ -3122,9 +3125,9 @@ void CreateGroup(char*grpn,char*field) { }
db_free(&dbv);
}
- strcpy_s(group,255,"D");
- strcat_s(group,255,(char*)grp);
- group[0]= 1 | GROUPF_EXPANDED;
+ strcpy_s(group, 255, "D");
+ strcat_s(group, 255, (char*)grp);
+ group[0] = 1 | GROUPF_EXPANDED;
mir_snprintf(temp, SIZEOF(temp), "%d", i + 1);
db_set_s(NULL, "CListGroups", temp, group);
CallServiceSync(MS_CLUI_GROUPADDED, i + 1, 0);
@@ -3133,39 +3136,40 @@ void CreateGroup(char*grpn,char*field) { INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) {
EnterCriticalSection(&modeMsgsMutex);
- if (( char* )lParam==NULL)
+ if ((char*)lParam == NULL)
{
- if (wParam==ID_STATUS_ONLINE)
+ if (wParam == ID_STATUS_ONLINE)
{
- strcpy(statusmessage[0],"");
+ strcpy(statusmessage[0], "");
}
- else if (wParam!=ID_STATUS_OFFLINE/*&&db_get_b(NULL,protocolname,"nocustomaway",0)==0*/)
+ else if (wParam != ID_STATUS_OFFLINE/*&&db_get_b(NULL,protocolname,"nocustomaway",0)==0*/)
{
mir_snprintf(statusmessage[1], SIZEOF(statusmessage[1]), "(AFK) %s", Translate("Away from Keyboard"));
}
}
else
{
- if (wParam==ID_STATUS_ONLINE)
+ if (wParam == ID_STATUS_ONLINE)
{
- strcpy(statusmessage[0],( char* )lParam);
+ strcpy(statusmessage[0], (char*)lParam);
}
else if (wParam != ID_STATUS_OFFLINE) {
- if (db_get_b(NULL,protocolname,"nocustomaway",0)==0&&strlen(( char* )lParam)>0) {
+ if (db_get_b(NULL, protocolname, "nocustomaway", 0) == 0 && strlen((char*)lParam) > 0) {
mir_snprintf(statusmessage[1], SIZEOF(statusmessage[1]), "(AFK) %s", (char*)lParam);
//strcpy(statusmessage[1],( char* )lParam);
- } else
+ }
+ else
mir_snprintf(statusmessage[1], SIZEOF(statusmessage[1]), "(AFK) %s", Translate("Away from Keyboard"));
}
}
- if (myClient!=NULL)
+ if (myClient != NULL)
{
if (myClient->client->connected)
{
- if (bpStatus==ID_STATUS_ONLINE)
+ if (bpStatus == ID_STATUS_ONLINE)
myClient->Status(statusmessage[0]);
- else if (wParam!=ID_STATUS_ONLINE&&wParam!=ID_STATUS_OFFLINE)
+ else if (wParam != ID_STATUS_ONLINE&&wParam != ID_STATUS_OFFLINE)
myClient->Status(statusmessage[1]);
}
}
@@ -3175,23 +3179,23 @@ INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) { /*static void SendAMAck( LPVOID param )
{
- ptrT statusMsg( db_get_tsa((HANDLE)param, protocolname, "XStatusMsg"));
- ProtoBroadcastAck(protocolname, (HANDLE)param, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)statusMsg);
+ptrT statusMsg( db_get_tsa((HANDLE)param, protocolname, "XStatusMsg"));
+ProtoBroadcastAck(protocolname, (HANDLE)param, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)statusMsg);
}*/
INT_PTR SetNickName(WPARAM newnick, LPARAM lparam)
{
- if (newnick==NULL)
+ if (newnick == NULL)
{
return FALSE;
}
- if (myClient!=NULL)
+ if (myClient != NULL)
if (myClient->client->connected)
{
- myClient->setNick((char*)newnick);
- db_set_s(NULL,protocolname,"Nick",(char*)newnick);
- return TRUE;
+ myClient->setNick((char*)newnick);
+ db_set_s(NULL, protocolname, "Nick", (char*)newnick);
+ return TRUE;
}
return FALSE;
}
@@ -3201,12 +3205,12 @@ INT_PTR SendPrefs(WPARAM wparam, LPARAM lparam) {
if (myClient != NULL)
if (myClient->client->connected) {
- PrefsPacket prefs;
- for(int i=0;i<XFIRE_RECVPREFSPACKET_MAXCONFIGS;i++)
- prefs.config[i]=xfireconfig[i];
+ PrefsPacket prefs;
+ for (int i = 0; i < XFIRE_RECVPREFSPACKET_MAXCONFIGS; i++)
+ prefs.config[i] = xfireconfig[i];
- myClient->client->send( &prefs );
- return TRUE;
+ myClient->client->send(&prefs);
+ return TRUE;
}
return FALSE;
}
@@ -3214,28 +3218,28 @@ INT_PTR SendPrefs(WPARAM wparam, LPARAM lparam) int ContactDeleted(WPARAM hContact, LPARAM lParam)
{
if (!db_get_b(hContact, protocolname, "DontSendDenyPacket", 0))
- if (db_get_b(hContact,"CList","NotOnList",0))
- {
- if (myClient!=NULL)
- if (myClient->client->connected)
+ if (db_get_b(hContact, "CList", "NotOnList", 0))
{
+ if (myClient != NULL)
+ if (myClient->client->connected)
+ {
DBVARIANT dbv2;
- if (!db_get(hContact,protocolname,"Username",&dbv2)) {
+ if (!db_get(hContact, protocolname, "Username", &dbv2)) {
SendDenyInvitationPacket deny;
deny.name = dbv2.pszVal;
- myClient->client->send( &deny );
+ myClient->client->send(&deny);
+ }
}
}
- }
return 0;
}
-INT_PTR StartGame(WPARAM wParam, LPARAM lParam,LPARAM fParam)
+INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam)
{
//gamelist blocken
xgamelist.Block(TRUE);
- Xfire_game*game=xgamelist.getGamebyGameid(fParam);
+ Xfire_game*game = xgamelist.getGamebyGameid(fParam);
//starte das spiel
if (game)
@@ -3253,20 +3257,20 @@ INT_PTR RemoveFriend(WPARAM hContact, LPARAM lParam) char temp[256];
DBVARIANT dbv;
- if (!db_get_s(hContact, protocolname, "Username",&dbv))
+ if (!db_get_s(hContact, protocolname, "Username", &dbv))
{
mir_snprintf(temp, SIZEOF(temp), Translate("Do you really want to delete your friend %s?"), dbv.pszVal);
- if (MessageBoxA(NULL,temp,Translate("Confirm Delete"),MB_YESNO|MB_ICONQUESTION)==IDYES)
+ if (MessageBoxA(NULL, temp, Translate("Confirm Delete"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
{
if (myClient->client->connected)
{
SendRemoveBuddyPacket removeBuddy;
- removeBuddy.userid=db_get_dw(hContact,protocolname,"UserId",0);
+ removeBuddy.userid = db_get_dw(hContact, protocolname, "UserId", 0);
- if (removeBuddy.userid!=0)
+ if (removeBuddy.userid != 0)
{
myClient->client->send(&removeBuddy);
}
@@ -3282,19 +3286,19 @@ INT_PTR BlockFriend(WPARAM hContact, LPARAM lParam) {
DBVARIANT dbv;
- if (!db_get_s(hContact, protocolname, "Username",&dbv))
+ if (!db_get_s(hContact, protocolname, "Username", &dbv))
{
- if (MessageBox(NULL,TranslateT("Block this user from ever contacting you again?"),TranslateT("Block Confirmation"),MB_YESNO|MB_ICONQUESTION)==IDYES)
+ if (MessageBox(NULL, TranslateT("Block this user from ever contacting you again?"), TranslateT("Block Confirmation"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
- if (myClient!=NULL)
+ if (myClient != NULL)
{
if (myClient->client->connected)
{
- db_set_b(NULL,"XFireBlock",dbv.pszVal,1);
+ db_set_b(NULL, "XFireBlock", dbv.pszVal, 1);
SendDenyInvitationPacket deny;
deny.name = dbv.pszVal;
- myClient->client->send( &deny );
+ myClient->client->send(&deny);
}
}
}
@@ -3310,7 +3314,7 @@ INT_PTR StartThisGame(WPARAM wParam, LPARAM lParam) xgamelist.Block(TRUE);
//hole die gameid des spiels
- int id = db_get_w(wParam, protocolname, "GameId",0);
+ int id = db_get_w(wParam, protocolname, "GameId", 0);
//hole passendes spielobjekt
Xfire_game*game = xgamelist.getGamebyGameid(id);
@@ -3331,16 +3335,16 @@ INT_PTR JoinGame(WPARAM hContact, LPARAM lParam) xgamelist.Block(TRUE);
//hole die gameid des spiels
- int id = db_get_w(hContact, protocolname, "GameId",0);
+ int id = db_get_w(hContact, protocolname, "GameId", 0);
//hole passendes spielobjekt
Xfire_game *game = xgamelist.getGamebyGameid(id);
if (game) {
DBVARIANT dbv; //dbv.pszVal
- int port=db_get_w(hContact, protocolname, "Port",0);
- if (!db_get_s(hContact, protocolname, "ServerIP",&dbv)) {
+ int port = db_get_w(hContact, protocolname, "Port", 0);
+ if (!db_get_s(hContact, protocolname, "ServerIP", &dbv)) {
//starte spiel mit netzwerk parametern
- game->start_game(dbv.pszVal,port);
+ game->start_game(dbv.pszVal, port);
db_free(&dbv);
}
}
@@ -3351,9 +3355,9 @@ INT_PTR JoinGame(WPARAM hContact, LPARAM lParam) }
-int doneQuery( WPARAM wParam, LPARAM lParam ) {
+int doneQuery(WPARAM wParam, LPARAM lParam) {
char temp[256];
- BuddyListEntry* bud=(BuddyListEntry*)wParam;
+ BuddyListEntry* bud = (BuddyListEntry*)wParam;
gServerstats* gameinfo = (gServerstats*)lParam;
db_set_s(bud->hcontact, protocolname, "ServerName", gameinfo->name);
db_set_s(bud->hcontact, protocolname, "GameType", gameinfo->gametype);
@@ -3362,8 +3366,8 @@ int doneQuery( WPARAM wParam, LPARAM lParam ) { db_set_s(bud->hcontact, protocolname, "Players", temp);
db_set_b(bud->hcontact, protocolname, "Passworded", gameinfo->password);
- if (myClient!=NULL)
- handlingBuddys(bud,0,NULL,TRUE);
+ if (myClient != NULL)
+ handlingBuddys(bud, 0, NULL, TRUE);
return 0;
}
@@ -3378,16 +3382,16 @@ int IconLibChanged(WPARAM wParam, LPARAM lParam) { char temp[255];
for(int i=0;i<1024;i++)
{
- if (icocache[i].hicon>0)
- {
- //ImageList_ReplaceIcon(hAdvancedStatusIcon,(int)icocache[i].handle,icocache[i].hicon);
- HANDLE before=icocache[i].handle;
- icocache[i].handle=(HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icocache[i].hicon, 0);
- mir_snprintf(temp, SIZEOF(temp), "before: %d after: %d", before, icocache[i].handle);
- MessageBoxA(NULL,temp,temp,0);
- DrawIcon(GetDC(NULL),x,0,(HICON)CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)icocache[i].handle));
- x+=32;
- }
+ if (icocache[i].hicon>0)
+ {
+ //ImageList_ReplaceIcon(hAdvancedStatusIcon,(int)icocache[i].handle,icocache[i].hicon);
+ HANDLE before=icocache[i].handle;
+ icocache[i].handle=(HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)icocache[i].hicon, 0);
+ mir_snprintf(temp, SIZEOF(temp), "before: %d after: %d", before, icocache[i].handle);
+ MessageBoxA(NULL,temp,temp,0);
+ DrawIcon(GetDC(NULL),x,0,(HICON)CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)icocache[i].handle));
+ x+=32;
+ }
}*/
return 0;
}
@@ -3396,17 +3400,17 @@ int IconLibChanged(WPARAM wParam, LPARAM lParam) { INT_PTR GetAvatarInfo(WPARAM wParam, LPARAM lParam) {
PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam;
- if (db_get_b(NULL,protocolname,"noavatars",-1)!=0)
+ if (db_get_b(NULL, protocolname, "noavatars", -1) != 0)
return GAIR_NOAVATAR;
- pai->format=db_get_w(pai->hContact,"ContactPhoto","Format",0);
- if (pai->format==0)
+ pai->format = db_get_w(pai->hContact, "ContactPhoto", "Format", 0);
+ if (pai->format == 0)
return GAIR_NOAVATAR;
DBVARIANT dbv;
- if (!db_get(pai->hContact,"ContactPhoto","File",&dbv))
+ if (!db_get(pai->hContact, "ContactPhoto", "File", &dbv))
{
- strcpy(pai->filename,dbv.pszVal);
+ strcpy(pai->filename, dbv.pszVal);
db_free(&dbv);
}
else
diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index 7465327d41..056bb7b2cd 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -1,5 +1,5 @@ /* - * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network. + * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network. * * Copyright (C) 2010 by * dufte <dufte@justmail.de> @@ -21,7 +21,7 @@ * Based on J. Lawler - BaseProtocol * Herbert Poul/Beat Wolf - xfirelib * - * Miranda ICQ: the free icq client for MS Windows + * Miranda ICQ: the free icq client for MS Windows * Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede * */ @@ -49,64 +49,64 @@ struct mytreeitem { }; extern int bpStatus; -BOOL alreadyInit=FALSE; +BOOL alreadyInit = FALSE; HWND ghwndDlg2; -HWND addgameDialog=NULL; +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"}, + { 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}, + { 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) +static int enumSettingsProc(const char *szSetting, LPARAM lParam) +{ + if (strlen(szSetting) > 0) { - SendDlgItemMessageA( (HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting); + SendDlgItemMessageA((HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting); } EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE); return 0; @@ -115,301 +115,301 @@ static int enumSettingsProc(const char *szSetting,LPARAM lParam) //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]=""; + char inipath[XFIRE_MAX_STATIC_STRING_LEN] = ""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; - static int nomsgboxsel[] = {1,0,2}; + 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 PSM_CHANGED: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; - case WM_INITDIALOG: - { - DBVARIANT dbv; - TranslateDialogDefault(hwndDlg); + case WM_INITDIALOG: + { + DBVARIANT dbv; + TranslateDialogDefault(hwndDlg); - ghwndDlg2=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; - } + 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 ("IconsFile")); - strcat(inipath, "icons.dll"); - - f = fopen(inipath,"r"); - if (f!=NULL) - { - fclose(f); - CheckDlgButton(hwndDlg,IDC_CHKI,1); - dllfound = TRUE; - } - else - dllfound = FALSE; + strcpy(inipath, XFireGetFoldersPath("IniFile")); + strcat(inipath, "xfire_games.ini"); - 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); - } + 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; + } - char temp[255]=""; - mir_snprintf(temp, SIZEOF(temp), "%d", db_get_b(NULL, protocolname, "protover", 0x5b)); - SetDlgItemTextA(hwndDlg,IDC_PVER,temp); + strcpy(inipath, XFireGetFoldersPath("IconsFile")); + strcat(inipath, "icons.dll"); - EnableWindow(GetDlgItem(hwndDlg,IDC_LASTGAME),FALSE); - if (!db_get(NULL,protocolname,"LastGame",&dbv)) { - SetDlgItemTextA(hwndDlg,IDC_LASTGAME,dbv.pszVal); - db_free(&dbv); - } + f = fopen(inipath, "r"); + if (f != NULL) + { + fclose(f); + CheckDlgButton(hwndDlg, IDC_CHKI, 1); + dllfound = TRUE; + } + else + dllfound = FALSE; - if (bpStatus==ID_STATUS_OFFLINE&&bpStatus!=ID_STATUS_CONNECTING) { - EnableDlgItem(hwndDlg, IDC_NICK, FALSE); - } - else + 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++) { - 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) { - 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); - } + CheckDlgButton(hwndDlg, xfireconfigitems[i].id, 1); } - //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren - if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1 )) + else { - CheckDlgButton(hwndDlg,IDC_KONFIG_2,0); - CheckDlgButton(hwndDlg,IDC_KONFIG_3,0); - EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); - EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); + 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; - 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 + 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++) { - 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 (login[i] >= 'A'&&login[i] <= 'Z') + mustlowercase = TRUE; + login[i] = tolower(login[i]); } - if ( LOWORD( wParam ) == IDC_LOSTPW ) { - CallService(MS_UTILS_OPENURL, 1, ( LPARAM )"https://secure.xfire.com/lost_password/" ); - return TRUE; + 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); } - 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; + db_set_s(NULL, protocolname, "login", login); + db_set_s(NULL, protocolname, "Username", login); - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) + //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)) { - 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); - } + if (CallService(XFIRE_SET_NICK, 0, (WPARAM)login)) + db_set_s(NULL, protocolname, "Nick", login); + } + if (dbv.pszVal != NULL) + db_free(&dbv); - db_set_s(NULL,protocolname,"login",login); - db_set_s(NULL,protocolname,"Username",login); + 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)); - //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)) + //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)) { - if (CallService(XFIRE_SET_NICK,0,(WPARAM)login)) - db_set_s(NULL,protocolname,"Nick",login); + 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; } - 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) + else { - 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); + 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)); + //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; - } + 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; } + break; + } } return FALSE; } static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char inipath[XFIRE_MAX_STATIC_STRING_LEN]=""; + char inipath[XFIRE_MAX_STATIC_STRING_LEN] = ""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; - static int nomsgboxsel[] = {1,0,2}; + static int nomsgboxsel[] = { 1, 0, 2 }; static HWND hwndTree = NULL; switch (msg) { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); - hwndTree = GetDlgItem(hwndDlg, IDC_TREE); + hwndTree = GetDlgItem(hwndDlg, IDC_TREE); - SetWindowLongPtr(hwndTree,GWL_STYLE,GetWindowLongPtr(hwndTree,GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); - SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); + 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" )); + 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" )); + //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); + SendDlgItemMessage(hwndDlg, IDC_SCANUPDATECB, CB_SETCURSEL, db_get_b(NULL, protocolname, "scanalways", 0), 0); - /* Gruppen raussuchen */ - { - int gruppen_id=0; - char temp[8]; - DBVARIANT dbv; + 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>" )); + 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); - 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); - } + + 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); } + 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; - } + return TRUE; + } - case DM_REBUILD_TREE: + case DM_REBUILD_TREE: //baue optionsmenü auf TreeView_SelectItem(hwndTree, NULL); ShowWindow(hwndTree, SW_HIDE); @@ -422,259 +422,259 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR tvis.hInsertAfter = TVI_SORT; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; - int size=sizeof(mytree)/sizeof(mytreeitem); + int size = sizeof(mytree) / sizeof(mytreeitem); - for(int i=0;i<size;i++) + 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 ) { + 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.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 ); + 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.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 ); + mytree[i].hitem = TreeView_InsertItem(hwndTree, &tvis); } } - } + } { TVITEM tvi; tvi.hItem = TreeView_GetRoot(hwndTree); - while ( tvi.hItem != NULL ) { + while (tvi.hItem != NULL) { tvi.mask = TVIF_PARAM | TVIF_HANDLE | TVIF_STATE; TreeView_GetItem(hwndTree, &tvi); - if ( tvi.lParam == -1 ) + if (tvi.lParam == -1) TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK); - tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); - } + 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); + case PSM_CHANGED: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; - if (HIWORD(wParam) == CBN_SELCHANGE) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - return 0; - } + case WM_COMMAND: + CheckDlgButton(hwndDlg, IDC_CHKI, dllfound); + CheckDlgButton(hwndDlg, IDC_CHKG, inifound); - 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; + if (HIWORD(wParam) == CBN_SELCHANGE) + { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: + 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 (((LPNMHDR)lParam)->idFrom) + 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 { - 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; - } - } - } + NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam; + if (ptkd&&ptkd->wVKey == VK_SPACE&&TreeView_GetSelection(ptkd->hdr.hwndFrom)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; } - switch (((LPNMHDR)lParam)->code) + case NM_CLICK: //wenn was geklickt wurde, apply aktivieren { - case PSN_APPLY: - { - int reconnectRequired=0; - int ccc; + 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); + 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); - } - } + //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)]); + 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); + 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)); + //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; - } + 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; } + break; + } } return FALSE; } static INT_PTR CALLBACK DlgProcOpts4(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char inipath[XFIRE_MAX_STATIC_STRING_LEN]=""; + char inipath[XFIRE_MAX_STATIC_STRING_LEN] = ""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; - static int nomsgboxsel[] = {1,0,2}; + static int nomsgboxsel[] = { 1, 0, 2 }; static HWND hwndTree = NULL; switch (msg) { - case WM_INITDIALOG: + 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) { - //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; - } + 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; + 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; + //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); + // 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)); + SendMessage(GetDlgItem(hwndDlg, IDC_REMUSER), BM_SETIMAGE, IMAGE_ICON, (WPARAM)LoadSkinnedIcon(SKINICON_OTHER_DELETE)); - strcpy(inipath, XFireGetFoldersPath ("IniFile")); - SetDlgItemTextA(hwndDlg,IDC_FILESSHOULDBE,inipath); + strcpy(inipath, XFireGetFoldersPath("IniFile")); + SetDlgItemTextA(hwndDlg, IDC_FILESSHOULDBE, inipath); - EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE); + EnableDlgItem(hwndDlg, IDC_REMUSER, FALSE); - return TRUE; - } + return TRUE; + } - case PSM_CHANGED: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - 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); + case WM_COMMAND: + CheckDlgButton(hwndDlg, IDC_CHKI, dllfound); + CheckDlgButton(hwndDlg, IDC_CHKG, inifound); - if (LOWORD(wParam) == IDC_REMUSER) //nutzer soll aus der blockierliste raus + 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 { - 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); - } + 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; + 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: + break; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - return TRUE; - } + case PSN_APPLY: + { + return TRUE; + } - } - break; } + break; + } } return FALSE; } @@ -685,73 +685,73 @@ static INT_PTR CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (msg) { - case WM_INITDIALOG: + 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)) { - 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); - } + 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); + EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); + EnableDlgItem(hwndDlg, IDC_ENABLESTSMSG, FALSE); + EnableDlgItem(hwndDlg, IDC_CHGSTATUS, FALSE); + EnableDlgItem(hwndDlg, IDC_DNDFIRST, FALSE); }*/ - return TRUE; - } + return TRUE; + } - case PSM_CHANGED: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; + 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); - } + 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); + 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: + break; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - int reconnectRequired=0; - char str[512]; + case PSN_APPLY: + { + int reconnectRequired = 0; + char str[512]; - GetDlgItemTextA(hwndDlg,IDC_STATUSMSG,str,sizeof(str)); - db_set_s(NULL,protocolname, "setstatusmsg", str); + 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)); + 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; - } + return TRUE; + } - } - break; } + break; + } } return FALSE; } @@ -760,224 +760,225 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { switch (msg) { - case WM_INITDIALOG: - { - addgameDialog=NULL; + case WM_INITDIALOG: + { + addgameDialog = NULL; - TranslateDialogDefault(hwndDlg); + 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); + //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); + //gamelist füllen + SendMessage(hwndDlg, WM_FILLGAMELIST, 0, 0); - //SendMessage(GetDlgItem(hwndDlg,IDC_CREATETXTLIST),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS)); + //SendMessage(GetDlgItem(hwndDlg,IDC_CREATETXTLIST),BM_SETIMAGE,IMAGE_ICON,(WPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS)); - return TRUE; - } - case WM_FILLGAMELIST: + 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++) { - //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; + //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); } - case WM_COMMAND: + return TRUE; + } + case WM_COMMAND: + { + if (LOWORD(wParam) == IDC_REMOVE) { - if (LOWORD(wParam)==IDC_REMOVE) - { - int idx=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + 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); - } + //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) + 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); + //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); - } + //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); + 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); + _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); - } + if (nextgame->skip) + { + xgamelist.appendString("\r\nThis game will be skipped in game detection!",&out); + } - xgamelist.appendString("\r\n",&out); - } + xgamelist.appendString("\r\n",&out); + } - if (OpenClipboard(NULL)) - { - HGLOBAL clipbuffer; - char* buffer; + 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); + EmptyClipboard(); + clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(out)+1); + buffer = (char*)GlobalLock(clipbuffer); + strcpy(buffer, LPCSTR(out)); + GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT, clipbuffer); - CloseClipboard(); - } + SetClipboardData(CF_TEXT, clipbuffer); + CloseClipboard(); + } - if (out!=NULL) delete[] out; + 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); + //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) { + 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); + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); //spielobject holen - Xfire_game* tempgame=xgamelist.getGamebyGameid(gameid); + Xfire_game* tempgame = xgamelist.getGamebyGameid(gameid); //gültiger verweis? if (tempgame) { //editmodus des addgamedialog - AddGameDialog(hwndDlg,tempgame); + 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); + 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); + 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); + 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); + 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) + if (idx != LB_ERR) { //textlänge auslesen - int size=SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0); + int size = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0); //textbuffer anlegen - char* text=new char[size+1]; + char* text = new char[size + 1]; SendDlgItemMessageA(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text); - SetDlgItemTextA(hwndDlg,IDC_GAMENAME,text); + SetDlgItemTextA(hwndDlg, IDC_GAMENAME, text); //textbuffer löschen - if (text!=NULL) + if (text != NULL) { delete text; - text=NULL; + text = NULL; } //id des spielsbekommen - int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); - HICON hicon=xgamelist.iconmngr.getGameIcon(gameid); + HICON hicon = xgamelist.iconmngr.getGameIcon(gameid); //iconhandle holen und setzen if (hicon) - SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,(WPARAM)hicon,0); + SendMessage(GetDlgItem(hwndDlg, IDC_GAMEICO), STM_SETICON, (WPARAM)hicon, 0); else - SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,0,0); + SendMessage(GetDlgItem(hwndDlg, IDC_GAMEICO), STM_SETICON, 0, 0); //elemente aktivieren EnableDlgItem(hwndDlg, IDC_DONTDETECT, TRUE); @@ -989,117 +990,117 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid); if (xgtemp && xgtemp->custom) { - ShowWindow(GetDlgItem(hwndDlg,IDC_MANADDED),SW_SHOW); + 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_MANADDED), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); } //gameskip wert setzen - char temp[64]=""; + char temp[64] = ""; mir_snprintf(temp, SIZEOF(temp), "gameskip_%d", gameid); - CheckDlgButton(hwndDlg,IDC_DONTDETECT,db_get_b(NULL,protocolname,temp,0)); + 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)); + 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)); - + 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)) + if (!db_get(NULL, protocolname, temp, &dbv)) { - SetDlgItemTextA(hwndDlg,IDC_EXTRAPARAMS,dbv.pszVal); + SetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, dbv.pszVal); db_free(&dbv); } else - SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,_T("")); + SetDlgItemText(hwndDlg, IDC_EXTRAPARAMS, _T("")); } else { EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); - SetDlgItemText(hwndDlg,IDC_EXTRAPARAMS,TranslateT("Not supported")); + 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) + } + else if (LOWORD(wParam) == IDC_APPLY) { - int gameid=SendDlgItemMessage( (HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); - int dbid; - - //gamelist blocken - xgamelist.Block(TRUE); - - if (xgamelist.Gameinlist(gameid,&dbid)) + //auswahl speichern + int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + //es wurde was ausgewählt? + if (idx != LB_ERR) { - Xfire_game* game=xgamelist.getGame(dbid); - if (game) + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + int dbid; + + //gamelist blocken + xgamelist.Block(TRUE); + + if (xgamelist.Gameinlist(gameid, &dbid)) { - 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 + Xfire_game* game = xgamelist.getGame(dbid); + if (game) { - //extra parameter leer, wenn gesetzt entfernen/freigeben - if (game->extraparams) + 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) { - delete[] game->extraparams; - game->extraparams=NULL; + //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); + game->refreshMenuitem(); + game->writeToDB(dbid); - SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Configuration saved!")); + 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?!")); + SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); } - } - else - { - SetDlgItemText(hwndDlg,IDC_TEXTSTATUS,TranslateT("Game not found?!")); - } - //gamelist unblocken - xgamelist.Block(FALSE); + //gamelist unblocken + xgamelist.Block(FALSE); + } } - } break; - } - - case WM_NOTIFY: - { - break; - } + } + + case WM_NOTIFY: + { + break; + } } return FALSE; } -int OptInit(WPARAM wParam,LPARAM) +int OptInit(WPARAM wParam, LPARAM) { ghwndDlg2 = NULL; @@ -1107,7 +1108,7 @@ int OptInit(WPARAM wParam,LPARAM) odp.hInstance = hinstance; odp.ptszTitle = LPGENT("XFire"); odp.ptszGroup = LPGENT("Network"); - odp.flags = ODPF_BOLDGROUPS| ODPF_TCHAR; + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; odp.pfnDlgProc = DlgProcOpts2; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTLOGIN); diff --git a/protocols/Xfire/src/passworddialog.cpp b/protocols/Xfire/src/passworddialog.cpp index 3141f82962..c395f3f630 100644 --- a/protocols/Xfire/src/passworddialog.cpp +++ b/protocols/Xfire/src/passworddialog.cpp @@ -4,56 +4,56 @@ #include "passworddialog.h"
static char nick[255];
-BOOL usenick=FALSE;
+BOOL usenick = FALSE;
INT_PTR CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static char* pw[255];
switch (msg)
{
- case WM_CLOSE:
- {
- GetDlgItemTextA(hwndDlg,IDC_PWSTRING,(LPSTR)pw,254);
- if (usenick)
- GetDlgItemTextA(hwndDlg,IDC_PWNICK,(LPSTR)nick,254);
- EndDialog(hwndDlg,(INT_PTR)pw);
- break;
- }
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- //passwort und nick leeren
- pw[0]=0;
- nick[0]=0;
- SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
- if (!usenick)
- EnableWindow(GetDlgItem(hwndDlg,IDC_PWNICK),FALSE);
+ case WM_CLOSE:
+ {
+ GetDlgItemTextA(hwndDlg, IDC_PWSTRING, (LPSTR)pw, 254);
+ if (usenick)
+ GetDlgItemTextA(hwndDlg, IDC_PWNICK, (LPSTR)nick, 254);
+ EndDialog(hwndDlg, (INT_PTR)pw);
+ break;
+ }
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ //passwort und nick leeren
+ pw[0] = 0;
+ nick[0] = 0;
+ SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ if (!usenick)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PWNICK), FALSE);
- return TRUE;
- }
- case WM_COMMAND:
- {
- if (LOWORD(wParam) == IDC_BTN4) {
- SendMessage(hwndDlg,WM_CLOSE,0,0);
- }
- break;
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (LOWORD(wParam) == IDC_BTN4) {
+ SendMessage(hwndDlg, WM_CLOSE, 0, 0);
}
+ break;
+ }
}
return FALSE;
}
-void ShowPasswordDialog(char*pw,char*mynick) {
- if (mynick!=NULL)
+void ShowPasswordDialog(char*pw, char*mynick) {
+ if (mynick != NULL)
{
- usenick=TRUE;
+ usenick = TRUE;
}
else
- usenick=FALSE;
+ usenick = FALSE;
- char* npw = (char*)DialogBox(hinstance,MAKEINTRESOURCE(IDD_PWDLG),NULL,DlgPWProc);
- strcpy(pw,npw);
+ char* npw = (char*)DialogBox(hinstance, MAKEINTRESOURCE(IDD_PWDLG), NULL, DlgPWProc);
+ strcpy(pw, npw);
if (mynick)
{
- strcpy(mynick,(char*)nick);
+ strcpy(mynick, (char*)nick);
}
}
\ No newline at end of file diff --git a/protocols/Xfire/src/passworddialog.h b/protocols/Xfire/src/passworddialog.h index 4078c766df..0ac99e3aff 100644 --- a/protocols/Xfire/src/passworddialog.h +++ b/protocols/Xfire/src/passworddialog.h @@ -1,4 +1,4 @@ #include "baseProtocol.h"
#include "resource.h"
-void ShowPasswordDialog(char*pw,char*mynick=NULL);
\ No newline at end of file +void ShowPasswordDialog(char*pw, char*mynick = NULL);
\ No newline at end of file diff --git a/protocols/Xfire/src/processbuddyinfo.cpp b/protocols/Xfire/src/processbuddyinfo.cpp index 014894cf54..68a5994d34 100644 --- a/protocols/Xfire/src/processbuddyinfo.cpp +++ b/protocols/Xfire/src/processbuddyinfo.cpp @@ -16,75 +16,75 @@ extern HANDLE XFireAvatarFolder; //vom Yahoo plugin
/*int avt_hash(const char *key, DWORD ksize)
{
- const char *p = key;
- int h = *p;
- long l = 1;
-
- if (h)
- for (p += 1; l < ksize; p++, l++)
- h = (h << 5) - h + *p;
-
- return h;
+const char *p = key;
+int h = *p;
+long l = 1;
+
+if (h)
+for (p += 1; l < ksize; p++, l++)
+h = (h << 5) - h + *p;
+
+return h;
}*/
-void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo,MCONTACT hcontact,char* username) {
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact, char* username) {
char temp[255] = "";
char filename[1024] = "";
- BOOL dl=FALSE;
+ BOOL dl = FALSE;
int type;
//versuche doppeltes laden zuvermeiden
if (hcontact) //avatar von freunden
{
- if (db_get_dw(hcontact, "ContactPhoto", "XFireAvatarId", 0)==buddyinfo->avatarid &&
- db_get_b(hcontact, "ContactPhoto", "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ if (db_get_dw(hcontact, "ContactPhoto", "XFireAvatarId", 0) == buddyinfo->avatarid &&
+ db_get_b(hcontact, "ContactPhoto", "XFireAvatarMode", 0) == buddyinfo->avatarmode)
return;
}
else //eigeneder avatar
{
- if (db_get_dw(hcontact, protocolname, "XFireAvatarId", 0)==buddyinfo->avatarid &&
- db_get_b(hcontact, protocolname, "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ if (db_get_dw(hcontact, protocolname, "XFireAvatarId", 0) == buddyinfo->avatarid &&
+ db_get_b(hcontact, protocolname, "XFireAvatarMode", 0) == buddyinfo->avatarmode)
return;
//alten dateipfad des avatars löschen, wenn sichw as geändert hat
- db_unset(NULL,protocolname, "MyAvatarFile");
+ db_unset(NULL, protocolname, "MyAvatarFile");
}
- strcpy(filename, XFireGetFoldersPath ("Avatar"));
-
- switch(buddyinfo->avatarmode) {
- case 1:
- strcat(filename,username);
- strcat(filename,".gif");
- type=PA_FORMAT_GIF;
-
- mir_snprintf(temp, SIZEOF(temp), "/xfire/xf/images/avatars/gallery/default/%03d.gif", buddyinfo->avatarid);
-
- dl=GetWWWContent("media.xfire.com",temp,filename,FALSE);
- break;
- case 2:
- strcat(filename,username);
- strcat(filename,".jpg");
- type=PA_FORMAT_JPEG;
-
- mir_snprintf(temp, SIZEOF(temp), "/avatar/100/%s.jpg?%d", username, buddyinfo->avatarid);
-
- dl=GetWWWContent("screenshot.xfire.com",temp,filename,FALSE);
- break;
- case 3:
- type=PA_FORMAT_GIF;
- strcat(filename,"xfire.gif");
-
- mir_snprintf(temp, SIZEOF(temp), "/xfire/xf/images/avatars/gallery/default/xfire.gif", buddyinfo->avatarid);
-
- dl=GetWWWContent("media.xfire.com",temp,filename,TRUE);
- break;
- default:
- return;
+ strcpy(filename, XFireGetFoldersPath("Avatar"));
+
+ switch (buddyinfo->avatarmode) {
+ case 1:
+ strcat(filename, username);
+ strcat(filename, ".gif");
+ type = PA_FORMAT_GIF;
+
+ mir_snprintf(temp, SIZEOF(temp), "/xfire/xf/images/avatars/gallery/default/%03d.gif", buddyinfo->avatarid);
+
+ dl = GetWWWContent("media.xfire.com", temp, filename, FALSE);
+ break;
+ case 2:
+ strcat(filename, username);
+ strcat(filename, ".jpg");
+ type = PA_FORMAT_JPEG;
+
+ mir_snprintf(temp, SIZEOF(temp), "/avatar/100/%s.jpg?%d", username, buddyinfo->avatarid);
+
+ dl = GetWWWContent("screenshot.xfire.com", temp, filename, FALSE);
+ break;
+ case 3:
+ type = PA_FORMAT_GIF;
+ strcat(filename, "xfire.gif");
+
+ mir_snprintf(temp, SIZEOF(temp), "/xfire/xf/images/avatars/gallery/default/xfire.gif", buddyinfo->avatarid);
+
+ dl = GetWWWContent("media.xfire.com", temp, filename, TRUE);
+ break;
+ default:
+ return;
}
- if (dl!=FALSE)
+ if (dl != FALSE)
{
if (hcontact) //buddyavatar setzen
{
@@ -94,17 +94,17 @@ void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo,MCONTACT hcontact,cha AI.cbSize = sizeof(AI);
AI.format = type;
AI.hContact = hcontact;
- lstrcpy(AI.filename,_A2T(filename));
- ProtoBroadcastAck(protocolname, hcontact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS,(HANDLE) &AI, 0);
+ lstrcpy(AI.filename, _A2T(filename));
+ ProtoBroadcastAck(protocolname, hcontact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&AI, 0);
}
else //eigenen avatar setzen
{
db_set_dw(NULL, protocolname, "XFireAvatarId", buddyinfo->avatarid);
db_set_b(NULL, protocolname, "XFireAvatarMode", buddyinfo->avatarmode);
//neuen avatarfilepath eintragen
- db_set_s(NULL,protocolname, "MyAvatarFile",filename);
+ db_set_s(NULL, protocolname, "MyAvatarFile", filename);
//beshceid geben, avatar hat sich geändert
- CallService(MS_AV_REPORTMYAVATARCHANGED,(WPARAM)protocolname,0);
+ CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)protocolname, 0);
}
}
}
\ No newline at end of file diff --git a/protocols/Xfire/src/processbuddyinfo.h b/protocols/Xfire/src/processbuddyinfo.h index c9f3e396b9..38b9bf482d 100644 --- a/protocols/Xfire/src/processbuddyinfo.h +++ b/protocols/Xfire/src/processbuddyinfo.h @@ -4,4 +4,4 @@ #include "getbuddyinfo.h"
#include "buddyinfo.h"
-void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact,char* username);
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact, char* username);
diff --git a/protocols/Xfire/src/pwd_dlg.cpp b/protocols/Xfire/src/pwd_dlg.cpp index 256c30eac7..c9e0316627 100644 --- a/protocols/Xfire/src/pwd_dlg.cpp +++ b/protocols/Xfire/src/pwd_dlg.cpp @@ -3,49 +3,49 @@ #include "stdafx.h"
#include "pwd_dlg.h"
-char password[256]="";
+char password[256] = "";
INT_PTR CALLBACK DlgPwProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
+ {
+ SetWindowText(hwndDlg, LPGENT("Please enter server password..."));
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (LOWORD(wParam) == IDOK)
{
- SetWindowText(hwndDlg, LPGENT("Please enter server password..."));
- TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ GetDlgItemTextA(hwndDlg, IDC_NICKNAME, password, sizeof(password));
+ EndDialog(hwndDlg, TRUE);
return TRUE;
}
- case WM_COMMAND:
+ else if (LOWORD(wParam) == IDCANCEL)
{
- if (LOWORD(wParam) == IDOK)
- {
- GetDlgItemTextA(hwndDlg,IDC_NICKNAME,password,sizeof(password));
- EndDialog(hwndDlg,TRUE);
- return TRUE;
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg,FALSE);
- return FALSE;
- }
+ EndDialog(hwndDlg, FALSE);
+ return FALSE;
}
}
+ }
return FALSE;
}
BOOL ShowPwdDlg(char* pw) {
//kein gültiges ziel für das eingegebene passwort
- if (&pw==NULL)
+ if (&pw == NULL)
return FALSE;
-
- if (DialogBox(hinstance,MAKEINTRESOURCE(IDD_SETNICKNAME),NULL,DlgPwProc))
+
+ if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgPwProc))
{
//passwort kopieren
if (*password == 0)
return FALSE;
- strcpy_s(pw,255,password);
+ strcpy_s(pw, 255, password);
return TRUE;
}
diff --git a/protocols/Xfire/src/resource.h b/protocols/Xfire/src/resource.h index bf720a50d6..735256afbc 100644 --- a/protocols/Xfire/src/resource.h +++ b/protocols/Xfire/src/resource.h @@ -168,4 +168,4 @@ /*
end of resource.h
-*/
\ No newline at end of file + */
\ No newline at end of file diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp index 4f1bca085c..93851ee494 100644 --- a/protocols/Xfire/src/searching4games.cpp +++ b/protocols/Xfire/src/searching4games.cpp @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -34,51 +34,51 @@ using std::string; extern int foundgames;
extern HANDLE XFireAvatarFolder;
extern HANDLE XFireWorkingFolder;
-extern INT_PTR StartGame(WPARAM wParam, LPARAM lParam,LPARAM fParam);
+extern INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam);
extern Xfire_gamelist xgamelist;
//versucht die * in den pfaden der ini mit dem korrekten eintrag zu ersetzen
-BOOL CheckPath(char*ppath,char*pathwildcard=NULL)
+BOOL CheckPath(char*ppath, char*pathwildcard = NULL)
{
- char* pos=0;
- char* pos2=0;
+ char* pos = 0;
+ char* pos2 = 0;
- pos = strchr(ppath,'*');
+ pos = strchr(ppath, '*');
if (pos)
- {
+ {
HANDLE fHandle;
- WIN32_FIND_DATAA wfd;
- BOOL weiter=TRUE;
+ WIN32_FIND_DATAA wfd;
+ BOOL weiter = TRUE;
if (pathwildcard)
{
- strcpy_s(pathwildcard,XFIRE_MAX_STATIC_STRING_LEN,ppath);
+ strcpy_s(pathwildcard, XFIRE_MAX_STATIC_STRING_LEN, ppath);
}
pos++;
- *pos=0;
+ *pos = 0;
pos++;
-
+
//versuch die exe zu finden
- fHandle=FindFirstFileA(ppath,&wfd); // . skippen
- FindNextFileA(fHandle,&wfd); // .. auch skippen
+ fHandle = FindFirstFileA(ppath, &wfd); // . skippen
+ FindNextFileA(fHandle, &wfd); // .. auch skippen
- while ((FindNextFileA(fHandle,&wfd)&&weiter==TRUE)) // erstes file
+ while ((FindNextFileA(fHandle, &wfd) && weiter == TRUE)) // erstes file
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant
{
char temp[XFIRE_MAX_STATIC_STRING_LEN];
- strcpy(temp,ppath);
- *(temp+strlen(temp)-1)=0;
- strcat(temp,wfd.cFileName);
- strcat(temp,"\\");
- strcat(temp,pos);
+ strcpy(temp, ppath);
+ *(temp + strlen(temp) - 1) = 0;
+ strcat(temp, wfd.cFileName);
+ strcat(temp, "\\");
+ strcat(temp, pos);
- if (GetFileAttributesA(temp)!=0xFFFFFFFF) { //exe vorhanden???? unt hint?
+ if (GetFileAttributesA(temp) != 0xFFFFFFFF) { //exe vorhanden???? unt hint?
//gefundenes in path kopieren
FindClose(fHandle);
- strcpy(ppath,temp);
+ strcpy(ppath, temp);
return TRUE;
}
}
@@ -87,8 +87,8 @@ BOOL CheckPath(char*ppath,char*pathwildcard=NULL) }
else
{
- if (GetFileAttributesA(ppath)!=0xFFFFFFFF) { //exe vorhanden???? unt hint?
- //gefundenes in path kopieren
+ if (GetFileAttributesA(ppath) != 0xFFFFFFFF) { //exe vorhanden???? unt hint?
+ //gefundenes in path kopieren
return TRUE;
}
}
@@ -100,11 +100,11 @@ INT_PTR CALLBACK DlgSearchDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR {
switch (msg)
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- return TRUE;
- }
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ }
}
return FALSE;
@@ -112,46 +112,46 @@ INT_PTR CALLBACK DlgSearchDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR void ShowSearchDialog(LPVOID lparam)
{
- HWND* hwnd=(HWND*)lparam;
- HWND myhwnd=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SEARCHING),NULL,DlgSearchDialogProc);
+ HWND* hwnd = (HWND*)lparam;
+ HWND myhwnd = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_SEARCHING), NULL, DlgSearchDialogProc);
- if (myhwnd==NULL)
+ if (myhwnd == NULL)
return;
- *hwnd=myhwnd;
+ *hwnd = myhwnd;
- ShowWindow(myhwnd,SW_SHOW);
+ ShowWindow(myhwnd, SW_SHOW);
//nachrichten schleife
MSG msg;
- while (GetMessage(&msg,myhwnd,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ while (GetMessage(&msg, myhwnd, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
-void Scan4Games( LPVOID lparam )
+void Scan4Games(LPVOID lparam)
{
- int i=2;
- unsigned int i2=1;
- BOOL split=FALSE;
- int notfound=0;
- char* pos=0;
- char* pos2=0;
+ int i = 2;
+ unsigned int i2 = 1;
+ BOOL split = FALSE;
+ int notfound = 0;
+ char* pos = 0;
+ char* pos2 = 0;
char *cutforlaunch = 0;
- char temp[10]="";
- char inipath[XFIRE_MAX_STATIC_STRING_LEN]="";
- char ret[XFIRE_MAX_STATIC_STRING_LEN]="";
- char gamename[XFIRE_MAX_STATIC_STRING_LEN]="";
- char ret2[XFIRE_MAX_STATIC_STRING_LEN]="";
- char gamelist[XFIRE_MAX_STATIC_STRING_LEN]="";
- BOOL multiexe=FALSE;
- BOOL somethingfound=TRUE;
- int i3=0;
- DWORD gpps=1;
- DWORD last_gpps=0;
- static BOOL searching=FALSE;
+ char temp[10] = "";
+ char inipath[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char ret[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char gamename[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char ret2[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char gamelist[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ BOOL multiexe = FALSE;
+ BOOL somethingfound = TRUE;
+ int i3 = 0;
+ DWORD gpps = 1;
+ DWORD last_gpps = 0;
+ static BOOL searching = FALSE;
//ich suche schon,also raushier
if (searching)
@@ -168,60 +168,60 @@ void Scan4Games( LPVOID lparam ) //gamelist blocken, damit nur 1 thread es ausführt/nutzt
xgamelist.Block(TRUE);
- searching=TRUE;
+ searching = TRUE;
//säubert die gameliste für eine neuauslesung
xgamelist.clearGamelist();
//prüfe ob schon gescannt wurde, dann das aus der db nehmen, beschleunigt den start
- foundgames=db_get_w(NULL, protocolname, "foundgames",-1);
+ foundgames = db_get_w(NULL, protocolname, "foundgames", -1);
//um bei einer neuen version einen rescan zuforcen, bei bestimmten wert found auf 0 resetten
- if (db_get_w(NULL, protocolname, "scanver",0)!=XFIRE_SCAN_VAL)
- foundgames=-1;
+ if (db_get_w(NULL, protocolname, "scanver", 0) != XFIRE_SCAN_VAL)
+ foundgames = -1;
- BOOL loadgamesfromdb=FALSE;
- if (db_get_b(NULL,protocolname,"scanalways",0)==0)
- loadgamesfromdb=TRUE;
+ BOOL loadgamesfromdb = FALSE;
+ if (db_get_b(NULL, protocolname, "scanalways", 0) == 0)
+ loadgamesfromdb = TRUE;
else
{
- if (db_get_b(NULL,protocolname,"scanalways",0)==2)
+ if (db_get_b(NULL, protocolname, "scanalways", 0) == 2)
{
time_t zeit;
struct tm *t;
time(&zeit);
t = localtime(&zeit);
- if (t!=NULL)
+ if (t != NULL)
{
- if (t->tm_yday!=db_get_w(NULL,protocolname,"scanalways_t",0))
+ if (t->tm_yday != db_get_w(NULL, protocolname, "scanalways_t", 0))
{
- db_set_w(NULL,protocolname,"scanalways_t",t->tm_yday);
+ db_set_w(NULL, protocolname, "scanalways_t", t->tm_yday);
}
else
- loadgamesfromdb=TRUE;
+ loadgamesfromdb = TRUE;
}
}
}
//spiele von db laden
if (loadgamesfromdb)
- if (foundgames>0)
+ if (foundgames > 0)
{
- //spieliste einlesen
- xgamelist.readGamelist(foundgames);
- //menüpunkte anlegen
- xgamelist.createStartmenu();
+ //spieliste einlesen
+ xgamelist.readGamelist(foundgames);
+ //menüpunkte anlegen
+ xgamelist.createStartmenu();
- //gamelist unblocken
- xgamelist.Block(FALSE);
+ //gamelist unblocken
+ xgamelist.Block(FALSE);
- searching=FALSE;
- return;
+ searching = FALSE;
+ return;
}
- else if (foundgames==0)
+ else if (foundgames == 0)
{
- searching=FALSE;
+ searching = FALSE;
//dummymenü punkt entfernen
//CallService(MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )dummymenu, 0 );
@@ -231,26 +231,26 @@ void Scan4Games( LPVOID lparam ) return;
}
else
- foundgames=0;
+ foundgames = 0;
else
- foundgames=0;
+ foundgames = 0;
- HWND hwnd=NULL;
+ HWND hwnd = NULL;
//suche dialog anzeigen
- if (!db_get_b(NULL,protocolname,"dontdissstatus",0))
+ if (!db_get_b(NULL, protocolname, "dontdissstatus", 0))
{
- mir_forkthread(ShowSearchDialog,&hwnd);
+ mir_forkthread(ShowSearchDialog, &hwnd);
}
- strcpy(inipath, XFireGetFoldersPath ("IniFile"));
- strcat(inipath,"xfire_games.ini");
+ strcpy(inipath, XFireGetFoldersPath("IniFile"));
+ strcat(inipath, "xfire_games.ini");
//erstmal db säubern
xgamelist.clearDatabase();
//maximal 200 notfounds, um die nicht belegten id's zu überspringen
- while(notfound<200)
+ while (notfound < 200)
{
//2 gameids?
if (split)
@@ -261,43 +261,43 @@ void Scan4Games( LPVOID lparam ) //MessageBox(0,temp,temp,0);
//letztes ergeniss sichern
- last_gpps=gpps;
+ last_gpps = gpps;
//las ma mal suchen...
- gpps=xfire_GetPrivateProfileString(temp, "LongName", "", gamename, 255, inipath);
+ gpps = xfire_GetPrivateProfileString(temp, "LongName", "", gamename, 255, inipath);
- char entrytype[100]="";
- if (gpps!=NULL) xfire_GetPrivateProfileString(temp, "SoftwareType", "", entrytype, 100, inipath);
+ char entrytype[100] = "";
+ if (gpps != NULL) xfire_GetPrivateProfileString(temp, "SoftwareType", "", entrytype, 100, inipath);
//kein eintrag? voicechat? musiapplicationen? schon in der gameliste?
- if (gpps!=NULL && strcmp(entrytype,"Music")!=0 && strcmp(entrytype,"VoiceChat")!=0 && !xgamelist.Gameinlist(i)) //was gefunden und noch nicht eintragen?
+ if (gpps != NULL && strcmp(entrytype, "Music") != 0 && strcmp(entrytype, "VoiceChat") != 0 && !xgamelist.Gameinlist(i)) //was gefunden und noch nicht eintragen?
{
- BOOL MatchExe=FALSE;
+ BOOL MatchExe = FALSE;
//MatchExe Games in der automatischen Suche skippen
if (xfire_GetPrivateProfileString(temp, "MatchExe", "", ret, 255, inipath))
- MatchExe=TRUE;
+ MatchExe = TRUE;
//Registryschlüssel auslesen und pfad auf exe prüfen
xfire_GetPrivateProfileString(temp, "LauncherDirKey", "", ret, 255, inipath);
- strcpy(ret2,ret);
+ strcpy(ret2, ret);
//ersten part des registry schlüssel raustrennen
- pos=strchr(ret2,'\\');
- if (!MatchExe && pos!=0)
+ pos = strchr(ret2, '\\');
+ if (!MatchExe && pos != 0)
{
- HKEY hkey,hsubk;
+ HKEY hkey, hsubk;
- *pos=0; //string trennen
+ *pos = 0; //string trennen
pos++;
- pos2=strrchr(pos,'\\'); //key trennen
- if (pos!=0)
+ pos2 = strrchr(pos, '\\'); //key trennen
+ if (pos != 0)
{
- *pos2=0;
+ *pos2 = 0;
pos2++;
//HKEY festlegen
- switch(*(ret2+6))
+ switch (*(ret2 + 6))
{
case 'L':
hkey = HKEY_CLASSES_ROOT;
@@ -308,7 +308,7 @@ void Scan4Games( LPVOID lparam ) case 'O':
hkey = HKEY_LOCAL_MACHINE;
break;
- default:
+ default:
hkey = NULL;
}
}
@@ -317,70 +317,70 @@ void Scan4Games( LPVOID lparam ) if (hkey) //nur wenn der key erkannt wurde
{
- if (RegOpenKeyA(hkey,pos,&hsubk) == ERROR_SUCCESS) //key versuchen zu "öffnen"
+ if (RegOpenKeyA(hkey, pos, &hsubk) == ERROR_SUCCESS) //key versuchen zu "öffnen"
{
- char path[XFIRE_MAX_STATIC_STRING_LEN]="";
- char path_r[XFIRE_MAX_STATIC_STRING_LEN]="";
- DWORD size=sizeof(path);
-
+ char path[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ char path_r[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ DWORD size = sizeof(path);
+
//key lesen
- if (RegQueryValueExA(hsubk,pos2,NULL,NULL,(LPBYTE)path,&size)== ERROR_SUCCESS)
+ if (RegQueryValueExA(hsubk, pos2, NULL, NULL, (LPBYTE)path, &size) == ERROR_SUCCESS)
{
//zusätzlichen pfad anhängen
if (xfire_GetPrivateProfileString(temp, "LauncherDirAppend", "", ret2, 255, inipath))
{
- if (*(path+strlen(path)-1)=='\\'&&*(ret2)=='\\')
- strcat(path,(ret2+1));
+ if (*(path + strlen(path) - 1) == '\\'&&*(ret2) == '\\')
+ strcat(path, (ret2 + 1));
else
- strcat(path,ret2);
+ strcat(path, ret2);
}
if (xfire_GetPrivateProfileString(temp, "LauncherDirTruncAt", "", ret2, 255, inipath))
{
//mögliches erstes anführungszeichen entfernen
- if (*(path)=='"')
+ if (*(path) == '"')
{
- pos2=path;
+ pos2 = path;
pos2++;
- strcpy(path,pos2);
+ strcpy(path, pos2);
}
-
+
//mögliche weitere anführungszeichen entfernen
- pos=strchr(path,'"');
- if (pos!=0)
- *pos=0;
+ pos = strchr(path, '"');
+ if (pos != 0)
+ *pos = 0;
- if (*(path+strlen(path)-1)!='\\')
- *(path+strlen(path)-strlen(ret2))=0;
+ if (*(path + strlen(path) - 1) != '\\')
+ *(path + strlen(path) - strlen(ret2)) = 0;
}
- if (*(path+strlen(path)-1)!='\\')
- strcat(path,"\\");
+ if (*(path + strlen(path) - 1) != '\\')
+ strcat(path, "\\");
//dateiname auslesen
if (xfire_GetPrivateProfileString(temp, "InstallHint", "", ret2, 255, inipath))
{
char pathtemp[XFIRE_MAX_STATIC_STRING_LEN];
- strcpy(pathtemp,path);
- strcat(pathtemp,ret2);
-
+ strcpy(pathtemp, path);
+ strcat(pathtemp, ret2);
+
if (CheckPath(pathtemp))
{
if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret, 255, inipath))
{
- cutforlaunch=path+strlen(path);
- strcpy(pathtemp,path);
+ cutforlaunch = path + strlen(path);
+ strcpy(pathtemp, path);
//wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
- if (ret[0]=='\\')
+ if (ret[0] == '\\')
{
- strcat(pathtemp,(char*)&ret[1]);
+ strcat(pathtemp, (char*)&ret[1]);
}
else
{
- strcat(pathtemp,ret);
+ strcat(pathtemp, ret);
}
if (CheckPath(pathtemp))
@@ -389,106 +389,106 @@ void Scan4Games( LPVOID lparam ) }
else
{
- *(path)=0;
+ *(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
+ else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
{
- cutforlaunch=path+strlen(path);
- strcat(path,ret2);
+ cutforlaunch = path + strlen(path);
+ strcat(path, ret2);
}
}
else
{
- *(path)=0;
+ *(path) = 0;
}
}
else if (xfire_GetPrivateProfileString(temp, "DetectExe[0]", "", ret2, 255, inipath))
{
- cutforlaunch=path+strlen(path);
- strcat(path,ret2);
- multiexe=TRUE;
- if (!CheckPath(path,path_r))
+ cutforlaunch = path + strlen(path);
+ strcat(path, ret2);
+ multiexe = TRUE;
+ if (!CheckPath(path, path_r))
{
- *(path)=0;
+ *(path) = 0;
}
}
else if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret2, 255, inipath))
{
- cutforlaunch=path+strlen(path);
+ cutforlaunch = path + strlen(path);
//wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
- if (ret2[0]=='\\')
+ if (ret2[0] == '\\')
{
- strcat(path,(char*)&ret2[1]);
+ strcat(path, (char*)&ret2[1]);
}
else
{
- strcat(path,ret2);
+ strcat(path, ret2);
}
- if (!CheckPath(path,path_r))
+ if (!CheckPath(path, path_r))
{
- *(path)=0;
+ *(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
+ else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
{
- cutforlaunch=path+strlen(path);
- strcat(path,ret2);
+ cutforlaunch = path + strlen(path);
+ strcat(path, ret2);
}
//prüfe ob existent, dann ist das spiel installiert
- if (path[0]!=0 && GetFileAttributesA(path)!=0xFFFFFFFF)
+ if (path[0] != 0 && GetFileAttributesA(path) != 0xFFFFFFFF)
{
- Xfire_game* newgame=new Xfire_game();
- newgame->id=i;
+ Xfire_game* newgame = new Xfire_game();
+ newgame->id = i;
//8.3 pfade umwandeln
//GetLongPathNameA(path,path,sizeof(path));
//lowercase pfad
- for(unsigned int ii=0;ii<strlen(path);ii++)
- path[ii]=tolower(path[ii]);
+ for (unsigned int ii = 0; ii < strlen(path); ii++)
+ path[ii] = tolower(path[ii]);
- if (path_r[0]==0)
- newgame->setString(path,&newgame->path);
+ if (path_r[0] == 0)
+ newgame->setString(path, &newgame->path);
else
{
//lowercase wildcard pfad
- for(unsigned int ii=0;ii<strlen(path_r);ii++)
- path_r[ii]=tolower(path_r[ii]);
- newgame->setString(path_r,&newgame->path);
+ for (unsigned int ii = 0; ii < strlen(path_r); ii++)
+ path_r[ii] = tolower(path_r[ii]);
+ newgame->setString(path_r, &newgame->path);
}
//spiel mit mehreren exefiles
if (multiexe)
{
- multiexe=FALSE;
- for(int i=1;i<9;i++)
+ multiexe = FALSE;
+ for (int i = 1; i < 9; i++)
{
mir_snprintf(ret, SIZEOF(ret), "DetectExe[%d]", i);
if (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
{
- char* pos=strrchr(path,'\\');
- if (pos!=0)
+ char* pos = strrchr(path, '\\');
+ if (pos != 0)
{
pos++;
- *pos=0;
- }
- strcat(path,ret2);
+ *pos = 0;
+ }
+ strcat(path, ret2);
if (!CheckPath(path))
{
- *(path)=0;
+ *(path) = 0;
}
else
{
- for(unsigned int i2=0;i2<strlen(path);i2++)
- path[i2]=tolower(path[i2]);
-
- char* mpathtemp=new char[strlen(path)+1];
- strcpy(mpathtemp,path);
+ for (unsigned int i2 = 0; i2 < strlen(path); i2++)
+ path[i2] = tolower(path[i2]);
+
+ char* mpathtemp = new char[strlen(path) + 1];
+ strcpy(mpathtemp, path);
newgame->mpath.push_back(mpathtemp);
}
}
@@ -496,70 +496,70 @@ void Scan4Games( LPVOID lparam ) }
//für launcherstring anpassen
- char* pos=strrchr(path,'\\');
- if (pos!=0)
+ char* pos = strrchr(path, '\\');
+ if (pos != 0)
{
pos++;
- *pos=0;
+ *pos = 0;
}
xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath); // anfügen
- if (cutforlaunch!=0) *cutforlaunch=0;
+ if (cutforlaunch != 0) *cutforlaunch = 0;
//pfad aufbereiten
- char launchpath[XFIRE_MAX_STATIC_STRING_LEN]="";
- strcpy(launchpath,path);
+ char launchpath[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ strcpy(launchpath, path);
//letzten backslash entfernen
- if (launchpath[strlen(launchpath)-1]=='\\') launchpath[strlen(launchpath)-1]=0;
+ if (launchpath[strlen(launchpath) - 1] == '\\') launchpath[strlen(launchpath) - 1] = 0;
- strcat(path,ret2);
+ strcat(path, ret2);
- newgame->setString(path,&newgame->launchparams);
- newgame->appendString(" ",&newgame->launchparams);
+ newgame->setString(path, &newgame->launchparams);
+ newgame->appendString(" ", &newgame->launchparams);
xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath);
- str_replace(ret2,"%UA_LAUNCHER_EXE_DIR%",launchpath);
- str_replace(ret2,"%UA_LAUNCHER_EXE_PATH%",""); //erstmal unwichtige sachen entfernen
+ str_replace(ret2, "%UA_LAUNCHER_EXE_DIR%", launchpath);
+ str_replace(ret2, "%UA_LAUNCHER_EXE_PATH%", ""); //erstmal unwichtige sachen entfernen
//str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
- str_replace(ret2,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
-
- newgame->appendString(ret2,&newgame->launchparams);
+ str_replace(ret2, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen
+
+ newgame->appendString(ret2, &newgame->launchparams);
/*if (xfire_GetPrivateProfileString(temp, "LauncherLoginArgs", "", ret2, 512, inipath))
{
- str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",ret2); // - auch entfernen
+ str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",ret2); // - auch entfernen
}
else*/
// str_replace(xf[foundgames].launchparams,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
if (xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->pwparams);
-
+ newgame->setString(ret2, &newgame->pwparams);
+
if (xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->networkparams);
+ newgame->setString(ret2, &newgame->networkparams);
if (xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->mustcontain);
+ newgame->setString(ret2, &newgame->mustcontain);
if (xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath))
- newgame->send_gameid=atoi(ret2);
+ newgame->send_gameid = atoi(ret2);
if (xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath))
- newgame->setstatusmsg=atoi(ret2);
+ newgame->setstatusmsg = atoi(ret2);
//launcherurl?
if (xfire_GetPrivateProfileString(temp, "LauncherUrl", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->launchparams);
+ newgame->setString(ret2, &newgame->launchparams);
//soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt
mir_snprintf(ret, SIZEOF(ret), "CommandLineMustNotContain[0]");
- int i=0;
+ int i = 0;
- while(xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
+ while (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
{
- if (!newgame->notcontain) newgame->setString("",&newgame->notcontain);
- if (i>0)
- newgame->appendString(";",&newgame->notcontain);
- newgame->appendString(ret2,&newgame->notcontain);
+ if (!newgame->notcontain) newgame->setString("", &newgame->notcontain);
+ if (i > 0)
+ newgame->appendString(";", &newgame->notcontain);
+ newgame->appendString(ret2, &newgame->notcontain);
i++;
mir_snprintf(ret, SIZEOF(ret), "CommandLineMustNotContain[%d]", i);
@@ -567,18 +567,18 @@ void Scan4Games( LPVOID lparam ) newgame->setNameandIcon();
- strcat(gamelist,gamename);
- strcat(gamelist,", ");
- if (foundgames%2==1)
- strcat(gamelist,"\r\n");
+ strcat(gamelist, gamename);
+ strcat(gamelist, ", ");
+ if (foundgames % 2 == 1)
+ strcat(gamelist, "\r\n");
xgamelist.Addgame(newgame);
-
+
foundgames++;
- split=FALSE;
+ split = FALSE;
}
-
+
}
RegCloseKey(hsubk);
@@ -590,78 +590,78 @@ void Scan4Games( LPVOID lparam ) {
if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret, 255, inipath))
{
- strcat(ret2,"\\");
- strcat(ret2,ret);
+ strcat(ret2, "\\");
+ strcat(ret2, ret);
}
- str_replace(ret2,"%WINDIR%",getenv("WINDIR"));
- str_replace(ret2,"%ProgramFiles%",getenv("ProgramFiles"));
+ str_replace(ret2, "%WINDIR%", getenv("WINDIR"));
+ str_replace(ret2, "%ProgramFiles%", getenv("ProgramFiles"));
//prüfe ob existent, dann ist das spiel installiert
- if (GetFileAttributesA(ret2)!=0xFFFFFFFF)
+ if (GetFileAttributesA(ret2) != 0xFFFFFFFF)
{
-
- Xfire_game* newgame=new Xfire_game();
- newgame->id=i;
-
+ Xfire_game* newgame = new Xfire_game();
+
+ newgame->id = i;
+
//8.3 pfade umwandeln
//GetLongPathNameA(ret2,ret2,sizeof(ret2));
//lowercase pfad
- for(unsigned int i=0;i<strlen(ret2);i++)
- ret2[i]=tolower(ret2[i]);
+ for (unsigned int i = 0; i < strlen(ret2); i++)
+ ret2[i] = tolower(ret2[i]);
+
+ newgame->setString(ret2, &newgame->path);
- newgame->setString(ret2,&newgame->path);
-
//launch parameterstring
//pfad aufbereiten
- char launchpath[XFIRE_MAX_STATIC_STRING_LEN]="";
- strcpy(launchpath,ret2);
- if (strrchr(launchpath,'\\')!=0)
+ char launchpath[XFIRE_MAX_STATIC_STRING_LEN] = "";
+ strcpy(launchpath, ret2);
+ if (strrchr(launchpath, '\\') != 0)
{
- *(strrchr(launchpath,'\\'))=0;
+ *(strrchr(launchpath, '\\')) = 0;
}
- newgame->setString(ret2,&newgame->launchparams);
- newgame->appendString(" ",&newgame->launchparams);
+ newgame->setString(ret2, &newgame->launchparams);
+ newgame->appendString(" ", &newgame->launchparams);
xfire_GetPrivateProfileString(temp, "Launch", "", ret2, 512, inipath);
- str_replace(ret2,"%UA_LAUNCHER_EXE_DIR%",launchpath);
+ str_replace(ret2, "%UA_LAUNCHER_EXE_DIR%", launchpath);
- str_replace(ret2,"%UA_LAUNCHER_EXE_PATH%",""); //unwichtige sachen entfernen
+ str_replace(ret2, "%UA_LAUNCHER_EXE_PATH%", ""); //unwichtige sachen entfernen
//str_replace(ret2,"%UA_LAUNCHER_EXTRA_ARGS%",""); // - auch entfernen
- str_replace(ret2,"%UA_LAUNCHER_LOGIN_ARGS%",""); // - auch entfernen
+ str_replace(ret2, "%UA_LAUNCHER_LOGIN_ARGS%", ""); // - auch entfernen
- newgame->appendString(ret2,&newgame->launchparams);
+ newgame->appendString(ret2, &newgame->launchparams);
if (xfire_GetPrivateProfileString(temp, "LauncherPasswordArgs", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->pwparams);
-
+ newgame->setString(ret2, &newgame->pwparams);
+
if (xfire_GetPrivateProfileString(temp, "LauncherNetworkArgs", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->networkparams);
+ newgame->setString(ret2, &newgame->networkparams);
if (xfire_GetPrivateProfileString(temp, "CommandLineMustContain[0]", "", ret2, 512, inipath))
- newgame->setString(ret2,&newgame->mustcontain);
+ newgame->setString(ret2, &newgame->mustcontain);
if (xfire_GetPrivateProfileString(temp, "XUSERSendId", "", ret2, 512, inipath))
- newgame->send_gameid=atoi(ret2);
+ newgame->send_gameid = atoi(ret2);
if (xfire_GetPrivateProfileString(temp, "XUSERSetStatusMsg", "", ret2, 512, inipath))
- newgame->setstatusmsg=atoi(ret2);
+ newgame->setstatusmsg = atoi(ret2);
//soll alle string, welche nicht in der commandline eines spiels sein soll in einen string pakcen semikolon getrennt
mir_snprintf(ret, SIZEOF(ret), "CommandLineMustNotContain[0]");
- int i=0;
+ int i = 0;
- while(xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
+ while (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
{
- if (!newgame->notcontain) newgame->setString("",&newgame->notcontain);
- if (i>0)
- newgame->appendString(";",&newgame->notcontain);
- newgame->appendString(ret2,&newgame->notcontain);
+ if (!newgame->notcontain) newgame->setString("", &newgame->notcontain);
+ if (i > 0)
+ newgame->appendString(";", &newgame->notcontain);
+ newgame->appendString(ret2, &newgame->notcontain);
i++;
mir_snprintf(ret, SIZEOF(ret), "CommandLineMustNotContain[%d]", i);
@@ -669,68 +669,68 @@ void Scan4Games( LPVOID lparam ) newgame->setNameandIcon();
- strcat(gamelist,gamename);
- strcat(gamelist,", ");
- if (foundgames%2==1)
- strcat(gamelist,"\r\n");
+ strcat(gamelist, gamename);
+ strcat(gamelist, ", ");
+ if (foundgames % 2 == 1)
+ strcat(gamelist, "\r\n");
xgamelist.Addgame(newgame);
foundgames++;
- split=FALSE;
+ split = FALSE;
}
}
- if (split)
+ if (split)
i2++;
else
i++;
- notfound=0;
+ notfound = 0;
}
- else if (split==FALSE) // nichts gefunden, dann die 2. gameid probieren (games die zb über steam und normal installiert werden können, haben eine 2. id)
+ else if (split == FALSE) // nichts gefunden, dann die 2. gameid probieren (games die zb über steam und normal installiert werden können, haben eine 2. id)
{
- i2=1;
- split=TRUE;
+ i2 = 1;
+ split = TRUE;
}
- else if (split==TRUE&&last_gpps!=NULL) // keine weiteren einträge mit der 2. id gefunden, also wieder mit der normalen weitersuchen
+ else if (split == TRUE&&last_gpps != NULL) // keine weiteren einträge mit der 2. id gefunden, also wieder mit der normalen weitersuchen
{
- split=FALSE;
+ split = FALSE;
i++;
- i2=0;
+ i2 = 0;
}
- else if (split==TRUE&&last_gpps==NULL) // überhaupt nix gefunden, vllt nicht belegete id's, überspringen und "notfound" hochsetzen
+ else if (split == TRUE&&last_gpps == NULL) // überhaupt nix gefunden, vllt nicht belegete id's, überspringen und "notfound" hochsetzen
{
- split=FALSE;
- i2=0;
- if (i==35) //großer sprung unbenutzer id's
- i+=4000;
+ split = FALSE;
+ i2 = 0;
+ if (i == 35) //großer sprung unbenutzer id's
+ i += 4000;
i++;
notfound++;
}
}
- if (hwnd)SetDlgItemText(hwnd,IDC_CURRENTGAME,TranslateT("Write to database..."));
-
+ if (hwnd)SetDlgItemText(hwnd, IDC_CURRENTGAME, TranslateT("Write to database..."));
+
//gefundene games in db eintragen
xgamelist.writeDatabase();
//scanversion setzen, um ungewollten rescan zu vermeiden
db_set_w(NULL, protocolname, "scanver", XFIRE_SCAN_VAL);
- EndDialog(hwnd,0);
+ EndDialog(hwnd, 0);
- if (!db_get_b(NULL,protocolname,"dontdisresults",0))
+ if (!db_get_b(NULL, protocolname, "dontdisresults", 0))
{
- int p=strlen(gamelist)-2;
- if (p>-1)
- gamelist[p]=0; //letztes koma killen
+ int p = strlen(gamelist) - 2;
+ if (p > -1)
+ gamelist[p] = 0; //letztes koma killen
mir_snprintf(ret, SIZEOF(ret), Translate("Games found:%s%s"), "\r\n\r\n", gamelist);
MSGBOX(ret);
}
- searching=FALSE;
+ searching = FALSE;
xgamelist.createStartmenu();
diff --git a/protocols/Xfire/src/services.cpp b/protocols/Xfire/src/services.cpp index a5c2f7d3d6..70a141f6b5 100644 --- a/protocols/Xfire/src/services.cpp +++ b/protocols/Xfire/src/services.cpp @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -21,7 +21,7 @@ * Based on J. Lawler - BaseProtocol
* Herbert Poul/Beat Wolf - xfirelib
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -34,12 +34,12 @@ BOOL IsContactMySelf(std::string buddyusername) { DBVARIANT dbv;
//nur wenn option aktiv, sonst immer FALSE
- if (!db_get_b(NULL,protocolname,"skipmyself",0))
+ if (!db_get_b(NULL, protocolname, "skipmyself", 0))
return FALSE;
- if (!db_get(NULL,protocolname,"login",&dbv))
+ if (!db_get(NULL, protocolname, "login", &dbv))
{
- if (!lstrcmpiA( dbv.pszVal, buddyusername.c_str() ))
+ if (!lstrcmpiA(dbv.pszVal, buddyusername.c_str()))
{
db_free(&dbv);
return TRUE;
@@ -48,15 +48,15 @@ BOOL IsContactMySelf(std::string buddyusername) { }
else
return FALSE;
-
+
return FALSE;
}
//liefert vollendateipfad vom eigenen avatar zurück, wenn definiert
-INT_PTR GetMyAvatar(WPARAM wparam,LPARAM lparam) {
+INT_PTR GetMyAvatar(WPARAM wparam, LPARAM lparam) {
DBVARIANT dbv;
- if (!db_get(NULL,protocolname,"MyAvatarFile",&dbv))
+ if (!db_get(NULL, protocolname, "MyAvatarFile", &dbv))
{
strncpy((char*)wparam, dbv.pszVal, (int)lparam);
db_free(&dbv);
@@ -67,14 +67,14 @@ INT_PTR GetMyAvatar(WPARAM wparam,LPARAM lparam) { }
//liefert vollendateipfad vom eigenen avatar zurück, wenn definiert
-int mBotNotify(WPARAM wparam,LPARAM lparam) {
-
+int mBotNotify(WPARAM wparam, LPARAM lparam) {
+
if (wparam) {
- CallService(MBOT_TRIGGER,(WPARAM)"xfireingame",1);
+ CallService(MBOT_TRIGGER, (WPARAM)"xfireingame", 1);
}
else
{
- CallService(MBOT_TRIGGER,(WPARAM)"xfireingame",0);
+ CallService(MBOT_TRIGGER, (WPARAM)"xfireingame", 0);
}
return 0;
diff --git a/protocols/Xfire/src/services.h b/protocols/Xfire/src/services.h index d77102aa9d..58329d07c3 100644 --- a/protocols/Xfire/src/services.h +++ b/protocols/Xfire/src/services.h @@ -12,7 +12,7 @@ #define MBOT_TRIGGER "MBot/Trigger"
//liefert den eigenen avatar zurück
-INT_PTR GetMyAvatar(WPARAM wparam,LPARAM lparam);
-int mBotNotify(WPARAM wparam,LPARAM lparam);
+INT_PTR GetMyAvatar(WPARAM wparam, LPARAM lparam);
+int mBotNotify(WPARAM wparam, LPARAM lparam);
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/setnickname.cpp b/protocols/Xfire/src/setnickname.cpp index d401959fd0..96e69c6276 100644 --- a/protocols/Xfire/src/setnickname.cpp +++ b/protocols/Xfire/src/setnickname.cpp @@ -7,40 +7,40 @@ INT_PTR CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara {
switch (msg)
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg,WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
- DBVARIANT dbv;
- if (!db_get(NULL,protocolname,"Nick",&dbv)) {
- SetDlgItemTextA(hwndDlg,IDC_NICKNAME,dbv.pszVal);
- db_free(&dbv);
- }
- return TRUE;
+ DBVARIANT dbv;
+ if (!db_get(NULL, protocolname, "Nick", &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_NICKNAME, dbv.pszVal);
+ db_free(&dbv);
}
- case WM_COMMAND:
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ if (LOWORD(wParam) == IDOK)
{
- if (LOWORD(wParam) == IDOK)
- {
- char nick[255];
- GetDlgItemTextA(hwndDlg,IDC_NICKNAME,nick,sizeof(nick));
+ char nick[255];
+ GetDlgItemTextA(hwndDlg, IDC_NICKNAME, nick, sizeof(nick));
- CallService(XFIRE_SET_NICK,0,(LPARAM)nick);
+ CallService(XFIRE_SET_NICK, 0, (LPARAM)nick);
- EndDialog(hwndDlg,TRUE);
- return TRUE;
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg,FALSE);
- return FALSE;
- }
+ EndDialog(hwndDlg, TRUE);
+ return TRUE;
+ }
+ else if (LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hwndDlg, FALSE);
+ return FALSE;
}
}
+ }
return FALSE;
}
BOOL ShowSetNick() {
- return DialogBox(hinstance,MAKEINTRESOURCE(IDD_SETNICKNAME),NULL,DlgNickProc);
+ return DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgNickProc);
}
\ No newline at end of file diff --git a/protocols/Xfire/src/stdafx.h b/protocols/Xfire/src/stdafx.h index c6055649f3..a11577c69c 100644 --- a/protocols/Xfire/src/stdafx.h +++ b/protocols/Xfire/src/stdafx.h @@ -9,12 +9,12 @@ #define _WIN32_WINNT 0x0501 // Ändern Sie dies in den geeigneten Wert für andere Versionen von Windows.
#endif
-#include <sys/types.h> +#include <sys/types.h>
#include <stdio.h>
#include <cstdlib>
#include <tchar.h>
#include <iostream>
-#include <string> +#include <string>
#define uint unsigned int
#define socklen_t int
@@ -35,7 +35,7 @@ #pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
-#include <winsock2.h> +#include <winsock2.h>
#include <gdiplus.h>
#include <Wininet.h>
#include <commctrl.h>
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index 5418a51f7b..42d8299505 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -41,38 +41,38 @@ extern HANDLE hNetlib; 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]); + 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); + 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) +BOOL str_replace(char*src, char*find, char*rep) { string strpath = src; int pos = strpath.find(find); - if (pos>-1) + if (pos > -1) { - char *temp=new char[strlen(src)+strlen(rep)+1]; + char *temp = new char[strlen(src) + strlen(rep) + 1]; - strcpy(temp,src); - *(temp+pos)=0; + strcpy(temp, src); + *(temp + pos) = 0; - strcat(temp,rep); - strcat(temp,(src+pos+strlen(find))); - strcpy(src,temp); + strcat(temp, rep); + strcat(temp, (src + pos + strlen(find))); + strcpy(src, temp); delete temp; @@ -82,7 +82,7 @@ BOOL str_replace(char*src,char*find,char*rep) } /* popup darstellen */ -int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hicon) +int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, HICON hicon) { static signed char bUsePopups = -1; static BOOL bIconsNotLoaded = TRUE; @@ -105,18 +105,18 @@ int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hi if ((uType & MB_ICONMASK) == MB_ICONSTOP) { ppd.lchIcon = hicError; - ppd.colorBack = RGB(191,0,0); - ppd.colorText = RGB(255,245,225); + 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); + 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); + ppd.colorBack = RGB(230, 230, 230); + ppd.colorText = RGB(0, 0, 0); } PUAddPopupT(&ppd); @@ -127,37 +127,37 @@ int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,HICON hi char*menuitemtext(char*mtext) { - static char temp[256]=""; - int anz=0; - int j=0; + static char temp[256] = ""; + int anz = 0; + int j = 0; if (!mtext) return NULL; - int size=strlen(mtext); + int size = strlen(mtext); - if (!size || size>255) + if (!size || size > 255) return mtext; //alle & zeichen zählen - for(int i=0;i<size;i++,j++) + for (int i = 0; i < size; i++, j++) { - temp[j]=mtext[i]; - if (mtext[i]=='&') + temp[j] = mtext[i]; + if (mtext[i] == '&') { j++; - temp[j]='&'; + temp[j] = '&'; } } //terminieren - temp[j]=0; + temp[j] = 0; return temp; } void Message(LPVOID msg) { - switch(db_get_b(NULL,protocolname,"nomsgbox",0)) + switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) { case 1: return; @@ -167,31 +167,31 @@ void Message(LPVOID msg) } MSGBOXPARAMSA mbp; - mbp.cbSize=sizeof(mbp); - mbp.hwndOwner=NULL; - mbp.hInstance=hinstance; - mbp.lpszText=(char*)msg; + 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; + 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)) + static BOOL already = FALSE; + switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) { case 0: if (!already) { - already=TRUE; //keine doppelte fehlernachrichten + already = TRUE; //keine doppelte fehlernachrichten Message(msg); - already=FALSE; + already = FALSE; } break; case 2: @@ -203,38 +203,38 @@ void MessageE(LPVOID msg) //funktion soll pfad erkennen und zurückgeben char* GetLaunchPath(char*launch) { - static char temp[XFIRE_MAX_STATIC_STRING_LEN]=""; - char find[]=".exe "; //gesucht wird + static char temp[XFIRE_MAX_STATIC_STRING_LEN] = ""; + char find[] = ".exe "; //gesucht wird char * p = temp; char * f = find; - if (launch==NULL) + if (launch == NULL) return temp; - strcpy(temp,launch); + strcpy(temp, launch); - while(*p!=0&&*f!=0) + while (*p != 0 && *f != 0) { - if (tolower(*p)==*f) + if (tolower(*p) == *f) { f++; } else - f=find; + f = find; p++; } - if (*f==0) + if (*f == 0) { - *p=0; + *p = 0; } else return temp; - if (strrchr(temp,'\\')) + if (strrchr(temp, '\\')) { - *(strrchr(temp,'\\'))=0; + *(strrchr(temp, '\\')) = 0; } return temp; @@ -242,89 +242,89 @@ char* GetLaunchPath(char*launch) //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 +#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) +BOOL FindTeamSpeak(DWORD*pid, int*vid) { + BOOL found = FALSE; + if (pid == NULL) return FALSE; - HANDLE hSnapShot = CreateToolhelp32Snapshot ( TH32CS_SNAPALL, 0); + HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0); PROCESSENTRY32* processInfo = new PROCESSENTRY32; - processInfo->dwSize = sizeof ( PROCESSENTRY32); + processInfo->dwSize = sizeof(PROCESSENTRY32); -// XFireLog("Scanning for voiceprograms..."); + // XFireLog("Scanning for voiceprograms..."); - while ( Process32Next ( hSnapShot,processInfo ) != FALSE) + while (Process32Next(hSnapShot, processInfo) != FALSE) { - if (processInfo->th32ProcessID!=0) { - int size=_tcslen(processInfo->szExeFile); + if (processInfo->th32ProcessID != 0) { + int size = _tcslen(processInfo->szExeFile); - if (size==13) + 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') + 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; + *pid = processInfo->th32ProcessID; + found = TRUE; + *vid = 32; break; } } - else if (size==12) + 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') + 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; + *pid = processInfo->th32ProcessID; + found = TRUE; + *vid = 33; break; } } - else if (size==10) + 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') + 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; + *pid = processInfo->th32ProcessID; + found = TRUE; + *vid = 34; break; } } } } - CloseHandle ( hSnapShot); + CloseHandle(hSnapShot); return found; } @@ -333,23 +333,23 @@ BOOL FindTeamSpeak(DWORD*pid,int*vid) { #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) +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; + static int lastip = 0; + static int lastport = 0; + static int lastpid = 0; //DUMP("***Suche IP/Port***",""); - if (pid!=lastpid) + if (pid != lastpid) { - lastip=lastport=0; - lastpid=pid; + lastip = lastport = 0; + lastpid = pid; } - DWORD size=0; + DWORD size = 0; MIB_UDPTABLE_OWNER_PID *ptab; GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); @@ -358,18 +358,18 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, 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) + if (ret == NO_ERROR) { - BOOL notfound=TRUE; - for(unsigned int i=0;i<ptab->dwNumEntries;i++) + BOOL notfound = TRUE; + for (unsigned int i = 0; i < ptab->dwNumEntries; i++) { - if (ptab->table[i].dwOwningPid==pid) //spiel gefunden + 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; + notfound = FALSE; } } if (notfound) //kein port gefunden @@ -391,16 +391,16 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, //socker erstellen SOCKET s; s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); - if (s==INVALID_SOCKET) + if (s == INVALID_SOCKET) { //DUMP("Kann Rawsocket nicht erstellen. Error: %d",WSAGetLastError()); - XFireLog("unable to create raw socket %d",WSAGetLastError()); + XFireLog("unable to create raw socket %d", WSAGetLastError()); closesocket(s); return FALSE; } static struct sockaddr_in msockaddr; - memset(&msockaddr,0,sizeof(msockaddr)); + memset(&msockaddr, 0, sizeof(msockaddr)); msockaddr.sin_addr.s_addr = localaddr; msockaddr.sin_family = AF_INET; msockaddr.sin_port = 0; @@ -409,7 +409,7 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, 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()); + XFireLog("unable to bind raw socket %d", WSAGetLastError()); closesocket(s); return FALSE; } @@ -417,21 +417,21 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, //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) + 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()); + 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)) + static int timeout = 200; + if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) == SOCKET_ERROR)) { - XFireLog("setsockopt(SO_RCVTIMEO) error %d",WSAGetLastError()); + XFireLog("setsockopt(SO_RCVTIMEO) error %d", WSAGetLastError()); } //updstruct, nur mit wichtigen sachen @@ -466,14 +466,14 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, u_short dstport; }; - mpacket temp={0}; //empfamngsbuffer + mpacket temp = { 0 }; //empfamngsbuffer udp * temp2; char * temp3; mpacket2 * temp4; - for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht + for (int I = 0; I < maxuppackets; I++) //maximal 4 packete, das reicht { - int msize=recv(s,(char*)&temp,sizeof(mpacket),0); + int msize = recv(s, (char*)&temp, sizeof(mpacket), 0); if (msize) //empfangen { /*DUMP("Packet empfangen",""); @@ -483,35 +483,35 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, DUMP("Headersize: %d",(temp.ipv & 0x0f)*4);*/ - temp3=(char*)&temp; - temp3+=(temp.ipv & 0x0f)*4; - temp2=(udp*)temp3; - temp4=(mpacket2*)&temp; + 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++) + 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 + 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; + *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) + 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; + 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!"); @@ -521,8 +521,8 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, XFireLog("no serverip found!"); return FALSE; } - /* else if (temp4->srcip==localaddr && temp2->srcport==localport.at(i)) //gesendete gamepackets - { + /* 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; @@ -530,37 +530,37 @@ BOOL GetServerIPPort(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1, *ip4=temp4->ip4; closesocket(s); //socket zumachn return TRUE; - }*/ + }*/ } } - else if (msize==SOCKET_ERROR) + else if (msize == SOCKET_ERROR) { - XFireLog("recv() error %d",WSAGetLastError()); + XFireLog("recv() error %d", WSAGetLastError()); } } closesocket(s); //socket zumachn - lastip=0; - lastport=0; + 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) +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; + static int lastip = 0; + static int lastpid = 0; + static int lastport = 0; - if (pid!=lastpid) + if (pid != lastpid) { - lastip=lastport=0; - lastpid=pid; + lastip = lastport = 0; + lastpid = pid; } - DWORD size=0; + DWORD size = 0; MIB_UDPTABLE_OWNER_PID *ptab; GetExtendedUdpTable(NULL, &size, FALSE, AF_INET, UDP_TABLE_OWNER_PID, 0); @@ -569,25 +569,25 @@ BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1 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) + if (ret == NO_ERROR) { - BOOL notfound=TRUE; - for(unsigned int i=0;i<ptab->dwNumEntries;i++) + BOOL notfound = TRUE; + for (unsigned int i = 0; i < ptab->dwNumEntries; i++) { - if (ptab->table[i].dwOwningPid==pid) //spiel gefunden + 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; + notfound = FALSE; } } if (notfound) //kein port gefunden { - if (lastip!=0) + if (lastip != 0) { - lastip=0; - lastport=0; + lastip = 0; + lastport = 0; return TRUE; } return FALSE; //dann erstmal schluss @@ -604,7 +604,7 @@ BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1 s = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); static struct sockaddr_in msockaddr; - memset(&msockaddr,0,sizeof(msockaddr)); + memset(&msockaddr, 0, sizeof(msockaddr)); msockaddr.sin_addr.s_addr = localaddr; msockaddr.sin_family = AF_INET; msockaddr.sin_port = 0; @@ -619,7 +619,7 @@ BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1 //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) + if (WSAIoctl(s, _WSAIOW(IOC_VENDOR, 1), &I, sizeof(I), NULL, NULL, &b, NULL, NULL) == SOCKET_ERROR) { /*closesocket(s); return FALSE;*/ @@ -628,8 +628,8 @@ BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1 //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)); + static int timeout = 200; + setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)); //updstruct, nur mit wichtigen sachen struct mpacket { @@ -663,87 +663,87 @@ BOOL GetServerIPPort2(DWORD pid,char*localaddrr,unsigned long localaddr,char*ip1 u_short dstport; }; - mpacket temp={0}; //empfamngsbuffer + mpacket temp = { 0 }; //empfamngsbuffer udp * temp2; char * temp3; mpacket2 * temp4; - for (int I=0;I<maxuppackets;I++) //maximal 4 packete, das reicht + for (int I = 0; I < maxuppackets; I++) //maximal 4 packete, das reicht { - int msize=recv(s,(char*)&temp,sizeof(mpacket),0); + 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; + 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 + 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; - } + *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; + 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; + *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; + lastip = 0; + lastport = 0; return TRUE; } -char * getItem(char * string,char delim,int count) +char * getItem(char * string, char delim, int count) { static char item[255]; - char i=0; + char i = 0; - while(*string!='\0'&&count>0) + while (*string != '\0'&&count > 0) { - if (*string==delim) + if (*string == delim) { - item[i]=0; - i=0; + item[i] = 0; + i = 0; count--; string++; } else { - item[i]=*string; + item[i] = *string; i++; string++; } } - if (*string=='\0') - item[i]=0; - if (count>1) - item[0]=0; + if (*string == '\0') + item[i] = 0; + if (count > 1) + item[0] = 0; - for(unsigned int i=0;i<strlen(item);i++) + for (unsigned int i = 0; i < strlen(item); i++) { - item[i]=tolower(item[i]); + item[i] = tolower(item[i]); } return item; @@ -762,7 +762,7 @@ pZwQueryInformationProcess _ZwQueryInformationProcess = NULL; //pZwClose _ZwClose = NULL; pZwReadVirtualMemory _ZwReadVirtualMemory = NULL; -BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) +BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain) { WCHAR * buffer; char * buffer2; @@ -776,89 +776,89 @@ BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) return TRUE; //prüfe und lade nötige funktionen - if (_ZwQueryInformationProcess==NULL) + if (_ZwQueryInformationProcess == NULL) { _ZwQueryInformationProcess = (pZwQueryInformationProcess)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwQueryInformationProcess"); - if (_ZwQueryInformationProcess==NULL) + if (_ZwQueryInformationProcess == NULL) { return TRUE; } } - if (_ZwReadVirtualMemory==NULL) + if (_ZwReadVirtualMemory == NULL) { _ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "ZwReadVirtualMemory"); - if (_ZwReadVirtualMemory==NULL) + if (_ZwReadVirtualMemory == NULL) { return TRUE; } } //commandline bekommen, siehe link oben - ULONG rc = _ZwQueryInformationProcess(hProcess,ProcessBasicInformation,&ProcessInfo,sizeof(ProcessInfo),NULL); + ULONG rc = _ZwQueryInformationProcess(hProcess, ProcessBasicInformation, &ProcessInfo, sizeof(ProcessInfo), NULL); - rc = _ZwReadVirtualMemory(hProcess,ProcessInfo.PebBaseAddress, UserPool, sizeof(PEB), NULL); + rc = _ZwReadVirtualMemory(hProcess, ProcessInfo.PebBaseAddress, UserPool, sizeof(PEB), NULL); peb = (PPEB)UserPool; - rc = _ZwReadVirtualMemory(hProcess,peb->ProcessParameters,UserPool,sizeof(PROCESS_PARAMETERS),NULL); + 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; + uSize = proc_params->CommandLine.Length; + pBaseAddress = proc_params->CommandLine.Buffer; //keine commandline?! - if (uSize==0||pBaseAddress==NULL) + if (uSize == 0 || pBaseAddress == NULL) { LocalFree(UserPool); return FALSE; } - buffer=(WCHAR*)new char[uSize]; + 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); + int correctsize = WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, NULL, 0, NULL, NULL); - if (correctsize==0) + 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; + 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++) + for (unsigned int i = 0; i < strlen(buffer2); i++) { - buffer2[i]=tolower(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]); - } + 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]); - } + for (unsigned int i = 0; i < strlen(mustnotcontain); i++) + { + mustnotcontain[i] = tolower(mustnotcontain[i]); + } - string cmdline=buffer2; + string cmdline = buffer2; if (mustcontain) - if (cmdline.find(mustcontain)!=string::npos) + if (cmdline.find(mustcontain) != string::npos) { - delete[] buffer; - delete[] buffer2; - LocalFree(UserPool); - return TRUE; + delete[] buffer; + delete[] buffer2; + LocalFree(UserPool); + return TRUE; } else { @@ -868,12 +868,12 @@ BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) return FALSE; } - int count=1; + int count = 1; if (mustnotcontain) { - char*str=getItem(mustnotcontain,';',count); + char*str = getItem(mustnotcontain, ';', count); do { - if (cmdline.find(str)!=string::npos) + if (cmdline.find(str) != string::npos) { delete[] buffer; delete[] buffer2; @@ -881,9 +881,8 @@ BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) return FALSE; } count++; - str=getItem(mustnotcontain,';',count); - } - while(*str!=0); + str = getItem(mustnotcontain, ';', count); + } while (*str != 0); } //_ZwClose(hProcess); @@ -897,25 +896,25 @@ BOOL checkCommandLine(HANDLE hProcess,char * mustcontain,char * mustnotcontain) #define RECV_BUFFER_SIZE 6144 BOOL CheckWWWContent(char*address) { - Netlib_Logf(hNetlib,"Check Url %s ...",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 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); + NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlib, (LPARAM)&nlhr); if (nlhrReply) { //nicht auf dem server - Netlib_Logf(hNetlib,"Resultcode %d ...",nlhrReply->resultCode); + Netlib_Logf(hNetlib, "Resultcode %d ...", nlhrReply->resultCode); if (nlhrReply->resultCode != 200) { - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); return FALSE; } - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } else return FALSE; @@ -924,137 +923,137 @@ BOOL CheckWWWContent(char*address) { } -BOOL GetWWWContent2(char*address,char*filename,BOOL dontoverwrite,char**tobuf,unsigned int* size) { - if (dontoverwrite==TRUE) +BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf, unsigned int* size) { + if (dontoverwrite == TRUE) { - if (GetFileAttributesA(filename)!=0xFFFFFFFF) + if (GetFileAttributesA(filename) != 0xFFFFFFFF) { - Netlib_Logf(hNetlib,"%s already exists, no overwrite.",filename); + Netlib_Logf(hNetlib, "%s already exists, no overwrite.", filename); return TRUE; } } - Netlib_Logf(hNetlib,"Download Url %s ...",address); + 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 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); + 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); + 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); + Netlib_Logf(hNetlib, "No data received."); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); return FALSE; } else { - if (tobuf==NULL) + if (tobuf == NULL) { - FILE * f = fopen(filename,"wb"); - if (f==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); + 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); + fwrite(nlhrReply->pData, nlhrReply->dataLength, 1, f); fclose(f); } else { - if (*tobuf==NULL) + if (*tobuf == NULL) { - *tobuf=new char[nlhrReply->dataLength+1]; - memcpy_s(*tobuf,nlhrReply->dataLength,nlhrReply->pData,nlhrReply->dataLength); + *tobuf = new char[nlhrReply->dataLength + 1]; + memcpy_s(*tobuf, nlhrReply->dataLength, nlhrReply->pData, nlhrReply->dataLength); //0 terminieren - (*tobuf)[nlhrReply->dataLength]=0; + (*tobuf)[nlhrReply->dataLength] = 0; //größe zurückliefern, wenn gewollt if (size) - *size=nlhrReply->dataLength+1; + *size = nlhrReply->dataLength + 1; } } } - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } else { - Netlib_Logf(hNetlib,"No valid Netlib Request.",filename); + 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); +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); + return GetWWWContent2(add, filename, dontoverwrite); } unsigned int getfilesize(char*path) { - FILE *f=fopen(path,"rb"); - if (f==NULL) + FILE *f = fopen(path, "rb"); + if (f == NULL) return 0; - fseek (f, 0, SEEK_END); - int size=ftell (f); - fclose (f); + 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) + 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); + 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); + *(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); + return GetPrivateProfileStringA(lpAppName, lpKeyName, lpDefault, lpReturnedString, nSize, lpFileName); } -BOOL mySleep(int ms,HANDLE evt) { - switch(WaitForSingleObject(evt,ms)) +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; + case WAIT_TIMEOUT: + return FALSE; + case WAIT_ABANDONED: + //MessageBoxA(NULL,"Abbruch","Abbruch",0); + return TRUE; + default: + return TRUE; } return FALSE; diff --git a/protocols/Xfire/src/tools.h b/protocols/Xfire/src/tools.h index ca0b906179..7b25e956bf 100644 --- a/protocols/Xfire/src/tools.h +++ b/protocols/Xfire/src/tools.h @@ -12,88 +12,88 @@ using std::string; //get commandline header stuff
//****************************
typedef struct _UNICODE_STRING {
-USHORT Length;
-USHORT MaximumLength;
-PWSTR Buffer;
+ USHORT Length;
+ USHORT MaximumLength;
+ PWSTR Buffer;
} UNICODE_STRING;
typedef UNICODE_STRING *PUNICODE_STRING;
typedef enum _PROCESSINFOCLASS {
- ProcessBasicInformation
+ ProcessBasicInformation
} PROCESSINFOCLASS;
typedef struct _PEB_LDR_DATA {
- BYTE Reserved1[8];
- PVOID Reserved2[3];
- LIST_ENTRY InMemoryOrderModuleList;
-} PEB_LDR_DATA,
- *PPEB_LDR_DATA;
+ BYTE Reserved1[8];
+ PVOID Reserved2[3];
+ LIST_ENTRY InMemoryOrderModuleList;
+} PEB_LDR_DATA,
+*PPEB_LDR_DATA;
typedef struct _RTL_USER_PROCESS_PARAMETERS {
- BYTE Reserved1[16];
- PVOID Reserved2[10];
- UNICODE_STRING ImagePathName;
- UNICODE_STRING CommandLine;
-} RTL_USER_PROCESS_PARAMETERS,
- *PRTL_USER_PROCESS_PARAMETERS;
+ BYTE Reserved1[16];
+ PVOID Reserved2[10];
+ UNICODE_STRING ImagePathName;
+ UNICODE_STRING CommandLine;
+} RTL_USER_PROCESS_PARAMETERS,
+*PRTL_USER_PROCESS_PARAMETERS;
typedef struct _PEB {
- BYTE Reserved1[2];
- BYTE BeingDebugged;
- BYTE Reserved2[1];
- PVOID Reserved3[2];
- PPEB_LDR_DATA Ldr;
- PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
- BYTE Reserved4[104];
- PVOID Reserved5[52];
- void* PostProcessInitRoutine;
- BYTE Reserved6[128];
- PVOID Reserved7[1];
- ULONG SessionId;
-} PEB,
- *PPEB;
+ BYTE Reserved1[2];
+ BYTE BeingDebugged;
+ BYTE Reserved2[1];
+ PVOID Reserved3[2];
+ PPEB_LDR_DATA Ldr;
+ PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
+ BYTE Reserved4[104];
+ PVOID Reserved5[52];
+ void* PostProcessInitRoutine;
+ BYTE Reserved6[128];
+ PVOID Reserved7[1];
+ ULONG SessionId;
+} PEB,
+*PPEB;
typedef struct
{
-ULONG AllocationSize;
-ULONG ActualSize;
-ULONG Flags;
-ULONG Unknown1;
-UNICODE_STRING Unknown2;
-HANDLE InputHandle;
-HANDLE OutputHandle;
-HANDLE ErrorHandle;
-UNICODE_STRING CurrentDirectory;
-HANDLE CurrentDirectoryHandle;
-UNICODE_STRING SearchPaths;
-UNICODE_STRING ApplicationName;
-UNICODE_STRING CommandLine;
-PVOID EnvironmentBlock;
-ULONG Unknown[9];
-UNICODE_STRING Unknown3;
-UNICODE_STRING Unknown4;
-UNICODE_STRING Unknown5;
-UNICODE_STRING Unknown6;
+ ULONG AllocationSize;
+ ULONG ActualSize;
+ ULONG Flags;
+ ULONG Unknown1;
+ UNICODE_STRING Unknown2;
+ HANDLE InputHandle;
+ HANDLE OutputHandle;
+ HANDLE ErrorHandle;
+ UNICODE_STRING CurrentDirectory;
+ HANDLE CurrentDirectoryHandle;
+ UNICODE_STRING SearchPaths;
+ UNICODE_STRING ApplicationName;
+ UNICODE_STRING CommandLine;
+ PVOID EnvironmentBlock;
+ ULONG Unknown[9];
+ UNICODE_STRING Unknown3;
+ UNICODE_STRING Unknown4;
+ UNICODE_STRING Unknown5;
+ UNICODE_STRING Unknown6;
} PROCESS_PARAMETERS, *PPROCESS_PARAMETERS;
typedef struct _PROCESS_BASIC_INFORMATION {
- PVOID Reserved1;
- PPEB PebBaseAddress;
- PVOID Reserved2[2];
- ULONG_PTR UniqueProcessId;
- PVOID Reserved3;
+ PVOID Reserved1;
+ PPEB PebBaseAddress;
+ PVOID Reserved2[2];
+ ULONG_PTR UniqueProcessId;
+ PVOID Reserved3;
} PROCESS_BASIC_INFORMATION;
-typedef ULONG (WINAPI *pZwQueryInformationProcess)(
+typedef ULONG(WINAPI *pZwQueryInformationProcess)(
IN HANDLE ProcessHandle,
IN PROCESSINFOCLASS ProcessInformationClass,
OUT PVOID ProcessInformation,
IN ULONG ProcessInformationLength,
OUT PULONG ReturnLength OPTIONAL
-);
-typedef ULONG (WINAPI *pZwClose)(
+ );
+typedef ULONG(WINAPI *pZwClose)(
IN HANDLE Handle
-);
-typedef ULONG (WINAPI *pZwReadVirtualMemory)(
+ );
+typedef ULONG(WINAPI *pZwReadVirtualMemory)(
IN HANDLE ProcessHandle,
IN PVOID BaseAddress,
OUT PVOID Buffer,
IN ULONG BufferLength,
OUT PULONG ReturnLength OPTIONAL
-);
+ );
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/userdetails.cpp b/protocols/Xfire/src/userdetails.cpp index 96ef2044f2..c5881af8e6 100644 --- a/protocols/Xfire/src/userdetails.cpp +++ b/protocols/Xfire/src/userdetails.cpp @@ -1,5 +1,5 @@ /*
- * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
+ * Plugin of miranda IM(ICQ) for Communicating with users of the XFire Network.
*
* Copyright (C) 2010 by
* dufte <dufte@justmail.de>
@@ -21,7 +21,7 @@ * Based on J. Lawler - BaseProtocol
* Herbert Poul/Beat Wolf - xfirelib
*
- * Miranda ICQ: the free icq client for MS Windows
+ * Miranda ICQ: the free icq client for MS Windows
* Copyright (C) 2000-2008 Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
*/
@@ -32,7 +32,7 @@ #include "Xfire_gamelist.h"
#include <string>
-HWND ghwndDlg=NULL;
+HWND ghwndDlg = NULL;
extern HANDLE XFireWorkingFolder;
extern Xfire_gamelist xgamelist;
@@ -43,55 +43,55 @@ void LoadProfilStatus(LPVOID lparam) { return;
//dl
- char url[255]="http://miniprofile.xfire.com/bg/sh/type/1/";
- char* buf=NULL;
- unsigned int size=0;
- strcat_s(url,255,(char*)lparam);
- strcat_s(url,255,".png");
+ char url[255] = "http://miniprofile.xfire.com/bg/sh/type/1/";
+ char* buf = NULL;
+ unsigned int size = 0;
+ strcat_s(url, 255, (char*)lparam);
+ strcat_s(url, 255, ".png");
//versuche das icon aus dem inet zulasen
- if (GetWWWContent2(url,NULL,FALSE,&buf,&size))
+ if (GetWWWContent2(url, NULL, FALSE, &buf, &size))
{
//aus dem buffer ein hicon erzeugen
- HBITMAP hbitmap=xgamelist.createHBITMAPfromdata(buf,size);
+ HBITMAP hbitmap = xgamelist.createHBITMAPfromdata(buf, size);
//speicher freigeben
delete[] buf;
- SendMessage(GetDlgItem(ghwndDlg,IDC_PROFILIMG),STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hbitmap);
+ SendMessage(GetDlgItem(ghwndDlg, IDC_PROFILIMG), STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbitmap);
}
delete[] lparam;
}
-void SetItemTxt(HWND hwndDlg,int feldid,char*feld,MCONTACT hcontact,int type)
+void SetItemTxt(HWND hwndDlg, int feldid, char*feld, MCONTACT hcontact, int type)
{
DBVARIANT dbv;
- if (!db_get(hcontact,protocolname,feld,&dbv)) {
- if (type==1)
+ if (!db_get(hcontact, protocolname, feld, &dbv)) {
+ if (type == 1)
{
char temp[255];
mir_snprintf(temp, SIZEOF(temp), "%i", dbv.wVal);
- SetDlgItemTextA(hwndDlg,feldid,temp);
+ SetDlgItemTextA(hwndDlg, feldid, temp);
}
else
{
- SetDlgItemTextA(hwndDlg,feldid,dbv.pszVal);
+ SetDlgItemTextA(hwndDlg, feldid, dbv.pszVal);
}
db_free(&dbv);
- EnableDlgItem(hwndDlg,feldid,TRUE);
+ EnableDlgItem(hwndDlg, feldid, TRUE);
}
else
{
- SetDlgItemText(hwndDlg,feldid,TranslateT("<not specified>"));
- EnableDlgItem(hwndDlg,feldid,FALSE);
+ SetDlgItemText(hwndDlg, feldid, TranslateT("<not specified>"));
+ EnableDlgItem(hwndDlg, feldid, FALSE);
}
}
-static int GetIPPortUDetails(MCONTACT hContact,char* feld1,char* feld2)
+static int GetIPPortUDetails(MCONTACT hContact, char* feld1, char* feld2)
{
- if (db_get_w(hContact, protocolname, feld2, -1)==0)
+ if (db_get_w(hContact, protocolname, feld2, -1) == 0)
return 0;
DBVARIANT dbv;
- if (db_get_s(hContact, protocolname, feld1,&dbv))
+ if (db_get_s(hContact, protocolname, feld1, &dbv))
return 0;
char temp[255];
@@ -101,7 +101,7 @@ static int GetIPPortUDetails(MCONTACT hContact,char* feld1,char* feld2) if (OpenClipboard(NULL)) {
EmptyClipboard();
- HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp)+1);
+ HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(temp) + 1);
char *buffer = (char*)GlobalLock(clipbuffer);
strcpy(buffer, LPCSTR(temp));
GlobalUnlock(clipbuffer);
@@ -113,59 +113,59 @@ static int GetIPPortUDetails(MCONTACT hContact,char* feld1,char* feld2) return 0;
}
-void addToList(HWND listbox,MCONTACT hContact,char*key,char*val)
+void addToList(HWND listbox, MCONTACT hContact, char*key, char*val)
{
DBVARIANT dbv;
- if (!db_get_s(hContact,protocolname,val,&dbv)) {
+ if (!db_get_s(hContact, protocolname, val, &dbv)) {
LVITEMA lvitem = { 0 };
- lvitem.mask=LVIF_TEXT;
- lvitem.cchTextMax=255;
- lvitem.pszText=key;
- SendMessageA(listbox,LVM_INSERTITEM,0,(LPARAM)&lvitem);
+ lvitem.mask = LVIF_TEXT;
+ lvitem.cchTextMax = 255;
+ lvitem.pszText = key;
+ SendMessageA(listbox, LVM_INSERTITEM, 0, (LPARAM)&lvitem);
lvitem.iSubItem++;
- lvitem.pszText=dbv.pszVal;
- SendMessageA(listbox,LVM_SETITEM,0,(LPARAM)&lvitem);
+ lvitem.pszText = dbv.pszVal;
+ SendMessageA(listbox, LVM_SETITEM, 0, (LPARAM)&lvitem);
db_free(&dbv);
}
}
-void setGameInfo(HWND listbox,char *mbuf)
+void setGameInfo(HWND listbox, char *mbuf)
{
- int ii=0;
+ int ii = 0;
char temp[255];
- char mod=0;
- char item=0;
- char *mbuf2=(char*)mbuf;
+ char mod = 0;
+ char item = 0;
+ char *mbuf2 = (char*)mbuf;
LVITEMA lvitem;
- memset(&lvitem,0,sizeof(lvitem));
- lvitem.mask=LVIF_TEXT;
- lvitem.cchTextMax=255;
+ memset(&lvitem, 0, sizeof(lvitem));
+ lvitem.mask = LVIF_TEXT;
+ lvitem.cchTextMax = 255;
- while(*mbuf2!=0)
+ while (*mbuf2 != 0)
{
- if (*mbuf2==1&&mod==0)
+ if (*mbuf2 == 1 && mod == 0)
{
- temp[ii]=0;
- mod=1;
- lvitem.iItem=item;
- lvitem.iSubItem=0;
- lvitem.pszText=temp;
- SendMessageA(listbox,LVM_INSERTITEM,0,(LPARAM)&lvitem);
+ temp[ii] = 0;
+ mod = 1;
+ lvitem.iItem = item;
+ lvitem.iSubItem = 0;
+ lvitem.pszText = temp;
+ SendMessageA(listbox, LVM_INSERTITEM, 0, (LPARAM)&lvitem);
item++;
- ii=-1;
+ ii = -1;
}
- else if (*mbuf2==2&&mod==1)
+ else if (*mbuf2 == 2 && mod == 1)
{
- temp[ii]=0;
- mod=0;
+ temp[ii] = 0;
+ mod = 0;
lvitem.iSubItem++;
- lvitem.pszText=temp;
- SendMessageA(listbox,LVM_SETITEM,0,(LPARAM)&lvitem);
- ii=-1;
+ lvitem.pszText = temp;
+ SendMessageA(listbox, LVM_SETITEM, 0, (LPARAM)&lvitem);
+ ii = -1;
}
else
- temp[ii]=*mbuf2;
+ temp[ii] = *mbuf2;
mbuf2++;
ii++;
}
@@ -173,250 +173,250 @@ void setGameInfo(HWND listbox,char *mbuf) static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static char path[XFIRE_MAX_STATIC_STRING_LEN]="";
+ static char path[XFIRE_MAX_STATIC_STRING_LEN] = "";
static WCHAR wpath[256];
- static HICON gameicon=0;
- static HICON voiceicon=0;
- static MCONTACT uhandle=0;
+ static HICON gameicon = 0;
+ static HICON voiceicon = 0;
+ static MCONTACT uhandle = 0;
static HWND listbox;
LVCOLUMNA pcol;
switch (msg)
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- ghwndDlg=hwndDlg;
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
- listbox=GetDlgItem(hwndDlg,IDC_GAMEINFOLIST);
- pcol.mask=LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
- pcol.pszText="Key";
- pcol.cx=65;
- pcol.fmt=LVCFMT_LEFT;
- SendMessageA(listbox,LVM_INSERTCOLUMNA,1,(LPARAM)&pcol);
- pcol.cx=80;
- pcol.pszText="Value";
- SendMessageA(listbox,LVM_INSERTCOLUMNA,2,(LPARAM)&pcol);
+ ghwndDlg = hwndDlg;
- HFONT hFont;
- LOGFONT lfFont;
+ listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST);
+ pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
+ pcol.pszText = "Key";
+ pcol.cx = 65;
+ pcol.fmt = LVCFMT_LEFT;
+ SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol);
+ pcol.cx = 80;
+ pcol.pszText = "Value";
+ SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol);
- memset(&lfFont, 0x00, sizeof(lfFont));
- memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
+ HFONT hFont;
+ LOGFONT lfFont;
- lfFont.lfHeight = 13;
- lfFont.lfWeight = FW_BOLD;
- lfFont.lfCharSet = ANSI_CHARSET;
- lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lfFont.lfQuality = DEFAULT_QUALITY;
+ memset(&lfFont, 0x00, sizeof(lfFont));
+ memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
- // Create the font from the LOGFONT structure passed.
- hFont = CreateFontIndirect (&lfFont);
+ lfFont.lfHeight = 13;
+ lfFont.lfWeight = FW_BOLD;
+ lfFont.lfCharSet = ANSI_CHARSET;
+ lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lfFont.lfQuality = DEFAULT_QUALITY;
- SendMessageA(listbox,WM_SETFONT,(WPARAM)hFont,TRUE);
+ // Create the font from the LOGFONT structure passed.
+ hFont = CreateFontIndirect(&lfFont);
- return TRUE;
- }
- case WM_CTLCOLORSTATIC:
- {
- break;
- }
+ SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE);
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
-
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
-
- case PSN_INFOCHANGED:
- {
- char* szProto;
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
- uhandle=hContact; //handle sichern
-
- if (hContact == NULL)
- szProto = protocolname;
- else
- szProto = GetContactProto(hContact);
-
- if (szProto == NULL)
- break;
-
- //alle items aus der liste entfernen
- SendMessage(listbox,LVM_DELETEALLITEMS,0,0);
-
- if (hContact)
- {
- DBVARIANT dbv;
- if (!db_get(hContact,protocolname,"Username",&dbv))
- {
- int usernamesize=strlen(dbv.pszVal)+1;
- char* username=new char[usernamesize];
- if (username)
- {
- strcpy_s(username,usernamesize,dbv.pszVal);
- mir_forkthread(LoadProfilStatus,(LPVOID)username);
- }
- //LoadProfilStatus
- db_free(&dbv);
- }
-
- if (!db_get(hContact,protocolname,"GameInfo",&dbv))
- {
- setGameInfo(listbox,dbv.pszVal);
- db_free(&dbv);
- }
-
- addToList(listbox,hContact,"Servername","ServerName");
- addToList(listbox,hContact,"GameType","GameType");
- addToList(listbox,hContact,"Map","Map");
- addToList(listbox,hContact,"Players","Players");
-
- SetItemTxt(hwndDlg,IDC_DNICK,"Nick",hContact,0);
- SetItemTxt(hwndDlg,IDC_DUSERNAME,"Username",hContact,0);
-
- SetItemTxt(hwndDlg,IDC_GIP,"ServerIP",hContact,0);
- SetItemTxt(hwndDlg,IDC_VIP,"VServerIP",hContact,0);
- SetItemTxt(hwndDlg,IDC_GPORT,"Port",hContact,1);
- SetItemTxt(hwndDlg,IDC_VPORT,"VPort",hContact,1);
-
- SetItemTxt(hwndDlg,IDC_GAME,"RGame",hContact,0);
- SetItemTxt(hwndDlg,IDC_VNAME,"RVoice",hContact,0);
-
- //render icons
- {
- DBVARIANT dbv;
-
- if (!db_get(hContact,protocolname,"GameId",&dbv))
- {
- SendMessage(GetDlgItem(hwndDlg,IDC_GAMEICO),STM_SETICON,(WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal),0);
- db_free(&dbv);
- }
- if (!db_get(hContact,protocolname,"VoiceId",&dbv))
- {
- SendMessage(GetDlgItem(hwndDlg,IDC_VOICEICO),STM_SETICON,(WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal),0);
- db_free(&dbv);
- }
-
- if (db_get(hContact,protocolname,"ServerIP",&dbv))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_COPYGAME),FALSE);
- db_free(&dbv);
- }
- if (db_get(hContact,protocolname,"VServerIP",&dbv))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_COPYVOICE),FALSE);
- db_free(&dbv);
- }
-
- //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
- }
- }
- }
- break;
- }
- }
- break;
- }
- }
+ return TRUE;
+ }
+ case WM_CTLCOLORSTATIC:
+ {
break;
- case WM_COMMAND:
- {
- switch(wParam)
- {
- case IDC_COPYGAME:
- GetIPPortUDetails(uhandle,"ServerIP","Port");
- break;
- case IDC_COPYVOICE:
- GetIPPortUDetails(uhandle,"VServerIP","VPort");
- break;
- }
- }
}
- return FALSE;
-}
-/*static BOOL CALLBACK DlgProcUserDetails2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- char profil[2056]="";
- switch (msg)
+ case WM_NOTIFY:
{
- case WM_INITDIALOG:
+ switch (((LPNMHDR)lParam)->idFrom)
{
- return TRUE;
- }
- case WM_NOTIFY:
+
+ case 0:
{
- switch (((LPNMHDR)lParam)->idFrom)
+ switch (((LPNMHDR)lParam)->code)
+ {
+
+ case PSN_INFOCHANGED:
{
- case 0:
+ char* szProto;
+ MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
+ uhandle = hContact; //handle sichern
+
+ if (hContact == NULL)
+ szProto = protocolname;
+ else
+ szProto = GetContactProto(hContact);
+
+ if (szProto == NULL)
+ break;
+
+ //alle items aus der liste entfernen
+ SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0);
+
+ if (hContact)
{
- switch (((LPNMHDR)lParam)->code)
+ DBVARIANT dbv;
+ if (!db_get(hContact, protocolname, "Username", &dbv))
{
- case PSN_INFOCHANGED:
+ int usernamesize = strlen(dbv.pszVal) + 1;
+ char* username = new char[usernamesize];
+ if (username)
{
- char* szProto;
- MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
-
- if (hContact == NULL)
- szProto = protocolname;
- else
- szProto = GetContactProto(hContact);
-
- if (szProto == NULL)
- break;
-
- if (hContact) {
- DBVARIANT dbv;
-
- char img[256]="";
- char username[256]="";
- char nick[256]="";
- char status[256]="";
- char game[512]="";
- if (!db_get(hContact,"ContactPhoto","File",&dbv))
- {
- mir_snprintf(img,256,"<img src=\"%s\">",dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(hContact,protocolname,"Username",&dbv))
- {
- mir_snprintf(username,256,"<b>Username:</b> %s<br>",dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(hContact,protocolname,"Nick",&dbv))
- {
- mir_snprintf(nick,256,"<b>Nick:</b> %s<br>",dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(hContact,protocolname,"XStatusMsg",&dbv))
- {
- mir_snprintf(status,256,"<b>Status:</b> %s<br>",dbv.pszVal);
- db_free(&dbv);
- }
- if (!db_get(hContact,protocolname,"RGame",&dbv))
- {
- mir_snprintf(game,512,"<fieldset style='border:1px solid #0091d5;background-color:#0d2c3e;margin-bottom:8px;'><legend>Spiel</legend><table><tr><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'><b><u>%s</u></b></td></tr></table></fieldset>",dbv.pszVal);
- db_free(&dbv);
- }
- mir_snprintf(profil,2056,"mshtml:<div style='position:absolute;top:0;left:0;border:1px solid #0091d5;background-color:#000;padding:6px;width:334px;height:249px'><table><tr><td valign=top>%s</td><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'>%s%s%s</td></tr><tr><td valign=top colspan=\"2\" style='font-family:Arial;font-size:11px;color:#fff;'>%s%s</td></tr></table></div>",img,username,nick,status,game);
- HWND hWnd = ::CreateWindow("AtlAxWin", profil,
- WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL,
- ::GetModuleHandle(NULL), NULL);
- }
+ strcpy_s(username, usernamesize, dbv.pszVal);
+ mir_forkthread(LoadProfilStatus, (LPVOID)username);
}
+ //LoadProfilStatus
+ db_free(&dbv);
+ }
+
+ if (!db_get(hContact, protocolname, "GameInfo", &dbv))
+ {
+ setGameInfo(listbox, dbv.pszVal);
+ db_free(&dbv);
+ }
+
+ addToList(listbox, hContact, "Servername", "ServerName");
+ addToList(listbox, hContact, "GameType", "GameType");
+ addToList(listbox, hContact, "Map", "Map");
+ addToList(listbox, hContact, "Players", "Players");
+
+ SetItemTxt(hwndDlg, IDC_DNICK, "Nick", hContact, 0);
+ SetItemTxt(hwndDlg, IDC_DUSERNAME, "Username", hContact, 0);
+
+ SetItemTxt(hwndDlg, IDC_GIP, "ServerIP", hContact, 0);
+ SetItemTxt(hwndDlg, IDC_VIP, "VServerIP", hContact, 0);
+ SetItemTxt(hwndDlg, IDC_GPORT, "Port", hContact, 1);
+ SetItemTxt(hwndDlg, IDC_VPORT, "VPort", hContact, 1);
+
+ SetItemTxt(hwndDlg, IDC_GAME, "RGame", hContact, 0);
+ SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0);
+
+ //render icons
+ {
+ DBVARIANT dbv;
+
+ if (!db_get(hContact, protocolname, "GameId", &dbv))
+ {
+ SendMessage(GetDlgItem(hwndDlg, IDC_GAMEICO), STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
+ db_free(&dbv);
+ }
+ if (!db_get(hContact, protocolname, "VoiceId", &dbv))
+ {
+ SendMessage(GetDlgItem(hwndDlg, IDC_VOICEICO), STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
+ db_free(&dbv);
+ }
+
+ if (db_get(hContact, protocolname, "ServerIP", &dbv))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE);
+ db_free(&dbv);
+ }
+ if (db_get(hContact, protocolname, "VServerIP", &dbv))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE);
+ db_free(&dbv);
+ }
+
+ //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
}
}
}
+ break;
+ }
+ }
+ break;
}
}
+ break;
+ case WM_COMMAND:
+ {
+ switch (wParam)
+ {
+ case IDC_COPYGAME:
+ GetIPPortUDetails(uhandle, "ServerIP", "Port");
+ break;
+ case IDC_COPYVOICE:
+ GetIPPortUDetails(uhandle, "VServerIP", "VPort");
+ break;
+ }
+ }
+ }
return FALSE;
+}
+
+/*static BOOL CALLBACK DlgProcUserDetails2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+char profil[2056]="";
+switch (msg)
+{
+case WM_INITDIALOG:
+{
+return TRUE;
+}
+case WM_NOTIFY:
+{
+switch (((LPNMHDR)lParam)->idFrom)
+{
+case 0:
+{
+switch (((LPNMHDR)lParam)->code)
+{
+case PSN_INFOCHANGED:
+{
+char* szProto;
+MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
+
+if (hContact == NULL)
+szProto = protocolname;
+else
+szProto = GetContactProto(hContact);
+
+if (szProto == NULL)
+break;
+
+if (hContact) {
+DBVARIANT dbv;
+
+char img[256]="";
+char username[256]="";
+char nick[256]="";
+char status[256]="";
+char game[512]="";
+if (!db_get(hContact,"ContactPhoto","File",&dbv))
+{
+mir_snprintf(img,256,"<img src=\"%s\">",dbv.pszVal);
+db_free(&dbv);
+}
+if (!db_get(hContact,protocolname,"Username",&dbv))
+{
+mir_snprintf(username,256,"<b>Username:</b> %s<br>",dbv.pszVal);
+db_free(&dbv);
+}
+if (!db_get(hContact,protocolname,"Nick",&dbv))
+{
+mir_snprintf(nick,256,"<b>Nick:</b> %s<br>",dbv.pszVal);
+db_free(&dbv);
+}
+if (!db_get(hContact,protocolname,"XStatusMsg",&dbv))
+{
+mir_snprintf(status,256,"<b>Status:</b> %s<br>",dbv.pszVal);
+db_free(&dbv);
+}
+if (!db_get(hContact,protocolname,"RGame",&dbv))
+{
+mir_snprintf(game,512,"<fieldset style='border:1px solid #0091d5;background-color:#0d2c3e;margin-bottom:8px;'><legend>Spiel</legend><table><tr><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'><b><u>%s</u></b></td></tr></table></fieldset>",dbv.pszVal);
+db_free(&dbv);
+}
+mir_snprintf(profil,2056,"mshtml:<div style='position:absolute;top:0;left:0;border:1px solid #0091d5;background-color:#000;padding:6px;width:334px;height:249px'><table><tr><td valign=top>%s</td><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'>%s%s%s</td></tr><tr><td valign=top colspan=\"2\" style='font-family:Arial;font-size:11px;color:#fff;'>%s%s</td></tr></table></div>",img,username,nick,status,game);
+HWND hWnd = ::CreateWindow("AtlAxWin", profil,
+WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL,
+::GetModuleHandle(NULL), NULL);
+}
+}
+}
+}
+}
+}
+}
+return FALSE;
}*/
int OnDetailsInit(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp index 5f9c7ee762..1dd8d5ffac 100644 --- a/protocols/Xfire/src/variables.cpp +++ b/protocols/Xfire/src/variables.cpp @@ -10,10 +10,10 @@ using namespace std; char* Varxfiregame(ARGUMENTSINFO *ai)
{
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact==NULL)
+ if (ai->fi->hContact == NULL)
{
//
}
@@ -21,27 +21,27 @@ char* Varxfiregame(ARGUMENTSINFO *ai) {
char temp[256];
DBVARIANT dbv3;
- if (!db_get(ai->fi->hContact,protocolname, "RGame",&dbv3))
+ if (!db_get(ai->fi->hContact, protocolname, "RGame", &dbv3))
{
- strncpy(temp,dbv3.pszVal,255);
+ strncpy(temp, dbv3.pszVal, 255);
db_free(&dbv3);
return mir_strdup(temp);
}
}
-
+
ai->flags = AIF_FALSE;
return mir_strdup("");
}
char* Varmyxfiregame(ARGUMENTSINFO *ai)
{
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL,protocolname, "currentgamename",&dbv3))
+ if (!db_get(NULL, protocolname, "currentgamename", &dbv3))
{
- char* ret=mir_strdup(dbv3.pszVal);
+ char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
}
@@ -51,13 +51,13 @@ char* Varmyxfiregame(ARGUMENTSINFO *ai) char* Varxfirevoice(ARGUMENTSINFO *ai)
{
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
DBVARIANT dbv3;
- if (!db_get(ai->fi->hContact,protocolname, "RVoice",&dbv3))
+ if (!db_get(ai->fi->hContact, protocolname, "RVoice", &dbv3))
{
- char* ret=mir_strdup(dbv3.pszVal);
+ char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
}
@@ -68,42 +68,42 @@ char* Varxfirevoice(ARGUMENTSINFO *ai) char* Varmyxfirevoiceip(ARGUMENTSINFO *ai) {
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL,protocolname, "VServerIP",&dbv3))
+ if (!db_get(NULL, protocolname, "VServerIP", &dbv3))
{
- char* ret=mir_strdup(dbv3.pszVal);
+ char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
}
-
+
ai->flags = AIF_FALSE;
return mir_strdup("");
}
char* Varmyxfireserverip(ARGUMENTSINFO *ai) {
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL,protocolname, "ServerIP",&dbv3))
+ if (!db_get(NULL, protocolname, "ServerIP", &dbv3))
{
- char* ret=mir_strdup(dbv3.pszVal);
+ char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
}
-
+
ai->flags = AIF_FALSE;
return mir_strdup("");
}
char* Varxfireserverip(ARGUMENTSINFO *ai) {
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact==NULL)
+ if (ai->fi->hContact == NULL)
{
ai->flags = AIF_FALSE;
return mir_strdup("");
@@ -112,7 +112,7 @@ char* Varxfireserverip(ARGUMENTSINFO *ai) { {
char temp[24];
DBVARIANT dbv3;
- if (!db_get(ai->fi->hContact,protocolname, "ServerIP",&dbv3))
+ if (!db_get(ai->fi->hContact, protocolname, "ServerIP", &dbv3))
{
mir_snprintf(temp, SIZEOF(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "Port", 0));
db_free(&dbv3);
@@ -121,16 +121,16 @@ char* Varxfireserverip(ARGUMENTSINFO *ai) { ai->flags = AIF_FALSE;
return mir_strdup("");
}
-
+
ai->flags = AIF_FALSE;
return mir_strdup("");
}
char* Varxfirevoiceip(ARGUMENTSINFO *ai) {
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact==NULL)
+ if (ai->fi->hContact == NULL)
{
ai->flags = AIF_FALSE;
return mir_strdup("");
@@ -139,7 +139,7 @@ char* Varxfirevoiceip(ARGUMENTSINFO *ai) { {
char temp[24];
DBVARIANT dbv3;
- if (!db_get(ai->fi->hContact,protocolname, "VServerIP",&dbv3))
+ if (!db_get(ai->fi->hContact, protocolname, "VServerIP", &dbv3))
{
mir_snprintf(temp, SIZEOF(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "VPort", 0));
db_free(&dbv3);
@@ -148,20 +148,20 @@ char* Varxfirevoiceip(ARGUMENTSINFO *ai) { ai->flags = AIF_FALSE;
return mir_strdup("");
}
-
+
ai->flags = AIF_FALSE;
return mir_strdup("");
}
char* Varmyxfirevoice(ARGUMENTSINFO *ai)
{
- if (ai->cbSize < sizeof(ARGUMENTSINFO))
+ if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL,protocolname, "currentvoicename",&dbv3))
+ if (!db_get(NULL, protocolname, "currentvoicename", &dbv3))
{
- char* ret=mir_strdup(dbv3.pszVal);
+ char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
}
@@ -173,27 +173,30 @@ char* XFireGetFoldersPath(char * pathtype) {// Get XFire folder path
static char path[1024]; path[0] = 0;
if (ServiceExists(MS_FOLDERS_REGISTER_PATH)){
- if (!strcmp(pathtype,"Avatar")){
- FoldersGetCustomPath(XFireAvatarFolder, path, 1024, "" );}
- if (!strcmp(pathtype,"IniFile")){
- FoldersGetCustomPath(XFireWorkingFolder, path, 1024, "" );}
- if (!strcmp(pathtype,"IconsFile")){
- FoldersGetCustomPath(XFireIconFolder, path, 1024, "" );}
- strcat(path,"\\");
+ if (!strcmp(pathtype, "Avatar")){
+ FoldersGetCustomPath(XFireAvatarFolder, path, 1024, "");
+ }
+ if (!strcmp(pathtype, "IniFile")){
+ FoldersGetCustomPath(XFireWorkingFolder, path, 1024, "");
+ }
+ if (!strcmp(pathtype, "IconsFile")){
+ FoldersGetCustomPath(XFireIconFolder, path, 1024, "");
+ }
+ strcat(path, "\\");
return path;
}
else {
-/******BASE********/
- char BaseFolder[MAX_PATH]= "";
+ /******BASE********/
+ char BaseFolder[MAX_PATH] = "";
char CurProfileF[MAX_PATH] = "";
char CurProfile[MAX_PATH] = "";
- CallService(MS_DB_GETPROFILEPATH, (WPARAM) MAX_PATH, (LPARAM)BaseFolder);
+ CallService(MS_DB_GETPROFILEPATH, (WPARAM)MAX_PATH, (LPARAM)BaseFolder);
strcat(BaseFolder, "\\");
- CallService(MS_DB_GETPROFILENAME, (WPARAM) MAX_PATH, (LPARAM)CurProfileF);
+ CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)CurProfileF);
int i;
for (i = MAX_PATH; 5; i--){
- if (CurProfileF[i] == 't' && CurProfileF[i-3] == '.'){
- i = i-3;
+ if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.'){
+ i = i - 3;
break;
}
}
@@ -202,8 +205,8 @@ char* XFireGetFoldersPath(char * pathtype) strcat(BaseFolder, "\\");
strcat(BaseFolder, "XFire");
strcat(BaseFolder, "\\");
-/*******BASE********/
- if (!strcmp(pathtype,"Avatar")){
+ /*******BASE********/
+ if (!strcmp(pathtype, "Avatar")){
strcat(BaseFolder, "Avatars");
strcat(BaseFolder, "\\");
}
|