summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2012-08-21 15:23:54 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2012-08-21 15:23:54 +0000
commit260cf26dec30e33ae3c7c6a91fccc0b4b43b8ce4 (patch)
treed2718f2979852832740f5eb1854e6e9b6d5dc7ed /plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp
parent3abc8a4dcba551b8a3a01fcc1b7c311dff5eaf32 (diff)
latest XFire plugin sources by dufte (thanks)
No adaptions, uploaded as-is git-svn-id: http://svn.miranda-ng.org/main/trunk@1514 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp')
-rw-r--r--plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp b/plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp
new file mode 100644
index 0000000000..f60d69ef5f
--- /dev/null
+++ b/plugins/!NotAdopted/Xfire/xfiretest/processbuddyinfo.cpp
@@ -0,0 +1,111 @@
+#include "stdafx.h"
+#include "processbuddyinfo.h"
+
+#include <sys\stat.h>
+
+
+/*
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "Backup", av.backup);
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "File", av.file);
+DBWriteContactSettingTString(xsa->hContact, "ContactPhoto", "RFile", av.rfile);
+DBWriteContactSettingWord(xsa->hContact, "ContactPhoto", "Format", av.type);
+*/
+
+extern HANDLE XFireAvatarFolder;
+
+//vom Yahoo plugin
+/*int avt_hash(const char *key, DWORD ksize)
+{
+ const char *p = key;
+ int h = *p;
+ long l = 1;
+
+ if (h)
+ for (p += 1; l < ksize; p++, l++)
+ h = (h << 5) - h + *p;
+
+ return h;
+}*/
+
+void ProcessBuddyInfo(xfirelib::BuddyInfoPacket *buddyinfo,HANDLE hcontact,char* username) {
+ char temp[512]="";
+ char filename[512];
+ BOOL dl=FALSE;
+ int type;
+
+ //versuche doppeltes laden zuvermeiden
+ if(hcontact) //avatar von freunden
+ {
+ if(DBGetContactSettingDword(hcontact, "ContactPhoto", "XFireAvatarId", 0)==buddyinfo->avatarid &&
+ DBGetContactSettingByte(hcontact, "ContactPhoto", "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ return;
+ }
+ else //eigeneder avatar
+ {
+ if(DBGetContactSettingDword(hcontact, protocolname, "XFireAvatarId", 0)==buddyinfo->avatarid &&
+ DBGetContactSettingByte(hcontact, protocolname, "XFireAvatarMode", 0)==buddyinfo->avatarmode)
+ return;
+
+ //alten dateipfad des avatars löschen, wenn sichw as geändert hat
+ DBDeleteContactSetting(NULL,protocolname, "MyAvatarFile");
+ }
+
+ FoldersGetCustomPath( XFireAvatarFolder, filename, 1024, 'A' );
+ strcat(filename,"\\");
+
+ switch(buddyinfo->avatarmode) {
+ case 1:
+ strcat(filename,username);
+ strcat(filename,".gif");
+ type=PA_FORMAT_GIF;
+
+ sprintf(temp,"/xfire/xf/images/avatars/gallery/default/%03d.gif",buddyinfo->avatarid);
+
+ dl=GetWWWContent("media.xfire.com",temp,filename,FALSE);
+ break;
+ case 2:
+ strcat(filename,username);
+ strcat(filename,".jpg");
+ type=PA_FORMAT_JPEG;
+
+ sprintf(temp,"/avatar/100/%s.jpg?%d",username,buddyinfo->avatarid);
+
+ dl=GetWWWContent("screenshot.xfire.com",temp,filename,FALSE);
+ break;
+ case 3:
+ type=PA_FORMAT_GIF;
+ strcat(filename,"xfire.gif");
+
+ sprintf(temp,"/xfire/xf/images/avatars/gallery/default/xfire.gif",buddyinfo->avatarid);
+
+ dl=GetWWWContent("media.xfire.com",temp,filename,TRUE);
+ break;
+ default:
+ return;
+ }
+
+
+ if(dl!=FALSE)
+ {
+ if(hcontact) //buddyavatar setzen
+ {
+ DBWriteContactSettingDword(hcontact, "ContactPhoto", "XFireAvatarId", buddyinfo->avatarid);
+ DBWriteContactSettingByte(hcontact, "ContactPhoto", "XFireAvatarMode", buddyinfo->avatarmode);
+ PROTO_AVATAR_INFORMATION AI;
+ AI.cbSize = sizeof(AI);
+ AI.format = type;
+ AI.hContact = hcontact;
+ lstrcpy(AI.filename,filename);
+ ProtoBroadcastAck(protocolname, hcontact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS,(HANDLE) &AI, 0);
+ }
+ else //eigenen avatar setzen
+ {
+ DBWriteContactSettingDword(NULL, protocolname, "XFireAvatarId", buddyinfo->avatarid);
+ DBWriteContactSettingByte(NULL, protocolname, "XFireAvatarMode", buddyinfo->avatarmode);
+ //neuen avatarfilepath eintragen
+ DBWriteContactSettingTString(NULL,protocolname, "MyAvatarFile",filename);
+ //beshceid geben, avatar hat sich geändert
+ CallService(MS_AV_REPORTMYAVATARCHANGED,(WPARAM)protocolname,0);
+ }
+ }
+} \ No newline at end of file