summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-18 07:05:03 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-18 07:05:03 +0000
commit52741a247b2f01c0495f2527e0939755d3348fc3 (patch)
tree7061b63893f33f59f9775acc694b543606546cdf /protocols
parent67c3941db8a7ea1965dbed909f33380200f04090 (diff)
SkypeWeb: Optimizations.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12899 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp30
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp8
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp5
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp17
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h4
7 files changed, 28 insertions, 44 deletions
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 8f629d0d5a..3b180b2f6b 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -138,7 +138,7 @@ void CSkypeProto::StartChatRoom(MCONTACT hChatRoom, bool showWindow)
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gceg);
}
- PushRequest(new GetChatInfoRequest(ptrA(getStringA("registrationToken")), ptrA(mir_t2a(tszChatID)), ptrA(getStringA("Server"))), &CSkypeProto::OnGetChatInfo);
+ PushRequest(new GetChatInfoRequest(RegToken, ptrA(mir_t2a(tszChatID)), Server), &CSkypeProto::OnGetChatInfo);
}
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 7b595ba8e3..c95ea3521a 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -86,13 +86,13 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM)
{
- PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 0, ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryRequest(RegToken, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 0, Server), &CSkypeProto::OnGetServerHistory);
return 0;
}
void CSkypeProto::SyncHistory()
{
- PushRequest(new SyncHistoryFirstRequest(ptrA(getStringA("registrationToken")), ptrA(getStringA("Server"))), &CSkypeProto::OnSyncHistory);
+ PushRequest(new SyncHistoryFirstRequest(RegToken, Server), &CSkypeProto::OnSyncHistory);
}
void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
@@ -123,6 +123,6 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
if (hContact == NULL && !IsMe(skypename))
hContact = AddContact(skypename, true);
if (GetMessageFromDb(hContact, clientMsgId, composeTime) == NULL)
- PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), skypename, 0, ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryRequest(RegToken, skypename, 0, Server), &CSkypeProto::OnGetServerHistory);
}
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 60c6b41064..e7df084f9c 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -107,10 +107,11 @@ void CSkypeProto::OnLoginSecond(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnLoginSuccess()
{
- PushRequest(new CreateEndpointRequest(ptrA(getStringA("TokenSecret"))), &CSkypeProto::OnEndpointCreated);
- PushRequest(new GetProfileRequest(ptrA(getStringA("TokenSecret"))), &CSkypeProto::LoadProfile);
- PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl"))), &CSkypeProto::OnReceiveAvatar, NULL);
- PushRequest(new GetContactListRequest(ptrA(getStringA("TokenSecret"))), &CSkypeProto::LoadContactList);
+ TokenSecret = getStringA("TokenSecret");
+ SendRequest(new CreateEndpointRequest(TokenSecret), &CSkypeProto::OnEndpointCreated);
+ PushRequest(new GetProfileRequest(TokenSecret), &CSkypeProto::LoadProfile);
+ PushRequest(new GetAvatarRequest(TokenSecret), &CSkypeProto::OnReceiveAvatar, NULL);
+ PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList);
}
void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
@@ -145,7 +146,8 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
else if (!mir_strcmpi(response->headers[i].szName, "Location"))
{
CMStringA szValue = response->headers[i].szValue, szCookieName, szCookieVal;
- setString("Server", ptrA(GetServerFromUrl(szValue)));
+ Server = GetServerFromUrl(szValue);
+ setString("Server", Server);
}
}
@@ -158,16 +160,15 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
return;
}
- ptrA server(getStringA("Server"));
if (response->resultCode != 201)
{
- ptrA token(getStringA("TokenSecret"));
- PushRequest(new CreateEndpointRequest(token, server), &CSkypeProto::OnEndpointCreated);
+ PushRequest(new CreateEndpointRequest(TokenSecret, Server), &CSkypeProto::OnEndpointCreated);
return;
}
- ptrA regToken(getStringA("registrationToken"));
- PushRequest(new CreateSubscriptionsRequest(regToken, server), &CSkypeProto::OnSubscriptionsCreated);
+ RegToken = getStringA("registrationToken");
+ EndpointId = getStringA("endpointId");
+ SendRequest(new CreateSubscriptionsRequest(RegToken, Server), &CSkypeProto::OnSubscriptionsCreated);
}
void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
@@ -182,17 +183,14 @@ void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
return;
}
- ptrA regToken(getStringA("registrationToken"));
ptrA skypename(getStringA(SKYPE_SETTINGS_ID));
- ptrA endpoint(getStringA("endpointId"));
- ptrA server(getStringA("Server"));
- PushRequest(new SendCapabilitiesRequest(regToken, endpoint, server));
- PushRequest(new SetStatusRequest(regToken, MirandaToSkypeStatus(m_iDesiredStatus), server), &CSkypeProto::OnStatusChanged);
+ PushRequest(new SendCapabilitiesRequest(RegToken, EndpointId, Server));
+ SendRequest(new SetStatusRequest(RegToken, MirandaToSkypeStatus(m_iDesiredStatus), Server), &CSkypeProto::OnStatusChanged);
LIST<char> skypenames(1);
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
- PushRequest(new CreateContactsRequest(regToken, skypenames, server));
+ PushRequest(new CreateContactsRequest(RegToken, skypenames, Server));
for (int i = 0; i < skypenames.getCount(); i++)
mir_free(skypenames[i]);
skypenames.destroy();
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index c125c3da85..882da1c212 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -134,16 +134,14 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessa
else
message = mir_utf8encode(szMessage);
- ptrA server(getStringA("Server"));
- ptrA token(getStringA("registrationToken"));
ptrA username(getStringA(hContact, "Skypename"));
debugLogA(__FUNCTION__ " clientmsgid = %d", param->hMessage);
if (strncmp(message, "/me ", 4) == 0)
- PushRequest(new SendActionRequest(token, username, param->hMessage, &message[4], server), &CSkypeProto::OnMessageSent, param);
+ SendRequest(new SendActionRequest(RegToken, username, param->hMessage, &message[4], Server), &CSkypeProto::OnMessageSent, param);
else
- PushRequest(new SendMessageRequest(token, username, param->hMessage, message, server), &CSkypeProto::OnMessageSent, param);
+ SendRequest(new SendMessageRequest(RegToken, username, param->hMessage, message, Server), &CSkypeProto::OnMessageSent, param);
return param->hMessage;
}
@@ -281,5 +279,5 @@ void CSkypeProto::MarkMessagesRead(MEVENT hDbEvent)
DBEVENTINFO dbei = { sizeof(dbei) };
db_event_get(hDbEvent, &dbei);
time_t timestamp = dbei.timestamp;
- PushRequest(new MarkMessageReadRequest(ptrA(getStringA("registrationToken")), timestamp, ptrA(getStringA("Server"))));
+ PushRequest(new MarkMessageReadRequest(RegToken, timestamp, Server));
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 921b2178e2..3ebfa13661 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -60,14 +60,11 @@ void CSkypeProto::PollingThread(void*)
{
debugLogA(__FUNCTION__": entering");
- ptrA regToken(getStringA("registrationToken"));
- ptrA server(getStringA("Server"));
-
int errors = 0;
isTerminated = false;
while (!isTerminated && errors < POLLING_ERRORS_LIMIT)
{
- PollRequest *request = new PollRequest(regToken, server);
+ PollRequest *request = new PollRequest(RegToken, Server);
request->nlc = m_pollingConnection;
NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 48f3713c28..4cee50e5f6 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -210,10 +210,8 @@ int CSkypeProto::SetStatus(int iNewStatus)
else
{
// set status
- ptrA regToken(getStringA("registrationToken"));
- ptrA endpoint(getStringA("endpointId"));
- PushRequest(new SetStatusRequest(regToken, MirandaToSkypeStatus(m_iDesiredStatus)), &CSkypeProto::OnStatusChanged);
- PushRequest(new SendCapabilitiesRequest(regToken, endpoint));
+ SendRequest(new SetStatusRequest(RegToken, MirandaToSkypeStatus(m_iDesiredStatus)), &CSkypeProto::OnStatusChanged);
+ PushRequest(new SendCapabilitiesRequest(RegToken, EndpointId));
}
}
@@ -223,16 +221,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
int CSkypeProto::UserIsTyping(MCONTACT hContact, int type)
{
- PushRequest
- (
- new SendTypingRequest
- (
- ptrA(getStringA("registrationToken")),
- ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)),
- type,
- ptrA(getStringA("Server"))
- )
- );
+ SendRequest(new SendTypingRequest(RegToken, ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)), type, Server));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 3d9d2ad4b4..7fd4f368c8 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -83,7 +83,6 @@ private:
RequestQueue *requestQueue;
bool isTerminated;
std::map<std::string, std::string> cookies;
- std::map<std::string, std::string> RegInfo;
HANDLE m_pollingConnection, m_hPollingThread;
static std::map<std::tstring, std::tstring> languages;
@@ -91,6 +90,9 @@ private:
// accounts
static LIST<CSkypeProto> Accounts;
+
+ char *Server, *RegToken, *TokenSecret, *EndpointId;
+
static int CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2);
static CSkypeProto* GetContactAccount(MCONTACT hContact);