summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-11 17:24:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-11 17:24:30 +0000
commit8ca99a25aca9803bee22fa558c7b6fa6656ee1fb (patch)
tree8c152afa7a8f47aab3bfb6bcb1d1bb6a4922de56 /protocols/VKontakte/src
parent8f3d6729cbee5e070ad7663029baa4c8431ac456 (diff)
VK: chat title editor
git-svn-id: http://svn.miranda-ng.org/main/trunk@7595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp31
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
2 files changed, 29 insertions, 3 deletions
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index cfe4753272..c9aef8a24e 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
enum
{
+ IDM_NONE,
IDM_TOPIC, IDM_INVITE, IDM_DESTROY,
IDM_KICK, IDM_INFO
};
@@ -123,7 +124,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (lstrcmp(tszTitle, cc->m_tszTopic)) {
cc->m_tszTopic = mir_tstrdup(tszTitle);
- GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_TOPIC };
+ GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_CHANGESESSIONAME };
GCEVENT gce = { sizeof(GCEVENT), &gcd };
gce.ptszText = tszTitle;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -395,6 +396,17 @@ static INT_PTR CALLBACK InviteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
return 0;
}
+LPTSTR CVkProto::ChangeChatTopic(CVkChatInfo *cc)
+{
+ ENTER_STRING pForm = { sizeof(pForm) };
+ pForm.type = ESF_MULTILINE;
+ pForm.caption = TranslateT("Enter new chat title");
+ pForm.ptszInitVal = cc->m_tszTopic;
+ pForm.szModuleName = m_szModuleName;
+ pForm.szDataPrefix = "gctopic_";
+ return (!EnterString(&pForm)) ? NULL : pForm.ptszResult;
+}
+
void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
{
HANDLE hContact;
@@ -402,6 +414,19 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
_itoa(cc->m_chatid, szChatId, 10);
switch (gch->dwData) {
+ case IDM_TOPIC:
+ if (LPTSTR ptszNew = ChangeChatTopic(cc)) {
+ ptrA szTitle(mir_utf8encodeT(ptszNew));
+ HttpParam params[] = {
+ { "title", szTitle },
+ { "chat_id", szChatId },
+ { "access_token", m_szAccessToken }
+ };
+ PushAsyncHttpRequest(REQUEST_GET, "/method/messages.editChat.json", true, NULL, SIZEOF(params), params);
+ mir_free(ptszNew);
+ }
+ break;
+
case IDM_INVITE:
hContact = (HANDLE)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INVITE), NULL, InviteDlgProc, (LPARAM)this);
if (hContact != NULL) {
@@ -480,9 +505,9 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
static gc_item sttLogListItems[] =
{
{ LPGENT("&Invite a user"), IDM_INVITE, MENU_ITEM },
- { LPGENT("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM },
+ { LPGENT("View/change &title"), IDM_TOPIC, MENU_ITEM },
{ NULL, 0, MENU_SEPARATOR },
- { LPGENT("&Destroy room"), IDM_DESTROY, MENU_POPUPITEM }
+ { LPGENT("&Destroy room"), IDM_DESTROY, MENU_ITEM }
};
static gc_item sttListItems[] =
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 1bd1cc8c85..f75489f42a 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -248,6 +248,7 @@ private:
int __cdecl OnGcMenuHook(WPARAM, LPARAM);
void LogMenuHook(CVkChatInfo*, GCHOOK*);
void NickMenuHook(CVkChatInfo*, GCHOOK*);
+ LPTSTR ChangeChatTopic(CVkChatInfo*);
CVkChatInfo* GetChatById(LPCTSTR ptszId);
CMString GetAttachmentDescr(JSONNODE*);