static int InternalRemoveMyAvatar(char *protocol) { SetIgnoreNotify(protocol, TRUE); // Remove avatar int ret = 0; if (protocol != NULL) { if ( ProtoServiceExists(protocol, PS_SETMYAVATAR)) ret = SaveAvatar(protocol, NULL); else ret = -3; if (ret == 0) { // Has global avatar? DBVARIANT dbv = {0}; if ( !db_get_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", &dbv)) { db_free(&dbv); db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); DeleteGlobalUserAvatar(); } } } else { PROTOACCOUNT **accs; int i,count; ProtoEnumAccounts( &count, &accs ); for (i = 0; i < count; i++) { if ( !ProtoServiceExists( accs[i]->szModuleName, PS_SETMYAVATAR)) continue; if (!Proto_IsAvatarsEnabled( accs[i]->szModuleName )) continue; // Found a protocol int retTmp = SaveAvatar( accs[i]->szModuleName, NULL); if (retTmp != 0) ret = retTmp; } DeleteGlobalUserAvatar(); if (ret) db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); else db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 0); } SetIgnoreNotify(protocol, FALSE); ReportMyAvatarChanged(WPARAM((protocol == NULL ) ? "" : protocol), 0); return ret; }
void LJProfile::handleProfileUpdate (const LJProfileData& profile) { ProfileData_ = profile; SaveAvatar (); for (int i = 0; i < ProfileData_.AvatarsID_.count (); ++i) SaveOthersAvatars (ProfileData_.AvatarsID_.value (i), ProfileData_.AvatarsUrls_.value (i)); emit profileUpdated (); }
void LJProfile::handleProfileUpdate (const LJProfileData& profile) { ProfileData_ = profile; std::sort (ProfileData_.Moods_.begin (), ProfileData_.Moods_.end (), [] (decltype (ProfileData_.Moods_.at (0)) mood1, decltype (ProfileData_.Moods_.at (0)) mood2) { return QString::localeAwareCompare (mood1.Name_, mood2.Name_) < 0; }); SaveAvatar (); for (int i = 0; i < ProfileData_.AvatarsID_.count (); ++i) SaveOthersAvatars (ProfileData_.AvatarsID_.value (i), ProfileData_.AvatarsUrls_.value (i)); emit profileUpdated (); }
static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, TCHAR *originalFilename, int originalFormat, BOOL square, BOOL grow) { if (!ProtoServiceExists(protocol, PS_SETMYAVATAR)) return -1; // If is swf or xml, just set it if (originalFormat == PA_FORMAT_SWF) { if (!Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_SWF)) return -1; return SaveAvatar(protocol, originalFilename); } if (originalFormat == PA_FORMAT_XML) { if (!Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_XML)) return -1; return SaveAvatar(protocol, originalFilename); } // Get protocol info SaveProtocolData d = { 0 }; d.max_size = (DWORD)Proto_GetAvatarMaxFileSize(protocol); Proto_GetAvatarMaxSize(protocol, &d.width, &d.height); int orig_width = d.width; int orig_height = d.height; if (Proto_AvatarImageProportion(protocol) & PIP_SQUARE) square = TRUE; // Try to save until a valid image is found or we give up int num_tries = 0; do { // Lets do it ResizeBitmap rb; rb.size = sizeof(ResizeBitmap); rb.hBmp = hBmp; rb.max_height = d.height; rb.max_width = d.width; rb.fit = (grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW) | (square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS); d.hBmpProto = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0); if (d.hBmpProto == NULL) { if (d.temp_file[0] != '\0') DeleteFile(d.temp_file); return -1; } // Check if can use original image if (d.hBmpProto == hBmp && Proto_IsAvatarFormatSupported(protocol, originalFormat) && (d.max_size == 0 || GetFileSize(originalFilename) < d.max_size)) { if (d.temp_file[0] != '\0') DeleteFile(d.temp_file); // Use original image return SaveAvatar(protocol, originalFilename); } // Create a temporary file (if was not created already) if (d.temp_file[0] == '\0') { d.temp_file[0] = '\0'; if (GetTempPath(MAX_PATH, d.temp_file) == 0 || GetTempFileName(d.temp_file, _T("mir_av_"), 0, d.temp_file) == 0) { DeleteObject(d.hBmpProto); return -1; } } // Which format? // First try to use original format if (originalFormat != PA_FORMAT_BMP) SaveImage(d, protocol, originalFormat); if (!d.saved && originalFormat != PA_FORMAT_PNG) SaveImage(d, protocol, PA_FORMAT_PNG); if (!d.saved && originalFormat != PA_FORMAT_JPEG) SaveImage(d, protocol, PA_FORMAT_JPEG); if (!d.saved && originalFormat != PA_FORMAT_GIF) SaveImage(d, protocol, PA_FORMAT_GIF); if (!d.saved) SaveImage(d, protocol, PA_FORMAT_BMP); num_tries++; if (!d.saved && d.need_smaller_size && num_tries < 4) { // Cleanup if (d.hBmpProto != hBmp) DeleteObject(d.hBmpProto); // use a smaller size d.width = orig_width * (4 - num_tries) / 4; d.height = orig_height * (4 - num_tries) / 4; } } while (!d.saved && d.need_smaller_size && num_tries < 4); int ret; if (d.saved) { // Call proto service ret = SaveAvatar(protocol, d.image_file_name); DeleteFile(d.image_file_name); } else ret = -1; if (d.temp_file[0] != '\0') DeleteFile(d.temp_file); if (d.hBmpProto != hBmp) DeleteObject(d.hBmpProto); return ret; }
void LJProfile::handleProfileUpdate (const LJProfileData& profile) { ProfileData_ = profile; SaveAvatar (); emit profileUpdated (); }