summaryrefslogtreecommitdiff
path: root/plugins/AVS/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-11-08 21:43:09 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-11-08 21:43:09 +0000
commit20885736f969af9eb55f30c373dc465ecfb481ea (patch)
tree8abe92e3958a4948d2e5eba3fd0d33e760e3fbf4 /plugins/AVS/src
parent75b84796d6d14b9df136f4ea47d87aff3cfa5c90 (diff)
- fix for the global avatar's redrawing;
- more _taccess; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10933 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r--plugins/AVS/src/options.cpp87
-rw-r--r--plugins/AVS/src/services.cpp12
-rw-r--r--plugins/AVS/src/utils.cpp14
-rw-r--r--plugins/AVS/src/version.h2
4 files changed, 50 insertions, 65 deletions
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp
index 4cae5a111e..0988050bc2 100644
--- a/plugins/AVS/src/options.cpp
+++ b/plugins/AVS/src/options.cpp
@@ -117,62 +117,61 @@ static void SetProtoPic(char *szProto)
ofn.lpstrInitialDir = _T(".");
*FileName = '\0';
ofn.lpstrDefExt = _T("");
- if (GetOpenFileName(&ofn)) {
- HANDLE hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- return;
+ if (!GetOpenFileName(&ofn))
+ return;
- CloseHandle(hFile);
+ if (_taccess(FileName, 4) == -1)
+ return;
- TCHAR szNewPath[MAX_PATH];
- PathToRelativeT(FileName, szNewPath, g_szDataPath);
- db_set_ts(NULL, PPICT_MODULE, szProto, szNewPath);
+ TCHAR szNewPath[MAX_PATH];
+ PathToRelativeT(FileName, szNewPath, g_szDataPath);
+ db_set_ts(NULL, PPICT_MODULE, szProto, szNewPath);
- if (!lstrcmpA(AVS_DEFAULT, szProto)) {
- for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
+ if (!lstrcmpA(AVS_DEFAULT, szProto)) {
+ for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
+ protoPicCacheEntry& p = g_ProtoPictures[i];
+ if (lstrlenA(p.szProtoname) == 0)
+ continue;
+
+ if (p.hbmPic == 0 || !lstrcmpA(p.szProtoname, AVS_DEFAULT)) {
+ CreateAvatarInCache(0, &p, szProto);
+ NotifyEventHooks(hEventChanged, 0, (LPARAM)&p);
+ }
+ }
+ }
+ else if (strstr(szProto, "Global avatar for")) {
+ char szProtoname[MAX_PATH] = { 0 };
+ lstrcpynA(szProtoname, szProto, lstrlenA(szProto) - lstrlenA("accounts"));
+ lstrcpyA(szProtoname, strrchr(szProtoname, ' ') + 1);
+ for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
+ PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)g_ProtoPictures[i].szProtoname);
+ if (pdescr == NULL && lstrcmpA(g_ProtoPictures[i].szProtoname, szProto))
+ continue;
+
+ if (!lstrcmpA(g_ProtoPictures[i].szProtoname, szProto) || !lstrcmpA(pdescr->szProtoName, szProtoname)) {
protoPicCacheEntry& p = g_ProtoPictures[i];
if (lstrlenA(p.szProtoname) != 0) {
if (p.hbmPic == 0) {
- CreateAvatarInCache(0, &p, (char*)szProto);
+ CreateAvatarInCache(0, &p, szProto);
NotifyEventHooks(hEventChanged, 0, (LPARAM)&p);
}
}
}
}
- else if (strstr(szProto, "Global avatar for")) {
- char szProtoname[MAX_PATH] = { 0 };
- lstrcpynA(szProtoname, szProto, lstrlenA(szProto) - lstrlenA("accounts"));
- lstrcpyA(szProtoname, strrchr(szProtoname, ' ') + 1);
- for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
- PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)g_ProtoPictures[i].szProtoname);
- if (pdescr == NULL && lstrcmpA(g_ProtoPictures[i].szProtoname, szProto))
- continue;
-
- if (!lstrcmpA(g_ProtoPictures[i].szProtoname, szProto) || !lstrcmpA(pdescr->szProtoName, szProtoname)) {
- protoPicCacheEntry& p = g_ProtoPictures[i];
- if (lstrlenA(p.szProtoname) != 0) {
- if (p.hbmPic == 0) {
- CreateAvatarInCache(0, &p, (char*)szProto);
- NotifyEventHooks(hEventChanged, 0, (LPARAM)&p);
- }
- }
- }
- }
- }
- else {
- for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
- protoPicCacheEntry& p = g_ProtoPictures[i];
- if (lstrlenA(p.szProtoname) == 0)
- break;
+ }
+ else {
+ for (int i = 0; i < g_ProtoPictures.getCount(); i++) {
+ protoPicCacheEntry& p = g_ProtoPictures[i];
+ if (lstrlenA(p.szProtoname) == 0)
+ break;
- if (!strcmp(p.szProtoname, szProto) && lstrlenA(p.szProtoname) == lstrlenA(szProto)) {
- if (p.hbmPic != 0)
- DeleteObject(p.hbmPic);
- ZeroMemory(&p, sizeof(avatarCacheEntry));
- CreateAvatarInCache(0, &p, (char*)szProto);
- NotifyEventHooks(hEventChanged, 0, (LPARAM)&p);
- break;
- }
+ if (!strcmp(p.szProtoname, szProto) && lstrlenA(p.szProtoname) == lstrlenA(szProto)) {
+ if (p.hbmPic != 0)
+ DeleteObject(p.hbmPic);
+ ZeroMemory(&p, sizeof(avatarCacheEntry));
+ CreateAvatarInCache(0, &p, szProto);
+ NotifyEventHooks(hEventChanged, 0, (LPARAM)&p);
+ break;
}
}
}
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index 035eb83cdb..3206546bee 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -157,13 +157,10 @@ static INT_PTR avSetAvatar(MCONTACT hContact, TCHAR *tszPath)
else szFinalName = tszPath;
// filename is now set, check it and perform all needed action
- HANDLE hFile = CreateFile(szFinalName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
+ if (_taccess(szFinalName, 4) == -1)
return 0;
// file exists...
- CloseHandle(hFile);
-
TCHAR szBackupName[MAX_PATH];
PathToRelativeT(szFinalName, szBackupName, g_szDataPath);
db_set_ts(hContact, "ContactPhoto", "Backup", szBackupName);
@@ -499,16 +496,11 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, TCHAR *originalFilenam
static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHookData &data, BOOL allAcceptXML, BOOL allAcceptSWF)
{
- HANDLE hFile = 0;
-
int format = ProtoGetAvatarFormat(szFinalName);
- if (format == PA_FORMAT_UNKNOWN || (hFile = CreateFile(szFinalName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
+ if (format == PA_FORMAT_UNKNOWN || _taccess(szFinalName, 4) == -1)
return -3;
- CloseHandle(hFile);
-
// file exists...
-
HBITMAP hBmp = NULL;
if (format == PA_FORMAT_SWF) {
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp
index a59f46af50..d9a4c07229 100644
--- a/plugins/AVS/src/utils.cpp
+++ b/plugins/AVS/src/utils.cpp
@@ -144,11 +144,9 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
return -1;
_tcsncpy_s(tszFilename, VARST(tszFilename), _TRUNCATE);
- if ((hFile = CreateFile(tszFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
+ if (_taccess(tszFilename, 4) == -1)
return -2;
- CloseHandle(hFile);
-
BOOL isTransparentImage = 0;
ace->hbmPic = BmpFilterLoadBitmap(&isTransparentImage, tszFilename);
ace->dwFlags = 0;
@@ -186,9 +184,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
}
// Make transparent?
- if (!noTransparency && !isTransparentImage
- && db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg",
- db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0))) {
+ if (!noTransparency && !isTransparentImage && db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0))) {
if (MakeTransparentBkg(hContact, &ace->hbmPic)) {
ace->dwFlags |= AVS_CUSTOMTRANSPBKG | AVS_HASTRANSPARENCY;
GetObject(ace->hbmPic, sizeof(bminfo), &bminfo);
@@ -197,9 +193,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
}
}
else if (hContact == INVALID_CONTACT_ID) { // My avatars
- if (!noTransparency && !isTransparentImage
- && db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0)
- && db_get_b(0, AVS_MODULE, "MakeMyAvatarsTransparent", 0)) {
+ if (!noTransparency && !isTransparentImage && db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0) && db_get_b(0, AVS_MODULE, "MakeMyAvatarsTransparent", 0)) {
if (MakeTransparentBkg(0, &ace->hbmPic)) {
ace->dwFlags |= AVS_CUSTOMTRANSPBKG | AVS_HASTRANSPARENCY;
GetObject(ace->hbmPic, sizeof(bminfo), &bminfo);
@@ -268,7 +262,7 @@ int GetFileHash(TCHAR* filename)
}
}
}
- while (dwRead == 1024);
+ while (dwRead == 1024);
CloseHandle(hFile);
diff --git a/plugins/AVS/src/version.h b/plugins/AVS/src/version.h
index 5e231725bd..ed30e02cb5 100644
--- a/plugins/AVS/src/version.h
+++ b/plugins/AVS/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 95
#define __RELEASE_NUM 3
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>