diff options
Diffstat (limited to 'protocols/SkypeWeb')
| -rw-r--r-- | protocols/SkypeWeb/src/requests/endpoint.h | 14 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/requests/history.h | 29 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 2 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_history_sync.cpp | 65 | ||||
| -rw-r--r-- | protocols/SkypeWeb/src/skype_proto.cpp | 14 | 
5 files changed, 90 insertions, 34 deletions
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h index 428a727b5b..e0fefa07a3 100644 --- a/protocols/SkypeWeb/src/requests/endpoint.h +++ b/protocols/SkypeWeb/src/requests/endpoint.h @@ -33,4 +33,18 @@ public:  	}
  };
 +class DeleteEndpointRequest : public HttpRequest
 +{
 +public:
 +	DeleteEndpointRequest(const char *regToken, const char *EndpointId, const char *server = SKYPE_ENDPOINTS_HOST) :
 +		HttpRequest(REQUEST_DELETE, FORMAT, "%s/v1/users/ME/endpoints/%s", server, ptrA(mir_urlEncode(EndpointId)))
 +	{
 +		Headers
 +			<< CHAR_VALUE("Accept", "application/json, text/javascript")
 +			<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
 +
 +	}
 +};
 +
 +
  #endif //_SKYPE_REQUEST_ENDPOINT_H_
 diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h index 3f2d3bdf04..f100e47685 100644 --- a/protocols/SkypeWeb/src/requests/history.h +++ b/protocols/SkypeWeb/src/requests/history.h @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.  class SyncHistoryFirstRequest : public HttpRequest
  {
  public:
 -	SyncHistoryFirstRequest(const char *regToken, const char *server = SKYPE_ENDPOINTS_HOST) :
 +	SyncHistoryFirstRequest(const char *regToken, int pageSize = 100, const char *server = SKYPE_ENDPOINTS_HOST) :
  		HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations", server)
  	{
  		Url 
 @@ -34,17 +34,27 @@ public:  			<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
  			<< CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
  	}
 +
 +	SyncHistoryFirstRequest(const char *url, const char *regToken) :
 +		HttpRequest(REQUEST_GET, url)
 +	{
 +
 +		Headers
 +			<< CHAR_VALUE("Accept", "application/json, text/javascript")
 +			<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
 +			<< CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
 +	}
  };
  class GetHistoryRequest : public HttpRequest
  {
  public:
 -	GetHistoryRequest(const char *regToken, const char *username, LONGLONG timestamp = 0, const char *server = SKYPE_ENDPOINTS_HOST, bool isChat = false) :
 +	GetHistoryRequest(const char *regToken, const char *username, int pageSize = 100, bool isChat = false, LONGLONG timestamp = 0, const char *server = SKYPE_ENDPOINTS_HOST) :
  		HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations/%s:%s/messages", server, isChat ? "19" : "8", ptrA(mir_urlEncode(username)))
  	{
  		Url 
  			<< INT_VALUE("startTime", timestamp)
 -			<< INT_VALUE("pageSize", 100)
 +			<< INT_VALUE("pageSize", pageSize)
  			<< CHAR_VALUE("view", "msnp24Equivalent")
  			<< CHAR_VALUE("targetType", "Passport|Skype|Lync|Thread");
 @@ -55,4 +65,17 @@ public:  	}
  };
 +class GetHistoryOnUrlRequest : public HttpRequest
 +{
 +public:
 +	GetHistoryOnUrlRequest(const char *url, const char *regToken) :
 +		HttpRequest(REQUEST_GET, url)
 +	{
 +		Headers
 +			<< CHAR_VALUE("Accept", "application/json, text/javascript")
 +			<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken)
 +			<< CHAR_VALUE("Content-Type", "application/json; charset = UTF-8");
 +	}
 +};
 +
  #endif //_SKYPE_REQUEST_HISTORY_H_
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 52519d2ff5..a60bfd402a 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -80,7 +80,7 @@ MCONTACT CSkypeProto::AddChatRoom(const char *chatname)  		setString(hContact, "ChatID", chatname);
  		TCHAR title[MAX_PATH];
 -		mir_sntprintf(title, SIZEOF(title), _T("%s #%d"), TranslateT("Groupchat"), chatname);
 +		mir_sntprintf(title, SIZEOF(title), _T("%s #%s"), TranslateT("Groupchat"), chatname);
  		setTString(hContact, "Nick", title);
  		DBVARIANT dbv;
 diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index d8ba51cb75..7c4bf07034 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -28,6 +28,14 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)  	if (root == NULL)
  		return;
 +	JSONNODE *metadata = json_get(root, "_metadata");
 +
 +	int totalCount = json_as_int(json_get(metadata, "totalCount"));
 +	ptrA syncState(mir_t2a(ptrT(json_as_string(json_get(metadata, "syncState")))));
 +
 +	if (totalCount >= 99)
 +		PushRequest(new GetHistoryOnUrlRequest(syncState, RegToken), &CSkypeProto::OnGetServerHistory);
 +
  	JSONNODE *conversations = json_as_array(json_get(root, "messages"));
  	for (size_t i = 0; i < json_size(conversations); i++)
  	{
 @@ -83,29 +91,32 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)  		}
  		else if (conversationLink != NULL && strstr(conversationLink, "/19:"))
  		{
 -			ptrA chatname(ContactUrlToName(conversationLink));
 -			GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_MESSAGE };
 -			GCEVENT gce = { sizeof(GCEVENT), &gcd };
 -			gce.bIsMe = IsMe(ContactUrlToName(from));
 -			gce.ptszUID = ptrT(mir_a2t(ContactUrlToName(from)));
 -			gce.time = timestamp;
 -			gce.ptszNick = ptrT(mir_a2t(ContactUrlToName(from)));
 -			gce.ptszText = ptrT(mir_a2t(ptrA(RemoveHtml(content))));
 -			gce.dwFlags = GCEF_NOTNOTIFY;
 -			CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 +			if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText"))
 +			{
 +				ptrA chatname(ContactUrlToName(conversationLink));
 +				GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_MESSAGE };
 +				GCEVENT gce = { sizeof(GCEVENT), &gcd };
 +				gce.bIsMe = IsMe(ContactUrlToName(from));
 +				gce.ptszUID = ptrT(mir_a2t(ContactUrlToName(from)));
 +				gce.time = timestamp;
 +				gce.ptszNick = ptrT(mir_a2t(ContactUrlToName(from)));
 +				gce.ptszText = ptrT(mir_a2t(ptrA(RemoveHtml(content))));
 +				gce.dwFlags = GCEF_NOTNOTIFY;
 +				CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
 +			}
  		}
  	}
  }
  INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM)
  {
 -	PushRequest(new GetHistoryRequest(RegToken, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 0, Server), &CSkypeProto::OnGetServerHistory);
 +	PushRequest(new GetHistoryRequest(RegToken, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 100, false, 0, Server), &CSkypeProto::OnGetServerHistory);
  	return 0;
  }
  void CSkypeProto::SyncHistory()
  {
 -	PushRequest(new SyncHistoryFirstRequest(RegToken, Server), &CSkypeProto::OnSyncHistory);
 +	PushRequest(new SyncHistoryFirstRequest(RegToken, 100, Server), &CSkypeProto::OnSyncHistory);
  }
  void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
 @@ -115,6 +126,15 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)  	JSONROOT root(response->pData);
  	if (root == NULL)
  		return;
 +
 +	JSONNODE *metadata = json_get(root, "_metadata");
 +
 +	int totalCount = json_as_int(json_get(metadata, "totalCount"));
 +	ptrA syncState(mir_t2a(ptrT(json_as_string(json_get(metadata, "syncState")))));
 +
 +	if (totalCount >= 99)
 +		PushRequest(new SyncHistoryFirstRequest(syncState, RegToken), &CSkypeProto::OnSyncHistory);
 +
  	JSONNODE *conversations = json_as_array(json_get(root, "conversations"));
  	for (size_t i = 0; i < json_size(conversations); i++)
  	{
 @@ -128,19 +148,26 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)  		bool isEdited = (skypeEditedId != NULL);
  		char *conversationLink = mir_t2a(json_as_string(json_get(lastMessage, "conversationLink")));
  		time_t composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "conversationLink")))));
 +
  		bool isChat = false;
 -		ptrA skypename(ContactUrlToName(conversationLink));
 -		if (skypename == NULL)
 +		ptrA skypename;
 +
 +		if (conversationLink != NULL && strstr(conversationLink, "/8:"))
 +		{
 +			skypename = ContactUrlToName(conversationLink);
 +		}
 +		else if (conversationLink != NULL && strstr(conversationLink, "/19:"))
  		{
  			skypename = ChatUrlToName(conversationLink);
 -			if (skypename == NULL)
 -				continue;
 -			else 
 -				isChat = true;
 +			isChat = true;
  		}
 +		else 
 +			continue;
 +
  		MCONTACT hContact = !isChat ? AddContact(skypename) : AddChatRoom(skypename);
  		if (isChat) StartChatRoom(hContact);
 +
  		if (GetMessageFromDb(hContact, clientMsgId, composeTime) == NULL)
 -			SendRequest(new GetHistoryRequest(RegToken, skypename, 0, Server, isChat), &CSkypeProto::OnGetServerHistory);
 +			PushRequest(new GetHistoryRequest(RegToken, skypename, !isChat ? 100 : 15, isChat, 0,Server), &CSkypeProto::OnGetServerHistory);
  	}
  }
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 4cee50e5f6..79379a1ade 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -172,18 +172,10 @@ int CSkypeProto::SetStatus(int iNewStatus)  		if (m_pollingConnection)
  			CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConnection, 0);
 -		/*if (m_iStatus > ID_STATUS_CONNECTING + 1)
 +		if (m_iStatus > ID_STATUS_CONNECTING + 1)
  		{
 -			LogoutRequest *logoutRequest = new LogoutRequest();
 -			if (!cookies.empty())
 -			{
 -				CMStringA allCookies;
 -				for (std::map<std::string, std::string>::iterator cookie = cookies.begin(); cookie != cookies.end(); ++cookie)
 -					allCookies.AppendFormat("%s=%s; ", cookie->first.c_str(), cookie->second.c_str());
 -				logoutRequest->Headers << CHAR_VALUE("Cookie", allCookies);
 -			}
 -			PushRequest(logoutRequest);
 -		}*/
 +			SendRequest(new DeleteEndpointRequest(RegToken, EndpointId, Server));
 +		}
  		requestQueue->Stop();
  		if (!Miranda_Terminated())
  | 
