diff options
author | George Hazan <ghazan@miranda.im> | 2019-04-16 20:48:08 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-04-16 20:48:08 +0300 |
commit | 34a7b7b35c879a067f389902ff62b76fe06a63b4 (patch) | |
tree | 4f527f5a58f63d98393cd067e20cf0db527fc386 /protocols | |
parent | 8874457d4ea1ede722f17b2fe29091cffe8cb0c7 (diff) |
ICQ-WIM:
- all these menu items & Visible List editor removed;
- all control over permit/deny lists went to Options - Contact - Visibility;
- fixes #1915 (impossible to set visibility for ICQ contacts)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/ICQ-WIM/res/resources.rc | 21 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/ignore.cpp | 142 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/main.cpp | 41 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 31 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 5 |
5 files changed, 8 insertions, 232 deletions
diff --git a/protocols/ICQ-WIM/res/resources.rc b/protocols/ICQ-WIM/res/resources.rc index 1abfa72b0d..2d5f212c1c 100644 --- a/protocols/ICQ-WIM/res/resources.rc +++ b/protocols/ICQ-WIM/res/resources.rc @@ -125,17 +125,6 @@ BEGIN EDITTEXT IDC_LASTSEEN,74,32,139,10,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP END -IDD_EDITIGNORE DIALOGEX 0, 0, 270, 160 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT -CAPTION "Ignore list editor" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,5,261,136 - DEFPUSHBUTTON "OK",IDOK,217,144,50,14 -END - - ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -173,11 +162,6 @@ BEGIN IDD_INFO_ICQ, DIALOG BEGIN END - - IDD_EDITIGNORE, DIALOG - BEGIN - RIGHTMARGIN, 208 - END END #endif // APSTUDIO_INVOKED @@ -212,11 +196,6 @@ BEGIN 0 END -IDD_EDITIGNORE AFX_DIALOG_LAYOUT -BEGIN - 0 -END - IDD_OPTIONS_ADV AFX_DIALOG_LAYOUT BEGIN 0 diff --git a/protocols/ICQ-WIM/src/ignore.cpp b/protocols/ICQ-WIM/src/ignore.cpp index 66501858df..ae7de463b4 100644 --- a/protocols/ICQ-WIM/src/ignore.cpp +++ b/protocols/ICQ-WIM/src/ignore.cpp @@ -21,148 +21,6 @@ #include "stdafx.h" -class CEditIgnoreListDlg : public CIcqDlgBase -{ - typedef CIcqDlgBase CSuper; - - CCtrlListView m_list; - -public: - CEditIgnoreListDlg(CIcqProto *ppro) : - CSuper(ppro, IDD_EDITIGNORE), - m_list(this, IDC_LIST) - { - m_list.OnClick = Callback(this, &CEditIgnoreListDlg::list_OnClick); - } - - bool OnInitDialog() override - { - HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - ImageList_AddIcon(hImageList, Skin_LoadIcon(SKINICON_OTHER_DELETE)); - m_list.SetImageList(hImageList, LVSIL_SMALL); - - m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_GRIDLINES); - - RECT rc; - GetClientRect(m_list.GetHwnd(), &rc); - - LVCOLUMN lvc = {}; - lvc.mask = LVCF_WIDTH; - lvc.cx = rc.right; - m_list.InsertColumn(0, &lvc); - - auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/preference/getPermitDeny", &CIcqProto::OnRefreshEditIgnore); - pReq << AIMSID(m_proto); - pReq->pUserInfo = this; - m_proto->ExecuteRequest(pReq); - - Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "editIgnore_"); - return true; - } - - void OnDestroy() override - { - m_proto->m_pdlgEditIgnore = nullptr; - Utils_SaveWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "editIgnore_"); - } - - INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override - { - INT_PTR ret = CSuper::DlgProc(uMsg, wParam, lParam); - if (uMsg == WM_SIZE) { - RECT rc; - GetClientRect(m_list.GetHeader(), &rc); - m_list.SetColumnWidth(0, rc.right - rc.left); - } - - return ret; - } - - int Resizer(UTILRESIZECONTROL *urc) override - { - switch (urc->wId) { - case IDC_LIST: - return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT; - } - return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM; - } - - void Refresh(const JSONNode &pData) - { - LVITEM lvi = {}; - lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - - for (auto &it : pData["ignores"]) { - CMStringW wszId(it.as_mstring()); - auto *p = m_proto->FindContactByUIN(wszId); - if (p) { - lvi.pszText = Clist_GetContactDisplayName(p->m_hContact); - lvi.lParam = p->m_hContact; - } - else { - lvi.pszText = wszId.GetBuffer(); - lvi.lParam = -1; - } - - m_list.InsertItem(&lvi); - lvi.iItem++; - } - } - - void list_OnClick(CCtrlListView::TEventInfo*) - { - LVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(m_list.GetHwnd(), &hti.pt); - if (m_list.SubItemHitTest(&hti) == -1) - return; - - if (!(hti.flags & LVHT_ONITEMICON)) - return; - - bool bCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; - if (!bCtrl) - if (IDYES != MessageBoxW(m_hwnd, TranslateT("Do you really want to remove it from ignore list?"), m_proto->m_tszUserName, MB_YESNO)) - return; - - CMStringW userId; - INT_PTR data = m_list.GetItemData(hti.iItem); - if (data == -1) { - wchar_t buf[100]; - m_list.GetItemText(hti.iItem, 0, buf, _countof(buf)); - userId = buf; - } - else userId = m_proto->GetUserId((MCONTACT)data); - - m_proto->SetPermitDeny(userId, true); - m_list.DeleteItem(hti.iItem); - } -}; - -void CIcqProto::OnRefreshEditIgnore(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) -{ - JsonReply root(pReply); - if (root.error() != 200) - return; - - auto *pDlg = (CEditIgnoreListDlg*)pReq->pUserInfo; - pDlg->Refresh(root.data()); -} - -INT_PTR CIcqProto::EditIgnoreList(WPARAM, LPARAM) -{ - if (m_pdlgEditIgnore == nullptr) { - m_pdlgEditIgnore = new CEditIgnoreListDlg(this); - m_pdlgEditIgnore->Show(); - } - else SetForegroundWindow(m_pdlgEditIgnore->GetHwnd()); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - void CIcqProto::GetPermitDeny() { Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/preference/getPermitDeny", &CIcqProto::OnGetPermitDeny) << AIMSID(this)); diff --git a/protocols/ICQ-WIM/src/main.cpp b/protocols/ICQ-WIM/src/main.cpp index 44422837ae..af0248292b 100644 --- a/protocols/ICQ-WIM/src/main.cpp +++ b/protocols/ICQ-WIM/src/main.cpp @@ -77,22 +77,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// -static int OnContactMenu(WPARAM hContact, LPARAM lParam) -{ - Menu_ShowItem(g_plugin.m_hmiRoot, false); - - CIcqProto *proto = CMPlugin::getInstance(hContact); - return proto ? proto->OnContactMenu(hContact, lParam) : 0; -} - -static INT_PTR ICQPermitDeny(WPARAM hContact, LPARAM, LPARAM bAllow) -{ - CIcqProto *proto = CMPlugin::getInstance(hContact); - if (proto) - proto->SetPermitDeny(proto->GetUserId(hContact), bAllow != 0); - return 0; -} - static int ModuleLoad(WPARAM, LPARAM) { g_bSecureIM = ServiceExists("SecureIM/IsContactSecured"); @@ -103,31 +87,6 @@ static int ModuleLoad(WPARAM, LPARAM) static int OnModulesLoaded(WPARAM, LPARAM) { ModuleLoad(0, 0); - - // init menus - CMenuItem mi(&g_plugin); - - SET_UID(mi, 0x9cd3a933, 0x3bd5, 0x4d1c, 0xbd, 0xf1, 0xa8, 0xf9, 0xbf, 0xf0, 0xd7, 0x28); - mi.position = 100000; - mi.name.a = "ICQ"; - mi.hIcolibItem = Skin_LoadProtoIcon(g_plugin.getModule(), ID_STATUS_ONLINE); - g_plugin.m_hmiRoot = Menu_AddContactMenuItem(&mi); - - mi.flags = CMIF_UNMOVABLE; - mi.root = g_plugin.m_hmiRoot; - mi.name.a = LPGEN("Ignore"); - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE); - mi.pszService = "ICQ/Ignore"; - g_plugin.m_hmiIgnore = Menu_AddContactMenuItem(&mi); - CreateServiceFunctionParam(mi.pszService, ICQPermitDeny, 0); - - mi.name.a = LPGEN("Remove Ignore"); - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_ADD); - mi.pszService = "ICQ/RemoveIgnore"; - g_plugin.m_hmiAllow = Menu_AddContactMenuItem(&mi); - CreateServiceFunctionParam(mi.pszService, ICQPermitDeny, 1); - - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnContactMenu); return 0; } diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 06e67ee280..0dc6a223a8 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -159,13 +159,6 @@ void CIcqProto::OnBuildProtoMenu() mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_GROUP); m_hUploadGroups = Menu_AddProtoMenuItem(&mi, m_szModuleName); - mi.pszService = "/EditIgnore"; - CreateProtoService(mi.pszService, &CIcqProto::EditIgnoreList); - mi.name.a = LPGEN("Edit ignore list"); - mi.position++; - mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS); - Menu_AddProtoMenuItem(&mi, m_szModuleName); - Menu_ShowItem(m_hUploadGroups, false); } @@ -201,19 +194,6 @@ INT_PTR CIcqProto::GotoInbox(WPARAM, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// -int CIcqProto::OnContactMenu(WPARAM hContact, LPARAM) -{ - Menu_ShowItem(g_plugin.m_hmiRoot, true); - Menu_ModifyItem(g_plugin.m_hmiRoot, nullptr, Skin_GetProtoIcon(GetContactProto(hContact), ID_STATUS_ONLINE)); - - bool bIgnorable = getDword(hContact, "ApparentMode") != ID_STATUS_OFFLINE; - Menu_ShowItem(g_plugin.m_hmiAllow, !bIgnorable); - Menu_ShowItem(g_plugin.m_hmiIgnore, bIgnorable); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - void CIcqProto::MarkReadTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD) { CIcqProto *ppro = (CIcqProto*)id; @@ -327,7 +307,7 @@ INT_PTR CIcqProto::GetCaps(int type, MCONTACT) switch (type) { case PFLAGNUM_1: nReturn = PF1_IM | PF1_AUTHREQ | PF1_BASICSEARCH | PF1_ADDSEARCHRES | /*PF1_SEARCHBYNAME | TODO */ - PF1_VISLIST | PF1_INVISLIST | PF1_MODEMSG | PF1_FILE | PF1_CONTACT | PF1_SERVERCLIST; + PF1_VISLIST | PF1_MODEMSG | PF1_FILE | PF1_CONTACT | PF1_SERVERCLIST; break; case PFLAGNUM_2: @@ -523,7 +503,12 @@ int CIcqProto::UserIsTyping(MCONTACT hContact, int type) //////////////////////////////////////////////////////////////////////////////////////// // PS_SetApparentMode - sets the visibility status -int CIcqProto::SetApparentMode(MCONTACT, int) +int CIcqProto::SetApparentMode(MCONTACT hContact, int iMode) { - return 1; // Failure + int oldMode = getWord(hContact, "ApparentMode"); + if (oldMode != iMode) { + setWord(hContact, "ApparentMode", iMode); + SetPermitDeny(GetUserId(hContact), iMode != ID_STATUS_OFFLINE); + } + return 0; } diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index b560335ce0..49943f39cc 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -209,7 +209,6 @@ class CIcqProto : public PROTO<CIcqProto> void OnLoginViaPhone(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnNormalizePhone(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*); - void OnRefreshEditIgnore(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnSearchResults(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnSendMessage(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnStartSession(NETLIBHTTPREQUEST*, AsyncHttpRequest*); @@ -302,7 +301,6 @@ class CIcqProto : public PROTO<CIcqProto> INT_PTR __cdecl SetAvatar(WPARAM, LPARAM); INT_PTR __cdecl CreateAccMgrUI(WPARAM, LPARAM); - INT_PTR __cdecl EditIgnoreList(WPARAM, LPARAM); INT_PTR __cdecl GetEmailCount(WPARAM, LPARAM); INT_PTR __cdecl GotoInbox(WPARAM, LPARAM); INT_PTR __cdecl UploadGroups(WPARAM, LPARAM); @@ -365,7 +363,6 @@ public: { return time(0) - m_iTimeShift; } - int __cdecl OnContactMenu(WPARAM, LPARAM); void SetPermitDeny(const CMStringW &userId, bool bAllow); }; @@ -373,8 +370,6 @@ struct CMPlugin : public ACCPROTOPLUGIN<CIcqProto> { CMPlugin(); - HGENMENU m_hmiRoot, m_hmiIgnore, m_hmiAllow; - int Load() override; int Unload() override; }; |