summaryrefslogtreecommitdiff
path: root/MySpace/proto.cpp
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-10-17 01:13:11 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-10-17 01:13:11 +0000
commitad7c1f95b18a323357ad02cff8609ba55a72d3e3 (patch)
tree263ffb031b2f62a2f1665ba3277483fb8392bc1e /MySpace/proto.cpp
parent3c8b6f59a6ed800740728fb10becba9ff630adb0 (diff)
fix get avatar logic
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@368 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'MySpace/proto.cpp')
-rw-r--r--MySpace/proto.cpp26
1 files changed, 16 insertions, 10 deletions
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;
}