diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-23 15:43:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-23 15:43:18 +0000 |
commit | 480aab2b3ffb0b439e160a8c716ef0d982af1acf (patch) | |
tree | 19a065c7ac15df14a6a32435d4e24d36283ae3ac /plugins/AVS/src | |
parent | 7d88f20d344ebd7c8db2778feda873b251019d9a (diff) |
removing direct access to metas: AVS
git-svn-id: http://svn.miranda-ng.org/main/trunk@9924 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AVS/src')
-rw-r--r-- | plugins/AVS/src/cache.cpp | 24 | ||||
-rw-r--r-- | plugins/AVS/src/main.cpp | 28 | ||||
-rw-r--r-- | plugins/AVS/src/utils.cpp | 12 | ||||
-rw-r--r-- | plugins/AVS/src/version.h | 20 |
4 files changed, 35 insertions, 49 deletions
diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index 999d9cba53..e12d979091 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -30,10 +30,10 @@ static CRITICAL_SECTION cachecs, alloccs; * does not link the new block with the old block(s) - caller needs to do this
*/
-static CacheNode *AllocCacheBlock()
+static CacheNode* AllocCacheBlock()
{
CacheNode *allocedBlock = (CacheNode*)malloc(CACHE_BLOCKSIZE * sizeof(struct CacheNode));
- ZeroMemory((void *)allocedBlock, sizeof(struct CacheNode) * CACHE_BLOCKSIZE);
+ ZeroMemory((void *)allocedBlock, sizeof(CacheNode) * CACHE_BLOCKSIZE);
for (int i = 0; i < CACHE_BLOCKSIZE - 1; i++)
allocedBlock[i].pNextNode = &allocedBlock[i + 1]; // pre-link the alloced block
@@ -45,7 +45,7 @@ static CacheNode *AllocCacheBlock() if (g_curBlock == g_maxBlock) {
g_maxBlock += 10;
- g_cacheBlocks = (CacheNode **)realloc(g_cacheBlocks, g_maxBlock * sizeof(CacheNode*));
+ g_cacheBlocks = (CacheNode**)realloc(g_cacheBlocks, g_maxBlock * sizeof(CacheNode*));
}
g_cacheBlocks[g_curBlock++] = allocedBlock;
@@ -88,7 +88,7 @@ static CacheNode* AddToList(CacheNode *node) return pCurrent;
}
-CacheNode *FindAvatarInCache(MCONTACT hContact, BOOL add, BOOL findAny)
+CacheNode* FindAvatarInCache(MCONTACT hContact, BOOL add, BOOL findAny)
{
if (g_shutDown)
return NULL;
@@ -126,7 +126,6 @@ CacheNode *FindAvatarInCache(MCONTACT hContact, BOOL add, BOOL findAny) }
foundNode->ace.hContact = hContact;
- foundNode->dwFlags |= (db_mc_isSub(hContact) ? MC_ISSUBCONTACT : 0);
foundNode->loaded = FALSE;
foundNode->mustLoad = 1; // pic loader will watch this and load images
SetEvent(hLoaderEvent); // wake him up
@@ -142,21 +141,19 @@ CacheNode *FindAvatarInCache(MCONTACT hContact, BOOL add, BOOL findAny) * popup plugin.
*/
-void NotifyMetaAware(MCONTACT hContact, CacheNode *node = NULL, AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)-1)
+void NotifyMetaAware(MCONTACT hContact, CacheNode *node = NULL, AVATARCACHEENTRY *ace = (AVATARCACHEENTRY*)-1)
{
if (g_shutDown)
return;
- if (ace == (AVATARCACHEENTRY *)-1)
+ if (ace == (AVATARCACHEENTRY*)-1)
ace = &node->ace;
NotifyEventHooks(hEventChanged, hContact, (LPARAM)ace);
- if ((node->dwFlags & MC_ISSUBCONTACT) && db_get_b(NULL, META_PROTO, "Enabled", 0)) {
- MCONTACT hMasterContact = db_mc_getMeta(hContact);
- if (hMasterContact && db_mc_getMostOnline(hMasterContact) == hContact && !db_get_b(hMasterContact, "ContactPhoto", "Locked", 0))
- NotifyEventHooks(hEventChanged, (WPARAM)hMasterContact, (LPARAM)ace);
- }
+ MCONTACT hMasterContact = db_mc_getMeta(hContact);
+ if (hMasterContact && db_mc_getMostOnline(hMasterContact) == hContact && !db_get_b(hMasterContact, "ContactPhoto", "Locked", 0))
+ NotifyEventHooks(hEventChanged, (WPARAM)hMasterContact, (LPARAM)ace);
if (node->dwFlags & AVH_MUSTNOTIFY) {
// Fire the event for avatar history
@@ -206,8 +203,7 @@ void DeleteAvatarFromCache(MCONTACT hContact, BOOL forever) hContact = GetContactThatHaveTheAvatar(hContact);
CacheNode *node = FindAvatarInCache(hContact, FALSE);
if (node == NULL) {
- struct CacheNode temp_node = { 0 };
- temp_node.dwFlags |= (db_mc_isSub(hContact) ? MC_ISSUBCONTACT : 0);
+ CacheNode temp_node = { 0 };
NotifyMetaAware(hContact, &temp_node, (AVATARCACHEENTRY *)GetProtoDefaultAvatar(hContact));
return;
}
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index caa11b7469..216d9799c5 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -98,8 +98,8 @@ static TCHAR* getJGMailID(char *szProto) static int ProtocolAck(WPARAM wParam, LPARAM lParam)
{
- ACKDATA *ack = (ACKDATA *) lParam;
- if (ack != NULL && ack->type == ACKTYPE_AVATAR && ack->hContact != 0 && strcmp(ack->szModule, META_PROTO)) {
+ ACKDATA *ack = (ACKDATA*)lParam;
+ if (ack != NULL && ack->type == ACKTYPE_AVATAR && db_mc_isMeta(ack->hContact)) {
if (ack->result == ACKRESULT_SUCCESS) {
if (ack->hProcess == NULL)
ProcessAvatarInfo(ack->hContact, GAIR_NOAVATAR, NULL, ack->szModule);
@@ -116,33 +116,29 @@ static int ProtocolAck(WPARAM wParam, LPARAM lParam) db_set_b(ack->hContact, "ContactPhoto", "NeedUpdate", 1);
QueueAdd(ack->hContact);
}
- else {
- // Fetch it now
+ else // Fetch it now
FetchAvatarFor(ack->hContact, szProto);
- }
}
}
return 0;
}
-static int MetaChanged(WPARAM hContact, LPARAM lParam)
+static int MetaChanged(WPARAM hMeta, LPARAM hSubContact)
{
- if (hContact == 0 || g_shutDown)
+ if (g_shutDown)
return 0;
AVATARCACHEENTRY *ace;
- MCONTACT hSubContact = GetContactThatHaveTheAvatar(hContact);
-
// Get the node
CacheNode *node = FindAvatarInCache(hSubContact, TRUE);
if (node == NULL || !node->loaded) {
- ace = (AVATARCACHEENTRY *)GetProtoDefaultAvatar(hSubContact);
+ ace = (AVATARCACHEENTRY*)GetProtoDefaultAvatar(hSubContact);
QueueAdd(hSubContact);
}
else ace = &node->ace;
- NotifyEventHooks(hEventChanged, hContact, (LPARAM)ace);
+ NotifyEventHooks(hEventChanged, hMeta, (LPARAM)ace);
return 0;
}
@@ -224,16 +220,10 @@ static int ContactSettingChanged(WPARAM hContact, LPARAM lParam) if (cws == NULL || g_shutDown)
return 0;
- if (hContact == 0) {
+ if (hContact == 0)
if (!strcmp(cws->szSetting, "AvatarFile") || !strcmp(cws->szSetting, "PictObject") || !strcmp(cws->szSetting, "AvatarHash") || !strcmp(cws->szSetting, "AvatarSaved"))
ReportMyAvatarChanged((WPARAM)cws->szModule, 0);
- return 0;
- }
- if (!strcmp(cws->szModule, META_PROTO)) {
- if (lstrlenA(cws->szSetting) > 6 && !strncmp(cws->szSetting, "Status", 5))
- MetaChanged(hContact, 0);
- }
return 0;
}
@@ -410,6 +400,8 @@ static int LoadAvatarModule() HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
HookEvent(ME_PROTO_ACK, ProtocolAck);
+ HookEvent(ME_MC_DEFAULTTCHANGED, MetaChanged);
+ HookEvent(ME_MC_SUBCONTACTSCHANGED, MetaChanged);
hEventChanged = CreateHookableEvent(ME_AV_AVATARCHANGED);
hEventContactAvatarChanged = CreateHookableEvent(ME_AV_CONTACTAVATARCHANGED);
diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index e4ab45e2ff..f1a1809be5 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -508,14 +508,12 @@ protoPicCacheEntry *GetProtoDefaultAvatar(MCONTACT hContact) MCONTACT GetContactThatHaveTheAvatar(MCONTACT hContact, int locked)
{
- if (db_get_b(NULL, META_PROTO, "Enabled", 0)) {
- if (db_get_dw(hContact, META_PROTO, "NumContacts", 0) >= 1) {
- if (locked == -1)
- locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);
+ if (db_mc_isMeta(hContact)) {
+ if (locked == -1)
+ locked = db_get_b(hContact, "ContactPhoto", "Locked", 0);
- if (!locked)
- hContact = db_mc_getMostOnline(hContact);
- }
+ if (!locked)
+ hContact = db_mc_getMostOnline(hContact);
}
return hContact;
}
diff --git a/plugins/AVS/src/version.h b/plugins/AVS/src/version.h index 7480ea6f05..ff7c3d5f2d 100644 --- a/plugins/AVS/src/version.h +++ b/plugins/AVS/src/version.h @@ -1,14 +1,14 @@ #define __MAJOR_VERSION 0
-#define __MINOR_VERSION 11
-#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __MINOR_VERSION 95
+#define __RELEASE_NUM 2
+#define __BUILD_NUM 1
#include <stdver.h>
-#define __PLUGIN_NAME "Avatar service"
-#define __FILENAME "AVS.dll"
-#define __DESCRIPTION "Loads and manages contact pictures for other plugins."
-#define __AUTHOR "Nightwish, Pescuma"
-#define __AUTHOREMAIL ""
-#define __AUTHORWEB "http://miranda-ng.org/p/AVS/"
-#define __COPYRIGHT "© 2000-2012 Miranda-IM project, 2012 Miranda NG team"
+#define __PLUGIN_NAME "Avatar service"
+#define __FILENAME "AVS.dll"
+#define __DESCRIPTION "Loads and manages contact pictures for other plugins."
+#define __AUTHOR "Nightwish, Pescuma"
+#define __AUTHOREMAIL ""
+#define __AUTHORWEB "http://miranda-ng.org/p/AVS/"
+#define __COPYRIGHT "© 2000-2012 Miranda-IM project, 2012-14 Miranda NG team"
|