From ad7c1f95b18a323357ad02cff8609ba55a72d3e3 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 17 Oct 2007 01:13:11 +0000 Subject: fix get avatar logic git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@368 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/server_con.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'MySpace/server_con.cpp') diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp index 07d3684..d2c5916 100644 --- a/MySpace/server_con.cpp +++ b/MySpace/server_con.cpp @@ -1044,13 +1044,14 @@ void __cdecl sttDownloadAvatar(void *param) { ProtoBroadcastAck(MODULE,info->hContact,ACKTYPE_AVATAR,ACKRESULT_DATA, 0, 0); char *ext = strrchr(info->url, '.'); + if(ext) ext++; // write file int uid = DBGetContactSettingDword(info->hContact, MODULE, "UID", 0); char fn[MAX_PATH]; char buff[128], tbuff[128]; - mir_snprintf(fn, MAX_PATH, "%s_%s.%s", _itoa(uid, buff, 10), _itoa(GetTickCount(), tbuff, 10), ext); + mir_snprintf(fn, MAX_PATH, "%s_%s.%s", _itoa(uid, buff, 10), _itoa(GetTickCount(), tbuff, 10), ext ? ext : ""); if(WriteData(fn, MAX_PATH, nlhrReply->pData, nlhrReply->dataLength)) { CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); @@ -1060,14 +1061,19 @@ void __cdecl sttDownloadAvatar(void *param) { AI.cbSize = sizeof(PROTO_AVATAR_INFORMATION); AI.hContact = info->hContact; strncpy(AI.filename, fn, MAX_PATH); - AI.format = - (stricmp(ext, ".png") ? PA_FORMAT_PNG : - (stricmp(ext, ".jpg") ? PA_FORMAT_JPEG : - (stricmp(ext, ".jpeg") ? PA_FORMAT_JPEG : - (stricmp(ext, ".gif") ? PA_FORMAT_GIF : - (stricmp(ext, ".swf") ? PA_FORMAT_SWF : PA_FORMAT_UNKNOWN))))); + if(ext) { + AI.format = + (stricmp(ext, ".png") ? PA_FORMAT_PNG : + (stricmp(ext, ".jpg") ? PA_FORMAT_JPEG : + (stricmp(ext, ".jpeg") ? PA_FORMAT_JPEG : + (stricmp(ext, ".gif") ? PA_FORMAT_GIF : + (stricmp(ext, ".swf") ? PA_FORMAT_SWF : PA_FORMAT_UNKNOWN))))); + } else + AI.format = PA_FORMAT_UNKNOWN; ProtoBroadcastAck(MODULE,info->hContact,ACKTYPE_AVATAR,ACKRESULT_SUCCESS,(HANDLE) &AI, 0); + if(!info->hContact) + CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)MODULE, 0); } else ProtoBroadcastAck(MODULE,info->hContact,ACKTYPE_AVATAR,ACKRESULT_FAILED, 0, 0); } else -- cgit v1.2.3