summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-06-19 19:20:22 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-06-19 19:20:22 +0000
commitf0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (patch)
treea14e3df46ea49e781a98e5ef3438aa25bc52e5b5 /protocols/SkypeWeb/src
parenta0827f61f16f691962b378ab64ea27e5132dc506 (diff)
SkypeWeb: support change chat topic
git-svn-id: http://svn.miranda-ng.org/main/trunk@14269 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h18
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp14
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h1
3 files changed, 33 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index b78053f7f1..1062b9f4b7 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -158,4 +158,22 @@ public:
}
};
+class SetChatPropertiesRequest : public HttpRequest
+{
+public:
+ SetChatPropertiesRequest(const char *regToken, const char *chatId, const char *propname, const char *value, const char *server = SKYPE_ENDPOINTS_HOST) :
+ HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/threads/19:%s/properties?name=%s", server, chatId, propname)
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
+
+ JSONNode node(JSON_NODE);
+ node.push_back(JSONNode(propname, value));
+
+ Body << VALUE(node.write().c_str());
+ }
+};
+
#endif //_SKYPE_REQUEST_CHATS_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 2f9a6658d6..70b31e4447 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -190,6 +190,9 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
OnLeaveChatRoom(FindChatRoom(chat_id), NULL);
break;
case 30:
+ CMString newTopic = ChangeTopicForm();
+ if (!newTopic.IsEmpty())
+ SendRequest(new SetChatPropertiesRequest(m_szRegToken, chat_id, "topic", ptrA(mir_utf8encodeT(newTopic.GetBuffer())), m_szServer));
break;
}
break;
@@ -718,4 +721,15 @@ void CSkypeProto::ResetOptions(HWND hwndDlg)
HWND hwndClist = GetDlgItem(hwndDlg, IDC_CLIST);
SendMessage(hwndClist, CLM_SETHIDEEMPTYGROUPS, 1, 0);
SendMessage(hwndClist, CLM_GETHIDEOFFLINEROOT, 1, 0);
+}
+
+CMString CSkypeProto::ChangeTopicForm()
+{
+ CMString caption(FORMAT, _T("[%s] %s"), _A2T(m_szModuleName), TranslateT("Enter new chatroom topic"));
+ ENTER_STRING pForm = { sizeof(pForm) };
+ pForm.type = ESF_PASSWORD;
+ pForm.caption = caption;
+ pForm.ptszInitVal = NULL;
+ pForm.szModuleName = m_szModuleName;
+ return (!EnterString(&pForm)) ? CMString() : CMString(ptrT(pForm.ptszResult));
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index db136cd963..cbc434bc43 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -337,6 +337,7 @@ private:
time_t GetLastMessageTime(MCONTACT hContact);
CMString RunConfirmationCode();
+ CMString ChangeTopicForm();
//events
void InitDBEvents();
int __cdecl ProcessSrmmEvent(WPARAM, LPARAM);