From 90d40f81fda6ae473ef399a2144c0766678dc1cf Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 7 May 2016 19:05:24 +0000 Subject: SkypeWeb: support custom nicks for chat's users git-svn-id: http://svn.miranda-ng.org/main/trunk@16814 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/main.cpp | 2 + protocols/SkypeWeb/src/skype_chatrooms.cpp | 62 ++++++++++++++++++++---------- protocols/SkypeWeb/src/skype_files.cpp | 1 - protocols/SkypeWeb/src/stdafx.h | 5 ++- 4 files changed, 47 insertions(+), 23 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index cbaf9aa86e..02a3f0cec4 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -23,6 +23,7 @@ CLIST_INTERFACE *pcli; FI_INTERFACE *fii = NULL; char g_szMirVer[100]; HANDLE g_hCallEvent; +CHAT_MANAGER *pci; PLUGININFOEX pluginInfo = { @@ -57,6 +58,7 @@ extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); mir_getCLI(); + mir_getCI(nullptr); CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fii); CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(g_szMirVer), LPARAM(g_szMirVer)); diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index e227e3b85b..4c7353cae0 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -38,7 +38,7 @@ void CSkypeProto::CloseAllChatChatSessions() gci.Flags = GCF_BYINDEX | GCF_ID | GCF_DATA; gci.pszModule = m_szModuleName; - int count = CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName); + int count = pci->SM_GetCount(m_szModuleName); for (int i = 0; i < count; i++) { gci.iItem = i; @@ -54,17 +54,8 @@ void CSkypeProto::CloseAllChatChatSessions() MCONTACT CSkypeProto::FindChatRoom(const char *chatname) { - MCONTACT hContact = NULL; - for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) - { - if (!isChatRoom(hContact)) - continue; - - ptrA cChatname(getStringA(hContact, "ChatRoomID")); - if (!mir_strcmpi(chatname, cChatname)) - break; - } - return hContact; + SESSION_INFO *si = pci->SM_FindSession(_A2T(chatname), m_szModuleName); + return si ? si->hContact : 0; } void CSkypeProto::StartChatRoom(const TCHAR *tid, const TCHAR *tname) @@ -203,11 +194,9 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) case GC_USER_NICKLISTMENU: { - ptrA user_id; - if (gch->dwData == 10 || gch->dwData == 30 || gch->dwData == 40) - { - user_id = mir_t2a_cp(gch->ptszUID, CP_UTF8); - } + + _T2A user_id(gch->ptszUID); + switch (gch->dwData) { @@ -220,6 +209,33 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) case 40: SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li)); break; + case 50: + + ENTER_STRING pForm = { sizeof(pForm) }; + pForm.type = ESF_COMBO; + pForm.recentCount = 0; + pForm.caption = TranslateT("Enter new nickname"); + pForm.ptszInitVal = gch->ptszUID; + pForm.szModuleName = m_szModuleName; + pForm.szDataPrefix = "renamenick_"; + + GCDEST gcd = { m_szModuleName, gch->ptszUID, GC_EVENT_NICK }; + GCEVENT gce = { sizeof(GCEVENT), &gcd }; + + EnterString(&pForm); + + gce.ptszNick = gch->ptszUID; + gce.bIsMe = IsMe(user_id); + gce.ptszUID = gch->ptszUID; + gce.ptszText = pForm.ptszResult; + gce.dwFlags = GCEF_ADDTOLOG; + gce.time = time(NULL); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); + + db_set_ts(FindChatRoom(chat_id), "UsersNicks", _T2A(gch->ptszUID), pForm.ptszResult); + + break; + } break; @@ -527,6 +543,9 @@ void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const ch return; ptrT tnick(mir_a2t_cp(name, CP_UTF8)); + if (TCHAR *tmp = db_get_tsa(FindChatRoom(_T2A(tchat_id)), "UsersNicks", id)) + tnick = tmp; + ptrT tid(mir_a2t(id)); GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN }; @@ -610,24 +629,25 @@ int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam) } else if (gcmi->Type == MENU_ON_NICKLIST) { - if (IsMe(_T2A(gcmi->pszUID))) +/* if (IsMe(_T2A(gcmi->pszUID))) { gcmi->nItems = 0; gcmi->Item = NULL; } else - { + {*/ static const struct gc_item Items[] = { { LPGENT("Kick &user"), 10, MENU_ITEM }, { NULL, 0, MENU_SEPARATOR }, { LPGENT("Set &role"), 20, MENU_NEWPOPUP }, { LPGENT("&Admin"), 30, MENU_POPUPITEM }, - { LPGENT("&User"), 40, MENU_POPUPITEM } + { LPGENT("&User"), 40, MENU_POPUPITEM }, + { LPGENT("Change nick"), 50, MENU_ITEM }, }; gcmi->nItems = _countof(Items); gcmi->Item = (gc_item*)Items; - } +// } } diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp index 8773ed4d4b..66b107a81e 100644 --- a/protocols/SkypeWeb/src/skype_files.cpp +++ b/protocols/SkypeWeb/src/skype_files.cpp @@ -56,7 +56,6 @@ void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *ar if (lBytes != lFileLen) { fclose(pFile); - mir_free(pData); FILETRANSFER_FAILED(fup); return; } diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index d05dd7b44e..c4ade57724 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -43,7 +43,7 @@ along with this program. If not, see . #include #include #include -#include +#include #include #include #include @@ -61,6 +61,9 @@ extern char g_szMirVer[]; extern HANDLE g_hCallEvent; extern FI_INTERFACE *fii; +struct SESSION_INFO : public GCSessionInfoBase +{}; + #define SKYPE_ENDPOINTS_HOST "client-s.gateway.messenger.live.com" struct LoginInfo -- cgit v1.2.3