diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
commit | 85bd008c039eb1d93894e94fba9d158a42a71a12 (patch) | |
tree | 2d72d10759f6928e9e4b960175d2de01b5cf7e12 | |
parent | 222802c2986dcaf029fdfb828b7679bdabfa7bb2 (diff) |
massive code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14910 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
145 files changed, 5443 insertions, 6530 deletions
diff --git a/protocols/Xfire/src/Xfire_avatar_loader.cpp b/protocols/Xfire/src/Xfire_avatar_loader.cpp index 92a84ef978..0b3a4c213f 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.cpp +++ b/protocols/Xfire/src/Xfire_avatar_loader.cpp @@ -1,17 +1,20 @@ #include "stdafx.h" #include "Xfire_avatar_loader.h" -Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) { +Xfire_avatar_loader::Xfire_avatar_loader(xfirelib::Client* client) +{ threadrunning = FALSE; this->client = client; } -Xfire_avatar_loader::~Xfire_avatar_loader() { +Xfire_avatar_loader::~Xfire_avatar_loader() +{ //liste leeren, damit der laufende thread abgebrochen wird list.clear(); } -void Xfire_avatar_loader::loadThread(void *arg) { +void Xfire_avatar_loader::loadThread(void *arg) +{ Xfire_avatar_loader *loader = (Xfire_avatar_loader*)arg; //kein loader, dann abbruch @@ -21,7 +24,7 @@ void Xfire_avatar_loader::loadThread(void *arg) { mir_cslock lck(loader->avatarMutex); loader->threadrunning = TRUE; - while (1){ + while (1) { //keinen avatarload auftrag mehr if (!loader->list.size()) break; @@ -33,9 +36,8 @@ void Xfire_avatar_loader::loadThread(void *arg) { GetBuddyInfo buddyinfo; buddyinfo.userid = process.userid; if (loader->client) - if (loader->client->connected) - { - loader->client->send(&buddyinfo); + if (loader->client->connected) { + loader->client->send(&buddyinfo); } else //nicht mehr verbunden? dann liste leeren und schleife abbrechen { diff --git a/protocols/Xfire/src/Xfire_avatar_loader.h b/protocols/Xfire/src/Xfire_avatar_loader.h index c906e26bf1..6250d6b4f1 100644 --- a/protocols/Xfire/src/Xfire_avatar_loader.h +++ b/protocols/Xfire/src/Xfire_avatar_loader.h @@ -32,7 +32,6 @@ #include "client.h"
#include "Xfire_base.h"
#include "getbuddyinfo.h"
-#include <vector>
using namespace xfirelib;
diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp index eecc1b6ac7..47ecf165b7 100644 --- a/protocols/Xfire/src/Xfire_base.cpp +++ b/protocols/Xfire/src/Xfire_base.cpp @@ -4,15 +4,15 @@ #include "variables.h"
//rechnet die einzelnen chars des strings zusammen
-BYTE Xfire_base::accStringByte(char* str){
+BYTE Xfire_base::accStringByte(char* str)
+{
BYTE temp = 0;
//keins tirng? bye bye
if (str == NULL)
return 0;
- for (unsigned int i = 0; i < (int)mir_strlen(str); i++)
- {
+ for (unsigned int i = 0; i < (int)mir_strlen(str); i++) {
temp += str[i];
}
@@ -27,8 +27,7 @@ void Xfire_base::strtolower(char*str) return;
//lowercase it :)
- for (unsigned int i = 0; i < (int)mir_strlen(str); i++)
- {
+ for (unsigned int i = 0; i < (int)mir_strlen(str); i++) {
str[i] = tolower(str[i]);
}
}
@@ -40,8 +39,7 @@ void Xfire_base::strtolowerT(TCHAR*str) return;
//lowercase it :)
- for (unsigned int i = 0; i < (int)mir_tstrlen(str); i++)
- {
+ for (unsigned int i = 0; i < (int)mir_tstrlen(str); i++) {
str[i] = tolower(str[i]);
}
}
@@ -54,8 +52,7 @@ void Xfire_base::strtoupper(char*str) return;
//lowercase it :)
- for (unsigned int i = 0; i < (int)mir_strlen(str); i++)
- {
+ for (unsigned int i = 0; i < (int)mir_strlen(str); i++) {
str[i] = toupper(str[i]);
}
}
@@ -114,8 +111,7 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, char**to) //wert aus der dblesen
mir_snprintf(temp, _countof(temp), "%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);
//dbval wieder freigeben
@@ -132,8 +128,7 @@ void Xfire_base::readStringfromDB(char*name, unsigned int dbid, int id, char**to //wert aus der dblesen
mir_snprintf(temp, _countof(temp), "%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);
//dbval wieder freigeben
@@ -150,8 +145,7 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, char**to) //wert aus der dblesen
mir_snprintf(temp, _countof(temp), "%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);
//dbval wieder freigeben
@@ -168,8 +162,7 @@ void Xfire_base::readUtf8StringfromDB(char*name, unsigned int dbid, int id, char //wert aus der dblesen
mir_snprintf(temp, _countof(temp), "%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);
//dbval wieder freigeben
@@ -287,8 +280,7 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid) mir_snprintf(temp, _countof(temp), "%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);
@@ -308,8 +300,7 @@ BOOL Xfire_base::removeDBEntry(char*name, unsigned int dbid, int id) mir_snprintf(temp, _countof(temp), "%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,10 +310,10 @@ 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;
return FALSE;
@@ -330,8 +321,7 @@ BOOL Xfire_base::inString(char*str, char*search, char**pos) { //ist der gesuchte string größer, wie der string wo gesucht werden soll? dann FALSE zurück
unsigned int sizeofsearch = mir_strlen(search);
- if (sizeofsearch > mir_strlen(str))
- {
+ if (sizeofsearch > mir_strlen(str)) {
//poszeiger, falls übergeben, auf NULL setzen
if (pos) *pos = NULL;
return FALSE;
@@ -340,8 +330,7 @@ BOOL Xfire_base::inString(char*str, char*search, char**pos) { char* src = str;
char* s = search;
- while (*src != 0)
- {
+ while (*src != 0) {
if (*src == *s) //gleich, dann zum nächsten buchstaben springen
s++;
else if (*s == 0) //string ende erreicht? dann true
@@ -367,20 +356,19 @@ BOOL Xfire_base::inString(char*str, char*search, char**pos) { 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 = "";
//leere pointer?, dann zurück
- if (search == NULL || data == NULL || *data == NULL)
- {
+ if (search == NULL || data == NULL || *data == NULL) {
return;
}
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;
@@ -403,7 +391,8 @@ void Xfire_base::strreplace(char*search, char*replace, char**data) { }
//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)
return FALSE;
@@ -413,8 +402,7 @@ BOOL Xfire_base::wildcmp(const TCHAR *search, const TCHAR *text) { do {
//wilcard gefunden?
- if (*search == '*')
- {
+ if (*search == '*') {
//wildcardmodus an
wildc = 1;
//nächsten suchzeichen
@@ -429,14 +417,12 @@ BOOL Xfire_base::wildcmp(const TCHAR *search, const TCHAR *text) { return FALSE;
//kein wildcardmodus
- if (!wildc)
- {
+ 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;
//nächstes suchzeichen
@@ -460,13 +446,15 @@ 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) {
+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;
@@ -495,7 +483,8 @@ BOOL Xfire_base::getIniValue(unsigned int gameid, unsigned int subid, const char return FALSE;
}
-BOOL Xfire_base::getIniPath(char*path) {
+BOOL Xfire_base::getIniPath(char*path)
+{
//kein ziel abbruch
if (!path)
return FALSE;
@@ -504,7 +493,8 @@ BOOL Xfire_base::getIniPath(char*path) { return TRUE;
}
-BOOL Xfire_base::getIconPath(char*path) {
+BOOL Xfire_base::getIconPath(char*path)
+{
//kein ziel abbruch
if (!path)
return FALSE;
@@ -512,13 +502,13 @@ BOOL Xfire_base::getIconPath(char*path) { 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[XFIRE_MAXSIZEOFGAMENAME];
@@ -535,7 +525,8 @@ 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);
if (buffer) {
@@ -544,8 +535,7 @@ HICON Xfire_base::createHICONfromdata(LPVOID data, unsigned int size) { memcpy(data2, data, size);
IStream* stream = NULL;
- if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK)
- {
+ if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK) {
HICON hicon = NULL;
Gdiplus::Bitmap image(stream);
@@ -565,7 +555,8 @@ 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);
if (buffer) {
@@ -574,8 +565,7 @@ HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data, unsigned int size) { memcpy(data2, data, size);
IStream* stream = NULL;
- if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK)
- {
+ if (CreateStreamOnHGlobal(data2, FALSE, &stream) == S_OK) {
HBITMAP hbitmap = NULL;
Gdiplus::Bitmap image(stream);
@@ -595,7 +585,8 @@ HBITMAP Xfire_base::createHBITMAPfromdata(LPVOID data, unsigned int size) { }
//prüft ob processid noch gültig is
-BOOL Xfire_base::isValidPid(DWORD pid) {
+BOOL Xfire_base::isValidPid(DWORD pid)
+{
DWORD aProcesses[1024], cbNeeded, cProcesses;
if (pid == NULL)
@@ -607,16 +598,16 @@ BOOL Xfire_base::isValidPid(DWORD pid) { cProcesses = cbNeeded / sizeof(DWORD);
for (unsigned int i = 0; i < cProcesses; i++)
- if (aProcesses[i] == pid)
- {
- return TRUE;
+ if (aProcesses[i] == pid) {
+ return TRUE;
}
return FALSE;
}
//sucht nach einen process und liefert die pid
-BOOL Xfire_base::getPidByProcessName(TCHAR *name, DWORD *pid) {
+BOOL Xfire_base::getPidByProcessName(TCHAR *name, DWORD *pid)
+{
if (pid == NULL || name == NULL)
return FALSE;
@@ -624,11 +615,9 @@ BOOL Xfire_base::getPidByProcessName(TCHAR *name, DWORD *pid) { PROCESSENTRY32* processInfo = new PROCESSENTRY32;
processInfo->dwSize = sizeof(PROCESSENTRY32);
- while (Process32Next(hSnapShot, processInfo) != FALSE)
- {
+ while (Process32Next(hSnapShot, processInfo) != FALSE) {
if (processInfo->th32ProcessID != 0) {
- if (mir_tstrcmpi(processInfo->szExeFile, name) == 0)
- {
+ if (mir_tstrcmpi(processInfo->szExeFile, name) == 0) {
*pid = processInfo->th32ProcessID;
CloseHandle(hSnapShot);
return TRUE;
diff --git a/protocols/Xfire/src/Xfire_game.cpp b/protocols/Xfire/src/Xfire_game.cpp index c954230cad..d71881d908 100644 --- a/protocols/Xfire/src/Xfire_game.cpp +++ b/protocols/Xfire/src/Xfire_game.cpp @@ -4,7 +4,8 @@ #include "pwd_dlg.h" //passwort eingabe dlg
//prüft nach, ob das game das nötige extragameargs im launcherstring hat
-BOOL Xfire_game::haveExtraGameArgs() {
+BOOL Xfire_game::haveExtraGameArgs()
+{
//kein launcher stirng, dann abbruch
if (!this->launchparams)
return FALSE;
@@ -17,21 +18,20 @@ BOOL Xfire_game::haveExtraGameArgs() { }
//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*)
+{
//launchparam prüfen ob gefüllt?
if (this->launchparams == NULL)
return FALSE;
//ist launchparam großgenug für eibne urlprüfung?
- if (mir_strlen(this->launchparams) > 5)
- {
+ if (mir_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] == ':')
- {
+ this->launchparams[4] == ':') {
Utils_OpenUrl(this->launchparams);
return 0;
}
@@ -41,10 +41,8 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { int networksize = 0;
char* mynetworkparams = NULL;
- if (this->networkparams)
- {
- if (ip)
- {
+ if (this->networkparams) {
+ if (ip) {
char portstr[6] = "";
int pwsize = 255;
@@ -64,7 +62,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { 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){
+ if (GetAsyncKeyState(VK_LSHIFT) && this->pwparams) {
char password[256] = ""; //passwort maximal 255 zeichen
if (ShowPwdDlg(password)) {
@@ -80,8 +78,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { else
str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", "");
}
- else
- {
+ else {
str_replace(mynetworkparams, "%UA_LAUNCHER_PASSWORD_ARGS%", "");
}
}
@@ -98,8 +95,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { //extra parameter
int extraparamssize = 0;
- if (this->extraparams)
- {
+ if (this->extraparams) {
extraparamssize = mir_strlen(this->extraparams);
}
@@ -107,8 +103,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { char*temp = NULL;
temp = new char[mir_strlen(this->launchparams) + networksize + extraparamssize + 1];
- if (temp == NULL)
- {
+ if (temp == NULL) {
//wenn nwparams gesetzt, leeren
if (mynetworkparams)
delete[] mynetworkparams;
@@ -120,8 +115,7 @@ BOOL Xfire_game::start_game(char*ip, unsigned int port, char*pw) { strcpy_s(temp, mir_strlen(this->launchparams) + 1, this->launchparams);
//netzwerkparameter ?
- if (mynetworkparams)
- {
+ if (mynetworkparams) {
str_replace(temp, "%UA_LAUNCHER_NETWORK_ARGS%", mynetworkparams);
delete[] mynetworkparams;
}
@@ -140,23 +134,19 @@ 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)
- {
+ if (exe == 0) {
delete[] temp;
return FALSE;
}
*exe = 0;
exe++;
char*params = strchr(exe, '.');
- if (params != 0)
- {
+ if (params != 0) {
params = strchr(params, ' ');
- if (params != 0)
- {
+ if (params != 0) {
*params = 0;
params++;
}
@@ -187,8 +177,7 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) //versuche ein processhandle des speils zubekommen
HANDLE op = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processInfo->th32ProcessID);
- if (op)
- {
+ if (op) {
//varaibele wohin der pfad eingelesen wird
TCHAR fpath[MAX_PATH] = _T("");
@@ -206,8 +195,7 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) //if (mir_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
@@ -217,13 +205,10 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) else //prüfe den multipfad
{
int size = mpath.size();
- for (int j = 0; j < size; j++)
- {
- if (mir_tstrcmpi(_A2T(mpath.at(j)), fpath) == 0)
- {
+ for (int j = 0; j < size; j++) {
+ if (mir_tstrcmpi(_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);
//positive antwort an die gamedetection
@@ -244,15 +229,13 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) 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++)
- {
+ for (int j = 0; j < size; j++) {
//exenamen rausfischen
char* exename = strrchr(mpath.at(j), '\\') + 1;
@@ -261,8 +244,7 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) continue;
//exe vergleichen
- if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0)
- {
+ if (_stricmp(exename, _T2A(processInfo->szExeFile)) == 0) {
//positive antwort an die gamedetection
return TRUE;
}
@@ -275,7 +257,8 @@ BOOL Xfire_game::checkpath(PROCESSENTRY32* processInfo) }
//icondaten setzen
-void Xfire_game::setIcon(HICON hicon, HANDLE handle) {
+void Xfire_game::setIcon(HICON hicon, HANDLE handle)
+{
this->hicon = hicon;
this->iconhandl = handle;
}
@@ -287,13 +270,10 @@ void Xfire_game::readFromDB(unsigned dbid) this->readStringfromDB("gamepath", dbid, &this->path);
//8.3 fix, prüfe auf ~ pfad, wenn ja pfad var umwalnd in longname
- if (this->path)
- {
+ if (this->path) {
BOOL found = FALSE;
- for (unsigned int i = 0; i < mir_strlen(this->path); i++)
- {
- if (this->path[i] == '~')
- {
+ for (unsigned int i = 0; i < mir_strlen(this->path); i++) {
+ if (this->path[i] == '~') {
found = TRUE;
break;
}
@@ -331,13 +311,11 @@ void Xfire_game::readFromDB(unsigned dbid) //mehrere pfade
int size = this->readWordfromDB("gamemulti", dbid, 0);
- for (int j = 0; j < size; j++)
- {
+ for (int j = 0; j < size; j++) {
char* tpath = NULL;
this->readStringfromDB("gamepath", dbid, j, &tpath);
- if (tpath)
- {
+ if (tpath) {
mpath.push_back(tpath);
}
}
@@ -349,12 +327,10 @@ void Xfire_game::readFromDB(unsigned dbid) //läd spielnamen aus, sowie icon
void Xfire_game::setNameandIcon()
{
- if (this->customgamename)
- {
+ if (this->customgamename) {
this->setString(this->customgamename, &this->name);
}
- else
- {
+ else {
//std::string game=GetGame(this->id,0,&this->iconhandl,&this->hicon,TRUE);
//zielbuffer für den namen
char buf[XFIRE_MAXSIZEOFGAMENAME] = "Unknown Game";
@@ -412,11 +388,9 @@ void Xfire_game::writeToDB(unsigned dbid) //mehrere pfade
int size = mpath.size();
- if (size > 0)
- {
+ if (size > 0) {
this->writeWordtoDB("gamemulti", dbid, mpath.size());
- for (int j = 0; j < size; j++)
- {
+ for (int j = 0; j < size; j++) {
this->writeStringtoDB("gamepath", dbid, j, mpath.at(j));
}
}
@@ -457,8 +431,7 @@ void Xfire_game::createMenuitem(unsigned int pos, int dbid) //entfernt menüpunkt
void Xfire_game::remoteMenuitem()
{
- if (menuhandle != NULL)
- {
+ if (menuhandle != NULL) {
Menu_RemoveItem(menuhandle);
menuhandle = NULL;
}
diff --git a/protocols/Xfire/src/Xfire_game.h b/protocols/Xfire/src/Xfire_game.h index 1e817ce503..f4e36c4155 100644 --- a/protocols/Xfire/src/Xfire_game.h +++ b/protocols/Xfire/src/Xfire_game.h @@ -32,7 +32,6 @@ #define _XFIRE_GAME
#include "Xfire_base.h"
-#include <vector>
using namespace std;
diff --git a/protocols/Xfire/src/Xfire_gamelist.cpp b/protocols/Xfire/src/Xfire_gamelist.cpp index 7c5663464f..c9b3340e03 100644 --- a/protocols/Xfire/src/Xfire_gamelist.cpp +++ b/protocols/Xfire/src/Xfire_gamelist.cpp @@ -5,8 +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);
}
return NULL;
@@ -23,10 +22,10 @@ Xfire_game* Xfire_gamelist::getGamebyGameid(unsigned int gameid) return NULL;
}
-void Xfire_gamelist::readGamelist(int anz) {
+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();
@@ -55,7 +54,8 @@ Xfire_gamelist::Xfire_gamelist() }
//dekonstruktor
-Xfire_gamelist::~Xfire_gamelist() {
+Xfire_gamelist::~Xfire_gamelist()
+{
for (unsigned int i = 0; i < gamelist.size(); i++) {
Xfire_game* game = (Xfire_game*)gamelist.at(i);
if (game) delete game;
@@ -71,21 +71,18 @@ BOOL Xfire_gamelist::getnextGame(Xfire_game**currentgame) 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);
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);
}
return TRUE;
}
- else
- {
+ else {
//liste durchgearbeitet, nextid wieder auf 0 setzen
nextgameid = 0;
return FALSE;
@@ -146,16 +143,13 @@ void Xfire_gamelist::createStartmenu() //sortiert mit bubblesortalgo
BOOL changed = FALSE;
- do
- {
+ do {
changed = FALSE;
- for (unsigned int i = 1; i < gamelist.size(); i++)
- {
+ 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]);
//sortieren
- if (mir_strcmp(game->name, game2->name) > 0)
- {
+ if (mir_strcmp(game->name, game2->name) > 0) {
int tempi = sorttemp[i - 1];
sorttemp[i - 1] = sorttemp[i];
sorttemp[i] = tempi;
@@ -194,10 +188,8 @@ 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);
- if (game)
- {
- if (game->id == id)
- {
+ if (game) {
+ if (game->id == id) {
//soll eine dbid zurückgeliefert werden? dann setzen
if (dbid)
*dbid = i;
@@ -229,7 +221,8 @@ void Xfire_gamelist::clearStartmenu() }
//dekonstruktor
-void Xfire_gamelist::clearGamelist() {
+void Xfire_gamelist::clearGamelist()
+{
createDummyMenuItem();
for (unsigned int i = 0; i < gamelist.size(); i++) {
Xfire_game* game = (Xfire_game*)gamelist.at(i);
@@ -265,11 +258,9 @@ void Xfire_gamelist::clearDatabase(BOOL dontaddcustom) 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)
- {
+ if (!dontaddcustom) {
//erzeuge gameobject
Xfire_game* game = new Xfire_game();
//lese das spiel ein
diff --git a/protocols/Xfire/src/Xfire_gamelist.h b/protocols/Xfire/src/Xfire_gamelist.h index 83f087cd96..b9fef189d6 100644 --- a/protocols/Xfire/src/Xfire_gamelist.h +++ b/protocols/Xfire/src/Xfire_gamelist.h @@ -34,7 +34,6 @@ #include "Xfire_game.h"
#include "Xfire_icon_mng.h"
-#include <vector>
using namespace std;
diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp index d4dab1b547..b51639d8fd 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.cpp +++ b/protocols/Xfire/src/Xfire_icon_mng.cpp @@ -2,7 +2,8 @@ #include "Xfire_icon_mng.h"
//liefert den handle eines icons zurück
-HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid) {
+HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid)
+{
Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
@@ -14,11 +15,10 @@ 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++)
- {
- if (iconcache.at(i).gameid == gameid)
- {
+unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid)
+{
+ for (unsigned int i = 0; i < iconcache.size(); i++) {
+ if (iconcache.at(i).gameid == gameid) {
return i;
}
}
@@ -26,16 +26,18 @@ unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) { }
//gameicon mit hilfe von id zurückliefern
-HICON Xfire_icon_mng::getGameIconFromId(unsigned int id) {
+HICON Xfire_icon_mng::getGameIconFromId(unsigned int id)
+{
//id nur im bereich zurückliefern
- if (id>iconcache.size() - 1)
+ if (id > iconcache.size() - 1)
return NULL;
return iconcache.at(id).hicon;
}
//liefert das hicon zurück
-HICON Xfire_icon_mng::getGameIcon(unsigned int gameid) {
+HICON Xfire_icon_mng::getGameIcon(unsigned int gameid)
+{
Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
@@ -46,7 +48,8 @@ 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 Xfire_icon_mng::getGameIconEntry(unsigned int gameid)
+{
Xfire_icon_cache entry = { 0 };
//icon im cache dann zurückliefern
@@ -57,15 +60,14 @@ Xfire_icon_cache Xfire_icon_mng::getGameIconEntry(unsigned int 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)
return FALSE;
- for (unsigned int i = 0; i < iconcache.size(); i++)
- {
- if (iconcache.at(i).gameid == gameid)
- {
+ for (unsigned int i = 0; i < iconcache.size(); i++) {
+ if (iconcache.at(i).gameid == gameid) {
*out = iconcache.at(i);
return TRUE;
}
@@ -76,12 +78,11 @@ BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid, Xfire_icon_cache* out }
//dekonstruktor
-Xfire_icon_mng::~Xfire_icon_mng() {
+Xfire_icon_mng::~Xfire_icon_mng()
+{
//geladene icons wieder freigeben
- for (unsigned int i = 0; i < iconcache.size(); i++)
- {
- if (iconcache.at(i).hicon)
- {
+ for (unsigned int i = 0; i < iconcache.size(); i++) {
+ if (iconcache.at(i).hicon) {
DestroyIcon(iconcache.at(i).hicon);
iconcache.at(i).hicon = NULL;
}
@@ -96,12 +97,14 @@ Xfire_icon_mng::~Xfire_icon_mng() { }
//konstruktor
-Xfire_icon_mng::Xfire_icon_mng() {
+Xfire_icon_mng::Xfire_icon_mng()
+{
hIconDll = NULL;
}
//erzeugt aus HICON ein Handle, welches in Miranda in der Clist angewendet werden kann
-HANDLE Xfire_icon_mng::createIconHandle(HICON hicon) {
+HANDLE Xfire_icon_mng::createIconHandle(HICON hicon)
+{
if (!hicon)
return NULL;
@@ -109,7 +112,8 @@ HANDLE Xfire_icon_mng::createIconHandle(HICON hicon) { }
//eigentliche laderoutine
-Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) {
+Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid)
+{
Xfire_icon_cache entry = { 0 };
//shortname
@@ -122,8 +126,7 @@ Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) { entry.gameid = gameid;
//Icons.dll noch nicht geladen?!?
- if (!hIconDll)
- {
+ if (!hIconDll) {
//versuch die Icons.dll zuladen
char path[MAX_PATH] = "";
if (!getIconPath(path))
@@ -175,7 +178,8 @@ Xfire_icon_cache Xfire_icon_mng::LoadGameIcon(unsigned int gameid) { }
//icon vom xfire server laden
-HICON Xfire_icon_mng::downloadIcon(char* shortname) {
+HICON Xfire_icon_mng::downloadIcon(char* shortname)
+{
//nur vom internetladen, wenn die option aktiv ist
if (!db_get_b(NULL, protocolname, "xfiresitegameico", 0))
return NULL;
@@ -193,8 +197,7 @@ HICON Xfire_icon_mng::downloadIcon(char* 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);
//speicher freigeben
@@ -207,9 +210,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++)
- {
+int Xfire_icon_mng::resetIconHandles()
+{
+ for (unsigned int i = 0; i < iconcache.size(); i++) {
iconcache.at(i).handle = this->createIconHandle(iconcache.at(i).hicon);
}
return 0;
diff --git a/protocols/Xfire/src/Xfire_icon_mng.h b/protocols/Xfire/src/Xfire_icon_mng.h index 682215d2ec..69bdb4839e 100644 --- a/protocols/Xfire/src/Xfire_icon_mng.h +++ b/protocols/Xfire/src/Xfire_icon_mng.h @@ -30,7 +30,6 @@ #define _XFIRE_ICON_MNG
#include "Xfire_base.h"
-#include <vector>
const char IconsdllName[] = "Icons.dll";
diff --git a/protocols/Xfire/src/Xfire_proxy.cpp b/protocols/Xfire/src/Xfire_proxy.cpp index fad6e879fe..8171ec5522 100644 --- a/protocols/Xfire/src/Xfire_proxy.cpp +++ b/protocols/Xfire/src/Xfire_proxy.cpp @@ -6,8 +6,8 @@ extern HANDLE hNetlib; HANDLE hBindPort = NULL;
HANDLE netlibcon = NULL;
-
-void FromServerToClient(LPVOID lParam) {
+void FromServerToClient(LPVOID lParam)
+{
char buf[1024] = { 0 };
HANDLE hConnection = (HANDLE)lParam;
@@ -25,7 +25,7 @@ void FromServerToClient(LPVOID lParam) { }
//xfireclient baut verbindung auf
-void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra)
+void XfireclientConnecting(HANDLE hConnection, DWORD, void*)
{
char buf[1024] = { 0 };
@@ -46,16 +46,14 @@ void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra) //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);
break;
}
if (cbRead) {
- if (!Netlib_Send(netlibcon, buf, cbRead, 0))
- {
+ if (!Netlib_Send(netlibcon, buf, cbRead, 0)) {
Netlib_CloseHandle(hConnection);
Netlib_CloseHandle(netlibcon);
break;
@@ -65,7 +63,7 @@ void XfireclientConnecting(HANDLE hConnection, DWORD, void* extra) }
//inits nachdem alle module geladen wurden
-int AfterSystemModulesLoaded(WPARAM wParam, LPARAM lParam)
+int AfterSystemModulesLoaded(WPARAM, LPARAM)
{
//init netlib handle
NETLIBUSER nlu = { 0 };
diff --git a/protocols/Xfire/src/Xfire_voicechat.cpp b/protocols/Xfire/src/Xfire_voicechat.cpp index 3795196aa2..acca27d1c9 100644 --- a/protocols/Xfire/src/Xfire_voicechat.cpp +++ b/protocols/Xfire/src/Xfire_voicechat.cpp @@ -2,7 +2,8 @@ #include "Xfire_voicechat.h"
//konstruktor
-Xfire_voicechat::Xfire_voicechat() {
+Xfire_voicechat::Xfire_voicechat()
+{
this->resetCurrentvoicestatus();
ipport = NULL;
tsrDLL = NULL;
@@ -28,7 +29,8 @@ void Xfire_voicechat::initVoicechat() }
//prüft ob das paket schonmal versendet wurde, soll unnötigen nwtraffic reduzieren, *ÜBERLEGUNG* ob wirklich notwendig
-BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) {
+BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet)
+{
if (packet == NULL)
return FALSE;
@@ -45,7 +47,8 @@ BOOL Xfire_voicechat::alreadySend(SendGameStatus2Packet* packet) { }
//prüft nach laufenden voicechat anwendungen
-BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) {
+BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet)
+{
//kein gültiger verweis?
if (packet == NULL)
return FALSE;
@@ -55,8 +58,7 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) { if (checkforTS2(packet)) {
return alreadySend(packet);
}
- else
- {
+ else {
//kein ts2 mehr? dann paket restten
resetSendGameStatus2Packet(packet);
resetCurrentvoicestatus();
@@ -69,8 +71,7 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) { if (checkforTS3(packet)) {
return alreadySend(packet);
}
- else
- {
+ else {
//kein ts3 mehr? dann paket restten
resetSendGameStatus2Packet(packet);
resetCurrentvoicestatus();
@@ -83,8 +84,7 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) { if (checkforMumble(packet)) {
return alreadySend(packet);
}
- else
- {
+ else {
//kein mumble mehr? dann paket restten
resetSendGameStatus2Packet(packet);
resetCurrentvoicestatus();
@@ -113,7 +113,8 @@ BOOL Xfire_voicechat::checkVoicechat(SendGameStatus2Packet* packet) { }
//setzte currentvoice auf 0 zurück, falls es einen disconnect gab
-void Xfire_voicechat::resetCurrentvoicestatus() {
+void Xfire_voicechat::resetCurrentvoicestatus()
+{
currentvoice = XFIREVOICECHAT_NOVOICE;
lastpacket.ip[3] = 0;
lastpacket.ip[2] = 0;
@@ -124,7 +125,8 @@ void Xfire_voicechat::resetCurrentvoicestatus() { }
//resettet das packet auf 0
-void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet) {
+void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet)
+{
if (packet == NULL)
return;
//voiceid
@@ -139,7 +141,8 @@ void Xfire_voicechat::resetSendGameStatus2Packet(SendGameStatus2Packet* packet) }
//schreibt derzetigen status in die mirandadb für variables usw
-void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) {
+void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet)
+{
//für sprintf
char temp[32];
@@ -171,7 +174,8 @@ void Xfire_voicechat::writeToDatabase(SendGameStatus2Packet* packet) { }
//versucht die TSR zuladen
-HMODULE Xfire_voicechat::loadTSR(char* path, BOOL nolocaltest) {
+HMODULE Xfire_voicechat::loadTSR(char*, BOOL nolocaltest)
+{
TCHAR pathtotsr[MAX_PATH] = _T("");
/*if (path)
@@ -181,8 +185,7 @@ HMODULE Xfire_voicechat::loadTSR(char* path, BOOL nolocaltest) { //versuche dll zuladen
HMODULE tsrDLL = LoadLibrary(pathtotsr);
//konnte nicht geladen werden
- if (!tsrDLL)
- {
+ if (!tsrDLL) {
XFireLog("TSRemote.dll load failed!");
//bei keinem lokalen test abbruch
@@ -215,7 +218,8 @@ HMODULE Xfire_voicechat::loadTSR(char* path, BOOL nolocaltest) { //teamspeak 3 detection, benötigt ts3plugin
-BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet) {
+BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet)
+{
//kein gültiger verweis?
if (packet == NULL)
return FALSE;
@@ -227,8 +231,7 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet) { //versuch ipport zubesorgen
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;
}
@@ -265,12 +268,12 @@ BOOL Xfire_voicechat::checkforTS3(SendGameStatus2Packet *packet) { }
//teamspeak 2 detection mit hilfe der tsr
-BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) {
+BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet)
+{
TtsrServerInfo serverinfo = { 0 };
//get funktion ist nicht initialisiert
- if (this->tsrGetServerInfo == NULL || packet == NULL)
- {
+ if (this->tsrGetServerInfo == NULL || packet == NULL) {
return FALSE;
}
@@ -278,11 +281,9 @@ 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)
- {
+ if (pos == 0) {
return FALSE;
}
@@ -311,14 +312,14 @@ BOOL Xfire_voicechat::checkforTS2(SendGameStatus2Packet* packet) { }
//detection für mumble
-BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) {
+BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet)
+{
//kein gültiger verweis?
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;
return FALSE;
}
@@ -335,10 +336,8 @@ BOOL Xfire_voicechat::checkforMumble(SendGameStatus2Packet* packet) { if (size) {
MIB_TCPTABLE_OWNER_PID *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++)
- {
+ if (GetExtendedTcpTable(ptab, &size, FALSE, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS, 0) == NO_ERROR) {
+ 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
{
unsigned char*rip = (unsigned char*)&ptab->table[i].dwRemoteAddr;
diff --git a/protocols/Xfire/src/Xfire_voicechat.h b/protocols/Xfire/src/Xfire_voicechat.h index 2a1a43a4ed..22da7485bc 100644 --- a/protocols/Xfire/src/Xfire_voicechat.h +++ b/protocols/Xfire/src/Xfire_voicechat.h @@ -35,8 +35,6 @@ #include "sendgamestatus2packet.h"
#include "Xfire_base.h"
-#include <vector>
-
/* tsr definitionen für teamspeak 2 */
struct TtsrServerInfo
{
diff --git a/protocols/Xfire/src/addgamedialog.cpp b/protocols/Xfire/src/addgamedialog.cpp index 2783d38c13..ea257308ca 100644 --- a/protocols/Xfire/src/addgamedialog.cpp +++ b/protocols/Xfire/src/addgamedialog.cpp @@ -15,7 +15,8 @@ Xfire_game* editgame = NULL; 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)) {
@@ -24,7 +25,8 @@ void AddGameDialog(HWND hwndDlg, Xfire_game* game) { 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);
@@ -36,8 +38,7 @@ static void FillGameList(LPVOID hwndDlg) { //das schließen des dialogs verhindern
dontClose = TRUE;
- if (Inicache.size() == 0)
- {
+ if (Inicache.size() == 0) {
//temp xfirebaseob für strlower
Xfire_base tempxfire;
//vector für doppelfilter
@@ -87,15 +88,12 @@ static void FillGameList(LPVOID hwndDlg) { //solange bis wir bei 0 angekommen sind
if (*p != 0)
p++;
- while (*p != 0)
- {
- if (*p == '['&&*(p - 1) == '\n')
- {
+ while (*p != 0) {
+ if (*p == '['&&*(p - 1) == '\n') {
z = zahlbuffer;
z2 = zahlbuffer2;
p++;
- while (*p >= '0'&&*p <= '9'&&p != 0)
- {
+ while (*p >= '0'&&*p <= '9'&&p != 0) {
*z = *p;
p++;
z++;
@@ -103,8 +101,7 @@ static void FillGameList(LPVOID hwndDlg) { *z = 0;
if (*p == '_') {
p++;
- while (*p >= '0'&&*p <= '9'&&p != 0)
- {
+ while (*p >= '0'&&*p <= '9'&&p != 0) {
*z2 = *p;
p++;
z2++;
@@ -113,12 +110,10 @@ static void FillGameList(LPVOID hwndDlg) { }
//erste zahl gefunden
- if (z != zahlbuffer)
- {
+ if (z != zahlbuffer) {
int gameid = atoi(zahlbuffer);
//prüfe ob das game schon in der gameliste ist
- if (!xgamelist.Gameinlist(gameid))
- {
+ if (!xgamelist.Gameinlist(gameid)) {
char*name = p;
lbInicache listentry;
char gameidtemp[10] = "";
@@ -141,13 +136,11 @@ static void FillGameList(LPVOID hwndDlg) { //spielnamen in den listentry einfügen
strcpy_s(listentry.name, 255, name);
- if (z2 != zahlbuffer2)
- {
+ if (z2 != zahlbuffer2) {
listentry.gameid = MAKELONG(gameid, atoi(zahlbuffer2));
mir_snprintf(gameidtemp, _countof(gameidtemp), "%d_%d", gameid, atoi(zahlbuffer2));
}
- else
- {
+ else {
listentry.gameid = gameid;
mir_snprintf(gameidtemp, _countof(gameidtemp), "%d", gameid);
}
@@ -157,8 +150,7 @@ 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, '\\'));
@@ -174,8 +166,7 @@ static void FillGameList(LPVOID hwndDlg) { ret[5] == '.'&&
ret[6] == 'e'&&
ret[7] == 'x'&&
- ret[8] == 'e')
- {
+ ret[8] == 'e') {
strcat_s(listentry.name, 255, " (Steam)");
}
}
@@ -201,8 +192,7 @@ static void FillGameList(LPVOID hwndDlg) { //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)
- {
+ if (dublBuffer.at(i) == uniqid) {
addtolist = FALSE;
break;
}
@@ -227,13 +217,11 @@ static void FillGameList(LPVOID hwndDlg) { p++;
}
}
- else
- {
+ else {
//liste mit dem cache aufbauen
for (uint i = 0; i < Inicache.size(); i++) {
//spielid in der liste spielliste?
- if (!xgamelist.Gameinlist(LOWORD(Inicache.at(i).gameid)))
- {
+ 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);
//gameid zuweisen
@@ -253,7 +241,8 @@ static void FillGameList(LPVOID hwndDlg) { dontClose = FALSE;
}
-BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe) {
+BOOL OpenFileDialog(HWND hwndDlg, OPENFILENAMEA*ofn, char*exe)
+{
//pointer zum exenamen
char* exename = NULL;
//buffer vom pfad
@@ -286,40 +275,33 @@ 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)
{
switch (uMsg) {
case WM_INITDIALOG:
- {
- //übersetzen lassen
- TranslateDialogDefault(hwndDlg);
+ {
+ //übersetzen lassen
+ TranslateDialogDefault(hwndDlg);
- //per thread liste füllen
- mir_forkthread(FillGameList, hwndDlg);
- }
+ //per thread liste füllen
+ mir_forkthread(FillGameList, hwndDlg);
+ }
break;
case WM_COMMAND:
- if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE)
- {
+ if (LOWORD(wParam) == IDC_SEARCH && HIWORD(wParam) == EN_CHANGE) {
char temp[256];
//eingabe bei der suche auslesen
GetDlgItemTextA(hwndDlg, IDC_SEARCH, temp, _countof(temp));
//eingabe in der liste suchen
int idx = SendDlgItemMessageA(hwndDlg, IDC_GAMELIST, LB_FINDSTRING, 0, (LPARAM)temp);
//gefunden?
- if (idx != LB_ERR)
- {
+ if (idx != LB_ERR) {
//als aktiv setzen
SendDlgItemMessage(hwndDlg, IDC_GAMELIST, LB_SETCURSEL, idx, 0);
}
}
- else if (LOWORD(wParam) == IDCANCEL)
- {
+ 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);
@@ -327,15 +309,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, }
return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
}
- else if (LOWORD(wParam) == IDC_CUSTOM)
- {
+ 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
- {
+ else {
char ret[512] = "";
char gameidtemp[10] = "";
@@ -369,15 +349,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, }
}
}
- else if (LOWORD(wParam) == IDOK)
- {
+ 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
- {
+ else {
//datei öffnen dialog
OPENFILENAMEA ofn;
//listdata auslesen, wo die gameid gespeihcert ist
@@ -404,15 +382,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, //launcherexe abfragen
if (xfire_GetPrivateProfileString(gameidtemp, "LauncherExe", "", ret, 512, inipath)) {
//datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg, &ofn, ret))
- {
+ if (OpenFileDialog(hwndDlg, &ofn, ret)) {
//lowercase pfad
newgame->strtolower(ofn.lpstrFile);
//pfad dem spiel zuordnen
newgame->setString(ofn.lpstrFile, &newgame->launchparams);
}
- else
- {
+ else {
//speicher freigeben
delete newgame;
return FALSE;
@@ -422,15 +398,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, //detectexe abfragen
if (xfire_GetPrivateProfileString(gameidtemp, "DetectExe", "", ret, 512, inipath)) {
//datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg, &ofn, ret))
- {
+ if (OpenFileDialog(hwndDlg, &ofn, ret)) {
//lowercase pfad
newgame->strtolower(ofn.lpstrFile);
//pfad dem spiel zuordnen
newgame->setString(ofn.lpstrFile, &newgame->path);
}
- else
- {
+ else {
//speicher freigeben
delete newgame;
return FALSE;
@@ -438,15 +412,13 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, } //MatchExe abfragen
else if (xfire_GetPrivateProfileString(gameidtemp, "MatchExe", "", ret, 512, inipath)) {
//datei vom user öffnen lassen
- if (OpenFileDialog(hwndDlg, &ofn, ret))
- {
+ if (OpenFileDialog(hwndDlg, &ofn, ret)) {
//lowercase pfad
newgame->strtolower(ofn.lpstrFile);
//pfad dem spiel zuordnen
newgame->setString(ofn.lpstrFile, &newgame->path);
}
- else
- {
+ else {
//speicher freigeben
delete newgame;
return FALSE;
@@ -520,10 +492,9 @@ INT_PTR CALLBACK DlgAddGameProc(HWND hwndDlg, }
-INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM)
{
- switch (uMsg)
- {
+ switch (uMsg) {
case WM_INITDIALOG:
//ein spiel wurde zum editieren geöffnet, felder alle vorbelegen
if (editgame) {
@@ -543,8 +514,7 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_ID), FALSE);
//sendgameid setzen, bei -1 leer lassen
- if (editgame->send_gameid != -1)
- {
+ if (editgame->send_gameid != -1) {
_itoa_s(editgame->send_gameid, gameid, 10, 10);
SetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, gameid);
}
@@ -575,290 +545,247 @@ INT_PTR CALLBACK DlgAddGameProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM return TRUE;
case WM_COMMAND:
- {
- 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"))
- {
- SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, ofn.lpstrFile);
+ 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_ADD_BROWSELAUNCHER)
- {
- OPENFILENAMEA ofn;
- if (OpenFileDialog(hwndDlg, &ofn, "*.exe"))
- {
- SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, ofn.lpstrFile);
+ 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) == 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_BROWSEDETECT) {
+ OPENFILENAMEA ofn;
+ if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, 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) == IDC_ADD_BROWSELAUNCHER) {
+ OPENFILENAMEA ofn;
+ if (OpenFileDialog(hwndDlg, &ofn, "*.exe")) {
+ SetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, 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;
+ }
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
+ }
+ else if (LOWORD(wParam) == IDOK) {
+ char temp[256];
- //neuen gameeintrag anlegen
- Xfire_game* newgame = NULL;
+ //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;
+ }
- if (editgame)
- newgame = editgame;
- else
- newgame = new Xfire_game();
-
- //Spielname
- GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, _countof(temp));
- if (!mir_strlen(temp))
- {
- if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please enter a game name."), 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, _countof(temp));
- if (!mir_strlen(temp))
- {
+ //neuen gameeintrag anlegen
+ Xfire_game* newgame = NULL;
+
+ if (editgame)
+ newgame = editgame;
+ else
+ newgame = new Xfire_game();
+
+ //Spielname
+ GetDlgItemTextA(hwndDlg, IDC_ADD_NAME, temp, _countof(temp));
+ if (!mir_strlen(temp)) {
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 name."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
}
- else
- {
- int gameid = atoi(temp);
- //negative gameid blocken
- if (gameid < 1)
- {
+ 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, _countof(temp));
+ if (!mir_strlen(temp)) {
if (!editgame) delete newgame;
- return MessageBox(hwndDlg, TranslateT("Please enter a game ID above 1."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION);
+ return MessageBox(hwndDlg, TranslateT("Please enter a game ID."), 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);
+ else {
+ 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;
}
- //gameid zuordnen
- newgame->id = gameid;
+ }
+ //zu sendene spielid
+ GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, _countof(temp));
+ if (mir_strlen(temp)) {
//standardmäßig wird bei einem customeintrag keine id versendet
- newgame->send_gameid = -1;
+ int sendid = atoi(temp);
+ if (sendid > 0)
+ newgame->send_gameid = sendid;
}
- }
- //zu sendene spielid
- GetDlgItemTextA(hwndDlg, IDC_ADD_SENDID, temp, _countof(temp));
- if (mir_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, _countof(temp));
- if (mir_strlen(temp))
- {
- //lowercase pfad
- newgame->strtolower(temp);
- //detect exe
- newgame->setString(temp, &newgame->launchparams);
- }
- //detectexe
- GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, _countof(temp));
- if (!mir_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)
+ //launcher exe
+ GetDlgItemTextA(hwndDlg, IDC_ADD_LAUNCHEREXE, temp, _countof(temp));
+ if (mir_strlen(temp)) {
+ //lowercase pfad
+ newgame->strtolower(temp);
+ //detect exe
newgame->setString(temp, &newgame->launchparams);
+ }
+ //detectexe
+ GetDlgItemTextA(hwndDlg, IDC_ADD_DETECTEXE, temp, _countof(temp));
+ if (!mir_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, _countof(temp));
- if (mir_strlen(temp))
- {
- newgame->setString(temp, &newgame->mustcontain);
- }
- //statusmsg speichern
- GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, _countof(temp));
- if (mir_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();
+ }
+ //mustcontain parameter
+ GetDlgItemTextA(hwndDlg, IDC_ADD_CUSTOMPARAMS, temp, _countof(temp));
+ if (mir_strlen(temp)) {
+ newgame->setString(temp, &newgame->mustcontain);
+ }
+ //statusmsg speichern
+ GetDlgItemTextA(hwndDlg, IDC_ADD_STATUSMSG, temp, _countof(temp));
+ if (mir_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);
+ return SendMessage(GetParent(hwndDlg), WM_CLOSE, 0, 0);
+ }
+ break;
}
- break;
- }
}
return FALSE;
}
-
-INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam
- )
+INT_PTR CALLBACK DlgAddGameProcMain(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam)
{
- switch (uMsg)
- {
+ TCITEM tci;
+
+ switch (uMsg) {
case WM_INITDIALOG:
- {
- TCITEMA tci = { 0 };
- int iTotal;
- RECT rcClient;
+ {
+ 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);
+ hPage = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADDGAME), hwndDlg, DlgAddGameProc);
- //bei editgame keine spiellisteauswahl
- if (!editgame)
- {
+ //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_ADDGAME2), hwndDlg, DlgAddGameProc2);
iTotal = TabCtrl_GetItemCount(hwndTab);
tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = (LPARAM)hPage;
- tci.pszText = Translate("Supported Games");
+ tci.pszText = Translate("Custom game");
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_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);
- }
+ //bei editgame 2. registerkarte aktiv schalten
+ if (!editgame) {
+ ShowWindow(hPage, FALSE);
+ TabCtrl_SetCurSel(hwndTab, 0);
+ }
+ }
return TRUE;
- }
+
case WM_CLOSE:
//nicht schließen, wenn noch der thread läuft
if (dontClose) return FALSE;
//buffer leeren
- if (buffer)
- {
+ if (buffer) {
delete[] buffer;
buffer = NULL;
}
EndDialog(hwndDlg, 0);
break;
+
case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom)
- {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- switch (((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- {
- TCITEM tci;
int i, count;
-
tci.mask = TCIF_PARAM;
count = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_OPTIONSTAB));
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_OPTIONSTAB), i, &tci);
SendMessage((HWND)tci.lParam, WM_NOTIFY, 0, lParam);
}
break;
}
- }
break;
case IDC_OPTIONSTAB:
- {
HWND hTabCtrl = GetDlgItem(hwndDlg, IDC_OPTIONSTAB);
- switch (((LPNMHDR)lParam)->code)
- {
+ 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);
- }
break;
case TCN_SELCHANGE:
- {
- TCITEM tci;
-
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(hTabCtrl, TabCtrl_GetCurSel(hTabCtrl), &tci);
ShowWindow((HWND)tci.lParam, SW_SHOW);
- }
break;
}
break;
}
- }
break;
}
return FALSE;
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp index 42936c9df0..5589a687fa 100644 --- a/protocols/Xfire/src/all_statusmsg.cpp +++ b/protocols/Xfire/src/all_statusmsg.cpp @@ -7,9 +7,6 @@ extern Xfire_gamelist xgamelist;
-
-#include <vector>
-
using namespace std;
#include "xdebug.h"
@@ -23,7 +20,8 @@ PROTOACCOUNT **temp; int anz, statusid;
int statustype;
-BOOL BackupStatusMsg() {
+BOOL BackupStatusMsg()
+{
DBVARIANT dbv;
statustype = db_get_b(NULL, protocolname, "statuschgtype", 0);
@@ -31,44 +29,38 @@ BOOL BackupStatusMsg() { XFireLog("Backup Status Message...");
//alten vector löschen
- if (olstatusmsg != NULL)
- {
+ if (olstatusmsg != NULL) {
delete olstatusmsg;
olstatusmsg = NULL;
}
- if (protoname != NULL)
- {
+ if (protoname != NULL) {
delete protoname;
protoname = NULL;
}
- if (olstatus != NULL)
- {
+ if (olstatus != NULL) {
delete olstatus;
olstatus = NULL;
}
- if (oltostatus != NULL)
- {
+ if (oltostatus != NULL) {
delete oltostatus;
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
Proto_EnumAccounts(&anz, &temp);
- for (int i = 0; i < anz; i++)
- {
+ for (int i = 0; i < anz; i++) {
statusid = CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0);
XFireLog("Get Status of %s ...", temp[i]->szModuleName);
//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 ||
- !mir_strcmpi(temp[i]->szModuleName, protocolname) ||
- !ProtoServiceExists(temp[i]->szModuleName, PS_SETAWAYMSG) ||
- db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1)
- {
+ if (!temp[i]->bIsEnabled || statusid == ID_STATUS_INVISIBLE || statusid == ID_STATUS_OFFLINE ||
+ !mir_strcmpi(temp[i]->szModuleName, protocolname) ||
+ !ProtoServiceExists(temp[i]->szModuleName, PS_SETAWAYMSG) ||
+ db_get_b(NULL, temp[i]->szModuleName, "LockMainStatus", 0) == 1) {
XFireLog("-> Skip %s.", temp[i]->szModuleName);
olstatus->push_back(-1);
@@ -78,32 +70,26 @@ BOOL BackupStatusMsg() { continue;
}
- if (statustype)
- {
+ if (statustype) {
int dummystatusid = -1;
- if (statusid != 0)
- {
+ if (statusid != 0) {
int caps = CallProtoService(temp[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
bool dndFirst = db_get_b(NULL, protocolname, "dndfirst", 0) > 0;
- if (dndFirst ? caps & PF2_HEAVYDND : caps & PF2_LIGHTDND)
- {
+ 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");
}
- else if (dndFirst ? caps&PF2_LIGHTDND : caps&PF2_HEAVYDND)
- {
+ 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");
}
- else if (caps&PF2_SHORTAWAY)
- {
+ else if (caps&PF2_SHORTAWAY) {
dummystatusid = ID_STATUS_AWAY;
XFireLog("%s supports AWAY.", temp[i]->szModuleName);
}
- else
- {
+ else {
dummystatusid = statusid;
XFireLog("%s no Away???.", temp[i]->szModuleName);
}
@@ -112,8 +98,7 @@ BOOL BackupStatusMsg() { oltostatus->push_back(dummystatusid);
}
- switch (statusid)
- {
+ switch (statusid) {
case ID_STATUS_ONLINE:
if (db_get(NULL, "SRAway", "OnMsg", &dbv))
olstatusmsg->push_back(Translate("Yep, I'm here."));
@@ -156,8 +141,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);
//freigeben
@@ -173,16 +157,14 @@ BOOL BackupStatusMsg() { BOOL SetGameStatusMsg()
{
//prüfe ob vector leer
- if (olstatusmsg == NULL)
- {
+ if (olstatusmsg == NULL) {
return FALSE;
}
ptrA statusMsg;
//zusetzende statusmsg erstellen
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
+ if (ServiceExists(MS_VARS_FORMATSTRING)) {
ptrT statusMsgT(db_get_tsa(NULL, protocolname, "setstatusmsg"));
//direkte funktionen verwenden
statusMsgT = variables_parse(statusMsgT, NULL, 0);
@@ -191,8 +173,7 @@ BOOL SetGameStatusMsg() statusMsg = _T2A(statusMsgT);
}
- else
- {
+ else {
//alternativ zweig ohne variables
ptrA statusMsg(db_get_sa(NULL, protocolname, "setstatusmsg"));
if (statusMsg == NULL)
@@ -226,15 +207,11 @@ BOOL SetGameStatusMsg() }
Proto_EnumAccounts(&anz, &temp);
- for (int i = 0; i < anz; i++)
- {
- if (olstatus->at(i) != -1)
- {
- if (statustype)
- {
+ for (int i = 0; i < anz; i++) {
+ if (olstatus->at(i) != -1) {
+ if (statustype) {
//newawaysys
- if (ServiceExists("NewAwaySystem/SetStateA"))
- {
+ if (ServiceExists("NewAwaySystem/SetStateA")) {
XFireLog("-> SetStatusMsg of %s with NewAwaySystem/SetStateA.", protoname->at(i).c_str());
NAS_PROTOINFO npi = { 0 };
@@ -254,8 +231,7 @@ BOOL SetGameStatusMsg() npi.szMsg = mir_strdup(statusMsg);
CallService("NewAwaySystem/SetStateW", (WPARAM)&npi, 1);
}
- else
- {
+ else {
XFireLog("-> SetStatusMsg of %s with Miranda with occupied status.", protoname->at(i).c_str());
//statusmsg für beschäftigt setzen
@@ -264,15 +240,13 @@ BOOL SetGameStatusMsg() //status auf beschäftigt wechseln
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), wszStatus);
}
}
}
- else
- {
+ else {
XFireLog("-> SetStatusMsg of %s.", protoname->at(i).c_str());
ptrW wszStatus(mir_a2u(statusMsg));
@@ -291,21 +265,17 @@ BOOL SetOldStatusMsg() return FALSE;
Proto_EnumAccounts(&anz, &temp);
- for (int i = 0; i < anz; i++)
- {
- if (olstatus->at(i) != -1)
- {
+ for (int i = 0; i < anz; i++) {
+ if (olstatus->at(i) != -1) {
ptrW wszStatus(mir_a2u(olstatusmsg->at(i).c_str()));
- if (statustype)
- {
+ if (statustype) {
//alten status setzen
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), wszStatus);
}
- else
- {
+ else {
CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, olstatus->at(i), 0);
CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), wszStatus);
}
@@ -313,26 +283,22 @@ BOOL SetOldStatusMsg() }
//alten vector löschen
- if (protoname != NULL)
- {
+ if (protoname != NULL) {
delete protoname;
protoname = NULL;
}
- if (olstatusmsg != NULL)
- {
+ if (olstatusmsg != NULL) {
delete olstatusmsg;
olstatusmsg = NULL;
}
- if (olstatus != NULL)
- {
+ if (olstatus != NULL) {
delete olstatus;
olstatus = NULL;
}
- if (oltostatus != NULL)
- {
+ if (oltostatus != NULL) {
delete olstatus;
olstatus = NULL;
}
return TRUE;
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/authpacket.cpp b/protocols/Xfire/src/authpacket.cpp index 9183fd1e48..19e618854d 100644 --- a/protocols/Xfire/src/authpacket.cpp +++ b/protocols/Xfire/src/authpacket.cpp @@ -26,22 +26,26 @@ #include "xfireparse.h" #include "variablevalue.h" -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + using namespace std; - AuthPacket::AuthPacket() : XFireRecvPacketContent() { - salt = 0; - } - AuthPacket::~AuthPacket() { - delete salt; - } + AuthPacket::AuthPacket() : XFireRecvPacketContent() + { + salt = 0; + } - void AuthPacket::parseContent(char *buf, int length, int numberOfAtts) { - - //XFireParse parse; - salt = new VariableValue(); - //parse.readVariableValue(buf, 0, length, salt); - salt->readVariableValue(buf, 0, length); - } + AuthPacket::~AuthPacket() + { + delete salt; + } + void AuthPacket::parseContent(char *buf, int length, int) + { + + //XFireParse parse; + salt = new VariableValue(); + //parse.readVariableValue(buf, 0, length, salt); + salt->readVariableValue(buf, 0, length); + } }; diff --git a/protocols/Xfire/src/authpacket.h b/protocols/Xfire/src/authpacket.h index 5a9f5bb057..ad642175f3 100644 --- a/protocols/Xfire/src/authpacket.h +++ b/protocols/Xfire/src/authpacket.h @@ -30,24 +30,24 @@ namespace xfirelib { - class AuthPacket : public XFireRecvPacketContent { - public: - AuthPacket(); - virtual ~AuthPacket(); + class AuthPacket : public XFireRecvPacketContent { + public: + AuthPacket(); + virtual ~AuthPacket(); - XFirePacketContent* newPacket() { return new AuthPacket(); } + XFirePacketContent* newPacket() { return new AuthPacket(); } - int getPacketId() { return XFIRE_PACKET_AUTH_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_PACKET_AUTH_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); - VariableValue *getSalt() { return salt; } - private: - VariableValue *salt; - }; + VariableValue *getSalt() { return salt; } + private: + VariableValue *salt; + }; }; diff --git a/protocols/Xfire/src/baseProtocol.h b/protocols/Xfire/src/baseProtocol.h index 7723cc1aa7..67232ce1be 100644 --- a/protocols/Xfire/src/baseProtocol.h +++ b/protocols/Xfire/src/baseProtocol.h @@ -194,10 +194,10 @@ typedef struct { 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.
int Flags;
diff --git a/protocols/Xfire/src/buddyinfo.cpp b/protocols/Xfire/src/buddyinfo.cpp index bcd9d47c81..85e38712b1 100644 --- a/protocols/Xfire/src/buddyinfo.cpp +++ b/protocols/Xfire/src/buddyinfo.cpp @@ -23,42 +23,40 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "buddyinfo.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + using namespace std; - void BuddyInfoPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; + void BuddyInfoPacket::parseContent(char *buf, int, int) + { + int index = 0; - VariableValue val; + VariableValue val; - XDEBUG2( "Len: %ld\n", length ); + XDEBUG2("Len: %ld\n", length); - index+=2; //paar bytes überspringen + index += 2; //paar bytes überspringen - index += val.readValue(buf,index,4); - this->userid = val.getValueAsLong(); + index += val.readValue(buf, index, 4); + this->userid = val.getValueAsLong(); - XDEBUG2( "UserId: %ld\n", this->userid); + XDEBUG2("UserId: %ld\n", this->userid); - index+=2; + index += 2; - this->avatarmode = buf[index]; - XDEBUG2( "Avatarmode: %ld\n", this->avatarmode); - index+=6; + this->avatarmode = buf[index]; + XDEBUG2("Avatarmode: %ld\n", this->avatarmode); + index += 6; - index += val.readValue(buf,index,4); - this->avatarid = val.getValueAsLong(); - XDEBUG2( "Avatarid: %ld\n", this->avatarid); - - } - + index += val.readValue(buf, index, 4); + this->avatarid = val.getValueAsLong(); + XDEBUG2("Avatarid: %ld\n", this->avatarid); + } };
\ No newline at end of file diff --git a/protocols/Xfire/src/buddyinfo.h b/protocols/Xfire/src/buddyinfo.h index 54f918dffd..ca13d62341 100644 --- a/protocols/Xfire/src/buddyinfo.h +++ b/protocols/Xfire/src/buddyinfo.h @@ -27,24 +27,23 @@ #define __BUDDYINFO_H #include "xfirerecvpacketcontent.h" -#include <string> #define XFIRE_BUDDYINFO 0xAE namespace xfirelib { - class BuddyInfoPacket : public XFireRecvPacketContent { - public: - virtual ~BuddyInfoPacket() { } - int getPacketId() { return XFIRE_BUDDYINFO; } + class BuddyInfoPacket : public XFireRecvPacketContent { + public: + virtual ~BuddyInfoPacket() { } + int getPacketId() { return XFIRE_BUDDYINFO; } - XFirePacketContent *newPacket() { return new BuddyInfoPacket(); } - void parseContent(char *buf, int length, int numberOfAtts); + XFirePacketContent *newPacket() { return new BuddyInfoPacket(); } + void parseContent(char *buf, int length, int numberOfAtts); - unsigned char avatarmode; - unsigned int avatarid; - unsigned int userid; + unsigned char avatarmode; + unsigned int avatarid; + unsigned int userid; - }; + }; }; diff --git a/protocols/Xfire/src/buddylist.cpp b/protocols/Xfire/src/buddylist.cpp index e3a5dd7dff..f5012eea53 100644 --- a/protocols/Xfire/src/buddylist.cpp +++ b/protocols/Xfire/src/buddylist.cpp @@ -22,8 +22,6 @@ #include "stdafx.h" -#include <iostream> -#include <vector> #include "buddylist.h" #include "buddylistonlinepacket.h" #include "buddylistgamespacket.h" @@ -39,335 +37,357 @@ extern MCONTACT handlingBuddys(xfirelib::BuddyListEntry *entry, int clan=0,char* group=NULL,BOOL dontscan=FALSE); extern void setBuddyStatusMsg(xfirelib::BuddyListEntry *entry); -namespace xfirelib { - - using namespace std; - - BuddyList::BuddyList(Client *client) { - entries = new vector<BuddyListEntry *>; - - //clan entries initialisieren - dufte - entriesClan = new vector<BuddyListEntry *>; - - this->client = client; - this->client->addPacketListener( this ); - } - BuddyList::~BuddyList() { - for(vector<BuddyListEntry *>::iterator it = entries->begin(); - it != entries->end(); it++) { - delete *it; - } - delete entries; - - //clan entries entfernen - dufte - for(vector<BuddyListEntry *>::iterator it = entriesClan->begin(); - it != entriesClan->end(); it++) { - delete *it; - } - delete entriesClan; - } - - BuddyListEntry *BuddyList::getBuddyById(long userid) { - for(uint i = 0 ; i < entries->size() ; i++) { - BuddyListEntry *entry = entries->at(i); - if (entry->userid == userid) - return entry; - } - - //clan entries durchsuchen - dufte - for(uint i = 0 ; i < entriesClan->size() ; i++) { - BuddyListEntry *entry = entriesClan->at(i); - if (entry->userid == userid) - return entry; - } - - return 0; - } - - BuddyListEntry *BuddyList::getBuddyByName(string username) { - for(uint i = 0 ; i < entries->size() ; i++) { - BuddyListEntry *entry = entries->at(i); - if (entry->username == username) - return entry; - } - - //clan entries durchsuchen - dufte - for(uint i = 0 ; i < entriesClan->size() ; i++) { - BuddyListEntry *entry = entriesClan->at(i); - if (entry->username == username) - return entry; - } - - return 0; - } - - BuddyListEntry *BuddyList::getBuddyBySid(const char *sid) { - for(uint i = 0 ; i < entries->size() ; i++) { - BuddyListEntry *entry = entries->at(i); - - if (memcmp((void *)sid,(void *)entry->sid,16) == 0) - return entry; - - } - - //clan entries durchsuchen - dufte - for(uint i = 0 ; i < entriesClan->size() ; i++) { - BuddyListEntry *entry = entriesClan->at(i); - - if (memcmp((void *)sid,(void *)entry->sid,16) == 0) - return entry; - - } - - return 0; - } - - - void BuddyList::initEntries(BuddyListNamesPacket *buddyNames) { - for(uint i = 0 ; i < buddyNames->usernames->size() ; i++) { - BuddyListEntry *entry = new BuddyListEntry; - entry->username = buddyNames->usernames->at(i); - entry->userid = buddyNames->userids->at(i); - entry->nick = buddyNames->nicks->at(i); - //buddies in miranda verarbeiten - handlingBuddys(entry,0,NULL); - entries->push_back(entry); - } - } - - // funktion zum initialisieren der clanliste - dufte - void BuddyList::initEntriesClan(ClanBuddyListNamesPacket *buddyNames) { - for(uint i = 0 ; i < buddyNames->usernames->size() ; i++) { - BuddyListEntry *entry = new BuddyListEntry; - entry->username = buddyNames->usernames->at(i); - entry->userid = buddyNames->userids->at(i); - entry->nick = buddyNames->nicks->at(i); - entry->clanid = buddyNames->clanid; - /* ## buddies im miranda verarbietn */ - char temp[255]; - char * dummy; - mir_snprintf(temp,_countof(temp),"Clan_%d",entry->clanid); - - DBVARIANT dbv; - if (!db_get(NULL,protocolname,temp,&dbv)) - { - dummy=dbv.pszVal; - } - else - dummy=NULL; - - handlingBuddys(entry,entry->clanid,dummy); - /* ## ende */ - entriesClan->push_back(entry); - } - } - - void BuddyList::updateFriendsofFriend(FriendsBuddyListNamesPacket* friends) - { - for(uint i = 0 ; i < friends->sids->size() ; i++) { - BuddyListEntry *entry = getBuddyBySid( friends->sids->at(i) ); - if (entry){ - XDEBUG2("Friends of Friend %s!\n",friends->usernames->at(i).c_str()); - entry->nick=friends->nicks->at(i); - entry->username=friends->usernames->at(i); - entry->userid=friends->userids->at(i); - }else{ - XERROR(("updateFriendsofFriendBuddies: sid not found!\n")); - } - } - } - - void BuddyList::updateOnlineBuddies(BuddyListOnlinePacket* buddiesOnline) { - for(uint i = 0 ; i < buddiesOnline->userids->size() ; i++) { - BuddyListEntry *entry = getBuddyById( buddiesOnline->userids->at(i) ); - if (entry){ - entry->setSid( buddiesOnline->sids->at(i) ); - //buddies in miranda verarbeiten - handlingBuddys(entry,0,NULL); - }else{ - XERROR(("updateOnlineBuddies: Could not find buddy with this sid!\n")); - } - } - } - - void BuddyList::updateBuddiesGame(BuddyListGamesPacket* buddiesGames) { - bool isFirst = buddiesGames->getPacketId() == XFIRE_BUDDYS_GAMES_ID; - for(uint i = 0 ; i < buddiesGames->sids->size() ; i++) { - BuddyListEntry *entry = getBuddyBySid( buddiesGames->sids->at(i) ); - if (!entry) { - //nicht zuordbare sids zuordnen - XERROR("Add dummy Contact in buddylist for friends of friends!\n"); - BuddyListEntry *newentry = new BuddyListEntry; - newentry->username = ""; - newentry->userid = 0; - newentry->nick = ""; - newentry->setSid(buddiesGames->sids->at(i)); - entries->push_back(newentry); - //nochmal entry suchen - entry = newentry; //getBuddyBySid( buddiesGames->sids->at(i) ); - } - if (entry){ - if (isFirst) { - entry->game = buddiesGames->gameids->at(i); - delete entry->gameObj; entry->gameObj = NULL; - } else { - entry->game2 = buddiesGames->gameids->at(i); - delete entry->game2Obj; entry->game2Obj = NULL; +namespace xfirelib +{ + + using namespace std; + + BuddyList::BuddyList(Client *client) + { + entries = new vector<BuddyListEntry *>; + + //clan entries initialisieren - dufte + entriesClan = new vector<BuddyListEntry *>; + + this->client = client; + this->client->addPacketListener(this); + } + BuddyList::~BuddyList() + { + for (vector<BuddyListEntry *>::iterator it = entries->begin(); + it != entries->end(); it++) { + delete *it; + } + delete entries; + + //clan entries entfernen - dufte + for (vector<BuddyListEntry *>::iterator it = entriesClan->begin(); + it != entriesClan->end(); it++) { + delete *it; + } + delete entriesClan; } - XDEBUG(( "Resolving Game... \n" )); - XFireGameResolver *resolver = client->getGameResolver(); - if (resolver) { - XDEBUG(( "Resolving Game... \n" )); - if (isFirst) - entry->gameObj = resolver->resolveGame( entry->game, i, buddiesGames ); - else - entry->game2Obj = resolver->resolveGame( entry->game2, i, buddiesGames ); - } else { - XDEBUG(( "No GameResolver ? :(\n" )); + + BuddyListEntry *BuddyList::getBuddyById(long userid) + { + for (uint i = 0; i < entries->size(); i++) { + BuddyListEntry *entry = entries->at(i); + if (entry->userid == userid) + return entry; + } + + //clan entries durchsuchen - dufte + for (uint i = 0; i < entriesClan->size(); i++) { + BuddyListEntry *entry = entriesClan->at(i); + if (entry->userid == userid) + return entry; + } + + return 0; } - XDEBUG(( "%s: Game (%ld): %s / Game2 (%ld): %s\n", - entry->username.c_str(), - entry->game, - (entry->gameObj == NULL ? "UNKNOWN" : entry->gameObj->getGameName().c_str()), - entry->game2, - (entry->game2Obj== NULL ? "UNKNOWN" :entry->game2Obj->getGameName().c_str()) - )); - }else{ - XERROR("updateBuddiesGame: Could not find buddy with this sid!\n"); - } - } - } - - void BuddyList::receivedPacket(XFirePacket *packet) { - XFirePacketContent *content = packet->getContent(); - if (content == 0) return; - XDEBUG2( "hmm... %d\n", content->getPacketId() ); - switch(content->getPacketId()) { - case XFIRE_BUDDYS_NAMES_ID: { - XINFO(( "Received Buddy List..\n" )); - this->initEntries( (BuddyListNamesPacket*)content ); - break; - } - case XFIRE_CLAN_BUDDYS_NAMES_ID: { - XINFO(( "Received Clan Buddy List..\n" )); - this->initEntriesClan( (ClanBuddyListNamesPacket*)content ); - break; - } - //neue nicks updaten, dufte - case XFIRE_RECVBUDDYCHANGEDNICK: { - RecvBuddyChangedNick* recvchangednick=(RecvBuddyChangedNick*)content; - XINFO(( "Received new nick of a buddy..\n" )); - BuddyListEntry* entry=NULL; - entry=this->getBuddyById(recvchangednick->userid); - if (entry) { - entry->nick=recvchangednick->newnick; - recvchangednick->entry=(void*)entry; - handlingBuddys(entry,0,NULL); - } - break; - } - case XFIRE_BUDDYS_ONLINE_ID: { - XINFO(( "Received Buddy Online Packet..\n" )); - this->updateOnlineBuddies( (BuddyListOnlinePacket *)content ); - break; - } - case XFIRE_FRIENDS_BUDDYS_NAMES_ID: { - XINFO(( "Received Friends of Friend..\n" )); - this->updateFriendsofFriend( (FriendsBuddyListNamesPacket *)content ); - break; - } - case XFIRE_BUDDYS_GAMES2_ID: - case XFIRE_BUDDYS_GAMES_ID: { - XINFO(( "Recieved the game a buddy is playing..\n" )); - this->updateBuddiesGame( (BuddyListGamesPacket *)content ); - break; - } - case XFIRE_RECVREMOVEBUDDYPACKET: { - RecvRemoveBuddyPacket *p = (RecvRemoveBuddyPacket*)content; - XDEBUG2( "Buddy was removed from contact list (userid: %ld)\n", p->userid ); - std::vector<BuddyListEntry *>::iterator i = entries->begin(); - while( i != entries->end() ) { - if ((*i)->userid == p->userid) { - BuddyListEntry *buddy = *i; - XINFO(( "%s (%s) was removed from BuddyList.\n", buddy->username.c_str(), buddy->nick.c_str() )); - p->username = buddy->username; - p->handle = buddy->hcontact; // handle übergeben - dufte - entries->erase(i); - // i.erase(); - break; // we are done. + + BuddyListEntry *BuddyList::getBuddyByName(string username) + { + for (uint i = 0; i < entries->size(); i++) { + BuddyListEntry *entry = entries->at(i); + if (entry->username == username) + return entry; + } + + //clan entries durchsuchen - dufte + for (uint i = 0; i < entriesClan->size(); i++) { + BuddyListEntry *entry = entriesClan->at(i); + if (entry->username == username) + return entry; + } + + return 0; } - ++i; - } - break; - } - case XFIRE_RECV_STATUSMESSAGE_PACKET_ID: { - RecvStatusMessagePacket *status = (RecvStatusMessagePacket*) content; - - //status->entries=new PBuddyListEntry[status->sids->size]; - - for(uint i = 0 ; i < status->sids->size() ; i++) { - BuddyListEntry *entry = getBuddyBySid( status->sids->at(i) ); - //status->entries[i]=entry; - - if (entry == NULL) { - XERROR(( "No such Entry - Got StatusMessage from someone who is not in the buddylist ??\n" )); - return; - } - else - { - entry->statusmsg = status->msgs->at(i); - setBuddyStatusMsg(entry); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das - //das problem der fehlenden statusmsg + + BuddyListEntry *BuddyList::getBuddyBySid(const char *sid) + { + for (uint i = 0; i < entries->size(); i++) { + BuddyListEntry *entry = entries->at(i); + + if (memcmp((void *)sid, (void *)entry->sid, 16) == 0) + return entry; + + } + + //clan entries durchsuchen - dufte + for (uint i = 0; i < entriesClan->size(); i++) { + BuddyListEntry *entry = entriesClan->at(i); + + if (memcmp((void *)sid, (void *)entry->sid, 16) == 0) + return entry; + } - } - - break; - } - } - } - - BuddyListEntry::~BuddyListEntry() { - if (lastpopup) { - delete[] lastpopup; - lastpopup=NULL; - } - } - - BuddyListEntry::BuddyListEntry() { - memset(sid,0,16); - statusmsg = std::string(); - game = 0; - game2 = 0; - gameObj = NULL; - game2Obj = NULL; - hcontact = NULL; - clanid = 0; - lastpopup=NULL; - } - bool BuddyListEntry::isOnline() { - for(int i = 0 ; i < 16 ; i++) { - if (sid[i]) return true; - } - return false; - } - void BuddyListEntry::setSid(const char *sid) { - int s=0; - for(int i = 0 ; i < 16 ; i++) { //wenn buddy offline geht, seine gameinfos zurücksetzen - dufte - if (sid[i]) - { - s=1; - break; - } - } - if (s) + + return 0; + } + + + void BuddyList::initEntries(BuddyListNamesPacket *buddyNames) { - this->statusmsg = std::string(); - this->game = 0; - this->game2 = 0; - this->gameObj = NULL; - this->game2Obj = NULL; + for (uint i = 0; i < buddyNames->usernames->size(); i++) { + BuddyListEntry *entry = new BuddyListEntry; + entry->username = buddyNames->usernames->at(i); + entry->userid = buddyNames->userids->at(i); + entry->nick = buddyNames->nicks->at(i); + //buddies in miranda verarbeiten + handlingBuddys(entry, 0, NULL); + entries->push_back(entry); + } + } + + // funktion zum initialisieren der clanliste - dufte + void BuddyList::initEntriesClan(ClanBuddyListNamesPacket *buddyNames) + { + for (uint i = 0; i < buddyNames->usernames->size(); i++) { + BuddyListEntry *entry = new BuddyListEntry; + entry->username = buddyNames->usernames->at(i); + entry->userid = buddyNames->userids->at(i); + entry->nick = buddyNames->nicks->at(i); + entry->clanid = buddyNames->clanid; + /* ## buddies im miranda verarbietn */ + char temp[255]; + char * dummy; + mir_snprintf(temp, _countof(temp), "Clan_%d", entry->clanid); + + DBVARIANT dbv; + if (!db_get(NULL, protocolname, temp, &dbv)) { + dummy = dbv.pszVal; + } + else + dummy = NULL; + + handlingBuddys(entry, entry->clanid, dummy); + /* ## ende */ + entriesClan->push_back(entry); + } + } + + void BuddyList::updateFriendsofFriend(FriendsBuddyListNamesPacket* friends) + { + for (uint i = 0; i < friends->sids->size(); i++) { + BuddyListEntry *entry = getBuddyBySid(friends->sids->at(i)); + if (entry) { + XDEBUG2("Friends of Friend %s!\n", friends->usernames->at(i).c_str()); + entry->nick = friends->nicks->at(i); + entry->username = friends->usernames->at(i); + entry->userid = friends->userids->at(i); + } + else { + XERROR(("updateFriendsofFriendBuddies: sid not found!\n")); + } + } + } + + void BuddyList::updateOnlineBuddies(BuddyListOnlinePacket* buddiesOnline) + { + for (uint i = 0; i < buddiesOnline->userids->size(); i++) { + BuddyListEntry *entry = getBuddyById(buddiesOnline->userids->at(i)); + if (entry) { + entry->setSid(buddiesOnline->sids->at(i)); + //buddies in miranda verarbeiten + handlingBuddys(entry, 0, NULL); + } + else { + XERROR(("updateOnlineBuddies: Could not find buddy with this sid!\n")); + } + } + } + + void BuddyList::updateBuddiesGame(BuddyListGamesPacket* buddiesGames) + { + bool isFirst = buddiesGames->getPacketId() == XFIRE_BUDDYS_GAMES_ID; + for (uint i = 0; i < buddiesGames->sids->size(); i++) { + BuddyListEntry *entry = getBuddyBySid(buddiesGames->sids->at(i)); + if (!entry) { + //nicht zuordbare sids zuordnen + XERROR("Add dummy Contact in buddylist for friends of friends!\n"); + BuddyListEntry *newentry = new BuddyListEntry; + newentry->username = ""; + newentry->userid = 0; + newentry->nick = ""; + newentry->setSid(buddiesGames->sids->at(i)); + entries->push_back(newentry); + //nochmal entry suchen + entry = newentry; //getBuddyBySid( buddiesGames->sids->at(i) ); + } + if (entry) { + if (isFirst) { + entry->game = buddiesGames->gameids->at(i); + delete entry->gameObj; entry->gameObj = NULL; + } + else { + entry->game2 = buddiesGames->gameids->at(i); + delete entry->game2Obj; entry->game2Obj = NULL; + } + XDEBUG(("Resolving Game... \n")); + XFireGameResolver *resolver = client->getGameResolver(); + if (resolver) { + XDEBUG(("Resolving Game... \n")); + if (isFirst) + entry->gameObj = resolver->resolveGame(entry->game, i, buddiesGames); + else + entry->game2Obj = resolver->resolveGame(entry->game2, i, buddiesGames); + } + else { + XDEBUG(("No GameResolver ? :(\n")); + } + XDEBUG(("%s: Game (%ld): %s / Game2 (%ld): %s\n", + entry->username.c_str(), + entry->game, + (entry->gameObj == NULL ? "UNKNOWN" : entry->gameObj->getGameName().c_str()), + entry->game2, + (entry->game2Obj == NULL ? "UNKNOWN" : entry->game2Obj->getGameName().c_str()) + )); + } + else { + XERROR("updateBuddiesGame: Could not find buddy with this sid!\n"); + } + } + } + + void BuddyList::receivedPacket(XFirePacket *packet) + { + XFirePacketContent *content = packet->getContent(); + if (content == 0) return; + XDEBUG2("hmm... %d\n", content->getPacketId()); + switch (content->getPacketId()) { + case XFIRE_BUDDYS_NAMES_ID: + XINFO(("Received Buddy List..\n")); + this->initEntries((BuddyListNamesPacket*)content); + break; + + case XFIRE_CLAN_BUDDYS_NAMES_ID: + XINFO(("Received Clan Buddy List..\n")); + this->initEntriesClan((ClanBuddyListNamesPacket*)content); + break; + //neue nicks updaten, dufte + case XFIRE_RECVBUDDYCHANGEDNICK: + { + RecvBuddyChangedNick* recvchangednick = (RecvBuddyChangedNick*)content; + XINFO(("Received new nick of a buddy..\n")); + BuddyListEntry* entry = NULL; + entry = this->getBuddyById(recvchangednick->userid); + if (entry) { + entry->nick = recvchangednick->newnick; + recvchangednick->entry = (void*)entry; + handlingBuddys(entry, 0, NULL); + } + } + break; + + case XFIRE_BUDDYS_ONLINE_ID: + XINFO(("Received Buddy Online Packet..\n")); + this->updateOnlineBuddies((BuddyListOnlinePacket *)content); + break; + + case XFIRE_FRIENDS_BUDDYS_NAMES_ID: + XINFO(("Received Friends of Friend..\n")); + this->updateFriendsofFriend((FriendsBuddyListNamesPacket *)content); + break; + + case XFIRE_BUDDYS_GAMES2_ID: + case XFIRE_BUDDYS_GAMES_ID: + XINFO(("Recieved the game a buddy is playing..\n")); + this->updateBuddiesGame((BuddyListGamesPacket *)content); + break; + + case XFIRE_RECVREMOVEBUDDYPACKET: + { + RecvRemoveBuddyPacket *p = (RecvRemoveBuddyPacket*)content; + XDEBUG2("Buddy was removed from contact list (userid: %ld)\n", p->userid); + std::vector<BuddyListEntry *>::iterator i = entries->begin(); + while (i != entries->end()) { + if ((*i)->userid == p->userid) { + BuddyListEntry *buddy = *i; + XINFO(("%s (%s) was removed from BuddyList.\n", buddy->username.c_str(), buddy->nick.c_str())); + p->username = buddy->username; + p->handle = buddy->hcontact; // handle übergeben - dufte + entries->erase(i); + // i.erase(); + break; // we are done. + } + ++i; + } + break; + } + case XFIRE_RECV_STATUSMESSAGE_PACKET_ID: + { + RecvStatusMessagePacket *status = (RecvStatusMessagePacket*)content; + + //status->entries=new PBuddyListEntry[status->sids->size]; + + for (uint i = 0; i < status->sids->size(); i++) { + BuddyListEntry *entry = getBuddyBySid(status->sids->at(i)); + //status->entries[i]=entry; + + if (entry == NULL) { + XERROR(("No such Entry - Got StatusMessage from someone who is not in the buddylist ??\n")); + return; + } + else { + entry->statusmsg = status->msgs->at(i); + setBuddyStatusMsg(entry); //auf eine funktion reduziert, verringert cpuauslastung und beseitigt das + //das problem der fehlenden statusmsg + } + } + + break; + } + } + } + + BuddyListEntry::~BuddyListEntry() + { + if (lastpopup) { + delete[] lastpopup; + lastpopup = NULL; + } + } + + BuddyListEntry::BuddyListEntry() + { + memset(sid, 0, 16); + statusmsg = std::string(); + game = 0; + game2 = 0; + gameObj = NULL; + game2Obj = NULL; + hcontact = NULL; + clanid = 0; + lastpopup = NULL; + } + + bool BuddyListEntry::isOnline() + { + for (int i = 0; i < 16; i++) + if (sid[i]) + return true; + + return false; + } + + void BuddyListEntry::setSid(const char *sid) + { + int s = 0; + for (int i = 0; i < 16; i++) { //wenn buddy offline geht, seine gameinfos zurücksetzen - dufte + if (sid[i]) { + s = 1; + break; + } + } + if (s) { + this->statusmsg = std::string(); + this->game = 0; + this->game2 = 0; + this->gameObj = NULL; + this->game2Obj = NULL; + } + memcpy(this->sid, sid, 16); } - memcpy(this->sid,sid,16); - } }; diff --git a/protocols/Xfire/src/buddylist.h b/protocols/Xfire/src/buddylist.h index 13fdd0b02d..3405441f2d 100644 --- a/protocols/Xfire/src/buddylist.h +++ b/protocols/Xfire/src/buddylist.h @@ -23,9 +23,6 @@ #ifndef __BUDDYLIST_H #define __BUDDYLIST_H -#include <iostream> -#include <vector> - #include "buddylistnamespacket.h" #include "clanbuddylistnamespacket.h" #include "buddylistgamespacket.h" @@ -67,33 +64,33 @@ namespace xfirelib { }; - class BuddyListEntry { - public: - BuddyListEntry(); - ~BuddyListEntry(); - bool isOnline(); - - void setSid(const char *sid); - - long userid; - char sid[16]; - string nick; - string username; - string statusmsg; - string gameinfo; - long game; - long game2; - MCONTACT hcontact; - int clanid; - - //lastpopup - char* lastpopup; - - XFireGame *gameObj; - XFireGame *game2Obj; - }; + class BuddyListEntry { + public: + BuddyListEntry(); + ~BuddyListEntry(); + bool isOnline(); + + void setSid(const char *sid); + + long userid; + char sid[16]; + string nick; + string username; + string statusmsg; + string gameinfo; + long game; + long game2; + MCONTACT hcontact; + int clanid; + + //lastpopup + char* lastpopup; + + XFireGame *gameObj; + XFireGame *game2Obj; + }; - typedef BuddyListEntry *PBuddyListEntry; + typedef BuddyListEntry *PBuddyListEntry; }; diff --git a/protocols/Xfire/src/buddylistgames2packet.cpp b/protocols/Xfire/src/buddylistgames2packet.cpp index 2252339908..fd8cc2392c 100644 --- a/protocols/Xfire/src/buddylistgames2packet.cpp +++ b/protocols/Xfire/src/buddylistgames2packet.cpp @@ -25,15 +25,17 @@ #include "buddylistgames2packet.h" #include "xdebug.h" -namespace xfirelib { - BuddyListGames2Packet::BuddyListGames2Packet() : BuddyListGamesPacket() { - - } - void BuddyListGames2Packet::parseContent(char *buf, int length, int numberOfAtts) { - XDEBUG( "....Parsing Packet Content of game 2 ??\n" ) - this->BuddyListGamesPacket::parseContent(buf,length,numberOfAtts); - XDEBUG2( "Parsed Packet Content of game 2 ??? ( %ld )\n", gameids->at(0) ) - } +namespace xfirelib +{ + BuddyListGames2Packet::BuddyListGames2Packet() : BuddyListGamesPacket() + { + } + void BuddyListGames2Packet::parseContent(char *buf, int length, int numberOfAtts) + { + XDEBUG("....Parsing Packet Content of game 2 ??\n") + this->BuddyListGamesPacket::parseContent(buf, length, numberOfAtts); + XDEBUG2("Parsed Packet Content of game 2 ??? ( %ld )\n", gameids->at(0)) + } }; diff --git a/protocols/Xfire/src/buddylistgames2packet.h b/protocols/Xfire/src/buddylistgames2packet.h index 81fe92eecb..6b96cf2c5b 100644 --- a/protocols/Xfire/src/buddylistgames2packet.h +++ b/protocols/Xfire/src/buddylistgames2packet.h @@ -31,13 +31,13 @@ namespace xfirelib { - class BuddyListGames2Packet : public BuddyListGamesPacket { - public: - BuddyListGames2Packet(); - XFirePacketContent* newPacket() { return new BuddyListGames2Packet(); } - virtual int getPacketId() { return XFIRE_BUDDYS_GAMES2_ID; } - virtual void parseContent(char *buf, int length, int numberOfAtts); - }; + class BuddyListGames2Packet : public BuddyListGamesPacket { + public: + BuddyListGames2Packet(); + XFirePacketContent* newPacket() { return new BuddyListGames2Packet(); } + virtual int getPacketId() { return XFIRE_BUDDYS_GAMES2_ID; } + virtual void parseContent(char *buf, int length, int numberOfAtts); + }; }; diff --git a/protocols/Xfire/src/buddylistgamespacket.cpp b/protocols/Xfire/src/buddylistgamespacket.cpp index 33ede53079..240f2a0cf2 100644 --- a/protocols/Xfire/src/buddylistgamespacket.cpp +++ b/protocols/Xfire/src/buddylistgamespacket.cpp @@ -22,123 +22,109 @@ #include "stdafx.h" -#include <vector> -#include <string> - #include "buddylistgamespacket.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - BuddyListGamesPacket::BuddyListGamesPacket() { - ips = 0; - ports = 0; - gameids = 0; - gameids2 = 0; - sids = 0; - type = 0; - } - BuddyListGamesPacket::~BuddyListGamesPacket() { - if (ips) { - for( vector<char*>::iterator it = ips->begin() ; - it != ips->end() ; it++) { - delete[] *it; - } - } - delete ips; - delete ports; - delete gameids; - delete gameids2; - delete sids; - } - - void BuddyListGamesPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - int numberOfSids = 0; - VariableValue val; - - index += val.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 03 - numberOfSids = (unsigned char) buf[index]; - index ++; // Ignore 00 - index ++; - sids = new vector<char *>; - for(int i = 0 ; i < numberOfSids ; i++) { - index += val.readValue(buf,index,16); - char *sid = new char[16]; - memcpy(sid,val.getValue(),16); - sids->push_back(sid); - } - - index += val.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 03 - numberOfSids = (unsigned char) buf[index]; - index ++; // Ignore 00 - index ++; - - gameids = new vector<long>; - gameids2 = new vector<long>; - for(int i = 0 ; i < numberOfSids ; i++) { - index += val.readValue(buf,index,2); - long game = val.getValueAsLong(); - index += val.readValue(buf,index,2); - long game2 = val.getValueAsLong(); - gameids->push_back(game); - gameids2->push_back(game2); - } - - index += val.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 03 - numberOfSids = (unsigned char) buf[index]; - index ++; // Ignore 00 - index ++; - - ips = new vector<char *>; - for(int i = 0 ; i < numberOfSids ; i++) { - index += val.readValue(buf,index,4); - char *ip = new char[4]; - memcpy(ip,val.getValue(),4); - ips->push_back(ip); - } - - index += val.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 03 - numberOfSids = (unsigned char) buf[index]; - index ++; // Ignore 00 - index ++; - -// static int was=0; -// int portwasnull=0; - - -// was++; - - ports = new vector<long>; - for(int i = 0 ; i < numberOfSids ; i++) { - index += val.readValue(buf,index,2); - long port = val.getValueAsLong(); -// if (port==0) -// { -// portwasnull=1; -// } - ports->push_back(port); - index += 2; // fixed port bug - dufte - } - -// char temp[512]; - /* sprintf(temp,"packet%d_%d.dmp",was,portwasnull); - FILE * f = fopen(temp,"wb"); - fwrite(buf,length,1,f); - fclose(f);*/ - - } - - +using namespace std; + +namespace xfirelib +{ + BuddyListGamesPacket::BuddyListGamesPacket() + { + ips = 0; + ports = 0; + gameids = 0; + gameids2 = 0; + sids = 0; + type = 0; + } + BuddyListGamesPacket::~BuddyListGamesPacket() + { + if (ips) { + for (vector<char*>::iterator it = ips->begin(); + it != ips->end(); it++) { + delete[] * it; + } + } + delete ips; + delete ports; + delete gameids; + delete gameids2; + delete sids; + } + + void BuddyListGamesPacket::parseContent(char *buf, int, int) + { + int index = 0; + int numberOfSids = 0; + VariableValue val; + + index += val.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 03 + numberOfSids = (unsigned char)buf[index]; + index++; // Ignore 00 + index++; + sids = new vector<char *>; + for (int i = 0; i < numberOfSids; i++) { + index += val.readValue(buf, index, 16); + char *sid = new char[16]; + memcpy(sid, val.getValue(), 16); + sids->push_back(sid); + } + + index += val.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 03 + numberOfSids = (unsigned char)buf[index]; + index++; // Ignore 00 + index++; + + gameids = new vector<long>; + gameids2 = new vector<long>; + for (int i = 0; i < numberOfSids; i++) { + index += val.readValue(buf, index, 2); + long game = val.getValueAsLong(); + index += val.readValue(buf, index, 2); + long game2 = val.getValueAsLong(); + gameids->push_back(game); + gameids2->push_back(game2); + } + + index += val.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 03 + numberOfSids = (unsigned char)buf[index]; + index++; // Ignore 00 + index++; + + ips = new vector<char *>; + for (int i = 0; i < numberOfSids; i++) { + index += val.readValue(buf, index, 4); + char *ip = new char[4]; + memcpy(ip, val.getValue(), 4); + ips->push_back(ip); + } + + index += val.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 03 + numberOfSids = (unsigned char)buf[index]; + index++; // Ignore 00 + index++; + + ports = new vector<long>; + for (int i = 0; i < numberOfSids; i++) { + index += val.readValue(buf, index, 2); + long port = val.getValueAsLong(); + // if (port==0) + // { + // portwasnull=1; + // } + ports->push_back(port); + index += 2; // fixed port bug - dufte + } + } }; diff --git a/protocols/Xfire/src/buddylistgamespacket.h b/protocols/Xfire/src/buddylistgamespacket.h index ba0264c29e..94d3ed4ee3 100644 --- a/protocols/Xfire/src/buddylistgamespacket.h +++ b/protocols/Xfire/src/buddylistgamespacket.h @@ -25,36 +25,32 @@ #define XFIRE_BUDDYS_GAMES_ID 135 -#include <vector> -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" - namespace xfirelib { - using namespace std; - - class BuddyListGamesPacket : public XFireRecvPacketContent { - public: - BuddyListGamesPacket(); - virtual ~BuddyListGamesPacket(); - - XFirePacketContent* newPacket() { return new BuddyListGamesPacket(); } - - virtual int getPacketId() { return XFIRE_BUDDYS_GAMES_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - virtual void parseContent(char *buf, int length, int numberOfAtts); - - vector<char *> *ips; - vector<long> *ports; - vector<long> *gameids; - vector<long> *gameids2; - vector<char *> *sids; - int type; - }; + using namespace std; + + class BuddyListGamesPacket : public XFireRecvPacketContent { + public: + BuddyListGamesPacket(); + virtual ~BuddyListGamesPacket(); + + XFirePacketContent* newPacket() { return new BuddyListGamesPacket(); } + + virtual int getPacketId() { return XFIRE_BUDDYS_GAMES_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + virtual void parseContent(char *buf, int length, int numberOfAtts); + + vector<char *> *ips; + vector<long> *ports; + vector<long> *gameids; + vector<long> *gameids2; + vector<char *> *sids; + int type; + }; }; diff --git a/protocols/Xfire/src/buddylistnamespacket.cpp b/protocols/Xfire/src/buddylistnamespacket.cpp index bebbc6db78..6566dc9618 100644 --- a/protocols/Xfire/src/buddylistnamespacket.cpp +++ b/protocols/Xfire/src/buddylistnamespacket.cpp @@ -21,84 +21,85 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "buddylistnamespacket.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; +using namespace std; - BuddyListNamesPacket::BuddyListNamesPacket() { - usernames = 0; - nicks = 0; - userids = 0; - } - BuddyListNamesPacket::~BuddyListNamesPacket() { - delete usernames; - delete nicks; - delete userids; - } - - void BuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - //prüfe ob das packet mit 0x7 anfängt um eventuell crashes zufixen - if (buf[0]!=0x7) +namespace xfirelib +{ + BuddyListNamesPacket::BuddyListNamesPacket() { - usernames = new vector<string>; - nicks = new vector<string>; - userids = new vector<long>; - return; + usernames = 0; + nicks = 0; + userids = 0; + } + BuddyListNamesPacket::~BuddyListNamesPacket() + { + delete usernames; + delete nicks; + delete userids; } - // friends - VariableValue friends; - index += friends.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 01, dufte skip 1 + void BuddyListNamesPacket::parseContent(char *buf, int, int) + { + int index = 0; + //prüfe ob das packet mit 0x7 anfängt um eventuell crashes zufixen + if (buf[0] != 0x7) { + usernames = new vector<string>; + nicks = new vector<string>; + userids = new vector<long>; + return; + } - usernames = new vector<string>; - index = readStrings(usernames,buf,index); + // friends + VariableValue friends; + index += friends.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 01, dufte skip 1 - index += friends.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 01, dufte skip 1 + usernames = new vector<string>; + index = readStrings(usernames, buf, index); - nicks = new vector<string>; - index = readStrings(nicks,buf,index); + index += friends.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 01, dufte skip 1 - index += friends.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 01, dufte skip 1 + nicks = new vector<string>; + index = readStrings(nicks, buf, index); - index += friends.readValue(buf,index,2); // 2 bytes lesen, für große mengen an friends - userids = new vector<long>; - int numberOfIds = friends.getValueAsLong(); - for(int i = 0 ; i < numberOfIds ; i++) { - index += friends.readValue(buf,index,4); - userids->push_back(friends.getValueAsLong()); - XDEBUG2( "UserID: %ld\n", friends.getValueAsLong() ); - } - } + index += friends.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 01, dufte skip 1 - int BuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) { - VariableValue friends; - index += friends.readValue(buf,index,2); //jeweils 2 bytes lesen - //index ++; // Ignore 00 0 brauch nicht mehr geskippt werden - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - string stringvalue = string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() ); - } - return index; - } + index += friends.readValue(buf, index, 2); // 2 bytes lesen, für große mengen an friends + userids = new vector<long>; + int numberOfIds = friends.getValueAsLong(); + for (int i = 0; i < numberOfIds; i++) { + index += friends.readValue(buf, index, 4); + userids->push_back(friends.getValueAsLong()); + XDEBUG2("UserID: %ld\n", friends.getValueAsLong()); + } + } + int BuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readValue(buf, index, 2); //jeweils 2 bytes lesen + //index ++; // Ignore 00 0 brauch nicht mehr geskippt werden + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + string stringvalue = string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG3("String length: %2d : %s\n", length, stringvalue.c_str()); + } + return index; + } }; diff --git a/protocols/Xfire/src/buddylistnamespacket.h b/protocols/Xfire/src/buddylistnamespacket.h index 5c50f4f110..3c1f355d5d 100644 --- a/protocols/Xfire/src/buddylistnamespacket.h +++ b/protocols/Xfire/src/buddylistnamespacket.h @@ -25,36 +25,33 @@ #define XFIRE_BUDDYS_NAMES_ID 131 -#include <vector> -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" namespace xfirelib { - using namespace std; + using namespace std; - class BuddyListNamesPacket : public XFireRecvPacketContent { - public: - BuddyListNamesPacket(); - virtual ~BuddyListNamesPacket(); + class BuddyListNamesPacket : public XFireRecvPacketContent { + public: + BuddyListNamesPacket(); + virtual ~BuddyListNamesPacket(); - XFirePacketContent* newPacket() { return new BuddyListNamesPacket(); } + XFirePacketContent* newPacket() { return new BuddyListNamesPacket(); } - int getPacketId() { return XFIRE_BUDDYS_NAMES_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_BUDDYS_NAMES_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int); - //private: - int readStrings(vector<string> *strings, char *buf, int index); + //private: + int readStrings(vector<string> *strings, char *buf, int index); - vector<string> *usernames; - vector<string> *nicks; - vector<long> *userids; - }; + vector<string> *usernames; + vector<string> *nicks; + vector<long> *userids; + }; }; diff --git a/protocols/Xfire/src/buddylistonlinepacket.cpp b/protocols/Xfire/src/buddylistonlinepacket.cpp index 3dd726d4e9..c65e3787a0 100644 --- a/protocols/Xfire/src/buddylistonlinepacket.cpp +++ b/protocols/Xfire/src/buddylistonlinepacket.cpp @@ -25,61 +25,57 @@ #include "buddylistonlinepacket.h" #include "xfireparse.h" #include "variablevalue.h" -#include <vector> #include "xdebug.h" #include <iostream> -namespace xfirelib { - using namespace std; +using namespace std; - void BuddyListOnlinePacket::parseContent(char *buf, int length, int numberOfAtts) { - DUMPPACKET("BuddyListOnlinePacket") - XINFO(( "Got List of buddys that are online\n" )); - int index = 0; - // friends - VariableValue userid; - userids = new vector<long>; +namespace xfirelib +{ + void BuddyListOnlinePacket::parseContent(char *buf, int, int) + { + DUMPPACKET("BuddyListOnlinePacket") + XINFO(("Got List of buddys that are online\n")); + int index = 0; + // friends + VariableValue userid; + userids = new vector<long>; - /* auskommentiert, wird nicht mehr gesendet 2.3.11 - index += userid.readName(buf,index); - */ - index ++; // Ignore 01 - index ++; // Ignore 04 - index ++; // Ignore 02 - + /* auskommentiert, wird nicht mehr gesendet 2.3.11 + index += userid.readName(buf,index); + */ + index++; // Ignore 01 + index++; // Ignore 04 + index++; // Ignore 02 - int numberOfIds = (unsigned char)buf[index]; - index++; - index++;//ignore 00 - for(int i = 0 ; i < numberOfIds ; i++) { - index += userid.readValue(buf,index,4); - userids->push_back(userid.getValueAsLong()); - XINFO2( "UserID: %ld\n", userid.getValueAsLong() ); - } - VariableValue sid; - sids = new vector<char *>; - /* auskommentiert, wird nicht mehr gesendet 2.3.11 - index += sid.readName(buf,index); */ + int numberOfIds = (unsigned char)buf[index]; + index++; + index++;//ignore 00 + for (int i = 0; i < numberOfIds; i++) { + index += userid.readValue(buf, index, 4); + userids->push_back(userid.getValueAsLong()); + XINFO2("UserID: %ld\n", userid.getValueAsLong()); + } - index ++; // Ignore 03 - index ++; // Ignore 04 - index ++; // Ignore 03 - + VariableValue sid; + sids = new vector<char *>; + /* auskommentiert, wird nicht mehr gesendet 2.3.11 + index += sid.readName(buf,index); */ - numberOfIds = (unsigned char)buf[index]; - index++; - index++;//ignore 00 - for(int i = 0 ; i < numberOfIds ; i++) { - index += userid.readValue(buf,index,16); - char *sid = new char[16]; - memcpy(sid,userid.getValue(),16); - sids->push_back(sid); - //for(int loop = 0; loop < userid.getValueLength();loop++){ - // XINFO(( "SID: %d\n", userid.getValue()[loop] )); - //} - } + index++; // Ignore 03 + index++; // Ignore 04 + index++; // Ignore 03 - } + numberOfIds = (unsigned char)buf[index]; + index++; + index++;//ignore 00 + for (int i = 0; i < numberOfIds; i++) { + index += userid.readValue(buf, index, 16); + char *sid = new char[16]; + memcpy(sid, userid.getValue(), 16); + sids->push_back(sid); + } + } }; diff --git a/protocols/Xfire/src/buddylistonlinepacket.h b/protocols/Xfire/src/buddylistonlinepacket.h index 1f9b432b63..038ea8db46 100644 --- a/protocols/Xfire/src/buddylistonlinepacket.h +++ b/protocols/Xfire/src/buddylistonlinepacket.h @@ -23,8 +23,6 @@ #ifndef __BUDDYLISTONLINEPACKET_H #define __BUDDYLISTONLINEPACKET_H -#include <vector> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" @@ -32,21 +30,21 @@ #define XFIRE_BUDDYS_ONLINE_ID 132 namespace xfirelib { -using namespace std; - class BuddyListOnlinePacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new BuddyListOnlinePacket(); } + using namespace std; + class BuddyListOnlinePacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new BuddyListOnlinePacket(); } - int getPacketId() { return XFIRE_BUDDYS_ONLINE_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_BUDDYS_ONLINE_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); - vector<long> *userids; - vector<char *> *sids; - }; + vector<long> *userids; + vector<char *> *sids; + }; }; diff --git a/protocols/Xfire/src/clanbuddylistnamespacket.cpp b/protocols/Xfire/src/clanbuddylistnamespacket.cpp index 76269a01cf..b84b959049 100644 --- a/protocols/Xfire/src/clanbuddylistnamespacket.cpp +++ b/protocols/Xfire/src/clanbuddylistnamespacket.cpp @@ -23,90 +23,92 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "clanbuddylistnamespacket.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; +using namespace std; - ClanBuddyListNamesPacket::ClanBuddyListNamesPacket() { - usernames = 0; - nicks = 0; - userids = 0; - clanid = 0; - } - ClanBuddyListNamesPacket::~ClanBuddyListNamesPacket() { - delete usernames; - delete nicks; - delete userids; - } +namespace xfirelib +{ + ClanBuddyListNamesPacket::ClanBuddyListNamesPacket() + { + usernames = 0; + nicks = 0; + userids = 0; + clanid = 0; + } - void ClanBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; + ClanBuddyListNamesPacket::~ClanBuddyListNamesPacket() + { + delete usernames; + delete nicks; + delete userids; + } - VariableValue friends; + void ClanBuddyListNamesPacket::parseContent(char *buf, int, int) + { + int index = 0; - XDEBUG2( "Len: %d\n", length ); + VariableValue friends; - index+=2; //paar bytes überspringen + XDEBUG2("Len: %d\n", length); - index += friends.readValue(buf,index,2); - this->clanid = friends.getValueAsLong(); + index += 2; //paar bytes überspringen - index+=4; //paar bytes überspringen + index += friends.readValue(buf, index, 2); + this->clanid = friends.getValueAsLong(); - userids = new vector<long>; + index += 4; //paar bytes überspringen - index += friends.readValue(buf,index); - - int numberOfIds = friends.getValueAsLong(); + userids = new vector<long>; - XDEBUG2( "numberofId: %d\n", numberOfIds ); + index += friends.readValue(buf, index); - for(int i = 0 ; i < numberOfIds ; i++) { - index += friends.readValue(buf,index,4); - userids->push_back(friends.getValueAsLong()); - XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() ); - } + int numberOfIds = friends.getValueAsLong(); - XDEBUG2( "NextByte: %c\n",buf[index] ); - XDEBUG2( "NextByte: %c\n",buf[index+1] ); + XDEBUG2("numberofId: %d\n", numberOfIds); - index+=3; //nächsten 3 skippen + for (int i = 0; i < numberOfIds; i++) { + index += friends.readValue(buf, index, 4); + userids->push_back(friends.getValueAsLong()); + XDEBUG3("UserID: %ld %ld\n", i + 1, friends.getValueAsLong()); + } - XDEBUG2( "NextByte: %c\n",buf[index] ); - XDEBUG2( "NextByte: %c\n",buf[index+1] ); - - usernames = new vector<string>; - index = readStrings(usernames,buf,index); + XDEBUG2("NextByte: %c\n", buf[index]); + XDEBUG2("NextByte: %c\n", buf[index + 1]); - index+=3; //nächsten 3 skippen + index += 3; //nächsten 3 skippen - nicks = new vector<string>; - index = readStrings(nicks,buf,index); + XDEBUG2("NextByte: %c\n", buf[index]); + XDEBUG2("NextByte: %c\n", buf[index + 1]); - } + usernames = new vector<string>; + index = readStrings(usernames, buf, index); - int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) { - VariableValue friends; - index += friends.readValue(buf,index,2); - //index ++; // Ignore 00 - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - string stringvalue = string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() )); - } - return index; - } + index += 3; //nächsten 3 skippen + nicks = new vector<string>; + index = readStrings(nicks, buf, index); + } + + int ClanBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readValue(buf, index, 2); + //index ++; // Ignore 00 + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + string stringvalue = string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG(("String length: %2d : %s\n", length, stringvalue.c_str())); + } + return index; + } }; diff --git a/protocols/Xfire/src/clanbuddylistnamespacket.h b/protocols/Xfire/src/clanbuddylistnamespacket.h index f47fc694f7..0e2b64a88b 100644 --- a/protocols/Xfire/src/clanbuddylistnamespacket.h +++ b/protocols/Xfire/src/clanbuddylistnamespacket.h @@ -27,37 +27,33 @@ #define XFIRE_CLAN_BUDDYS_NAMES_ID 159 -#include <vector> -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" - namespace xfirelib { - using namespace std; + using namespace std; - class ClanBuddyListNamesPacket : public XFireRecvPacketContent { - public: - ClanBuddyListNamesPacket(); - virtual ~ClanBuddyListNamesPacket(); + class ClanBuddyListNamesPacket : public XFireRecvPacketContent { + public: + ClanBuddyListNamesPacket(); + virtual ~ClanBuddyListNamesPacket(); - XFirePacketContent* newPacket() { return new ClanBuddyListNamesPacket(); } + XFirePacketContent* newPacket() { return new ClanBuddyListNamesPacket(); } - int getPacketId() { return XFIRE_CLAN_BUDDYS_NAMES_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 10024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_CLAN_BUDDYS_NAMES_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 10024; }; + void parseContent(char *buf, int length, int numberOfAtts); - //private: - int readStrings(vector<string> *strings, char *buf, int index); + //private: + int readStrings(vector<string> *strings, char *buf, int index); - long clanid; - vector<string> *usernames; - vector<string> *nicks; - vector<long> *userids; - }; + long clanid; + vector<string> *usernames; + vector<string> *nicks; + vector<long> *userids; + }; }; diff --git a/protocols/Xfire/src/claninvitationpacket.cpp b/protocols/Xfire/src/claninvitationpacket.cpp index 08fb2b2267..834c8658b3 100644 --- a/protocols/Xfire/src/claninvitationpacket.cpp +++ b/protocols/Xfire/src/claninvitationpacket.cpp @@ -24,115 +24,101 @@ #include "stdafx.h" -#include <vector> -#include <string> - #include "claninvitationpacket.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - ClanInvitationPacket::ClanInvitationPacket() { - } - ClanInvitationPacket::~ClanInvitationPacket() { - } +using namespace std; - void ClanInvitationPacket::parseContent(char *buf, int length, int numberOfAtts) { +namespace xfirelib +{ + void ClanInvitationPacket::parseContent(char *buf, int, int) + { int index = 0; numberOfInv = 0; VariableValue val; - index+=0x3; //einige bytes überspringen + index += 0x3; //einige bytes überspringen - numberOfInv=buf[index]; - XDEBUG2("Invs %d\n",numberOfInv); + numberOfInv = buf[index]; + XDEBUG2("Invs %d\n", numberOfInv); - index+=2; // überspring 0 + index += 2; // überspring 0 //clan id's überspringen, wird eh nicht gebraucht - for(int i=0;i<numberOfInv;i++) - index+=4; + for (int i = 0; i < numberOfInv; i++) + index += 4; index++; // 0x72 überspringen - index+=4; // weitere bytes überspringen + index += 4; // weitere bytes überspringen //clanidnamen überspringen - for(int i=0;i<numberOfInv;i++) - { + for (int i = 0; i < numberOfInv; i++) { int length = (unsigned char)buf[index++]; index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - XDEBUG2("Clanidnames von %s\n",stringvalue.c_str()); + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + XDEBUG2("Clanidnames von %s\n", stringvalue.c_str()); } //weitere 5 bytes überspringen - index+=5; + index += 5; - for(int i=0;i<numberOfInv;i++) - { + for (int i = 0; i < numberOfInv; i++) { int length = (unsigned char)buf[index++]; index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - XDEBUG2("Inv von %s\n",stringvalue.c_str()); - clanname[i]=stringvalue; + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + XDEBUG2("Inv von %s\n", stringvalue.c_str()); + clanname[i] = stringvalue; } //weitere 5 bytes skippen - index+=5; + index += 5; //weitere leere bytes skippen, weis nich was für einen sinn haben - for(int i=0;i<numberOfInv;i++) - index+=4; + for (int i = 0; i < numberOfInv; i++) + index += 4; //weitere 5 bytes skippen - index+=5; + index += 5; //usernames auslesen - for(int i=0;i<numberOfInv;i++) - { + for (int i = 0; i < numberOfInv; i++) { int length = (unsigned char)buf[index++]; index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - XDEBUG2("Usernames von %s\n",stringvalue.c_str()); - invitefromusername[i]=stringvalue; + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + XDEBUG2("Usernames von %s\n", stringvalue.c_str()); + invitefromusername[i] = stringvalue; } //nochmal weitere 5 bytes skippen - index+=5; + index += 5; //nicks auslesen - for(int i=0;i<numberOfInv;i++) - { + for (int i = 0; i < numberOfInv; i++) { int length = (unsigned char)buf[index++]; index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - XDEBUG2("Nicks von %s\n",stringvalue.c_str()); - invitefrom[i]=stringvalue; + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + XDEBUG2("Nicks von %s\n", stringvalue.c_str()); + invitefrom[i] = stringvalue; } //nochmal weitere 5 bytes skippen - index+=5; + index += 5; //einladungen auslesen - for(int i=0;i<numberOfInv;i++) - { + for (int i = 0; i < numberOfInv; i++) { int length = (unsigned char)buf[index++]; index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - XDEBUG2("Nicks von %s\n",stringvalue.c_str()); - invitemsg[i]=stringvalue; + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + XDEBUG2("Nicks von %s\n", stringvalue.c_str()); + invitemsg[i] = stringvalue; } - } - - }; diff --git a/protocols/Xfire/src/claninvitationpacket.h b/protocols/Xfire/src/claninvitationpacket.h index b595c5ba9c..3d39df8ef5 100644 --- a/protocols/Xfire/src/claninvitationpacket.h +++ b/protocols/Xfire/src/claninvitationpacket.h @@ -27,35 +27,33 @@ #define XFIRE_CLANINVITATION_ID 165 -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" namespace xfirelib { - using namespace std; + using namespace std; - class ClanInvitationPacket : public XFireRecvPacketContent { - public: - ClanInvitationPacket(); - virtual ~ClanInvitationPacket(); + class ClanInvitationPacket : public XFireRecvPacketContent { + public: + ClanInvitationPacket() {} + virtual ~ClanInvitationPacket() {} - XFirePacketContent* newPacket() { return new ClanInvitationPacket(); } + XFirePacketContent* newPacket() { return new ClanInvitationPacket(); } - virtual int getPacketId() { return XFIRE_CLANINVITATION_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - virtual void parseContent(char *buf, int length, int numberOfAtts); + virtual int getPacketId() { return XFIRE_CLANINVITATION_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + virtual void parseContent(char *buf, int length, int numberOfAtts); - //maximal 10 inv, mehr wird denk ich äh nich aufeinmal auftreten - string clanname[10]; - string invitefrom[10]; - string invitefromusername[10]; - string invitemsg[10]; + //maximal 10 inv, mehr wird denk ich äh nich aufeinmal auftreten + string clanname[10]; + string invitefrom[10]; + string invitefromusername[10]; + string invitemsg[10]; - int numberOfInv; - }; + int numberOfInv; + }; }; #endif
\ No newline at end of file diff --git a/protocols/Xfire/src/client.cpp b/protocols/Xfire/src/client.cpp index 024cfc16d9..41deafe97d 100644 --- a/protocols/Xfire/src/client.cpp +++ b/protocols/Xfire/src/client.cpp @@ -43,254 +43,269 @@ #define XFIRE_HOST "206.220.42.147"
#define XFIRE_PORT 25999
-extern BOOL mySleep(int ms,HANDLE evt);
+extern BOOL mySleep(int ms, HANDLE evt);
extern HANDLE hConnectionClose;
extern WINBASEAPI
BOOL
WINAPI
ResetEvent(
- __in HANDLE hEvent
- );
+__in HANDLE hEvent
+);
//#define UINT_8 unsigned char
//#define UINT_32 unsigned long
-namespace xfirelib {
+namespace xfirelib
+{
-using namespace std;
+ using namespace std;
- Client::Client() {
- XDEBUG(("Client constructor...\n"));
- gameResolver = NULL;
- packetReader = new PacketReader(NULL);
- packetReader->addPacketListener( this );
- buddyList = new BuddyList( this );
- socket=NULL;
+ Client::Client()
+ {
+ XDEBUG(("Client constructor...\n"));
+ gameResolver = NULL;
+ packetReader = new PacketReader(NULL);
+ packetReader->addPacketListener(this);
+ buddyList = new BuddyList(this);
+ socket = NULL;
#ifndef NO_PTHREAD
- sendpingthread.p=NULL;
- readthread.p=NULL;
+ sendpingthread.p=NULL;
+ readthread.p=NULL;
#endif
- }
-
- Client::~Client(){
- XDEBUG(("Client destructor...\n"));
- delete username;
- delete password;
- delete buddyList;
- delete packetReader;
- delete socket;
- }
-
- void Client::connect( string username, string password, int useproxy, string proxyip, int proxyport) {
- try {
- this->gotBudduyList=FALSE;
- this->username = new string(username);
- this->password = new string(password);
- socket = new Socket( XFIRE_HOST, XFIRE_PORT,useproxy,proxyip,proxyport );
-
- //bevors losgeht, erstmal die localaddr sichern
- struct sockaddr_in sa;
- int iLen = sizeof(sa);
- getsockname(socket->m_sock, (SOCKADDR*)&sa, &iLen);
- strncpy(this->localaddr,inet_ntoa(sa.sin_addr), sizeof(this->localaddr)-1);
- this->llocaladdr=inet_addr(this->localaddr);
-
- packetReader->setSocket(socket);
-
- ResetEvent(hConnectionClose);
-
- startThreads();
- //packetReader->startListening();
-
-
- socket->send("UA01");
- XDEBUG(("Sent UA01\n"));
- ClientInformationPacket *infoPacket = new ClientInformationPacket();
- this->send( infoPacket );
- delete infoPacket;
- XINFO(("sent ClientInformationPacket\n"));
-
- ClientVersionPacket *versionPacket = new ClientVersionPacket();
- versionPacket->setProtocolVersion( protocolVersion);
- this->send( versionPacket );
- delete versionPacket;
-
- XINFO(("sent ClientVersionPacket\n"));
- this->connected=TRUE;
- } catch( SocketException ex ) {
- XERROR(("Socket Exception ?! %s \n",ex.description().c_str() ));
- this->connected=FALSE;
- }
- }
- XFireGameResolver *Client::getGameResolver() {
- return gameResolver;
- }
- void Client::startThreads() {
- XINFO(("About to start thread\n"));
+ }
+
+ Client::~Client()
+ {
+ XDEBUG(("Client destructor...\n"));
+ delete username;
+ delete password;
+ delete buddyList;
+ delete packetReader;
+ delete socket;
+ }
+
+ void Client::connect(string username, string password, int useproxy, string proxyip, int proxyport)
+ {
+ try {
+ this->gotBudduyList = FALSE;
+ this->username = new string(username);
+ this->password = new string(password);
+ socket = new Socket(XFIRE_HOST, XFIRE_PORT, useproxy, proxyip, proxyport);
+
+ //bevors losgeht, erstmal die localaddr sichern
+ struct sockaddr_in sa;
+ int iLen = sizeof(sa);
+ getsockname(socket->m_sock, (SOCKADDR*)&sa, &iLen);
+ strncpy(this->localaddr, inet_ntoa(sa.sin_addr), sizeof(this->localaddr) - 1);
+ this->llocaladdr = inet_addr(this->localaddr);
+
+ packetReader->setSocket(socket);
+
+ ResetEvent(hConnectionClose);
+
+ startThreads();
+ //packetReader->startListening();
+
+
+ socket->send("UA01");
+ XDEBUG(("Sent UA01\n"));
+ ClientInformationPacket *infoPacket = new ClientInformationPacket();
+ this->send(infoPacket);
+ delete infoPacket;
+ XINFO(("sent ClientInformationPacket\n"));
+
+ ClientVersionPacket *versionPacket = new ClientVersionPacket();
+ versionPacket->setProtocolVersion(protocolVersion);
+ this->send(versionPacket);
+ delete versionPacket;
+
+ XINFO(("sent ClientVersionPacket\n"));
+ this->connected = TRUE;
+ }
+ catch (SocketException ex) {
+ XERROR(("Socket Exception ?! %s \n", ex.description().c_str()));
+ this->connected = FALSE;
+ }
+ }
+ XFireGameResolver *Client::getGameResolver()
+ {
+ return gameResolver;
+ }
+ void Client::startThreads()
+ {
+ XINFO(("About to start thread\n"));
#ifndef NO_PTHREAD
- void* (*func)(void*) = &xfirelib::Client::startReadThread;
- pthread_create( &readthread, NULL, func, (void*)this );
- void* (*func2)(void*) = &xfirelib::Client::startSendPingThread;
- pthread_create( &sendpingthread, NULL, func2, (void*)this );
+ void* (*func)(void*) = &xfirelib::Client::startReadThread;
+ pthread_create( &readthread, NULL, func, (void*)this );
+ void* (*func2)(void*) = &xfirelib::Client::startSendPingThread;
+ pthread_create( &sendpingthread, NULL, func2, (void*)this );
#else
- //mir_create!!!!
- mir_forkthread(xfirelib::Client::startReadThread,(LPVOID)this);
- mir_forkthread(xfirelib::Client::startSendPingThread,(LPVOID)this);
+ //mir_create!!!!
+ mir_forkthread(xfirelib::Client::startReadThread, (LPVOID)this);
+ mir_forkthread(xfirelib::Client::startSendPingThread, (LPVOID)this);
#endif
- }
+ }
#ifndef NO_PTHREAD
- void *Client::startReadThread(void *ptr) {
+ void *Client::startReadThread(void *ptr) {
#else
- void Client::startReadThread(LPVOID lParam) {
- void* ptr=(void*)lParam;
+ void Client::startReadThread(LPVOID lParam)
+ {
+ void* ptr = (void*)lParam;
#endif
- if (ptr==NULL||((Client*)ptr)->packetReader==NULL)
+ if (ptr == NULL || ((Client*)ptr)->packetReader == NULL)
#ifndef NO_PTHREAD
- return NULL;
+ return NULL;
#else
- return;
+ return;
#endif
- try {
- ((Client*)ptr)->packetReader->run();
- } catch (SocketException ex) {
- XERROR(("Socket Exception ?! %s \n",ex.description().c_str() ));
+ try {
+ ((Client*)ptr)->packetReader->run();
+ }
+ catch (SocketException ex) {
+ XERROR(("Socket Exception ?! %s \n", ex.description().c_str()));
- //miranda bescheid geben, wir haben verbindung verloren
- if (ptr==NULL||((Client*)ptr)->connected) SetStatus(ID_STATUS_OFFLINE,NULL);
+ //miranda bescheid geben, wir haben verbindung verloren
+ if (ptr == NULL || ((Client*)ptr)->connected) SetStatus(ID_STATUS_OFFLINE, NULL);
- //((Client*)ptr)->disconnect();
- }
+ //((Client*)ptr)->disconnect();
+ }
#ifndef NO_PTHREAD
- return NULL;
+ return NULL;
#else
- return;
+ return;
#endif
- }
+ }
#ifndef NO_PTHREAD
- void *Client::startSendPingThread(void *ptr) {
- Client *me = (Client*)ptr;
+ void *Client::startSendPingThread(void *ptr) {
+ Client *me = (Client*)ptr;
#else
- void Client::startSendPingThread(LPVOID lParam) {
- Client *me = (Client*)lParam;
+ void Client::startSendPingThread(LPVOID lParam)
+ {
+ Client *me = (Client*)lParam;
#endif
- SendKeepAlivePacket packet;
+ SendKeepAlivePacket packet;
- while(1) {
+ while (1) {
#ifndef NO_PTHREAD
- pthread_testcancel();
+ pthread_testcancel();
#endif
- //Sleep(60000); // Sleep for 40 sek
- if (mySleep(60000,hConnectionClose))
- {
+ //Sleep(60000); // Sleep for 40 sek
+ if (mySleep(60000, hConnectionClose)) {
#ifndef NO_PTHREAD
- return NULL;
+ return NULL;
#else
- return;
+ return;
#endif
- }
+ }
#ifndef NO_PTHREAD
- pthread_testcancel();
+ pthread_testcancel();
#endif
- XDEBUG(( "Sending KeepAlivePacket\n" ));
- if (!me->send( &packet )) {
- XINFO(( "Could not send KeepAlivePacket... exiting thread.\n" ));
- break;
- }
- }
+ XDEBUG(("Sending KeepAlivePacket\n"));
+ if (!me->send(&packet)) {
+ XINFO(("Could not send KeepAlivePacket... exiting thread.\n"));
+ break;
+ }
+ }
#ifndef NO_PTHREAD
- return NULL;
+ return NULL;
#else
- return;
+ return;
#endif
- }
+ }
- void Client::disconnect() {
- this->connected=FALSE;
+ void Client::disconnect()
+ {
+ this->connected = FALSE;
- //socket vom packetreader auf NULL, damit die readschleife geschlossen wird
- if (this->packetReader!=NULL)
- this->packetReader->setSocket(NULL);
+ //socket vom packetreader auf NULL, damit die readschleife geschlossen wird
+ if (this->packetReader != NULL)
+ this->packetReader->setSocket(NULL);
- XDEBUG( "cancelling readthread... \n");
+ XDEBUG("cancelling readthread... \n");
#ifndef NO_PTHREAD
- if (readthread.p!=NULL) pthread_cancel (readthread);
- readthread.p=NULL;
+ if (readthread.p!=NULL) pthread_cancel (readthread);
+ readthread.p=NULL;
- XDEBUG( "cancelling sendpingthread... \n");
- if (sendpingthread.p!=NULL) pthread_cancel (sendpingthread);
- sendpingthread.p=NULL;
+ XDEBUG( "cancelling sendpingthread... \n");
+ if (sendpingthread.p!=NULL) pthread_cancel (sendpingthread);
+ sendpingthread.p=NULL;
#endif
- XDEBUG( "deleting socket...\n" );
- if (socket){
- delete socket;
- socket = NULL;
- }
- XDEBUG(( "done\n" ));
- }
-
- bool Client::send( XFirePacketContent *content ) {
- if (!socket) {
- XERROR(( "Trying to send content packet altough socket is NULL ! (ignored)\n" ));
- return false;
- }
- XFirePacket *packet = new XFirePacket(content);
- packet->sendPacket( socket );
- delete packet;
- return true;
- }
-
- void Client::addPacketListener( PacketListener *listener ) {
- packetReader->addPacketListener( listener );
- }
-
-
- void Client::receivedPacket( XFirePacket *packet ) {
- XDEBUG(("Client::receivedPacket\n"));
- if ( packet == NULL ) {
- XERROR(("packet is NULL !!!\n"));
- return;
- }
- if ( packet->getContent() == NULL ) {
- XERROR(("ERRRR getContent() returns null ?!\n"));
- return;
- }
- XFirePacketContent *content = packet->getContent();
-
- switch( content->getPacketId() ) {
- case XFIRE_PACKET_AUTH_ID: {
- XINFO(("Got Auth Packet .. Sending Login\n"));
- AuthPacket *authPacket = (AuthPacket*)packet->getContent();
-
- ClientLoginPacket *login = new ClientLoginPacket();
- login->setSalt( authPacket->getSalt() );
- login->setUsername( *username );
- login->setPassword( *password );
- send( login );
- delete login;
- break;
- }
-
- case XFIRE_MESSAGE_ID: {
- XDEBUG(( "Got Message, sending ACK\n" ));
- MessagePacket *message = (MessagePacket*)packet->getContent();
- if (message->getMessageType() == 0){
- MessageACKPacket *ack = new MessageACKPacket();
- memcpy(ack->sid,message->getSid(),16);
- ack->imindex = message->getImIndex();
- send( ack );
- delete ack;
- }else if (message->getMessageType() == 2){
- send(message);
- }
- break;
- }
-
- default:
- //cout << "Nothing here... " << endl;
- break;
- }
-
- }
+ XDEBUG("deleting socket...\n");
+ if (socket) {
+ delete socket;
+ socket = NULL;
+ }
+ XDEBUG(("done\n"));
+ }
+
+ bool Client::send(XFirePacketContent *content)
+ {
+ if (!socket) {
+ XERROR(("Trying to send content packet altough socket is NULL ! (ignored)\n"));
+ return false;
+ }
+ XFirePacket *packet = new XFirePacket(content);
+ packet->sendPacket(socket);
+ delete packet;
+ return true;
+ }
+
+ void Client::addPacketListener(PacketListener *listener)
+ {
+ packetReader->addPacketListener(listener);
+ }
+
+
+ void Client::receivedPacket(XFirePacket *packet)
+ {
+ XDEBUG(("Client::receivedPacket\n"));
+ if (packet == NULL) {
+ XERROR(("packet is NULL !!!\n"));
+ return;
+ }
+ if (packet->getContent() == NULL) {
+ XERROR(("ERRRR getContent() returns null ?!\n"));
+ return;
+ }
+ XFirePacketContent *content = packet->getContent();
+
+ switch (content->getPacketId()) {
+ case XFIRE_PACKET_AUTH_ID:
+ {
+ XINFO(("Got Auth Packet .. Sending Login\n"));
+ AuthPacket *authPacket = (AuthPacket*)packet->getContent();
+
+ ClientLoginPacket *login = new ClientLoginPacket();
+ login->setSalt(authPacket->getSalt());
+ login->setUsername(*username);
+ login->setPassword(*password);
+ send(login);
+ delete login;
+ break;
+ }
+
+ case XFIRE_MESSAGE_ID:
+ {
+ XDEBUG(("Got Message, sending ACK\n"));
+ MessagePacket *message = (MessagePacket*)packet->getContent();
+ if (message->getMessageType() == 0) {
+ MessageACKPacket *ack = new MessageACKPacket();
+ memcpy(ack->sid, message->getSid(), 16);
+ ack->imindex = message->getImIndex();
+ send(ack);
+ delete ack;
+ }
+ else if (message->getMessageType() == 2) {
+ send(message);
+ }
+ break;
+ }
+
+ default:
+ //cout << "Nothing here... " << endl;
+ break;
+ }
+ }
};
diff --git a/protocols/Xfire/src/client.h b/protocols/Xfire/src/client.h index 5822c6c27e..0ebc7b4359 100644 --- a/protocols/Xfire/src/client.h +++ b/protocols/Xfire/src/client.h @@ -29,7 +29,6 @@ #include <pthread.h> #endif -#include <string> #include "packetreader.h" #include "xfirepacketcontent.h" #include "packetlistener.h" @@ -37,59 +36,59 @@ #include "xfiregameresolver.h" namespace xfirelib { - struct BuddyList; + struct BuddyList; -class Client : public PacketListener { - public: - Client(); - ~Client(); - //proxy hinzugefügt dufte - void connect(std::string username, std::string password,int useproxy=0,string proxyip="",int proxyport=0); - /** - * Sends a XFirePacketContent (does NOT delete content) - * Returns true if sent successfully. - */ - bool send(XFirePacketContent *content); + class Client : public PacketListener { + public: + Client(); + ~Client(); + //proxy hinzugefügt dufte + void connect(std::string username, std::string password,int useproxy=0,string proxyip="",int proxyport=0); + /** + * Sends a XFirePacketContent (does NOT delete content) + * Returns true if sent successfully. + */ + bool send(XFirePacketContent *content); - BuddyList *getBuddyList() { return buddyList; } - void addPacketListener(PacketListener *packetListener); - void disconnect(); - void sendMessage(string username, string message); - void sendNickChange(string nick); - XFireGameResolver *getGameResolver(); - void setGameResolver(XFireGameResolver *resolver) { - delete this->gameResolver; - this->gameResolver = resolver; - } + BuddyList *getBuddyList() { return buddyList; } + void addPacketListener(PacketListener *packetListener); + void disconnect(); + void sendMessage(string username, string message); + void sendNickChange(string nick); + XFireGameResolver *getGameResolver(); + void setGameResolver(XFireGameResolver *resolver) { + delete this->gameResolver; + this->gameResolver = resolver; + } - BOOL gotBudduyList; - BOOL connected; - char protocolVersion; - char localaddr[18]; - unsigned long llocaladdr; + BOOL gotBudduyList; + BOOL connected; + char protocolVersion; + char localaddr[18]; + unsigned long llocaladdr; - protected: - void receivedPacket( XFirePacket *packet ); - void startThreads(); + protected: + void receivedPacket( XFirePacket *packet ); + void startThreads(); #ifndef NO_PTHREAD - static void *startReadThread(void *ptr); - static void *startSendPingThread(void *ptr); + static void *startReadThread(void *ptr); + static void *startSendPingThread(void *ptr); #else - static void startReadThread(LPVOID lParam); - static void startSendPingThread(LPVOID lParam); + static void startReadThread(LPVOID lParam); + static void startSendPingThread(LPVOID lParam); #endif - private: - XFireGameResolver *gameResolver; - PacketReader *packetReader; - std::string *username; - std::string *password; - Socket *socket; - BuddyList *buddyList; + private: + XFireGameResolver *gameResolver; + PacketReader *packetReader; + std::string *username; + std::string *password; + Socket *socket; + BuddyList *buddyList; #ifndef NO_PTHREAD - pthread_t readthread; - pthread_t sendpingthread; + pthread_t readthread; + pthread_t sendpingthread; #endif -}; + }; }; diff --git a/protocols/Xfire/src/clientinformationpacket.cpp b/protocols/Xfire/src/clientinformationpacket.cpp index 7843c6d8a8..67dd37fb70 100644 --- a/protocols/Xfire/src/clientinformationpacket.cpp +++ b/protocols/Xfire/src/clientinformationpacket.cpp @@ -26,52 +26,54 @@ #include <string.h> #include <iostream> -namespace xfirelib { - using namespace std; +using namespace std; - int ClientInformationPacket::getPacketContent(char *packet) { - int index = 0; - int skins = 2; - int i; +namespace xfirelib +{ + int ClientInformationPacket::getPacketContent(char *packet) + { + int index = 0; + int skins = 2; + int i; - index = XFireUtils::addAttributName(packet,index, "skin");/*add skin*/ - packet[index++] = 0x04; - packet[index++] = 0x01; - packet[index++] = (char)skins; - packet[index++] = 0x00; - packet[index++] = mir_strlen("Standard"); - packet[index++] = 0x00; - - memcpy(packet+index,"Standard",mir_strlen("Standard"));/*add first skin name*/ - index += mir_strlen("Standard"); - - packet[index++] = mir_strlen("XFire"); - packet[index++] = 0x00; - - memcpy(packet+index,"XFire",mir_strlen("XFire"));/*add second skin name*/ - index += mir_strlen("XFire"); - - VariableValue val; - val.setName( "version" ); - index += val.writeName( packet, index ); - //index = XFireUtils::addAttributName(packet,index, "version");/*add version of skins*/ - packet[index++] = 0x04; - packet[index++] = 0x02; - packet[index++] = (char)skins; - packet[index++] = 0x00; - - for(i = 0;i < skins;i++){/*(forEachSkin){ 01 00 00 00 }*/ + index = XFireUtils::addAttributName(packet, index, "skin");/*add skin*/ + packet[index++] = 0x04; packet[index++] = 0x01; + packet[index++] = (char)skins; packet[index++] = 0x00; + packet[index++] = mir_strlen("Standard"); packet[index++] = 0x00; + + memcpy(packet + index, "Standard", mir_strlen("Standard"));/*add first skin name*/ + index += mir_strlen("Standard"); + + packet[index++] = mir_strlen("XFire"); packet[index++] = 0x00; - } - length = index; - return index; - } - int ClientInformationPacket::getPacketAttributeCount() { - return 2; - } + memcpy(packet + index, "XFire", mir_strlen("XFire"));/*add second skin name*/ + index += mir_strlen("XFire"); + VariableValue val; + val.setName("version"); + index += val.writeName(packet, index); + //index = XFireUtils::addAttributName(packet,index, "version");/*add version of skins*/ + packet[index++] = 0x04; + packet[index++] = 0x02; + packet[index++] = (char)skins; + packet[index++] = 0x00; + + for (i = 0; i < skins; i++) {/*(forEachSkin){ 01 00 00 00 }*/ + packet[index++] = 0x01; + packet[index++] = 0x00; + packet[index++] = 0x00; + packet[index++] = 0x00; + } + length = index; + return index; + } + + int ClientInformationPacket::getPacketAttributeCount() + { + return 2; + } } diff --git a/protocols/Xfire/src/clientinformationpacket.h b/protocols/Xfire/src/clientinformationpacket.h index 533e3fbc91..183d54740d 100644 --- a/protocols/Xfire/src/clientinformationpacket.h +++ b/protocols/Xfire/src/clientinformationpacket.h @@ -28,27 +28,25 @@ #include "xfiresendpacketcontent.h" #include "variablevalue.h" -#include <string> - namespace xfirelib { - /** - * (Internal) packet used by Client::login( std::string, std::string ) - * Users of xfirelib won't need this packet. - */ - class ClientInformationPacket : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new ClientInformationPacket(); } - - int getPacketId() { return 18; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 46; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; - std::string skinname; - private: - int length; - }; + /** + * (Internal) packet used by Client::login( std::string, std::string ) + * Users of xfirelib won't need this packet. + */ + class ClientInformationPacket : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new ClientInformationPacket(); } + + int getPacketId() { return 18; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 46; }; + void parseContent(char*, int, int) { }; + std::string skinname; + private: + int length; + }; }; diff --git a/protocols/Xfire/src/clientloginpacket.cpp b/protocols/Xfire/src/clientloginpacket.cpp index 59ac46fcdd..33e9fd9130 100644 --- a/protocols/Xfire/src/clientloginpacket.cpp +++ b/protocols/Xfire/src/clientloginpacket.cpp @@ -28,94 +28,96 @@ #include <iostream> #include "baseProtocol.h" -namespace xfirelib { - using namespace std; - - int ClientLoginPacket::getPacketContent(char *packet) { - int index = 0; - /*Username*/ - - index = XFireUtils::addAttributName(packet,index, "name");/*add username attribute*/ - packet[index] = 0x01; - packet[index+1] = (char)name.length(); - packet[index+2] = 0x00; - index +=3; - std::copy(name.begin(),name.end(),packet+index); - index += name.size(); - - /*Crypted Password*/ - unsigned char pass[41]; - pass[40] = 0x00; - cryptPassword(pass); - index = XFireUtils::addAttributName(packet,index, "password");/*add username attribute*/ - packet[index] = 0x01; - packet[index+1] = (char)40; - packet[index+2] = 0x00; - index += 3; - - memcpy(packet+index,pass,40); - index += 40; - - VariableValue val; - val.setName( "flags" ); - index += val.writeName( packet, index ); - packet[index++] = 0x02; - packet[index++] = 0x00; - packet[index++] = 0x00; - packet[index++] = 0x00; - packet[index++] = 0x00; - - val.setName( "sid" ); - index += val.writeName( packet, index ); - packet[index++] = 0x03; - - for(int i=0;i<16;i++) +using namespace std; + +namespace xfirelib +{ + int ClientLoginPacket::getPacketContent(char *packet) { - packet[index++] = 0x0; + int index = 0; + /*Username*/ + + index = XFireUtils::addAttributName(packet, index, "name");/*add username attribute*/ + packet[index] = 0x01; + packet[index + 1] = (char)name.length(); + packet[index + 2] = 0x00; + index += 3; + std::copy(name.begin(), name.end(), packet + index); + index += name.size(); + + /*Crypted Password*/ + unsigned char pass[41]; + pass[40] = 0x00; + cryptPassword(pass); + index = XFireUtils::addAttributName(packet, index, "password");/*add username attribute*/ + packet[index] = 0x01; + packet[index + 1] = (char)40; + packet[index + 2] = 0x00; + index += 3; + + memcpy(packet + index, pass, 40); + index += 40; + + VariableValue val; + val.setName("flags"); + index += val.writeName(packet, index); + packet[index++] = 0x02; + packet[index++] = 0x00; + packet[index++] = 0x00; + packet[index++] = 0x00; + packet[index++] = 0x00; + + val.setName("sid"); + index += val.writeName(packet, index); + packet[index++] = 0x03; + + for (int i = 0; i < 16; i++) { + packet[index++] = 0x0; + } + + length = index; + return index; } - length = index; - return index; - } - - int ClientLoginPacket::getPacketAttributeCount() { - return 3; - } - - void ClientLoginPacket::cryptPassword(unsigned char *crypt){ - std::string total; - char temp[81]; - CSHA1 sha1; - - total = name+password+"UltimateArena"; - hashSha1(total.c_str(),crypt); - memcpy(temp,crypt,40); - memcpy(temp+40,salt->getValue(),40); - temp[80] = 0x00; - - hashSha1(temp,crypt); - } + int ClientLoginPacket::getPacketAttributeCount() + { + return 3; + } + void ClientLoginPacket::cryptPassword(unsigned char *crypt) + { + std::string total; + char temp[81]; + CSHA1 sha1; + total = name + password + "UltimateArena"; + hashSha1(total.c_str(), crypt); + memcpy(temp, crypt, 40); + memcpy(temp + 40, salt->getValue(), 40); + temp[80] = 0x00; -/*give string and you will get the hash*/ -void ClientLoginPacket::hashSha1(const char *string, unsigned char *sha){ + hashSha1(temp, crypt); + } - char result[41]; - unsigned char temp[1024]; - CSHA1 sha1; - sha1.Reset(); - sha1.Update((UINT_8 *)string, mir_strlen(string)); - sha1.Final(); - sha1.GetHash(temp); + /*give string and you will get the hash*/ + void ClientLoginPacket::hashSha1(const char *string, unsigned char *sha) + { - result[0] = 0; - char szTemp[16]; - for(int i = 0 ; i < 20 ; i++) { - mir_snprintf(szTemp, "%02x", temp[i]); - mir_strcat(result,szTemp); + char result[41]; + unsigned char temp[1024]; + CSHA1 sha1; + sha1.Reset(); + sha1.Update((UINT_8 *)string, mir_strlen(string)); + sha1.Final(); + sha1.GetHash(temp); + + result[0] = 0; + char szTemp[16]; + for (int i = 0; i < 20; i++) { + mir_snprintf(szTemp, "%02x", temp[i]); + mir_strcat(result, szTemp); + } + memcpy(sha, result, 40); + sha[40] = 0x00; } - memcpy(sha,result,40); - sha[40] = 0x00; -} } diff --git a/protocols/Xfire/src/clientloginpacket.h b/protocols/Xfire/src/clientloginpacket.h index 56f8641b25..8a747e1332 100644 --- a/protocols/Xfire/src/clientloginpacket.h +++ b/protocols/Xfire/src/clientloginpacket.h @@ -33,38 +33,38 @@ namespace xfirelib { - /** - * (Internal) Packet used to send login/authorization data. - * Users of xfirelib should not use it, call - * Client::connect( std::string username, std::string password ) - * instead. - */ - class ClientLoginPacket : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new ClientLoginPacket(); } + /** + * (Internal) Packet used to send login/authorization data. + * Users of xfirelib should not use it, call + * Client::connect( std::string username, std::string password ) + * instead. + */ + class ClientLoginPacket : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new ClientLoginPacket(); } - int getPacketId() { return 1; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1024; }; - void setUsername(std::string name) {this->name = name;} - void setPassword(std::string password) {this->password = password; }; + int getPacketId() { return 1; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1024; }; + void setUsername(std::string name) {this->name = name;} + void setPassword(std::string password) {this->password = password; }; - /** - *Set the salt the server sent us to crypt the password - *@param salt The VariableValue object that we extracted from the packet - */ - void setSalt(VariableValue *salt) {this->salt = salt; }; + /** + *Set the salt the server sent us to crypt the password + *@param salt The VariableValue object that we extracted from the packet + */ + void setSalt(VariableValue *salt) {this->salt = salt; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; - private: - void cryptPassword(unsigned char *crypt); - void hashSha1(const char *string, unsigned char *sha); - int length; - std::string name; - std::string password; - VariableValue *salt; - }; + void parseContent(char*, int, int) { }; + private: + void cryptPassword(unsigned char *crypt); + void hashSha1(const char *string, unsigned char *sha); + int length; + std::string name; + std::string password; + VariableValue *salt; + }; }; diff --git a/protocols/Xfire/src/clientversionpacket.cpp b/protocols/Xfire/src/clientversionpacket.cpp index 3150eac746..84f2c8788f 100644 --- a/protocols/Xfire/src/clientversionpacket.cpp +++ b/protocols/Xfire/src/clientversionpacket.cpp @@ -25,28 +25,30 @@ #include "xfireutils.h" #include <string.h> -namespace xfirelib { +namespace xfirelib +{ + int ClientVersionPacket::getPacketContent(char *packet) + { + int index = 0; - int ClientVersionPacket::getPacketContent(char *packet) { - int index = 0; - - index = XFireUtils::addAttributName(packet,index, "version");/*add xfire version*/ - packet[index] = 0x02; - packet[index+1] = (char) version;//protocol version - packet[index+2] = 0x00; - packet[index+3] = 0x00; - packet[index+4] = 0x00; - index += 5; - length = index; - return index; - } + index = XFireUtils::addAttributName(packet, index, "version");/*add xfire version*/ + packet[index] = 0x02; + packet[index + 1] = (char)version;//protocol version + packet[index + 2] = 0x00; + packet[index + 3] = 0x00; + packet[index + 4] = 0x00; + index += 5; + length = index; + return index; + } - int ClientVersionPacket::getPacketAttributeCount() { - return 1; - } - - void ClientVersionPacket::setProtocolVersion(int newVersion){ - version = newVersion; - } + int ClientVersionPacket::getPacketAttributeCount() + { + return 1; + } + void ClientVersionPacket::setProtocolVersion(int newVersion) + { + version = newVersion; + } } diff --git a/protocols/Xfire/src/clientversionpacket.h b/protocols/Xfire/src/clientversionpacket.h index 4c40b1875a..c8c8d5e6ce 100644 --- a/protocols/Xfire/src/clientversionpacket.h +++ b/protocols/Xfire/src/clientversionpacket.h @@ -29,25 +29,25 @@ namespace xfirelib { - /** - * (Internal) Packet used to send client version information. - * it is sent in Client::connect( std::string, std::string ) - * so users of xfirelib won't need this packet. - */ - class ClientVersionPacket : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new ClientVersionPacket(); } - - int getPacketId() { return 3; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1024; }; - void setProtocolVersion(int version); - void parseContent(char *buf, int length, int numberOfAtts) { }; - private: - int length; - int version; - }; + /** + * (Internal) Packet used to send client version information. + * it is sent in Client::connect( std::string, std::string ) + * so users of xfirelib won't need this packet. + */ + class ClientVersionPacket : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new ClientVersionPacket(); } + + int getPacketId() { return 3; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1024; } + void setProtocolVersion(int version); + void parseContent(char*, int, int) {} + private: + int length; + int version; + }; }; diff --git a/protocols/Xfire/src/dummyxfiregameresolver.cpp b/protocols/Xfire/src/dummyxfiregameresolver.cpp index 5189c8ef9b..7d4f14f151 100644 --- a/protocols/Xfire/src/dummyxfiregameresolver.cpp +++ b/protocols/Xfire/src/dummyxfiregameresolver.cpp @@ -24,26 +24,25 @@ #include "dummyxfiregameresolver.h" #include "xdebug.h" -namespace xfirelib { - - XFireGame *DummyXFireGameResolver::resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) { - XDEBUG2( "Resolving GameId: %d\n", gameid ); - DummyXFireGame *game = new DummyXFireGame(); - switch(gameid) { - case 2: game->init( gameid, "America's Army: Special Forces", packet,iterator ); break; - case 3: game->init( gameid, "Unreal Tournament", packet,iterator ); break; - case 4: game->init( gameid, "Unreal Tournament 2003", packet ,iterator); break; - case 5: game->init( gameid, "Counter-Strike 1.6", packet ,iterator); break; - case 32: game->init( gameid, "Teamspeak", packet ,iterator); break; - case 4181: game->init( gameid, "Unreal Tournament 2004", packet,iterator ); break; - case 4578: game->init( gameid, "Battlefield 2", packet ,iterator); break; - case 4611: game->init( gameid, "Live for Speed", packet,iterator ); break; - default: - game->init( gameid, "Non Resolvegame", packet,iterator ); - break; - } - return game; - } - - +namespace xfirelib +{ + XFireGame* DummyXFireGameResolver::resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) + { + XDEBUG2("Resolving GameId: %d\n", gameid); + DummyXFireGame *game = new DummyXFireGame(); + switch (gameid) { + case 2: game->init(gameid, "America's Army: Special Forces", packet, iterator); break; + case 3: game->init(gameid, "Unreal Tournament", packet, iterator); break; + case 4: game->init(gameid, "Unreal Tournament 2003", packet, iterator); break; + case 5: game->init(gameid, "Counter-Strike 1.6", packet, iterator); break; + case 32: game->init(gameid, "Teamspeak", packet, iterator); break; + case 4181: game->init(gameid, "Unreal Tournament 2004", packet, iterator); break; + case 4578: game->init(gameid, "Battlefield 2", packet, iterator); break; + case 4611: game->init(gameid, "Live for Speed", packet, iterator); break; + default: + game->init(gameid, "Non Resolvegame", packet, iterator); + break; + } + return game; + } }; diff --git a/protocols/Xfire/src/dummyxfiregameresolver.h b/protocols/Xfire/src/dummyxfiregameresolver.h index fdaaeb5c0b..54b28c27a5 100644 --- a/protocols/Xfire/src/dummyxfiregameresolver.h +++ b/protocols/Xfire/src/dummyxfiregameresolver.h @@ -26,42 +26,41 @@ #include "xfiregame.h" #include "xfiregameresolver.h" #include "xdebug.h" -#include <string> namespace xfirelib { - struct DummyXFireGame; - class DummyXFireGameResolver : public XFireGameResolver { - public: - XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet); + struct DummyXFireGame; + class DummyXFireGameResolver : public XFireGameResolver { + public: + XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet); - }; + }; - class DummyXFireGame : public XFireGame { - public: - // TODO !!!!!!!!!!!!! this->packet = packet should NOT be used !! - // we need to create a copy of packet, because it will be deleted as soon - // as all listeners are notified !!! - void init(int gameid, std::string gamename, BuddyListGamesPacket *packet, int iterator) { - this->gameid = gameid; - this->gamename = gamename; - this->packet = packet; - - memcpy(ip,packet->ips->at(iterator),4); - port = packet->ports->at(iterator); - XDEBUG(( "init .. %d / %s\n", gameid, gamename.c_str() )); - } + class DummyXFireGame : public XFireGame { + public: + // TODO !!!!!!!!!!!!! this->packet = packet should NOT be used !! + // we need to create a copy of packet, because it will be deleted as soon + // as all listeners are notified !!! + void init(int gameid, std::string gamename, BuddyListGamesPacket *packet, int iterator) { + this->gameid = gameid; + this->gamename = gamename; + this->packet = packet; - int getGameId() { return gameid; } - std::string getGameName() { return gamename; } + memcpy(ip,packet->ips->at(iterator),4); + port = packet->ports->at(iterator); + XDEBUG(( "init .. %d / %s\n", gameid, gamename.c_str() )); + } - BuddyListGamesPacket *packet; - int gameid; - char ip[4]; - long port; - std::string gamename; - }; + int getGameId() { return gameid; } + std::string getGameName() { return gamename; } + + BuddyListGamesPacket *packet; + int gameid; + char ip[4]; + long port; + std::string gamename; + }; }; diff --git a/protocols/Xfire/src/friendsoffriendlist.cpp b/protocols/Xfire/src/friendsoffriendlist.cpp index c2c5fa5c70..7a27c2c36b 100644 --- a/protocols/Xfire/src/friendsoffriendlist.cpp +++ b/protocols/Xfire/src/friendsoffriendlist.cpp @@ -23,89 +23,90 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "friendsoffriendlist.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - FriendsBuddyListNamesPacket::FriendsBuddyListNamesPacket() { - usernames = 0; - nicks = 0; - userids = 0; - } - FriendsBuddyListNamesPacket::~FriendsBuddyListNamesPacket() { - delete usernames; - delete nicks; - delete userids; - } - - void FriendsBuddyListNamesPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - - VariableValue friends; - - XDEBUG2( "Len: %d\n", length ); - - index+=8; //paar bytes überspringen - - int numberOfIds = (unsigned char)buf[index]; - XDEBUG2( "numberofId: %d\n", numberOfIds ); - index++; - index++;//ignore 00 - sids = new vector<char *>; - for(int i = 0 ; i < numberOfIds ; i++) { - index += friends.readValue(buf,index,16); - char *sid = new char[16]; - memcpy(sid,friends.getValue(),16); - sids->push_back(sid); - } - - XERROR("Sids ausgelesen\n"); - - index+=7; - - index+=4; - - userids = new vector<long>; - for(int i = 0 ; i < numberOfIds ; i++) { - index += friends.readValue(buf,index,4); - userids->push_back(friends.getValueAsLong()); - XDEBUG3( "UserID: %ld %ld\n",i+1, friends.getValueAsLong() ); - } - - index+=7; - - usernames = new vector<string>; - index = readStrings(usernames,buf,index); - - index+=7; - - nicks = new vector<string>; - index = readStrings(nicks,buf,index); - - } - - int FriendsBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) { - VariableValue friends; - index += friends.readValue(buf,index,2); - //index ++; // Ignore 00 - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - string stringvalue = string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() )); - } - return index; - } - -}; +using namespace std; + +namespace xfirelib +{ + FriendsBuddyListNamesPacket::FriendsBuddyListNamesPacket() + { + usernames = 0; + nicks = 0; + userids = 0; + } + + FriendsBuddyListNamesPacket::~FriendsBuddyListNamesPacket() + { + delete usernames; + delete nicks; + delete userids; + } + + void FriendsBuddyListNamesPacket::parseContent(char *buf, int, int) + { + int index = 0; + + VariableValue friends; + + index += 8; //paar bytes überspringen + + int numberOfIds = (unsigned char)buf[index]; + XDEBUG2("numberofId: %d\n", numberOfIds); + index++; + index++;//ignore 00 + sids = new vector<char *>; + for (int i = 0; i < numberOfIds; i++) { + index += friends.readValue(buf, index, 16); + char *sid = new char[16]; + memcpy(sid, friends.getValue(), 16); + sids->push_back(sid); + } + + XERROR("Sids ausgelesen\n"); + + index += 7; + + index += 4; + + userids = new vector<long>; + for (int i = 0; i < numberOfIds; i++) { + index += friends.readValue(buf, index, 4); + userids->push_back(friends.getValueAsLong()); + XDEBUG3("UserID: %ld %ld\n", i + 1, friends.getValueAsLong()); + } + + index += 7; + + usernames = new vector<string>; + index = readStrings(usernames, buf, index); + + index += 7; + + nicks = new vector<string>; + index = readStrings(nicks, buf, index); + + } + + int FriendsBuddyListNamesPacket::readStrings(vector<string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readValue(buf, index, 2); + //index ++; // Ignore 00 + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + string stringvalue = string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG(("String length: %2d : %s\n", length, stringvalue.c_str())); + } + return index; + } +} diff --git a/protocols/Xfire/src/friendsoffriendlist.h b/protocols/Xfire/src/friendsoffriendlist.h index 70c59a76e9..6e645e81c3 100644 --- a/protocols/Xfire/src/friendsoffriendlist.h +++ b/protocols/Xfire/src/friendsoffriendlist.h @@ -27,37 +27,33 @@ #define XFIRE_FRIENDS_BUDDYS_NAMES_ID 0x88 -#include <vector> -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" - namespace xfirelib { - using namespace std; + using namespace std; - class FriendsBuddyListNamesPacket : public XFireRecvPacketContent { - public: - FriendsBuddyListNamesPacket(); - virtual ~FriendsBuddyListNamesPacket(); + class FriendsBuddyListNamesPacket : public XFireRecvPacketContent { + public: + FriendsBuddyListNamesPacket(); + virtual ~FriendsBuddyListNamesPacket(); - XFirePacketContent* newPacket() { return new FriendsBuddyListNamesPacket(); } + XFirePacketContent* newPacket() { return new FriendsBuddyListNamesPacket(); } - int getPacketId() { return XFIRE_FRIENDS_BUDDYS_NAMES_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 10024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_FRIENDS_BUDDYS_NAMES_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 10024; }; + void parseContent(char *buf, int length, int numberOfAtts); - //private: - int readStrings(vector<string> *strings, char *buf, int index); + //private: + int readStrings(vector<string> *strings, char *buf, int index); - vector<string> *usernames; - vector<string> *nicks; - vector<long> *userids; - vector<char *> *sids; - }; + vector<string> *usernames; + vector<string> *nicks; + vector<long> *userids; + vector<char *> *sids; + }; }; diff --git a/protocols/Xfire/src/gameinfopacket.cpp b/protocols/Xfire/src/gameinfopacket.cpp index a134af85c9..1eb78923aa 100644 --- a/protocols/Xfire/src/gameinfopacket.cpp +++ b/protocols/Xfire/src/gameinfopacket.cpp @@ -24,62 +24,61 @@ #include "stdafx.h" -#include <vector> -#include <string> - #include "gameinfopacket.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - GameInfoPacket::GameInfoPacket() { - } - GameInfoPacket::~GameInfoPacket() { - } - - void GameInfoPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - int numberOfSids = 0; - VariableValue val; - - index += val.readName(buf,index); - - index++; //ignore 04 - index++; //ignore 03 - - XDEBUG2("Anzahl: %d\n",buf[index]); - numberOfSids = buf[index]; - - index++; //ignore 01 - index++; //ignore 0 +using namespace std; - sids = new vector<char *>; - for(int i = 0 ; i < numberOfSids ; i++) { - index += val.readValue(buf,index,16); - char *sid = new char[16]; - memcpy(sid,val.getValue(),16); - sids->push_back(sid); +namespace xfirelib +{ + GameInfoPacket::GameInfoPacket() + { } - index += val.readName(buf,index); - - index += 4; // nächsten 4 bytes skippen - - gameinfo=new vector<string>; - for(int i = 0 ; i < numberOfSids ; i++) { - int length = (unsigned char)buf[index++]; - index++; - index += val.readValue(buf,index,length); - string stringvalue = string(val.getValue(),length); - gameinfo->push_back(stringvalue); - XDEBUG(( "String length: %2d : %s\n", length, stringvalue.c_str() )); - } - - XDEBUG2("Position: %d\n",index); - - } + GameInfoPacket::~GameInfoPacket() + { + } + void GameInfoPacket::parseContent(char *buf, int, int) + { + int index = 0; + int numberOfSids = 0; + VariableValue val; + + index += val.readName(buf, index); + + index++; //ignore 04 + index++; //ignore 03 + + XDEBUG2("Anzahl: %d\n", buf[index]); + numberOfSids = buf[index]; + + index++; //ignore 01 + index++; //ignore 0 + + sids = new vector<char *>; + for (int i = 0; i < numberOfSids; i++) { + index += val.readValue(buf, index, 16); + char *sid = new char[16]; + memcpy(sid, val.getValue(), 16); + sids->push_back(sid); + } + index += val.readName(buf, index); + + index += 4; // nächsten 4 bytes skippen + + gameinfo = new vector<string>; + for (int i = 0; i < numberOfSids; i++) { + int length = (unsigned char)buf[index++]; + index++; + index += val.readValue(buf, index, length); + string stringvalue = string(val.getValue(), length); + gameinfo->push_back(stringvalue); + XDEBUG(("String length: %2d : %s\n", length, stringvalue.c_str())); + } + + XDEBUG2("Position: %d\n", index); + } }; diff --git a/protocols/Xfire/src/gameinfopacket.h b/protocols/Xfire/src/gameinfopacket.h index dfd890e814..707458ba85 100644 --- a/protocols/Xfire/src/gameinfopacket.h +++ b/protocols/Xfire/src/gameinfopacket.h @@ -27,30 +27,28 @@ #define XFIRE_GAMEINFO_ID 156 -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" namespace xfirelib { - using namespace std; + using namespace std; - class GameInfoPacket : public XFireRecvPacketContent { - public: - GameInfoPacket(); - virtual ~GameInfoPacket(); + class GameInfoPacket : public XFireRecvPacketContent { + public: + GameInfoPacket(); + virtual ~GameInfoPacket(); - XFirePacketContent* newPacket() { return new GameInfoPacket(); } + XFirePacketContent* newPacket() { return new GameInfoPacket(); } - virtual int getPacketId() { return XFIRE_GAMEINFO_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - virtual void parseContent(char *buf, int length, int numberOfAtts); + virtual int getPacketId() { return XFIRE_GAMEINFO_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + virtual void parseContent(char *buf, int length, int numberOfAtts); - vector<char *> *sids; - vector<string> *gameinfo; - }; + vector<char *> *sids; + vector<string> *gameinfo; + }; }; #endif
\ No newline at end of file diff --git a/protocols/Xfire/src/getbuddyinfo.cpp b/protocols/Xfire/src/getbuddyinfo.cpp index 6d21742510..af5f3645b3 100644 --- a/protocols/Xfire/src/getbuddyinfo.cpp +++ b/protocols/Xfire/src/getbuddyinfo.cpp @@ -32,25 +32,27 @@ getestet mit clanbuddy's >270 members */ -namespace xfirelib { - using namespace std; +using namespace std; - int GetBuddyInfo::getPacketContent(char *packet) { - int index = 0; +namespace xfirelib +{ + int GetBuddyInfo::getPacketContent(char *packet) + { + int index = 0; - VariableValue val; - val.setValueFromLong(userid,4); + VariableValue val; + val.setValueFromLong(userid, 4); - packet[index++] = 0x01; - packet[index++] = 0x02; - index += val.writeValue(packet, index); + packet[index++] = 0x01; + packet[index++] = 0x02; + index += val.writeValue(packet, index); - length = index; - return index; - } - - int GetBuddyInfo::getPacketAttributeCount() { - return 1; - } + length = index; + return index; + } + int GetBuddyInfo::getPacketAttributeCount() + { + return 1; + } } diff --git a/protocols/Xfire/src/getbuddyinfo.h b/protocols/Xfire/src/getbuddyinfo.h index efd8ded51d..a46b7b0f91 100644 --- a/protocols/Xfire/src/getbuddyinfo.h +++ b/protocols/Xfire/src/getbuddyinfo.h @@ -30,25 +30,23 @@ #include "xfiresendpacketcontent.h" #include "variablevalue.h" -#include <string> - namespace xfirelib { - class GetBuddyInfo : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new GetBuddyInfo(); } + class GetBuddyInfo : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new GetBuddyInfo(); } - int getPacketId() { return 0x25; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1000; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; + int getPacketId() { return 0x25; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1000; }; + void parseContent(char*, int, int) { }; - unsigned int userid; + unsigned int userid; - private: - int length; - }; + private: + int length; + }; }; diff --git a/protocols/Xfire/src/iniupdater.cpp b/protocols/Xfire/src/iniupdater.cpp index 6d97588ad4..ed3a43534e 100644 --- a/protocols/Xfire/src/iniupdater.cpp +++ b/protocols/Xfire/src/iniupdater.cpp @@ -9,30 +9,27 @@ extern HANDLE XFireWorkingFolder;
extern HANDLE XFireIconFolder;
-INT_PTR CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
+ {
+ 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;
- }
+ return TRUE;
+ }
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hwndDlg, IDOK);
return TRUE;
@@ -47,24 +44,22 @@ INT_PTR CALLBACK DlgUpdateDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE;
}
-void UpdateMyXFireIni(LPVOID dummy) {
+void UpdateMyXFireIni(LPVOID)
+{
char request[1024];
char *inipath = XFireGetFoldersPath("IniFile");
//ini pfad rausbekommen
char file[1024], file2[1024], file3[1024];
- mir_snprintf(file,_countof(file), "%sxfire_games.new",inipath);
- mir_snprintf(file2,_countof(file2), "%sxfire_games.ini",inipath);
- mir_snprintf(file3,_countof(file3), "%sxfire_games.old",inipath);
+ mir_snprintf(file, _countof(file), "%sxfire_games.new", inipath);
+ mir_snprintf(file2, _countof(file2), "%sxfire_games.ini", inipath);
+ mir_snprintf(file3, _countof(file3), "%sxfire_games.old", inipath);
mir_snprintf(request, _countof(request), "%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 (GetWWWContent2(request, file, FALSE))
- {
+ if (CheckWWWContent(request)) {
+ if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 1 || DialogBox(hinstance, MAKEINTRESOURCE(IDD_UPDATE), NULL, DlgUpdateDialogProc) == IDOK) {
+ if (GetWWWContent2(request, file, FALSE)) {
//altes backup löschen
remove(file3);
//derzeitige ini und sichern
@@ -77,28 +72,26 @@ void UpdateMyXFireIni(LPVOID dummy) { 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."));
+ else MSGBOX(Translate("Error during xfire_games.ini update."));
}
}
}
-void UpdateMyIcons(LPVOID dummy) {
+void UpdateMyIcons(LPVOID)
+{
char request[1024];
char *inipath = XFireGetFoldersPath("IconsFile");
//ini pfad rausbekommen
char file[1024], file2[1024], file3[1024];
- mir_snprintf(file,_countof(file), "%sicons.new",inipath);
- mir_snprintf(file2,_countof(file2), "%sicons.dll",inipath);
- mir_snprintf(file3,_countof(file3), "%sicons.old",inipath);
+ mir_snprintf(file, _countof(file), "%sicons.new", inipath);
+ mir_snprintf(file2, _countof(file2), "%sicons.dll", inipath);
+ mir_snprintf(file3, _countof(file3), "%sicons.old", inipath);
mir_snprintf(request, _countof(request), "%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 (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 (GetWWWContent2(request, file, FALSE)) {
//altes backup löschen
remove(file3);
@@ -112,8 +105,7 @@ void UpdateMyIcons(LPVOID dummy) { if (db_get_b(NULL, protocolname, "dontaskforupdate", 0) == 0) MSGBOX(Translate("The Icons.dll was updated."));
}
- else
- MSGBOX(Translate("Error during Icons.dll Update."));
+ else MSGBOX(Translate("Error during Icons.dll Update."));
}
}
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/invitebuddypacket.cpp b/protocols/Xfire/src/invitebuddypacket.cpp index f9e46cdebf..3763e69e09 100644 --- a/protocols/Xfire/src/invitebuddypacket.cpp +++ b/protocols/Xfire/src/invitebuddypacket.cpp @@ -23,71 +23,77 @@ #include "invitebuddypacket.h" #include "variablevalue.h" -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + using namespace std; - InviteBuddyPacket::InviteBuddyPacket() { - names = new vector<string>; - msgs = new vector<string>; - } - InviteBuddyPacket::~InviteBuddyPacket() { - delete names; - delete msgs; - } + InviteBuddyPacket::InviteBuddyPacket() + { + names = new vector<string>; + msgs = new vector<string>; + } - void InviteBuddyPacket::parseContent(char *buf, int length, int numberOfAtts) { - /* Useless.. we only receive Packet 138 for invitations - VariableValue val; - int index = 0; - index += val.readName( buf, index ); - int namecount = (unsigned char)buf[index++]; - for(int i = 0 ; i < namecount ; i++) { - int namelen = (unsigned char)buf[index++]; - index++; // ignore 00 - index += val.readValue( buf, index, namelen ); - this->msg->push_back(string(val.getValue(),val.getValueLength())); - } - index += val.readName( buf, index ); - - int msgcount = (unsigned char)buf[index++]; - for(int i = 0 ; i < msgcount ; i++) { - int msglen = (unsigned char)buf[index++]; - index++; // ignore 00 - index += val.readValue(buf,index,msglen); - this->msg->push_back(string(val.getValue(),val.getValueLength())); - } - */ - } - int InviteBuddyPacket::getPacketContent(char *buf) { - int index = 0; - VariableValue val; - val.setName("name"); - index += val.writeName(buf,index); - buf[index++] = names->size(); - for(uint i = 0 ; i < names->size() ; i++) { - string name = names->at(i); - buf[index++] = name.length(); - buf[index++] = 0; - memcpy(buf+index,name.c_str(),name.length()); - index+=name.length(); - } - val.setName("msg"); - index += val.writeName(buf,index); - buf[index++] = msgs->size(); - for(uint i = 0 ; i < msgs->size() ; i++) { - string msg = msgs->at(i); - buf[index++] = msg.length(); - buf[index++] = 0; - memcpy(buf+index,msg.c_str(),msg.length()); - index+=msg.length(); - } - return index; - } + InviteBuddyPacket::~InviteBuddyPacket() + { + delete names; + delete msgs; + } - void InviteBuddyPacket::addInviteName(string name, string msg) { - this->names->push_back(name); - this->msgs->push_back(msg); - } + void InviteBuddyPacket::parseContent(char*, int, int) + { + /* Useless.. we only receive Packet 138 for invitations + VariableValue val; + int index = 0; + index += val.readName( buf, index ); + int namecount = (unsigned char)buf[index++]; + for(int i = 0 ; i < namecount ; i++) { + int namelen = (unsigned char)buf[index++]; + index++; // ignore 00 + index += val.readValue( buf, index, namelen ); + this->msg->push_back(string(val.getValue(),val.getValueLength())); + } + index += val.readName( buf, index ); + int msgcount = (unsigned char)buf[index++]; + for(int i = 0 ; i < msgcount ; i++) { + int msglen = (unsigned char)buf[index++]; + index++; // ignore 00 + index += val.readValue(buf,index,msglen); + this->msg->push_back(string(val.getValue(),val.getValueLength())); + } + */ + } + int InviteBuddyPacket::getPacketContent(char *buf) + { + int index = 0; + VariableValue val; + val.setName("name"); + index += val.writeName(buf, index); + buf[index++] = names->size(); + for (uint i = 0; i < names->size(); i++) { + string name = names->at(i); + buf[index++] = name.length(); + buf[index++] = 0; + memcpy(buf + index, name.c_str(), name.length()); + index += name.length(); + } + val.setName("msg"); + index += val.writeName(buf, index); + buf[index++] = msgs->size(); + for (uint i = 0; i < msgs->size(); i++) { + string msg = msgs->at(i); + buf[index++] = msg.length(); + buf[index++] = 0; + memcpy(buf + index, msg.c_str(), msg.length()); + index += msg.length(); + } + return index; + } + + void InviteBuddyPacket::addInviteName(string name, string msg) + { + this->names->push_back(name); + this->msgs->push_back(msg); + } }; diff --git a/protocols/Xfire/src/invitebuddypacket.h b/protocols/Xfire/src/invitebuddypacket.h index 055898d04a..43a1d17a2b 100644 --- a/protocols/Xfire/src/invitebuddypacket.h +++ b/protocols/Xfire/src/invitebuddypacket.h @@ -24,43 +24,38 @@ #define __INVITEBUDDYPACKET_H #include "xfiresendpacketcontent.h" -#include <vector> -#include <string> #define XFIRE_PACKET_INVITE_BUDDY 6 using namespace xfirelib; namespace xfirelib { - using namespace std; + using namespace std; - /** - * Packet Used to Invite Buddy into Contact List - * (Received is InviteRequestPacket) - */ - class InviteBuddyPacket : public XFireSendPacketContent { - public: - InviteBuddyPacket(); - ~InviteBuddyPacket(); + /** + * Packet Used to Invite Buddy into Contact List + * (Received is InviteRequestPacket) + */ + class InviteBuddyPacket : public XFireSendPacketContent { + public: + InviteBuddyPacket(); + ~InviteBuddyPacket(); - XFirePacketContent* newPacket() { return new InviteBuddyPacket(); } + XFirePacketContent* newPacket() { return new InviteBuddyPacket(); } - int getPacketId() { return XFIRE_PACKET_INVITE_BUDDY; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 2; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_PACKET_INVITE_BUDDY; } + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 2; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); - void addInviteName(string name, string msg); - - vector<string> *names; - vector<string> *msgs; - private: - }; + void addInviteName(string name, string msg); + vector<string> *names; + vector<string> *msgs; + }; }; - #endif diff --git a/protocols/Xfire/src/inviterequestpacket.cpp b/protocols/Xfire/src/inviterequestpacket.cpp index dc105d31ff..a6f976f094 100644 --- a/protocols/Xfire/src/inviterequestpacket.cpp +++ b/protocols/Xfire/src/inviterequestpacket.cpp @@ -24,28 +24,28 @@ #include "inviterequestpacket.h" #include "variablevalue.h" -#include <string> -namespace xfirelib { - using namespace std; +using namespace std; - void InviteRequestPacket::parseContent(char *buf, int length, int numberOfAtts) { - VariableValue val; - int index = 0; - index += val.readName(buf,index); - index += 4; // Ignore 04 01 01 00 - index += val.readValue(buf,index,-1,1); - name = string(val.getValue(),val.getValueLength()); - - index += val.readName(buf,index); - index += 4; // Ignore 04 01 01 00 - index += val.readValue(buf,index,-1,1); - nick = string(val.getValue(),val.getValueLength()); - - index += val.readName(buf,index); - index += 4; // Ignore 04 01 01 00 - index += val.readValue(buf,index,-1,1); - msg = string(val.getValue(),val.getValueLength()); - } +namespace xfirelib +{ + void InviteRequestPacket::parseContent(char *buf, int, int) + { + VariableValue val; + int index = 0; + index += val.readName(buf, index); + index += 4; // Ignore 04 01 01 00 + index += val.readValue(buf, index, -1, 1); + name = string(val.getValue(), val.getValueLength()); + index += val.readName(buf, index); + index += 4; // Ignore 04 01 01 00 + index += val.readValue(buf, index, -1, 1); + nick = string(val.getValue(), val.getValueLength()); + + index += val.readName(buf, index); + index += 4; // Ignore 04 01 01 00 + index += val.readValue(buf, index, -1, 1); + msg = string(val.getValue(), val.getValueLength()); + } }; diff --git a/protocols/Xfire/src/inviterequestpacket.h b/protocols/Xfire/src/inviterequestpacket.h index 5f8bac43cb..d5741b4c55 100644 --- a/protocols/Xfire/src/inviterequestpacket.h +++ b/protocols/Xfire/src/inviterequestpacket.h @@ -23,38 +23,33 @@ #ifndef __INVITEREQUESTPACKET_H #define __INVITEREQUESTPACKET_H -#include <string> #include "xfirerecvpacketcontent.h" #define XFIRE_PACKET_INVITE_REQUEST_PACKET 138 namespace xfirelib { - using namespace std; - - /** - * Received when someone invites you to his buddylist - * (For sending invitations see InviteBuddyPacket) - */ - class InviteRequestPacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new InviteRequestPacket(); } - - - int getPacketId() { return XFIRE_PACKET_INVITE_REQUEST_PACKET; } - int getPacketContent(char *buf) { return 0;} - int getPacketAttributeCount() { return 3; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - - string name; - string nick; - string msg; - - private: - }; - + using namespace std; + + /** + * Received when someone invites you to his buddylist + * (For sending invitations see InviteBuddyPacket) + */ + class InviteRequestPacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new InviteRequestPacket(); } + + + int getPacketId() { return XFIRE_PACKET_INVITE_REQUEST_PACKET; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 3; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + + string name; + string nick; + string msg; + }; }; - #endif diff --git a/protocols/Xfire/src/loginfailedpacket.cpp b/protocols/Xfire/src/loginfailedpacket.cpp index 9d6490dfb2..53d16eaacc 100644 --- a/protocols/Xfire/src/loginfailedpacket.cpp +++ b/protocols/Xfire/src/loginfailedpacket.cpp @@ -20,19 +20,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - - #include "stdafx.h" #include "loginfailedpacket.h" #include "xfireparse.h" #include "variablevalue.h" -namespace xfirelib { - using namespace std; - using namespace xfirelib; - - void LoginFailedPacket::parseContent(char *buf, int length, int numberOfAtts) { - cout << "Login failed, incorrect username or password" << endl; - } +using namespace std; +namespace xfirelib +{ + void LoginFailedPacket::parseContent(char*, int, int) + { + cout << "Login failed, incorrect username or password" << endl; + } }; diff --git a/protocols/Xfire/src/loginfailedpacket.h b/protocols/Xfire/src/loginfailedpacket.h index 20f955bc51..563b5dc0cd 100644 --- a/protocols/Xfire/src/loginfailedpacket.h +++ b/protocols/Xfire/src/loginfailedpacket.h @@ -30,17 +30,17 @@ namespace xfirelib { - class LoginFailedPacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new LoginFailedPacket(); } + class LoginFailedPacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new LoginFailedPacket(); } - int getPacketId() { return XFIRE_LOGIN_FAILED_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - }; + int getPacketId() { return XFIRE_LOGIN_FAILED_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + }; }; diff --git a/protocols/Xfire/src/loginsuccesspacket.cpp b/protocols/Xfire/src/loginsuccesspacket.cpp index 9d855d66d4..e33466bf80 100644 --- a/protocols/Xfire/src/loginsuccesspacket.cpp +++ b/protocols/Xfire/src/loginsuccesspacket.cpp @@ -25,50 +25,53 @@ #include "xdebug.h" #include "loginsuccesspacket.h" -namespace xfirelib { +namespace xfirelib +{ + void LoginSuccessPacket::parseContent(char *buf, int, int numberOfAtts) + { + int read = 0; + for (int i = 0; i < numberOfAtts; i++) { + VariableValue *val = new VariableValue(); + read += val->readName(buf, read); + XDEBUG(("Read Variable Name: %s\n", val->getName().c_str())); + if (val->getName() == "userid") { + read++; // ignore 02 + read += val->readValue(buf, read, 3); + read++; // ignore 00 + XDEBUG2("My userid: %lu\n", val->getValueAsLong()); + this->myuid = val->getValueAsLong(); + } + else if (val->getName() == "sid") { + read++; // ignore 03 + read += val->readValue(buf, read, 16); + //XDEBUG(( "My SID: %u\n", val->getValue() )); + } + else if (val->getName() == "nick") { + //int lengthLength = (int)val->getValueAsLong(); + read++; // ignore 01 + //read+=val->readValue(buf, read, -1, 1); - void LoginSuccessPacket::parseContent(char *buf, int length, int numberOfAtts) { - - int read = 0; - for(int i = 0 ; i < numberOfAtts ; i++) { - VariableValue *val = new VariableValue(); - read += val->readName(buf, read); - XDEBUG(( "Read Variable Name: %s\n", val->getName().c_str() )); - if (val->getName() == "userid") { - read++; // ignore 02 - read += val->readValue(buf, read, 3); - read++; // ignore 00 - XDEBUG2( "My userid: %lu\n", val->getValueAsLong() ); - this->myuid=val->getValueAsLong(); - } else if (val->getName() == "sid") { - read++; // ignore 03 - read+=val->readValue(buf, read, 16); - //XDEBUG(( "My SID: %u\n", val->getValue() )); - } else if (val->getName() == "nick") { - //int lengthLength = (int)val->getValueAsLong(); - read++; // ignore 01 - //read+=val->readValue(buf, read, -1, 1); - - unsigned int l = (unsigned char)buf[read++]; //dufte - nick wird benötigt - XDEBUG2( "Nick Length: %d\n", l ); - read++; - read += val->readValue(buf,read,l); - XDEBUG2( "Nick Length: %s\n", val->getValue() ); - - this->nick=std::string(val->getValue(),l); - - } else if (val->getName() == "status") { - read+=5; // ignore everything - } else if (val->getName() == "dlset") { - read+=3; // ignore everything - } else { - i = numberOfAtts; - // If we find something we don't know .. we stop parsing the - // packet.. who cares about the rest... - } - delete val; - } - } + unsigned int l = (unsigned char)buf[read++]; //dufte - nick wird benötigt + XDEBUG2("Nick Length: %d\n", l); + read++; + read += val->readValue(buf, read, l); + XDEBUG2("Nick Length: %s\n", val->getValue()); + this->nick = std::string(val->getValue(), l); + } + else if (val->getName() == "status") { + read += 5; // ignore everything + } + else if (val->getName() == "dlset") { + read += 3; // ignore everything + } + else { + i = numberOfAtts; + // If we find something we don't know .. we stop parsing the + // packet.. who cares about the rest... + } + delete val; + } + } }; diff --git a/protocols/Xfire/src/loginsuccesspacket.h b/protocols/Xfire/src/loginsuccesspacket.h index 55dae54b01..d2efbaafbb 100644 --- a/protocols/Xfire/src/loginsuccesspacket.h +++ b/protocols/Xfire/src/loginsuccesspacket.h @@ -31,21 +31,19 @@ namespace xfirelib { - class LoginSuccessPacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new LoginSuccessPacket(); } - - int getPacketId() { return XFIRE_LOGIN_SUCCESS_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - - std::string nick; - long myuid; - }; - + class LoginSuccessPacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new LoginSuccessPacket(); } + + int getPacketId() { return XFIRE_LOGIN_SUCCESS_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + + std::string nick; + long myuid; + }; }; - #endif diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index 75948260e2..e9c881ca94 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -203,7 +203,8 @@ int ExtraListRebuild(WPARAM wparam, LPARAM lparam); //XFire Stuff
using namespace xfirelib;
-class XFireClient : public PacketListener {
+class XFireClient : public PacketListener
+{
public:
Client* client;
@@ -241,17 +242,16 @@ private: XFireClient* myClient = NULL;
-void XFireClient::CheckAvatar(BuddyListEntry* entry) {
+void XFireClient::CheckAvatar(BuddyListEntry* entry)
+{
//kein entry, zurück
if (!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);
}
@@ -263,8 +263,7 @@ void XFireClient::handlingBuddy(MCONTACT handle) vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
for (uint i = 0; i < entries->size(); i++) {
BuddyListEntry *entry = entries->at(i);
- if (entry->hcontact == handle)
- {
+ if (entry->hcontact == handle) {
handlingBuddys(entry, 0, NULL);
break;
}
@@ -272,7 +271,8 @@ void XFireClient::handlingBuddy(MCONTACT handle) //mir_forkthread(
}
-void XFireClient::setNick(char*nnick) {
+void XFireClient::setNick(char*nnick)
+{
/*if (mir_strlen(nnick)==0)
return;*/
SendNickChangePacket nick;
@@ -281,7 +281,8 @@ void XFireClient::setNick(char*nnick) { }
-void XFireClient::sendmsg(char*usr, char*cmsg) {
+void XFireClient::sendmsg(char*usr, char*cmsg)
+{
SendMessagePacket msg;
// if (mir_strlen(cmsg)>255)
// *(cmsg+255)=0;
@@ -291,7 +292,8 @@ void XFireClient::sendmsg(char*usr, char*cmsg) { XFireClient::XFireClient(string username_, string password_, char protover, int useproxy, string proxyip, int proxyport)
- : username(username_), password(password_) {
+ : username(username_), password(password_)
+{
client = new Client();
client->setGameResolver(new DummyXFireGameResolver());
client->protocolVersion = protover;
@@ -305,7 +307,8 @@ XFireClient::XFireClient(string username_, string password_, char protover, int connected = FALSE;
}
-XFireClient::~XFireClient() {
+XFireClient::~XFireClient()
+{
if (client != NULL) {
client->disconnect();
delete client;
@@ -317,12 +320,14 @@ XFireClient::~XFireClient() { if (lastInviteRequest != NULL) delete lastInviteRequest;
}
-void XFireClient::run() {
+void XFireClient::run()
+{
client->connect(username, password, useproxy, proxyip, proxyport);
client->addPacketListener(this);
}
-void XFireClient::Status(string s) {
+void XFireClient::Status(string s)
+{
//da bei xfire statusmsg nur 100bytes länge unterstützt werden, wird gecutted
if (!client->gotBudduyList)
return;
@@ -336,11 +341,11 @@ void XFireClient::Status(string s) { delete packet;
}
-void XFireClient::receivedPacket(XFirePacket *packet) {
+void XFireClient::receivedPacket(XFirePacket *packet)
+{
XFirePacketContent *content = packet->getContent();
- switch (content->getPacketId())
- {
+ switch (content->getPacketId()) {
/*case XFIRE_RECVBUDDYCHANGEDNICK:
{
RecvBuddyChangedNick *changednick = (RecvBuddyChangedNick*)content;
@@ -351,129 +356,121 @@ void XFireClient::receivedPacket(XFirePacket *packet) { }*/
//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;
+ //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);
}
- db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, temp);
}
+ break;
}
- break;
- }
case XFIRE_FOUNDBUDDYS_ID:
- {
- PROTOSEARCHRESULT psr;
- memset(&psr, 0, 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.t = _A2T((char*)fb->usernames->at(i).c_str());
- if ((char*)fb->fname->at(i).c_str() != NULL)
- psr.firstName.t = _A2T((char*)fb->fname->at(i).c_str());
- if ((char*)fb->lname->at(i).c_str() != NULL)
- psr.lastName.t = _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);
+ {
+ PROTOSEARCHRESULT psr;
+ memset(&psr, 0, 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.t = _A2T((char*)fb->usernames->at(i).c_str());
+ if ((char*)fb->fname->at(i).c_str() != NULL)
+ psr.firstName.t = _A2T((char*)fb->fname->at(i).c_str());
+ if ((char*)fb->lname->at(i).c_str() != NULL)
+ psr.lastName.t = _A2T((char*)fb->lname->at(i).c_str());
+ ProtoBroadcastAck(protocolname, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)& psr);
+ }
- //wenn die uid die gleiche wie die eigene ist, dann avatar auch selbst zuweisen
- if (buddyinfo->userid == this->myuid) {
- ProcessBuddyInfo(buddyinfo, NULL, "myxfireavatar");
+ 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);
- if (entry)
- ProcessBuddyInfo(buddyinfo, entry->hcontact, (char*)entry->username.c_str());
+ //wenn die uid die gleiche wie die eigene ist, dann avatar auch selbst zuweisen
+ if (buddyinfo->userid == this->myuid) {
+ ProcessBuddyInfo(buddyinfo, NULL, "myxfireavatar");
+ }
- break;
- }
+ 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, _countof(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);
+ ClanInvitationPacket *claninv = (ClanInvitationPacket*)content;
+ for (int i = 0; i < claninv->numberOfInv; i++) {
+ char msg[XFIRE_MAX_STATIC_STRING_LEN];
+ mir_snprintf(msg, _countof(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;
}
- 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);
+ {
+ 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;
}
- break;
- }
case XFIRE_RECVREMOVEBUDDYPACKET:
- {
- RecvRemoveBuddyPacket *remove = (RecvRemoveBuddyPacket*)content;
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)remove->handle, 1);
- break;
- }
+ {
+ 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]);
+ //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;
- }
- sendonrecieve = FALSE;
- /* GetBuddyInfo buddyinfo;
+ /* GetBuddyInfo buddyinfo;
- vector<BuddyListEntry*> *entries = client->getBuddyList()->getEntries();
- for(uint i = 0 ; i < entries->size() ; i ++) {
- BuddyListEntry *entry = entries->at(i);
- handlingBuddys(entry,0,NULL);
- }*/
- break;
- }
+ 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();
@@ -500,29 +497,27 @@ void XFireClient::receivedPacket(XFirePacket *packet) { 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);
+ {
+ 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;
}
- break;
- }
/*case XFIRE_BUDDYS_ONLINE_ID:
{
for(uint i = 0 ; i < ((BuddyListOnlinePacket*)content)->userids->size() ; i++) {
@@ -546,157 +541,143 @@ void XFireClient::receivedPacket(XFirePacket *packet) { 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 * > ;
+ 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);
}
- //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;
}
- //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);
+ 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;
}
- 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);
+ 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;
}
- 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, _countof(temp), "Clan_%d", clan->clanid[i]);
- db_set_s(NULL, protocolname, temp, (char*)clan->name[i].c_str());
+ char temp[100];
+ XFireClanPacket *clan = (XFireClanPacket*)content;
+
+ for (int i = 0; i < clan->count; i++) {
+ mir_snprintf(temp, _countof(temp), "Clan_%d", clan->clanid[i]);
+ db_set_s(NULL, protocolname, temp, (char*)clan->name[i].c_str());
- mir_snprintf(temp, _countof(temp), "ClanUrl_%d", clan->clanid[i]);
- db_set_s(NULL, protocolname, temp, (char*)clan->url[i].c_str());
+ mir_snprintf(temp, _countof(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");
+ if (!db_get_b(NULL, protocolname, "noclangroups", 0)) {
+ CreateGroup((char*)clan->name[i].c_str(), "mainclangroup");
+ }
}
+ break;
}
- 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;
- }
+ {
+ 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, _countof(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);
+ 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, _countof(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);
+ }
+ else {
+ SetStatus(ID_STATUS_RECONNECT, NULL);
+ return;
+ }
}
- else
- {
- SetStatus(ID_STATUS_RECONNECT, NULL);
- return;
+ else {
+ mir_snprintf(temp, _countof(temp), Translate("The protocol version is too old. Cannot detect a new version number."));
+ MSGBOXE(temp);
+ SetStatus(ID_STATUS_OFFLINE, NULL);
}
+ break;
}
- else
- {
- mir_snprintf(temp, _countof(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."));
@@ -705,36 +686,35 @@ void XFireClient::receivedPacket(XFirePacket *packet) { //ne nachricht für mich, juhu
case XFIRE_MESSAGE_ID: {
- string str;
+ 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();
- CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, PROTOTYPE_CONTACTTYPING_OFF);
+ CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)entry->hcontact, PROTOTYPE_CONTACTTYPING_OFF);
- PROTORECVEVENT pre = { 0 };
- pre.timestamp = time(NULL);
- pre.szMessage = (char*)str.c_str();
- ProtoChainRecvMsg(entry->hcontact, &pre);
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = time(NULL);
+ pre.szMessage = (char*)str.c_str();
+ 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);
}
- }
- 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;
- }
+ 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);*/
}
//
@@ -785,7 +765,7 @@ void __stdcall XFireLog(const char* fmt, ...) // WINAPI DllMain
//=====================================================
-BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
{
hinstance = hinst;
//AtlAxWinInit();
@@ -793,7 +773,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) }
//suche nach ini und danach starte gamedetection thread
-void StartIniUpdateAndDetection(LPVOID dummy)
+void StartIniUpdateAndDetection(LPVOID)
{
mir_cslock lck(connectingMutex);
@@ -811,35 +791,31 @@ void StartIniUpdateAndDetection(LPVOID dummy) #endif
}
-INT_PTR UrlCall(WPARAM wparam, LPARAM lparam) {
+INT_PTR UrlCall(WPARAM, LPARAM lparam)
+{
//lparam!=0?
if (lparam) {
//nach dem doppelpunkt suchen
char*type = strchr((char*)lparam, ':');
//gefunden, dann anch fragezeichen suchen
- if (type)
- {
+ if (type) {
type++;
char*q = strchr(type, '?');
//gefunden? dann urltype ausschneiden
- if (q)
- {
+ if (q) {
//abschneiden
*q = 0;
//ein addfriend url request?
- if (mir_strcmp("add_friend", type) == 0)
- {
+ if (mir_strcmp("add_friend", type) == 0) {
q++;
//nach = suchen
char*g = strchr(q, '=');
//gefunden? dann abschneiden
- if (g)
- {
+ if (g) {
*g = 0;
g++;
//user parameter?
- if (mir_strcmp("user", q) == 0)
- {
+ if (mir_strcmp("user", q) == 0) {
//tempbuffer für die frage and en user
char temp[100];
@@ -848,12 +824,9 @@ INT_PTR UrlCall(WPARAM wparam, LPARAM lparam) { mir_snprintf(temp, _countof(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->client->connected)
- {
+ if (MessageBoxA(NULL, temp, Translate(PLUGIN_TITLE), MB_YESNO | MB_ICONQUESTION) == IDYES) {
+ if (myClient != NULL) {
+ if (myClient->client->connected) {
InviteBuddyPacket invite;
invite.addInviteName(g, Translate("Add me to your friend list."));
myClient->client->send(&invite);
@@ -875,7 +848,7 @@ INT_PTR UrlCall(WPARAM wparam, LPARAM lparam) { }
//wenn alle module geladen sind
-static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam)
+static int OnSystemModulesLoaded(WPARAM, LPARAM)
{
/*NETLIB***********************************/
NETLIBUSER nlu;
@@ -944,8 +917,7 @@ static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam) }
//File Association Manager support
- if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
- {
+ if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
AssocMgr_AddNewUrlType("xfire:", Translate("Xfire Link Protocol"), hinstance, IDI_TM, XFIRE_URLCALL, 0);
}
@@ -968,29 +940,14 @@ static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam) // Called when plugin is loaded into Miranda
//=====================================================
-/*placebo funktionen*/
-/*PROTO_INTERFACE* xfireProtoInit( const char* pszProtoName, const TCHAR* tszUserName )
-{
-Xfire_m8 m8=new Xfire_m8();
-return m8;
-}
-/*placebo funktionen*/
-/*static int xfireProtoUninit( void* ppro )
-{
-return 0;
-}
-
-*/
-
-int ExtraListRebuild(WPARAM wparam, LPARAM lparam)
+int ExtraListRebuild(WPARAM, LPARAM)
{
//für alle gameicons ein neues handle setzen
return xgamelist.iconmngr.resetIconHandles();
}
-int ExtraImageApply1(WPARAM wparam, LPARAM lparam)
+int ExtraImageApply1(WPARAM hContact, LPARAM)
{
- MCONTACT hContact = (MCONTACT)wparam;
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !mir_strcmpi(szProto, protocolname) && db_get_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
int gameid = db_get_w(hContact, protocolname, "GameId", 0);
@@ -1000,9 +957,8 @@ int ExtraImageApply1(WPARAM wparam, LPARAM lparam) return 0;
}
-int ExtraImageApply2(WPARAM wparam, LPARAM lparam)
+int ExtraImageApply2(WPARAM hContact, LPARAM)
{
- MCONTACT hContact = (MCONTACT)wparam;
// TODO: maybe need to fix extra icons
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !mir_strcmpi(szProto, protocolname) && db_get_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
@@ -1022,8 +978,7 @@ 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);
@@ -1032,8 +987,7 @@ extern "C" __declspec(dllexport) int Load(void) 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)
- {
+ 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);
}
@@ -1093,8 +1047,8 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)CurProfileF);
int i;
- for (i = MAX_PATH-1; i > 5; i--){
- if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.'){
+ for (i = MAX_PATH - 1; i > 5; i--) {
+ if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.') {
i -= 3;
break;
}
@@ -1214,8 +1168,7 @@ extern "C" __declspec(dllexport) int Load(void) 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);
XFireLog("Wasn't able to get GetExtendedUdpTable function");
@@ -1231,13 +1184,11 @@ extern "C" __declspec(dllexport) int Load(void) //funktion liefert für xstatusid den passenden ico zurück, für tipper zb notwendig
INT_PTR GetXStatusIcon(WPARAM wParam, LPARAM lParam)
{
- if (lParam == LR_SHARED)
- {
+ if (lParam == LR_SHARED) {
if (wParam > 1)
return (INT_PTR)xgamelist.iconmngr.getGameIconFromId(wParam - 2); //icocache[(int)wParam-2].hicon;
}
- else
- {
+ else {
if (wParam > 1)
return (INT_PTR)CopyIcon((HICON)xgamelist.iconmngr.getGameIconFromId(wParam - 2)/*icocache[(int)wParam-2].hicon*/);
}
@@ -1259,8 +1210,7 @@ INT_PTR RecvMessage(WPARAM wParam, LPARAM lParam) static void SetMeAFK(LPVOID param)
{
- if (bpStatus == ID_STATUS_ONLINE)
- {
+ if (bpStatus == ID_STATUS_ONLINE) {
SetStatus(ID_STATUS_AWAY, (LPARAM)param);
}
}
@@ -1268,8 +1218,7 @@ static void SetMeAFK(LPVOID param) static void SetStatusLate(LPVOID param)
{
Sleep(1000);
- if (bpStatus == ID_STATUS_OFFLINE)
- {
+ if (bpStatus == ID_STATUS_OFFLINE) {
SetStatus((WPARAM)param, 0);
}
}
@@ -1288,56 +1237,50 @@ static INT_PTR UserIsTyping(WPARAM hContact, LPARAM lParam) {
DBVARIANT dbv;
- if (lParam == PROTOTYPE_SELFTYPING_ON)
- {
- if (db_get_b(NULL, protocolname, "sendtyping", 1) == 1)
- {
+ if (lParam == PROTOTYPE_SELFTYPING_ON) {
+ if (db_get_b(NULL, protocolname, "sendtyping", 1) == 1) {
if (myClient != NULL)
if (myClient->client->connected)
- if (!db_get_s(hContact, protocolname, "Username", &dbv))
- {
- SendTypingPacket typing;
- typing.init(myClient->client, dbv.pszVal);
- myClient->client->send(&typing);
- db_free(&dbv);
+ if (!db_get_s(hContact, protocolname, "Username", &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) {
}
return 0;
}
-INT_PTR SendMessage(WPARAM wParam, LPARAM lParam)
+INT_PTR SendMessage(WPARAM, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA *)lParam;
- PROTORECVEVENT* pre = (PROTORECVEVENT*)ccs->lParam;
DBVARIANT dbv;
int sended = 0;
- if(db_get_s(ccs->hContact, protocolname, "Username", &dbv))
+ if (db_get_s(ccs->hContact, protocolname, "Username", &dbv))
return 0;
if (myClient != NULL)
- if (myClient->client->connected&&db_get_w(ccs->hContact, protocolname, "Status", -1) != ID_STATUS_OFFLINE)
- {
+ 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;
}
else mir_forkthread(SendBadAck, (void*)ccs->hContact);
- db_free(&dbv);
- return sended;
+ db_free(&dbv);
+ return sended;
}
//=======================================================
-//GetCaps
+// GetCaps
//=======================================================
-INT_PTR GetCaps(WPARAM wParam, LPARAM lParam)
+INT_PTR GetCaps(WPARAM wParam, LPARAM)
{
if (wParam == PFLAGNUM_1)
return PF1_BASICSEARCH | PF1_MODEMSG | PF1_IM/*|PF1_SERVERCLIST*/;
@@ -1357,8 +1300,9 @@ INT_PTR GetCaps(WPARAM wParam, LPARAM lParam) }
//=======================================================
-//GetName (tray icon)
+// GetName (tray icon)
//=======================================================
+
INT_PTR GetName(WPARAM wParam, LPARAM lParam)
{
mir_strncpy((char*)lParam, "XFire", wParam);
@@ -1366,9 +1310,10 @@ INT_PTR GetName(WPARAM wParam, LPARAM lParam) }
//=======================================================
-//TMLoadIcon
+// TMLoadIcon
//=======================================================
-INT_PTR TMLoadIcon(WPARAM wParam, LPARAM lParam)
+
+INT_PTR TMLoadIcon(WPARAM wParam, LPARAM)
{
if (LOWORD(wParam) == PLI_PROTOCOL) {
if (wParam & PLIF_ICOLIB)
@@ -1407,13 +1352,12 @@ static void ConnectingThread(LPVOID params) }
//=======================================================
-//SetStatus
+// SetStatus
//=======================================================
-INT_PTR SetStatus(WPARAM wParam, LPARAM lParam)
-{
- int oldStatus;
- oldStatus = bpStatus;
+INT_PTR SetStatus(WPARAM wParam, LPARAM)
+{
+ int oldStatus = bpStatus;
if (bpStatus == ID_STATUS_CONNECTING)
return 0;
@@ -1427,30 +1371,25 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) if (
(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
{
myClient->Status(statusmessage[0]);
}
- else
- {
+ else {
// the status has been changed to online (maybe run some more code)
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;
}
- 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;
}
- else
- {
+ else {
if (myClient != NULL)
delete myClient;
@@ -1474,8 +1413,7 @@ 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
{
}
@@ -1506,14 +1444,12 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) db_unset(NULL, protocolname, "VServerIP");
db_unset(NULL, protocolname, "ServerIP");
- if (wParam == ID_STATUS_RECONNECT)
- {
+ if (wParam == ID_STATUS_RECONNECT) {
mir_forkthread(SetStatusLate, (LPVOID)oldStatus);
wParam = ID_STATUS_OFFLINE;
}
}
- else
- {
+ else {
// the status has been changed to unknown (maybe run some more code)
}
//broadcast the message
@@ -1525,9 +1461,10 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam) }
//=======================================================
-//GetStatus
+// GetStatus
//=======================================================
-INT_PTR GetStatus(WPARAM wParam, LPARAM lParam)
+
+INT_PTR GetStatus(WPARAM, LPARAM)
{
if (bpStatus == ID_STATUS_ONLINE)
return ID_STATUS_ONLINE;
@@ -1574,24 +1511,21 @@ MCONTACT CList_AddContact(XFireContact xfc, bool InList, bool SetOnline, int cla 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, "specialavatarload", 0))
- {
+ if (db_get_b(NULL, protocolname, "noavatars", -1) == 0) {
+ if (!db_get_b(NULL, protocolname, "specialavatarload", 0)) {
XFire_SetAvatar* xsa = new XFire_SetAvatar;
xsa->hContact = hContact;
xsa->username = new char[mir_strlen(xfc.username) + 1];
mir_strcpy(xsa->username, xfc.username);
mir_forkthread(SetAvatar, (LPVOID)xsa);
}
- else
- {
+ else {
/*
- scheinbar unterpricht xfire bei zu agressiven nachfragen der buddyinfos die verbindung , deshalb erstmal auskommentiert
- getestet mit clanbuddy's >270 members
+ 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 = xfc.id;
mir_forkthread(SetAvatar2, (LPVOID)buddyinfo);
@@ -1650,8 +1584,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");
db_unset(hContact, "ContactPhoto", "Backup");
@@ -1660,15 +1593,12 @@ void CList_MakeAllOffline() db_unset(hContact, "ContactPhoto", "XFireAvatarId");
db_unset(hContact, "ContactPhoto", "XFireAvatarMode");
}
- else
- {
+ else {
//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)
- {
+ if (f == NULL) {
db_unset(hContact, "ContactPhoto", "File");
db_unset(hContact, "ContactPhoto", "RFile");
db_unset(hContact, "ContactPhoto", "Backup");
@@ -1690,14 +1620,14 @@ void CList_MakeAllOffline() CallService(MS_DB_CONTACT_DELETE, (WPARAM)fhandles.at(i), 0);
}
-void SetAvatar2(void *arg) {
+void SetAvatar2(void *arg)
+{
static int lasttime = 0;
int sleep = db_get_w(NULL, protocolname, "avatarloadlatency", 1000);
lasttime += sleep;
GetBuddyInfo *buddyinfo = (GetBuddyInfo*)arg;
- if (mySleep(lasttime, hConnectionClose))
- {
+ if (mySleep(lasttime, hConnectionClose)) {
delete buddyinfo;
lasttime -= sleep;
return;
@@ -1723,8 +1653,7 @@ void SetAvatar(void *arg) XFire_SetAvatar* xsa = (XFire_SetAvatar*)arg;
lasttime += sleep;
//Sleep(lasttime);
- if (mySleep(lasttime, hConnectionClose))
- {
+ if (mySleep(lasttime, hConnectionClose)) {
delete xsa;
lasttime -= sleep;
return;
@@ -1778,13 +1707,11 @@ BOOL GetAvatar(char* username, XFireAvatar* av) return FALSE;
}
//keine daten für mich
- else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL)
- {
+ else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) {
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
return FALSE;
}
- else
- {
+ else {
//fwrite(nlhrReply->pData,nlhrReply->dataLength,1,f);
//id wo angefangen wird, die adresse "rauszuschneiden"
@@ -1796,10 +1723,8 @@ BOOL GetAvatar(char* username, XFireAvatar* av) //status ob gefunden oder nich
BOOL found = FALSE;
- while (pointer < deathend&&*pointer_av != 0)
- {
- if (*pointer_av == *pointer)
- {
+ while (pointer < deathend&&*pointer_av != 0) {
+ if (*pointer_av == *pointer) {
pointer_av++;
if (pointer_av - avatarid > 4)
found = TRUE;
@@ -1810,23 +1735,20 @@ BOOL GetAvatar(char* username, XFireAvatar* av) 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, ' ');
- if (pos)
- {
+ if (pos) {
pos--;
*pos = 0;
//analysieren, welchent typ das bild hat
pos = strrchr(pointer, '.');
- if (pos)
- {
+ if (pos) {
char filename[512];
mir_strcpy(filename, XFireGetFoldersPath("Avatar"));
mir_strcat(filename, username);
@@ -1835,8 +1757,7 @@ BOOL GetAvatar(char* username, XFireAvatar* av) //gif?!?!
if (*pos == 'g'&&
*(pos + 1) == 'i'&&
- *(pos + 2) == 'f')
- {
+ *(pos + 2) == 'f') {
av->type = PA_FORMAT_GIF;
mir_strcat(filename, ".gif");
}
@@ -1847,8 +1768,7 @@ BOOL GetAvatar(char* username, XFireAvatar* av) }
//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 :)
}
@@ -1862,7 +1782,7 @@ BOOL GetAvatar(char* username, XFireAvatar* av) return status;
}
-static INT_PTR GetIPPort(WPARAM hContact, LPARAM lParam)
+static INT_PTR GetIPPort(WPARAM hContact, LPARAM)
{
if (db_get_w(hContact, protocolname, "Port", -1) == 0)
return 0;
@@ -1890,7 +1810,7 @@ static INT_PTR GetIPPort(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR GetVIPPort(WPARAM hContact, LPARAM lParam)
+static INT_PTR GetVIPPort(WPARAM hContact, LPARAM)
{
if (db_get_w(hContact, protocolname, "VPort", -1) == 0)
return 0;
@@ -1918,7 +1838,7 @@ static INT_PTR GetVIPPort(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR GotoProfile(WPARAM hContact, LPARAM lParam)
+static INT_PTR GotoProfile(WPARAM hContact, LPARAM)
{
DBVARIANT dbv;
if (db_get_s(hContact, protocolname, "Username", &dbv))
@@ -1933,7 +1853,7 @@ static INT_PTR GotoProfile(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR GotoXFireClanSite(WPARAM hContact, LPARAM lParam)
+static INT_PTR GotoXFireClanSite(WPARAM hContact, LPARAM)
{
DBVARIANT dbv;
char temp[64] = "";
@@ -1952,7 +1872,7 @@ static INT_PTR GotoXFireClanSite(WPARAM hContact, LPARAM lParam) return 0;
}
-static INT_PTR GotoProfile2(WPARAM wParam, LPARAM lParam)
+static INT_PTR GotoProfile2(WPARAM, LPARAM)
{
DBVARIANT dbv;
if (db_get_s(NULL, protocolname, "login", &dbv))
@@ -1967,7 +1887,7 @@ static INT_PTR GotoProfile2(WPARAM wParam, LPARAM lParam) return 0;
}
-static INT_PTR GotoProfileAct(WPARAM wParam, LPARAM lParam)
+static INT_PTR GotoProfileAct(WPARAM, LPARAM)
{
DBVARIANT dbv;
char temp[64] = "";
@@ -1983,7 +1903,7 @@ static INT_PTR GotoProfileAct(WPARAM wParam, LPARAM lParam) return 0;
}
-int RebuildContactMenu(WPARAM hContact, LPARAM lParam)
+int RebuildContactMenu(WPARAM hContact, LPARAM)
{
bool bEnabled = true, bEnabled2 = true;
@@ -2043,9 +1963,9 @@ int RebuildContactMenu(WPARAM hContact, LPARAM lParam) //wird beim miranda start ausgeführt, lädt spiele und startet gamedetection
#ifndef NO_PTHREAD
-void *inigamedetectiont(void *ptr)
+void *inigamedetectiont(void*)
#else
-void inigamedetectiont(LPVOID lParam)
+void inigamedetectiont(void*)
#endif
{
Scan4Games(NULL);
@@ -2059,7 +1979,6 @@ void inigamedetectiont(LPVOID lParam) void SetXFireGameStatusMsg(Xfire_game* game)
{
- char inipath[XFIRE_MAX_STATIC_STRING_LEN] = "";
static char statusmsg[100] = "";
//kein gameobject, dann abbrechen
@@ -2077,23 +1996,19 @@ void SetXFireGameStatusMsg(Xfire_game* game) }
#ifndef NO_PTHREAD
-void *gamedetectiont(void *ptr)
+void *gamedetectiont(void*)
#else
-void gamedetectiont(LPVOID lparam)
+void gamedetectiont(void*)
#endif
{
DWORD ec; //exitcode der processid
- 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;
//vaiable zum spielzeit messen
- time_t t1;
-
+ time_t t1 = time(NULL);
if (db_get_b(NULL, protocolname, "nogamedetect", 0))
#ifndef NO_PTHREAD
@@ -2106,12 +2021,10 @@ void gamedetectiont(LPVOID lparam) //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;
#else
@@ -2127,158 +2040,32 @@ void gamedetectiont(LPVOID lparam) #endif
if (myClient != NULL)
- if (!myClient->client->connected)
- {
- //XFireLog("PID und TSPID resett...","");
- ts2pid = pid = 0;
- //voicechat internen status zurücksetzen
- voicechat.resetCurrentvoicestatus();
+ if (!myClient->client->connected) {
+ //XFireLog("PID und TSPID resett...","");
+ ts2pid = pid = 0;
+ //voicechat internen status zurücksetzen
+ voicechat.resetCurrentvoicestatus();
}
/*
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);
}
}
delete packet;
-
- //nach ts3 mapfile suchen
- //HANDLE hMapObject = OpenFileMappingA(FILE_MAP_READ, FALSE, "$ts3info4xfire$");
- //if (hMapObject) {
- //}
- //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);
-
- if (packet->ip[3]!=0)
- {
- mir_snprintf(temp, _countof(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;
-
- }
- 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 (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);
-
- mir_snprintf(temp, _countof(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 (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);
-
- mir_snprintf(temp, _countof(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)
- {
-
- //XFireLog("XFire Gamedetection - Game still running...","");
-
- //prüf ob das spiel noch offen
+ if (currentgame != NULL) {
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
- if (!xgamelist.isValidPid(pid))
- {
- //XFireLog("XFire Gamedetection - Game was closed ID: %i",currentgame);
+ if (!xgamelist.isValidPid(pid)) {
SendGameStatusPacket *packet = new SendGameStatusPacket();
packet->gameid = 0;
if (db_get_b(NULL, protocolname, "sendgamestatus", 1))
@@ -2291,8 +2078,7 @@ void gamedetectiont(LPVOID lparam) tm * mytm = gmtime(&t3);
//statusmsg von xfire zurücksetzen
- if (currentgame->setstatusmsg)
- {
+ if (currentgame->setstatusmsg) {
if (myClient != NULL)
if (myClient->client->connected)
if (bpStatus == ID_STATUS_ONLINE)
@@ -2312,20 +2098,17 @@ void gamedetectiont(LPVOID lparam) //popup wieder aktivieren, menuservice funk aufrufen, nur wenn popups vorher abgestellt wurden
if (disabledpopups)
- if (db_get_b(NULL, protocolname, "nopopups", 0))
- {
- if (ServiceExists("Popup/EnableDisableMenuCommand"))
- {
- CallService("Popup/EnableDisableMenuCommand", NULL, NULL);
- }
- disabledpopups = FALSE;
+ if (db_get_b(NULL, protocolname, "nopopups", 0)) {
+ 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))
- {
- db_set_b(NULL, "Skin", "UseSound", 1);
- disabledsound = FALSE;
+ if (db_get_b(NULL, protocolname, "nosoundev", 0)) {
+ db_set_b(NULL, "Skin", "UseSound", 1);
+ disabledsound = FALSE;
}
//bug beseitigt, wenn spiel beendet, alte ip entfernen
@@ -2344,38 +2127,35 @@ 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)
- {
- 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))
- {
-
- if (packet->ip[3] != 0)
- {
- mir_snprintf(temp, _countof(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);
+ if (currentgame->networkparams != NULL&¤tgame->send_gameid > 0) {
+ 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)) {
+
+ if (packet->ip[3] != 0) {
+ mir_snprintf(temp, _countof(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);
+
+ if (currentgame->noicqstatus != TRUE&&db_get_b(NULL, protocolname, "autosetstatusmsg", 0))
+ SetGameStatusMsg();
}
else {
- db_unset(NULL, protocolname, "ServerIP");
- XFireLog("NO IPPort", "");
+ XFireLog("GetServerIPPort failed", "");
}
-
- 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;
+ delete packet;
}
//XFireLog("fertig...","");
//packet->=xf[currentgame].gameid2;
@@ -2383,8 +2163,7 @@ void gamedetectiont(LPVOID lparam) //if (op!=NULL) CloseHandle(op);
}
- else
- {
+ else {
//XFireLog("nach spiel suchen...","");
//hardcoded game detection
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
@@ -2397,72 +2176,62 @@ 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)
continue;
Xfire_game* nextgame;
- while (xgamelist.getnextGame(&nextgame))
- {
- if (nextgame->checkpath(processInfo))
- {
+ while (xgamelist.getnextGame(&nextgame)) {
+ if (nextgame->checkpath(processInfo)) {
SendGameStatusPacket *packet = new SendGameStatusPacket();
XFireLog("XFire Gamedetection - Spiel gefunden: %i", nextgame->id);
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))
- {
- 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);
+ 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)) {
+ 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);
+ }
}
- }
- 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);
+ 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) {
+ db_set_b(NULL, "Skin", "UseSound", 0);
+ disabledsound = TRUE;
}
- }
- //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;
@@ -2480,16 +2249,15 @@ void gamedetectiont(LPVOID lparam) }
}
-static INT_PTR ReScanMyGames(WPARAM wParam, LPARAM lParam)
+static INT_PTR ReScanMyGames(WPARAM, LPARAM)
{
db_unset(NULL, protocolname, "foundgames");
mir_forkthread(Scan4Games, NULL);
-
return 0;
}
-static INT_PTR CustomGameSetup(WPARAM wParam, LPARAM lParam)
+static INT_PTR CustomGameSetup(WPARAM, LPARAM)
{
//DialogBox(hinstance,MAKEINTRESOURCE(IDD_GAMELIST),NULL,DlgAddGameProc);
return 0;
@@ -2503,33 +2271,27 @@ void setBuddyStatusMsg(BuddyListEntry *entry) if (IsContactMySelf(entry->username))
return;
- if (entry->game)
- {
+ if (entry->game) {
ostringstream xstatus;
DBVARIANT dbv;
- if (!db_get_s(entry->hcontact, protocolname, "RGame", &dbv))
- {
+ if (!db_get_s(entry->hcontact, protocolname, "RGame", &dbv)) {
xstatus << dbv.pszVal << " ";
db_free(&dbv);
}
- if (!db_get_b(NULL, protocolname, "noipportinstatus", 0))
- {
- if (!db_get_s(entry->hcontact, protocolname, "ServerName", &dbv))
- {
+ if (!db_get_b(NULL, protocolname, "noipportinstatus", 0)) {
+ if (!db_get_s(entry->hcontact, protocolname, "ServerName", &dbv)) {
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);
}
}
db_set_utf(entry->hcontact, protocolname, "XStatusMsg", xstatus.str().c_str());
}
- else
- {
+ else {
//db_set_b(entry->hcontact, protocolname, "XStatusId", 1);
db_unset(entry->hcontact, protocolname, "XStatusId");
db_unset(entry->hcontact, protocolname, "XStatusName");
@@ -2597,18 +2359,15 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc 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)
- {
+ if (entry->hcontact&&clan == -1) {
db_set_w(entry->hcontact, protocolname, "Status", ID_STATUS_ONLINE);
db_set_s(entry->hcontact, protocolname, "MirVer", "xfire");
}
}
- if (entry->hcontact == NULL)
- {
+ if (entry->hcontact == NULL) {
XFireContact xfire_newc;
xfire_newc.username = (char*)entry->username.c_str();
xfire_newc.nick = (char*)entry->nick.c_str();
@@ -2620,8 +2379,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc hContact = entry->hcontact;
- if (hContact != 0)
- {
+ if (hContact != 0) {
if (!entry->nick.empty() && db_get_b(NULL, protocolname, "shownicks", 1)) {
db_set_utf(hContact, protocolname, "Nick", entry->nick.c_str());
}
@@ -2629,8 +2387,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_set_s(hContact, protocolname, "Nick", entry->username.c_str());
}
- if (!entry->isOnline())
- {
+ if (!entry->isOnline()) {
db_set_w(hContact, protocolname, "Status", ID_STATUS_OFFLINE);
db_unset(hContact, protocolname, "XStatusMsg");
db_unset(hContact, protocolname, "XStatusId");
@@ -2647,8 +2404,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_unset(hContact, protocolname, "VoiceId");
db_unset(hContact, protocolname, "GameInfo");
}
- else if (entry->game > 0 || entry->game2 > 0)
- {
+ else if (entry->game > 0 || entry->game2 > 0) {
char temp[XFIRE_MAX_STATIC_STRING_LEN] = "";
char gname[255] = "";
@@ -2658,24 +2414,21 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_set_s(hContact, protocolname, "GameInfo", entry->gameinfo.c_str());
//beim voicechat foglendes machn
- if (entry->game2 > 0)
- {
+ 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 (gameob) {
if ((unsigned char)gameob->ip[3] != 0) // wenn ip, dann speichern
{
mir_snprintf(temp, _countof(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
- {
+ else {
db_unset(hContact, protocolname, "VServerIP");
db_unset(hContact, protocolname, "VPort");
}
@@ -2685,8 +2438,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc ExtraIcon_SetIcon(hExtraIcon2, hContact, xgamelist.iconmngr.getGameIconHandle(entry->game2));
}
- else
- {
+ else {
db_unset(hContact, protocolname, "VServerIP");
db_unset(hContact, protocolname, "VPort");
db_unset(hContact, protocolname, "RVoice");
@@ -2695,8 +2447,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc }
//beim game folgendes machen
- if (entry->game > 0)
- {
+ if (entry->game > 0) {
HICON hicongame = xgamelist.iconmngr.getGameIcon(entry->game);
xgamelist.getGamename(entry->game, gname, 255);
@@ -2719,10 +2470,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc entry->nick.c_str())
, gname);
- if (gameob)
- {
- if ((unsigned char)gameob->ip[3] != 0)
- {
+ if (gameob) {
+ if ((unsigned char)gameob->ip[3] != 0) {
mir_snprintf(temp, _countof(temp), Translate("%s is playing %s on server %d.%d.%d.%d:%d."),
//ist ein nick gesetzt?
(entry->nick.length() == 0 ?
@@ -2738,8 +2487,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc POPUP-Filter
Nur Popups anzeigen die noch nicht angezeigt wurden
*/
- if (entry->lastpopup == NULL)
- {
+ if (entry->lastpopup == NULL) {
//größe des popupstrings
int size = mir_strlen(temp) + 1;
//popup darstellen
@@ -2749,10 +2497,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc //string kopieren
strcpy_s(entry->lastpopup, size, temp);
}
- else
- {
- if (mir_strcmp(entry->lastpopup, temp) != 0)
- {
+ else {
+ if (mir_strcmp(entry->lastpopup, temp) != 0) {
delete[] entry->lastpopup;
entry->lastpopup = NULL;
@@ -2768,10 +2514,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc }
}
- if (gameob)
- {
- if ((unsigned char)gameob->ip[3] != 0)
- {
+ if (gameob) {
+ if ((unsigned char)gameob->ip[3] != 0) {
//ip und port in kontakt speichern
mir_snprintf(temp, _countof(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);
@@ -2779,17 +2523,15 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc //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;
- strncpy(gsqq.ip, temp, _countof(gsqq.ip)-1);
- CallService("GameServerQuery/Query", (WPARAM)entry, (LPARAM)&gsqq);
+ if (ServiceExists("GameServerQuery/Query") && db_get_b(NULL, protocolname, "gsqsupport", 0)) {
+ GameServerQuery_query gsqq = { 0 };
+ gsqq.port = gameob->port;
+ gsqq.xfiregameid = entry->game;
+ strncpy(gsqq.ip, temp, _countof(gsqq.ip) - 1);
+ CallService("GameServerQuery/Query", (WPARAM)entry, (LPARAM)&gsqq);
}
}
- else
- {
+ else {
db_unset(hContact, protocolname, "ServerName");
db_unset(hContact, protocolname, "ServerIP");
db_unset(hContact, protocolname, "Port");
@@ -2810,8 +2552,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_set_w(hContact, protocolname, "GameId", entry->game);
}
- else
- {
+ else {
ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
db_unset(hContact, protocolname, "ServerIP");
db_unset(hContact, protocolname, "Port");
@@ -2823,8 +2564,7 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc setBuddyStatusMsg(entry);
}
}
- else if (!entry->statusmsg.empty())
- {
+ else if (!entry->statusmsg.empty()) {
setBuddyStatusMsg(entry);
ExtraIcon_SetIcon(hExtraIcon1, hContact, INVALID_HANDLE_VALUE);
@@ -2845,10 +2585,8 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_unset(hContact, protocolname, "GameId");
db_unset(hContact, protocolname, "VoiceId");
}
- else
- {
- if (db_get_w(entry->hcontact, protocolname, "Status", -1) == ID_STATUS_OFFLINE)
- {
+ 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
@@ -2876,31 +2614,24 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc db_unset(hContact, protocolname, "VoiceId");
}
}
- if (group != NULL)
- {
- if (!db_get_b(NULL, protocolname, "noclangroups", 0))
- {
- if (clan > 0)
- {
+ if (group != NULL) {
+ if (!db_get_b(NULL, protocolname, "noclangroups", 0)) {
+ if (clan > 0) {
int val = db_get_b(NULL, protocolname, "mainclangroup", 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)
- {
+ ) {
+ if (val == 0) {
db_set_s(entry->hcontact, "CList", "Group", group);
}
- else
- {
+ else {
char temp[256];
DBVARIANT dbv;
mir_snprintf(temp, _countof(temp), "%d", val - 1);
db_get_s(NULL, "CListGroups", temp, &dbv);
- if (dbv.pszVal != NULL)
- {
+ if (dbv.pszVal != NULL) {
mir_snprintf(temp, _countof(temp), "%s\\%s", &dbv.pszVal[1], group);
db_set_s(entry->hcontact, "CList", "Group", temp);
db_free(&dbv);
@@ -2912,18 +2643,15 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc {
int val = db_get_b(NULL, protocolname, "fofgroup", 0);
- if (val == 0)
- {
+ if (val == 0) {
db_set_s(entry->hcontact, "CList", "Group", group);
}
- else
- {
+ else {
char temp[256];
DBVARIANT dbv;
mir_snprintf(temp, _countof(temp), "%d", val - 1);
db_get_s(NULL, "CListGroups", temp, &dbv);
- if (dbv.pszVal != NULL)
- {
+ if (dbv.pszVal != NULL) {
mir_snprintf(temp, _countof(temp), "%s\\%s", &dbv.pszVal[1], group);
db_set_s(entry->hcontact, "CList", "Group", temp);
db_free(&dbv);
@@ -2932,28 +2660,26 @@ MCONTACT handlingBuddys(BuddyListEntry *entry, int clan, char*group, BOOL dontsc }
}
}
- else
- {
+ else {
db_set_b(entry->hcontact, protocolname, "isfriend", 1);
}
return hContact;
}
-INT_PTR AddtoList(WPARAM wParam, LPARAM lParam) {
+INT_PTR AddtoList(WPARAM, LPARAM lParam)
+{
CCSDATA* ccs = (CCSDATA*)lParam;
- if (ccs->hContact)
- {
+ if (ccs->hContact) {
DBVARIANT dbv2;
if (!db_get(ccs->hContact, protocolname, "Username", &dbv2)) {
if (myClient != NULL)
- if (myClient->client->connected)
- {
- SendAcceptInvitationPacket accept;
- accept.name = dbv2.pszVal;
- myClient->client->send(&accept);
+ if (myClient->client->connected) {
+ SendAcceptInvitationPacket accept;
+ accept.name = dbv2.pszVal;
+ myClient->client->send(&accept);
}
//temporären buddy entfernen, da eh ein neues packet kommt
@@ -2967,27 +2693,25 @@ INT_PTR AddtoList(WPARAM wParam, LPARAM lParam) { static void __cdecl AckBasicSearch(void * pszNick)
{
- if (pszNick != NULL)
- {
+ if (pszNick != NULL) {
if (myClient != NULL)
- if (myClient->client->connected)
- {
- SearchBuddy search;
- search.searchfor((char*)pszNick);
- myClient->client->send(&search);
+ if (myClient->client->connected) {
+ SearchBuddy search;
+ search.searchfor((char*)pszNick);
+ myClient->client->send(&search);
}
}
}
-INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam) {
+INT_PTR BasicSearch(WPARAM, LPARAM lParam)
+{
static char buf[50];
if (lParam) {
if (myClient != NULL)
- if (myClient->client->connected)
- {
- mir_strncpy(buf, (const char *)lParam, 49);
- mir_forkthread(AckBasicSearch, &buf);
- return 1;
+ if (myClient->client->connected) {
+ mir_strncpy(buf, (const char *)lParam, 49);
+ mir_forkthread(AckBasicSearch, &buf);
+ return 1;
}
}
@@ -3005,34 +2729,31 @@ INT_PTR SearchAddtoList(WPARAM wParam, LPARAM lParam) if ((int)wParam == 0)
if (myClient != NULL)
- if (myClient->client->connected)
- {
- InviteBuddyPacket invite;
- invite.addInviteName(std::string(_T2A(psr->nick.t)), Translate("Add me to your friend list."));
- myClient->client->send(&invite);
+ if (myClient->client->connected) {
+ InviteBuddyPacket invite;
+ invite.addInviteName(std::string(_T2A(psr->nick.t)), Translate("Add me to your friend list."));
+ myClient->client->send(&invite);
}
return -1;
}
-void CreateGroup(char*grpn, char*field) {
+void CreateGroup(char*grpn, char*field)
+{
DBVARIANT dbv;
char grp[255];
int val = db_get_b(NULL, protocolname, field, 0);
- if (val == 0)
- {
+ if (val == 0) {
strcpy_s(grp, _countof(grp), grpn);//((char*)clan->name[i].c_str());
}
- else
- {
+ else {
char temp[255];
DBVARIANT dbv;
mir_snprintf(temp, _countof(temp), "%d", val - 1);
- if (!db_get_s(NULL, "CListGroups", temp, &dbv))
- {
+ if (!db_get_s(NULL, "CListGroups", temp, &dbv)) {
mir_snprintf(grp, _countof(grp), "%s\\%s", &dbv.pszVal[1], grpn);
db_free(&dbv);
}
@@ -3047,15 +2768,13 @@ void CreateGroup(char*grpn, char*field) { char group[255] = "";
char temp[10];
int i = 0;
- for (i = 0;; i++)
- {
+ for (i = 0;; i++) {
mir_snprintf(temp, _countof(temp), "%d", i);
- if (db_get_s(NULL, "CListGroups", temp, &dbv))
- {
+ if (db_get_s(NULL, "CListGroups", temp, &dbv)) {
i--;
break;
}
- if (dbv.pszVal[0] != '\0' && !mir_strcmp(dbv.pszVal + 1, (char*)grp)) {
+ if (dbv.pszVal[0] != '\0' && !mir_strcmp(dbv.pszVal + 1, (char*)grp)) {
db_free(&dbv);
return;
}
@@ -3102,7 +2821,7 @@ INT_PTR SetAwayMsg(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR SetNickName(WPARAM newnick, LPARAM lparam)
+INT_PTR SetNickName(WPARAM newnick, LPARAM)
{
if (newnick == NULL)
return FALSE;
@@ -3117,7 +2836,7 @@ INT_PTR SetNickName(WPARAM newnick, LPARAM lparam) }
//sendet neue preferencen zu xfire
-INT_PTR SendPrefs(WPARAM wparam, LPARAM lparam)
+INT_PTR SendPrefs(WPARAM, LPARAM)
{
if (myClient != NULL)
if (myClient->client->connected) {
@@ -3131,7 +2850,7 @@ INT_PTR SendPrefs(WPARAM wparam, LPARAM lparam) return FALSE;
}
-int ContactDeleted(WPARAM hContact, LPARAM lParam)
+int ContactDeleted(WPARAM hContact, LPARAM)
{
if (!db_get_b(hContact, protocolname, "DontSendDenyPacket", 0)) {
if (db_get_b(hContact, "CList", "NotOnList", 0)) {
@@ -3150,7 +2869,7 @@ int ContactDeleted(WPARAM hContact, LPARAM lParam) return 0;
}
-INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam)
+INT_PTR StartGame(WPARAM, LPARAM, LPARAM fParam)
{
//gamelist blocken
xgamelist.Block(TRUE);
@@ -3168,11 +2887,11 @@ INT_PTR StartGame(WPARAM wParam, LPARAM lParam, LPARAM fParam) return 0;
}
-INT_PTR RemoveFriend(WPARAM hContact, LPARAM lParam)
+INT_PTR RemoveFriend(WPARAM hContact, 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, _countof(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 (myClient != NULL) {
@@ -3189,7 +2908,7 @@ INT_PTR RemoveFriend(WPARAM hContact, LPARAM lParam) return 0;
}
-INT_PTR BlockFriend(WPARAM hContact, LPARAM lParam)
+INT_PTR BlockFriend(WPARAM hContact, LPARAM)
{
DBVARIANT dbv;
if (!db_get_s(hContact, protocolname, "Username", &dbv)) {
@@ -3210,7 +2929,7 @@ INT_PTR BlockFriend(WPARAM hContact, LPARAM lParam) return 0;
}
-INT_PTR StartThisGame(WPARAM wParam, LPARAM lParam)
+INT_PTR StartThisGame(WPARAM wParam, LPARAM)
{
//gamelist blocken
xgamelist.Block(TRUE);
@@ -3231,7 +2950,7 @@ INT_PTR StartThisGame(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR JoinGame(WPARAM hContact, LPARAM lParam)
+INT_PTR JoinGame(WPARAM hContact, LPARAM)
{
//gamelist blocken
xgamelist.Block(TRUE);
@@ -3274,12 +2993,12 @@ int doneQuery(WPARAM wParam, LPARAM lParam) return 0;
}
-static INT_PTR SetNickDlg(WPARAM wParam, LPARAM lParam)
+static INT_PTR SetNickDlg(WPARAM, LPARAM)
{
return ShowSetNick();
}
-INT_PTR GetAvatarInfo(WPARAM wParam, LPARAM lParam)
+INT_PTR GetAvatarInfo(WPARAM, LPARAM lParam)
{
PROTO_AVATAR_INFORMATION* pai = (PROTO_AVATAR_INFORMATION*)lParam;
diff --git a/protocols/Xfire/src/messageackpacket.cpp b/protocols/Xfire/src/messageackpacket.cpp index 178e2c9717..c797404c50 100644 --- a/protocols/Xfire/src/messageackpacket.cpp +++ b/protocols/Xfire/src/messageackpacket.cpp @@ -28,48 +28,51 @@ #include "variablevalue.h" #include <iostream> -namespace xfirelib { +namespace xfirelib +{ + MessageACKPacket::MessageACKPacket() + { + memset(sid, 0, 16); + imindex = -1; + } - MessageACKPacket::MessageACKPacket() { - memset( sid, 0, 16 ); - imindex = -1; - } - MessageACKPacket::~MessageACKPacket() { - } + MessageACKPacket::~MessageACKPacket() + { + } - int MessageACKPacket::getPacketContent(char *buf) { - int index = 0; - VariableValue val; - val.setName("sid"); - val.setValue(sid,16); + int MessageACKPacket::getPacketContent(char *buf) + { + int index = 0; + VariableValue val; + val.setName("sid"); + val.setValue(sid, 16); - index += val.writeName(buf,index); - buf[index++] = 3; - index += val.writeValue(buf,index); + index += val.writeName(buf, index); + buf[index++] = 3; + index += val.writeValue(buf, index); - val.setName("peermsg"); - index += val.writeName(buf,index); - buf[index++] = 5; - buf[index++] = 2; + val.setName("peermsg"); + index += val.writeName(buf, index); + buf[index++] = 5; + buf[index++] = 2; - val.setName("msgtype"); - val.setValueFromLong(1,4); - index += val.writeName(buf,index); - buf[index++] = 2; - index += val.writeValue(buf,index); + val.setName("msgtype"); + val.setValueFromLong(1, 4); + index += val.writeName(buf, index); + buf[index++] = 2; + index += val.writeValue(buf, index); - val.setName("imindex"); - val.setValueFromLong(imindex,4); - index += val.writeName(buf,index); - buf[index++] = 02; - index += val.writeValue(buf,index); - - return index; - } - - void MessageACKPacket::parseContent(char *buf, int length, int numberOfAtts) { - } + val.setName("imindex"); + val.setValueFromLong(imindex, 4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + return index; + } + void MessageACKPacket::parseContent(char*, int, int) + { + } }; diff --git a/protocols/Xfire/src/messageackpacket.h b/protocols/Xfire/src/messageackpacket.h index 35d0848fbd..a1bbfaaa5a 100644 --- a/protocols/Xfire/src/messageackpacket.h +++ b/protocols/Xfire/src/messageackpacket.h @@ -29,33 +29,28 @@ namespace xfirelib { - /** - * (Internal) Packet used to acknowledge a received message. - * It is of no use to users of the library because it is already - * sent by the Client. - */ - class MessageACKPacket : public XFireSendPacketContent { - public: - MessageACKPacket(); - ~MessageACKPacket(); - - XFirePacketContent* newPacket() { return new MessageACKPacket(); } - - - int getPacketId() { return XFIRE_MESSAGE_ACK_ID; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 2; } - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - - char sid[16]; - long imindex; - - private: - }; - + /** + * (Internal) Packet used to acknowledge a received message. + * It is of no use to users of the library because it is already + * sent by the Client. + */ + class MessageACKPacket : public XFireSendPacketContent { + public: + MessageACKPacket(); + ~MessageACKPacket(); + + XFirePacketContent* newPacket() { return new MessageACKPacket(); } + + int getPacketId() { return XFIRE_MESSAGE_ACK_ID; } + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 2; } + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + + char sid[16]; + long imindex; + }; }; - #endif diff --git a/protocols/Xfire/src/messagepacket.cpp b/protocols/Xfire/src/messagepacket.cpp index e3f4b2b445..3fd0bb7274 100644 --- a/protocols/Xfire/src/messagepacket.cpp +++ b/protocols/Xfire/src/messagepacket.cpp @@ -25,68 +25,70 @@ #include "messagepacket.h" #include "xfireparse.h" #include "variablevalue.h" -#include <iostream> -#include <string> #include "xdebug.h" +using namespace std; -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + MessagePacket::MessagePacket() + { + packetID = 133; + } - MessagePacket::MessagePacket(){ - packetID = 133; - } + int MessagePacket::getPacketContent(char *packet) + { + memcpy(packet, buf, bufLength); + packetID = 2; + return 150; + } -int MessagePacket::getPacketContent(char *packet){ - memcpy(packet,buf,bufLength); - packetID = 2; - return 150; -} - void MessagePacket::parseContent(char *buf, int length, int numberOfAtts) { - - bufLength = length; - XINFO(( "Got IM\n" )); - - int index = 0; - sid = new VariableValue(); - peermsg = new VariableValue(); - msgtype = new VariableValue(); + void MessagePacket::parseContent(char *buf, int length, int) + { + bufLength = length; + XINFO(("Got IM\n")); - index += sid->readName(buf,index); - index++; //ignore 03 - index += sid->readValue(buf,index,16); + int index = 0; + sid = new VariableValue(); + peermsg = new VariableValue(); + msgtype = new VariableValue(); - index += peermsg->readName(buf,index); - index++; - index++; - index += msgtype->readName(buf,index); - index++; - index += msgtype->readValue(buf,index,4); + index += sid->readName(buf, index); + index++; //ignore 03 + index += sid->readValue(buf, index, 16); - if (msgtype->getValue()[0] == 0){ - imindex = new VariableValue(); - index += imindex->readName(buf,index); + index += peermsg->readName(buf, index); + index++; + index++; + index += msgtype->readName(buf, index); + index++; + index += msgtype->readValue(buf, index, 4); - VariableValue messageTemp; - index++;//ignore 02 - index += imindex->readValue(buf,index,4); - index += messageTemp.readName(buf,index); - index++; - index += messageTemp.readValue(buf,index,2); - int messageLength = messageTemp.getValueAsLong(); - index = messageTemp.readValue(buf,index,messageLength); + if (msgtype->getValue()[0] == 0) { + imindex = new VariableValue(); + index += imindex->readName(buf, index); - for(int i = 0; i < messageTemp.getValueLength();i++){ - message += messageTemp.getValue()[i]; - } - /*TODO: implement this and answer the package*/ - }else if (msgtype->getValue()[0] == 1){ - cout << "got ack for a message we have sent" << endl; - }else if (msgtype->getValue()[0] == 2){ - memcpy(this->buf,buf,150); - /*answer the packet*/ - cout << "some auth magic stuff" << length << endl; - } - } + VariableValue messageTemp; + index++;//ignore 02 + index += imindex->readValue(buf, index, 4); + index += messageTemp.readName(buf, index); + index++; + index += messageTemp.readValue(buf, index, 2); + int messageLength = messageTemp.getValueAsLong(); + index = messageTemp.readValue(buf, index, messageLength); + for (int i = 0; i < messageTemp.getValueLength(); i++) { + message += messageTemp.getValue()[i]; + } + /*TODO: implement this and answer the package*/ + } + else if (msgtype->getValue()[0] == 1) { + cout << "got ack for a message we have sent" << endl; + } + else if (msgtype->getValue()[0] == 2) { + memcpy(this->buf, buf, 150); + /*answer the packet*/ + cout << "some auth magic stuff" << length << endl; + } + } }; diff --git a/protocols/Xfire/src/messagepacket.h b/protocols/Xfire/src/messagepacket.h index fe867ef96b..f869161393 100644 --- a/protocols/Xfire/src/messagepacket.h +++ b/protocols/Xfire/src/messagepacket.h @@ -25,39 +25,37 @@ #include "xfirerecvpacketcontent.h" #include "variablevalue.h" -#include <string> #define XFIRE_MESSAGE_ID 133 namespace xfirelib { - class MessagePacket : public XFireRecvPacketContent { - public: - - MessagePacket(); - XFirePacketContent* newPacket() { return new MessagePacket(); } - - int getPacketContent(char *packet); - int getPacketId() { return packetID; } - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - std::string getMessage() {return message; } - int getMessageType(){return msgtype->getValue()[0];} - int getImIndex(){ return imindex->getValue()[0];}//TODO: fix this if we have more than 255 messages - int getPacketAttributeCount(){ return 2; } - char * getSid(){ return sid->getValue(); } - - private: - VariableValue *sid; - VariableValue *peermsg; - VariableValue *msgtype; - VariableValue *imindex; - std::string message; - char buf[150]; - int bufLength; - int packetID;//Special case because we have to answer this packet with id 2 - }; + class MessagePacket : public XFireRecvPacketContent { + public: + + MessagePacket(); + XFirePacketContent* newPacket() { return new MessagePacket(); } + + int getPacketContent(char *packet); + int getPacketId() { return packetID; } + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + std::string getMessage() {return message; } + int getMessageType(){return msgtype->getValue()[0];} + int getImIndex(){ return imindex->getValue()[0];}//TODO: fix this if we have more than 255 messages + int getPacketAttributeCount(){ return 2; } + char * getSid(){ return sid->getValue(); } + + private: + VariableValue *sid; + VariableValue *peermsg; + VariableValue *msgtype; + VariableValue *imindex; + std::string message; + char buf[150]; + int bufLength; + int packetID;//Special case because we have to answer this packet with id 2 + }; }; - #endif diff --git a/protocols/Xfire/src/monitoredobj.cpp b/protocols/Xfire/src/monitoredobj.cpp index 42b00120ae..a5abe3fa78 100644 --- a/protocols/Xfire/src/monitoredobj.cpp +++ b/protocols/Xfire/src/monitoredobj.cpp @@ -24,18 +24,21 @@ //alle string klassen entfernt, da die stringklasse instabil ist - dufte -namespace xfirelib { - int MonitoredObj::id = 0; - MonitoredObj::MonitoredObj() { - this->myid = id++; - } +namespace xfirelib +{ + int MonitoredObj::id = 0; + MonitoredObj::MonitoredObj() + { + this->myid = id++; + } - MonitoredObj::~MonitoredObj() { - } - - int MonitoredObj::getTotalObjectCount() { - int total = 0; - return total; - } + MonitoredObj::~MonitoredObj() + { + } + int MonitoredObj::getTotalObjectCount() + { + int total = 0; + return total; + } }; diff --git a/protocols/Xfire/src/monitoredobj.h b/protocols/Xfire/src/monitoredobj.h index 4e4b2d66f6..7f5a2104f4 100644 --- a/protocols/Xfire/src/monitoredobj.h +++ b/protocols/Xfire/src/monitoredobj.h @@ -24,26 +24,21 @@ #define __MONITOREDOBJ_H #include <typeinfo> -#include <string> #include "xdebug.h" #include <map> namespace xfirelib { - class MonitoredObj { - public: - MonitoredObj(); - ~MonitoredObj(); - int getTotalObjectCount(); - - std::string classname; - int myid; - static std::map<std::string,int> instances; - static int id; - }; - - + class MonitoredObj { + public: + MonitoredObj(); + ~MonitoredObj(); + int getTotalObjectCount(); + + std::string classname; + int myid; + static std::map<std::string,int> instances; + static int id; + }; }; - - #endif diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index 145f49dd2c..fd1a9c9f3c 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -40,7 +40,8 @@ extern HANDLE XFireIconFolder; extern xfire_prefitem xfireconfig[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; extern Xfire_gamelist xgamelist; -struct mytreeitem { +struct mytreeitem +{ TCHAR name[256]; char dbentry[256]; int parent; @@ -54,58 +55,57 @@ HWND ghwndDlg2; HWND addgameDialog = NULL; xfireconfigitem xfireconfigitems[XFIRE_RECVPREFSPACKET_SUPPORTEDONFIGS] = { - { IDC_KONFIG_1, 1, "sendgamestatus" }, - { IDC_KONFIG_2, 3, "hideprofile" }, - { IDC_KONFIG_3, 2, "ipportdetec" }, - { IDC_KONFIG_4, 0xa, "shownicks" }, - { IDC_KONFIG_5, 0xb, "ts2detection" }, - { IDC_KONFIG_6, 0xc, "sendtyping" }, - { IDC_KONFIG_7, 8, "friendsoffriends" }, + { 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 (mir_strlen(szSetting) > 0) - { + if (mir_strlen(szSetting) > 0) { SendDlgItemMessageA((HWND)lParam, IDC_BLOCKUSER, LB_ADDSTRING, 0, (LPARAM)szSetting); } EnableDlgItem((HWND)lParam, IDC_REMUSER, TRUE); @@ -122,110 +122,101 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR static HWND hwndTree = NULL; static char login[128]; - switch (msg) - { + switch (msg) { case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_INITDIALOG: - { - DBVARIANT dbv; - TranslateDialogDefault(hwndDlg); + { + 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); + hwndTree = GetDlgItem(hwndDlg, IDC_TREE); + SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES); + SendMessage(hwndDlg, DM_REBUILD_TREE, 0, 0); - mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN,"%sxfire_games.ini",XFireGetFoldersPath("IniFile")); + mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN, "%sxfire_games.ini", XFireGetFoldersPath("IniFile")); - FILE * f = fopen(inipath, "r"); - if (f != NULL) - { - fclose(f); - CheckDlgButton(hwndDlg, IDC_CHKG, BST_CHECKED); - inifound = TRUE; - } - else - { - EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); - inifound = FALSE; - } - - mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN,"%sicons.dll",XFireGetFoldersPath("IconsFile")); + FILE * f = fopen(inipath, "r"); + if (f != NULL) { + fclose(f); + CheckDlgButton(hwndDlg, IDC_CHKG, BST_CHECKED); + inifound = TRUE; + } + else { + EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); + inifound = FALSE; + } - f = fopen(inipath, "r"); - if (f != NULL) - { - fclose(f); - CheckDlgButton(hwndDlg, IDC_CHKI, BST_CHECKED); - dllfound = TRUE; - } - else - dllfound = FALSE; + mir_snprintf(inipath, XFIRE_MAX_STATIC_STRING_LEN, "%sicons.dll", XFireGetFoldersPath("IconsFile")); - 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); - } + f = fopen(inipath, "r"); + if (f != NULL) { + fclose(f); + CheckDlgButton(hwndDlg, IDC_CHKI, BST_CHECKED); + dllfound = TRUE; + } + else + dllfound = FALSE; - char temp[255] = ""; - mir_snprintf(temp, _countof(temp), "%d", db_get_b(NULL, protocolname, "protover", 0x5b)); - SetDlgItemTextA(hwndDlg, IDC_PVER, temp); + 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); + } - EnableWindow(GetDlgItem(hwndDlg, IDC_LASTGAME), FALSE); - if (!db_get(NULL, protocolname, "LastGame", &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_LASTGAME, dbv.pszVal); - db_free(&dbv); - } + char temp[255] = ""; + mir_snprintf(temp, _countof(temp), "%d", db_get_b(NULL, protocolname, "protover", 0x5b)); + SetDlgItemTextA(hwndDlg, IDC_PVER, temp); - if (bpStatus == ID_STATUS_OFFLINE&&bpStatus != ID_STATUS_CONNECTING) { - EnableDlgItem(hwndDlg, IDC_NICK, FALSE); - } - else - { - int size = sizeof(xfireconfigitems) / sizeof(xfireconfigitem); - for (int i = 0; i < size; i++) - { - EnableDlgItem(hwndDlg, xfireconfigitems[i].id, TRUE); - CheckDlgButton(hwndDlg, xfireconfigitems[i].id, (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset == 0) ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_LASTGAME), FALSE); + if (!db_get(NULL, protocolname, "LastGame", &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_LASTGAME, dbv.pszVal); + db_free(&dbv); } - //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren - if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1)) - { - CheckDlgButton(hwndDlg, IDC_KONFIG_2, BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_KONFIG_3, BST_UNCHECKED); - EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); - EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); + + if (bpStatus == ID_STATUS_OFFLINE&&bpStatus != ID_STATUS_CONNECTING) { + EnableDlgItem(hwndDlg, IDC_NICK, FALSE); + } + else { + int size = sizeof(xfireconfigitems) / sizeof(xfireconfigitem); + for (int i = 0; i < size; i++) { + EnableDlgItem(hwndDlg, xfireconfigitems[i].id, TRUE); + CheckDlgButton(hwndDlg, xfireconfigitems[i].id, (xfireconfig[xfireconfigitems[i].xfireconfigid].wasset == 0) ? BST_CHECKED : BST_UNCHECKED); + } + //wenn die erste option aktiv ist, untere aktivieren, sonst deaktivieren + if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1)) { + CheckDlgButton(hwndDlg, IDC_KONFIG_2, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_KONFIG_3, BST_UNCHECKED); + EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); + EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); + } } - } - return TRUE; - } + return TRUE; + } case WM_COMMAND: - if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1)) - { + if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_KONFIG_1)) { CheckDlgButton(hwndDlg, IDC_KONFIG_2, BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_KONFIG_3, BST_UNCHECKED); EnableDlgItem(hwndDlg, IDC_KONFIG_2, FALSE); EnableDlgItem(hwndDlg, IDC_KONFIG_3, FALSE); } - else - { + else { EnableDlgItem(hwndDlg, IDC_KONFIG_2, TRUE); EnableDlgItem(hwndDlg, IDC_KONFIG_3, TRUE); } @@ -244,161 +235,151 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: { - int reconnectRequired = 0; - char str[128]; - DBVARIANT dbv; - - GetDlgItemTextA(hwndDlg, IDC_LOGIN, login, _countof(login)); - dbv.pszVal = NULL; - if (db_get(NULL, protocolname, "login", &dbv) || mir_strcmp(login, dbv.pszVal)) - reconnectRequired = 1; - if (dbv.pszVal != NULL) - db_free(&dbv); - - //den login lowercasen - int size = mir_strlen(login); - BOOL mustlowercase = FALSE; - for (int i = 0; i < size; i++) - { - if (login[i] >= 'A'&&login[i] <= 'Z') - mustlowercase = TRUE; - login[i] = tolower(login[i]); - } - if (mustlowercase) { - MessageBox(NULL, TranslateT("The username must be lowercase, so it will be lowercased saved."), TranslateT("XFire Options"), MB_OK | MB_ICONINFORMATION); - SetDlgItemTextA(hwndDlg, IDC_LOGIN, login); - } - - db_set_s(NULL, protocolname, "login", login); - db_set_s(NULL, protocolname, "Username", login); - - //nur wenn der nick erfolgreich übertragen wurde - GetDlgItemTextA(hwndDlg, IDC_NICK, login, _countof(login)); - dbv.pszVal = NULL; - if (db_get(NULL, protocolname, "Nick", &dbv) || mir_strcmp(login, dbv.pszVal)) - { - if (CallService(XFIRE_SET_NICK, 0, (WPARAM)login)) - db_set_s(NULL, protocolname, "Nick", login); - } - if (dbv.pszVal != NULL) - db_free(&dbv); + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + int reconnectRequired = 0; + char str[128]; + DBVARIANT dbv; + + GetDlgItemTextA(hwndDlg, IDC_LOGIN, login, _countof(login)); + dbv.pszVal = NULL; + if (db_get(NULL, protocolname, "login", &dbv) || mir_strcmp(login, dbv.pszVal)) + reconnectRequired = 1; + if (dbv.pszVal != NULL) + db_free(&dbv); + + //den login lowercasen + int size = mir_strlen(login); + BOOL mustlowercase = FALSE; + for (int i = 0; i < size; i++) { + if (login[i] >= 'A'&&login[i] <= 'Z') + mustlowercase = TRUE; + login[i] = tolower(login[i]); + } + if (mustlowercase) { + MessageBox(NULL, TranslateT("The username must be lowercase, so it will be lowercased saved."), TranslateT("XFire Options"), MB_OK | MB_ICONINFORMATION); + SetDlgItemTextA(hwndDlg, IDC_LOGIN, login); + } - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(str)); - dbv.pszVal = NULL; - if (db_get(NULL, protocolname, "password", &dbv) || mir_strcmp(str, dbv.pszVal)) - reconnectRequired = 1; - if (dbv.pszVal != NULL) - db_free(&dbv); - db_set_s(NULL, protocolname, "password", str); - GetDlgItemTextA(hwndDlg, IDC_SERVER, str, _countof(str)); + db_set_s(NULL, protocolname, "login", login); + db_set_s(NULL, protocolname, "Username", login); - //neue preferencen sichern - if (bpStatus != ID_STATUS_OFFLINE&&bpStatus != ID_STATUS_CONNECTING) - { - int size = sizeof(xfireconfigitems) / sizeof(xfireconfigitem); - for (int i = 0; i < size; i++) - { - if (!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id)) - { - db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, 0); - xfireconfig[xfireconfigitems[i].xfireconfigid].wasset = 1; - xfireconfig[xfireconfigitems[i].xfireconfigid].data[0] = 1; - xfireconfig[xfireconfigitems[i].xfireconfigid].data[1] = 1; - xfireconfig[xfireconfigitems[i].xfireconfigid].data[2] = 0; - xfireconfig[xfireconfigitems[i].xfireconfigid].data[3] = 0x30; + //nur wenn der nick erfolgreich übertragen wurde + GetDlgItemTextA(hwndDlg, IDC_NICK, login, _countof(login)); + dbv.pszVal = NULL; + if (db_get(NULL, protocolname, "Nick", &dbv) || mir_strcmp(login, dbv.pszVal)) { + if (CallService(XFIRE_SET_NICK, 0, (WPARAM)login)) + db_set_s(NULL, protocolname, "Nick", login); } - else - { - xfireconfig[xfireconfigitems[i].xfireconfigid].wasset = 0; - db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, 1); + if (dbv.pszVal != NULL) + db_free(&dbv); + + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, _countof(str)); + dbv.pszVal = NULL; + if (db_get(NULL, protocolname, "password", &dbv) || mir_strcmp(str, dbv.pszVal)) + reconnectRequired = 1; + if (dbv.pszVal != NULL) + db_free(&dbv); + db_set_s(NULL, protocolname, "password", str); + GetDlgItemTextA(hwndDlg, IDC_SERVER, str, _countof(str)); + + //neue preferencen sichern + if (bpStatus != ID_STATUS_OFFLINE&&bpStatus != ID_STATUS_CONNECTING) { + int size = sizeof(xfireconfigitems) / sizeof(xfireconfigitem); + for (int i = 0; i < size; i++) { + if (!(BYTE)IsDlgButtonChecked(hwndDlg, xfireconfigitems[i].id)) { + db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, 0); + xfireconfig[xfireconfigitems[i].xfireconfigid].wasset = 1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[0] = 1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[1] = 1; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[2] = 0; + xfireconfig[xfireconfigitems[i].xfireconfigid].data[3] = 0x30; + } + else { + xfireconfig[xfireconfigitems[i].xfireconfigid].wasset = 0; + db_set_b(NULL, protocolname, xfireconfigitems[i].dbentry, 1); + } + } + CallService(XFIRE_SEND_PREFS, 0, 0); } - } - CallService(XFIRE_SEND_PREFS, 0, 0); - } - //protocolversion wird autoamtisch vergeben - //GetDlgItemTextA(hwndDlg,IDC_PVER,str,_countof(str)); - //db_set_b(NULL,protocolname,"protover",(char)atoi(str)); + //protocolversion wird autoamtisch vergeben + //GetDlgItemTextA(hwndDlg,IDC_PVER,str,_countof(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] = ""; static BOOL inifound = FALSE; static BOOL dllfound = FALSE; static int nomsgboxsel[] = { 1, 0, 2 }; static HWND hwndTree = NULL; - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); + { + 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_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_NOMSG, CB_SETCURSEL, nomsgboxsel[db_get_b(NULL, protocolname, "nomsgbox", 0)], 0); - /* Gruppen raussuchen */ - { - int gruppen_id = 0; - char temp[8]; - DBVARIANT dbv; + /* 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, _countof(temp), "%d", gruppen_id); - while (!db_get_s(NULL, "CListGroups", temp, &dbv)) - { - gruppen_id++; mir_snprintf(temp, _countof(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); + while (!db_get_s(NULL, "CListGroups", temp, &dbv)) { + gruppen_id++; + mir_snprintf(temp, _countof(temp), "%d", gruppen_id); + + if (dbv.pszVal != NULL) { + SendDlgItemMessageA(hwndDlg, IDC_CLANGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); + SendDlgItemMessageA(hwndDlg, IDC_FOFGROUP, CB_ADDSTRING, 0, (LPARAM)&dbv.pszVal[1]); + db_free(&dbv); + } } + SendDlgItemMessage(hwndDlg, IDC_CLANGROUP, CB_SETCURSEL, db_get_b(NULL, protocolname, "mainclangroup", 0), 0); + SendDlgItemMessage(hwndDlg, IDC_FOFGROUP, CB_SETCURSEL, db_get_b(NULL, protocolname, "fofgroup", 0), 0); } - 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: //baue optionsmenü auf @@ -416,8 +397,7 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR 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; @@ -433,8 +413,7 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR tvis.item.state = INDEXTOSTATEIMAGEMASK(0); TreeView_SetItem(hwndTree, &tvis.item); } - else - { + else { tvis.item.stateMask = TVIS_STATEIMAGEMASK; tvis.item.state = INDEXTOSTATEIMAGEMASK(db_get_b(NULL, protocolname, mytree[i].dbentry, 0) == 1 ? 2 : 1); tvis.item.lParam = 0; @@ -469,8 +448,7 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR CheckDlgButton(hwndDlg, IDC_CHKI, dllfound ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHKG, inifound ? BST_CHECKED : BST_UNCHECKED); - if (HIWORD(wParam) == CBN_SELCHANGE) - { + if (HIWORD(wParam) == CBN_SELCHANGE) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); return 0; } @@ -481,78 +459,74 @@ static INT_PTR CALLBACK DlgProcOpts3(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) - { + switch (((LPNMHDR)lParam)->idFrom) { case IDC_TREE: - { - switch (((NMHDR*)lParam)->code) { //wenn was geändert wurde, apply aktivieren - case TVN_SELCHANGED: - 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)) + switch (((NMHDR*)lParam)->code) { //wenn was geändert wurde, apply aktivieren + case TVN_SELCHANGED: 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; - } + break; + + case TVN_KEYDOWN: //tastatursteuerung + { + NMTVKEYDOWN* ptkd = (NMTVKEYDOWN*)lParam; + if (ptkd&&ptkd->wVKey == VK_SPACE&&TreeView_GetSelection(ptkd->hdr.hwndFrom)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + case NM_CLICK: //wenn was geklickt wurde, apply aktivieren + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) + if (hti.flags&TVHT_ONITEM) + if (hti.flags&TVHT_ONITEMSTATEICON) + if (TreeView_GetParent(hwndTree, hti.hItem) != NULL) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + } } - } - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - int ccc; + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + 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; + //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); - } - } + 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); - return TRUE; - } + return TRUE; + } + } + break; } - break; - } } return FALSE; } @@ -565,60 +539,56 @@ static INT_PTR CALLBACK DlgProcOpts4(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR static int nomsgboxsel[] = { 1, 0, 2 }; static HWND hwndTree = NULL; - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { - //addgamedia auf 0 setzen - TranslateDialogDefault(hwndDlg); + { + //addgamedia auf 0 setzen + TranslateDialogDefault(hwndDlg); - mir_strcpy(inipath, XFireGetFoldersPath("IniFile")); - mir_strcat(inipath, "xfire_games.ini"); + mir_strcpy(inipath, XFireGetFoldersPath("IniFile")); + mir_strcat(inipath, "xfire_games.ini"); - FILE * f = fopen(inipath, "r"); - if (f != NULL) - { - fclose(f); - CheckDlgButton(hwndDlg, IDC_CHKG, BST_CHECKED); - inifound = TRUE; - } - else - { - EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); - inifound = FALSE; - } + FILE * f = fopen(inipath, "r"); + if (f != NULL) { + fclose(f); + CheckDlgButton(hwndDlg, IDC_CHKG, BST_CHECKED); + inifound = TRUE; + } + else { + EnableDlgItem(hwndDlg, IDC_SETUPGAMES, FALSE); + inifound = FALSE; + } - mir_strcpy(inipath, XFireGetFoldersPath("IconsFile")); - mir_strcat(inipath, "icons.dll"); + mir_strcpy(inipath, XFireGetFoldersPath("IconsFile")); + mir_strcat(inipath, "icons.dll"); - f = fopen(inipath, "r"); - if (f != NULL) - { - fclose(f); - CheckDlgButton(hwndDlg, IDC_CHKI, BST_CHECKED); - dllfound = TRUE; - } - else - dllfound = FALSE; + f = fopen(inipath, "r"); + if (f != NULL) { + fclose(f); + CheckDlgButton(hwndDlg, IDC_CHKI, BST_CHECKED); + 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); - SendDlgItemMessage(hwndDlg, IDC_REMUSER, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE)); + SendDlgItemMessage(hwndDlg, IDC_REMUSER, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE)); - mir_strcpy(inipath, XFireGetFoldersPath("IniFile")); - SetDlgItemTextA(hwndDlg, IDC_FILESSHOULDBE, inipath); + mir_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); @@ -649,17 +619,16 @@ static INT_PTR CALLBACK DlgProcOpts4(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - { - return TRUE; - } + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + return TRUE; + } + } + break; } - break; - } } return FALSE; } @@ -668,60 +637,51 @@ static INT_PTR CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { DBVARIANT dbv; - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - CheckDlgButton(hwndDlg, IDC_ENABLESTSMSG, db_get_b(NULL, protocolname, "autosetstatusmsg", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_CHGSTATUS, db_get_b(NULL, protocolname, "statuschgtype", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DNDFIRST, db_get_b(NULL, protocolname, "dndfirst", 0) ? BST_CHECKED : BST_UNCHECKED); - if (!db_get(NULL, protocolname, "setstatusmsg", &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, dbv.pszVal); - db_free(&dbv); - } - if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)) { - EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); - } - /* if (!ServiceExists(MS_VARS_FORMATSTRING)) - { - EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); - EnableDlgItem(hwndDlg, IDC_ENABLESTSMSG, FALSE); - EnableDlgItem(hwndDlg, IDC_CHGSTATUS, FALSE); - EnableDlgItem(hwndDlg, IDC_DNDFIRST, FALSE); - }*/ + TranslateDialogDefault(hwndDlg); - return TRUE; - } + CheckDlgButton(hwndDlg, IDC_ENABLESTSMSG, db_get_b(NULL, protocolname, "autosetstatusmsg", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_CHGSTATUS, db_get_b(NULL, protocolname, "statuschgtype", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DNDFIRST, db_get_b(NULL, protocolname, "dndfirst", 0) ? BST_CHECKED : BST_UNCHECKED); + if (!db_get(NULL, protocolname, "setstatusmsg", &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, dbv.pszVal); + db_free(&dbv); + } + if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)) { + EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); + } + /* if (!ServiceExists(MS_VARS_FORMATSTRING)) + { + EnableDlgItem(hwndDlg, IDC_STATUSMSG, FALSE); + EnableDlgItem(hwndDlg, IDC_ENABLESTSMSG, FALSE); + EnableDlgItem(hwndDlg, IDC_CHGSTATUS, FALSE); + EnableDlgItem(hwndDlg, IDC_DNDFIRST, FALSE); + }*/ + + return TRUE; + } case PSM_CHANGED: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_COMMAND: - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLESTSMSG)) { + 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); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - { - int reconnectRequired = 0; char str[512]; GetDlgItemTextA(hwndDlg, IDC_STATUSMSG, str, _countof(str)); @@ -733,20 +693,15 @@ static INT_PTR CALLBACK DlgProcOpts5(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE; } - - } break; } - } return FALSE; } -static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM) { - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { addgameDialog = NULL; TranslateDialogDefault(hwndDlg); @@ -761,36 +716,31 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR //gamelist füllen SendMessage(hwndDlg, WM_FILLGAMELIST, 0, 0); - - //SendDlgItemMessage(hwndDlg, IDC_CREATETXTLIST), BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_USERDETAILS)); - return TRUE; - } + case WM_FILLGAMELIST: - { //spielliste leeren SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_RESETCONTENT, 0, 0); - //spiele auslesen und in die liste einfügen - int found = db_get_w(NULL, protocolname, "foundgames", 0); - char temp[XFIRE_MAXSIZEOFGAMENAME]; - for (int i = 0; i < found; i++) { - //id auslesen - mir_snprintf(temp, _countof(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); + //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, _countof(temp), "gameid_%d", i); + int gameid = db_get_w(NULL, protocolname, temp, 0); + //spielnamen auslesen + xgamelist.getGamename(gameid, temp, XFIRE_MAXSIZEOFGAMENAME); + //eintrag einfügen + int idx = SendDlgItemMessageA((HWND)hwndDlg, IDC_LGAMELIST, LB_ADDSTRING, 0, (LPARAM)temp); + //id an das element übergeben + SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_SETITEMDATA, idx, gameid); + } } return TRUE; - } + case WM_COMMAND: - { - if (LOWORD(wParam) == IDC_REMOVE) - { + if (LOWORD(wParam) == IDC_REMOVE) { int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); //was ausgewählt in der liste? @@ -821,13 +771,9 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR 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 MessageBox(hwndDlg, TranslateT("Please select a game."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); } - else - if (LOWORD(wParam) == IDC_ADDGAME) - { + else if (LOWORD(wParam) == IDC_ADDGAME) { //gameliste blocken xgamelist.Block(TRUE); //if (DialogBox(hinstance,MAKEINTRESOURCE(IDD_ADDGAME),hwndDlg,DlgAddGameProc)) { @@ -836,249 +782,159 @@ static INT_PTR CALLBACK DlgProcOpts6(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR xgamelist.Block(FALSE); //gamelist neu füllen SendMessage(hwndDlg, WM_FILLGAMELIST, 0, 0); - } - //copy gamelist to clipboard button entfernt - /*else if (LOWORD(wParam)==IDC_CREATETXTLIST) //gameliste als textform für debugging erstellen - { - //gameliste blocken - xgamelist.Block(TRUE); - - //alle games durchgehen - Xfire_game* nextgame; - //output string - char* out=new char[10]; - xgamelist.setString("Xfire-gamelist:\r\n",&out); - while(xgamelist.getnextGame(&nextgame)) - { - if (nextgame->name) - { - xgamelist.appendString("\r\nName: ",&out); - xgamelist.appendString(nextgame->name,&out); - } - if (nextgame->path) - { - xgamelist.appendString("\r\nPath: ",&out); - xgamelist.appendString(nextgame->path,&out); - } - if (nextgame->launchparams) - { - xgamelist.appendString("\r\nLaunch: ",&out); - xgamelist.appendString(nextgame->launchparams,&out); } - char temp[10]; - _itoa(nextgame->id,temp,10); - xgamelist.appendString("\r\nId: ",&out); - xgamelist.appendString(temp,&out); - - _itoa(nextgame->send_gameid,temp,10); - xgamelist.appendString("\r\nSend-Id: ",&out); - xgamelist.appendString(temp,&out); - - if (nextgame->skip) - { - xgamelist.appendString("\r\nThis game will be skipped in game detection!",&out); - } - - xgamelist.appendString("\r\n",&out); - } - - if (OpenClipboard(NULL)) - { - HGLOBAL clipbuffer; - char* buffer; - - EmptyClipboard(); - clipbuffer = GlobalAlloc(GMEM_DDESHARE, mir_strlen(out)+1); - buffer = (char*)GlobalLock(clipbuffer); - mir_strcpy(buffer, LPCSTR(out)); - GlobalUnlock(clipbuffer); - - SetClipboardData(CF_TEXT, clipbuffer); - CloseClipboard(); - } - - if (out!=NULL) delete[] out; - - //gameliste unblocken - xgamelist.Block(FALSE); - }*/ - else if (LOWORD(wParam) == IDC_EDITGAME) { - int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + else if (LOWORD(wParam) == IDC_EDITGAME) { + int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); - //was ausgewählt in der liste? - if (idx != LB_ERR) { - //gameliste blocken - xgamelist.Block(TRUE); - //gameid der aktuellen auswahl auslesen - int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); - //spielobject holen - Xfire_game* tempgame = xgamelist.getGamebyGameid(gameid); - //gültiger verweis? - if (tempgame) { - //editmodus des addgamedialog - AddGameDialog(hwndDlg, tempgame); - //elemente wieder unsichtbar machen - EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE); - EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE); - EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE); - EnableDlgItem(hwndDlg, IDC_APPLY, FALSE); - EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); - ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); - } - else - MessageBox(hwndDlg, TranslateT("Error: unknown game ID."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); - //gameliste unblocken - xgamelist.Block(FALSE); - //gamelist neu füllen - SendMessage(hwndDlg, WM_FILLGAMELIST, 0, 0); + //was ausgewählt in der liste? + if (idx != LB_ERR) { + //gameliste blocken + xgamelist.Block(TRUE); + //gameid der aktuellen auswahl auslesen + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + //spielobject holen + Xfire_game* tempgame = xgamelist.getGamebyGameid(gameid); + //gültiger verweis? + if (tempgame) { + //editmodus des addgamedialog + AddGameDialog(hwndDlg, tempgame); + //elemente wieder unsichtbar machen + EnableDlgItem(hwndDlg, IDC_DONTDETECT, FALSE); + EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, FALSE); + EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, FALSE); + EnableDlgItem(hwndDlg, IDC_APPLY, FALSE); + EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); + ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); } else - MessageBox(hwndDlg, TranslateT("Please select a game."), 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); } - else //wurde ein spiel aus der liste gewählt? - if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LGAMELIST) - { - int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); - //es wurde was ausgewählt? - if (idx != LB_ERR) - { - //textlänge auslesen - int size = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0); - //textbuffer anlegen - char* text = new char[size + 1]; - SendDlgItemMessageA(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text); - SetDlgItemTextA(hwndDlg, IDC_GAMENAME, text); - //textbuffer löschen - if (text != NULL) - { - delete[] text; - text = NULL; - } - //id des spielsbekommen - int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); - - HICON hicon = xgamelist.iconmngr.getGameIcon(gameid); - //iconhandle holen und setzen - SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)hicon, 0); + else MessageBox(hwndDlg, TranslateT("Please select a game."), TranslateT("XFire Options"), MB_OK | MB_ICONEXCLAMATION); + } + else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LGAMELIST) { + int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + //es wurde was ausgewählt? + if (idx != LB_ERR) { + //textlänge auslesen + int size = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETTEXTLEN, idx, 0); + //textbuffer anlegen + char* text = new char[size + 1]; + SendDlgItemMessageA(hwndDlg, IDC_LGAMELIST, LB_GETTEXT, idx, (LPARAM)text); + SetDlgItemTextA(hwndDlg, IDC_GAMENAME, text); + //textbuffer löschen + if (text != NULL) { + delete[] text; + text = NULL; + } + //id des spielsbekommen + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + + HICON hicon = xgamelist.iconmngr.getGameIcon(gameid); + //iconhandle holen und setzen + SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)hicon, 0); + + //elemente aktivieren + EnableDlgItem(hwndDlg, IDC_DONTDETECT, TRUE); + EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, TRUE); + EnableDlgItem(hwndDlg, IDC_APPLY, TRUE); + EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, TRUE); + EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); + + Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid); + if (xgtemp && xgtemp->custom) { + ShowWindow(GetDlgItem(hwndDlg, IDC_MANADDED), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_SHOW); + } + else { + ShowWindow(GetDlgItem(hwndDlg, IDC_MANADDED), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); + } - //elemente aktivieren - EnableDlgItem(hwndDlg, IDC_DONTDETECT, TRUE); - EnableDlgItem(hwndDlg, IDC_NOSTATUSMSG, TRUE); - EnableDlgItem(hwndDlg, IDC_APPLY, TRUE); - EnableDlgItem(hwndDlg, IDC_NOTINSTARTMENU, TRUE); + //gameskip wert setzen + char temp[64] = ""; + mir_snprintf(temp, _countof(temp), "gameskip_%d", gameid); + CheckDlgButton(hwndDlg, IDC_DONTDETECT, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); + mir_snprintf(temp, _countof(temp), "gamenostatus_%d", gameid); + CheckDlgButton(hwndDlg, IDC_NOSTATUSMSG, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); + mir_snprintf(temp, _countof(temp), "notinstartmenu_%d", gameid); + CheckDlgButton(hwndDlg, IDC_NOTINSTARTMENU, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); + + //extra parameter auslesen, aber nur, wenn das spiel auch sowas unterstützt + if (xgtemp && xgtemp->haveExtraGameArgs()) { EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); - - Xfire_game* xgtemp = xgamelist.getGamebyGameid(gameid); - if (xgtemp && xgtemp->custom) - { - ShowWindow(GetDlgItem(hwndDlg, IDC_MANADDED), SW_SHOW); - ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_SHOW); + mir_snprintf(temp, _countof(temp), "gameextraparams_%d", gameid); + DBVARIANT dbv; + if (!db_get(NULL, protocolname, temp, &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, dbv.pszVal); + db_free(&dbv); } else - { - ShowWindow(GetDlgItem(hwndDlg, IDC_MANADDED), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_EDITGAME), SW_HIDE); - } - - //gameskip wert setzen - char temp[64] = ""; - mir_snprintf(temp, _countof(temp), "gameskip_%d", gameid); - CheckDlgButton(hwndDlg, IDC_DONTDETECT, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); - mir_snprintf(temp, _countof(temp), "gamenostatus_%d", gameid); - CheckDlgButton(hwndDlg, IDC_NOSTATUSMSG, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); - mir_snprintf(temp, _countof(temp), "notinstartmenu_%d", gameid); - CheckDlgButton(hwndDlg, IDC_NOTINSTARTMENU, db_get_b(NULL, protocolname, temp, 0) ? BST_CHECKED : BST_UNCHECKED); - - //extra parameter auslesen, aber nur, wenn das spiel auch sowas unterstützt - if (xgtemp && xgtemp->haveExtraGameArgs()) - { - EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, TRUE); - mir_snprintf(temp, _countof(temp), "gameextraparams_%d", gameid); - DBVARIANT dbv; - if (!db_get(NULL, protocolname, temp, &dbv)) - { - SetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, dbv.pszVal); - db_free(&dbv); - } - else - SetDlgItemText(hwndDlg, IDC_EXTRAPARAMS, _T("")); - } - else - { - EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); - SetDlgItemText(hwndDlg, IDC_EXTRAPARAMS, TranslateT("Not supported")); - } + SetDlgItemText(hwndDlg, IDC_EXTRAPARAMS, _T("")); } + else { + EnableDlgItem(hwndDlg, IDC_EXTRAPARAMS, FALSE); + SetDlgItemText(hwndDlg, IDC_EXTRAPARAMS, TranslateT("Not supported")); } - else if (LOWORD(wParam) == IDC_APPLY) - { - //auswahl speichern - int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); - //es wurde was ausgewählt? - if (idx != LB_ERR) - { - int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); - int dbid; - - //gamelist blocken - xgamelist.Block(TRUE); - - if (xgamelist.Gameinlist(gameid, &dbid)) - { - Xfire_game* game = xgamelist.getGame(dbid); - if (game) - { - game->skip = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT); - game->noicqstatus = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG); - game->notinstartmenu = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU); - - //extra parameter auslesen und das gameobj schreiben - char str[128] = ""; - GetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, str, _countof(str)); - if (str[0] != 0) - { - //extra parameter sind gesetzt, zuweisen - game->setString(str, &game->extraparams); - } - else - { - //extra parameter leer, wenn gesetzt entfernen/freigeben - if (game->extraparams) - { - delete[] game->extraparams; - game->extraparams = NULL; - } - } - - - game->refreshMenuitem(); - game->writeToDB(dbid); - - SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Configuration saved!")); - } - else - { - SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); - } + } + } + else if (LOWORD(wParam) == IDC_APPLY) { + //auswahl speichern + int idx = SendDlgItemMessage(hwndDlg, IDC_LGAMELIST, LB_GETCURSEL, 0, 0); + //es wurde was ausgewählt? + if (idx != LB_ERR) { + int gameid = SendDlgItemMessage((HWND)hwndDlg, IDC_LGAMELIST, LB_GETITEMDATA, idx, 0); + int dbid; + + //gamelist blocken + xgamelist.Block(TRUE); + + if (xgamelist.Gameinlist(gameid, &dbid)) { + Xfire_game* game = xgamelist.getGame(dbid); + if (game) { + game->skip = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DONTDETECT); + game->noicqstatus = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOSTATUSMSG); + game->notinstartmenu = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NOTINSTARTMENU); + + //extra parameter auslesen und das gameobj schreiben + char str[128] = ""; + GetDlgItemTextA(hwndDlg, IDC_EXTRAPARAMS, str, _countof(str)); + if (str[0] != 0) { + //extra parameter sind gesetzt, zuweisen + game->setString(str, &game->extraparams); } - else - { - SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); + else { + //extra parameter leer, wenn gesetzt entfernen/freigeben + if (game->extraparams) { + delete[] game->extraparams; + game->extraparams = NULL; + } } - //gamelist unblocken - xgamelist.Block(FALSE); + + game->refreshMenuitem(); + game->writeToDB(dbid); + + SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Configuration saved!")); + } + else { + SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); } } - break; - } + else { + SetDlgItemText(hwndDlg, IDC_TEXTSTATUS, TranslateT("Game not found?!")); + } - case WM_NOTIFY: - { + //gamelist unblocken + xgamelist.Block(FALSE); + } + } break; } - } return FALSE; } diff --git a/protocols/Xfire/src/otherloginpacket.cpp b/protocols/Xfire/src/otherloginpacket.cpp index d0d16fb41e..0c90ca78ff 100644 --- a/protocols/Xfire/src/otherloginpacket.cpp +++ b/protocols/Xfire/src/otherloginpacket.cpp @@ -27,11 +27,12 @@ #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - void OtherLoginPacket::parseContent(char *buf, int length, int numberOfAtts) { - XINFO(("Someone login in with the same account that we have\n")); - } +using namespace std; +namespace xfirelib +{ + void OtherLoginPacket::parseContent(char*, int, int) + { + XINFO(("Someone login in with the same account that we have\n")); + } }; diff --git a/protocols/Xfire/src/otherloginpacket.h b/protocols/Xfire/src/otherloginpacket.h index 4f1168e427..19f2321399 100644 --- a/protocols/Xfire/src/otherloginpacket.h +++ b/protocols/Xfire/src/otherloginpacket.h @@ -30,17 +30,16 @@ namespace xfirelib { - class OtherLoginPacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new OtherLoginPacket(); } - - int getPacketId() { return XFIRE_OTHER_LOGIN; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - }; + class OtherLoginPacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new OtherLoginPacket(); } + + int getPacketId() { return XFIRE_OTHER_LOGIN; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + }; }; - #endif diff --git a/protocols/Xfire/src/packetlistener.h b/protocols/Xfire/src/packetlistener.h index 5702affcff..d463a2e959 100644 --- a/protocols/Xfire/src/packetlistener.h +++ b/protocols/Xfire/src/packetlistener.h @@ -25,17 +25,14 @@ #include "xfirepacket.h" - namespace xfirelib { - struct XFirePacket; - - class PacketListener { - public: - virtual ~PacketListener() { } - virtual void receivedPacket(XFirePacket *packet) = 0; - }; + struct XFirePacket; + class PacketListener { + public: + virtual ~PacketListener() { } + virtual void receivedPacket(XFirePacket *packet) = 0; + }; }; - #endif diff --git a/protocols/Xfire/src/packetreader.cpp b/protocols/Xfire/src/packetreader.cpp index a1b18590e1..866a5acb5d 100644 --- a/protocols/Xfire/src/packetreader.cpp +++ b/protocols/Xfire/src/packetreader.cpp @@ -54,110 +54,119 @@ #include "recvbuddychangednick.h" #include "xdebug.h" -//#include "packetlistener.h" - -namespace xfirelib { - using namespace std; - - PacketReader::PacketReader(Socket *socket) { - this->socket = socket; - this->packetListeners = new vector<PacketListener *>(); - - initPackets(); - } - void PacketReader::setSocket(Socket *socket) { - this->socket = socket; - } - PacketReader::~PacketReader() { - // TODO: delete each packetListener .. - delete packetListeners; - - while(!packets->empty()) { delete packets->at(packets->size()-1); packets->pop_back(); } - delete packets; - } - - void PacketReader::initPackets() { - packets = new vector <XFirePacketContent *>(); - packets->push_back( new ClientInformationPacket() ); - packets->push_back( new AuthPacket() ); - packets->push_back( new LoginFailedPacket() ); - packets->push_back( new LoginSuccessPacket() ); - packets->push_back( new MessagePacket() ); - packets->push_back( new BuddyListOnlinePacket() ); - packets->push_back( new BuddyListNamesPacket() ); - packets->push_back( new BuddyListGamesPacket() ); - packets->push_back( new BuddyListGames2Packet() ); - packets->push_back( new OtherLoginPacket() ); - packets->push_back( new InviteBuddyPacket() ); - packets->push_back( new InviteRequestPacket() ); - packets->push_back( new RecvRemoveBuddyPacket() ); - packets->push_back( new RecvDidPacket() ); - packets->push_back( new RecvStatusMessagePacket() ); - packets->push_back( new RecvOldVersionPacket() ); - packets->push_back( new RecvPrefsPacket() ); - //neue packetklassen hinzugefügt - dufte - packets->push_back( new FriendsBuddyListNamesPacket() ); - packets->push_back( new ClanBuddyListNamesPacket() ); - packets->push_back( new XFireClanPacket() ); - packets->push_back( new GameInfoPacket() ); - packets->push_back( new ClanInvitationPacket() ); - packets->push_back( new XFireFoundBuddys() ); - packets->push_back( new BuddyInfoPacket() ); - packets->push_back( new RecvBuddyChangedNick() ); - } - - - void *muh(void *ptr); - - /* I moved thread starting to Client - - void PacketReader::startListening() { - PacketReader *myself = this; - void* (*func)(void*) = &xfirelib::PacketReader::thread_start; - XINFO(("About to start thread\n")); - int ret = pthread_create( &readthread, NULL, func, (void*)myself ); - XDEBUG(("ret: %d\n",ret)); - } - */ - - void PacketReader::run() { - // start receiving on socket... - XDEBUG(("Starting run() method... \n")); - while(socket != NULL) { - string str; - //int b = socket->recv(str); - XFirePacket *packet = new XFirePacket(this); - XDEBUG(("Waiting for next packet... \n")); - if (packet==NULL) continue; - packet->recvPacket( socket ); - XINFO(("Received packet\n")); - if (packet->getContent() != NULL) { - fireListeners( packet ); - } else { - XDEBUG(("Packet Content was NULL ... Unknown Packet Id ??\n")); - } - XDEBUG(("Notified Listeners\n"));// << b << "bytes: " << str << endl; - delete packet->getContent(); - delete packet; - } - } - - void PacketReader::fireListeners( XFirePacket *packet ) { - for(vector<PacketListener *>::iterator it = packetListeners->begin() ; - it != packetListeners->end() ; ++it) { - (*it)->receivedPacket( packet ); - } - } - - XFirePacketContent *PacketReader::getPacketContentClass(int packetId) { - XDEBUG(("Searching for a content class...\n")); - for(uint i = 0 ; i < packets->size() ; i++) - if (packets->at(i)->getPacketId() == packetId) return packets->at(i); - XDEBUG(("None Found\n")); - return NULL; - } - - void PacketReader::addPacketListener( PacketListener *listener ) { - packetListeners->push_back( listener ); - } + +using namespace std; + +namespace xfirelib +{ + PacketReader::PacketReader(Socket *socket) + { + this->socket = socket; + this->packetListeners = new vector<PacketListener *>(); + + initPackets(); + } + void PacketReader::setSocket(Socket *socket) + { + this->socket = socket; + } + PacketReader::~PacketReader() + { + // TODO: delete each packetListener .. + delete packetListeners; + + while (!packets->empty()) { delete packets->at(packets->size() - 1); packets->pop_back(); } + delete packets; + } + + void PacketReader::initPackets() + { + packets = new vector <XFirePacketContent *>(); + packets->push_back(new ClientInformationPacket()); + packets->push_back(new AuthPacket()); + packets->push_back(new LoginFailedPacket()); + packets->push_back(new LoginSuccessPacket()); + packets->push_back(new MessagePacket()); + packets->push_back(new BuddyListOnlinePacket()); + packets->push_back(new BuddyListNamesPacket()); + packets->push_back(new BuddyListGamesPacket()); + packets->push_back(new BuddyListGames2Packet()); + packets->push_back(new OtherLoginPacket()); + packets->push_back(new InviteBuddyPacket()); + packets->push_back(new InviteRequestPacket()); + packets->push_back(new RecvRemoveBuddyPacket()); + packets->push_back(new RecvDidPacket()); + packets->push_back(new RecvStatusMessagePacket()); + packets->push_back(new RecvOldVersionPacket()); + packets->push_back(new RecvPrefsPacket()); + //neue packetklassen hinzugefügt - dufte + packets->push_back(new FriendsBuddyListNamesPacket()); + packets->push_back(new ClanBuddyListNamesPacket()); + packets->push_back(new XFireClanPacket()); + packets->push_back(new GameInfoPacket()); + packets->push_back(new ClanInvitationPacket()); + packets->push_back(new XFireFoundBuddys()); + packets->push_back(new BuddyInfoPacket()); + packets->push_back(new RecvBuddyChangedNick()); + } + + + void *muh(void *ptr); + + /* I moved thread starting to Client + + void PacketReader::startListening() { + PacketReader *myself = this; + void* (*func)(void*) = &xfirelib::PacketReader::thread_start; + XINFO(("About to start thread\n")); + int ret = pthread_create( &readthread, NULL, func, (void*)myself ); + XDEBUG(("ret: %d\n",ret)); + } + */ + + void PacketReader::run() + { + // start receiving on socket... + XDEBUG(("Starting run() method... \n")); + while (socket != NULL) { + string str; + //int b = socket->recv(str); + XFirePacket *packet = new XFirePacket(this); + XDEBUG(("Waiting for next packet... \n")); + if (packet == NULL) continue; + packet->recvPacket(socket); + XINFO(("Received packet\n")); + if (packet->getContent() != NULL) { + fireListeners(packet); + } + else { + XDEBUG(("Packet Content was NULL ... Unknown Packet Id ??\n")); + } + XDEBUG(("Notified Listeners\n"));// << b << "bytes: " << str << endl; + delete packet->getContent(); + delete packet; + } + } + + void PacketReader::fireListeners(XFirePacket *packet) + { + for (vector<PacketListener *>::iterator it = packetListeners->begin(); + it != packetListeners->end(); ++it) { + (*it)->receivedPacket(packet); + } + } + + XFirePacketContent *PacketReader::getPacketContentClass(int packetId) + { + XDEBUG(("Searching for a content class...\n")); + for (uint i = 0; i < packets->size(); i++) + if (packets->at(i)->getPacketId() == packetId) return packets->at(i); + XDEBUG(("None Found\n")); + return NULL; + } + + void PacketReader::addPacketListener(PacketListener *listener) + { + packetListeners->push_back(listener); + } }; diff --git a/protocols/Xfire/src/packetreader.h b/protocols/Xfire/src/packetreader.h index 6108500565..1a4d99aded 100644 --- a/protocols/Xfire/src/packetreader.h +++ b/protocols/Xfire/src/packetreader.h @@ -25,33 +25,31 @@ #ifndef __PACKETREADER_H #define __PACKETREADER_H -#include <vector> #include "xfirepacketcontent.h" #include "packetlistener.h" namespace xfirelib { - struct PacketListener; - struct XFirePacket; - -class PacketReader { - public: - PacketReader(Socket *socket); - ~PacketReader(); - - void setSocket(Socket *socket); - void startListening(); - XFirePacketContent *getPacketContentClass(int packetId); - void addPacketListener( PacketListener *listener ); - void run(); - private: - void initPackets(); - void fireListeners( XFirePacket *packet ); - - Socket *socket; - std::vector <XFirePacketContent *> *packets; - std::vector <PacketListener *> *packetListeners; -}; - + struct PacketListener; + struct XFirePacket; + + class PacketReader { + public: + PacketReader(Socket *socket); + ~PacketReader(); + + void setSocket(Socket *socket); + void startListening(); + XFirePacketContent *getPacketContentClass(int packetId); + void addPacketListener( PacketListener *listener ); + void run(); + private: + void initPackets(); + void fireListeners( XFirePacket *packet ); + + Socket *socket; + std::vector <XFirePacketContent *> *packets; + std::vector <PacketListener *> *packetListeners; + }; }; #endif diff --git a/protocols/Xfire/src/passworddialog.cpp b/protocols/Xfire/src/passworddialog.cpp index fac061f214..bef0abd9c7 100644 --- a/protocols/Xfire/src/passworddialog.cpp +++ b/protocols/Xfire/src/passworddialog.cpp @@ -6,21 +6,18 @@ static char nick[255];
BOOL usenick = FALSE;
-INT_PTR CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
static char* pw[255];
- switch (msg)
- {
+ switch (msg) {
case WM_CLOSE:
- {
GetDlgItemTextA(hwndDlg, IDC_PWSTRING, (LPSTR)pw, 254);
if (usenick)
GetDlgItemTextA(hwndDlg, IDC_PWNICK, (LPSTR)nick, _countof(nick));
EndDialog(hwndDlg, (INT_PTR)pw);
break;
- }
+
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
//passwort und nick leeren
pw[0] = 0;
@@ -30,30 +27,22 @@ INT_PTR CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hwndDlg, IDC_PWNICK), FALSE);
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)
- {
- usenick = TRUE;
- }
- else
- usenick = FALSE;
+void ShowPasswordDialog(char*pw, char*mynick)
+{
+ usenick = (mynick != NULL);
- char* npw = (char*)DialogBox(hinstance, MAKEINTRESOURCE(IDD_PWDLG), NULL, DlgPWProc);
+ char *npw = (char*)DialogBox(hinstance, MAKEINTRESOURCE(IDD_PWDLG), NULL, DlgPWProc);
mir_strcpy(pw, npw);
if (mynick)
- {
mir_strcpy(mynick, (char*)nick);
- }
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/processbuddyinfo.cpp b/protocols/Xfire/src/processbuddyinfo.cpp index 788991c7db..0a48997f31 100644 --- a/protocols/Xfire/src/processbuddyinfo.cpp +++ b/protocols/Xfire/src/processbuddyinfo.cpp @@ -13,21 +13,8 @@ db_set_w(xsa->hContact, "ContactPhoto", "Format", av.type); extern HANDLE XFireAvatarFolder;
-//vom Yahoo plugin
-/*int avt_hash(const char *key, DWORD ksize)
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact, char* username)
{
-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) {
char temp[255] = "";
char filename[1024] = "";
BOOL dl = FALSE;
@@ -84,8 +71,7 @@ void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact, c }
- if (dl != FALSE)
- {
+ if (dl != FALSE) {
if (hcontact) //buddyavatar setzen
{
db_set_dw(hcontact, "ContactPhoto", "XFireAvatarId", buddyinfo->avatarid);
@@ -106,4 +92,4 @@ void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo, MCONTACT hcontact, c CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)protocolname, 0);
}
}
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/pwd_dlg.cpp b/protocols/Xfire/src/pwd_dlg.cpp index 3703e6caa1..d0e2cf6564 100644 --- a/protocols/Xfire/src/pwd_dlg.cpp +++ b/protocols/Xfire/src/pwd_dlg.cpp @@ -5,43 +5,37 @@ char password[256] = "";
-INT_PTR CALLBACK DlgPwProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgPwProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
- switch (msg)
- {
+ switch (msg) {
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)
- {
+ if (LOWORD(wParam) == IDOK) {
GetDlgItemTextA(hwndDlg, IDC_NICKNAME, password, _countof(password));
EndDialog(hwndDlg, TRUE);
return TRUE;
}
- else if (LOWORD(wParam) == IDCANCEL)
- {
+ else if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hwndDlg, FALSE);
return FALSE;
}
}
- }
return FALSE;
}
-BOOL ShowPwdDlg(char* pw) {
- //kein gültiges ziel für das eingegebene passwort
+BOOL ShowPwdDlg(char* pw)
+{
+ // kein gültiges ziel für das eingegebene passwort
if (pw == NULL)
return FALSE;
- if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgPwProc))
- {
- //passwort kopieren
+ if (DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgPwProc)) {
+ // passwort kopieren
if (*password == 0)
return FALSE;
@@ -50,4 +44,4 @@ BOOL ShowPwdDlg(char* pw) { }
return FALSE;
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/recvbuddychangednick.cpp b/protocols/Xfire/src/recvbuddychangednick.cpp index f48b8da043..2a1bc4188c 100644 --- a/protocols/Xfire/src/recvbuddychangednick.cpp +++ b/protocols/Xfire/src/recvbuddychangednick.cpp @@ -28,21 +28,22 @@ //packet liest neue nicks ein -namespace xfirelib { - using namespace std; - - void RecvBuddyChangedNick::parseContent(char *buf, int length, int numberOfAtts) { - VariableValue val; - int index = 0; - index +=2; // Ignore 02 01 02 ?? - index += val.readValue(buf,index,4); - userid = val.getValueAsLong(); - index +=2; // Ignore 0d 01 - int l = (unsigned char)buf[index++]; - index++; - index += val.readValue(buf,index,l); - string stringvalue = string(val.getValue(),l); - this->newnick=stringvalue; - } +using namespace std; +namespace xfirelib +{ + void RecvBuddyChangedNick::parseContent(char *buf, int, int) + { + VariableValue val; + int index = 0; + index += 2; // Ignore 02 01 02 ?? + index += val.readValue(buf, index, 4); + userid = val.getValueAsLong(); + index += 2; // Ignore 0d 01 + int l = (unsigned char)buf[index++]; + index++; + index += val.readValue(buf, index, l); + string stringvalue = string(val.getValue(), l); + this->newnick = stringvalue; + } }; diff --git a/protocols/Xfire/src/recvbuddychangednick.h b/protocols/Xfire/src/recvbuddychangednick.h index 6c3ae08e05..db71eefd1e 100644 --- a/protocols/Xfire/src/recvbuddychangednick.h +++ b/protocols/Xfire/src/recvbuddychangednick.h @@ -27,26 +27,23 @@ //packet liest neue nicks ein #include "xfirerecvpacketcontent.h" -#include <string> #define XFIRE_RECVBUDDYCHANGEDNICK 161 namespace xfirelib { - class RecvBuddyChangedNick : public XFireRecvPacketContent { - public: - virtual ~RecvBuddyChangedNick() { } - int getPacketId() { return XFIRE_RECVBUDDYCHANGEDNICK; } + class RecvBuddyChangedNick : public XFireRecvPacketContent { + public: + virtual ~RecvBuddyChangedNick() { } + int getPacketId() { return XFIRE_RECVBUDDYCHANGEDNICK; } - XFirePacketContent *newPacket() { return new RecvBuddyChangedNick(); } - void parseContent(char *buf, int length, int numberOfAtts); + XFirePacketContent *newPacket() { return new RecvBuddyChangedNick(); } + void parseContent(char *buf, int length, int numberOfAtts); - long userid; - - std::string newnick; - void* entry; // handle eingefügt, damit ich schnell den buddy killen kann - dufte - }; + long userid; + std::string newnick; + void* entry; // handle eingefügt, damit ich schnell den buddy killen kann - dufte + }; }; - #endif diff --git a/protocols/Xfire/src/recvdidpacket.cpp b/protocols/Xfire/src/recvdidpacket.cpp index 3a22134d73..7c205ff6fd 100644 --- a/protocols/Xfire/src/recvdidpacket.cpp +++ b/protocols/Xfire/src/recvdidpacket.cpp @@ -26,10 +26,10 @@ #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - - void RecvDidPacket::parseContent(char *buf, int length, int numberOfAtts) { - XDEBUG(("This is the useless DID packet, it's really useless\n")); - } - +namespace xfirelib +{ + void RecvDidPacket::parseContent(char*, int, int) + { + XDEBUG(("This is the useless DID packet, it's really useless\n")); + } }; diff --git a/protocols/Xfire/src/recvdidpacket.h b/protocols/Xfire/src/recvdidpacket.h index 92e09ff2f3..89d3026c05 100644 --- a/protocols/Xfire/src/recvdidpacket.h +++ b/protocols/Xfire/src/recvdidpacket.h @@ -28,16 +28,14 @@ #define XFIRE_RECVDIDPACKET 144 namespace xfirelib { - class RecvDidPacket : public XFireRecvPacketContent { - public: - virtual ~RecvDidPacket() { } - int getPacketId() { return XFIRE_RECVDIDPACKET; } - - XFirePacketContent *newPacket() { return new RecvDidPacket(); } - void parseContent(char *buf, int length, int numberOfAtts); - }; - + class RecvDidPacket : public XFireRecvPacketContent { + public: + virtual ~RecvDidPacket() { } + int getPacketId() { return XFIRE_RECVDIDPACKET; } + + XFirePacketContent *newPacket() { return new RecvDidPacket(); } + void parseContent(char *buf, int length, int numberOfAtts); + }; }; - #endif diff --git a/protocols/Xfire/src/recvoldversionpacket.cpp b/protocols/Xfire/src/recvoldversionpacket.cpp index 635d69352a..200bda04df 100644 --- a/protocols/Xfire/src/recvoldversionpacket.cpp +++ b/protocols/Xfire/src/recvoldversionpacket.cpp @@ -26,17 +26,18 @@ #include "variablevalue.h" #include "xdebug.h" -#include <vector> -#include <string> -namespace xfirelib { - class RecvOldVersionPacket; +namespace xfirelib +{ + class RecvOldVersionPacket; - RecvOldVersionPacket::RecvOldVersionPacket() : XFireRecvPacketContent() { - } + RecvOldVersionPacket::RecvOldVersionPacket() : XFireRecvPacketContent() + { + } - void RecvOldVersionPacket::parseContent(char *buf, int length, int numberOfAtts) { - //aktuelle version - this->newversion=buf[12]; - } + void RecvOldVersionPacket::parseContent(char *buf, int, int) + { + //aktuelle version + this->newversion = buf[12]; + } }; diff --git a/protocols/Xfire/src/recvoldversionpacket.h b/protocols/Xfire/src/recvoldversionpacket.h index 46bc1d6ccc..2176aa9daf 100644 --- a/protocols/Xfire/src/recvoldversionpacket.h +++ b/protocols/Xfire/src/recvoldversionpacket.h @@ -29,20 +29,18 @@ namespace xfirelib { - class RecvOldVersionPacket : public XFireRecvPacketContent { - public: - RecvOldVersionPacket(); - virtual ~RecvOldVersionPacket() { } - XFirePacketContent *newPacket() { return new RecvOldVersionPacket; } - int getPacketId() { return XFIRE_RECV_OLDVERSION_PACKET_ID; } + class RecvOldVersionPacket : public XFireRecvPacketContent { + public: + RecvOldVersionPacket(); + virtual ~RecvOldVersionPacket() { } + XFirePacketContent *newPacket() { return new RecvOldVersionPacket; } + int getPacketId() { return XFIRE_RECV_OLDVERSION_PACKET_ID; } - void parseContent(char *buf, int length, int numberOfAtts); + void parseContent(char *buf, int length, int numberOfAtts); - char newversion; - - }; + char newversion; + }; }; - #endif diff --git a/protocols/Xfire/src/recvprefspacket.cpp b/protocols/Xfire/src/recvprefspacket.cpp index 840dd1230b..5916d6d58e 100644 --- a/protocols/Xfire/src/recvprefspacket.cpp +++ b/protocols/Xfire/src/recvprefspacket.cpp @@ -27,81 +27,74 @@ #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { +namespace xfirelib +{ + void RecvPrefsPacket::parseContent(char *buf, int, int) + { + int index = 0; - void RecvPrefsPacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; + memset(&this->config, 0, sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS); - memset(&this->config,0,sizeof(xfire_prefitem)*XFIRE_RECVPREFSPACKET_MAXCONFIGS); + XDEBUG("This packet gives us the preferences that you can set with the official client.\n"); - XDEBUG("This packet gives us the preferences that you can set with the official client.\n"); + //skip 4c,09 + index += 2; - //skip 4c,09 - index+=2; + //anzahl an konfigurationen welche abgestellt wurden + int anz = buf[index]; + XDEBUG2("%d disabled Configs\n", anz); - //anzahl an konfigurationen welche abgestellt wurden - int anz=buf[index]; - XDEBUG2("%d disabled Configs\n",anz); + index++; - index++; + for (int i = 0; i < anz; i++) { + int kid = buf[index]; + XDEBUG2("Konfigid: %d\n", kid); - for(int i=0;i<anz;i++) - { - int kid=buf[index]; - XDEBUG2("Konfigid: %d\n",kid); - - if (kid<XFIRE_RECVPREFSPACKET_MAXCONFIGS&&kid>0) - { - config[kid].wasset=1; - for(int j=0;j<4;j++) - { - index++; - config[kid].data[j]=buf[index]; + if (kid < XFIRE_RECVPREFSPACKET_MAXCONFIGS&&kid>0) { + config[kid].wasset = 1; + for (int j = 0; j < 4; j++) { + index++; + config[kid].data[j] = buf[index]; + } } - } - XDEBUG2("Konfigval: %d\n",buf[index]); - index++; + XDEBUG2("Konfigval: %d\n", buf[index]); + index++; + } } + //prefences packet vorbereiten + int PrefsPacket::getPacketContent(char *buf) + { + int index = 0; - } - - //prefences packet vorbereiten - int PrefsPacket::getPacketContent(char *buf) { - int index = 0; - - buf[index++]=5; - buf[index++]='p'; - buf[index++]='r'; - buf[index++]='e'; - buf[index++]='f'; - buf[index++]='s'; + buf[index++] = 5; + buf[index++] = 'p'; + buf[index++] = 'r'; + buf[index++] = 'e'; + buf[index++] = 'f'; + buf[index++] = 's'; - buf[index++]=9; + buf[index++] = 9; - //anzahlindex zwischenspeichern - int anzindex=index; - index++; + //anzahlindex zwischenspeichern + int anzindex = index; + index++; - int anz=0; - for(int j=0;j<XFIRE_RECVPREFSPACKET_MAXCONFIGS;j++) - { - if (this->config[j].wasset==1) - { - buf[index++]=j; - buf[index++]=this->config[j].data[0]; - buf[index++]=this->config[j].data[1]; - buf[index++]=this->config[j].data[2]; - buf[index++]=this->config[j].data[3]; - anz++; + int anz = 0; + for (int j = 0; j < XFIRE_RECVPREFSPACKET_MAXCONFIGS; j++) { + if (this->config[j].wasset == 1) { + buf[index++] = j; + buf[index++] = this->config[j].data[0]; + buf[index++] = this->config[j].data[1]; + buf[index++] = this->config[j].data[2]; + buf[index++] = this->config[j].data[3]; + anz++; + } } - } - - buf[anzindex]=anz; - - return index; - } + buf[anzindex] = anz; + return index; + } }; diff --git a/protocols/Xfire/src/recvprefspacket.h b/protocols/Xfire/src/recvprefspacket.h index 24683f870b..0640ad8d82 100644 --- a/protocols/Xfire/src/recvprefspacket.h +++ b/protocols/Xfire/src/recvprefspacket.h @@ -47,35 +47,33 @@ struct xfireconfigitem { namespace xfirelib { - //packet mit den preferences - class RecvPrefsPacket : public XFireRecvPacketContent { - public: - virtual ~RecvPrefsPacket() { } - int getPacketId() { return XFIRE_RECVPREFSPACKET; } + //packet mit den preferences + class RecvPrefsPacket : public XFireRecvPacketContent { + public: + virtual ~RecvPrefsPacket() { } + int getPacketId() { return XFIRE_RECVPREFSPACKET; } - XFirePacketContent *newPacket() { return new RecvPrefsPacket(); } - void parseContent(char *buf, int length, int numberOfAtts); + XFirePacketContent *newPacket() { return new RecvPrefsPacket(); } + void parseContent(char *buf, int length, int numberOfAtts); - //array vorbereiten, eventuell auf 32 bytes aufstocken, man weis ja nie was kommt - xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; - }; + //array vorbereiten, eventuell auf 32 bytes aufstocken, man weis ja nie was kommt + xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; + }; - //packet zum setzen neuer preferences - class PrefsPacket : public XFireSendPacketContent { - public: - virtual ~PrefsPacket() { } + //packet zum setzen neuer preferences + class PrefsPacket : public XFireSendPacketContent { + public: + virtual ~PrefsPacket() { } - XFirePacketContent *newPacket() { return new PrefsPacket; } - int getPacketId() { return XFIRE_SENDPREFSPACKET; } + XFirePacketContent *newPacket() { return new PrefsPacket; } + int getPacketId() { return XFIRE_SENDPREFSPACKET; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 1; } - int getPacketSize() { return 1024; } - - xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; - }; + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 1; } + int getPacketSize() { return 1024; } + xfire_prefitem config[XFIRE_RECVPREFSPACKET_MAXCONFIGS]; + }; }; - #endif diff --git a/protocols/Xfire/src/recvremovebuddypacket.cpp b/protocols/Xfire/src/recvremovebuddypacket.cpp index 1e9b14d939..7b345b21cb 100644 --- a/protocols/Xfire/src/recvremovebuddypacket.cpp +++ b/protocols/Xfire/src/recvremovebuddypacket.cpp @@ -25,15 +25,15 @@ #include "recvremovebuddypacket.h" #include "variablevalue.h" -namespace xfirelib { - - void RecvRemoveBuddyPacket::parseContent(char *buf, int length, int numberOfAtts) { - VariableValue val; - int index = 0; - index += val.readName(buf,index); - index ++; // Ignore 02 ?? - index += val.readValue(buf,index,4); - userid = val.getValueAsLong(); - } - +namespace xfirelib +{ + void RecvRemoveBuddyPacket::parseContent(char *buf, int, int) + { + VariableValue val; + int index = 0; + index += val.readName(buf, index); + index++; // Ignore 02 ?? + index += val.readValue(buf, index, 4); + userid = val.getValueAsLong(); + } }; diff --git a/protocols/Xfire/src/recvremovebuddypacket.h b/protocols/Xfire/src/recvremovebuddypacket.h index c617215d66..16d053c5e1 100644 --- a/protocols/Xfire/src/recvremovebuddypacket.h +++ b/protocols/Xfire/src/recvremovebuddypacket.h @@ -24,7 +24,6 @@ #define __RECVREMOVEBUDDYPACKET_H #include "xfirerecvpacketcontent.h" -#include <string> #define XFIRE_RECVREMOVEBUDDYPACKET 139 @@ -49,8 +48,6 @@ namespace xfirelib { std::string username; MCONTACT handle; // handle eingefügt, damit ich schnell den buddy killen kann - dufte }; - }; - #endif diff --git a/protocols/Xfire/src/recvstatusmessagepacket.cpp b/protocols/Xfire/src/recvstatusmessagepacket.cpp index 38387f424d..3bf45bbbdc 100644 --- a/protocols/Xfire/src/recvstatusmessagepacket.cpp +++ b/protocols/Xfire/src/recvstatusmessagepacket.cpp @@ -26,55 +26,55 @@ #include "variablevalue.h" #include "xdebug.h" -#include <vector> -#include <string> -namespace xfirelib { - RecvStatusMessagePacket::RecvStatusMessagePacket() { - centries=0; - } +namespace xfirelib +{ + RecvStatusMessagePacket::RecvStatusMessagePacket() + { + centries = 0; + } - void RecvStatusMessagePacket::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - int numberOfIds = 0; - VariableValue val; - index += val.readName(buf,index); - index ++; // ignore 03 ?? - index ++; // jump to counter - numberOfIds = (unsigned char) buf[index]; - index ++; // Ignore 00 ?? - index ++; - sids = new std::vector<char *>; - for(int i = 0 ; i < numberOfIds ; i++) { - index += val.readValue(buf,index,16); - char *sid = new char[16]; - memcpy(sid,val.getValue(),16); - sids->push_back(sid); - } + void RecvStatusMessagePacket::parseContent(char *buf, int, int) + { + int index = 0; + int numberOfIds = 0; + VariableValue val; + index += val.readName(buf, index); + index++; // ignore 03 ?? + index++; // jump to counter + numberOfIds = (unsigned char)buf[index]; + index++; // Ignore 00 ?? + index++; + sids = new std::vector<char *>; + for (int i = 0; i < numberOfIds; i++) { + index += val.readValue(buf, index, 16); + char *sid = new char[16]; + memcpy(sid, val.getValue(), 16); + sids->push_back(sid); + } - index += val.readName(buf,index); - XDEBUG(( "valname %s\n", val.getName().c_str() )); - index ++; // Ignore 04 ?? - msgs = new std::vector<std::string>; - index = readStrings(msgs,buf,index); + index += val.readName(buf, index); + XDEBUG(("valname %s\n", val.getName().c_str())); + index++; // Ignore 04 ?? + msgs = new std::vector<std::string>; + index = readStrings(msgs, buf, index); + } - } - - -int RecvStatusMessagePacket::readStrings(std::vector<std::string> *strings, char *buf, int index) { - VariableValue friends; - index += friends.readValue(buf,index); - index ++; // Ignore 00 - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - std::string stringvalue = std::string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() ); - } - return index; - } + int RecvStatusMessagePacket::readStrings(std::vector<std::string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readValue(buf, index); + index++; // Ignore 00 + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + std::string stringvalue = std::string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG3("String length: %2d : %s\n", length, stringvalue.c_str()); + } + return index; + } }; diff --git a/protocols/Xfire/src/recvstatusmessagepacket.h b/protocols/Xfire/src/recvstatusmessagepacket.h index 95e61fab12..2c3a245211 100644 --- a/protocols/Xfire/src/recvstatusmessagepacket.h +++ b/protocols/Xfire/src/recvstatusmessagepacket.h @@ -27,31 +27,27 @@ #include "xfirerecvpacketcontent.h" #include "buddylist.h" -#include <string> -#include <vector> namespace xfirelib { - class RecvStatusMessagePacket : public XFireRecvPacketContent { - public: - RecvStatusMessagePacket(); - virtual ~RecvStatusMessagePacket() { } - XFirePacketContent *newPacket() { return new RecvStatusMessagePacket; } - int getPacketId() { return XFIRE_RECV_STATUSMESSAGE_PACKET_ID; } + class RecvStatusMessagePacket : public XFireRecvPacketContent { + public: + RecvStatusMessagePacket(); + virtual ~RecvStatusMessagePacket() { } + XFirePacketContent *newPacket() { return new RecvStatusMessagePacket; } + int getPacketId() { return XFIRE_RECV_STATUSMESSAGE_PACKET_ID; } - void parseContent(char *buf, int length, int numberOfAtts); - char * getSid(int i){ return sids->at(i); } + void parseContent(char *buf, int length, int numberOfAtts); + char * getSid(int i){ return sids->at(i); } - std::vector<char *> *sids; - std::vector<std::string> *msgs; - BuddyListEntry** entries; - int centries; - - private: - int readStrings(std::vector<std::string> *strings, char *buf, int index); - }; + std::vector<char *> *sids; + std::vector<std::string> *msgs; + BuddyListEntry** entries; + int centries; + private: + int readStrings(std::vector<std::string> *strings, char *buf, int index); + }; }; - #endif diff --git a/protocols/Xfire/src/resource.h b/protocols/Xfire/src/resource.h index 735256afbc..512d2a967e 100644 --- a/protocols/Xfire/src/resource.h +++ b/protocols/Xfire/src/resource.h @@ -86,7 +86,7 @@ #define IDC_INSTALLTYPES 1707
#define IDC_STC16 31001
#define IDC_PVER 91002
-#define IDD_PWDLG 991000
+#define IDD_PWDLG 9100
#define IDC_STC17 41901
#define IDC_PWSTRING 1902
#define IDC_BTN4 12903
diff --git a/protocols/Xfire/src/searchbuddy.cpp b/protocols/Xfire/src/searchbuddy.cpp index 716d88438c..51f5bd7a0e 100644 --- a/protocols/Xfire/src/searchbuddy.cpp +++ b/protocols/Xfire/src/searchbuddy.cpp @@ -27,51 +27,53 @@ #include <string.h> #include <iostream> -namespace xfirelib { - using namespace std; +using namespace std; - int SearchBuddy::getPacketContent(char *packet) { - int index = 0; +namespace xfirelib +{ + int SearchBuddy::getPacketContent(char *packet) + { + int index = 0; - // name - VariableValue val; - val.setName( "name" ); - index += val.writeName( packet, index ); + // name + VariableValue val; + val.setName("name"); + index += val.writeName(packet, index); - packet[index++] = 0x01; + packet[index++] = 0x01; - val.setValue((char*)searchstring.c_str(),searchstring.size()); - packet[index++] = searchstring.size()%256;
- packet[index++] = (int)searchstring.size()/256;
- index += val.writeValue(packet,index); + val.setValue((char*)searchstring.c_str(), searchstring.size()); + packet[index++] = searchstring.size() % 256;
+ packet[index++] = (int)searchstring.size() / 256;
+ index += val.writeValue(packet, index); - val.setName( "fname" ); - index += val.writeName( packet, index ); + val.setName("fname"); + index += val.writeName(packet, index); - packet[index++] = 0x01; - packet[index++] = 0x00; - packet[index++] = 0x00; + packet[index++] = 0x01; + packet[index++] = 0x00; + packet[index++] = 0x00; - val.setName( "lname" ); - index += val.writeName( packet, index ); + val.setName("lname"); + index += val.writeName(packet, index); - packet[index++] = 0x01; - packet[index++] = 0x00; - packet[index++] = 0x00; + packet[index++] = 0x01; + packet[index++] = 0x00; + packet[index++] = 0x00; - val.setName( "email" ); - index += val.writeName( packet, index ); + val.setName("email"); + index += val.writeName(packet, index); - packet[index++] = 0x01; - packet[index++] = 0x00; - packet[index++] = 0x00; + packet[index++] = 0x01; + packet[index++] = 0x00; + packet[index++] = 0x00; - length = index; - return index; - } - - int SearchBuddy::getPacketAttributeCount() { - return 4; - } + length = index; + return index; + } + int SearchBuddy::getPacketAttributeCount() + { + return 4; + } } diff --git a/protocols/Xfire/src/searchbuddy.h b/protocols/Xfire/src/searchbuddy.h index 79c474d06c..92f14e63e0 100644 --- a/protocols/Xfire/src/searchbuddy.h +++ b/protocols/Xfire/src/searchbuddy.h @@ -30,26 +30,23 @@ #include "xfiresendpacketcontent.h" #include "variablevalue.h" -#include <string> - namespace xfirelib { - class SearchBuddy : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new SearchBuddy(); } - - int getPacketId() { return 0xC; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1000; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; - void searchfor(std::string s) { searchstring=s; } - - private: - int length; - std::string searchstring; - }; - + class SearchBuddy : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new SearchBuddy(); } + + int getPacketId() { return 0xC; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1000; }; + void parseContent(char*, int, int) { }; + void searchfor(std::string s) { searchstring=s; } + + private: + int length; + std::string searchstring; + }; }; #endif diff --git a/protocols/Xfire/src/searching4games.cpp b/protocols/Xfire/src/searching4games.cpp index 0be853b828..476273172d 100644 --- a/protocols/Xfire/src/searching4games.cpp +++ b/protocols/Xfire/src/searching4games.cpp @@ -28,7 +28,6 @@ #include "baseProtocol.h"
#include "Xfire_gamelist.h"
#include "variables.h"
-#include <string>
using std::string;
extern int foundgames;
@@ -41,13 +40,10 @@ extern Xfire_gamelist xgamelist; BOOL CheckPath(char*ppath, char*pathwildcard = NULL)
{
char* pos = 0;
- char* pos2 = 0;
pos = strchr(ppath, '*');
- if (pos)
- {
- if (pathwildcard)
- {
+ if (pos) {
+ if (pathwildcard) {
strcpy_s(pathwildcard, XFIRE_MAX_STATIC_STRING_LEN, ppath);
}
@@ -60,14 +56,14 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) HANDLE fHandle = FindFirstFileA(ppath, &wfd); // . skippen
if (fHandle == INVALID_HANDLE_VALUE)
return FALSE;
- if(FindNextFileA(fHandle, &wfd)) { // .. auch skippen
+ if (FindNextFileA(fHandle, &wfd)) { // .. auch skippen
while (FindNextFileA(fHandle, &wfd)) // erstes file
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // nur verzeichnisse sind interessant
{
char temp[XFIRE_MAX_STATIC_STRING_LEN];
- strncpy(temp, ppath,XFIRE_MAX_STATIC_STRING_LEN-1);
+ strncpy(temp, ppath, XFIRE_MAX_STATIC_STRING_LEN - 1);
*(temp + mir_strlen(temp) - 1) = 0;
mir_strncat(temp, wfd.cFileName, _countof(temp) - mir_strlen(temp));
mir_strncat(temp, "\\", _countof(temp) - mir_strlen(temp));
@@ -84,8 +80,7 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) }
FindClose(fHandle);
}
- else
- {
+ else {
if (GetFileAttributesA(ppath) != 0xFFFFFFFF) { //exe vorhanden???? unt hint?
//gefundenes in path kopieren
return TRUE;
@@ -95,15 +90,14 @@ BOOL CheckPath(char*ppath, char*pathwildcard = NULL) return FALSE;
}
-INT_PTR CALLBACK DlgSearchDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgSearchDialogProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- return TRUE;
- }
+ {
+ TranslateDialogDefault(hwndDlg);
+ return TRUE;
+ }
}
return FALSE;
@@ -123,14 +117,13 @@ void ShowSearchDialog(LPVOID lparam) //nachrichten schleife
MSG msg;
- while (GetMessage(&msg, myhwnd, 0, 0))
- {
+ while (GetMessage(&msg, myhwnd, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
-void Scan4Games(LPVOID lparam)
+void Scan4Games(LPVOID)
{
int i = 2;
unsigned int i2 = 1;
@@ -146,20 +139,16 @@ void Scan4Games(LPVOID lparam) 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)
- {
+ if (searching) {
MSGBOX("Game searching is already running!");
return;
}
- if (xgamelist.Ingame())
- {
+ if (xgamelist.Ingame()) {
MSGBOX("A game is currently running, please close the game.");
return;
}
@@ -182,19 +171,15 @@ void Scan4Games(LPVOID lparam) BOOL loadgamesfromdb = FALSE;
if (db_get_b(NULL, protocolname, "scanalways", 0) == 0)
loadgamesfromdb = TRUE;
- else
- {
- if (db_get_b(NULL, protocolname, "scanalways", 0) == 2)
- {
+ else {
+ 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->tm_yday != db_get_w(NULL, protocolname, "scanalways_t", 0))
- {
+ if (t != NULL) {
+ if (t->tm_yday != db_get_w(NULL, protocolname, "scanalways_t", 0)) {
db_set_w(NULL, protocolname, "scanalways_t", t->tm_yday);
}
else
@@ -205,21 +190,19 @@ void Scan4Games(LPVOID lparam) //spiele von db laden
if (loadgamesfromdb)
- if (foundgames > 0)
- {
- //spieliste einlesen
- xgamelist.readGamelist(foundgames);
- //menüpunkte anlegen
- xgamelist.createStartmenu();
+ if (foundgames > 0) {
+ //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;
//dummymenü punkt entfernen
//CallService(MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )dummymenu, 0 );
@@ -237,8 +220,7 @@ void Scan4Games(LPVOID lparam) 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);
}
@@ -249,8 +231,7 @@ void Scan4Games(LPVOID lparam) xgamelist.clearDatabase();
//maximal 200 notfounds, um die nicht belegten id's zu überspringen
- while (notfound < 200)
- {
+ while (notfound < 200) {
//2 gameids?
if (split)
mir_snprintf(temp, _countof(temp), "%i_%i", i, i2);
@@ -282,22 +263,19 @@ void Scan4Games(LPVOID lparam) //ersten part des registry schlüssel raustrennen
pos = strchr(ret2, '\\');
- if (!MatchExe && pos != 0)
- {
+ if (!MatchExe && pos != 0) {
HKEY hkey, hsubk;
*pos = 0; //string trennen
pos++;
pos2 = strrchr(pos, '\\'); //key trennen
- if (pos2 != 0)
- {
+ if (pos2 != 0) {
*pos2 = 0;
pos2++;
//HKEY festlegen
- switch (*(ret2 + 6))
- {
+ switch (*(ret2 + 6)) {
case 'L':
hkey = HKEY_CLASSES_ROOT;
break;
@@ -323,22 +301,18 @@ void Scan4Games(LPVOID lparam) 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 (xfire_GetPrivateProfileString(temp, "LauncherDirAppend", "", ret2, 255, inipath)) {
if (*(path + mir_strlen(path) - 1) == '\\'&&*(ret2) == '\\')
mir_strcat(path, (ret2 + 1));
else
mir_strcat(path, ret2);
}
- if (xfire_GetPrivateProfileString(temp, "LauncherDirTruncAt", "", ret2, 255, inipath))
- {
+ if (xfire_GetPrivateProfileString(temp, "LauncherDirTruncAt", "", ret2, 255, inipath)) {
//mögliches erstes anführungszeichen entfernen
- if (*(path) == '"')
- {
+ if (*(path) == '"') {
pos2 = path;
pos2++;
@@ -359,88 +333,71 @@ void Scan4Games(LPVOID lparam) //dateiname auslesen
- if (xfire_GetPrivateProfileString(temp, "InstallHint", "", ret2, 255, inipath))
- {
+ if (xfire_GetPrivateProfileString(temp, "InstallHint", "", ret2, 255, inipath)) {
char pathtemp[XFIRE_MAX_STATIC_STRING_LEN];
mir_strcpy(pathtemp, path);
mir_strcat(pathtemp, ret2);
- if (CheckPath(pathtemp))
- {
- if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret, 255, inipath))
- {
+ if (CheckPath(pathtemp)) {
+ if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret, 255, inipath)) {
cutforlaunch = path + mir_strlen(path);
mir_strcpy(pathtemp, path);
//wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
- if (ret[0] == '\\')
- {
+ if (ret[0] == '\\') {
mir_strcat(pathtemp, (char*)&ret[1]);
}
- else
- {
+ else {
mir_strcat(pathtemp, ret);
}
- if (CheckPath(pathtemp))
- {
+ if (CheckPath(pathtemp)) {
mir_strcpy(path, pathtemp);
}
- else
- {
+ else {
*(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
- {
+ else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath)) {
cutforlaunch = path + mir_strlen(path);
mir_strcat(path, ret2);
}
}
- else
- {
+ else {
*(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "DetectExe[0]", "", ret2, 255, inipath))
- {
+ else if (xfire_GetPrivateProfileString(temp, "DetectExe[0]", "", ret2, 255, inipath)) {
cutforlaunch = path + mir_strlen(path);
mir_strcat(path, ret2);
multiexe = TRUE;
- if (!CheckPath(path, path_r))
- {
+ if (!CheckPath(path, path_r)) {
*(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret2, 255, inipath))
- {
+ else if (xfire_GetPrivateProfileString(temp, "DetectExe", "", ret2, 255, inipath)) {
cutforlaunch = path + mir_strlen(path);
//wenn backslash bei detectexe, dann diesen skippen (eveonline bug)
- if (ret2[0] == '\\')
- {
+ if (ret2[0] == '\\') {
mir_strcat(path, (char*)&ret2[1]);
}
- else
- {
+ else {
mir_strcat(path, ret2);
}
- if (!CheckPath(path, path_r))
- {
+ if (!CheckPath(path, path_r)) {
*(path) = 0;
}
}
- else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath))
- {
+ else if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret2, 255, inipath)) {
cutforlaunch = path + mir_strlen(path);
mir_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;
@@ -453,8 +410,7 @@ void Scan4Games(LPVOID lparam) if (path_r[0] == 0)
newgame->setString(path, &newgame->path);
- else
- {
+ else {
//lowercase wildcard pfad
for (unsigned int ii = 0; ii < mir_strlen(path_r); ii++)
path_r[ii] = tolower(path_r[ii]);
@@ -462,27 +418,21 @@ void Scan4Games(LPVOID lparam) }
//spiel mit mehreren exefiles
- if (multiexe)
- {
+ if (multiexe) {
multiexe = FALSE;
- for (int i = 1; i < 9; i++)
- {
+ for (int i = 1; i < 9; i++) {
mir_snprintf(ret, _countof(ret), "DetectExe[%d]", i);
- if (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath))
- {
+ if (xfire_GetPrivateProfileString(temp, ret, "", ret2, 512, inipath)) {
char* pos = strrchr(path, '\\');
- if (pos != 0)
- {
+ if (pos != 0) {
pos++;
*pos = 0;
}
mir_strcat(path, ret2);
- if (!CheckPath(path))
- {
+ if (!CheckPath(path)) {
*(path) = 0;
}
- else
- {
+ else {
for (unsigned int i2 = 0; i2 < mir_strlen(path); i2++)
path[i2] = tolower(path[i2]);
@@ -496,8 +446,7 @@ void Scan4Games(LPVOID lparam) //für launcherstring anpassen
char* pos = strrchr(path, '\\');
- if (pos != 0)
- {
+ if (pos != 0) {
pos++;
*pos = 0;
}
@@ -553,8 +502,7 @@ void Scan4Games(LPVOID lparam) mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[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);
@@ -585,10 +533,8 @@ void Scan4Games(LPVOID lparam) }
}
- else if (!MatchExe && xfire_GetPrivateProfileString(temp, "LauncherDirDefault", "", ret2, 255, inipath))
- {
- if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret, 255, inipath))
- {
+ else if (!MatchExe && xfire_GetPrivateProfileString(temp, "LauncherDirDefault", "", ret2, 255, inipath)) {
+ if (xfire_GetPrivateProfileString(temp, "LauncherExe", "", ret, 255, inipath)) {
mir_strcat(ret2, "\\");
mir_strcat(ret2, ret);
}
@@ -597,8 +543,7 @@ void Scan4Games(LPVOID lparam) 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();
@@ -618,8 +563,7 @@ void Scan4Games(LPVOID lparam) //pfad aufbereiten
char launchpath[XFIRE_MAX_STATIC_STRING_LEN] = "";
mir_strcpy(launchpath, ret2);
- if (strrchr(launchpath, '\\') != 0)
- {
+ if (strrchr(launchpath, '\\') != 0) {
*(strrchr(launchpath, '\\')) = 0;
}
@@ -655,8 +599,7 @@ void Scan4Games(LPVOID lparam) mir_snprintf(ret, _countof(ret), "CommandLineMustNotContain[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);
@@ -679,7 +622,6 @@ void Scan4Games(LPVOID lparam) split = FALSE;
}
-
}
if (split)
@@ -720,8 +662,7 @@ void Scan4Games(LPVOID lparam) EndDialog(hwnd, 0);
- if (!db_get_b(NULL, protocolname, "dontdisresults", 0))
- {
+ if (!db_get_b(NULL, protocolname, "dontdisresults", 0)) {
int p = mir_strlen(gamelist) - 2;
if (p > -1)
gamelist[p] = 0; //letztes koma killen
@@ -735,4 +676,4 @@ void Scan4Games(LPVOID lparam) //gamelist unblocken
xgamelist.Block(FALSE);
-}
\ No newline at end of file +}
diff --git a/protocols/Xfire/src/sendacceptinvitationpacket.cpp b/protocols/Xfire/src/sendacceptinvitationpacket.cpp index ece6c0bc3a..fe4010c395 100644 --- a/protocols/Xfire/src/sendacceptinvitationpacket.cpp +++ b/protocols/Xfire/src/sendacceptinvitationpacket.cpp @@ -27,21 +27,20 @@ #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - - int SendAcceptInvitationPacket::getPacketContent(char *buf) { - VariableValue val; - val.setName( "name" ); - val.setValue( name.c_str() ); - int index = 0; - index += val.writeName(buf, index); - buf[index++] = 01; - buf[index++] = name.length(); - buf[index++] = 00; - index += val.writeValue(buf, index); - - return index; - } - - +namespace xfirelib +{ + int SendAcceptInvitationPacket::getPacketContent(char *buf) + { + VariableValue val; + val.setName("name"); + val.setValue(name.c_str()); + int index = 0; + index += val.writeName(buf, index); + buf[index++] = 01; + buf[index++] = name.length(); + buf[index++] = 00; + index += val.writeValue(buf, index); + + return index; + } }; diff --git a/protocols/Xfire/src/sendacceptinvitationpacket.h b/protocols/Xfire/src/sendacceptinvitationpacket.h index 9bc2c4769b..5f8e078885 100644 --- a/protocols/Xfire/src/sendacceptinvitationpacket.h +++ b/protocols/Xfire/src/sendacceptinvitationpacket.h @@ -24,28 +24,22 @@ #define __SENDACCEPTINVITATION_H #include "xfiresendpacketcontent.h" -#include <string> - #define XFIRE_ACCEPT_INVITATION_PACKET 07 namespace xfirelib { - class SendAcceptInvitationPacket : public XFireSendPacketContent { - public: - virtual ~SendAcceptInvitationPacket() { } - int getPacketId() { return XFIRE_ACCEPT_INVITATION_PACKET; } - - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 3; } - int getPacketSize() { return 1024; } + class SendAcceptInvitationPacket : public XFireSendPacketContent { + public: + virtual ~SendAcceptInvitationPacket() { } + int getPacketId() { return XFIRE_ACCEPT_INVITATION_PACKET; } - std::string name; - private: - - }; + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 3; } + int getPacketSize() { return 1024; } + std::string name; + }; }; - #endif diff --git a/protocols/Xfire/src/senddenyinvitationpacket.h b/protocols/Xfire/src/senddenyinvitationpacket.h index 10cf6a3a80..b221b767db 100644 --- a/protocols/Xfire/src/senddenyinvitationpacket.h +++ b/protocols/Xfire/src/senddenyinvitationpacket.h @@ -29,15 +29,11 @@ namespace xfirelib { - class SendDenyInvitationPacket : public SendAcceptInvitationPacket { - public: - virtual ~SendDenyInvitationPacket() { } - int getPacketId() { return XFIRE_DENY_INVITATION_PACKET; } - - private: - }; - + class SendDenyInvitationPacket : public SendAcceptInvitationPacket { + public: + virtual ~SendDenyInvitationPacket() { } + int getPacketId() { return XFIRE_DENY_INVITATION_PACKET; } + }; }; - #endif diff --git a/protocols/Xfire/src/sendgameserverpacket.cpp b/protocols/Xfire/src/sendgameserverpacket.cpp index 2f65e1578b..ad0f677320 100644 --- a/protocols/Xfire/src/sendgameserverpacket.cpp +++ b/protocols/Xfire/src/sendgameserverpacket.cpp @@ -26,25 +26,24 @@ #include "variablevalue.h" #include <iostream> -namespace xfirelib { +namespace xfirelib +{ + int SendGameServerPacket::getPacketContent(char *buf) + { + VariableValue val; + val.setName("gip"); + val.setValue(ip); + val.setValueLength(4); - int SendGameServerPacket::getPacketContent(char *buf) { - VariableValue val; - val.setName( "gip" ); - val.setValue(ip); - val.setValueLength(4); - - int index = 0; - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - val.setName("gport"); - val.setValueFromLong(port,4); - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - return index; - } - - -}; + int index = 0; + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + val.setName("gport"); + val.setValueFromLong(port, 4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + return index; + } +} diff --git a/protocols/Xfire/src/sendgameserverpacket.h b/protocols/Xfire/src/sendgameserverpacket.h index d9f8dfc8b4..5e44b07e81 100644 --- a/protocols/Xfire/src/sendgameserverpacket.h +++ b/protocols/Xfire/src/sendgameserverpacket.h @@ -29,21 +29,18 @@ #define XFIRE_GAME_SERVER_PACKET 04 namespace xfirelib { - class SendGameServerPacket : public XFireSendPacketContent { - public: - virtual ~SendGameServerPacket() { } - int getPacketId() { return XFIRE_GAME_SERVER_PACKET; } - - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 3; } - int getPacketSize() { return 1024; } - - long port; - char ip[4]; - private: - - }; - + class SendGameServerPacket : public XFireSendPacketContent { + public: + virtual ~SendGameServerPacket() { } + int getPacketId() { return XFIRE_GAME_SERVER_PACKET; } + + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 3; } + int getPacketSize() { return 1024; } + + long port; + char ip[4]; + }; }; #endif //_SENDGAMESERVERPACKET_H_ diff --git a/protocols/Xfire/src/sendgamestatus2packet.cpp b/protocols/Xfire/src/sendgamestatus2packet.cpp index 8859e004cb..682d6bb60d 100644 --- a/protocols/Xfire/src/sendgamestatus2packet.cpp +++ b/protocols/Xfire/src/sendgamestatus2packet.cpp @@ -31,44 +31,43 @@ //packet vervollständigt -namespace xfirelib { +namespace xfirelib +{ + SendGameStatus2Packet::SendGameStatus2Packet() + { + ip[0] = ip[1] = ip[2] = ip[3] = 0; + port = 0; + } - SendGameStatus2Packet::SendGameStatus2Packet() { - ip[0] = ip[1] = ip[2] = ip[3] = 0; - port = 0; - } + int SendGameStatus2Packet::getPacketContent(char *buf) + { + VariableValue val; - int SendGameStatus2Packet::getPacketContent(char *buf) { - - VariableValue val; + val.setName(getGameAttributeName()); - val.setName( getGameAttributeName() ); + val.setValueFromLong(gameid, 4); - val.setValueFromLong(gameid,4); - - int index = 0; - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); + int index = 0; + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); - val.setName( getIPAttributeName() ); + val.setName(getIPAttributeName()); - //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte - val.setValue(ip,4); - val.setValueLength(4); - - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - val.setName( getPortAttributeName() ); - val.setValueFromLong(port,4); - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - - return index; - } + //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte + val.setValue(ip, 4); + val.setValueLength(4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + val.setName(getPortAttributeName()); + val.setValueFromLong(port, 4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + return index; + } }; diff --git a/protocols/Xfire/src/sendgamestatus2packet.h b/protocols/Xfire/src/sendgamestatus2packet.h index cad9d0108b..52ac3c17b9 100644 --- a/protocols/Xfire/src/sendgamestatus2packet.h +++ b/protocols/Xfire/src/sendgamestatus2packet.h @@ -30,27 +30,26 @@ namespace xfirelib { - class SendGameStatus2Packet : public SendGameStatusPacket { - public: - virtual ~SendGameStatus2Packet() { } - SendGameStatus2Packet(); - int getPacketId() { return XFIRE_GAME_STATUS2_PACKET; } - - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 3; } - int getPacketSize() { return 1024; } - - //gamestatus2 packet ready gemacht - long gameid; - char ip[4]; - long port; - - protected: - virtual std::string getGameAttributeName() { return "vid"; } - virtual std::string getIPAttributeName() { return "vip"; } - virtual std::string getPortAttributeName() { return "vport"; } - }; - + class SendGameStatus2Packet : public SendGameStatusPacket { + public: + virtual ~SendGameStatus2Packet() { } + SendGameStatus2Packet(); + int getPacketId() { return XFIRE_GAME_STATUS2_PACKET; } + + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 3; } + int getPacketSize() { return 1024; } + + //gamestatus2 packet ready gemacht + long gameid; + char ip[4]; + long port; + + protected: + virtual std::string getGameAttributeName() { return "vid"; } + virtual std::string getIPAttributeName() { return "vip"; } + virtual std::string getPortAttributeName() { return "vport"; } + }; }; #endif diff --git a/protocols/Xfire/src/sendgamestatuspacket.cpp b/protocols/Xfire/src/sendgamestatuspacket.cpp index fe3ae43e5a..597bfb7e8a 100644 --- a/protocols/Xfire/src/sendgamestatuspacket.cpp +++ b/protocols/Xfire/src/sendgamestatuspacket.cpp @@ -27,43 +27,42 @@ #include <windows.h> -namespace xfirelib { +namespace xfirelib +{ + SendGameStatusPacket::SendGameStatusPacket() + { + ip[0] = ip[1] = ip[2] = ip[3] = 0; + port = 0; + } - SendGameStatusPacket::SendGameStatusPacket() { - ip[0] = ip[1] = ip[2] = ip[3] = 0; - port = 0; - } + int SendGameStatusPacket::getPacketContent(char *buf) + { + VariableValue val; - int SendGameStatusPacket::getPacketContent(char *buf) { - - VariableValue val; + val.setName(getGameAttributeName()); - val.setName( getGameAttributeName() ); + val.setValueFromLong(gameid, 4); - val.setValueFromLong(gameid,4); - - int index = 0; - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); + int index = 0; + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); - val.setName( getIPAttributeName() ); + val.setName(getIPAttributeName()); - //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte - val.setValue(ip,4); - val.setValueLength(4); - - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - val.setName( getPortAttributeName() ); - val.setValueFromLong(port,4); - index += val.writeName(buf, index); - buf[index++] = 02; - index += val.writeValue(buf, index); - - return index; - } + //BUG: hab ,4 hinzugefügt, führte und vista zum crash - dufte + val.setValue(ip, 4); + val.setValueLength(4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + val.setName(getPortAttributeName()); + val.setValueFromLong(port, 4); + index += val.writeName(buf, index); + buf[index++] = 02; + index += val.writeValue(buf, index); + return index; + } }; diff --git a/protocols/Xfire/src/sendgamestatuspacket.h b/protocols/Xfire/src/sendgamestatuspacket.h index 57bec411ee..5eedb443c9 100644 --- a/protocols/Xfire/src/sendgamestatuspacket.h +++ b/protocols/Xfire/src/sendgamestatuspacket.h @@ -25,32 +25,29 @@ #define _SENDGAMESTATUSPACKET_H_ #include "xfiresendpacketcontent.h" -#include <string> #define XFIRE_GAME_STATUS_PACKET 04 namespace xfirelib { - class SendGameStatusPacket : public XFireSendPacketContent { - public: - SendGameStatusPacket(); - virtual ~SendGameStatusPacket() { } - int getPacketId() { return XFIRE_GAME_STATUS_PACKET; } - - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 3; } - int getPacketSize() { return 1024; } - - long gameid; - char ip[4]; - long port; - - protected: - virtual std::string getGameAttributeName() { return "gameid"; } - virtual std::string getIPAttributeName() { return "gip"; } - virtual std::string getPortAttributeName() { return "gport"; } - private: - - }; - + class SendGameStatusPacket : public XFireSendPacketContent { + public: + SendGameStatusPacket(); + virtual ~SendGameStatusPacket() { } + int getPacketId() { return XFIRE_GAME_STATUS_PACKET; } + + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 3; } + int getPacketSize() { return 1024; } + + long gameid; + char ip[4]; + long port; + + protected: + virtual std::string getGameAttributeName() { return "gameid"; } + virtual std::string getIPAttributeName() { return "gip"; } + virtual std::string getPortAttributeName() { return "gport"; } + }; }; + #endif //_SENDGAMESTATUSPACKET_H_ diff --git a/protocols/Xfire/src/sendkeepalivepacket.cpp b/protocols/Xfire/src/sendkeepalivepacket.cpp index 242ba88214..9a9af9ed05 100644 --- a/protocols/Xfire/src/sendkeepalivepacket.cpp +++ b/protocols/Xfire/src/sendkeepalivepacket.cpp @@ -24,33 +24,31 @@ #include "sendkeepalivepacket.h" #include "variablevalue.h" -#include <string.h> -namespace xfirelib { +namespace xfirelib +{ + int SendKeepAlivePacket::getPacketContent(char *buf) + { + int index = 0; - int SendKeepAlivePacket::getPacketContent(char *buf) { - int index = 0; + VariableValue val; + val.setName("value"); - VariableValue val; - val.setName("value"); + index += val.writeName(buf, index); + buf[index++] = 2; + buf[index++] = 0; + buf[index++] = 0; + buf[index++] = 0; + buf[index++] = 0; - index += val.writeName(buf,index); - buf[index++] = 2; - buf[index++] = 0; - buf[index++] = 0; - buf[index++] = 0; - buf[index++] = 0; - - val.setName("stats"); - - index += val.writeName(buf,index); - buf[index++] = 4; - buf[index++] = 2; - buf[index++] = 0; - buf[index++] = 0; - - return index; - } + val.setName("stats"); + index += val.writeName(buf, index); + buf[index++] = 4; + buf[index++] = 2; + buf[index++] = 0; + buf[index++] = 0; + return index; + } }; diff --git a/protocols/Xfire/src/sendkeepalivepacket.h b/protocols/Xfire/src/sendkeepalivepacket.h index 5d81785998..9bd34527c9 100644 --- a/protocols/Xfire/src/sendkeepalivepacket.h +++ b/protocols/Xfire/src/sendkeepalivepacket.h @@ -24,25 +24,21 @@ #define __SENDKEEPALIVEPACKET_H #include "xfiresendpacketcontent.h" -#include <string> #define XFIRE_SEND_KEEPALIVE_PACKET_ID 13; namespace xfirelib { - using namespace std; + using namespace std; - class SendKeepAlivePacket : public XFireSendPacketContent { - public: - virtual ~SendKeepAlivePacket() { } - int getPacketId() { return XFIRE_SEND_KEEPALIVE_PACKET_ID; } - - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 2; } - int getPacketSize() { return 26; } - - }; + class SendKeepAlivePacket : public XFireSendPacketContent { + public: + virtual ~SendKeepAlivePacket() { } + int getPacketId() { return XFIRE_SEND_KEEPALIVE_PACKET_ID; } + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 2; } + int getPacketSize() { return 26; } + }; }; - #endif diff --git a/protocols/Xfire/src/sendmessagepacket.cpp b/protocols/Xfire/src/sendmessagepacket.cpp index a0ca1400e1..05be382135 100644 --- a/protocols/Xfire/src/sendmessagepacket.cpp +++ b/protocols/Xfire/src/sendmessagepacket.cpp @@ -34,70 +34,75 @@ #include <iostream>
#include "xdebug.h"
-namespace xfirelib {
- using namespace std;
-
- std::map<std::string,int> SendMessagePacket::imindexes;
-
- void SendMessagePacket::init(Client *client, string username, string message) {
- BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
- if (entry) {
- setSid(entry->sid);
- }
- this->message = message;
- initIMIndex();
- }
-
- void SendMessagePacket::initIMIndex() {
- string str_sid(sid);
- if ( imindexes.count( str_sid ) < 1 )
- imindex = imindexes[str_sid] = 1;
- else
- imindex = ++imindexes[str_sid];
- }
-
- void SendMessagePacket::setSid(const char *sid) {
- memcpy(this->sid,sid,16);
- }
-
- int SendMessagePacket::getPacketContent(char *buf) {
- if ( imindex == 0 ) initIMIndex();
-
- int index = 0;
- VariableValue val;
- val.setName("sid");
- val.setValue(sid,16);
-
- index += val.writeName(buf,index);
- buf[index++] = 3;
- index += val.writeValue(buf,index);
-
- val.setName("peermsg");
- index += val.writeName(buf,index);
- buf[index++] = 5;
- //buf[index++] = 7;
- buf[index++] = 3;
-
- val.setName("msgtype");
- val.setValueFromLong(0,4);
- index += val.writeName(buf,index);
- buf[index++] = 2;
- index += val.writeValue(buf,index);
-
- val.setName("imindex");
- val.setValueFromLong(imindex,4);
- index += val.writeName(buf,index);
- buf[index++] = 02;
- index += val.writeValue(buf,index);
-
- val.setName("im");
- val.setValue((char*)message.c_str(),message.size());
- index += val.writeName(buf,index);
- buf[index++] = 01;
- buf[index++] = message.size()%256;
- buf[index++] = (int)message.size()/256;
- index += val.writeValue(buf,index);
-
- return index;
- }
+using namespace std;
+
+namespace xfirelib
+{
+ map<string, int> SendMessagePacket::imindexes;
+
+ void SendMessagePacket::init(Client *client, string username, string message)
+ {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
+ if (entry) {
+ setSid(entry->sid);
+ }
+ this->message = message;
+ initIMIndex();
+ }
+
+ void SendMessagePacket::initIMIndex()
+ {
+ string str_sid(sid);
+ if (imindexes.count(str_sid) < 1)
+ imindex = imindexes[str_sid] = 1;
+ else
+ imindex = ++imindexes[str_sid];
+ }
+
+ void SendMessagePacket::setSid(const char *sid)
+ {
+ memcpy(this->sid, sid, 16);
+ }
+
+ int SendMessagePacket::getPacketContent(char *buf)
+ {
+ if (imindex == 0) initIMIndex();
+
+ int index = 0;
+ VariableValue val;
+ val.setName("sid");
+ val.setValue(sid, 16);
+
+ index += val.writeName(buf, index);
+ buf[index++] = 3;
+ index += val.writeValue(buf, index);
+
+ val.setName("peermsg");
+ index += val.writeName(buf, index);
+ buf[index++] = 5;
+ //buf[index++] = 7;
+ buf[index++] = 3;
+
+ val.setName("msgtype");
+ val.setValueFromLong(0, 4);
+ index += val.writeName(buf, index);
+ buf[index++] = 2;
+ index += val.writeValue(buf, index);
+
+ val.setName("imindex");
+ val.setValueFromLong(imindex, 4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ val.setName("im");
+ val.setValue((char*)message.c_str(), message.size());
+ index += val.writeName(buf, index);
+ buf[index++] = 01;
+ buf[index++] = message.size() % 256;
+ buf[index++] = (int)message.size() / 256;
+ index += val.writeValue(buf, index);
+
+ return index;
+ }
}
diff --git a/protocols/Xfire/src/sendmessagepacket.h b/protocols/Xfire/src/sendmessagepacket.h index f54efd778c..7ca5943599 100644 --- a/protocols/Xfire/src/sendmessagepacket.h +++ b/protocols/Xfire/src/sendmessagepacket.h @@ -25,8 +25,6 @@ #ifndef __SENDMESSAGEPACKET_H #define __SENDMESSAGEPACKET_H - - #include "xfiresendpacketcontent.h" #include "variablevalue.h" #include <string.h> @@ -34,44 +32,42 @@ namespace xfirelib {
- class SendMessagePacket : public XFireSendPacketContent {
- public:
- SendMessagePacket() {
- imindex = 0;
- }
- virtual ~SendMessagePacket() { }
-
- void init(Client *client, string username, string message);
- void setSid(const char *sid);
+ class SendMessagePacket : public XFireSendPacketContent {
+ public:
+ SendMessagePacket() {
+ imindex = 0;
+ }
+ virtual ~SendMessagePacket() { }
- XFirePacketContent* newPacket() { return new SendMessagePacket(); }
+ void init(Client *client, string username, string message);
+ void setSid(const char *sid);
- int getPacketId() { return 2; }
- int getPacketContent(char *buf);
- int getPacketAttributeCount() {return 2;};
- int getPacketSize() { return 5024; };
+ XFirePacketContent* newPacket() { return new SendMessagePacket(); }
- /**
- * SID of the user to who the message should be sent.
- */
- char sid[16];
- /**
- * A running counter for each buddy. (will be initialized to 0 by default.. and..
- * shouldn't be a problem to leave it 0)
- */
- long imindex;
- /**
- * Message body to be sent.
- */
- std::string message;
+ int getPacketId() { return 2; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() {return 2;};
+ int getPacketSize() { return 5024; };
- protected:
- void initIMIndex();
+ /**
+ * SID of the user to who the message should be sent.
+ */
+ char sid[16];
+ /**
+ * A running counter for each buddy. (will be initialized to 0 by default.. and..
+ * shouldn't be a problem to leave it 0)
+ */
+ long imindex;
+ /**
+ * Message body to be sent.
+ */
+ std::string message;
- static std::map<std::string,int> imindexes;
-
- };
+ protected:
+ void initIMIndex();
+ static std::map<std::string,int> imindexes;
+ };
}; #endif diff --git a/protocols/Xfire/src/sendnickchangepacket.cpp b/protocols/Xfire/src/sendnickchangepacket.cpp index 57d38ac50d..f1afc946fd 100644 --- a/protocols/Xfire/src/sendnickchangepacket.cpp +++ b/protocols/Xfire/src/sendnickchangepacket.cpp @@ -26,24 +26,23 @@ #include "variablevalue.h" #include <string.h> -namespace xfirelib { -/*TODO: this packet is outdated, sniff with official client and change it to a correct implementation*/ - int SendNickChangePacket::getPacketContent(char *buf) { - int index = 0; +namespace xfirelib +{ + int SendNickChangePacket::getPacketContent(char *buf) + { + int index = 0; - VariableValue val; - val.setName("nick"); - val.setValue((char*)nick.c_str(),nick.size()); + VariableValue val; + val.setName("nick"); + val.setValue((char*)nick.c_str(), nick.size()); - index += val.writeName(buf,index); - buf[index++] = 1; - buf[index++] = nick.size(); - buf[index++] = 0; - - index += val.writeValue(buf,index); - - return index; - } + index += val.writeName(buf, index); + buf[index++] = 1; + buf[index++] = nick.size(); + buf[index++] = 0; + index += val.writeValue(buf, index); + return index; + } }; diff --git a/protocols/Xfire/src/sendnickchangepacket.h b/protocols/Xfire/src/sendnickchangepacket.h index 940bac032d..5ce0668422 100644 --- a/protocols/Xfire/src/sendnickchangepacket.h +++ b/protocols/Xfire/src/sendnickchangepacket.h @@ -24,28 +24,25 @@ #define __SENDNICKCHANGEPACKET_H #include "xfiresendpacketcontent.h" -#include <string> #define XFIRE_SEND_NICKCHANGE_PACKET_ID 14; namespace xfirelib { - using namespace std; + using namespace std; - class SendNickChangePacket : public XFireSendPacketContent { - public: - virtual ~SendNickChangePacket() { } + class SendNickChangePacket : public XFireSendPacketContent { + public: + virtual ~SendNickChangePacket() { } - XFirePacketContent *newPacket() { return new SendNickChangePacket; } - int getPacketId() { return XFIRE_SEND_NICKCHANGE_PACKET_ID; } + XFirePacketContent *newPacket() { return new SendNickChangePacket; } + int getPacketId() { return XFIRE_SEND_NICKCHANGE_PACKET_ID; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 1; } - int getPacketSize() { return 1024; } - - string nick; - }; + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 1; } + int getPacketSize() { return 1024; } + string nick; + }; }; - #endif diff --git a/protocols/Xfire/src/sendremovebuddypacket.cpp b/protocols/Xfire/src/sendremovebuddypacket.cpp index a49b3f38ed..dea08bbeb2 100644 --- a/protocols/Xfire/src/sendremovebuddypacket.cpp +++ b/protocols/Xfire/src/sendremovebuddypacket.cpp @@ -27,20 +27,20 @@ #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - - int SendRemoveBuddyPacket::getPacketContent(char *buf) { - int index = 0; - VariableValue val; - val.setName("userid"); - XDEBUG2( "Creating packet to remove userid %ld\n", userid ); - index += val.writeName(buf,index); - val.setValueFromLong(userid,4); - buf[index++] = 2; - index += val.writeValue(buf,index); - - return index; - } - +namespace xfirelib +{ + int SendRemoveBuddyPacket::getPacketContent(char *buf) + { + int index = 0; + VariableValue val; + val.setName("userid"); + XDEBUG2("Creating packet to remove userid %ld\n", userid); + index += val.writeName(buf, index); + val.setValueFromLong(userid, 4); + buf[index++] = 2; + index += val.writeValue(buf, index); + + return index; + } }; diff --git a/protocols/Xfire/src/sendremovebuddypacket.h b/protocols/Xfire/src/sendremovebuddypacket.h index 6a27728300..293662957f 100644 --- a/protocols/Xfire/src/sendremovebuddypacket.h +++ b/protocols/Xfire/src/sendremovebuddypacket.h @@ -29,18 +29,17 @@ namespace xfirelib { - class SendRemoveBuddyPacket : public XFireSendPacketContent { - public: - virtual ~SendRemoveBuddyPacket() { } - int getPacketId() { return XFIRE_SENDREMOVEBUDDYPACKET; } + class SendRemoveBuddyPacket : public XFireSendPacketContent { + public: + virtual ~SendRemoveBuddyPacket() { } + int getPacketId() { return XFIRE_SENDREMOVEBUDDYPACKET; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 1; } - int getPacketSize() { return 1024; } - - long userid; - }; + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 1; } + int getPacketSize() { return 1024; } + long userid; + }; }; #endif diff --git a/protocols/Xfire/src/sendsidpacket.cpp b/protocols/Xfire/src/sendsidpacket.cpp index 34c80a7ff3..0ca9230bd4 100644 --- a/protocols/Xfire/src/sendsidpacket.cpp +++ b/protocols/Xfire/src/sendsidpacket.cpp @@ -31,41 +31,40 @@ whois packet von xfire, für z.b. friends of friends */ -namespace xfirelib { - using namespace std; +namespace xfirelib +{ + int SendSidPacket::getPacketContent(char *packet) + { + int index = 0; - int SendSidPacket::getPacketContent(char *packet) { - int index = 0; + XERROR("Send Sid Packet!\n"); - XERROR("Send Sid Packet!\n"); + packet[index++] = 0x03; + packet[index++] = 's'; + packet[index++] = 'i'; + packet[index++] = 'd'; + packet[index++] = 4; + packet[index++] = 3; + XDEBUG2("Sids: %d\n", sids->size()); + packet[index++] = sids->size(); + packet[index++] = 0; - packet[index++] = 0x03; - packet[index++] = 's'; - packet[index++] = 'i'; - packet[index++] = 'd'; - packet[index++] = 4; - packet[index++] = 3; - XDEBUG2("Sids: %d\n",sids->size()); - packet[index++] = sids->size(); - packet[index++] = 0; - - for(uint i = 0 ; i < sids->size() ; i++) { - XDEBUG2("Sid%d:",i); - char* sid=sids->at(i); - for(int u = 0; u <16 ; u++) - { - XDEBUG2("%x,",sid[u]); - packet[index++] = sid[u]; + for (uint i = 0; i < sids->size(); i++) { + XDEBUG2("Sid%d:", i); + char* sid = sids->at(i); + for (int u = 0; u < 16; u++) { + XDEBUG2("%x,", sid[u]); + packet[index++] = sid[u]; + } + XDEBUG("\n"); } - XDEBUG("\n"); - } - - length = index; - return index; - } - int SendSidPacket::getPacketAttributeCount() { - return 1; - } + length = index; + return index; + } + int SendSidPacket::getPacketAttributeCount() + { + return 1; + } } diff --git a/protocols/Xfire/src/sendsidpacket.h b/protocols/Xfire/src/sendsidpacket.h index ffffad2071..a39e615f33 100644 --- a/protocols/Xfire/src/sendsidpacket.h +++ b/protocols/Xfire/src/sendsidpacket.h @@ -31,27 +31,24 @@ #include "xfiresendpacketcontent.h" #include "variablevalue.h" -#include <vector> -#include <string> - namespace xfirelib { using namespace std; - class SendSidPacket : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new SendSidPacket(); } + class SendSidPacket : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new SendSidPacket(); } - int getPacketId() { return 0x5; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1000; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; + int getPacketId() { return 0x5; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1000; }; + void parseContent(char*, int, int) { }; - vector<char *> *sids; + vector<char *> *sids; - private: - int length; - }; + private: + int length; + }; }; diff --git a/protocols/Xfire/src/sendstatusmessagepacket.cpp b/protocols/Xfire/src/sendstatusmessagepacket.cpp index 6495515119..88284ab4de 100644 --- a/protocols/Xfire/src/sendstatusmessagepacket.cpp +++ b/protocols/Xfire/src/sendstatusmessagepacket.cpp @@ -24,20 +24,17 @@ #include "sendstatusmessagepacket.h" -#include <string.h> - -namespace xfirelib { - - int SendStatusMessagePacket::getPacketContent(char *buf) { - int index = 0; - buf[index++] = 0x2e; - buf[index++] = 0x01; - buf[index++] = awaymsg.length(); - buf[index++] = 0x00; - memcpy(buf+index,awaymsg.c_str(),awaymsg.length()); - index+=awaymsg.length(); - return index; - } - - +namespace xfirelib +{ + int SendStatusMessagePacket::getPacketContent(char *buf) + { + int index = 0; + buf[index++] = 0x2e; + buf[index++] = 0x01; + buf[index++] = awaymsg.length(); + buf[index++] = 0x00; + memcpy(buf + index, awaymsg.c_str(), awaymsg.length()); + index += awaymsg.length(); + return index; + } }; diff --git a/protocols/Xfire/src/sendstatusmessagepacket.h b/protocols/Xfire/src/sendstatusmessagepacket.h index 3c4106e260..67fb869910 100644 --- a/protocols/Xfire/src/sendstatusmessagepacket.h +++ b/protocols/Xfire/src/sendstatusmessagepacket.h @@ -24,29 +24,25 @@ #define __SENDSTATUSMESSAGEPACKET_H #include "xfiresendpacketcontent.h" -#include <string> #define XFIRE_SEND_STATUSMESSAGE_PACKET_ID 32 namespace xfirelib { - using namespace std; + using namespace std; - class SendStatusMessagePacket : public XFireSendPacketContent { - public: - ~SendStatusMessagePacket(){}; - XFirePacketContent *newPacket() { return new SendStatusMessagePacket; } + class SendStatusMessagePacket : public XFireSendPacketContent { + public: + ~SendStatusMessagePacket(){}; + XFirePacketContent *newPacket() { return new SendStatusMessagePacket; } - int getPacketId() { return XFIRE_SEND_STATUSMESSAGE_PACKET_ID; } + int getPacketId() { return XFIRE_SEND_STATUSMESSAGE_PACKET_ID; } - int getPacketContent(char *buf); - int getPacketAttributeCount() { return 1; } - int getPacketSize() { return 1024; } - - - string awaymsg; - }; + int getPacketContent(char *buf); + int getPacketAttributeCount() { return 1; } + int getPacketSize() { return 1024; } + string awaymsg; + }; }; - #endif diff --git a/protocols/Xfire/src/sendtypingpacket.cpp b/protocols/Xfire/src/sendtypingpacket.cpp index 8e17679135..df38f5bd5e 100644 --- a/protocols/Xfire/src/sendtypingpacket.cpp +++ b/protocols/Xfire/src/sendtypingpacket.cpp @@ -30,74 +30,74 @@ //sendtypingklasse hinzugefügt http://xfirelib.sphene.net/board2/showThread/367 - big thx to Fl0ri4n - dufte
-
#include "sendtypingpacket.h"
#include "xfireutils.h"
-#include <string.h>
-#include <iostream>
#include "xdebug.h"
-namespace xfirelib {
-using namespace std;
-
-std::map<std::string,int> SendTypingPacket::imindexes;
-
-void SendTypingPacket::init(Client *client, string username) {
-BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
-if (entry) {
-setSid(entry->sid);
-}
-initIMIndex();
-}
-
-void SendTypingPacket::initIMIndex() {
-string str_sid(sid);
-if ( imindexes.count( str_sid ) < 1 )
-imindex = imindexes[str_sid] = 1;
-else
-imindex = ++imindexes[str_sid];
-
-}
-void SendTypingPacket::setSid(const char *sid) {
-memcpy(this->sid,sid,16);
-}
-
-int SendTypingPacket::getPacketContent(char *buf) {
-if ( imindex == 0 ) initIMIndex();
-
-int index = 0;
-VariableValue val;
-val.setName("sid");
-val.setValue(sid,16);
-
-index += val.writeName(buf,index);
-buf[index++] = 3;
-index += val.writeValue(buf,index);
-
-val.setName("peermsg");
-index += val.writeName(buf,index);
-buf[index++] = 5;
-//buf[index++] = 7;
-buf[index++] = 3;
-
-val.setName("msgtype");
-val.setValueFromLong(3,4);
-index += val.writeName(buf,index);
-buf[index++] = 2;
-index += val.writeValue(buf,index);
-
-val.setName("imindex");
-val.setValueFromLong(imindex,4);
-index += val.writeName(buf,index);
-buf[index++] = 02;
-index += val.writeValue(buf,index);
-
-val.setName("typing");
-val.setValueFromLong(1,4);
-index += val.writeName(buf,index);
-buf[index++] = 02;
-index += val.writeValue(buf,index);
-
-return index;
-}
+namespace xfirelib
+{
+ map<string, int> SendTypingPacket::imindexes;
+
+ void SendTypingPacket::init(Client *client, string username)
+ {
+ BuddyListEntry *entry = client->getBuddyList()->getBuddyByName(username);
+ if (entry) {
+ setSid(entry->sid);
+ }
+ initIMIndex();
+ }
+
+ void SendTypingPacket::initIMIndex()
+ {
+ string str_sid(sid);
+ if (imindexes.count(str_sid) < 1)
+ imindex = imindexes[str_sid] = 1;
+ else
+ imindex = ++imindexes[str_sid];
+
+ }
+ void SendTypingPacket::setSid(const char *sid)
+ {
+ memcpy(this->sid, sid, 16);
+ }
+
+ int SendTypingPacket::getPacketContent(char *buf)
+ {
+ if (imindex == 0) initIMIndex();
+
+ int index = 0;
+ VariableValue val;
+ val.setName("sid");
+ val.setValue(sid, 16);
+
+ index += val.writeName(buf, index);
+ buf[index++] = 3;
+ index += val.writeValue(buf, index);
+
+ val.setName("peermsg");
+ index += val.writeName(buf, index);
+ buf[index++] = 5;
+ //buf[index++] = 7;
+ buf[index++] = 3;
+
+ val.setName("msgtype");
+ val.setValueFromLong(3, 4);
+ index += val.writeName(buf, index);
+ buf[index++] = 2;
+ index += val.writeValue(buf, index);
+
+ val.setName("imindex");
+ val.setValueFromLong(imindex, 4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ val.setName("typing");
+ val.setValueFromLong(1, 4);
+ index += val.writeName(buf, index);
+ buf[index++] = 02;
+ index += val.writeValue(buf, index);
+
+ return index;
+ }
}
\ No newline at end of file diff --git a/protocols/Xfire/src/sendtypingpacket.h b/protocols/Xfire/src/sendtypingpacket.h index d3226f3a0e..0ba3637a47 100644 --- a/protocols/Xfire/src/sendtypingpacket.h +++ b/protocols/Xfire/src/sendtypingpacket.h @@ -31,8 +31,6 @@ #ifndef __SENDTYPINGPACKET_H
#define __SENDTYPINGPACKET_H
-
-
#include "xfiresendpacketcontent.h"
#include "variablevalue.h"
#include <string.h>
@@ -40,40 +38,38 @@ namespace xfirelib {
-class SendTypingPacket : public XFireSendPacketContent {
-public:
-SendTypingPacket() {
-imindex = 0;
-}
-virtual ~SendTypingPacket() { }
-
-void init(Client *client, string username);
-void setSid(const char *sid);
-
-XFirePacketContent* newPacket() { return new SendTypingPacket(); }
-
-int getPacketId() { return 2; }
-int getPacketContent(char *buf);
-int getPacketAttributeCount() {return 2;};
-int getPacketSize() { return 1024; };
-
-/**
-* SID of the user to who the message should be sent.
-*/
-char sid[16];
-/**
-* A running counter for each buddy. (will be initialized to 0 by default.. and..
-* shouldn't be a problem to leave it 0)
-*/
-long imindex;
-
-protected:
-void initIMIndex();
-
-static std::map<std::string,int> imindexes;
-
-};
-
+ class SendTypingPacket : public XFireSendPacketContent {
+ public:
+ SendTypingPacket() {
+ imindex = 0;
+ }
+ virtual ~SendTypingPacket() { }
+
+ void init(Client *client, string username);
+ void setSid(const char *sid);
+
+ XFirePacketContent* newPacket() { return new SendTypingPacket(); }
+
+ int getPacketId() { return 2; }
+ int getPacketContent(char *buf);
+ int getPacketAttributeCount() {return 2;};
+ int getPacketSize() { return 1024; };
+
+ /**
+ * SID of the user to who the message should be sent.
+ */
+ char sid[16];
+ /**
+ * A running counter for each buddy. (will be initialized to 0 by default.. and..
+ * shouldn't be a problem to leave it 0)
+ */
+ long imindex;
+
+ protected:
+ void initIMIndex();
+
+ static std::map<std::string,int> imindexes;
+ };
};
#endif
\ No newline at end of file diff --git a/protocols/Xfire/src/services.cpp b/protocols/Xfire/src/services.cpp index fdb15d7e80..26903077fe 100644 --- a/protocols/Xfire/src/services.cpp +++ b/protocols/Xfire/src/services.cpp @@ -30,17 +30,16 @@ #include "baseProtocol.h"
-BOOL IsContactMySelf(std::string buddyusername) {
+BOOL IsContactMySelf(std::string buddyusername)
+{
DBVARIANT dbv;
//nur wenn option aktiv, sonst immer FALSE
if (!db_get_b(NULL, protocolname, "skipmyself", 0))
return FALSE;
- if (!db_get(NULL, protocolname, "login", &dbv))
- {
- if (!mir_strcmpi(dbv.pszVal, buddyusername.c_str()))
- {
+ if (!db_get(NULL, protocolname, "login", &dbv)) {
+ if (!mir_strcmpi(dbv.pszVal, buddyusername.c_str())) {
db_free(&dbv);
return TRUE;
}
@@ -64,15 +63,12 @@ INT_PTR GetMyAvatar(WPARAM wparam, LPARAM lparam) }
//liefert vollendateipfad vom eigenen avatar zurück, wenn definiert
-int mBotNotify(WPARAM wparam, LPARAM lparam) {
-
- if (wparam) {
+int mBotNotify(WPARAM wparam, LPARAM)
+{
+ if (wparam)
CallService(MBOT_TRIGGER, (WPARAM)"xfireingame", 1);
- }
else
- {
CallService(MBOT_TRIGGER, (WPARAM)"xfireingame", 0);
- }
return 0;
}
\ No newline at end of file diff --git a/protocols/Xfire/src/setnickname.cpp b/protocols/Xfire/src/setnickname.cpp index d4eecf58c3..eb644c98f9 100644 --- a/protocols/Xfire/src/setnickname.cpp +++ b/protocols/Xfire/src/setnickname.cpp @@ -3,12 +3,10 @@ #include "stdafx.h"
#include "setnickname.h"
-INT_PTR CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
@@ -18,11 +16,9 @@ INT_PTR CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara db_free(&dbv);
}
return TRUE;
- }
+
case WM_COMMAND:
- {
- if (LOWORD(wParam) == IDOK)
- {
+ if (LOWORD(wParam) == IDOK) {
char nick[255];
GetDlgItemTextA(hwndDlg, IDC_NICKNAME, nick, _countof(nick));
@@ -31,16 +27,15 @@ INT_PTR CALLBACK DlgNickProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara EndDialog(hwndDlg, TRUE);
return TRUE;
}
- else if (LOWORD(wParam) == IDCANCEL)
- {
+ else if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hwndDlg, FALSE);
return FALSE;
}
}
- }
return FALSE;
}
-BOOL ShowSetNick() {
+BOOL ShowSetNick()
+{
return DialogBox(hinstance, MAKEINTRESOURCE(IDD_SETNICKNAME), NULL, DlgNickProc);
}
\ No newline at end of file diff --git a/protocols/Xfire/src/socket.cpp b/protocols/Xfire/src/socket.cpp index 1863639249..5e96f5d5dc 100644 --- a/protocols/Xfire/src/socket.cpp +++ b/protocols/Xfire/src/socket.cpp @@ -24,20 +24,20 @@ extern HANDLE hNetlib; using namespace std;
-Socket::Socket( std::string host, int port, int useproxy, std::string proxyhost , int proxyport ) :
- m_sock ( -1 )
+Socket::Socket(std::string host, int port, int useproxy, std::string proxyhost, int proxyport)
+ : m_sock(-1)
{
- memset ( &m_addr,
- 0,
- sizeof ( m_addr ) );
+ memset(&m_addr,
+ 0,
+ sizeof(m_addr));
- if (!create()) {
- throw SocketException( "Could not create socket." );
- }
- if (!connect(host,port,useproxy,proxyhost,proxyport)) {
- throw SocketException( "Could not bind port." );
- }
+ if (!create()) {
+ throw SocketException("Could not create socket.");
+ }
+ if (!connect(host, port, useproxy, proxyhost, proxyport)) {
+ throw SocketException("Could not bind port.");
+ }
}
Socket::~Socket()
@@ -48,225 +48,186 @@ Socket::~Socket() bool Socket::create()
{
-/*
- m_sock = socket ( AF_INET, SOCK_STREAM, 0 );
+ /*
+ m_sock = socket ( AF_INET, SOCK_STREAM, 0 );
- if ( ! is_valid() )
- return false;*/
+ if ( ! is_valid() )
+ return false;*/
- // TIME_WAIT - argh
-// int on = 1;
- //if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
-// return false;
+ // TIME_WAIT - argh
+ // int on = 1;
+ //if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
+ // return false;
- return true;
+ return true;
}
-bool Socket::bind ( const int port )
+bool Socket::bind(const int /*port*/)
{
-/* if ( ! is_valid() )
- {
- return false;
- }
+ /* if ( ! is_valid() )
+ {
+ return false;
+ }
- m_addr.sin_family = AF_INET;
- m_addr.sin_addr.s_addr = INADDR_ANY;
- m_addr.sin_port = htons ( port );
+ m_addr.sin_family = AF_INET;
+ m_addr.sin_addr.s_addr = INADDR_ANY;
+ m_addr.sin_port = htons ( port );
- int bind_return = ::bind ( m_sock,
- ( struct sockaddr * ) &m_addr,
- sizeof ( m_addr ) );
+ int bind_return = ::bind ( m_sock,
+ ( struct sockaddr * ) &m_addr,
+ sizeof ( m_addr ) );
- if ( bind_return == -1 )
- {
- return false;
- }
-*/
- return true;
+ if ( bind_return == -1 )
+ {
+ return false;
+ }
+ */
+ return true;
}
bool Socket::listen() const
{
- /*if ( ! is_valid() )
- {
- return false;
- }
+ /*if ( ! is_valid() )
+ {
+ return false;
+ }
- int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
+ int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
- if ( listen_return == -1 )
- {
- return false;
- }
-*/
- return false;
+ if ( listen_return == -1 )
+ {
+ return false;
+ }
+ */
+ return false;
}
-bool Socket::accept ( Socket& new_socket ) const
+bool Socket::accept(Socket& /*new_socket*/) const
{
- /*int addr_length = sizeof ( m_addr );
- new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
+ /*int addr_length = sizeof ( m_addr );
+ new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
- if ( new_socket.m_sock <= 0 )
- return false;
- else
- return true;*/
+ if ( new_socket.m_sock <= 0 )
+ return false;
+ else
+ return true;*/
return false;
-
}
-bool Socket::send ( char *buf, int length ) const {
- int status = Netlib_Send(this->netlibcon,buf, length,0); //::send ( m_sock, buf, length, 0);
- if ( status == -1 )
- {
- return false;
- }
- else
- {
- return true;
- }
+bool Socket::send(char *buf, int length) const
+{
+ int status = Netlib_Send(this->netlibcon, buf, length, 0); //::send ( m_sock, buf, length, 0);
+ if (status == -1) {
+ return false;
+ }
+ else {
+ return true;
+ }
}
-bool Socket::send ( const std::string s ) const
+bool Socket::send(const std::string s) const
{
- int status = Netlib_Send(this->netlibcon,s.c_str(), s.size(),0); //::send ( m_sock, s.c_str(), s.size(), 0);
- if ( status == -1 )
- {
- return false;
- }
- else
- {
- return true;
- }
+ int status = Netlib_Send(this->netlibcon, s.c_str(), s.size(), 0); //::send ( m_sock, s.c_str(), s.size(), 0);
+ if (status == -1) {
+ return false;
+ }
+ else {
+ return true;
+ }
}
-int Socket::recv ( char *buf, int maxlen ) const {
- int status = Netlib_Recv(this->netlibcon,buf,maxlen,0); //::recv( m_sock, buf, maxlen, 0 );
+int Socket::recv(char *buf, int maxlen) const
+{
+ int status = Netlib_Recv(this->netlibcon, buf, maxlen, 0); //::recv( m_sock, buf, maxlen, 0 );
- if ( status == -1 )
- {
+ if (status == -1) {
//std::cout << "status == -1 errno == " << errno << " in Socket::recv WSA:::" << ::WSAGetLastError() << "\n";
- return 0;
- }
- return status;
+ return 0;
+ }
+ return status;
}
-int Socket::recv ( std::string& s ) const
+int Socket::recv(std::string& s) const
{
- char buf [ MAXRECV + 1 ];
-
- s = "";
-
- memset ( buf, 0, MAXRECV + 1 );
-
- int status = Netlib_Recv(this->netlibcon,buf,MAXRECV,0);//::recv ( m_sock, buf, MAXRECV, 0 );
-
- if ( status == -1 )
- {
- //std::cout << "status == -1 errno == " << errno << " in Socket::recv\n";
- return 0;
- }
- else if ( status == 0 )
- {
- return 0;
- }
- else
- {
- s = buf;
- return status;
- }
-}
+ char buf[MAXRECV + 1];
+
+ s = "";
+ memset(buf, 0, MAXRECV + 1);
+ int status = Netlib_Recv(this->netlibcon, buf, MAXRECV, 0);//::recv ( m_sock, buf, MAXRECV, 0 );
+
+ if (status == -1) {
+ //std::cout << "status == -1 errno == " << errno << " in Socket::recv\n";
+ return 0;
+ }
+ else if (status == 0) {
+ return 0;
+ }
+ else {
+ s = buf;
+ return status;
+ }
+}
-bool Socket::connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport)
+bool Socket::connect(const std::string host, const int, int, std::string, int)
{
- //if ( ! is_valid() ) return false;
-
- /*m_addr.sin_family = AF_INET;
- if (useproxy)
- {
- m_addr.sin_port = htons ( proxyport );
- m_addr.sin_addr.s_addr=inet_addr(proxyhost.c_str());
- }
- else
- {
- m_addr.sin_port = htons ( port );
- m_addr.sin_addr.s_addr=inet_addr(host.c_str());
- }
- */
-
- int status = 0; //inet_pton ( AF_INET, host.c_str(), &m_addr.sin_addr );
-
- /* XDEBUG(("Is valid .. %d\n",status));
- if ( errno == EAFNOSUPPORT ) return false; */
- //status = ::connect ( m_sock, ( sockaddr * ) &m_addr, sizeof ( m_addr ) );
-
- /*if (useproxy&&status==0) {
- char temp[1024];
- this->send("CONNECT cs.xfire.com:25999 HTTP/1.1\nHost: cs.xfire.com:25999\nUser-Agent: " + NETLIB_USER_AGENT + "\n\n");
- this->recv((char*)temp,1024);
- }*/
-
- NETLIBOPENCONNECTION ncon = { 0 };
- ncon.cbSize = sizeof(ncon);
- ncon.szHost = "cs.xfire.com";
- ncon.wPort = (WORD)atol("25999");
- ncon.timeout=5;
- netlibcon = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
-
-
- //std::cout << "status: " << status << std::endl;
- if ( netlibcon != NULL )
- {
- //CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) hNetlib, (LPARAM) & ncon);
- m_sock=CallService(MS_NETLIB_GETSOCKET,(WPARAM) netlibcon,0);
- return true;
- }
- else {
- int errsv = errno;
- if (errsv == SOCKET_ERROR) {
- // std::cout << "Connection refused to " << host << ":" << port << std::endl;
- throw SocketException( "Connection refused." );
- }
- //std::cout << "errno: " << errsv << std::endl;
- return false;
- }
+ NETLIBOPENCONNECTION ncon = { 0 };
+ ncon.cbSize = sizeof(ncon);
+ ncon.szHost = "cs.xfire.com";
+ ncon.wPort = (WORD)atol("25999");
+ ncon.timeout = 5;
+ netlibcon = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlib, (LPARAM)&ncon);
+
+ //std::cout << "status: " << status << std::endl;
+ if (netlibcon != NULL) {
+ m_sock = CallService(MS_NETLIB_GETSOCKET, (WPARAM)netlibcon, 0);
+ return true;
+ }
+ else {
+ int errsv = errno;
+ if (errsv == SOCKET_ERROR) {
+ // std::cout << "Connection refused to " << host << ":" << port << std::endl;
+ throw SocketException("Connection refused.");
+ }
+ //std::cout << "errno: " << errsv << std::endl;
+ return false;
+ }
}
-void Socket::set_non_blocking ( const bool b )
+void Socket::set_non_blocking(const bool /*b*/)
{
-/* u_long arg=0;
+ /* u_long arg=0;
- if (b) arg=1;*/
+ if (b) arg=1;*/
//ioctlsocket(m_sock, 0x8004667e,&arg);
-// int opts;
-
- /* opts = fcntl ( m_sock,
- F_GETFL );
-
- if ( opts < 0 )
- {
- return;
- }
-*/
- //if ( b )
- // opts = ( opts | O_NONBLOCK );
- /*else
- opts = ( opts & ~O_NONBLOCK );*/
-
- /*fcntl ( m_sock,
- F_SETFL,opts );*/
+ // int opts;
+
+ /* opts = fcntl ( m_sock,
+ F_GETFL );
+
+ if ( opts < 0 )
+ {
+ return;
+ }
+ */
+ //if ( b )
+ // opts = ( opts | O_NONBLOCK );
+ /*else
+ opts = ( opts & ~O_NONBLOCK );*/
+
+ /*fcntl ( m_sock,
+ F_SETFL,opts );*/
}
diff --git a/protocols/Xfire/src/socket.h b/protocols/Xfire/src/socket.h index 17fdd46bc6..58e287ec42 100644 --- a/protocols/Xfire/src/socket.h +++ b/protocols/Xfire/src/socket.h @@ -19,41 +19,36 @@ const int MAXRECV = 500; class Socket { - public: - //proxy hinzugefügt dufte - Socket( std::string host, int port,int useproxy = 0,std::string proxyhost = " ", int proxyport = 0 ); - virtual ~Socket(); +public: + //proxy hinzugefügt dufte + Socket( std::string host, int port,int useproxy = 0,std::string proxyhost = " ", int proxyport = 0 ); + virtual ~Socket(); - // Server initialization - bool create(); - bool bind ( const int port ); - bool listen() const; - bool accept ( Socket& ) const; + // Server initialization + bool create(); + bool bind ( const int port ); + bool listen() const; + bool accept ( Socket& ) const; - // Client initialization - bool connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport); + // Client initialization + bool connect ( const std::string host, const int port, int useproxy,std::string proxyhost,int proxyport); - // Data Transimission - bool send ( char *buf, int length ) const; - bool send ( const std::string ) const; - int recv ( std::string& ) const; - int recv ( char *buf, int maxlen ) const; + // Data Transimission + bool send ( char *buf, int length ) const; + bool send ( const std::string ) const; + int recv ( std::string& ) const; + int recv ( char *buf, int maxlen ) const; - void set_non_blocking ( const bool ); + void set_non_blocking ( const bool ); - bool is_valid() const { return true; } - - int m_sock; - - private: - - - sockaddr_in m_addr; - HANDLE netlibcon; + bool is_valid() const { return true; } + int m_sock; +private: + sockaddr_in m_addr; + HANDLE netlibcon; }; - #endif diff --git a/protocols/Xfire/src/socketexception.h b/protocols/Xfire/src/socketexception.h index dc506aeaf7..ffe5d49368 100644 --- a/protocols/Xfire/src/socketexception.h +++ b/protocols/Xfire/src/socketexception.h @@ -26,19 +26,17 @@ #ifndef SocketException_class #define SocketException_class -#include <string> - class SocketException { - public: - SocketException ( std::string s ) : m_s ( s ) {}; - ~SocketException (){}; +public: + SocketException ( std::string s ) : m_s ( s ) {}; + ~SocketException (){}; - std::string description() { return m_s; } + std::string description() { return m_s; } - private: +private: - std::string m_s; + std::string m_s; }; diff --git a/protocols/Xfire/src/stdafx.h b/protocols/Xfire/src/stdafx.h index f6cd6313c2..2b5ec68d7f 100644 --- a/protocols/Xfire/src/stdafx.h +++ b/protocols/Xfire/src/stdafx.h @@ -7,10 +7,12 @@ #include <sys/types.h>
#include <stdio.h>
-#include <cstdlib>
#include <tchar.h>
+
+#include <cstdlib>
#include <iostream>
#include <string>
+#include <vector> #define uint unsigned int
#define socklen_t int
diff --git a/protocols/Xfire/src/tools.cpp b/protocols/Xfire/src/tools.cpp index a38a70fe82..3f33a9e45b 100644 --- a/protocols/Xfire/src/tools.cpp +++ b/protocols/Xfire/src/tools.cpp @@ -33,24 +33,7 @@ #include "xdebug.h" extern HANDLE hNetlib; -//convert buf to hexstring -/*char* tohex(unsigned char*buf,int size) { - static char buffer[1024*10]=""; - mir_strcpy(buffer,""); - - for(int i=0;i<size;i++) - { - if (i%16==0&&i!=0) - mir_snprintf(buffer, "%s\n%02x ", buffer, buf[i]); - else - mir_snprintf(buffer, "%s%02x ", buffer, buf[i]); - } - - return buffer; - }*/ - -//von icqproto kopiert void EnableDlgItem(HWND hwndDlg, UINT control, int state) { EnableWindow(GetDlgItem(hwndDlg, control), state); @@ -63,8 +46,7 @@ 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[mir_strlen(src) + mir_strlen(rep) + 1]; mir_strcpy(temp, src); @@ -82,7 +64,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, LPCSTR lpText, LPCSTR lpCaption, UINT uType, HICON hicon) { static signed char bUsePopups = -1; static BOOL bIconsNotLoaded = TRUE; @@ -128,7 +110,6 @@ int displayPopup(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, HICON h char*menuitemtext(char*mtext) { static char temp[256] = ""; - int anz = 0; int j = 0; if (!mtext) @@ -140,11 +121,9 @@ char*menuitemtext(char*mtext) 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] == '&') - { + if (mtext[i] == '&') { j++; temp[j] = '&'; } @@ -157,8 +136,7 @@ char*menuitemtext(char*mtext) void Message(LPVOID msg) { - switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) - { + switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) { case 1: return; case 2: @@ -184,11 +162,9 @@ void Message(LPVOID msg) void MessageE(LPVOID msg) { static BOOL already = FALSE; - switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) - { + switch (db_get_b(NULL, protocolname, "nomsgbox", 0)) { case 0: - if (!already) - { + if (!already) { already = TRUE; //keine doppelte fehlernachrichten Message(msg); already = FALSE; @@ -211,12 +187,10 @@ char* GetLaunchPath(char*launch) if (launch == NULL) return temp; - strncpy(temp, launch, XFIRE_MAX_STATIC_STRING_LEN -1); + strncpy(temp, launch, XFIRE_MAX_STATIC_STRING_LEN - 1); - while (*p != 0 && *f != 0) - { - if (tolower(*p) == *f) - { + while (*p != 0 && *f != 0) { + if (tolower(*p) == *f) { f++; } else @@ -225,15 +199,13 @@ char* GetLaunchPath(char*launch) p++; } - if (*f == 0) - { + if (*f == 0) { *p = 0; } else return temp; - if (strrchr(temp, '\\')) - { + if (strrchr(temp, '\\')) { *(strrchr(temp, '\\')) = 0; } @@ -255,7 +227,8 @@ unsigned short r(unsigned short data) } //simple und hoffetnlich schnelle teamspeakdetection -BOOL FindTeamSpeak(DWORD*pid, int*vid) { +BOOL FindTeamSpeak(DWORD*pid, int*vid) +{ BOOL found = FALSE; if (pid == NULL) return FALSE; @@ -267,13 +240,11 @@ BOOL FindTeamSpeak(DWORD*pid, int*vid) { // XFireLog("Scanning for voiceprograms..."); - while (Process32Next(hSnapShot, processInfo) != FALSE) - { + while (Process32Next(hSnapShot, processInfo) != FALSE) { if (processInfo->th32ProcessID != 0) { int size = mir_tstrlen(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'&& @@ -282,16 +253,14 @@ BOOL FindTeamSpeak(DWORD*pid, int*vid) { processInfo->szExeFile[5] == 'p'&& processInfo->szExeFile[6] == 'e'&& processInfo->szExeFile[7] == 'a'&& - processInfo->szExeFile[8] == 'k') - { + processInfo->szExeFile[8] == 'k') { *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'&& @@ -299,23 +268,20 @@ BOOL FindTeamSpeak(DWORD*pid, int*vid) { processInfo->szExeFile[4] == 'r'&& processInfo->szExeFile[5] == 'i'&& processInfo->szExeFile[6] == 'l'&& - processInfo->szExeFile[7] == 'o') - { + processInfo->szExeFile[7] == 'o') { *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') - { + processInfo->szExeFile[5] == 'e') { *pid = processInfo->th32ProcessID; found = TRUE; *vid = 34; @@ -328,12 +294,10 @@ BOOL FindTeamSpeak(DWORD*pid, int*vid) { return found; } -#include <vector> - #define maxuppackets 4 //funktion liefer ip/port einer verbindung -BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*ip1, char*ip2, char*ip3, char*ip4, long*port) +BOOL GetServerIPPort(DWORD pid, char*, unsigned long localaddr, char*ip1, char*ip2, char*ip3, char*ip4, long*port) { static std::vector<int> localport; static const int hdrInclude = 1; @@ -343,8 +307,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //DUMP("***Suche IP/Port***",""); - if (pid != lastpid) - { + if (pid != lastpid) { lastip = lastport = 0; lastpid = pid; } @@ -357,11 +320,9 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i 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++) - { + for (unsigned int i = 0; i < ptab->dwNumEntries; i++) { if (ptab->table[i].dwOwningPid == pid) //spiel gefunden { localport.push_back(ptab->table[i].dwLocalPort); @@ -378,8 +339,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i return FALSE; //dann erstmal schluss } } - else - { + else { XFireLog("GetExtendedUdpTable error!"); return FALSE; } @@ -390,8 +350,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //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()); closesocket(s); @@ -405,8 +364,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i msockaddr.sin_port = 0; //socket an nw binden - if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) - { + if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) { //DUMP("Kann Rawsocket nicht binden. Error: %d",WSAGetLastError()); XFireLog("unable to bind raw socket %d", WSAGetLastError()); closesocket(s); @@ -416,8 +374,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //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;*/ @@ -428,13 +385,13 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //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)) - { + if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout) == SOCKET_ERROR)) { XFireLog("setsockopt(SO_RCVTIMEO) error %d", WSAGetLastError()); } //updstruct, nur mit wichtigen sachen - struct mpacket { + struct mpacket + { unsigned char ipv; char dmp[11]; //dummy //srcip, serverip @@ -446,7 +403,8 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i unsigned int ipdst; char temp[1024]; }; - struct mpacket2 { + struct mpacket2 + { unsigned char ipv; char dmp[11]; //dummy //srcip, serverip @@ -458,7 +416,8 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i unsigned char ip4; char temp[1024]; }; - struct udp { + struct udp + { //srcport u_short srcport; //dstport @@ -473,8 +432,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i for (int I = 0; I < maxuppackets; I++) //maximal 4 packete, das reicht { int msize = recv(s, (char*)&temp, sizeof(mpacket), 0); - if (msize == SOCKET_ERROR) - { + if (msize == SOCKET_ERROR) { XFireLog("recv() error %d", WSAGetLastError()); } else if (msize) //empfangen @@ -496,8 +454,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i 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 @@ -511,8 +468,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //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; closesocket(s); @@ -545,7 +501,7 @@ BOOL GetServerIPPort(DWORD pid, char*localaddrr, unsigned long localaddr, char*i //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*, unsigned long localaddr, char*ip1, char*ip2, char*ip3, char*ip4, long*port) { static std::vector<int> localport; static const int hdrInclude = 1; @@ -553,8 +509,7 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* static int lastpid = 0; static int lastport = 0; - if (pid != lastpid) - { + if (pid != lastpid) { lastip = lastport = 0; lastpid = pid; } @@ -567,11 +522,9 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* 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++) - { + for (unsigned int i = 0; i < ptab->dwNumEntries; i++) { if (ptab->table[i].dwOwningPid == pid) //spiel gefunden { localport.push_back(ptab->table[i].dwLocalPort); @@ -582,8 +535,7 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* } if (notfound) //kein port gefunden { - if (lastip != 0) - { + if (lastip != 0) { lastip = 0; lastport = 0; return TRUE; @@ -608,8 +560,7 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* msockaddr.sin_port = 0; //socket an nw binden - if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) - { + if (bind(s, (sockaddr *)&msockaddr, sizeof(msockaddr)) == SOCKET_ERROR) { closesocket(s); return FALSE; } @@ -617,8 +568,7 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* //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;*/ //unter bestimmten umständen schlägt es hier fehl, dann lass trotzdem ip weiter erkennen @@ -630,7 +580,8 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)); //updstruct, nur mit wichtigen sachen - struct mpacket { + struct mpacket + { unsigned char ipv; char dmp[11]; //dummy //srcip, serverip @@ -642,7 +593,8 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* unsigned int ipdst; char temp[1024]; }; - struct mpacket2 { + struct mpacket2 + { unsigned char ipv; char dmp[11]; //dummy //srcip, serverip @@ -654,7 +606,8 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* unsigned char ip4; char temp[1024]; }; - struct udp { + struct udp + { //srcport u_short srcport; //dstport @@ -679,21 +632,20 @@ BOOL GetServerIPPort2(DWORD pid, char*localaddrr, unsigned long localaddr, char* 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 + *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; - } + 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 { @@ -719,10 +671,8 @@ char * getItem(char * string, char delim, int count) static char item[255]; char i = 0; - while (*string != '\0'&&count > 0) - { - if (*string == delim) - { + while (*string != '\0'&&count > 0) { + if (*string == delim) { item[i] = 0; i = 0; count--; @@ -739,8 +689,7 @@ char * getItem(char * string, char delim, int count) if (count > 1) item[0] = 0; - for (unsigned int i = 0; i < mir_strlen(item); i++) - { + for (unsigned int i = 0; i < mir_strlen(item); i++) { item[i] = tolower(item[i]); } @@ -775,20 +724,16 @@ 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(hNt, "ZwQueryInformationProcess"); - if (_ZwQueryInformationProcess == NULL) - { + if (_ZwQueryInformationProcess == NULL) { LocalFree(UserPool); return TRUE; } } - if (_ZwReadVirtualMemory == NULL) - { + if (_ZwReadVirtualMemory == NULL) { _ZwReadVirtualMemory = (pZwReadVirtualMemory)GetProcAddress(hNt, "ZwReadVirtualMemory"); - if (_ZwReadVirtualMemory == NULL) - { + if (_ZwReadVirtualMemory == NULL) { LocalFree(UserPool); return TRUE; } @@ -810,8 +755,7 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain pBaseAddress = proc_params->CommandLine.Buffer; //keine commandline?! - if (uSize == 0 || pBaseAddress == NULL) - { + if (uSize == 0 || pBaseAddress == NULL) { LocalFree(UserPool); return FALSE; } @@ -823,8 +767,7 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain //in ansi umwandeln int correctsize = WideCharToMultiByte(CP_OEMCP, 0, buffer, -1, NULL, 0, NULL, NULL); - if (correctsize == 0) - { + if (correctsize == 0) { LocalFree(UserPool); return FALSE; } @@ -834,8 +777,7 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain buffer2[correctsize - 1] = 0; - for (unsigned int i = 0; i < mir_strlen(buffer2); i++) - { + for (unsigned int i = 0; i < mir_strlen(buffer2); i++) { buffer2[i] = tolower(buffer2[i]); } @@ -851,49 +793,46 @@ BOOL checkCommandLine(HANDLE hProcess, char * mustcontain, char * mustnotcontain 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; } - else - { + else { delete[] buffer; delete[] buffer2; LocalFree(UserPool); return FALSE; } - int count = 1; - if (mustnotcontain) - { - char*str = getItem(mustnotcontain, ';', count); - do { - if (cmdline.find(str) != string::npos) - { - delete[] buffer; - delete[] buffer2; - LocalFree(UserPool); - return FALSE; - } - count++; - str = getItem(mustnotcontain, ';', count); - } while (*str != 0); - } + int count = 1; + if (mustnotcontain) { + char*str = getItem(mustnotcontain, ';', count); + do { + if (cmdline.find(str) != string::npos) { + delete[] buffer; + delete[] buffer2; + LocalFree(UserPool); + return FALSE; + } + count++; + str = getItem(mustnotcontain, ';', count); + } while (*str != 0); + } - //_ZwClose(hProcess); - LocalFree(UserPool); - delete[] buffer; - delete[] buffer2; + //_ZwClose(hProcess); + LocalFree(UserPool); + delete[] buffer; + delete[] buffer2; - return TRUE; + return TRUE; } #define RECV_BUFFER_SIZE 6144 -BOOL CheckWWWContent(char*address) { +BOOL CheckWWWContent(char*address) +{ Netlib_Logf(hNetlib, "Check Url %s ...", address); //netlib request @@ -921,11 +860,10 @@ BOOL CheckWWWContent(char*address) { } -BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf, unsigned int* size) { - if (dontoverwrite == TRUE) - { - if (GetFileAttributesA(filename) != 0xFFFFFFFF) - { +BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf, unsigned int* size) +{ + if (dontoverwrite == TRUE) { + if (GetFileAttributesA(filename) != 0xFFFFFFFF) { Netlib_Logf(hNetlib, "%s already exists, no overwrite.", filename); return TRUE; } @@ -949,19 +887,15 @@ BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf return FALSE; } //keine daten für mich - else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) - { + else if (nlhrReply->dataLength < 1 || nlhrReply->pData == NULL) { Netlib_Logf(hNetlib, "No data received."); CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); return FALSE; } - else - { - if (tobuf == NULL) - { + else { + if (tobuf == NULL) { FILE * f = fopen(filename, "wb"); - if (f == NULL) - { + if (f == NULL) { Netlib_Logf(hNetlib, "Cannot open %s for binary write mode.", filename); CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); return FALSE; @@ -969,10 +903,8 @@ BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf fwrite(nlhrReply->pData, nlhrReply->dataLength, 1, f); fclose(f); } - else - { - if (*tobuf == NULL) - { + else { + if (*tobuf == NULL) { *tobuf = new char[nlhrReply->dataLength + 1]; memcpy_s(*tobuf, nlhrReply->dataLength, nlhrReply->pData, nlhrReply->dataLength); //0 terminieren @@ -985,15 +917,15 @@ BOOL GetWWWContent2(char*address, char*filename, BOOL dontoverwrite, char**tobuf } CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } - else - { + else { Netlib_Logf(hNetlib, "No valid Netlib Request.", filename); return FALSE; } return TRUE; } //eigener www downloader, da winet exceptions erzeugt -BOOL GetWWWContent(char*host, char* request, char*filename, BOOL dontoverwrite) { +BOOL GetWWWContent(char*host, char* request, char*filename, BOOL dontoverwrite) +{ char add[1024] = "http://"; mir_strcat(add, host); mir_strcat(add, request); @@ -1013,11 +945,11 @@ unsigned int getfilesize(char*path) } //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) { +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 = mir_strlen(lpFileName); - if (size > 15) - { + if (size > 15) { char*file = (char*)lpFileName; int ret = 0; *(file + size - 14) = 'u'; @@ -1026,25 +958,21 @@ DWORD xfire_GetPrivateProfileString(__in LPCSTR lpAppName, __in LPCSTR lpKey *(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); } -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: @@ -1053,6 +981,4 @@ BOOL mySleep(int ms, HANDLE evt) { default: return TRUE; } - - return FALSE; -}
\ No newline at end of file +} diff --git a/protocols/Xfire/src/tools.h b/protocols/Xfire/src/tools.h index 7b25e956bf..22db7abe62 100644 --- a/protocols/Xfire/src/tools.h +++ b/protocols/Xfire/src/tools.h @@ -5,7 +5,7 @@ #include "baseProtocol.h"
#include <m_popup.h>
-#include <string>
+
using std::string;
//****************************
@@ -25,14 +25,14 @@ typedef struct _PEB_LDR_DATA { PVOID Reserved2[3];
LIST_ENTRY InMemoryOrderModuleList;
} PEB_LDR_DATA,
-*PPEB_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;
+ *PRTL_USER_PROCESS_PARAMETERS;
typedef struct _PEB {
BYTE Reserved1[2];
BYTE BeingDebugged;
@@ -47,7 +47,7 @@ typedef struct _PEB { PVOID Reserved7[1];
ULONG SessionId;
} PEB,
-*PPEB;
+ *PPEB;
typedef struct
{
ULONG AllocationSize;
diff --git a/protocols/Xfire/src/userdetails.cpp b/protocols/Xfire/src/userdetails.cpp index 49e2cd2875..aa4de637c3 100644 --- a/protocols/Xfire/src/userdetails.cpp +++ b/protocols/Xfire/src/userdetails.cpp @@ -30,7 +30,6 @@ #include "baseProtocol.h"
#include "Xfire_gamelist.h"
-#include <string>
HWND ghwndDlg = NULL;
extern HANDLE XFireWorkingFolder;
@@ -38,20 +37,20 @@ extern Xfire_gamelist xgamelist; //als funktion, damit es per thread geladen werden kann
-void LoadProfilStatus(void *arg) {
- char *fname = (char*) arg;
+void LoadProfilStatus(void *arg)
+{
+ char *fname = (char*)arg;
if (!fname || !ghwndDlg)
return;
//dl
char url[255];
- mir_snprintf(url, _countof(url),"http://miniprofile.xfire.com/bg/sh/type/1/%s.png",fname);
+ mir_snprintf(url, _countof(url), "http://miniprofile.xfire.com/bg/sh/type/1/%s.png", fname);
char* buf = NULL;
unsigned int size = 0;
//versuche das icon aus dem inet zulasen
- if (GetWWWContent2(url, NULL, FALSE, &buf, &size))
- {
+ if (GetWWWContent2(url, NULL, FALSE, &buf, &size)) {
//aus dem buffer ein hicon erzeugen
HBITMAP hbitmap = xgamelist.createHBITMAPfromdata(buf, size);
//speicher freigeben
@@ -65,21 +64,18 @@ void SetItemTxt(HWND hwndDlg, int feldid, char*feld, MCONTACT hcontact, int type {
DBVARIANT dbv;
if (!db_get(hcontact, protocolname, feld, &dbv)) {
- if (type == 1)
- {
+ if (type == 1) {
char temp[255];
mir_snprintf(temp, _countof(temp), "%i", dbv.wVal);
SetDlgItemTextA(hwndDlg, feldid, temp);
}
- else
- {
+ else {
SetDlgItemTextA(hwndDlg, feldid, dbv.pszVal);
}
db_free(&dbv);
EnableDlgItem(hwndDlg, feldid, TRUE);
}
- else
- {
+ else {
SetDlgItemText(hwndDlg, feldid, TranslateT("<not specified>"));
EnableDlgItem(hwndDlg, feldid, FALSE);
}
@@ -140,10 +136,8 @@ void setGameInfo(HWND listbox, char *mbuf) memset(&lvitem, 0, sizeof(lvitem));
lvitem.mask = LVIF_TEXT;
- while (*mbuf2 != 0)
- {
- if (*mbuf2 == 1 && mod == 0)
- {
+ while (*mbuf2 != 0) {
+ if (*mbuf2 == 1 && mod == 0) {
temp[ii] = 0;
mod = 1;
lvitem.iItem = item;
@@ -153,8 +147,7 @@ void setGameInfo(HWND listbox, char *mbuf) item++;
ii = -1;
}
- else if (*mbuf2 == 2 && mod == 1)
- {
+ else if (*mbuf2 == 2 && mod == 1) {
temp[ii] = 0;
mod = 0;
lvitem.iSubItem++;
@@ -179,61 +172,47 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam static HWND listbox;
LVCOLUMNA pcol;
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
TranslateDialogDefault(hwndDlg);
-
- ghwndDlg = hwndDlg;
-
- listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST);
- pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
- pcol.pszText = "Key";
- pcol.cx = 65;
- pcol.fmt = LVCFMT_LEFT;
- SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol);
- pcol.cx = 80;
- pcol.pszText = "Value";
- SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol);
-
- HFONT hFont;
- LOGFONT lfFont;
-
- memset(&lfFont, 0x00, sizeof(lfFont));
- memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
-
- lfFont.lfHeight = 13;
- lfFont.lfWeight = FW_BOLD;
- lfFont.lfCharSet = ANSI_CHARSET;
- lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lfFont.lfQuality = DEFAULT_QUALITY;
-
- // Create the font from the LOGFONT structure passed.
- hFont = CreateFontIndirect(&lfFont);
-
- SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE);
-
+ {
+ ghwndDlg = hwndDlg;
+
+ listbox = GetDlgItem(hwndDlg, IDC_GAMEINFOLIST);
+ pcol.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;
+ pcol.pszText = "Key";
+ pcol.cx = 65;
+ pcol.fmt = LVCFMT_LEFT;
+ SendMessageA(listbox, LVM_INSERTCOLUMNA, 1, (LPARAM)&pcol);
+ pcol.cx = 80;
+ pcol.pszText = "Value";
+ SendMessageA(listbox, LVM_INSERTCOLUMNA, 2, (LPARAM)&pcol);
+
+ HFONT hFont;
+ LOGFONT lfFont;
+
+ memset(&lfFont, 0x00, sizeof(lfFont));
+ memcpy(lfFont.lfFaceName, TEXT("Arial"), 8);
+
+ lfFont.lfHeight = 13;
+ lfFont.lfWeight = FW_BOLD;
+ lfFont.lfCharSet = ANSI_CHARSET;
+ lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lfFont.lfQuality = DEFAULT_QUALITY;
+
+ // Create the font from the LOGFONT structure passed.
+ hFont = CreateFontIndirect(&lfFont);
+
+ SendMessageA(listbox, WM_SETFONT, (WPARAM)hFont, TRUE);
+ }
return TRUE;
- }
- case WM_CTLCOLORSTATIC:
- {
- break;
- }
case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
-
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
-
+ switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
- {
char* szProto;
MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
uhandle = hContact; //handle sichern
@@ -249,15 +228,12 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam //alle items aus der liste entfernen
SendMessage(listbox, LVM_DELETEALLITEMS, 0, 0);
- if (hContact)
- {
+ if (hContact) {
DBVARIANT dbv;
- if (!db_get(hContact, protocolname, "Username", &dbv))
- {
+ if (!db_get(hContact, protocolname, "Username", &dbv)) {
int usernamesize = mir_strlen(dbv.pszVal) + 1;
char* username = new char[usernamesize];
- if (username)
- {
+ if (username) {
strcpy_s(username, usernamesize, dbv.pszVal);
mir_forkthread(LoadProfilStatus, (LPVOID)username);
}
@@ -265,8 +241,7 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam db_free(&dbv);
}
- if (!db_get(hContact, protocolname, "GameInfo", &dbv))
- {
+ if (!db_get(hContact, protocolname, "GameInfo", &dbv)) {
setGameInfo(listbox, dbv.pszVal);
db_free(&dbv);
}
@@ -288,135 +263,43 @@ static INT_PTR CALLBACK DlgProcUserDetails(HWND hwndDlg, UINT msg, WPARAM wParam SetItemTxt(hwndDlg, IDC_VNAME, "RVoice", hContact, 0);
//render icons
- {
- DBVARIANT dbv;
-
- if (!db_get(hContact, protocolname, "GameId", &dbv))
- {
- SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
- db_free(&dbv);
- }
- if (!db_get(hContact, protocolname, "VoiceId", &dbv))
- {
- SendDlgItemMessage(hwndDlg, IDC_VOICEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
- db_free(&dbv);
- }
-
- if (db_get(hContact, protocolname, "ServerIP", &dbv))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE);
- db_free(&dbv);
- }
- if (db_get(hContact, protocolname, "VServerIP", &dbv))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE);
- db_free(&dbv);
- }
+ if (!db_get(hContact, protocolname, "GameId", &dbv)) {
+ SendDlgItemMessage(hwndDlg, IDC_GAMEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
+ db_free(&dbv);
+ }
+ if (!db_get(hContact, protocolname, "VoiceId", &dbv)) {
+ SendDlgItemMessage(hwndDlg, IDC_VOICEICO, STM_SETICON, (WPARAM)xgamelist.iconmngr.getGameIcon(dbv.wVal), 0);
+ db_free(&dbv);
+ }
- //ShowWindow(GetDlgItem(hwndDlg,IDC_VOICEICO),FALSE)
+ if (db_get(hContact, protocolname, "ServerIP", &dbv)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPYGAME), FALSE);
+ db_free(&dbv);
+ }
+ if (db_get(hContact, protocolname, "VServerIP", &dbv)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COPYVOICE), FALSE);
+ db_free(&dbv);
}
}
}
- break;
- }
- }
- break;
}
- }
break;
+
case WM_COMMAND:
- {
- switch (wParam)
{
- case IDC_COPYGAME:
- GetIPPortUDetails(uhandle, "ServerIP", "Port");
- break;
- case IDC_COPYVOICE:
- GetIPPortUDetails(uhandle, "VServerIP", "VPort");
- break;
+ switch (wParam) {
+ case IDC_COPYGAME:
+ GetIPPortUDetails(uhandle, "ServerIP", "Port");
+ break;
+ case IDC_COPYVOICE:
+ GetIPPortUDetails(uhandle, "VServerIP", "VPort");
+ break;
+ }
}
}
- }
return FALSE;
}
-/*static BOOL CALLBACK DlgProcUserDetails2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-char profil[2056]="";
-switch (msg)
-{
-case WM_INITDIALOG:
-{
-return TRUE;
-}
-case WM_NOTIFY:
-{
-switch (((LPNMHDR)lParam)->idFrom)
-{
-case 0:
-{
-switch (((LPNMHDR)lParam)->code)
-{
-case PSN_INFOCHANGED:
-{
-char* szProto;
-MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
-
-if (hContact == NULL)
-szProto = protocolname;
-else
-szProto = GetContactProto(hContact);
-
-if (szProto == NULL)
-break;
-
-if (hContact) {
-DBVARIANT dbv;
-
-char img[256]="";
-char username[256]="";
-char nick[256]="";
-char status[256]="";
-char game[512]="";
-if (!db_get(hContact,"ContactPhoto","File",&dbv))
-{
-mir_snprintf(img,_countof(img),"<img src=\"%s\">",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"Username",&dbv))
-{
-mir_snprintf(username,_countof(username),"<b>Username:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"Nick",&dbv))
-{
-mir_snprintf(nick,_countof(nick),"<b>Nick:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"XStatusMsg",&dbv))
-{
-mir_snprintf(status,_countof(status),"<b>Status:</b> %s<br>",dbv.pszVal);
-db_free(&dbv);
-}
-if (!db_get(hContact,protocolname,"RGame",&dbv))
-{
-mir_snprintf(game,_countof(game),"<fieldset style='border:1px solid #0091d5;background-color:#0d2c3e;margin-bottom:8px;'><legend>Spiel</legend><table><tr><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'><b><u>%s</u></b></td></tr></table></fieldset>",dbv.pszVal);
-db_free(&dbv);
-}
-mir_snprintf(profil,_countof(profil),"mshtml:<div style='position:absolute;top:0;left:0;border:1px solid #0091d5;background-color:#000;padding:6px;width:334px;height:249px'><table><tr><td valign=top>%s</td><td valign=top style='font-family:Arial;font-size:11px;color:#fff;'>%s%s%s</td></tr><tr><td valign=top colspan=\"2\" style='font-family:Arial;font-size:11px;color:#fff;'>%s%s</td></tr></table></div>",img,username,nick,status,game);
-HWND hWnd = ::CreateWindow("AtlAxWin", profil,
-WS_CHILD|WS_VISIBLE, 0, 0, 334, 249, hwndDlg, NULL,
-::GetModuleHandle(NULL), NULL);
-}
-}
-}
-}
-}
-}
-}
-return FALSE;
-}*/
-
int OnDetailsInit(WPARAM wParam, LPARAM lParam)
{
if (!IsXFireContact(lParam))
diff --git a/protocols/Xfire/src/variables.cpp b/protocols/Xfire/src/variables.cpp index e77c4e22b2..e3b7eabedc 100644 --- a/protocols/Xfire/src/variables.cpp +++ b/protocols/Xfire/src/variables.cpp @@ -2,7 +2,6 @@ #include "stdafx.h"
#include "variables.h"
-#include <string>
extern HANDLE XFireWorkingFolder, XFireIconFolder, XFireAvatarFolder;
@@ -13,16 +12,13 @@ char* Varxfiregame(ARGUMENTSINFO *ai) if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact == NULL)
- {
+ if (ai->fi->hContact == NULL) {
//
}
- else
- {
+ else {
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);
db_free(&dbv3);
return mir_strdup(temp);
@@ -39,8 +35,7 @@ char* Varmyxfiregame(ARGUMENTSINFO *ai) return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL, protocolname, "currentgamename", &dbv3))
- {
+ if (!db_get(NULL, protocolname, "currentgamename", &dbv3)) {
char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
@@ -55,8 +50,7 @@ char* Varxfirevoice(ARGUMENTSINFO *ai) 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);
db_free(&dbv3);
return ret;
@@ -67,13 +61,13 @@ char* Varxfirevoice(ARGUMENTSINFO *ai) }
-char* Varmyxfirevoiceip(ARGUMENTSINFO *ai) {
+char* Varmyxfirevoiceip(ARGUMENTSINFO *ai)
+{
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);
db_free(&dbv3);
return ret;
@@ -83,13 +77,13 @@ char* Varmyxfirevoiceip(ARGUMENTSINFO *ai) { return mir_strdup("");
}
-char* Varmyxfireserverip(ARGUMENTSINFO *ai) {
+char* Varmyxfireserverip(ARGUMENTSINFO *ai)
+{
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);
db_free(&dbv3);
return ret;
@@ -99,15 +93,15 @@ char* Varmyxfireserverip(ARGUMENTSINFO *ai) { return mir_strdup("");
}
-char* Varxfireserverip(ARGUMENTSINFO *ai) {
+char* Varxfireserverip(ARGUMENTSINFO *ai)
+{
if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
if (ai->fi->hContact != NULL) {
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, _countof(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "Port", 0));
db_free(&dbv3);
return mir_strdup(temp);
@@ -118,21 +112,19 @@ char* Varxfireserverip(ARGUMENTSINFO *ai) { return mir_strdup("");
}
-char* Varxfirevoiceip(ARGUMENTSINFO *ai) {
+char* Varxfirevoiceip(ARGUMENTSINFO *ai)
+{
if (ai->cbSize < sizeof(ARGUMENTSINFO))
return NULL;
- if (ai->fi->hContact == NULL)
- {
+ if (ai->fi->hContact == NULL) {
ai->flags = AIF_FALSE;
return mir_strdup("");
}
- else
- {
+ else {
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, _countof(temp), "%s:%d", dbv3.pszVal, db_get_w(ai->fi->hContact, protocolname, "VPort", 0));
db_free(&dbv3);
return mir_strdup(temp);
@@ -148,8 +140,7 @@ char* Varmyxfirevoice(ARGUMENTSINFO *ai) return NULL;
DBVARIANT dbv3;
- if (!db_get(NULL, protocolname, "currentvoicename", &dbv3))
- {
+ if (!db_get(NULL, protocolname, "currentvoicename", &dbv3)) {
char* ret = mir_strdup(dbv3.pszVal);
db_free(&dbv3);
return ret;
@@ -161,14 +152,14 @@ char* Varmyxfirevoice(ARGUMENTSINFO *ai) char* XFireGetFoldersPath(char * pathtype)
{// Get XFire folder path
static char path[1024]; path[0] = 0;
- if (ServiceExists(MS_FOLDERS_REGISTER_PATH)){
- if (!mir_strcmp(pathtype, "Avatar")){
+ if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
+ if (!mir_strcmp(pathtype, "Avatar")) {
FoldersGetCustomPath(XFireAvatarFolder, path, 1024, "");
}
- if (!mir_strcmp(pathtype, "IniFile")){
+ if (!mir_strcmp(pathtype, "IniFile")) {
FoldersGetCustomPath(XFireWorkingFolder, path, 1024, "");
}
- if (!mir_strcmp(pathtype, "IconsFile")){
+ if (!mir_strcmp(pathtype, "IconsFile")) {
FoldersGetCustomPath(XFireIconFolder, path, 1024, "");
}
mir_strcat(path, "\\");
@@ -183,8 +174,8 @@ char* XFireGetFoldersPath(char * pathtype) mir_strcat(BaseFolder, "\\");
CallService(MS_DB_GETPROFILENAME, (WPARAM)MAX_PATH, (LPARAM)CurProfileF);
int i;
- for (i = MAX_PATH - 1; i > 5; i--){
- if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.'){
+ for (i = MAX_PATH - 1; i > 5; i--) {
+ if (CurProfileF[i] == 't' && CurProfileF[i - 3] == '.') {
i -= 3;
break;
}
@@ -195,7 +186,7 @@ char* XFireGetFoldersPath(char * pathtype) mir_strcat(BaseFolder, "XFire");
mir_strcat(BaseFolder, "\\");
/*******BASE********/
- if (!mir_strcmp(pathtype, "Avatar")){
+ if (!mir_strcmp(pathtype, "Avatar")) {
mir_strcat(BaseFolder, "Avatars");
mir_strcat(BaseFolder, "\\");
}
diff --git a/protocols/Xfire/src/variablevalue.cpp b/protocols/Xfire/src/variablevalue.cpp index 0de417cffd..6d3050da34 100644 --- a/protocols/Xfire/src/variablevalue.cpp +++ b/protocols/Xfire/src/variablevalue.cpp @@ -22,184 +22,171 @@ #include "stdafx.h" -#include <string> #include "variablevalue.h" #include "xdebug.h" #include "math.h" // for pow(..) -namespace xfirelib { - using namespace std; - VariableValue::VariableValue() { - value = 0; - } - VariableValue::~VariableValue() { - if (value) - delete[] value; - } - - void VariableValue::setName(std::string name){ - this->name = name; - } - - void VariableValue::setValueLength(int valueLength){ - this->valueLength = valueLength; - } - - void VariableValue::setValue( char * value) { - if (this->value) delete[] this->value; - this->value = value; - } - void VariableValue::setValue( std::string value ) { - const char *val = value.c_str(); - setValue( val, value.length() ); - } - void VariableValue::setValue( const char *value, int valueLength ) { - this->value = new char[valueLength]; - memcpy( this->value, value, valueLength ); - this->valueLength = valueLength; - } - void VariableValue::setValueFromLong( long value, int bytes ) { - this->valueLength = bytes; - this->value = new char[bytes]; - for(int i = 0 ; i < bytes ; i++) { - this->value[i] = value % 256; - value = value / 256; - } - } - - std::string VariableValue::getName(){ - return name; - } - - int VariableValue::getValueLength(){ - return valueLength; - } - - char* VariableValue::getValue(){ - return value; - } - - long VariableValue::getValueAsLong() { - long intVal = 0; - for(int i = 0 ; i < valueLength ; i++) { - intVal += ((unsigned char)value[i]) * myPow(256,i); - } - return intVal; - } - - long VariableValue::myPow(int x, int y) { - long r = 1; - for(int i = 0 ; i < y ; i++) r *= x; - return r; - } - - int VariableValue::readName(char *packet, int index) { - int read = 0; - int nameLength = packet[index]; - read++; - char* namestr=new char[nameLength+1]; - namestr[nameLength]=0; - memcpy(namestr,packet+index+read,nameLength); - name = string(namestr); - read+=nameLength; - delete[] namestr; - return read; - } - - int VariableValue::readValue(char *packet, int index, int length,int ignoreZeroAfterLength) { - int read = 0; - valueLength = length; - if (valueLength < 0) { - valueLength = (unsigned char)packet[index+read];read++; - if (ignoreZeroAfterLength) read++; - } - - if (value) delete[] value; - value = new char[valueLength]; - memcpy(value,packet+index+read,valueLength); - read+=valueLength; - - return read; - } - -/*TODO: this cant work, attLength is always 0, needs to be fixed*/ -/* int VariableValue::readFixValue(char *packet, int index, int packetLength, int valueLength) { - VariableValue *value = this; - int nameLength = packet[index]; - - int i = 1; - int attLengthLength = 0; - int attLength = 0; - string name; - - for(; i <= nameLength;i++){ - name += packet[index+i]; - } - value->setName(name); - index += i; - index++; //ignore next value - - value->setValueLength(valueLength); - - char *att = new char[attLength]; - index += i+1; - for(i = 0; i < attLength;i++){ - att[i] = packet[index+i]; - } - index += i; - value->setValue(att); - return index; - }*/ - - - int VariableValue::readVariableValue(char *packet, int index, int packetLength){ - VariableValue *value = this; - int nameLength = packet[index]; - - int i = 1; - int attLengthLength = 0; - int attLength = 0; - string name; - - for(; i <= nameLength;i++){ - name += packet[index+i]; - } - value->setName(name); - - index += i; - attLengthLength = packet[index]; - index++; - - for(i = 0; i < attLengthLength;i++){ - attLength += (unsigned char)packet[index+i];/*todo: make it work if length is longer than 1 byte*/ - } - value->setValueLength(attLength); - - char *att = new char[attLength]; - index += i+1; - for(i = 0; i < attLength;i++){ - att[i] = packet[index+i]; - } - value->setValue(att); - index += i; - return index; - } - - - - - int VariableValue::writeName(char *buf, int index) { - int len = name.length(); - buf[index] = len; - memcpy(buf+index+1,name.c_str(),len); - return len+1; - } - int VariableValue::writeValue(char *buf, int index) { - memcpy(buf+index,value,valueLength); - return valueLength; - } - +namespace xfirelib +{ + VariableValue::VariableValue() + { + value = 0; + } + + VariableValue::~VariableValue() + { + if (value) + delete[] value; + } + + void VariableValue::setName(std::string name) + { + this->name = name; + } + + void VariableValue::setValueLength(int valueLength) + { + this->valueLength = valueLength; + } + + void VariableValue::setValue(char * value) + { + if (this->value) delete[] this->value; + this->value = value; + } + + void VariableValue::setValue(std::string value) + { + const char *val = value.c_str(); + setValue(val, value.length()); + } + + void VariableValue::setValue(const char *value, int valueLength) + { + this->value = new char[valueLength]; + memcpy(this->value, value, valueLength); + this->valueLength = valueLength; + } + + void VariableValue::setValueFromLong(long value, int bytes) + { + this->valueLength = bytes; + this->value = new char[bytes]; + for (int i = 0; i < bytes; i++) { + this->value[i] = value % 256; + value = value / 256; + } + } + + std::string VariableValue::getName() + { + return name; + } + + int VariableValue::getValueLength() + { + return valueLength; + } + + char* VariableValue::getValue() + { + return value; + } + + long VariableValue::getValueAsLong() + { + long intVal = 0; + for (int i = 0; i < valueLength; i++) { + intVal += ((unsigned char)value[i]) * myPow(256, i); + } + return intVal; + } + + long VariableValue::myPow(int x, int y) + { + long r = 1; + for (int i = 0; i < y; i++) r *= x; + return r; + } + + int VariableValue::readName(char *packet, int index) + { + int read = 0; + int nameLength = packet[index]; + read++; + char* namestr = new char[nameLength + 1]; + namestr[nameLength] = 0; + memcpy(namestr, packet + index + read, nameLength); + name = string(namestr); + read += nameLength; + delete[] namestr; + return read; + } + + int VariableValue::readValue(char *packet, int index, int length, int ignoreZeroAfterLength) + { + int read = 0; + valueLength = length; + if (valueLength < 0) { + valueLength = (unsigned char)packet[index + read]; read++; + if (ignoreZeroAfterLength) read++; + } + + if (value) delete[] value; + value = new char[valueLength]; + memcpy(value, packet + index + read, valueLength); + read += valueLength; + + return read; + } + + int VariableValue::readVariableValue(char *packet, int index, int) + { + VariableValue *value = this; + int nameLength = packet[index]; + + int i = 1; + int attLengthLength = 0; + int attLength = 0; + string name; + + for (; i <= nameLength; i++) { + name += packet[index + i]; + } + value->setName(name); + + index += i; + attLengthLength = packet[index]; + index++; + + for (i = 0; i < attLengthLength; i++) + attLength += (unsigned char)packet[index + i];/*todo: make it work if length is longer than 1 byte*/ + + value->setValueLength(attLength); + + char *att = new char[attLength]; + index += i + 1; + for (i = 0; i < attLength; i++) + att[i] = packet[index + i]; + + value->setValue(att); + index += i; + return index; + } + + int VariableValue::writeName(char *buf, int index) + { + int len = name.length(); + buf[index] = len; + memcpy(buf + index + 1, name.c_str(), len); + return len + 1; + } + int VariableValue::writeValue(char *buf, int index) + { + memcpy(buf + index, value, valueLength); + return valueLength; + } }; diff --git a/protocols/Xfire/src/variablevalue.h b/protocols/Xfire/src/variablevalue.h index 8282f47cbf..29e12743cb 100644 --- a/protocols/Xfire/src/variablevalue.h +++ b/protocols/Xfire/src/variablevalue.h @@ -20,45 +20,43 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <string> - #ifndef __VARIABVLEVALUE_H #define __VARIABVLEVALUE_H namespace xfirelib { -class VariableValue { - public: - VariableValue(); - ~VariableValue(); - - void setName(std::string name); - void setValueLength(int valueLength); - void setValue( char * value ); - void setValue( std::string value ); - void setValue( const char *value, int valueLength ); - void setValueFromLong( long value, int bytes ); - std::string getName(); - int getValueLength(); - char* getValue(); - - int readName(char *packet, int index); - int readValue(char *packet, int index, int length = -1, int ignoreZeroAfterLength = 0); - int readVariableValue(char *packet, int index, int packetLength); - /*TODO: disabled because of a bug in this method*/ - //int VariableValue::readFixValue(char *packet, int index, int packetLength, int valueLength); - - int writeName(char *buf, int index); - int writeValue(char *buf, int index); - - long getValueAsLong(); - private: - long myPow(int x, int y); - - std::string name; - char *value; - int valueLength; -}; + class VariableValue { + public: + VariableValue(); + ~VariableValue(); + + void setName(std::string name); + void setValueLength(int valueLength); + void setValue( char * value ); + void setValue( std::string value ); + void setValue( const char *value, int valueLength ); + void setValueFromLong( long value, int bytes ); + std::string getName(); + int getValueLength(); + char* getValue(); + + int readName(char *packet, int index); + int readValue(char *packet, int index, int length = -1, int ignoreZeroAfterLength = 0); + int readVariableValue(char *packet, int index, int packetLength); + /*TODO: disabled because of a bug in this method*/ + //int VariableValue::readFixValue(char *packet, int index, int packetLength, int valueLength); + + int writeName(char *buf, int index); + int writeValue(char *buf, int index); + + long getValueAsLong(); + private: + long myPow(int x, int y); + + std::string name; + char *value; + int valueLength; + }; }; diff --git a/protocols/Xfire/src/version.h b/protocols/Xfire/src/version.h index 758569a331..b338029551 100644 --- a/protocols/Xfire/src/version.h +++ b/protocols/Xfire/src/version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 1
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
#define __RELEASE_NUM 9
-#define __BUILD_NUM 0
+#define __BUILD_NUM 0
#include <stdver.h>
#define __PLUGIN_NAME "Xfire protocol"
#define __FILENAME "Xfire.dll"
-#define __DESCRIPTION "Xfire protocol support for Miranda NG."
-#define __AUTHOR "dufte"
+#define __DESCRIPTION "Xfire protocol support for Miranda NG."
+#define __AUTHOR "dufte"
#define __AUTHOREMAIL "dufte@justmail.de"
-#define __AUTHORWEB "http://miranda-ng.org/p/XFire/"
-#define __COPYRIGHT "(c) 2012 Xfirelib by Herbert Poul, Xfire Miranda protocol plugin by dufte"
+#define __AUTHORWEB "http://miranda-ng.org/p/XFire/"
+#define __COPYRIGHT "(c) 2012 Xfirelib by Herbert Poul, Xfire Miranda protocol plugin by dufte"
diff --git a/protocols/Xfire/src/xfireclanpacket.cpp b/protocols/Xfire/src/xfireclanpacket.cpp index c26577fae1..2bc6796572 100644 --- a/protocols/Xfire/src/xfireclanpacket.cpp +++ b/protocols/Xfire/src/xfireclanpacket.cpp @@ -26,54 +26,50 @@ #include "xfireclanpacket.h" #include "variablevalue.h" -#include <string> -namespace xfirelib { - using namespace std; +using namespace std; - void XFireClanPacket::parseContent(char *buf, int nlength, int numberOfAtts) { - VariableValue val; - int index = 0; - int length = 0; - string stringvalue; - - index += 3; // ersten 5 bytes skippen +namespace xfirelib +{ + void XFireClanPacket::parseContent(char *buf, int, int) + { + VariableValue val; + int index = 0; + int length = 0; + string stringvalue; - this->count=(char)buf[index]; + index += 3; // ersten 5 bytes skippen - index += 2; + this->count = (char)buf[index]; - for(int i=0;i<this->count;i++) - { - index += val.readValue(buf,index,2); //clanid lesen - this->clanid[i] = val.getValueAsLong(); index += 2; - } - - index += 5; // 7 bytes skippen - for(int i=0;i<this->count;i++) - { - length = (unsigned char)buf[index++]; //clannamen lesen - index++; - index += val.readValue(buf,index,length); - stringvalue = string(val.getValue(),length); + for (int i = 0; i < this->count; i++) { + index += val.readValue(buf, index, 2); //clanid lesen + this->clanid[i] = val.getValueAsLong(); + index += 2; + } - this->name[i] = stringvalue; - } + index += 5; // 7 bytes skippen - index += 5; // 5 skippen + for (int i = 0; i < this->count; i++) { + length = (unsigned char)buf[index++]; //clannamen lesen + index++; + index += val.readValue(buf, index, length); + stringvalue = string(val.getValue(), length); - for(int i=0;i<this->count;i++) - { - length = (unsigned char)buf[index++]; //url anhängsel auslesen - index++; - index += val.readValue(buf,index,length); - stringvalue = string(val.getValue(),length); + this->name[i] = stringvalue; + } - this->url[i] = stringvalue; - } + index += 5; // 5 skippen - } + for (int i = 0; i < this->count; i++) { + length = (unsigned char)buf[index++]; //url anhängsel auslesen + index++; + index += val.readValue(buf, index, length); + stringvalue = string(val.getValue(), length); -}; + this->url[i] = stringvalue; + } + } +} diff --git a/protocols/Xfire/src/xfireclanpacket.h b/protocols/Xfire/src/xfireclanpacket.h index 7e5b1bc843..55804f2a53 100644 --- a/protocols/Xfire/src/xfireclanpacket.h +++ b/protocols/Xfire/src/xfireclanpacket.h @@ -25,37 +25,32 @@ #ifndef __XFIRECLANPACKET_H #define __XFIRECLANPACKET_H -#include <string> #include "xfirerecvpacketcontent.h" #define XFIRE_CLAN_PACKET 158 namespace xfirelib { - using namespace std; - - /** - * beinhaltet, clanid, name und weburl-zusatz - * - */ - class XFireClanPacket : public XFireRecvPacketContent { - public: - XFirePacketContent* newPacket() { return new XFireClanPacket(); } - - - int getPacketId() { return XFIRE_CLAN_PACKET; } - int getPacketContent(char *buf) { return 0;} - int getPacketAttributeCount() { return 3; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); - - string name[10]; - string url[10]; - long clanid[10]; - int count; - - private: - }; - + using namespace std; + + /** + * beinhaltet, clanid, name und weburl-zusatz + * + */ + class XFireClanPacket : public XFireRecvPacketContent { + public: + XFirePacketContent* newPacket() { return new XFireClanPacket(); } + + int getPacketId() { return XFIRE_CLAN_PACKET; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 3; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); + + string name[10]; + string url[10]; + long clanid[10]; + int count; + }; }; diff --git a/protocols/Xfire/src/xfirefoundbuddys.cpp b/protocols/Xfire/src/xfirefoundbuddys.cpp index dacae8f885..610ff00edd 100644 --- a/protocols/Xfire/src/xfirefoundbuddys.cpp +++ b/protocols/Xfire/src/xfirefoundbuddys.cpp @@ -23,70 +23,71 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "xfirefoundbuddys.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - XFireFoundBuddys::XFireFoundBuddys() { - usernames = 0; - fname = 0; - lname = 0; - } - XFireFoundBuddys::~XFireFoundBuddys() { - delete usernames; - delete fname; - delete lname; - } - - void XFireFoundBuddys::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - - VariableValue bs; - - XDEBUG2( "Len: %ld\n", length ); - - XDEBUG2( "Byte1: %ld\n", (char)buf[index] ); - XDEBUG2( "Byte2: %ld\n", (char)buf[index+1] ); - XDEBUG2( "Byte3: %ld\n", (char)buf[index+2] ); - - usernames = new vector<string>; - index = readStrings(usernames,buf,index); - - fname = new vector<string>; - index = readStrings(fname,buf,index); - - lname = new vector<string>; - index = readStrings(lname,buf,index); - - } - - int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) { - VariableValue friends; - index+=friends.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 01 - - index+=friends.readValue(buf,index,2); - - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - XDEBUG2( "Index: %ld\n", index ); - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - string stringvalue = string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() ); - } - return index; - } - -}; +using namespace std; + +namespace xfirelib +{ + XFireFoundBuddys::XFireFoundBuddys() + { + usernames = 0; + fname = 0; + lname = 0; + } + XFireFoundBuddys::~XFireFoundBuddys() + { + delete usernames; + delete fname; + delete lname; + } + + void XFireFoundBuddys::parseContent(char *buf, int, int) + { + int index = 0; + + VariableValue bs; + + XDEBUG2("Len: %ld\n", length); + + XDEBUG2("Byte1: %ld\n", (char)buf[index]); + XDEBUG2("Byte2: %ld\n", (char)buf[index + 1]); + XDEBUG2("Byte3: %ld\n", (char)buf[index + 2]); + + usernames = new vector<string>; + index = readStrings(usernames, buf, index); + + fname = new vector<string>; + index = readStrings(fname, buf, index); + + lname = new vector<string>; + index = readStrings(lname, buf, index); + } + + int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 01 + + index += friends.readValue(buf, index, 2); + + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + XDEBUG2("Index: %ld\n", index); + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + string stringvalue = string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG3("String length: %2d : %s\n", length, stringvalue.c_str()); + } + return index; + } +} diff --git a/protocols/Xfire/src/xfirefoundbuddys.h b/protocols/Xfire/src/xfirefoundbuddys.h index 70d44f201b..c51152d8f5 100644 --- a/protocols/Xfire/src/xfirefoundbuddys.h +++ b/protocols/Xfire/src/xfirefoundbuddys.h @@ -29,37 +29,32 @@ #define XFIRE_FOUNDBUDDYS_ID 0x8f -#include <vector> -#include <string> - #include "xfirerecvpacketcontent.h" #include "variablevalue.h" - namespace xfirelib { - using namespace std; + using namespace std; - class XFireFoundBuddys : public XFireRecvPacketContent { - public: - XFireFoundBuddys(); - virtual ~XFireFoundBuddys(); + class XFireFoundBuddys : public XFireRecvPacketContent { + public: + XFireFoundBuddys(); + virtual ~XFireFoundBuddys(); - XFirePacketContent* newPacket() { return new XFireFoundBuddys(); } + XFirePacketContent* newPacket() { return new XFireFoundBuddys(); } - int getPacketId() { return XFIRE_FOUNDBUDDYS_ID; } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; }; - int getPacketSize() { return 1024; }; - void parseContent(char *buf, int length, int numberOfAtts); + int getPacketId() { return XFIRE_FOUNDBUDDYS_ID; } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; }; + int getPacketSize() { return 1024; }; + void parseContent(char *buf, int length, int numberOfAtts); - //private: - int readStrings(vector<string> *strings, char *buf, int index); + //private: + int readStrings(vector<string> *strings, char *buf, int index); - vector<string> *usernames; - vector<string> *fname; - vector<string> *lname; - }; + vector<string> *usernames; + vector<string> *fname; + vector<string> *lname; + }; }; - #endif diff --git a/protocols/Xfire/src/xfiregame.h b/protocols/Xfire/src/xfiregame.h index b8293750ad..baf3fc153f 100644 --- a/protocols/Xfire/src/xfiregame.h +++ b/protocols/Xfire/src/xfiregame.h @@ -24,19 +24,14 @@ #ifndef __XFIREGAME_H #define __XFIREGAME_H -#include <string> - namespace xfirelib { - class XFireGame { - public: - virtual ~XFireGame() { } - virtual int getGameId() = 0; - virtual std::string getGameName() = 0; - }; - - + class XFireGame { + public: + virtual ~XFireGame() { } + virtual int getGameId() = 0; + virtual std::string getGameName() = 0; + }; }; - #endif diff --git a/protocols/Xfire/src/xfiregameresolver.h b/protocols/Xfire/src/xfiregameresolver.h index 1215550009..7ed6969cbe 100644 --- a/protocols/Xfire/src/xfiregameresolver.h +++ b/protocols/Xfire/src/xfiregameresolver.h @@ -25,28 +25,26 @@ #include "buddylistgamespacket.h" #include "xfiregame.h" -#include <string> namespace xfirelib { - /** - * This is a virtual class which users of the library can - * subclass so they can use their own gameid <-> XFireGame object - * resolver (Implementors might want to consider that their application - * also requires backward converting .. from game to gameid since - * SendGameStatusPacket requires a gameid. - */ - class XFireGameResolver { - public: - virtual ~XFireGameResolver() { } - - /** - * this method should resolve the gameid - * and return a new XFireGame object or NULL if it was not resolvable. - * (if more information is needed, it can be taken from packet->xxx[iterator]) - */ - virtual XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) = 0; - }; + /** + * This is a virtual class which users of the library can + * subclass so they can use their own gameid <-> XFireGame object + * resolver (Implementors might want to consider that their application + * also requires backward converting .. from game to gameid since + * SendGameStatusPacket requires a gameid. + */ + class XFireGameResolver { + public: + virtual ~XFireGameResolver() { } + /** + * this method should resolve the gameid + * and return a new XFireGame object or NULL if it was not resolvable. + * (if more information is needed, it can be taken from packet->xxx[iterator]) + */ + virtual XFireGame *resolveGame(int gameid, int iterator, BuddyListGamesPacket *packet) = 0; + }; }; #endif diff --git a/protocols/Xfire/src/xfirepacket.cpp b/protocols/Xfire/src/xfirepacket.cpp index 9a2087a018..541e971139 100644 --- a/protocols/Xfire/src/xfirepacket.cpp +++ b/protocols/Xfire/src/xfirepacket.cpp @@ -31,115 +31,103 @@ #include "socketexception.h" -namespace xfirelib { - using namespace std; - - XFirePacket::XFirePacket(PacketReader *reader) { - this->reader = reader; - this->content = NULL; - } - XFirePacket::XFirePacket(XFirePacketContent *content) { - this->content = content; - this->reader = NULL; - } - - XFirePacket::~XFirePacket() { - } - - - void XFirePacket::recvPacket(Socket *socket) { - char buf[5]; - //char temp[255]; - int nlen=0; - //FILE* f2; - - if (socket==NULL) return; - - int r = socket->recv( buf, 5 ); - int missingbytes=5-r; - if (missingbytes != 0) { - XERROR3("Returned only %d bytes try last %d bytes again ?!: \n",r,missingbytes); - r+= socket->recv( &buf[r], missingbytes ); +using namespace std; + +namespace xfirelib +{ + XFirePacket::XFirePacket(PacketReader *reader) + { + this->reader = reader; + this->content = NULL; } - if (r != 5) { - XERROR2("Returned less than 5 ?!: %d\n",r); - throw SocketException("Connection Closed ?"); - } - XDEBUG2("Read %d bytes...\n", r ); - unsigned int len = ((unsigned char)buf[0]) + (((unsigned char)buf[1]) * 256); - - int packetid = buf[2]; - int numberOfAtts = (unsigned char)buf[4]; - - char* contentbuf=new char[len-5]; - XDEBUG2("calling socket->recv(contentbuf,%d)\n",len-5); - int r2 = socket->recv( contentbuf, len-5 ); - - - char* ncontentbuf=contentbuf+r2; - int nsize=len-5-r2; - int dummyi=0; - //packet solang auslesen, bis fertig - dufte - while(nsize>0) + + XFirePacket::XFirePacket(XFirePacketContent *content) { - dummyi++; - XDEBUG2("nsize: %d\n", nsize); - r2=socket->recv( ncontentbuf, nsize ); - ncontentbuf=ncontentbuf+r2; - nsize-=r2; - XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid,numberOfAtts,len-5,len-5-nsize); + this->content = content; + this->reader = NULL; } - XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid,numberOfAtts,len-5,r2); + XFirePacket::~XFirePacket() + { + } - if (r2 < 1) return; + void XFirePacket::recvPacket(Socket *socket) + { + char buf[5]; + + if (socket == NULL) return; + + int r = socket->recv(buf, 5); + int missingbytes = 5 - r; + if (missingbytes != 0) { + XERROR3("Returned only %d bytes try last %d bytes again ?!: \n", r, missingbytes); + r += socket->recv(&buf[r], missingbytes); + } + if (r != 5) { + XERROR2("Returned less than 5 ?!: %d\n", r); + throw SocketException("Connection Closed ?"); + } + XDEBUG2("Read %d bytes...\n", r); + unsigned int len = ((unsigned char)buf[0]) + (((unsigned char)buf[1]) * 256); + + int packetid = buf[2]; + int numberOfAtts = (unsigned char)buf[4]; + + char* contentbuf = new char[len - 5]; + XDEBUG2("calling socket->recv(contentbuf,%d)\n", len - 5); + int r2 = socket->recv(contentbuf, len - 5); + + + char* ncontentbuf = contentbuf + r2; + int nsize = len - 5 - r2; + int dummyi = 0; + //packet solang auslesen, bis fertig - dufte + while (nsize > 0) { + dummyi++; + XDEBUG2("nsize: %d\n", nsize); + r2 = socket->recv(ncontentbuf, nsize); + ncontentbuf = ncontentbuf + r2; + nsize -= r2; + XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid, numberOfAtts, len - 5, len - 5 - nsize); + } + + XDEBUG5("packetid: %d numberOfAtts: %d length: %d Got: %d\n", (unsigned char)packetid, numberOfAtts, len - 5, r2); + + if (r2 < 1) return; + + XFirePacketContent *contentClass = reader->getPacketContentClass((unsigned char)packetid); + + if (contentClass == NULL) { + XERROR2("NO SUCH CONTENT PACKET (%d) :(\n", (unsigned char)packetid); + return; + } + XDEBUG(("Creating ContentClass Instance\n")); + content = contentClass->newPacket(); + + XDEBUG(("Parse Content\n")); + //statt r2 wird jetzt die komplette länge des packets genommen, also len-5 dufte + content->parseContent(contentbuf, len - 5, numberOfAtts); + } - /*if ((unsigned char)packetid==131) + void XFirePacket::sendPacket(Socket *socket) { - sprintf(temp,"packet%d_%d.dmp",(unsigned char)packetid,rand()); - f2=fopen(temp,"wb"); - fwrite(contentbuf,1,len-5,f2); - fclose(f2); - }*/ - - XFirePacketContent *contentClass = reader->getPacketContentClass( (unsigned char)packetid ); - - //sprintf(temp,"packet%d.dmp",(unsigned char)packetid); - - if (contentClass == NULL) { - /*sprintf(temp,"packet%d.dmp",(unsigned char)packetid); - f2=fopen(temp,"wb"); - fwrite(contentbuf,1,len-5,f2); - fclose(f2);*/ - XERROR2("NO SUCH CONTENT PACKET (%d) :(\n", (unsigned char)packetid); - return; - } - XDEBUG(("Creating ContentClass Instance\n")); - content = contentClass->newPacket(); - - XDEBUG(("Parse Content\n")); - //statt r2 wird jetzt die komplette länge des packets genommen, also len-5 dufte - content->parseContent(contentbuf, len-5, numberOfAtts); - } - - void XFirePacket::sendPacket(Socket *socket) { - int size = content->getPacketSize(); - char *buf = (char*)malloc(size * sizeof(char)); - XDEBUG3("Allocated %d characters (%d)\n", size, sizeof(char)); - int rsize = content->getPacketContent( buf ); - XDEBUG2("Real Size: %d\n", rsize); - int realsize = rsize + 5; - char *sendbuf = (char*)malloc(realsize * sizeof(char)); - sendbuf[0] = realsize % 256; - sendbuf[1] = (int)realsize / 256; - sendbuf[2] = content->getPacketId(); - XDEBUG2("Send Content Id: %d\n", content->getPacketId()); - sendbuf[3] = 0; - sendbuf[4] = content->getPacketAttributeCount(); - memcpy( sendbuf + 5, buf, rsize ); - - socket->send( sendbuf, realsize ); - - free(buf); free(sendbuf); - } -}; + int size = content->getPacketSize(); + char *buf = (char*)malloc(size * sizeof(char)); + XDEBUG3("Allocated %d characters (%d)\n", size, sizeof(char)); + int rsize = content->getPacketContent(buf); + XDEBUG2("Real Size: %d\n", rsize); + int realsize = rsize + 5; + char *sendbuf = (char*)malloc(realsize * sizeof(char)); + sendbuf[0] = realsize % 256; + sendbuf[1] = (int)realsize / 256; + sendbuf[2] = content->getPacketId(); + XDEBUG2("Send Content Id: %d\n", content->getPacketId()); + sendbuf[3] = 0; + sendbuf[4] = content->getPacketAttributeCount(); + memcpy(sendbuf + 5, buf, rsize); + + socket->send(sendbuf, realsize); + + free(buf); free(sendbuf); + } +} diff --git a/protocols/Xfire/src/xfirepacket.h b/protocols/Xfire/src/xfirepacket.h index c7b938e2f9..cad92e07de 100644 --- a/protocols/Xfire/src/xfirepacket.h +++ b/protocols/Xfire/src/xfirepacket.h @@ -27,27 +27,26 @@ #include "xfirepacketcontent.h" namespace xfirelib { - struct PacketReader; - struct XFirePacketContent; - - class XFirePacket { - public: - XFirePacket(PacketReader *reader); - XFirePacket(XFirePacketContent *content); - ~XFirePacket(); - - int getSendBuffer(void *buf); - void recvPacket(Socket *socket); - void sendPacket(Socket *socket); - void sendPacket2(Socket *socket); - - XFirePacketContent *getContent() { return content; } - private: - PacketReader *reader; - - XFirePacketContent *content; - }; + struct PacketReader; + struct XFirePacketContent; + + class XFirePacket { + public: + XFirePacket(PacketReader *reader); + XFirePacket(XFirePacketContent *content); + ~XFirePacket(); + + int getSendBuffer(void *buf); + void recvPacket(Socket *socket); + void sendPacket(Socket *socket); + void sendPacket2(Socket *socket); + + XFirePacketContent *getContent() { return content; } + private: + PacketReader *reader; + + XFirePacketContent *content; + }; }; - #endif diff --git a/protocols/Xfire/src/xfirepacketcontent.cpp b/protocols/Xfire/src/xfirepacketcontent.cpp index 87a7778357..efd05a95b9 100644 --- a/protocols/Xfire/src/xfirepacketcontent.cpp +++ b/protocols/Xfire/src/xfirepacketcontent.cpp @@ -23,8 +23,10 @@ #include "xfirepacketcontent.h" -namespace xfirelib { - XFirePacketContent::XFirePacketContent() : MonitoredObj( ) { - } +namespace xfirelib +{ + XFirePacketContent::XFirePacketContent() : MonitoredObj() + { + } }; diff --git a/protocols/Xfire/src/xfirepacketcontent.h b/protocols/Xfire/src/xfirepacketcontent.h index abb894f5fc..040802f985 100644 --- a/protocols/Xfire/src/xfirepacketcontent.h +++ b/protocols/Xfire/src/xfirepacketcontent.h @@ -26,22 +26,20 @@ #include "monitoredobj.h" namespace xfirelib { - struct Client; - - class XFirePacketContent : public MonitoredObj { - public: - XFirePacketContent(); - virtual ~XFirePacketContent() { } - virtual XFirePacketContent* newPacket() = 0; - - virtual int getPacketContent(char *buf) = 0; - virtual int getPacketId() = 0; - virtual int getPacketAttributeCount() = 0; - virtual int getPacketSize() = 0; - virtual void parseContent(char *buf, int length, int numberOfAtts) = 0; - }; - + struct Client; + + class XFirePacketContent : public MonitoredObj { + public: + XFirePacketContent(); + virtual ~XFirePacketContent() { } + virtual XFirePacketContent* newPacket() = 0; + + virtual int getPacketContent(char *buf) = 0; + virtual int getPacketId() = 0; + virtual int getPacketAttributeCount() = 0; + virtual int getPacketSize() = 0; + virtual void parseContent(char *buf, int length, int numberOfAtts) = 0; + }; }; - #endif diff --git a/protocols/Xfire/src/xfireparse.cpp b/protocols/Xfire/src/xfireparse.cpp index 382901f853..1d49eb0f34 100644 --- a/protocols/Xfire/src/xfireparse.cpp +++ b/protocols/Xfire/src/xfireparse.cpp @@ -23,27 +23,12 @@ #include "stdafx.h" #include "xfireparse.h" -namespace xfirelib { using namespace std; -XFireParse::XFireParse() { -} - - -/*void XFireParse::readVariableAttribut( char *value, char *packet, char *attr,int packet_length,int attr_length, int start,int max_length ) { -int length_index = findString2(packet,attr, packet_length,mir_strlen(attr),start)+attr_length+1; - - unsigned int length = xfire_hex_to_intC(packet[length_index]); - - if (max_length >= length){ - memcpy(value,packet+length_index+2,length); +namespace xfirelib +{ + XFireParse::XFireParse() + { } - if (max_length > length){ - memset(value+length,0,1); - } - return length_index+2+length; -}*/ - - }; diff --git a/protocols/Xfire/src/xfireparse.h b/protocols/Xfire/src/xfireparse.h index e03e814a6e..e50078337f 100644 --- a/protocols/Xfire/src/xfireparse.h +++ b/protocols/Xfire/src/xfireparse.h @@ -27,10 +27,10 @@ #include "variablevalue.h" namespace xfirelib { -class XFireParse { - public: - XFireParse(); -}; + class XFireParse { + public: + XFireParse(); + }; }; diff --git a/protocols/Xfire/src/xfireprefpacket.cpp b/protocols/Xfire/src/xfireprefpacket.cpp index 6afc613fed..256b8c7d94 100644 --- a/protocols/Xfire/src/xfireprefpacket.cpp +++ b/protocols/Xfire/src/xfireprefpacket.cpp @@ -27,24 +27,26 @@ #include <string.h> #include <iostream> -namespace xfirelib { - using namespace std; +using namespace std; - int XFirePrefPacket::getPacketContent(char *packet) { - int index = 0; +namespace xfirelib +{ + int XFirePrefPacket::getPacketContent(char *packet) + { + int index = 0; - VariableValue val; - val.setName( "prefs" ); - index += val.writeName( packet, index ); - packet[index++] = 0x09; - packet[index++] = 0x00; - - length = index; - return index; - } + VariableValue val; + val.setName("prefs"); + index += val.writeName(packet, index); + packet[index++] = 0x09; + packet[index++] = 0x00; - int XFirePrefPacket::getPacketAttributeCount() { - return 1; - } + length = index; + return index; + } + int XFirePrefPacket::getPacketAttributeCount() + { + return 1; + } } diff --git a/protocols/Xfire/src/xfireprefpacket.h b/protocols/Xfire/src/xfireprefpacket.h index f4e1709357..d9c593319a 100644 --- a/protocols/Xfire/src/xfireprefpacket.h +++ b/protocols/Xfire/src/xfireprefpacket.h @@ -30,23 +30,20 @@ #include "xfiresendpacketcontent.h" #include "variablevalue.h" -#include <string> - namespace xfirelib { - class XFirePrefPacket : public XFireSendPacketContent { - public: - XFirePacketContent* newPacket() { return new XFirePrefPacket(); } - - int getPacketId() { return 10; } - int getPacketContent(char *buf); - int getPacketAttributeCount(); - int getPacketSize() { return 1000; }; - void parseContent(char *buf, int length, int numberOfAtts) { }; - private: - int length; - }; - + class XFirePrefPacket : public XFireSendPacketContent { + public: + XFirePacketContent* newPacket() { return new XFirePrefPacket(); } + + int getPacketId() { return 10; } + int getPacketContent(char *buf); + int getPacketAttributeCount(); + int getPacketSize() { return 1000; }; + void parseContent(char*, int, int) { }; + private: + int length; + }; }; #endif diff --git a/protocols/Xfire/src/xfirerecvpacketcontent.h b/protocols/Xfire/src/xfirerecvpacketcontent.h index 2ca2aca424..c2b0419295 100644 --- a/protocols/Xfire/src/xfirerecvpacketcontent.h +++ b/protocols/Xfire/src/xfirerecvpacketcontent.h @@ -27,19 +27,17 @@ #include "xfirepacketcontent.h" namespace xfirelib { - - class XFireRecvPacketContent : public XFirePacketContent { - public: - XFireRecvPacketContent() : XFirePacketContent() { } - virtual ~XFireRecvPacketContent() { } - int getPacketContent(char *buf) { return 0; } - int getPacketAttributeCount() { return 0; } - int getPacketSize() { return 0; } - }; + class XFireRecvPacketContent : public XFirePacketContent { + public: + XFireRecvPacketContent() : XFirePacketContent() { } + virtual ~XFireRecvPacketContent() { } + int getPacketContent(char*) { return 0; } + int getPacketAttributeCount() { return 0; } + int getPacketSize() { return 0; } + }; }; - #endif diff --git a/protocols/Xfire/src/xfiresendpacketcontent.h b/protocols/Xfire/src/xfiresendpacketcontent.h index 7ce106d295..807ef1a27e 100644 --- a/protocols/Xfire/src/xfiresendpacketcontent.h +++ b/protocols/Xfire/src/xfiresendpacketcontent.h @@ -27,17 +27,15 @@ namespace xfirelib { - class XFireSendPacketContent : public XFirePacketContent { - public: - /** - * This method is not needed for outgoing packets.. since this method is only - * used for parsing .. so return null - */ - XFirePacketContent *newPacket() { return 0; } - void parseContent(char *buf, int length, int numberOfAtts) { } - }; - + class XFireSendPacketContent : public XFirePacketContent { + public: + /** + * This method is not needed for outgoing packets.. since this method is only + * used for parsing .. so return null + */ + XFirePacketContent *newPacket() { return 0; } + void parseContent(char*, int, int) {} + }; }; - #endif diff --git a/protocols/Xfire/src/xfireutils.cpp b/protocols/Xfire/src/xfireutils.cpp index 93793c72e7..73b78961a0 100644 --- a/protocols/Xfire/src/xfireutils.cpp +++ b/protocols/Xfire/src/xfireutils.cpp @@ -23,22 +23,21 @@ #include "stdafx.h" #include "xdebug.h" -#include <string.h> -#include <iostream> #include "xfireutils.h" - -namespace xfirelib { - using namespace std; - XFireUtils::XFireUtils() { - } +namespace xfirelib +{ + XFireUtils::XFireUtils() + { + } - int XFireUtils::addAttributName(char *packet,int packet_length, char *att){ - XDEBUG3( "Adding %d chars at position %d\n",mir_strlen(att),packet_length); - packet[packet_length] = (char)mir_strlen(att);//set att length - memcpy(packet+packet_length+1,att,mir_strlen(att)); //set attname - return packet_length+1+mir_strlen(att); - } + int XFireUtils::addAttributName(char *packet, int packet_length, char *att) + { + XDEBUG3("Adding %d chars at position %d\n", mir_strlen(att), packet_length); + packet[packet_length] = (char)mir_strlen(att);//set att length + memcpy(packet + packet_length + 1, att, mir_strlen(att)); //set attname + return packet_length + 1 + mir_strlen(att); + } }; diff --git a/protocols/Xfire/src/xfireutils.h b/protocols/Xfire/src/xfireutils.h index a149b27a63..3fba542d63 100644 --- a/protocols/Xfire/src/xfireutils.h +++ b/protocols/Xfire/src/xfireutils.h @@ -26,15 +26,13 @@ namespace xfirelib { -class XFireUtils { - public: - XFireUtils(); - /** - *Adds the name of a attribute with its length to the packet - */ - static int addAttributName(char *packet,int packet_length, char *att); -}; + class XFireUtils { + public: + XFireUtils(); + // Adds the name of a attribute with its length to the packet + static int addAttributName(char *packet,int packet_length, char *att); + }; }; #endif diff --git a/protocols/Xfire/xfire.vcxproj b/protocols/Xfire/xfire.vcxproj index b5e1ab0cc8..4c08d50ff1 100644 --- a/protocols/Xfire/xfire.vcxproj +++ b/protocols/Xfire/xfire.vcxproj @@ -25,4 +25,9 @@ <ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ </ClCompile>
+ </ItemDefinitionGroup>
</Project>
\ No newline at end of file |