From 048aaf0c4e77402adf584e3318e5aae6f1cdd749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Mon, 5 Nov 2012 21:11:48 +0000 Subject: XFire adoption (crashes on login, no 64bit) git-svn-id: http://svn.miranda-ng.org/main/trunk@2212 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Xfire/src/Xfire_icon_mng.cpp | 216 +++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 protocols/Xfire/src/Xfire_icon_mng.cpp (limited to 'protocols/Xfire/src/Xfire_icon_mng.cpp') diff --git a/protocols/Xfire/src/Xfire_icon_mng.cpp b/protocols/Xfire/src/Xfire_icon_mng.cpp new file mode 100644 index 0000000000..f5612e8e56 --- /dev/null +++ b/protocols/Xfire/src/Xfire_icon_mng.cpp @@ -0,0 +1,216 @@ +#include "stdafx.h" +#include "Xfire_icon_mng.h" + +//liefert den handle eines icons zurück +HANDLE Xfire_icon_mng::getGameIconHandle(unsigned int gameid) { + Xfire_icon_cache entry={0}; + + //icon im cache dann zurückliefern + if(getIconfromCache(gameid,&entry)) + return entry.handle; + + //ansonsten gameicon laden + return this->LoadGameIcon(gameid).handle; +} + +//liefert den index des icons zurück +unsigned int Xfire_icon_mng::getGameIconId(unsigned int gameid) { + for(unsigned int i=0;iiconcache.size()-1) + return NULL; + + return iconcache.at(id).hicon; +} + +//liefert das hicon zurück +HICON Xfire_icon_mng::getGameIcon(unsigned int gameid) { + Xfire_icon_cache entry={0}; + + //icon im cache dann zurückliefern + if(getIconfromCache(gameid,&entry)) + return entry.hicon; + + return this->LoadGameIcon(gameid).hicon; +} + +//liefert den icon eintrag zurück +Xfire_icon_cache Xfire_icon_mng::getGameIconEntry(unsigned int gameid) { + Xfire_icon_cache entry={0}; + + //icon im cache dann zurückliefern + if(getIconfromCache(gameid,&entry)) + return entry; + + return this->LoadGameIcon(gameid); +} + +//sucht nach dem spielicon im cache +BOOL Xfire_icon_mng::getIconfromCache(unsigned int gameid,Xfire_icon_cache* out) { + //kein ziel, keine prüfung + if(out==NULL) + return FALSE; + + for(unsigned int i=0;icreateHICONfromdata(data,size); + UnlockResource(hglobal); + } + FreeResource(hglobal); + } + } + } + + //kein icon in der dll, dann aus dem internet laden + if(!entry.hicon) + entry.hicon=downloadIcon(shortname); + + //wenn ein hicon erzeugt wurde, dann handle erstellen und in den cache laden + if(entry.hicon) + entry.handle=this->createIconHandle(entry.hicon); + + //eintrag in den cache, selbst wenn kein icon geladen werden konnte + this->iconcache.push_back(entry); + + return entry; +} + +//icon vom xfire server laden +HICON Xfire_icon_mng::downloadIcon(char* shortname) { + //nur vom internetladen, wenn die option aktiv ist + if(!DBGetContactSettingByte(NULL,protocolname,"xfiresitegameico",0)) + return NULL; + + //keinen namen angegeben? + if(!shortname) + return NULL; + + //buffer + char*buf=NULL; + unsigned int size=0; + + char url[255]="http://media.xfire.com/xfire/xf/images/icons/"; + strcat_s(url,255,shortname); + strcat_s(url,255,".gif"); + + //verscuhe das icon aus dem inet zulasen + if(GetWWWContent2(url,NULL,FALSE,&buf,&size)) + { + //aus dem buffer ein hicon erzeugen + HICON hicon=this->createHICONfromdata(buf,size); + //speicher freigeben + delete[] buf; + + return hicon; + } + + return NULL; +} + +//setzt alle handles der icons neu +int Xfire_icon_mng::resetIconHandles() { + for(unsigned int i=0;icreateIconHandle(iconcache.at(i).hicon); + } + return 0; +} \ No newline at end of file -- cgit v1.2.3