diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-04 17:52:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-04 17:52:34 +0300 |
commit | 3de995f6736e1869fedbff7d14c210df0b9b20a9 (patch) | |
tree | 659c27f242e1e0bca78013849f195564e6ab145b | |
parent | 4cb450857e40d6c61f1346801c40374e7f1b0d10 (diff) |
custom icons for UserInfo (AVS, SeenPlugin)
-rw-r--r-- | plugins/AVS/avs.vcxproj | 1 | ||||
-rw-r--r-- | plugins/AVS/avs.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/AVS/res/avatar.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/AVS/res/avs.rc | 7 | ||||
-rw-r--r-- | plugins/AVS/src/acc.cpp | 8 | ||||
-rw-r--r-- | plugins/AVS/src/main.cpp | 7 | ||||
-rw-r--r-- | plugins/AVS/src/options.cpp | 425 | ||||
-rw-r--r-- | plugins/AVS/src/resource.h | 2 | ||||
-rw-r--r-- | plugins/AVS/src/stdafx.h | 15 | ||||
-rw-r--r-- | plugins/AVS/src/userInfo.cpp | 443 | ||||
-rw-r--r-- | plugins/SeenPlugin/res/clock.ico | bin | 0 -> 1150 bytes | |||
-rw-r--r-- | plugins/SeenPlugin/res/resource.rc | 8 | ||||
-rw-r--r-- | plugins/SeenPlugin/src/main.cpp | 31 | ||||
-rw-r--r-- | plugins/SeenPlugin/src/resource.h | 1 | ||||
-rw-r--r-- | plugins/SeenPlugin/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/SeenPlugin/src/userinfo.cpp | 2 | ||||
-rw-r--r-- | src/core/stduserinfo/src/contactinfo.cpp | 2 | ||||
-rw-r--r-- | src/core/stduserinfo/src/stdinfo.cpp | 8 | ||||
-rw-r--r-- | src/core/stduserinfo/src/userinfo.cpp | 6 |
19 files changed, 518 insertions, 453 deletions
diff --git a/plugins/AVS/avs.vcxproj b/plugins/AVS/avs.vcxproj index cddd472d55..d9f23880f3 100644 --- a/plugins/AVS/avs.vcxproj +++ b/plugins/AVS/avs.vcxproj @@ -37,6 +37,7 @@ <PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\utils.cpp" />
+ <ClCompile Include="src\userInfo.cpp" />
<ClInclude Include="src\acc.h" />
<ClInclude Include="src\image_utils.h" />
<ClInclude Include="src\poll.h" />
diff --git a/plugins/AVS/avs.vcxproj.filters b/plugins/AVS/avs.vcxproj.filters index e4eee50b44..421d589193 100644 --- a/plugins/AVS/avs.vcxproj.filters +++ b/plugins/AVS/avs.vcxproj.filters @@ -29,6 +29,9 @@ <ClCompile Include="src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\userInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\acc.h">
diff --git a/plugins/AVS/res/avatar.ico b/plugins/AVS/res/avatar.ico Binary files differnew file mode 100644 index 0000000000..6916aa581e --- /dev/null +++ b/plugins/AVS/res/avatar.ico diff --git a/plugins/AVS/res/avs.rc b/plugins/AVS/res/avs.rc index 8634396540..cf59d5d449 100644 --- a/plugins/AVS/res/avs.rc +++ b/plugins/AVS/res/avs.rc @@ -20,6 +20,13 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /////////////////////////////////////////////////////////////////////////////
//
+// Icon
+//
+
+IDI_AVATAR ICON "avatar.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
// Dialog
//
diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index 36b6ea54b9..359a5660c3 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -24,15 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-#define DM_AVATARCHANGED (WM_USER + 20)
-#define DM_MYAVATARCHANGED (WM_USER + 21)
-
#define GIF_DISPOSAL_UNSPECIFIED 0
#define GIF_DISPOSAL_LEAVE 1
#define GIF_DISPOSAL_BACKGROUND 2
#define GIF_DISPOSAL_PREVIOUS 3
-typedef struct
+struct ACCData
{
MCONTACT hContact;
char proto[64];
@@ -71,8 +68,7 @@ typedef struct int disposal_method;
} frame;
} ag;
-
-} ACCData;
+};
BOOL AnimatedGifGetData(ACCData *data)
diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 9fd4421229..f99af3102b 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -345,8 +345,15 @@ static int ModulesLoaded(WPARAM, LPARAM) return 0;
}
+static IconItem iconList[] =
+{
+ { LPGEN("Avatar"), "main", IDI_AVATAR },
+};
+
int CMPlugin::Load()
{
+ registerIcon("AVS", iconList);
+
LoadACC();
hShutdownEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index e53585ff12..8a489b6af2 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -24,17 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -#define DM_SETAVATARNAME (WM_USER + 10) -#define DM_REALODAVATAR (WM_USER + 11) -#define DM_AVATARCHANGED (WM_USER + 12) -#define DM_PROTOCOLCHANGED (WM_USER + 13) - extern OBJLIST<protoPicCacheEntry> g_ProtoPictures; extern HANDLE hEventChanged; extern HICON g_hIcon; -extern BOOL ScreenToClient(HWND hWnd, LPRECT lpRect); - static BOOL dialoginit = TRUE; struct WindowData @@ -440,7 +433,7 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar ///////////////////////////////////////////////////////////////////////////////////////// -static void LoadTransparentData(HWND hwndDlg, MCONTACT hContact) +void LoadTransparentData(HWND hwndDlg, MCONTACT hContact) { CheckDlgButton(hwndDlg, IDC_MAKETRANSPBKG, db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", g_plugin.getByte("MakeTransparentBkg", 0)) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", g_plugin.getWord("TranspBkgNumPoints", 5))); @@ -476,7 +469,7 @@ static void SaveTransparentData(HWND hwndDlg, MCONTACT hContact) db_set_w(hContact, "ContactPhoto", "TranspBkgColorDiff", tmp); } -static void SaveTransparentData(HWND hwndDlg, MCONTACT hContact, BOOL locked) +void SaveTransparentData(HWND hwndDlg, MCONTACT hContact, BOOL locked) { SaveTransparentData(hwndDlg, hContact); @@ -730,417 +723,3 @@ int OptInit(WPARAM wParam, LPARAM) g_plugin.addOptions(wParam, &odp); return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// -// User info dialog - -class AvatarUserInfoDlg : public CUserInfoPageDlg -{ - HANDLE hHook = nullptr; - - CCtrlCheck chkTransparent; - CCtrlButton btnHide, btnChange, btnDefaults, btnProtect, btnReset, btnDelete; - - void ReloadAvatar() - { - SaveTransparentData(m_hwnd, m_hContact, IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR)); - ChangeAvatar(m_hContact, true); - } - - INT_PTR OnChangeAvatar(UINT, WPARAM, LPARAM) - { - InvalidateRect(GetDlgItem(m_hwnd, IDC_PROTOPIC), nullptr, TRUE); - return 0; - } - - UI_MESSAGE_MAP(AvatarUserInfoDlg, CUserInfoPageDlg); - UI_MESSAGE(DM_AVATARCHANGED, OnChangeAvatar); - UI_MESSAGE_MAP_END(); - -public: - AvatarUserInfoDlg() : - CUserInfoPageDlg(g_plugin, IDD_USER_AVATAR), - btnHide(this, IDC_HIDEAVATAR), - btnReset(this, IDC_RESET), - btnChange(this, IDC_CHANGE), - btnDelete(this, IDC_DELETE), - btnProtect(this, IDC_PROTECTAVATAR), - btnDefaults(this, ID_USE_DEFAULTS), - chkTransparent(this, IDC_MAKETRANSPBKG) - { - btnHide.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Hide); - btnReset.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Reset); - btnChange.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Change); - btnDelete.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Delete); - btnProtect.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Protect); - btnDefaults.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_UseDefaults); - - chkTransparent.OnChange = Callback(this, &AvatarUserInfoDlg::onChange_Transparent); - } - - bool OnInitDialog() override - { - hHook = HookEventMessage(ME_AV_AVATARCHANGED, m_hwnd, DM_AVATARCHANGED); - - HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); - SendMessage(protopic, AVATAR_SETCONTACT, 0, m_hContact); - SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); - SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("Contact has no avatar")); - SendMessage(protopic, AVATAR_RESPECTHIDDEN, 0, (LPARAM)FALSE); - SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - - SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); - CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(m_hwnd, IDC_HIDEAVATAR, Contact::IsHidden(m_hContact) ? BST_CHECKED : BST_UNCHECKED); - - SendDlgItemMessage(m_hwnd, IDC_BKG_NUM_POINTS_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS), 0); - SendDlgItemMessage(m_hwnd, IDC_BKG_NUM_POINTS_SPIN, UDM_SETRANGE, 0, MAKELONG(8, 2)); - - SendDlgItemMessage(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE), 0); - SendDlgItemMessage(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); - - LoadTransparentData(m_hwnd, GetContactThatHaveTheAvatar(m_hContact)); - return true; - } - - void OnDestroy() override - { - UnhookEvent(hHook); - } - - void onClick_UseDefaults(CCtrlButton *) - { - m_hContact = GetContactThatHaveTheAvatar(m_hContact); - - db_unset(m_hContact, "ContactPhoto", "MakeTransparentBkg"); - db_unset(m_hContact, "ContactPhoto", "TranspBkgNumPoints"); - db_unset(m_hContact, "ContactPhoto", "TranspBkgColorDiff"); - - LoadTransparentData(m_hwnd, m_hContact); - ReloadAvatar(); - } - - void onClick_Change(CCtrlButton *) - { - SetAvatar(m_hContact, 0); - SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); - CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); - } - - void onClick_Hide(CCtrlButton *) - { - bool hidden = IsDlgButtonChecked(m_hwnd, IDC_HIDEAVATAR) != 0; - SetAvatarAttribute(m_hContact, AVS_HIDEONCLIST, hidden); - if (hidden != Contact::IsHidden(m_hContact)) - Contact::Hide(m_hContact, hidden); - } - - void onClick_Protect(CCtrlButton *) - { - BOOL locked = IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR); - SaveTransparentData(m_hwnd, m_hContact, locked); - ProtectAvatar(m_hContact, locked ? 1 : 0); - } - - void onChange_Transparent(CCtrlCheck *) - { - BOOL enable = IsDlgButtonChecked(m_hwnd, IDC_MAKETRANSPBKG); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_L), enable); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_SPIN), enable); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS), enable); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_L), enable); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN), enable); - EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE), enable); - ReloadAvatar(); - } - - void onClick_Reset(CCtrlButton *) - { - ProtectAvatar(m_hContact, 0); - if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { - DBVARIANT dbv = { 0 }; - if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { - DeleteFile(dbv.pwszVal); - db_free(&dbv); - } - } - db_unset(m_hContact, "ContactPhoto", "Locked"); - db_unset(m_hContact, "ContactPhoto", "Backup"); - db_unset(m_hContact, "ContactPhoto", "RFile"); - db_unset(m_hContact, "ContactPhoto", "File"); - db_unset(m_hContact, "ContactPhoto", "Format"); - - char *szProto = Proto_GetBaseAccountName(m_hContact); - db_unset(m_hContact, szProto, "AvatarHash"); - DeleteAvatarFromCache(m_hContact, FALSE); - - QueueAdd(m_hContact); - } - - void onClick_Delete(CCtrlButton *) - { - ProtectAvatar(m_hContact, 0); - if (MessageBoxW(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { - DBVARIANT dbv = { 0 }; - if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { - DeleteFile(dbv.pwszVal); - db_free(&dbv); - } - } - db_unset(m_hContact, "ContactPhoto", "Locked"); - db_unset(m_hContact, "ContactPhoto", "Backup"); - db_unset(m_hContact, "ContactPhoto", "RFile"); - db_unset(m_hContact, "ContactPhoto", "File"); - db_unset(m_hContact, "ContactPhoto", "Format"); - DeleteAvatarFromCache(m_hContact, FALSE); - SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); - } -}; - -///////////////////////////////////////////////////////////////////////////////////////// -// Protocol avatar dialog - -static char* GetSelectedProtocol(HWND hwndDlg) -{ - HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS); - - // Get selection - int iItem = ListView_GetSelectionMark(hwndList); - if (iItem < 0) - return nullptr; - - // Get protocol name - LVITEM item = { 0 }; - item.mask = LVIF_PARAM; - item.iItem = iItem; - SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); - return (char*)item.lParam; -} - -static void EnableDisableControls(HWND hwndDlg, char *proto) -{ - if (IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) { - if (proto == nullptr) { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); - } - else { - if (!ProtoServiceExists(proto, PS_SETMYAVATAR)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); - - int width, height; - SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_GETUSEDSPACE, (WPARAM)&width, (LPARAM)&height); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), (LPARAM)width != 0 || height != 0); - } - } - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); - - if (g_plugin.getByte("GlobalUserAvatarNotConsistent", 1)) - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); - else { - int width, height; - SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_GETUSEDSPACE, (WPARAM)&width, (LPARAM)&height); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), (LPARAM)width != 0 || height != 0); - } - } -} - -static void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy) -{ - RECT rc; - GetWindowRect(hwnd, &rc); - ScreenToClient(parent, &rc); - OffsetRect(&rc, dx, dy); - MoveWindow(hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); -} - -static void EnableDisableProtocols(HWND hwndDlg, BOOL init) -{ - int diff = 147; // Pre-calc - BOOL perProto = IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO); - HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS); - - if (perProto) { - if (!init && !IsWindowVisible(hwndList)) { - // Show list of protocols - ShowWindow(hwndList, SW_SHOW); - - // Move controls - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_PROTOPIC), diff, 0); - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_CHANGE), diff, 0); - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_DELETE), diff, 0); - } - - char * proto = GetSelectedProtocol(hwndDlg); - if (proto == nullptr) { - ListView_SetItemState(hwndList, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x0F); - } - else { - SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, (LPARAM)proto); - EnableDisableControls(hwndDlg, proto); - } - } - else { - if (init || IsWindowVisible(hwndList)) { - // Show list of protocols - ShowWindow(hwndList, SW_HIDE); - - // Move controls - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_PROTOPIC), -diff, 0); - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_CHANGE), -diff, 0); - OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_DELETE), -diff, 0); - } - - SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, NULL); - } -} - -class AvatarProtoInfoDlg : public CUserInfoPageDlg -{ - CCtrlCheck chkPerProto; - CCtrlButton btnChange, btnDelete; - CCtrlListView protocols; - -public: - AvatarProtoInfoDlg() : - CUserInfoPageDlg(g_plugin, IDD_PROTO_AVATARS), - protocols(this, IDC_PROTOCOLS), - btnChange(this, IDC_CHANGE), - btnDelete(this, IDC_DELETE), - chkPerProto(this, IDC_PER_PROTO) - { - btnChange.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Change); - btnDelete.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Delete); - - chkPerProto.OnChange = Callback(this, &AvatarProtoInfoDlg::onChange_PerProto); - } - - bool OnInitDialog() override - { - HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); - SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); - SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("No avatar")); - SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); - - protocols.SetExtendedListViewStyleEx(0, LVS_EX_SUBITEMIMAGES); - - HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); - protocols.SetImageList(hIml, LVSIL_SMALL); - - LVCOLUMN lvc = { 0 }; - lvc.mask = LVCF_FMT; - lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; - protocols.InsertColumn(0, &lvc); - - LVITEM item = { 0 }; - item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; - item.iItem = 1000; - - // List protocols - int num = 0; - for (auto &it : Accounts()) { - if (!ProtoServiceExists(it->szModuleName, PS_GETMYAVATAR)) - continue; - - if (!Proto_IsAvatarsEnabled(it->szModuleName)) - continue; - - ImageList_AddIcon(hIml, Skin_LoadProtoIcon(it->szModuleName, ID_STATUS_ONLINE)); - item.pszText = it->tszAccountName; - item.iImage = num; - item.lParam = (LPARAM)it->szModuleName; - protocols.InsertItem(&item); - num++; - } - - protocols.SetColumnWidth(0, LVSCW_AUTOSIZE); - protocols.Arrange(LVA_ALIGNLEFT | LVA_ALIGNTOP); - - // Check if should show per protocol avatars - CheckDlgButton(m_hwnd, IDC_PER_PROTO, g_plugin.getByte("PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); - EnableDisableProtocols(m_hwnd, TRUE); - return true; - } - - void onItemChanged_List(CCtrlListView::TEventInfo *ev) - { - LPNMLISTVIEW li = ev->nmlv; - if (li->uNewState & LVIS_SELECTED) { - SendDlgItemMessage(m_hwnd, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, li->lParam); - EnableDisableControls(m_hwnd, (char*)li->lParam); - } - } - - INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override - { - if (msg == WM_NOTIFY) { - LPNMHDR hdr = (LPNMHDR)lParam; - if (hdr->idFrom == IDC_PROTOPIC && hdr->code == NM_AVATAR_CHANGED) - EnableDisableControls(m_hwnd, GetSelectedProtocol(m_hwnd)); - } - return CDlgBase::DlgProc(msg, wParam, lParam); - } - - void onClick_Change(CCtrlButton *) - { - if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) - SetMyAvatar(NULL, NULL); - else { - char *proto = GetSelectedProtocol(m_hwnd); - if (proto != nullptr) - SetMyAvatar((WPARAM)proto, NULL); - } - } - - void onClick_Delete(CCtrlButton *) - { - if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) { - if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), TranslateT("Global avatar"), MB_YESNO) == IDYES) - SetMyAvatar(NULL, (LPARAM)L""); - } - else { - if (char *proto = GetSelectedProtocol(m_hwnd)) { - char description[256]; - CallProtoService(proto, PS_GETNAME, _countof(description), (LPARAM)description); - wchar_t *descr = mir_a2u(description); - if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) - SetMyAvatar((WPARAM)proto, (LPARAM)L""); - mir_free(descr); - } - } - } - - void onChange_PerProto(CCtrlCheck*) - { - g_plugin.setByte("PerProtocolUserAvatars", IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO) ? 1 : 0); - EnableDisableProtocols(m_hwnd, FALSE); - } -}; - -int OnDetailsInit(WPARAM wParam, LPARAM hContact) -{ - USERINFOPAGE uip = {}; - uip.szTitle.a = LPGEN("Avatar"); - - if (hContact == NULL) { - // User dialog - uip.pDialog = new AvatarProtoInfoDlg(); - g_plugin.addUserInfo(wParam, &uip); - } - else { - char *szProto = Proto_GetBaseAccountName(hContact); - if (szProto == nullptr || g_plugin.getByte(szProto, 1)) { - // Contact dialog - uip.position = -2000000000; - uip.pDialog = new AvatarUserInfoDlg(); - g_plugin.addUserInfo(wParam, &uip); - } - } - return 0; -} diff --git a/plugins/AVS/src/resource.h b/plugins/AVS/src/resource.h index f00a86980c..b8dacf4123 100644 --- a/plugins/AVS/src/resource.h +++ b/plugins/AVS/src/resource.h @@ -11,6 +11,8 @@ #define IDD_USER_AVATAR 106
#define IDD_PROTO_AVATARS 107
#define IDD_OPTIONS_AVATARS 108
+#define IDI_AVATAR 109
+
#define IDC_PROTOCOLS 1001
#define IDC_SHOWWARNINGS 1002
#define IDC_SETPROTOPIC 1003
diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h index d5a31465ee..05091c2ca9 100644 --- a/plugins/AVS/src/stdafx.h +++ b/plugins/AVS/src/stdafx.h @@ -124,6 +124,12 @@ struct SetMyAvatarHookData #define AVS_DEFAULT "Global avatar"
+#define DM_SETAVATARNAME (WM_USER + 10)
+#define DM_REALODAVATAR (WM_USER + 11)
+#define DM_AVATARCHANGED (WM_USER + 12)
+#define DM_PROTOCOLCHANGED (WM_USER + 13)
+#define DM_MYAVATARCHANGED (WM_USER + 21)
+
void mir_sleep(int time);
extern bool g_shutDown;
extern wchar_t g_szDataPath[]; // user datae path (read at startup only)
@@ -177,6 +183,9 @@ int Proto_GetAvatarMaxFileSize(const char *proto); protoPicCacheEntry* GetProtoDefaultAvatar(MCONTACT hContact);
-int OnDetailsInit(WPARAM wParam, LPARAM lParam);
-int OptInit(WPARAM wParam, LPARAM lParam);
-void InitServices();
+int OnDetailsInit(WPARAM wParam, LPARAM lParam);
+int OptInit(WPARAM wParam, LPARAM lParam);
+void InitServices();
+
+void LoadTransparentData(HWND hwndDlg, MCONTACT hContact);
+void SaveTransparentData(HWND hwndDlg, MCONTACT hContact, BOOL locked);
diff --git a/plugins/AVS/src/userInfo.cpp b/plugins/AVS/src/userInfo.cpp new file mode 100644 index 0000000000..bbf8d0d0f3 --- /dev/null +++ b/plugins/AVS/src/userInfo.cpp @@ -0,0 +1,443 @@ +/* +Copyright (C) 2012-22 Miranda NG team (https://miranda-ng.org) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" + +BOOL ScreenToClient(HWND hWnd, LPRECT lpRect); + +///////////////////////////////////////////////////////////////////////////////////////// +// User info dialog + +class AvatarUserInfoDlg : public CUserInfoPageDlg +{ + HANDLE hHook = nullptr; + + CCtrlSpin spinPoints, spinDifference; + CCtrlCheck chkTransparent; + CCtrlButton btnHide, btnChange, btnDefaults, btnProtect, btnReset, btnDelete; + + void ReloadAvatar() + { + SaveTransparentData(m_hwnd, m_hContact, IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR)); + ChangeAvatar(m_hContact, true); + } + + INT_PTR OnChangeAvatar(UINT, WPARAM, LPARAM) + { + InvalidateRect(GetDlgItem(m_hwnd, IDC_PROTOPIC), nullptr, TRUE); + return 0; + } + + UI_MESSAGE_MAP(AvatarUserInfoDlg, CUserInfoPageDlg); + UI_MESSAGE(DM_AVATARCHANGED, OnChangeAvatar); + UI_MESSAGE_MAP_END(); + +public: + AvatarUserInfoDlg() : + CUserInfoPageDlg(g_plugin, IDD_USER_AVATAR), + btnHide(this, IDC_HIDEAVATAR), + btnReset(this, IDC_RESET), + btnChange(this, IDC_CHANGE), + btnDelete(this, IDC_DELETE), + btnProtect(this, IDC_PROTECTAVATAR), + btnDefaults(this, ID_USE_DEFAULTS), + chkTransparent(this, IDC_MAKETRANSPBKG), + spinPoints(this, IDC_BKG_NUM_POINTS_SPIN, 8, 2), + spinDifference(this, IDC_BKG_NUM_POINTS_SPIN, 100) + { + btnHide.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Hide); + btnReset.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Reset); + btnChange.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Change); + btnDelete.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Delete); + btnProtect.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_Protect); + btnDefaults.OnClick = Callback(this, &AvatarUserInfoDlg::onClick_UseDefaults); + + chkTransparent.OnChange = Callback(this, &AvatarUserInfoDlg::onChange_Transparent); + } + + bool OnInitDialog() override + { + hHook = HookEventMessage(ME_AV_AVATARCHANGED, m_hwnd, DM_AVATARCHANGED); + + LoadTransparentData(m_hwnd, GetContactThatHaveTheAvatar(m_hContact)); + return true; + } + + bool OnRefresh() override + { + HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); + SendMessage(protopic, AVATAR_SETCONTACT, 0, m_hContact); + SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); + SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("Contact has no avatar")); + SendMessage(protopic, AVATAR_RESPECTHIDDEN, 0, (LPARAM)FALSE); + SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); + + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); + CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(m_hwnd, IDC_HIDEAVATAR, Contact::IsHidden(m_hContact) ? BST_CHECKED : BST_UNCHECKED); + return false; + } + + bool IsEmpty() const override + { + auto wszFileName(db_get_wsm(m_hContact, "ContactPhoto", "File")); + return (wszFileName.IsEmpty() || _waccess(wszFileName, 0) != 0); + } + + void OnDestroy() override + { + UnhookEvent(hHook); + } + + void onClick_UseDefaults(CCtrlButton *) + { + m_hContact = GetContactThatHaveTheAvatar(m_hContact); + + db_unset(m_hContact, "ContactPhoto", "MakeTransparentBkg"); + db_unset(m_hContact, "ContactPhoto", "TranspBkgNumPoints"); + db_unset(m_hContact, "ContactPhoto", "TranspBkgColorDiff"); + + LoadTransparentData(m_hwnd, m_hContact); + ReloadAvatar(); + } + + void onClick_Change(CCtrlButton *) + { + SetAvatar(m_hContact, 0); + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); + CheckDlgButton(m_hwnd, IDC_PROTECTAVATAR, db_get_b(m_hContact, "ContactPhoto", "Locked", 0) ? BST_CHECKED : BST_UNCHECKED); + } + + void onClick_Hide(CCtrlButton *) + { + bool hidden = IsDlgButtonChecked(m_hwnd, IDC_HIDEAVATAR) != 0; + SetAvatarAttribute(m_hContact, AVS_HIDEONCLIST, hidden); + if (hidden != Contact::IsHidden(m_hContact)) + Contact::Hide(m_hContact, hidden); + } + + void onClick_Protect(CCtrlButton *) + { + BOOL locked = IsDlgButtonChecked(m_hwnd, IDC_PROTECTAVATAR); + SaveTransparentData(m_hwnd, m_hContact, locked); + ProtectAvatar(m_hContact, locked ? 1 : 0); + } + + void onChange_Transparent(CCtrlCheck *) + { + BOOL enable = IsDlgButtonChecked(m_hwnd, IDC_MAKETRANSPBKG); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_L), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS_SPIN), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_NUM_POINTS), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_L), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE_SPIN), enable); + EnableWindow(GetDlgItem(m_hwnd, IDC_BKG_COLOR_DIFFERENCE), enable); + ReloadAvatar(); + } + + void onClick_Reset(CCtrlButton *) + { + ProtectAvatar(m_hContact, 0); + if (MessageBox(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { + DBVARIANT dbv = { 0 }; + if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { + DeleteFile(dbv.pwszVal); + db_free(&dbv); + } + } + db_unset(m_hContact, "ContactPhoto", "Locked"); + db_unset(m_hContact, "ContactPhoto", "Backup"); + db_unset(m_hContact, "ContactPhoto", "RFile"); + db_unset(m_hContact, "ContactPhoto", "File"); + db_unset(m_hContact, "ContactPhoto", "Format"); + + char *szProto = Proto_GetBaseAccountName(m_hContact); + db_unset(m_hContact, szProto, "AvatarHash"); + DeleteAvatarFromCache(m_hContact, FALSE); + + QueueAdd(m_hContact); + } + + void onClick_Delete(CCtrlButton *) + { + ProtectAvatar(m_hContact, 0); + if (MessageBoxW(nullptr, TranslateT("Delete picture file from disk (may be necessary to force a reload, but will delete local pictures)?"), TranslateT("Reset contact picture"), MB_YESNO) == IDYES) { + DBVARIANT dbv = { 0 }; + if (!db_get_ws(m_hContact, "ContactPhoto", "File", &dbv)) { + DeleteFile(dbv.pwszVal); + db_free(&dbv); + } + } + db_unset(m_hContact, "ContactPhoto", "Locked"); + db_unset(m_hContact, "ContactPhoto", "Backup"); + db_unset(m_hContact, "ContactPhoto", "RFile"); + db_unset(m_hContact, "ContactPhoto", "File"); + db_unset(m_hContact, "ContactPhoto", "Format"); + DeleteAvatarFromCache(m_hContact, FALSE); + SendMessage(m_hwnd, DM_SETAVATARNAME, 0, 0); + } +}; + +///////////////////////////////////////////////////////////////////////////////////////// +// Protocol avatar dialog + +static char* GetSelectedProtocol(HWND hwndDlg) +{ + HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS); + + // Get selection + int iItem = ListView_GetSelectionMark(hwndList); + if (iItem < 0) + return nullptr; + + // Get protocol name + LVITEM item = { 0 }; + item.mask = LVIF_PARAM; + item.iItem = iItem; + SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&item); + return (char*)item.lParam; +} + +static void EnableDisableControls(HWND hwndDlg, char *proto) +{ + if (IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO)) { + if (proto == nullptr) { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); + } + else { + if (!ProtoServiceExists(proto, PS_SETMYAVATAR)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); + + int width, height; + SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_GETUSEDSPACE, (WPARAM)&width, (LPARAM)&height); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), (LPARAM)width != 0 || height != 0); + } + } + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); + + if (g_plugin.getByte("GlobalUserAvatarNotConsistent", 1)) + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); + else { + int width, height; + SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_GETUSEDSPACE, (WPARAM)&width, (LPARAM)&height); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), (LPARAM)width != 0 || height != 0); + } + } +} + +static void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy) +{ + RECT rc; + GetWindowRect(hwnd, &rc); + ScreenToClient(parent, &rc); + OffsetRect(&rc, dx, dy); + MoveWindow(hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); +} + +static void EnableDisableProtocols(HWND hwndDlg, BOOL init) +{ + int diff = 147; // Pre-calc + BOOL perProto = IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO); + HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS); + + if (perProto) { + if (!init && !IsWindowVisible(hwndList)) { + // Show list of protocols + ShowWindow(hwndList, SW_SHOW); + + // Move controls + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_PROTOPIC), diff, 0); + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_CHANGE), diff, 0); + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_DELETE), diff, 0); + } + + char * proto = GetSelectedProtocol(hwndDlg); + if (proto == nullptr) { + ListView_SetItemState(hwndList, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x0F); + } + else { + SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, (LPARAM)proto); + EnableDisableControls(hwndDlg, proto); + } + } + else { + if (init || IsWindowVisible(hwndList)) { + // Show list of protocols + ShowWindow(hwndList, SW_HIDE); + + // Move controls + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_PROTOPIC), -diff, 0); + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_CHANGE), -diff, 0); + OffsetWindow(hwndDlg, GetDlgItem(hwndDlg, IDC_DELETE), -diff, 0); + } + + SendDlgItemMessage(hwndDlg, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, NULL); + } +} + +class AvatarProtoInfoDlg : public CUserInfoPageDlg +{ + CCtrlCheck chkPerProto; + CCtrlButton btnChange, btnDelete; + CCtrlListView protocols; + +public: + AvatarProtoInfoDlg() : + CUserInfoPageDlg(g_plugin, IDD_PROTO_AVATARS), + protocols(this, IDC_PROTOCOLS), + btnChange(this, IDC_CHANGE), + btnDelete(this, IDC_DELETE), + chkPerProto(this, IDC_PER_PROTO) + { + btnChange.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Change); + btnDelete.OnClick = Callback(this, &AvatarProtoInfoDlg::onClick_Delete); + + chkPerProto.OnChange = Callback(this, &AvatarProtoInfoDlg::onChange_PerProto); + } + + bool OnInitDialog() override + { + HWND protopic = GetDlgItem(m_hwnd, IDC_PROTOPIC); + SendMessage(protopic, AVATAR_SETAVATARBORDERCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNSHADOW)); + SendMessage(protopic, AVATAR_SETNOAVATARTEXT, 0, (LPARAM)LPGENW("No avatar")); + SendMessage(protopic, AVATAR_SETRESIZEIFSMALLER, 0, (LPARAM)FALSE); + + protocols.SetExtendedListViewStyleEx(0, LVS_EX_SUBITEMIMAGES); + + HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); + protocols.SetImageList(hIml, LVSIL_SMALL); + + LVCOLUMN lvc = { 0 }; + lvc.mask = LVCF_FMT; + lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; + protocols.InsertColumn(0, &lvc); + + LVITEM item = { 0 }; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + item.iItem = 1000; + + // List protocols + int num = 0; + for (auto &it : Accounts()) { + if (!ProtoServiceExists(it->szModuleName, PS_GETMYAVATAR)) + continue; + + if (!Proto_IsAvatarsEnabled(it->szModuleName)) + continue; + + ImageList_AddIcon(hIml, Skin_LoadProtoIcon(it->szModuleName, ID_STATUS_ONLINE)); + item.pszText = it->tszAccountName; + item.iImage = num; + item.lParam = (LPARAM)it->szModuleName; + protocols.InsertItem(&item); + num++; + } + + protocols.SetColumnWidth(0, LVSCW_AUTOSIZE); + protocols.Arrange(LVA_ALIGNLEFT | LVA_ALIGNTOP); + + // Check if should show per protocol avatars + CheckDlgButton(m_hwnd, IDC_PER_PROTO, g_plugin.getByte("PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); + EnableDisableProtocols(m_hwnd, TRUE); + return true; + } + + void onItemChanged_List(CCtrlListView::TEventInfo *ev) + { + LPNMLISTVIEW li = ev->nmlv; + if (li->uNewState & LVIS_SELECTED) { + SendDlgItemMessage(m_hwnd, IDC_PROTOPIC, AVATAR_SETPROTOCOL, 0, li->lParam); + EnableDisableControls(m_hwnd, (char*)li->lParam); + } + } + + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + { + if (msg == WM_NOTIFY) { + LPNMHDR hdr = (LPNMHDR)lParam; + if (hdr->idFrom == IDC_PROTOPIC && hdr->code == NM_AVATAR_CHANGED) + EnableDisableControls(m_hwnd, GetSelectedProtocol(m_hwnd)); + } + return CDlgBase::DlgProc(msg, wParam, lParam); + } + + void onClick_Change(CCtrlButton *) + { + if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) + SetMyAvatar(NULL, NULL); + else { + char *proto = GetSelectedProtocol(m_hwnd); + if (proto != nullptr) + SetMyAvatar((WPARAM)proto, NULL); + } + } + + void onClick_Delete(CCtrlButton *) + { + if (BST_UNCHECKED == IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO)) { + if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), TranslateT("Global avatar"), MB_YESNO) == IDYES) + SetMyAvatar(NULL, (LPARAM)L""); + } + else { + if (char *proto = GetSelectedProtocol(m_hwnd)) { + char description[256]; + CallProtoService(proto, PS_GETNAME, _countof(description), (LPARAM)description); + wchar_t *descr = mir_a2u(description); + if (MessageBox(m_hwnd, TranslateT("Are you sure you want to remove your avatar?"), descr, MB_YESNO) == IDYES) + SetMyAvatar((WPARAM)proto, (LPARAM)L""); + mir_free(descr); + } + } + } + + void onChange_PerProto(CCtrlCheck*) + { + g_plugin.setByte("PerProtocolUserAvatars", IsDlgButtonChecked(m_hwnd, IDC_PER_PROTO) ? 1 : 0); + EnableDisableProtocols(m_hwnd, FALSE); + } +}; + +int OnDetailsInit(WPARAM wParam, LPARAM hContact) +{ + USERINFOPAGE uip = {}; + uip.szTitle.a = LPGEN("Avatar"); + + if (hContact == NULL) { + // User dialog + uip.pDialog = new AvatarProtoInfoDlg(); + g_plugin.addUserInfo(wParam, &uip); + } + else { + char *szProto = Proto_GetBaseAccountName(hContact); + if (szProto == nullptr || g_plugin.getByte(szProto, 1)) { + // Contact dialog + uip.flags = ODPF_ICON; + uip.position = -2000000000; + uip.pDialog = new AvatarUserInfoDlg(); + uip.dwInitParam = (LPARAM)g_plugin.getIconHandle(IDI_AVATAR); + g_plugin.addUserInfo(wParam, &uip); + } + } + return 0; +} diff --git a/plugins/SeenPlugin/res/clock.ico b/plugins/SeenPlugin/res/clock.ico Binary files differnew file mode 100644 index 0000000000..082058308f --- /dev/null +++ b/plugins/SeenPlugin/res/clock.ico diff --git a/plugins/SeenPlugin/res/resource.rc b/plugins/SeenPlugin/res/resource.rc index 41ee25ec08..93db3c9f5f 100644 --- a/plugins/SeenPlugin/res/resource.rc +++ b/plugins/SeenPlugin/res/resource.rc @@ -46,6 +46,14 @@ END /////////////////////////////////////////////////////////////////////////////
//
+// Icon
+//
+
+IDI_CLOCK ICON "clock.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
// Dialog
//
diff --git a/plugins/SeenPlugin/src/main.cpp b/plugins/SeenPlugin/src/main.cpp index 6ba25a154c..1e2b114f73 100644 --- a/plugins/SeenPlugin/src/main.cpp +++ b/plugins/SeenPlugin/src/main.cpp @@ -68,6 +68,18 @@ void UninitHistoryDialog(void); /////////////////////////////////////////////////////////////////////////////////////////
+INT_PTR GetParsedFormat(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = (MCONTACT)wParam;
+ ptrW wszStamp(g_plugin.getWStringA("MenuStamp"));
+
+ CMStringW wszRet(ParseString(wszStamp ? wszStamp : DEFAULT_MENUSTAMP, hContact));
+
+ return (INT_PTR)wszRet.Detach();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static int MainInit(WPARAM, LPARAM)
{
if (g_bFileActive = g_plugin.getByte("FileOutput", 0))
@@ -92,8 +104,15 @@ static int OnShutdown(WPARAM, LPARAM) return 0;
}
+static IconItem iconList[] =
+{
+ { LPGEN("Clock"), "clock", IDI_CLOCK },
+};
+
int CMPlugin::Load()
{
+ registerIcon(MODULENAME, iconList);
+
g_pUserInfo = WindowList_Create();
g_hShutdownEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
@@ -136,15 +155,3 @@ int CMPlugin::Unload() UninitHistoryDialog();
return 0;
}
-
-
-INT_PTR GetParsedFormat(WPARAM wParam, LPARAM)
-{
-
- MCONTACT hContact = (MCONTACT)wParam;
- ptrW wszStamp(g_plugin.getWStringA("MenuStamp"));
-
- CMStringW wszRet(ParseString(wszStamp ? wszStamp : DEFAULT_MENUSTAMP, hContact));
-
- return (INT_PTR)wszRet.Detach();
-}
\ No newline at end of file diff --git a/plugins/SeenPlugin/src/resource.h b/plugins/SeenPlugin/src/resource.h index f3a5d84aec..f89bed3c03 100644 --- a/plugins/SeenPlugin/src/resource.h +++ b/plugins/SeenPlugin/src/resource.h @@ -8,6 +8,7 @@ #define IDD_USERDETAILS 104
#define IDD_HISTORY 105
#define IDD_POPUPS 106
+#define IDI_CLOCK 107
#define IDC_SEENMENUITEM 1000
#define IDC_MENUITEM 1001
#define IDC_UINFOTAB 1002
diff --git a/plugins/SeenPlugin/src/stdafx.h b/plugins/SeenPlugin/src/stdafx.h index 9172cce71d..61f6009db6 100644 --- a/plugins/SeenPlugin/src/stdafx.h +++ b/plugins/SeenPlugin/src/stdafx.h @@ -121,8 +121,6 @@ void ShowHistory(MCONTACT hContact, uint8_t isAlert); void InitFileOutput(void);
void UninitFileOutput(void);
-INT_PTR GetParsedFormat(WPARAM wParam, LPARAM lParam);
-
struct logthread_info
{
MCONTACT hContact;
diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index adbe29c85c..3a4db98022 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -65,8 +65,10 @@ int UserinfoInit(WPARAM wparam, LPARAM hContact) char *szProto = Proto_GetBaseAccountName(hContact);
if (IsWatchedProtocol(szProto) && !Contact::IsGroupChat(hContact, szProto)) {
USERINFOPAGE uip = {};
+ uip.flags = ODPF_ICON;
uip.szTitle.a = LPGEN("Last seen");
uip.pDialog = new UserinfoDlg();
+ uip.dwInitParam = (LPARAM)g_plugin.getIconHandle(IDI_CLOCK);
g_plugin.addUserInfo(wparam, &uip);
}
return 0;
diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 165c6ba214..8447a39024 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -570,6 +570,6 @@ void InitContactInfo(WPARAM wParam, USERINFOPAGE &uip) {
uip.pDialog = new CContactPage();
uip.szTitle.a = LPGEN("Contact");
- uip.dwInitParam = IDI_CONTACT;
+ uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_CONTACT);
g_plugin.addUserInfo(wParam, &uip);
}
diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index cea7d02464..9b7f624307 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -467,19 +467,19 @@ int DetailsInit(WPARAM wParam, LPARAM lParam) uip.pDialog = new CSummaryDlg();
uip.szGroup.a = LPGEN("General");
uip.szTitle.a = LPGEN("Summary");
- uip.dwInitParam = IDI_SUMMARY;
+ uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_SUMMARY);
g_plugin.addUserInfo(wParam, &uip);
InitContactInfo(wParam, uip);
uip.pDialog = new CLocationDlg();
uip.szTitle.a = LPGEN("Location");
- uip.dwInitParam = IDI_LOCATION;
+ uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_LOCATION);
g_plugin.addUserInfo(wParam, &uip);
uip.pDialog = new CWorkDlg();
uip.szTitle.a = LPGEN("Work");
- uip.dwInitParam = IDI_WORK;
+ uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_WORK);
g_plugin.addUserInfo(wParam, &uip);
uip.pDialog = new CBackgroundDlg();
@@ -489,7 +489,7 @@ int DetailsInit(WPARAM wParam, LPARAM lParam) uip.pDialog = new CNotesDlg();
uip.szTitle.a = LPGEN("Notes");
- uip.dwInitParam = IDI_NOTES;
+ uip.dwInitParam = (INT_PTR)g_plugin.getIconHandle(IDI_NOTES);
g_plugin.addUserInfo(wParam, &uip);
return 0;
}
diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index 82b0cc3ae3..0d24f785b6 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -158,9 +158,11 @@ class CUserInfoDlg : public CDlgBase int iImage = 1;
if ((it->dwFlags & ODPF_ICON) && it->lParam) {
- HICON hIcon = g_plugin.getIcon(it->lParam);
- if (hIcon)
+ HICON hIcon = IcoLib_GetIconByHandle((HANDLE)it->lParam);
+ if (hIcon) {
iImage = ImageList_AddIcon(m_imageList, hIcon);
+ IcoLib_ReleaseIcon(hIcon);
+ }
}
TVINSERTSTRUCT tvis;
|