summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-07-27 10:28:20 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-07-27 10:28:20 +0000
commit1a0cc38136914d475df14be27198fb2b88494cb8 (patch)
treecca4e5f96a0cbec8a08fcdb51420c6c1f1ea7f57 /protocols
parent8b77c1ba74a24af5ec831385fc876807aed509c0 (diff)
SkypeWeb: *YAHOO* fixed edited messages sync, other fixes.
git-svn-id: http://svn.miranda-ng.org/main/trunk@14735 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_events.cpp20
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp34
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp66
-rw-r--r--protocols/SkypeWeb/src/stdafx.h3
4 files changed, 66 insertions, 57 deletions
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp
index f670130e66..c346e6ff1a 100644
--- a/protocols/SkypeWeb/src/skype_events.cpp
+++ b/protocols/SkypeWeb/src/skype_events.cpp
@@ -33,7 +33,8 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam)
JSONNode jMsg = JSONNode::parse((char*)pEvent->dbei->pBlob);
if (jMsg)
{
- text.AppendFormat(Translate("Original message:\n\t%s\n"), jMsg["original_message"]["text"].as_string());
+ JSONNode &jOriginalMsg = jMsg["original_message"];
+ text.AppendFormat(Translate("Original message:\n\t%s\n"), jOriginalMsg["text"].as_string().c_str());
JSONNode &jEdits = jMsg["edits"];
for (auto it = jEdits.begin(); it != jEdits.end(); ++it)
{
@@ -43,16 +44,16 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam)
char szTime[MAX_PATH];
strftime(szTime, sizeof(szTime), "%X %x", localtime(&time));
- text.AppendFormat(Translate("Edited at %s:\n\t%s\n"), szTime, jEdit["text"].as_string());
+ text.AppendFormat(Translate("Edited at %s:\n\t%s\n"), szTime, jEdit["text"].as_string().c_str());
}
}
else
{
#ifdef _DEBUG
- text = (char*)pEvent->dbei->pBlob;
+ text = mir_strdup((char*)pEvent->dbei->pBlob);
#else
- text = Translate("Invalid data!");
+ text = mir_utf8encode(Translate("Invalid data!"));
#endif
}
@@ -131,7 +132,12 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam)
}
case SKYPE_DB_EVENT_TYPE_INCOMING_CALL:
{
- pszText = Translate("Incoming call.");
+ pszText = Translate("Incoming call");
+ break;
+ }
+ case SKYPE_DB_EVENT_TYPE_UNKNOWN:
+ {
+ pszText = mir_strdup(CMStringA(FORMAT, "Unknown event, please send this text for developer: \"%s\"", (char*)pEvent->dbei->pBlob));
break;
}
default:
@@ -209,6 +215,10 @@ void CSkypeProto::InitDBEvents()
dbEventType.descr = Translate("URI object");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+ dbEventType.eventType = SKYPE_DB_EVENT_TYPE_UNKNOWN;
+ dbEventType.descr = Translate("Unknown event");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
dbEventType.eventType = SKYPE_DB_EVENT_TYPE_INCOMING_CALL;
dbEventType.descr = Translate("Incoming call");
dbEventType.flags |= DETF_NONOTIFY;
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 4d70e23d99..1016bd3e1c 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -43,8 +43,8 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
{
const JSONNode &message = conversations.at(i);
- std::string clientMsgId = message["clientmessageid"].as_string();
- std::string skypeEditedId = message["skypeeditedid"].as_string();
+ CMStringA szMessageId = message["clientmessageid"] ? message["clientmessageid"].as_string().c_str() : message["skypeeditedid"].as_string().c_str();
+
std::string messageType = message["messagetype"].as_string();
std::string from = message["from"].as_string();
std::string content = message["content"].as_string();
@@ -60,38 +60,42 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
if (timestamp > db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0))
db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
- int flags = DBEF_UTF;
+ int iFlags = DBEF_UTF;
if (!markAllAsUnread)
- flags |= DBEF_READ;
+ iFlags |= DBEF_READ;
if (IsMe(skypename))
- flags |= DBEF_SENT;
+ iFlags |= DBEF_SENT;
if (strstr(conversationLink.c_str(), "/8:"))
{
- if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
+ if (messageType == "Text" || messageType == "RichText")
{
ptrA message(RemoveHtml(content.c_str()));
- MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId.c_str());
+ MEVENT dbevent = GetMessageFromDb(hContact, szMessageId);
if (isEdited && dbevent != NULL)
{
- AppendDBEvent(hContact, dbevent, message, clientMsgId.c_str(), timestamp);
+ AppendDBEvent(hContact, dbevent, message, szMessageId, timestamp);
}
- else AddDbEvent(EVENTTYPE_MESSAGE, hContact, timestamp, flags, &message[emoteOffset], clientMsgId.c_str());
+ else AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, iFlags, &message[emoteOffset], szMessageId);
+ }
+ else if (messageType == "Event/Call")
+ {
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "Event/Call"))
+ else if (messageType == "RichText/Files")
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/Files"))
+ else if (messageType == "RichText/UriObject")
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/UriObject"))
+ else
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
}
else if (conversationLink.find("/19:") != -1)
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index d5cc4727c4..e6974fd2a3 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -65,16 +65,6 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
ptrA username(getStringA(hContact, "Skypename"));
- debugLogA(__FUNCTION__ " clientmsgid = %d", param->hMessage);
-
- /*TCHAR *tszMessage = mir_utf8decodeT(szMessage);
- int len = EscapeXML(tszMessage, _tcslen(tszMessage), NULL, 0);
- TCHAR *buff = new TCHAR[len+1];
- buff[len] = '\0';
- EscapeXML(tszMessage, _tcslen(tszMessage), buff, len);
- char *szNewMessage = mir_utf8encodeT(buff);
- delete[] buff;*/
-
if (strncmp(szMessage, "/me ", 4) == 0)
SendRequest(new SendActionRequest(m_szRegToken, username, m_szSelfSkypeName, param->hMessage, &szMessage[4], m_szServer), &CSkypeProto::OnMessageSent, param);
else
@@ -97,7 +87,7 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
{
JSONNode root = JSONNode::parse(response->pData);
const JSONNode &node = root["errorCode"];
- if (!node.isnull())
+ if (node)
error = node.as_string();
}
ptrT username(getTStringA(hContact, "Skypename"));
@@ -133,13 +123,10 @@ int CSkypeProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
{
- std::string clientMsgId = node["clientmessageid"].as_string();
- std::string skypeEditedId = node["skypeeditedid"].as_string();
+ CMStringA szMessageId = node["clientmessageid"] ? node["clientmessageid"].as_string().c_str() : node["skypeeditedid"].as_string().c_str();
bool isEdited = node["skypeeditedid"];
-
- std::string composeTime = node["composetime"].as_string();
- time_t timestamp = getByte("UseLocalTime", 0) ? time(NULL) : IsoToUnixTime(composeTime.c_str());
+ time_t timestamp = getByte("UseLocalTime", 0) ? time(NULL) : IsoToUnixTime(node["composetime"].as_string().c_str());
CMStringA skypename(ContactUrlToName(node["conversationLink"].as_string().c_str()));
CMStringA from(ContactUrlToName(node["from"].as_string().c_str()));
@@ -149,53 +136,60 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
ptrA message(RemoveHtml(content.c_str()));
- std::string messageType= node["messagetype"].as_string();
+ std::string messageType = node["messagetype"].as_string();
MCONTACT hContact = AddContact(skypename, true);
if (HistorySynced)
db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
- if (!mir_strcmpi(messageType.c_str(), "Control/Typing"))
+ if (messageType == "Control/Typing")
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_INFINITE);
- else if (!mir_strcmpi(messageType.c_str(), "Control/ClearTyping"))
+ else if (messageType == "Control/ClearTyping")
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
- else if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
+ else if (messageType == "Text" || messageType == "RichText")
{
if (IsMe(from))
{
- int hMessage = atoi(clientMsgId.c_str());
+ long hMessage = atol(szMessageId);
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0);
- debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
- AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, DBEF_UTF | DBEF_SENT, &message[emoteOffset], clientMsgId.c_str());
+ debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, szMessageId);
+
+ AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact,
+ timestamp, DBEF_UTF | DBEF_SENT, &message[emoteOffset], szMessageId);
+
return;
}
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
- debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId);
- MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId.c_str());
+ debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, szMessageId);
+ MEVENT dbevent = GetMessageFromDb(hContact, szMessageId);
if (isEdited && dbevent != NULL)
{
- AppendDBEvent(hContact, dbevent, message, skypeEditedId.c_str(), timestamp);
+ AppendDBEvent(hContact, dbevent, message, szMessageId, timestamp);
}
- else OnReceiveMessage(clientMsgId.c_str(), node["conversationLink"].as_string().c_str(), timestamp, message, emoteOffset);
+ else OnReceiveMessage(szMessageId, node["conversationLink"].as_string().c_str(), timestamp, message, emoteOffset);
}
- else if (!mir_strcmpi(messageType.c_str(), "Event/SkypeVideoMessage")) {}
- else if (!mir_strcmpi(messageType.c_str(), "Event/Call"))
+ else if (messageType == "Event/SkypeVideoMessage") {}
+ else if (messageType == "Event/Call")
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/Files"))
+ else if (messageType == "RichText/Files")
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), szMessageId);
+ }
+ else if (messageType == "RichText/UriObject")
+ {
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/Location")) {}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/UriObject"))
+ //else if (!mir_strcmpi(messageType.c_str(), "RichText/Contacts")) {}
+ //else if (!mir_strcmpi(messageType.c_str(), "RichText/Location")) {}
+ else
{
- AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str());
+ AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, DBEF_UTF, content.c_str(), szMessageId);
}
- else if (!mir_strcmpi(messageType.c_str(), "RichText/Contacts")) {}
}
int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent)
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h
index 6e57b8969a..6816b262e4 100644
--- a/protocols/SkypeWeb/src/stdafx.h
+++ b/protocols/SkypeWeb/src/stdafx.h
@@ -104,7 +104,8 @@ enum SKYPE_DB_EVENT_TYPE
SKYPE_DB_EVENT_TYPE_CALL_INFO,
SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO,
SKYPE_DB_EVENT_TYPE_URIOBJ,
- SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE
+ SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE,
+ SKYPE_DB_EVENT_TYPE_UNKNOWN
};
#define SKYPE_SETTINGS_ID "Skypename"