diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-19 10:44:40 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-19 10:44:40 +0000 |
commit | 828d3d3cc4244db17bd56a8ed6122cc8ebc11fd2 (patch) | |
tree | 95e4e66df17a5cd102155e08a6e9a3505fc2c5b7 /protocols | |
parent | 75d49b8c135872953af2aa706916e5e2117efd64 (diff) |
SkypeWeb: Chats supprt part 3.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12932 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/SkypeWeb/src/requests/chatrooms.h | 24 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 100 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.cpp | 4 |
3 files changed, 125 insertions, 3 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h index 2a41798c50..088c096040 100644 --- a/protocols/SkypeWeb/src/requests/chatrooms.h +++ b/protocols/SkypeWeb/src/requests/chatrooms.h @@ -18,6 +18,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef _SKYPE_REQUEST_CHATS_H_
#define _SKYPE_REQUEST_CHATS_H_
+class SendChatMessageRequest : public HttpRequest
+{
+public:
+ SendChatMessageRequest(const char *regToken, const char *username, time_t timestamp, const char *message, const char *server = SKYPE_ENDPOINTS_HOST) :
+ HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/19:%s/messages", server, username)
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
+
+ JSONNODE *node = json_new(5);
+ json_push_back(node, json_new_i("clientmessageid", timestamp));
+ json_push_back(node, json_new_a("messagetype", "RichText"));
+ json_push_back(node, json_new_a("contenttype", "text"));
+ json_push_back(node, json_new_a("content", message));
+
+ ptrA data(mir_utf8encodeT(ptrT(json_write(node))));
+ Body << VALUE(data);
+
+ json_delete(node);
+ }
+};
+
class CreateChatroomRequest : public HttpRequest
{
public:
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 51195b2522..3b3851127d 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -62,7 +62,7 @@ MCONTACT CSkypeProto::FindChatRoom(const char *chatname) if (!isChatRoom(hContact))
continue;
- ptrA cChatname(getStringA(hContact, "ChatID"));
+ ptrA cChatname(getStringA(hContact, "ChatRoomID"));
if (!mir_strcmpi(chatname, cChatname))
break;
}
@@ -106,9 +106,93 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam) {
return 0;
}
+
+ switch (gch->pDest->iType) + { + case GC_USER_MESSAGE: + { + ptrA msg(mir_t2a(gch->ptszText)); + ptrA chat_id(mir_t2a(gch->pDest->ptszID)); + + if (IsOnline()) { + debugLogA(" > Chat - Outgoing message"); + SendRequest(new SendChatMessageRequest(RegToken, chat_id, time(NULL), msg, Server)); + } + + break; + } + + case GC_USER_PRIVMESS: + { + /*facebook_user fbu; + fbu.user_id = _T2A(hook->ptszUID, CP_UTF8); + + // Find this contact in list or add new temporary contact + MCONTACT hContact = AddToContactList(&fbu, CONTACT_NONE, false, true); + + if (!hContact) + break; + + CallService(MS_MSG_SENDMESSAGET, hContact, 0);*/ + break; + } + + /* + case GC_USER_LOGMENU: + { + switch(hook->dwData) + { + case 10: + DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog, + LPARAM(new invite_chat_param(item->id, this))); + break; + + case 20: + //chat_leave(id); + break; + } + break; + } + */ + + case GC_USER_NICKLISTMENU: + { + MCONTACT hContact = NULL; + if (gch->dwData == 10 || gch->dwData == 20) { + /* + facebook_user fbu; + fbu.user_id = _T2A(gch->ptszUID, CP_UTF8); + + // Find this contact in list or add new temporary contact + hContact = AddToContactList(&fbu, CONTACT_NONE, false, true); + + if (!hContact) + break; + */ + } + + switch (gch->dwData) + { + case 10: + CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); + break; + + case 20: + //CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); + break; + + case 110: + //chat_leave(id); + break; + } + + break;
+
return 0;
-}
+ }
+ }
+}
void CSkypeProto::StartChatRoom(const TCHAR *tid, const TCHAR *tname) { // Create the group chat session @@ -168,6 +252,16 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM) {
if (hContact)
{
+ ptrT idT(hContact ? getTStringA(hContact, "ChatRoomID") : NULL); + + GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL }; + gcd.ptszID = idT; + + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = ::time(NULL); + + CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce)); + CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, reinterpret_cast<LPARAM>(&gce));
}
return 0;
}
@@ -327,7 +421,7 @@ void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const ch gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; - gce.time = ::time(NULL); + gce.time = time(NULL); gce.bIsMe = IsMe(id); if (gce.bIsMe) { diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 79379a1ade..dc72f42657 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -175,6 +175,10 @@ int CSkypeProto::SetStatus(int iNewStatus) if (m_iStatus > ID_STATUS_CONNECTING + 1)
{
SendRequest(new DeleteEndpointRequest(RegToken, EndpointId, Server));
+ delSetting("registrationRoken");
+ delSetting("endpointId");
+ delSetting("expires");
+
}
requestQueue->Stop();
|