summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_avatars.h2
-rw-r--r--plugins/AVS/src/services.cpp24
-rw-r--r--plugins/AVS/src/userInfo.cpp4
-rw-r--r--plugins/AVS/src/utils.cpp2
4 files changed, 16 insertions, 16 deletions
diff --git a/include/m_avatars.h b/include/m_avatars.h
index 1cf2fe62a4..25e9841959 100644
--- a/include/m_avatars.h
+++ b/include/m_avatars.h
@@ -237,7 +237,7 @@ struct CONTACTAVATARCHANGEDNOTIFICATION
/*
wParam=0
lParam=(const wchar_t*)Avatar file name or NULL to remove the avatar
-return=0 for success
+return=0 for success, -1 to deny temporary file deletion (suitable for async operations)
*/
#define PS_SETMYAVATAR "/SetMyAvatar"
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index 11636abe8d..56219f6a70 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -337,13 +337,13 @@ void SaveImage(SaveProtocolData &d, char *protocol, int format)
return;
if (d.max_size != 0 && GetFileSize(d.image_file_name) > d.max_size) {
- DeleteFile(d.image_file_name);
+ DeleteFileW(d.image_file_name);
if (format == PA_FORMAT_JPEG) {
// Try with lower quality
if (!BmpFilterSaveBitmap(d.hBmpProto, d.image_file_name, JPEG_QUALITYGOOD)) {
if (GetFileSize(d.image_file_name) > d.max_size) {
- DeleteFile(d.image_file_name);
+ DeleteFileW(d.image_file_name);
d.need_smaller_size = TRUE;
}
else d.saved = TRUE;
@@ -365,14 +365,14 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, const wchar_t *origina
if (!Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_SWF))
return -1;
- return CallProtoService(protocol, PS_SETMYAVATAR, (LPARAM)originalFilename);
+ return CallProtoService(protocol, PS_SETMYAVATAR, 0, (LPARAM)originalFilename);
}
if (originalFormat == PA_FORMAT_XML) {
if (!Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_XML))
return -1;
- return CallProtoService(protocol, PS_SETMYAVATAR, (LPARAM)originalFilename);
+ return CallProtoService(protocol, PS_SETMYAVATAR, 0, (LPARAM)originalFilename);
}
// Get protocol info
@@ -396,7 +396,7 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, const wchar_t *origina
if (d.hBmpProto == nullptr) {
if (d.temp_file[0] != '\0')
- DeleteFile(d.temp_file);
+ DeleteFileW(d.temp_file);
return -1;
}
@@ -405,17 +405,16 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, const wchar_t *origina
&& Proto_IsAvatarFormatSupported(protocol, originalFormat)
&& (d.max_size == 0 || GetFileSize(originalFilename) < d.max_size)) {
if (d.temp_file[0] != '\0')
- DeleteFile(d.temp_file);
+ DeleteFileW(d.temp_file);
// Use original image
- return CallProtoService(protocol, PS_SETMYAVATAR, (LPARAM)originalFilename);
+ return CallProtoService(protocol, PS_SETMYAVATAR, 0, (LPARAM)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, L"mir_av_", 0, d.temp_file) == 0) {
+ if (GetTempPathW(MAX_PATH, d.temp_file) == 0 || GetTempFileNameW(d.temp_file, L"mir_av_", 0, d.temp_file) == 0) {
DeleteObject(d.hBmpProto);
return -1;
}
@@ -455,13 +454,14 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, const wchar_t *origina
if (d.saved) {
// Call proto service
- ret = CallProtoService(protocol, PS_SETMYAVATAR, (LPARAM)d.image_file_name);
- DeleteFileW(d.image_file_name);
+ ret = CallProtoService(protocol, PS_SETMYAVATAR, 0, (LPARAM)d.image_file_name);
+ if (ret != -1)
+ DeleteFileW(d.image_file_name);
}
else ret = -1;
if (d.temp_file[0] != '\0')
- DeleteFile(d.temp_file);
+ DeleteFileW(d.temp_file);
if (d.hBmpProto != hBmp)
DeleteObject(d.hBmpProto);
diff --git a/plugins/AVS/src/userInfo.cpp b/plugins/AVS/src/userInfo.cpp
index 3b7a4bd129..a77064079c 100644
--- a/plugins/AVS/src/userInfo.cpp
+++ b/plugins/AVS/src/userInfo.cpp
@@ -203,7 +203,7 @@ public:
if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) {
DBVARIANT dbv = { 0 };
if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) {
- DeleteFile(dbv.pwszVal);
+ DeleteFileW(dbv.pwszVal);
db_free(&dbv);
}
}
@@ -226,7 +226,7 @@ public:
if (MessageBoxW(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) {
DBVARIANT dbv = { 0 };
if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) {
- DeleteFile(dbv.pwszVal);
+ DeleteFileW(dbv.pwszVal);
db_free(&dbv);
}
}
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp
index 9daf048db9..6c27f50af3 100644
--- a/plugins/AVS/src/utils.cpp
+++ b/plugins/AVS/src/utils.cpp
@@ -440,7 +440,7 @@ void DeleteGlobalUserAvatar()
wchar_t szFilename[MAX_PATH];
MyPathToAbsolute(wszPath, szFilename);
- DeleteFile(szFilename);
+ DeleteFileW(szFilename);
g_plugin.delSetting("GlobalUserAvatarFile");
}