summaryrefslogtreecommitdiff
path: root/Plugins/avatarhistory/AvatarHistory.cpp
diff options
context:
space:
mode:
authorwishmaster51@gmail.com <wishmaster51@gmail.com@c086bb3d-8645-0410-b8da-73a8550f86e7>2012-04-21 10:05:59 +0000
committerwishmaster51@gmail.com <wishmaster51@gmail.com@c086bb3d-8645-0410-b8da-73a8550f86e7>2012-04-21 10:05:59 +0000
commite5fcb23f1da0228d227e4397f622fdb38d22bfa3 (patch)
tree1351c86887697b0f967e3823ec41a7045318f174 /Plugins/avatarhistory/AvatarHistory.cpp
parent0984583475f7b6eb332542060cdf451f3aea8c11 (diff)
-fixed notifications of duplicate avatars
(thanks to xaos for testing and reporting it) git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@246 c086bb3d-8645-0410-b8da-73a8550f86e7
Diffstat (limited to 'Plugins/avatarhistory/AvatarHistory.cpp')
-rw-r--r--Plugins/avatarhistory/AvatarHistory.cpp62
1 files changed, 23 insertions, 39 deletions
diff --git a/Plugins/avatarhistory/AvatarHistory.cpp b/Plugins/avatarhistory/AvatarHistory.cpp
index a1be638..13781ed 100644
--- a/Plugins/avatarhistory/AvatarHistory.cpp
+++ b/Plugins/avatarhistory/AvatarHistory.cpp
@@ -23,8 +23,6 @@ Avatar History Plugin
*/
#include "AvatarHistory.h"
-// #define DBGPOPUPS
-
HINSTANCE hInst;
PLUGINLINK *pluginLink;
DWORD mirVer;
@@ -221,8 +219,9 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
- hHooks[2] = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged);
hHooks[3] = HookEvent(ME_OPT_INITIALISE, OptInit);
+ hHooks[4] = HookEvent(ME_SKIN2_ICONSCHANGED, IcoLibIconsChanged);
+ hHooks[5] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
hServices[0] = CreateServiceFunction(MS_AVATARHISTORY_ENABLED, IsEnabled);
hServices[1] = CreateServiceFunction(MS_AVATARHISTORY_GET_CACHED_AVATAR, GetCachedAvatar);
@@ -292,6 +291,8 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
GetHistoryEventText, templates, MAX_REGS(templates));
DestroyIcon(hIcon);
}
+
+ hHooks[2] = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged);
return 0;
}
@@ -489,52 +490,39 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam)
return 0;
}
- BOOL removed = (avatar == NULL && DBGetContactSettingWord(hContact, "ContactPhoto", "Format", 0) == 0);
-
- TCHAR oldhash[1024] = _T("");
- TCHAR * ret = MyDBGetStringT(hContact, MODULE_NAME, "AvatarHash", oldhash, sizeof(oldhash));
-
- BOOL first_time = (ret == NULL);
-
- if(
- (avatar != NULL && !_tcscmp(oldhash, avatar->hash)) // Changed it
- || (avatar == NULL && oldhash[0] == '\0') // Removed it
- )
- {
- ShowDebugPopup(hContact, _T("AVH Debug"), _T("Hashes are the same... skipping"));
- return 0;
- }
-
- if (removed)
- {
- SkinPlaySound("avatar_removed");
- DBWriteContactSettingTString(hContact, MODULE_NAME, "AvatarHash", _T(""));
-
- if (!first_time && ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_removed)
- ShowPopup(hContact, NULL, opts.popup_removed);
+ DBVARIANT dbvOldHash = {0};
+ bool ret = (DBGetContactSettingTString(hContact,MODULE_NAME,"AvatarHash",&dbvOldHash) == 0);
- if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY))
- HistoryEvents_AddToHistorySimple(hContact, EVENTTYPE_AVATAR_CHANGE, 1, DBEF_READ);
- }
- else if (avatar == NULL)
+ if (avatar == NULL)
{
- if (!_tcscmp(oldhash, _T("-")))
+ if (!ret || !_tcscmp(dbvOldHash.ptszVal, _T("-")))
{
- ShowDebugPopup(hContact, _T("AVH Debug"), _T("Changed from a flash avatar to a flash avatar... skipping"));
+ //avoid duplicate "removed avatar" notifications
+ //do not notify on an empty profile
+ ShowDebugPopup(hContact, _T("AVH Debug"), _T("Removed avatar, no avatar before...skipping"));
+ DBFreeVariant(&dbvOldHash);
return 0;
}
+ SkinPlaySound("avatar_removed");
// Is a flash avatar or avs could not load it
DBWriteContactSettingTString(hContact, MODULE_NAME, "AvatarHash", _T("-"));
- if (!first_time && ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
+ if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
ShowPopup(hContact, NULL, opts.popup_changed);
if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY))
- HistoryEvents_AddToHistorySimple(hContact, EVENTTYPE_AVATAR_CHANGE, 0, DBEF_READ);
+ HistoryEvents_AddToHistorySimple(hContact, EVENTTYPE_AVATAR_CHANGE, 1, DBEF_READ);
}
else
{
+ if(ret && !_tcscmp(dbvOldHash.ptszVal, avatar->hash))
+ {
+ // same avatar hash, skipping
+ ShowDebugPopup(hContact, _T("AVH Debug"), _T("Hashes are the same... skipping"));
+ DBFreeVariant(&dbvOldHash);
+ return 0;
+ }
SkinPlaySound("avatar_changed");
DBWriteContactSettingTString(hContact, "AvatarHistory", "AvatarHash", avatar->hash);
@@ -615,7 +603,7 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam)
}
- if (!first_time && ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
+ if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed)
ShowPopup(hContact, NULL, opts.popup_changed);
if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY))
@@ -806,10 +794,6 @@ TCHAR * GetOldStyleAvatarName(TCHAR *fn, HANDLE hContact)
return fn;
}
-
-#include <ShObjIdl.h>
-#include <ShlGuid.h>
-
BOOL CreateShortcut(TCHAR *file, TCHAR *shortcut)
{
CoInitialize(NULL);