diff options
Diffstat (limited to 'MySpace/proto.cpp')
-rw-r--r-- | MySpace/proto.cpp | 26 |
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;
}
|