summaryrefslogtreecommitdiff
path: root/plugins/AVS/src/options.cpp
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/options.cpp
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/options.cpp')
-rw-r--r--plugins/AVS/src/options.cpp87
1 files changed, 43 insertions, 44 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;
}
}
}