summaryrefslogtreecommitdiff
path: root/plugins/AVS
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-11-08 20:04:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-11-08 20:04:24 +0000
commit75b84796d6d14b9df136f4ea47d87aff3cfa5c90 (patch)
treee9e1d95081758aacc58bfb8173c974009a5e9c53 /plugins/AVS
parent0f869bffb767a7fb2e3ceb4b081ba1ec6953dbfd (diff)
code cleaning:
- (MCONTACT)-1 replaced with INVALID_CONTACT_ID; - DBVARIANT+db_get_ts replaced with ptrT+db_get_tsa; - VARST added for path reading; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10932 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AVS')
-rw-r--r--plugins/AVS/avs_10.vcxproj1
-rw-r--r--plugins/AVS/avs_10.vcxproj.filters3
-rw-r--r--plugins/AVS/avs_12.vcxproj1
-rw-r--r--plugins/AVS/avs_12.vcxproj.filters3
-rw-r--r--plugins/AVS/src/commonheaders.h1
-rw-r--r--plugins/AVS/src/main.cpp4
-rw-r--r--plugins/AVS/src/options.cpp6
-rw-r--r--plugins/AVS/src/services.cpp2
-rw-r--r--plugins/AVS/src/utils.cpp90
-rw-r--r--plugins/AVS/src/version.h2
10 files changed, 56 insertions, 57 deletions
diff --git a/plugins/AVS/avs_10.vcxproj b/plugins/AVS/avs_10.vcxproj
index 34c7fd64c7..0b0bfe2be3 100644
--- a/plugins/AVS/avs_10.vcxproj
+++ b/plugins/AVS/avs_10.vcxproj
@@ -220,6 +220,7 @@
<ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\include\m_avatars.h" />
<ClInclude Include="src\acc.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\image_utils.h" />
diff --git a/plugins/AVS/avs_10.vcxproj.filters b/plugins/AVS/avs_10.vcxproj.filters
index 338e0d11a4..209ee1048d 100644
--- a/plugins/AVS/avs_10.vcxproj.filters
+++ b/plugins/AVS/avs_10.vcxproj.filters
@@ -59,6 +59,9 @@
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\m_avatars.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\avs.rc">
diff --git a/plugins/AVS/avs_12.vcxproj b/plugins/AVS/avs_12.vcxproj
index ba408b6460..b36738e046 100644
--- a/plugins/AVS/avs_12.vcxproj
+++ b/plugins/AVS/avs_12.vcxproj
@@ -223,6 +223,7 @@
<ClCompile Include="src\utils.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\include\m_avatars.h" />
<ClInclude Include="src\acc.h" />
<ClInclude Include="src\commonheaders.h" />
<ClInclude Include="src\image_utils.h" />
diff --git a/plugins/AVS/avs_12.vcxproj.filters b/plugins/AVS/avs_12.vcxproj.filters
index 1c2c19c978..85b6e3a49a 100644
--- a/plugins/AVS/avs_12.vcxproj.filters
+++ b/plugins/AVS/avs_12.vcxproj.filters
@@ -59,6 +59,9 @@
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\m_avatars.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\avs.rc">
diff --git a/plugins/AVS/src/commonheaders.h b/plugins/AVS/src/commonheaders.h
index f483b7dac3..dca9a23bad 100644
--- a/plugins/AVS/src/commonheaders.h
+++ b/plugins/AVS/src/commonheaders.h
@@ -127,6 +127,7 @@ int GetFileHash(TCHAR* filename);
DWORD GetFileSize(TCHAR *szFilename);
void MakePathRelative(MCONTACT hContact);
void MakePathRelative(MCONTACT hContact, TCHAR *dest);
+void MyPathToAbsolute(const TCHAR *ptszPath, TCHAR *ptszDest);
HBITMAP LoadPNG(struct avatarCacheEntry *ace, char *szFilename);
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp
index 42ebac3b36..c122e1f410 100644
--- a/plugins/AVS/src/main.cpp
+++ b/plugins/AVS/src/main.cpp
@@ -185,7 +185,7 @@ static void LoadAccountInfo(PROTOACCOUNT *acc)
g_ProtoPictures.insert(pce);
pce = new protoPicCacheEntry;
- CreateAvatarInCache((MCONTACT)-1, pce, acc->szModuleName);
+ CreateAvatarInCache(INVALID_CONTACT_ID, pce, acc->szModuleName);
pce->szProtoname = mir_strdup(acc->szModuleName);
pce->tszAccName = mir_tstrdup(acc->tszAccountName);
g_MyAvatars.insert(pce);
@@ -384,7 +384,7 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
// Load global avatar
protoPicCacheEntry *pce = new protoPicCacheEntry;
- CreateAvatarInCache((MCONTACT)-1, pce, "");
+ CreateAvatarInCache(INVALID_CONTACT_ID, pce, "");
pce->szProtoname = mir_strdup("");
g_MyAvatars.insert(pce);
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp
index 9cade6f3d3..4cae5a111e 100644
--- a/plugins/AVS/src/options.cpp
+++ b/plugins/AVS/src/options.cpp
@@ -677,15 +677,15 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
szFinalName[0] = 0;
if (is_locked && !db_get_ts(hContact, "ContactPhoto", "Backup", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, szFinalName, g_szDataPath);
+ MyPathToAbsolute(dbv.ptszVal, szFinalName);
db_free(&dbv);
}
else if (!db_get_ts(hContact, "ContactPhoto", "RFile", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, szFinalName, g_szDataPath);
+ MyPathToAbsolute(dbv.ptszVal, szFinalName);
db_free(&dbv);
}
else if (!db_get_ts(hContact, "ContactPhoto", "File", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, szFinalName, g_szDataPath);
+ MyPathToAbsolute(dbv.ptszVal, szFinalName);
db_free(&dbv);
}
szFinalName[MAX_PATH - 1] = 0;
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index 58f707b366..035eb83cdb 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -832,7 +832,7 @@ static void ReloadMyAvatar(LPVOID lpParam)
if (g_MyAvatars[i].hbmPic)
DeleteObject(g_MyAvatars[i].hbmPic);
- if (CreateAvatarInCache((MCONTACT)-1, &g_MyAvatars[i], myAvatarProto) != -1)
+ if (CreateAvatarInCache(INVALID_CONTACT_ID, &g_MyAvatars[i], myAvatarProto) != -1)
NotifyEventHooks(hMyAvatarChanged, (WPARAM)myAvatarProto, (LPARAM)&g_MyAvatars[i]);
else
NotifyEventHooks(hMyAvatarChanged, (WPARAM)myAvatarProto, 0);
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp
index 945b11db2b..a59f46af50 100644
--- a/plugins/AVS/src/utils.cpp
+++ b/plugins/AVS/src/utils.cpp
@@ -26,6 +26,14 @@ void mir_sleep(int time)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// substitutes variables and passes our own data path as base
+
+void MyPathToAbsolute(const TCHAR *ptszPath, TCHAR *ptszDest)
+{
+ PathToAbsoluteT(VARST(ptszPath), ptszDest, g_szDataPath);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// convert the avatar image path to a relative one...
// given: contact handle, path to image
@@ -59,13 +67,12 @@ void MakePathRelative(MCONTACT hContact)
int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
{
- DBVARIANT dbv = { 0 };
char *szExt = NULL;
- TCHAR tszFilename[MAX_PATH];
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD dwFileSizeHigh = 0, dwFileSize = 0, sizeLimit = 0;
- tszFilename[0] = 0;
+ ptrT tszValue;
+ TCHAR tszFilename[MAX_PATH]; tszFilename[0] = 0;
ace->hbmPic = 0;
ace->dwFlags = 0;
@@ -79,57 +86,42 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
if (proto == NULL || !db_get_b(NULL, AVS_MODULE, proto, 1))
return -1;
- if (db_get_b(hContact, "ContactPhoto", "Locked", 0) && !db_get_ts(hContact, "ContactPhoto", "Backup", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
- else if (!db_get_ts(hContact, "ContactPhoto", "RFile", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
- else if (!db_get_ts(hContact, "ContactPhoto", "File", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
+ if (db_get_b(hContact, "ContactPhoto", "Locked", 0) && (tszValue = db_get_tsa(hContact, "ContactPhoto", "Backup")))
+ MyPathToAbsolute(tszValue, tszFilename);
+ else if (tszValue = db_get_tsa(hContact, "ContactPhoto", "RFile"))
+ MyPathToAbsolute(tszValue, tszFilename);
+ else if (tszValue = db_get_tsa(hContact, "ContactPhoto", "File"))
+ MyPathToAbsolute(tszValue, tszFilename);
else return -2;
}
else {
if (hContact == 0) { // create a protocol picture in the proto picture cache
- if (!db_get_ts(NULL, PPICT_MODULE, szProto, &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
- else {
- if (lstrcmpA(szProto, AVS_DEFAULT)) {
- if (!db_get_ts(NULL, PPICT_MODULE, AVS_DEFAULT, &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
-
- if (!strstr(szProto, "Global avatar for")) {
- PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)szProto);
- if (pdescr == NULL)
- return -1;
- char key[MAX_PATH];
- mir_snprintf(key, SIZEOF(key), "Global avatar for %s accounts", pdescr->szProtoName);
- if (!db_get_ts(NULL, PPICT_MODULE, key, &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
- }
+ if (tszValue = db_get_tsa(NULL, PPICT_MODULE, szProto))
+ MyPathToAbsolute(tszValue, tszFilename);
+ else if (lstrcmpA(szProto, AVS_DEFAULT)) {
+ if (tszValue = db_get_tsa(NULL, PPICT_MODULE, AVS_DEFAULT))
+ MyPathToAbsolute(tszValue, tszFilename);
+
+ if (!strstr(szProto, "Global avatar for")) {
+ PROTOACCOUNT* pdescr = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)szProto);
+ if (pdescr == NULL)
+ return -1;
+ char key[MAX_PATH];
+ mir_snprintf(key, SIZEOF(key), "Global avatar for %s accounts", pdescr->szProtoName);
+ if (tszValue = db_get_tsa(NULL, PPICT_MODULE, key))
+ MyPathToAbsolute(tszValue, tszFilename);
}
}
}
- else if (hContact == (MCONTACT)-1) {
+ else if (hContact == INVALID_CONTACT_ID) {
// create own picture - note, own avatars are not on demand, they are loaded once at
// startup and everytime they are changed.
if (szProto[0] == '\0') {
// Global avatar
- if (db_get_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", &dbv))
+ if (tszValue = db_get_tsa(NULL, AVS_MODULE, "GlobalUserAvatarFile"))
+ MyPathToAbsolute(tszValue, tszFilename);
+ else
return -10;
-
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
}
else if (ProtoServiceExists(szProto, PS_GETMYAVATART)) {
if (CallProtoService(szProto, PS_GETMYAVATART, (WPARAM)tszFilename, (LPARAM)MAX_PATH))
@@ -142,10 +134,8 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
else
MultiByteToWideChar(CP_ACP, 0, szFileName, -1, tszFilename, SIZEOF(tszFilename));
}
- else if (!db_get_ts(NULL, szProto, "AvatarFile", &dbv)) {
- PathToAbsoluteT(dbv.ptszVal, tszFilename, g_szDataPath);
- db_free(&dbv);
- }
+ else if (tszValue = db_get_tsa(NULL, szProto, "AvatarFile"))
+ MyPathToAbsolute(tszValue, tszFilename);
else return -1;
}
}
@@ -184,7 +174,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
BOOL noTransparency = db_get_b(0, AVS_MODULE, "RemoveAllTransparency", 0);
// Calc image hash
- if (hContact != 0 && hContact != (MCONTACT)-1) {
+ if (hContact != 0 && hContact != INVALID_CONTACT_ID) {
// Have to reset settings? -> do it if image changed
DWORD imgHash = GetImgHash(ace->hbmPic);
if (imgHash != db_get_dw(hContact, "ContactPhoto", "ImageHash", 0)) {
@@ -206,7 +196,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
}
}
}
- else if (hContact == (MCONTACT)-1) { // My avatars
+ 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)) {
@@ -237,7 +227,7 @@ int CreateAvatarInCache(MCONTACT hContact, avatarCacheEntry *ace, char *szProto)
protoPicCacheEntry *pAce = (protoPicCacheEntry *)ace;
if (hContact == 0)
pAce->dwFlags |= AVS_PROTOPIC;
- else if (hContact == (MCONTACT)-1)
+ else if (hContact == INVALID_CONTACT_ID)
pAce->dwFlags |= AVS_OWNAVATAR;
}
@@ -454,7 +444,7 @@ void DeleteGlobalUserAvatar()
return;
TCHAR szFilename[MAX_PATH];
- PathToAbsoluteT(dbv.ptszVal, szFilename, g_szDataPath);
+ MyPathToAbsolute(dbv.ptszVal, szFilename);
db_free(&dbv);
DeleteFile(szFilename);
diff --git a/plugins/AVS/src/version.h b/plugins/AVS/src/version.h
index 390bf57273..5e231725bd 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 2
+#define __BUILD_NUM 3
#include <stdver.h>