diff options
-rw-r--r-- | protocols/SkypeWeb/src/requests/chatrooms.h | 8 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/messages.h | 8 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 7 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 9 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/stdafx.h | 9 |
6 files changed, 23 insertions, 22 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h index 68855cb9bf..78c4e5937d 100644 --- a/protocols/SkypeWeb/src/requests/chatrooms.h +++ b/protocols/SkypeWeb/src/requests/chatrooms.h @@ -40,7 +40,7 @@ public: class SendChatMessageRequest : public HttpRequest
{
public:
- SendChatMessageRequest(const char *to, ULONGLONG timestamp, const char *message, LoginInfo &li) :
+ SendChatMessageRequest(const char *to, time_t timestamp, const char *message, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/19:%s/messages", li.endpoint.szServer, to)
{
Headers
@@ -49,7 +49,7 @@ public: << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
JSONNode node;
node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
+ << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
<< JSONNode("messagetype", "RichText")
<< JSONNode("contenttype", "text")
<< JSONNode("content", message);
@@ -61,7 +61,7 @@ public: class SendChatActionRequest : public HttpRequest
{
public:
- SendChatActionRequest(const char *to, ULONGLONG timestamp, const char *message, LoginInfo &li) :
+ SendChatActionRequest(const char *to, time_t timestamp, const char *message, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/19:%s/messages", li.endpoint.szServer, to)
{
Headers
@@ -71,7 +71,7 @@ public: JSONNode node(JSON_NODE);
node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
+ << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
<< JSONNode("messagetype", "RichText")
<< JSONNode("contenttype", "text")
<< JSONNode("content", message)
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index ff706473df..104632ecfd 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. class SendMessageRequest : public HttpRequest
{
public:
- SendMessageRequest(const char *username, ULONGLONG timestamp, const char *message, LoginInfo &li) :
+ SendMessageRequest(const char *username, time_t timestamp, const char *message, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, username)
{
Headers
@@ -31,7 +31,7 @@ public: JSONNode node;
node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
+ << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
<< JSONNode("messagetype", "Text")
<< JSONNode("contenttype", "text")
<< JSONNode("content", message);
@@ -43,7 +43,7 @@ public: class SendActionRequest : public HttpRequest
{
public:
- SendActionRequest(const char *username, ULONGLONG timestamp, const char *message, LoginInfo &li) :
+ SendActionRequest(const char *username, time_t timestamp, const char *message, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, username)
{
Headers
@@ -56,7 +56,7 @@ public: JSONNode node;
node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
+ << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
<< JSONNode("messagetype", "RichText")
<< JSONNode("contenttype", "text")
<< JSONNode("content", content)
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 7be0b232d8..5cd6536814 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -403,9 +403,9 @@ void CSkypeProto::OnSendChatMessage(const TCHAR *chat_id, const TCHAR * tszMessa ptrA szChatId(mir_t2a(chat_id));
ptrA szMessage(mir_utf8encodeT(tszMessage));
if (strncmp(szMessage, "/me ", 4) == 0)
- SendRequest(new SendChatActionRequest(szChatId, GenerateMessageId(), szMessage, li));
+ SendRequest(new SendChatActionRequest(szChatId, time(NULL), szMessage, li));
else
- SendRequest(new SendChatMessageRequest(szChatId, GenerateMessageId(), szMessage, li));
+ SendRequest(new SendChatMessageRequest(szChatId, time(NULL), szMessage, li));
}
void CSkypeProto::AddMessageToChat(const TCHAR *chat_id, const TCHAR *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index ecf39013af..3b49886705 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -39,7 +39,7 @@ int CSkypeProto::OnReceiveMessage(MCONTACT hContact, const char *szContent, cons struct SendMessageParam
{
MCONTACT hContact;
- ULONGLONG hMessage;
+ LONGLONG hMessage;
};
// outcoming message flow
@@ -53,7 +53,7 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage) SendMessageParam *param = new SendMessageParam();
param->hContact = hContact;
- param->hMessage = GenerateMessageId();
+ param->hMessage = time(NULL);
ptrA username(getStringA(hContact, "Skypename"));
@@ -186,7 +186,8 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) {
if (IsMe(szFromSkypename))
{
- HANDLE hMessage = (HANDLE)std::stoull(szMessageId.GetString());
+ szMessageId.Truncate(szMessageId.GetLength() - 3);
+ HANDLE hMessage = (HANDLE)(std::stoull(szMessageId.GetString()));
if (m_OutMessages.getIndex(hMessage) != -1)
{
auto it = m_mpOutMessages.find(hMessage);
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 607c3f6e86..491f93eadb 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -250,6 +250,8 @@ private: // messages
+ std::map<ULONGLONG, HANDLE> m_mpOutMessagesIds;
+
MEVENT GetMessageFromDb(MCONTACT hContact, const char *messageId, LONGLONG timestamp = 0);
MEVENT AddDbEvent(WORD type, MCONTACT hContact, DWORD timestamp, DWORD flags, const char *content, const char *uid);
MEVENT AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, const char *szUid, time_t edit_time);
@@ -351,13 +353,6 @@ private: static void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD);
//---/
- __inline ULONGLONG GenerateMessageId()
- {
- _timeb timeb;
- _ftime(&timeb);
- return (ULONGLONG)((timeb.time * 1000) + timeb.millitm);
- }
-
time_t GetLastMessageTime(MCONTACT hContact);
CMString RunConfirmationCode();
CMString ChangeTopicForm();
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index 37eb381157..6c4329b524 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <vector>
#include <regex>
#include <map>
-#include <sys/timeb.h>
#include <newpluginapi.h>
@@ -92,7 +91,13 @@ struct TRInfo sig,
url;
time_t lastRegistrationTime;
-}trouter;
+};
+
+struct MessageId
+{
+ ULONGLONG id;
+ HANDLE handle;
+};
#include "version.h"
#include "resource.h"
|