summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-04 21:50:36 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-04 21:50:36 +0300
commit15d1c4c7d318d71b9c06ebced7ed191b7a02a0ec (patch)
treef2c146387f0a05672ae756fa5fbfbe572690f63c
parent932be7eac7944a69a1fe1acadcbcca2743377b3f (diff)
fixes #2410 (Problems with (false) offline contacts in skype protocol)
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h2
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp20
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp52
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp16
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h8
-rw-r--r--protocols/SkypeWeb/src/skype_search.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp4
10 files changed, 58 insertions, 58 deletions
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
index bcb4929d76..51a50c7096 100644
--- a/protocols/SkypeWeb/src/requests/endpoint.h
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -32,7 +32,7 @@ struct CreateEndpointRequest : public AsyncHttpRequest
struct DeleteEndpointRequest : public AsyncHttpRequest
{
DeleteEndpointRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(ppro->m_szId))
+ AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT, "/users/ME/endpoints/" + mir_urlEncode(ppro->m_szId), &CSkypeProto::OnEndpointDeleted)
{
}
};
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 137d6b8475..4034dddfa0 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -119,7 +119,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
CSkypeInviteDlg dlg(this);
if (dlg.DoModal()) {
if (dlg.m_hContact != NULL)
- SendRequest(new InviteUserToChatRequest(chat_id, getId(dlg.m_hContact), "User"));
+ PushRequest(new InviteUserToChatRequest(chat_id, getId(dlg.m_hContact), "User"));
}
}
break;
@@ -131,7 +131,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case 30:
CMStringW newTopic = ChangeTopicForm();
if (!newTopic.IsEmpty())
- SendRequest(new SetChatPropertiesRequest(chat_id, "topic", T2Utf(newTopic.GetBuffer())));
+ PushRequest(new SetChatPropertiesRequest(chat_id, "topic", T2Utf(newTopic.GetBuffer())));
break;
}
break;
@@ -139,13 +139,13 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
switch (gch->dwData) {
case 10:
- SendRequest(new KickUserRequest(chat_id, user_id));
+ PushRequest(new KickUserRequest(chat_id, user_id));
break;
case 30:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin"));
+ PushRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin"));
break;
case 40:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User"));
+ PushRequest(new InviteUserToChatRequest(chat_id, user_id, "User"));
break;
case 50:
ptrA tnick_old(GetChatContactNick(chat_id, user_id, T2Utf(gch->ptszText)));
@@ -211,7 +211,7 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
Chat_Control(m_szModuleName, idT, SESSION_OFFLINE);
Chat_Terminate(m_szModuleName, idT);
- SendRequest(new KickUserRequest(_T2A(idT), m_szSkypename));
+ PushRequest(new KickUserRequest(_T2A(idT), m_szSkypename));
db_delete_contact(hContact);
}
@@ -233,7 +233,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
int nEmoteOffset = node["skypeemoteoffset"].as_int();
if (FindChatRoom(szConversationName) == NULL)
- SendRequest(new GetChatInfoRequest(szConversationName, szTopic));
+ PushRequest(new GetChatInfoRequest(szConversationName, szTopic));
std::string messageType = node["messagetype"].as_string();
if (messageType == "Text" || messageType == "RichText") {
@@ -318,9 +318,9 @@ void CSkypeProto::OnSendChatMessage(const char *chat_id, const wchar_t *tszMessa
ptrA szMessage(mir_utf8encodeW(buf));
if (strncmp(szMessage, "/me ", 4) == 0)
- SendRequest(new SendChatActionRequest(chat_id, time(0), szMessage));
+ PushRequest(new SendChatActionRequest(chat_id, time(0), szMessage));
else
- SendRequest(new SendChatMessageRequest(chat_id, time(0), szMessage));
+ PushRequest(new SendChatMessageRequest(chat_id, time(0), szMessage));
}
void CSkypeProto::AddMessageToChat(const char *chat_id, const char *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
@@ -466,7 +466,7 @@ INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
if (IsOnline()) {
CSkypeGCCreateDlg dlg(this);
if (dlg.DoModal()) {
- SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, this));
+ PushRequest(new CreateChatroomRequest(dlg.m_ContactsList, this));
return 0;
}
}
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 9ae5cb008c..c8b56066fd 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -232,7 +232,7 @@ INT_PTR CSkypeProto::BlockContact(WPARAM hContact, LPARAM)
if (!IsOnline()) return 1;
if (IDYES == MessageBox(NULL, TranslateT("Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION))
- SendRequest(new BlockContactRequest(this, hContact));
+ PushRequest(new BlockContactRequest(this, hContact));
return 0;
}
@@ -245,7 +245,7 @@ void CSkypeProto::OnBlockContact(NETLIBHTTPREQUEST *response, AsyncHttpRequest *
INT_PTR CSkypeProto::UnblockContact(WPARAM hContact, LPARAM)
{
- SendRequest(new UnblockContactRequest(this, hContact));
+ PushRequest(new UnblockContactRequest(this, hContact));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp
index 8f0c94eaa7..4bf25eee6a 100644
--- a/protocols/SkypeWeb/src/skype_files.cpp
+++ b/protocols/SkypeWeb/src/skype_files.cpp
@@ -25,7 +25,7 @@ void CSkypeProto::SendFileThread(void *p)
}
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)fup);
- SendRequest(new ASMObjectCreateRequest(this, fup));
+ PushRequest(new ASMObjectCreateRequest(this, fup));
}
void CSkypeProto::OnASMObjectCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest)
@@ -70,7 +70,7 @@ LBL_Error:
}
fup->size = lBytes;
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
- SendRequest(new ASMObjectUploadRequest(this, strObjectId.c_str(), pData, lBytes, fup));
+ PushRequest(new ASMObjectUploadRequest(this, strObjectId.c_str(), pData, lBytes, fup));
fclose(pFile);
}
@@ -104,7 +104,7 @@ void CSkypeProto::OnASMObjectUploaded(NETLIBHTTPREQUEST *response, AsyncHttpRequ
tinyxml2::XMLPrinter printer(0, true);
doc.Print(&printer);
- SendRequest(new SendMessageRequest(getId(fup->hContact), time(NULL), printer.CStr(), "RichText/Media_GenericFile"));
+ PushRequest(new SendMessageRequest(getId(fup->hContact), time(NULL), printer.CStr(), "RichText/Media_GenericFile"));
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)fup);
delete fup;
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 3f4e0226a2..0bb7711995 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -22,7 +22,7 @@ void CSkypeProto::Login()
// login
m_iStatus = ID_STATUS_CONNECTING;
StartQueue();
- int tokenExpires(getDword("TokenExpiresIn", 0));
+ int tokenExpires = getDword("TokenExpiresIn");
m_szSkypename = getMStringA(SKYPE_SETTINGS_ID);
@@ -35,8 +35,8 @@ void CSkypeProto::Login()
m_bHistorySynced = m_bThreadsTerminated = false;
if ((tokenExpires - 1800) > time(0))
OnLoginSuccess();
-
- PushRequest(new OAuthRequest());
+ else
+ PushRequest(new OAuthRequest());
}
void CSkypeProto::OnLoginOAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
@@ -113,7 +113,7 @@ void CSkypeProto::OnLoginSuccess()
m_impl.m_heartBeat.StartSafe(600 * 1000);
- SendRequest(new CreateEndpointRequest(this));
+ PushRequest(new CreateEndpointRequest(this));
}
void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
@@ -132,9 +132,14 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
switch (response->resultCode) {
case 200:
- case 201: // ok, endpoint created
+ case 201: // okay, endpoint created
+ break;
+
case 301:
- case 302: // redirect
+ case 302: // redirect to the closest data center
+ if (auto *hdr = Netlib_GetHeader(response, "Location"))
+ g_plugin.szDefaultServer = GetServerFromUrl(hdr);
+ PushRequest(new CreateEndpointRequest(this));
break;
case 401: // unauthorized
@@ -142,18 +147,14 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
if (!strstr(szStatus, "SkypeTokenExpired"))
delSetting("TokenSecret");
delSetting("TokenExpiresIn");
- SendRequest(new LoginOAuthRequest(m_szSkypename, pass_ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))));
+ PushRequest(new LoginOAuthRequest(m_szSkypename, pass_ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))));
return;
- case 400:
+ default:
delSetting("TokenExpiresIn");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
-
- default: // it should be rewritten
- SendRequest(new CreateEndpointRequest(this));
- return;
}
if (m_iStatus++ > SKYPE_MAX_CONNECT_RETRIES) {
@@ -174,7 +175,6 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
int iStart2 = 0;
CMStringA name = szToken.Tokenize("=", iStart2);
CMStringA val = szToken.Mid(iStart2);
- setString(name, val);
if (name == "registrationToken")
m_szToken = val.Detach();
@@ -183,10 +183,13 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
}
}
- if (auto *hdr = Netlib_GetHeader(response, "Location"))
- g_plugin.szDefaultServer = GetServerFromUrl(hdr);
-
- SendRequest(new CreateSubscriptionsRequest());
+ PushRequest(new CreateSubscriptionsRequest());
+}
+
+void CSkypeProto::OnEndpointDeleted(NETLIBHTTPREQUEST *, AsyncHttpRequest *)
+{
+ m_szId = nullptr;
+ m_szToken = nullptr;
}
void CSkypeProto::OnSubscriptionsCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
@@ -201,10 +204,10 @@ void CSkypeProto::OnSubscriptionsCreated(NETLIBHTTPREQUEST *response, AsyncHttpR
return;
}
- SendPresence(true);
+ SendPresence();
}
-void CSkypeProto::SendPresence(bool isLogin)
+void CSkypeProto::SendPresence()
{
ptrA epname;
@@ -217,10 +220,7 @@ void CSkypeProto::SendPresence(bool isLogin)
epname = mir_utf8encodeW(compName);
}
- if (isLogin)
- SendRequest(new SendCapabilitiesRequest(epname, this));
- else
- PushRequest(new SendCapabilitiesRequest(epname, this));
+ PushRequest(new SendCapabilitiesRequest(epname, this));
}
void CSkypeProto::OnCapabilitiesSended(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
@@ -234,20 +234,20 @@ void CSkypeProto::OnCapabilitiesSended(NETLIBHTTPREQUEST *response, AsyncHttpReq
return;
}
- SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
+ PushRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
LIST<char> skypenames(1);
for (auto &hContact : AccContacts())
if (!isChatRoom(hContact))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
- SendRequest(new CreateContactsSubscriptionRequest(skypenames));
+ PushRequest(new CreateContactsSubscriptionRequest(skypenames));
FreeList(skypenames);
skypenames.destroy();
m_hPollingEvent.Set();
- SendRequest(new LoadChatsRequest());
+ PushRequest(new LoadChatsRequest());
PushRequest(new GetContactListRequest(this, nullptr));
PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl")), 0));
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 477c271be7..773a6ec588 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -40,7 +40,7 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
else
pReq = new SendMessageRequest(username, param->hMessage, szMessage);
pReq->pUserInfo = param;
- SendRequest(pReq);
+ PushRequest(pReq);
{
mir_cslock lck(m_lckOutMessagesList);
m_OutMessages.insert((void*)param->hMessage);
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index e910c856e1..7a0bb990b5 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -253,9 +253,9 @@ int CSkypeProto::SetStatus(int iNewStatus)
m_iDesiredStatus = iNewStatus;
if (iNewStatus == ID_STATUS_OFFLINE) {
- if (m_iStatus > ID_STATUS_CONNECTING + 1) {
- SendRequest(new DeleteEndpointRequest(this));
- }
+ if (m_iStatus > ID_STATUS_CONNECTING + 1 && m_szId)
+ PushRequest(new DeleteEndpointRequest(this));
+
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
// logout
StopQueue();
@@ -273,12 +273,10 @@ int CSkypeProto::SetStatus(int iNewStatus)
if (old_status == ID_STATUS_CONNECTING)
return 0;
- if (old_status == ID_STATUS_OFFLINE && m_iStatus == ID_STATUS_OFFLINE) {
+ if (old_status == ID_STATUS_OFFLINE && m_iStatus == ID_STATUS_OFFLINE)
Login();
- }
- else {
- SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
- }
+ else
+ PushRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
}
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -287,7 +285,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
int CSkypeProto::UserIsTyping(MCONTACT hContact, int type)
{
- SendRequest(new SendTypingRequest(getId(hContact), type));
+ PushRequest(new SendTypingRequest(getId(hContact), type));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 99392ad332..8355e0e33c 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -112,11 +112,13 @@ public:
// login
void OnLoginOAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnSubscriptionsCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnCapabilitiesSended(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnStatusChanged(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
-
+
+ void OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
+ void OnEndpointDeleted(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
+
// oauth
void OnOAuthStart(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnOAuthAuthorize(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
@@ -211,7 +213,7 @@ private:
// login
void Login();
void OnLoginSuccess();
- void SendPresence(bool isLogin = false);
+ void SendPresence();
// profile
void UpdateProfileFirstName(const JSONNode &root, MCONTACT hContact = NULL);
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp
index 845882f78c..331e7ab80d 100644
--- a/protocols/SkypeWeb/src/skype_search.cpp
+++ b/protocols/SkypeWeb/src/skype_search.cpp
@@ -27,7 +27,7 @@ void CSkypeProto::SearchBasicThread(void *id)
{
debugLogA("CSkypeProto::OnSearchBasicThread");
if (IsOnline())
- SendRequest(new GetSearchRequest(T2Utf((wchar_t *)id)));
+ PushRequest(new GetSearchRequest(T2Utf((wchar_t *)id)));
}
void CSkypeProto::OnSearch(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index d74b3876ea..f0c07d5ede 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -22,6 +22,6 @@ void CSkypeProto::ProcessTimer()
if (!IsOnline())
return;
- PushRequest(new GetContactListRequest(this, nullptr));
- SendPresence(false);
+ SendRequest(new GetContactListRequest(this, nullptr));
+ SendPresence();
}