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/proto.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'MySpace/proto.cpp') diff --git a/MySpace/proto.cpp b/MySpace/proto.cpp index fbd9e69..e505d9e 100644 --- a/MySpace/proto.cpp +++ b/MySpace/proto.cpp @@ -365,17 +365,23 @@ int GetAvatarInfo(WPARAM wParam,LPARAM lParam) { bool online = (status > ID_STATUS_OFFLINE); bool force = ((wParam & GAIF_FORCE) != 0); - bool file_exists = (DBGetContactSettingString(AI->hContact, MODULE, "AvatarFilename", &dbv2) == 0) && FileExists(dbv2.pszVal); + bool free_dbv2 = (DBGetContactSettingString(AI->hContact, MODULE, "AvatarFilename", &dbv2) == 0); + bool file_exists = free_dbv2 && FileExists(dbv2.pszVal); - if(force && online) { - if(file_exists) { - DeleteFileA(dbv2.pszVal); - DBDeleteContactSetting(0, MODULE, "AvatarFilename"); - } - DownloadAvatar(AI->hContact, dbv.pszVal); - ret = GAIR_WAITFOR; - } else if(file_exists) { + if(file_exists) { strncpy(AI->filename, dbv2.pszVal, sizeof(AI->filename)); + char *ext = strrchr(AI->filename, '.'); + if(ext) ext++; + 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; + ret = GAIR_SUCCESS; } else if(online) { DownloadAvatar(AI->hContact, dbv.pszVal); @@ -385,7 +391,7 @@ int GetAvatarInfo(WPARAM wParam,LPARAM lParam) { } DBFreeVariant(&dbv); - if(file_exists) DBFreeVariant(&dbv2); + if(free_dbv2) DBFreeVariant(&dbv2); return ret; } -- cgit v1.2.3