summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp40
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h9
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp121
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp37
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h10
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp24
7 files changed, 109 insertions, 134 deletions
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index c3ae3fb798..aa5812aa0b 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -17,6 +17,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpRequestHandler pFunc) :
+ m_host(host)
+{
+ switch (host) {
+ case HOST_API: m_szUrl = "api.skype.com"; break;
+ case HOST_CONTACTS: m_szUrl = "contacts.skype.com"; break;
+ case HOST_GRAPH: m_szUrl = "skypegraph.skype.com"; break;
+ case HOST_LOGIN: m_szUrl = "login.skype.com"; break;
+ case HOST_DEFAULT:
+ m_szUrl.Format("%s/v1", g_plugin.szDefaultServer.c_str());
+ break;
+ }
+
+ AddHeader("User-Agent", NETLIB_USER_AGENT);
+
+ if (url)
+ m_szUrl.Append(url);
+ m_pFunc = pFunc;
+ flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_DUMPASTEXT;
+ requestType = type;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CSkypeProto::StartQueue()
{
if (!m_isTerminated)
@@ -47,16 +71,11 @@ void CSkypeProto::PushRequest(AsyncHttpRequest *request)
m_hRequestQueueEvent.Set();
}
-void CSkypeProto::SendRequest(AsyncHttpRequest *request)
-{
- mir_forkthreadowner(&CSkypeProto::AsyncSendThread, this, request, nullptr);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
NETLIBHTTPREQUEST* CSkypeProto::DoSend(AsyncHttpRequest *pReq)
{
- if (pReq->m_szUrl.Find("://") == -1)
+ if (pReq->m_host != HOST_OTHER)
pReq->m_szUrl.Insert(0, ((pReq->flags & NLHRF_SSL) ? "https://" : "http://"));
if (!pReq->m_szParam.IsEmpty()) {
@@ -122,15 +141,6 @@ void CSkypeProto::Execute(AsyncHttpRequest *item)
delete item;
}
-unsigned CSkypeProto::AsyncSendThread(void *owner, void *arg)
-{
- CSkypeProto *that = (CSkypeProto*)owner;
- AsyncHttpRequest *item = (AsyncHttpRequest*)arg;
-
- that->Execute(item);
- return 0;
-}
-
void CSkypeProto::WorkerThread(void*)
{
while (true) {
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index 921f6b2519..b8f6f48c82 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -33,7 +33,7 @@ struct SendChatMessageRequest : public AsyncHttpRequest
SendChatMessageRequest(const char *to, time_t timestamp, const char *message) :
AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT)
{
- m_szUrl.AppendFormat("/users/ME/conversations/19:%s/messages", to);
+ m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", to);
JSONNode node;
node << CHAR_PARAM("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
@@ -47,7 +47,7 @@ struct SendChatActionRequest : public AsyncHttpRequest
SendChatActionRequest(const char *to, time_t timestamp, const char *message) :
AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT)
{
- m_szUrl.AppendFormat("/users/ME/conversations/19:%s/messages", to);
+ m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", to);
JSONNode node(JSON_NODE);
node << CHAR_PARAM("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
@@ -78,11 +78,10 @@ struct CreateChatroomRequest : public AsyncHttpRequest
struct GetChatInfoRequest : public AsyncHttpRequest
{
- GetChatInfoRequest(const char *chatId, const CMStringW &topic) :
+ GetChatInfoRequest(const wchar_t *chatId) :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetChatInfo)
{
- m_szUrl.AppendFormat("/threads/%s", chatId);
- pUserInfo = topic.Detach();
+ m_szUrl.AppendFormat("/threads/%S", chatId);
this << CHAR_PARAM("view", "msnp24Equivalent");
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 71193390a0..b00cd5e1f2 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -46,6 +46,8 @@ SESSION_INFO* CSkypeProto::StartChatRoom(const wchar_t *tid, const wchar_t *tnam
// Finish initialization
Chat_Control(m_szModuleName, tid, (getBool("HideChats", 1) ? WINDOW_HIDDEN : SESSION_INITDONE));
Chat_Control(m_szModuleName, tid, SESSION_ONLINE);
+
+ PushRequest(new GetChatInfoRequest(tid));
return si;
}
@@ -65,14 +67,10 @@ void CSkypeProto::OnLoadChats(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
if (totalCount >= 99 || conversations.size() >= 99)
ReadHistoryRest(syncState.c_str());
- for (auto &conversation : conversations) {
- if (!conversation["lastMessage"])
- continue;
-
- const JSONNode &id = conversation["id"];
- const JSONNode &threadProperties = conversation["threadProperties"];
- CMStringW topic(threadProperties["topic"].as_mstring());
- SendRequest(new GetChatInfoRequest(id.as_string().c_str(), topic));
+ for (auto &it : conversations) {
+ auto &props = it["threadProperties"];
+ if (it["lastMessage"] && props["members"])
+ StartChatRoom(it["id"].as_mstring(), props["topic"].as_mstring());
}
}
@@ -116,11 +114,11 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
if (mir_strcmp(si->pszModule, m_szModuleName) != 0)
return 0;
- T2Utf user_id(gch->ptszUID);
+ T2Utf chat_id(si->ptszID), user_id(gch->ptszUID);
switch (gch->iType) {
case GC_USER_MESSAGE:
- OnSendChatMessage(si->hContact, gch->ptszText);
+ SendChatMessage(si, gch->ptszText);
break;
case GC_USER_PRIVMESS:
@@ -130,7 +128,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
hContact = AddContact(user_id, true);
setWord(hContact, "Status", ID_STATUS_ONLINE);
Contact_Hide(hContact);
- setWString(hContact, "Nick", gch->ptszUID);
+ setWString(hContact, "Nick", (gch->ptszNick) ? gch->ptszNick : GetSkypeNick(gch->ptszUID));
}
CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
}
@@ -143,7 +141,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
CSkypeInviteDlg dlg(this);
if (dlg.DoModal())
if (dlg.m_hContact != NULL)
- PushRequest(new InviteUserToChatRequest(getId(si->hContact), getId(dlg.m_hContact), "User"));
+ PushRequest(new InviteUserToChatRequest(chat_id, getId(dlg.m_hContact), "User"));
}
break;
@@ -154,7 +152,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case 30:
CMStringW newTopic = ChangeTopicForm();
if (!newTopic.IsEmpty())
- PushRequest(new SetChatPropertiesRequest(getId(si->hContact), "topic", T2Utf(newTopic.GetBuffer())));
+ PushRequest(new SetChatPropertiesRequest(chat_id, "topic", T2Utf(newTopic.GetBuffer())));
break;
}
break;
@@ -162,13 +160,13 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
switch (gch->dwData) {
case 10:
- PushRequest(new KickUserRequest(getId(si->hContact), user_id));
+ PushRequest(new KickUserRequest(chat_id, user_id));
break;
case 30:
- PushRequest(new InviteUserToChatRequest(getId(si->hContact), user_id, "Admin"));
+ PushRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin"));
break;
case 40:
- PushRequest(new InviteUserToChatRequest(getId(si->hContact), user_id, "User"));
+ PushRequest(new InviteUserToChatRequest(chat_id, user_id, "User"));
break;
case 50:
ptrW tnick_old(GetChatContactNick(si->hContact, gch->ptszUID, gch->ptszText));
@@ -180,23 +178,22 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
pForm.szDataPrefix = "renamenick_";
if (EnterString(&pForm)) {
- MCONTACT hChatContact = si->hContact;
- if (hChatContact == NULL)
+ if (si->hContact == NULL)
break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
ptrW tnick_new(pForm.ptszResult);
bool reset = mir_wstrlen(tnick_new) == 0;
if (reset) {
// User fill blank name, which means we reset the custom nick
- db_unset(hChatContact, "UsersNicks", user_id);
- tnick_new = GetChatContactNick(gch->si->hContact, gch->ptszUID, gch->ptszText);
+ db_unset(si->hContact, "UsersNicks", user_id);
+ tnick_new = GetChatContactNick(si->hContact, gch->ptszUID, gch->ptszText);
}
if (!mir_wstrcmp(tnick_old, tnick_new))
break; // New nick is same, do nothing
GCEVENT gce = { m_szModuleName, 0, GC_EVENT_NICK };
- gce.pszID.w = gch->si->ptszID;
+ gce.pszID.w = si->ptszID;
gce.dwFlags = GCEF_ADDTOLOG;
gce.pszNick.w = tnick_old;
gce.bIsMe = IsMe(user_id);
@@ -206,7 +203,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
Chat_Event(&gce);
if (!reset)
- db_set_ws(hChatContact, "UsersNicks", user_id, tnick_new);
+ db_set_ws(si->hContact, "UsersNicks", user_id, tnick_new);
}
break;
}
@@ -263,13 +260,12 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
debugLogW(L"unable to create chat %s", wszChatId.c_str());
return;
}
- PushRequest(new GetChatInfoRequest(T2Utf(wszChatId), wszTopic));
}
std::string messageType = node["messagetype"].as_string();
if (messageType == "Text" || messageType == "RichText") {
CMStringW wszClearedContent(messageType == "RichText" ? RemoveHtml(wszContent) : wszContent);
- AddMessageToChat(si->hContact, szFromId, wszClearedContent, nEmoteOffset != NULL, nEmoteOffset, timestamp);
+ AddMessageToChat(si, szFromId, wszClearedContent, nEmoteOffset != NULL, nEmoteOffset, timestamp);
}
else if (messageType == "ThreadActivity/AddMember") {
// <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
@@ -278,8 +274,8 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
return;
if (auto *pRoot = doc.FirstChildElement("addMember")) {
- CMStringW target = UrlToSkypeId(pRoot->FirstChildElement("target")->Value());
- AddChatContact(si->hContact, target, L"User");
+ CMStringW target = Utf2T(XmlGetChildText(pRoot, "target"));
+ AddChatContact(si, target, L"User");
}
}
else if (messageType == "ThreadActivity/DeleteMember") {
@@ -289,9 +285,9 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
return;
if (auto *pRoot = doc.FirstChildElement("deletemember")) {
- CMStringW target = Utf2T(UrlToSkypeId(pRoot->FirstChildElement("target")->Value()));
- CMStringW initiator = Utf2T(UrlToSkypeId(pRoot->FirstChildElement("initiator")->Value()));
- RemoveChatContact(si->hContact, target, true, initiator);
+ CMStringW target = Utf2T(UrlToSkypeId(XmlGetChildText(pRoot, "target")));
+ CMStringW initiator = Utf2T(XmlGetChildText(pRoot, "initiator"));
+ RemoveChatContact(si, target, true, initiator);
}
}
else if (messageType == "ThreadActivity/TopicUpdate") {
@@ -302,14 +298,14 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
auto *pRoot = doc.FirstChildElement("topicupdate");
if (pRoot) {
- CMStringW initiator = Utf2T(UrlToSkypeId(pRoot->FirstChildElement("initiator")->Value()));
- CMStringW value = Utf2T(pRoot->FirstChildElement("value")->Value());
+ CMStringW initiator = Utf2T(XmlGetChildText(pRoot, "initiator"));
+ CMStringW value = Utf2T(XmlGetChildText(pRoot, "value"));
Chat_ChangeSessionName(m_szModuleName, wszChatId, value);
GCEVENT gce = { m_szModuleName, 0, GC_EVENT_TOPIC };
gce.pszID.w = wszChatId;
gce.pszUID.w = initiator;
- gce.pszNick.w = initiator;
+ gce.pszNick.w = GetSkypeNick(initiator);
gce.pszText.w = wszTopic;
Chat_Event(&gce);
}
@@ -322,12 +318,12 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
auto *pRoot = doc.FirstChildElement("roleupdate");
if (pRoot) {
- CMStringW initiator = Utf2T(UrlToSkypeId(pRoot->FirstChildElement("initiator")->Value()));
+ CMStringW initiator = Utf2T(UrlToSkypeId(XmlGetChildText(pRoot, "initiator")));
auto *pTarget = pRoot->FirstChildElement("target");
if (pTarget) {
- CMStringW id = Utf2T(UrlToSkypeId(pTarget->FirstChildElement("id")->Value()));
- const char *role = pTarget->FirstChildElement("role")->Value();
+ CMStringW id = Utf2T(UrlToSkypeId(XmlGetChildText(pTarget, "id")));
+ const char *role = XmlGetChildText(pTarget, "role");
GCEVENT gce = { m_szModuleName, 0, !mir_strcmpi(role, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
gce.pszID.w = wszChatId;
@@ -344,7 +340,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
}
}
-void CSkypeProto::OnSendChatMessage(MCONTACT hContact, const wchar_t *tszMessage)
+void CSkypeProto::SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage)
{
if (!IsOnline())
return;
@@ -353,7 +349,7 @@ void CSkypeProto::OnSendChatMessage(MCONTACT hContact, const wchar_t *tszMessage
rtrimw(buf);
Chat_UnescapeTags(buf);
- CMStringA chat_id(getId(hContact));
+ T2Utf chat_id(si->ptszID);
ptrA szMessage(mir_utf8encodeW(buf));
if (strncmp(szMessage, "/me ", 4) == 0)
@@ -362,27 +358,25 @@ void CSkypeProto::OnSendChatMessage(MCONTACT hContact, const wchar_t *tszMessage
PushRequest(new SendChatMessageRequest(chat_id, time(0), szMessage));
}
-void CSkypeProto::AddMessageToChat(MCONTACT hContact, const wchar_t *from, const wchar_t *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
+void CSkypeProto::AddMessageToChat(SESSION_INFO *si, const wchar_t *from, const wchar_t *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
{
- CMStringW wszChatId(getMStringW(hContact, SKYPE_SETTINGS_ID));
- ptrW tnick(GetChatContactNick(hContact, from));
+ ptrW tnick(GetChatContactNick(si->hContact, from));
GCEVENT gce = { m_szModuleName, 0, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
- gce.pszID.w = wszChatId;
- gce.dwFlags = GCEF_UTF8;
+ gce.pszID.w = si->ptszID;
gce.bIsMe = IsMe(from);
gce.pszNick.w = tnick;
gce.time = timestamp;
gce.pszUID.w = from;
- CMStringA szText(content);
- szText.Replace("%", "%%");
+ CMStringW wszText(content);
+ wszText.Replace(L"%", L"%%");
if (!isAction) {
- gce.pszText.a = szText;
+ gce.pszText.w = wszText;
gce.dwFlags |= GCEF_ADDTOLOG;
}
- else gce.pszText.a = szText.GetBuffer() + emoteOffset;
+ else gce.pszText.w = wszText.c_str() + emoteOffset;
if (isLoading)
gce.dwFlags |= GCEF_NOTNOTIFY;
@@ -390,10 +384,8 @@ void CSkypeProto::AddMessageToChat(MCONTACT hContact, const wchar_t *from, const
Chat_Event(&gce);
}
-void CSkypeProto::OnGetChatInfo(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest)
+void CSkypeProto::OnGetChatInfo(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
{
- ptrW wszTopic((wchar_t *)pRequest->pUserInfo);
-
JsonReply reply(response);
if (reply.error())
return;
@@ -405,26 +397,23 @@ void CSkypeProto::OnGetChatInfo(NETLIBHTTPREQUEST *response, AsyncHttpRequest *p
CMStringW wszChatId(UrlToSkypeId(root["messages"].as_mstring()));
auto *si = g_chatApi.SM_FindSession(wszChatId, m_szModuleName);
- if (si == nullptr) {
- si = StartChatRoom(wszChatId, wszTopic);
- if (si == nullptr)
- return;
- }
+ if (si == nullptr)
+ return;
for (auto &member : root["members"]) {
CMStringW username(UrlToSkypeId(member["userLink"].as_mstring()));
CMStringW role = member["role"].as_mstring();
- AddChatContact(si->hContact, username, role, true);
+ AddChatContact(si, username, role, true);
}
- PushRequest(new GetHistoryRequest(getId(si->hContact), true, 0));
+ PushRequest(new GetHistoryRequest(_T2A(si->ptszID), true, 0));
}
wchar_t* CSkypeProto::GetChatContactNick(MCONTACT hContact, const wchar_t *id, const wchar_t *name)
{
// Check if there is custom nick for this chat contact
if (hContact)
- if (auto *tname = getWStringA(hContact, "UsersNicks"))
+ if (auto *tname = db_get_wsa(hContact, "UsersNicks", T2Utf(id)))
return tname;
// Check if we have this contact in database
@@ -452,13 +441,12 @@ wchar_t* CSkypeProto::GetChatContactNick(MCONTACT hContact, const wchar_t *id, c
return mir_wstrdup(GetSkypeNick(id));
}
-void CSkypeProto::AddChatContact(MCONTACT hContact, const wchar_t *id, const wchar_t *role, bool isChange)
+void CSkypeProto::AddChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *role, bool isChange)
{
- CMStringW chat_id(getMStringW(hContact, SKYPE_SETTINGS_ID));
- ptrW szNick(GetChatContactNick(hContact, id));
+ ptrW szNick(GetChatContactNick(si->hContact, id));
GCEVENT gce = { m_szModuleName, 0, GC_EVENT_JOIN };
- gce.pszID.w = chat_id;
+ gce.pszID.w = si->ptszID;
gce.dwFlags = GCEF_ADDTOLOG;
gce.pszNick.w = szNick;
gce.pszUID.w = id;
@@ -468,17 +456,16 @@ void CSkypeProto::AddChatContact(MCONTACT hContact, const wchar_t *id, const wch
Chat_Event(&gce);
}
-void CSkypeProto::RemoveChatContact(MCONTACT hContact, const wchar_t *id, bool isKick, const wchar_t *initiator)
+void CSkypeProto::RemoveChatContact(SESSION_INFO *si, const wchar_t *id, bool isKick, const wchar_t *initiator)
{
if (IsMe(id))
return;
- CMStringW chat_id(getMStringW(hContact, SKYPE_SETTINGS_ID));
- ptrW szNick(GetChatContactNick(hContact, id));
- ptrW szInitiator(GetChatContactNick(hContact, initiator));
+ ptrW szNick(GetChatContactNick(si->hContact, id));
+ ptrW szInitiator(GetChatContactNick(si->hContact, initiator));
GCEVENT gce = { m_szModuleName, 0, isKick ? GC_EVENT_KICK : GC_EVENT_PART };
- gce.pszID.w = chat_id;
+ gce.pszID.w = si->ptszID;
gce.pszNick.w = szNick;
gce.pszUID.w = id;
gce.time = time(0);
@@ -602,7 +589,7 @@ int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
CMStringW CSkypeProto::ChangeTopicForm()
{
- CMStringW caption(FORMAT, L"[%s] %s", _A2T(m_szModuleName), TranslateT("Enter new chatroom topic"));
+ CMStringW caption(FORMAT, L"[%s] %s", _A2T(m_szModuleName).get(), TranslateT("Enter new chatroom topic"));
ENTER_STRING pForm = {};
pForm.type = ESF_MULTILINE;
pForm.caption = caption;
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index d69620dd86..60ecb06cf4 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -45,12 +45,11 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
int userType;
CMStringW wszChatId = UrlToSkypeId(message["conversationLink"].as_mstring(), &userType);
CMStringW wszContent = message["content"].as_mstring();
+ CMStringW wszFrom = UrlToSkypeId(message["from"].as_mstring());
std::string messageType = message["messagetype"].as_string();
- std::string from = message["from"].as_string();
int emoteOffset = message["skypeemoteoffset"].as_int();
time_t timestamp = IsoToUnixTime(message["composetime"].as_string());
- CMStringA skypename(UrlToSkypeId(from.c_str()));
bool isEdited = message["skypeeditedid"];
@@ -64,7 +63,7 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
if (!markAllAsUnread)
iFlags |= DBEF_READ;
- if (IsMe(skypename))
+ if (IsMe(wszFrom))
iFlags |= DBEF_SENT;
if (userType == 8 || userType == 2) {
@@ -96,8 +95,12 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
}
}
else if (userType == 19) {
+ auto *si = g_chatApi.SM_FindSession(wszChatId, m_szModuleName);
+ if (si == nullptr)
+ return;
+
if (messageType == "Text" || messageType == "RichText")
- AddMessageToChat(hContact, wszChatId, messageType == "RichText" ? RemoveHtml(wszContent) : wszContent, emoteOffset != NULL, emoteOffset, timestamp, true);
+ AddMessageToChat(si, wszFrom, messageType == "RichText" ? RemoveHtml(wszContent) : wszContent, emoteOffset != NULL, emoteOffset, timestamp, true);
}
}
}
@@ -133,19 +136,19 @@ void CSkypeProto::OnSyncHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
for (auto &conversation : conversations) {
const JSONNode &lastMessage = conversation["lastMessage"];
- if (lastMessage) {
- std::string strConversationLink = lastMessage["conversationLink"].as_string();
-
- int iUserType;
- CMStringA szSkypename = UrlToSkypeId(strConversationLink.c_str(), &iUserType);
- if (iUserType == 8 || iUserType == 2) {
- time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string()));
-
- MCONTACT hContact = FindContact(szSkypename);
- if (hContact != NULL)
- if (getDword(hContact, "LastMsgTime", 0) < composeTime)
- PushRequest(new GetHistoryRequest(szSkypename, 100, 0));
- }
+ if (!lastMessage)
+ continue;
+
+ int iUserType;
+ std::string strConversationLink = lastMessage["conversationLink"].as_string();
+ CMStringA szSkypename = UrlToSkypeId(strConversationLink.c_str(), &iUserType);
+ if (iUserType == 8 || iUserType == 2) {
+ time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string()));
+
+ MCONTACT hContact = FindContact(szSkypename);
+ if (hContact != NULL)
+ if (getDword(hContact, "LastMsgTime", 0) < composeTime)
+ PushRequest(new GetHistoryRequest(szSkypename, 100, 0));
}
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 8264f4dc50..da6f66e17c 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -197,7 +197,6 @@ private:
void Execute(AsyncHttpRequest *request);
void PushRequest(AsyncHttpRequest *request);
- void SendRequest(AsyncHttpRequest *request);
// menus
static HGENMENU ContactMenuItems[CMI_MAX];
@@ -275,12 +274,13 @@ private:
SESSION_INFO* StartChatRoom(const wchar_t *tid, const wchar_t *tname);
void OnChatEvent(const JSONNode &node);
- void OnSendChatMessage(MCONTACT hContact, const wchar_t *tszMessage);
- void AddMessageToChat(MCONTACT hContact, const wchar_t *from, const wchar_t *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading = false);
- void AddChatContact(MCONTACT hContact, const wchar_t *id, const wchar_t *role, bool isChange = false);
- void RemoveChatContact(MCONTACT hContact, const wchar_t *id, bool isKick = false, const wchar_t *initiator = L"");
wchar_t* GetChatContactNick(MCONTACT hContact, const wchar_t *id, const wchar_t *name = nullptr);
+ void AddMessageToChat(SESSION_INFO *si, const wchar_t *from, const wchar_t *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading = false);
+ void AddChatContact(SESSION_INFO *si, const wchar_t *id, const wchar_t *role, bool isChange = false);
+ void RemoveChatContact(SESSION_INFO *si, const wchar_t *id, bool isKick = false, const wchar_t *initiator = L"");
+ void SendChatMessage(SESSION_INFO *si, const wchar_t *tszMessage);
+
void SetChatStatus(MCONTACT hContact, int iStatus);
// polling
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index 163c7776df..de608eccf3 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -22,7 +22,7 @@ void CSkypeProto::ProcessTimer()
if (!IsOnline())
return;
- SendRequest(new GetContactListRequest(this, nullptr));
+ PushRequest(new GetContactListRequest(this, nullptr));
SendPresence();
}
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 305bf1c102..291ca892e7 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -658,30 +658,6 @@ INT_PTR CSkypeProto::GlobalParseSkypeUriService(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpRequestHandler pFunc) :
- m_host(host)
-{
- switch (host) {
- case HOST_API: m_szUrl = "https://api.skype.com"; break;
- case HOST_CONTACTS: m_szUrl = "https://contacts.skype.com"; break;
- case HOST_GRAPH: m_szUrl = "https://skypegraph.skype.com"; break;
- case HOST_LOGIN: m_szUrl = "https://login.skype.com"; break;
- case HOST_DEFAULT:
- m_szUrl.Format("https://%s/v1", g_plugin.szDefaultServer.c_str());
- break;
- }
-
- AddHeader("User-Agent", NETLIB_USER_AGENT);
-
- if (url)
- m_szUrl.Append(url);
- m_pFunc = pFunc;
- flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_DUMPASTEXT;
- requestType = type;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
JsonReply::JsonReply(NETLIBHTTPREQUEST *pReply)
{
if (pReply == nullptr) {