summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Xfire/src/main.cpp')
-rw-r--r--protocols/Xfire/src/main.cpp1353
1 files changed, 536 insertions, 817 deletions
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&&currentgame->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&&currentgame->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;