summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-06 22:28:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-06 22:28:16 +0000
commit387259e6c1c0efb36d4b849b837f2709f061391d (patch)
tree08976c712a55710c9b3eaa9fea8b4bac048f219b /protocols/SkypeWeb/src
parenteefc7846e7379932910cf60d0fceff56f8029478 (diff)
dozen of mem leaks fixed in SkypeWeb
git-svn-id: http://svn.miranda-ng.org/main/trunk@14034 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r--protocols/SkypeWeb/src/skype_avatars.cpp7
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp59
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp24
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp48
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp21
-rw-r--r--protocols/SkypeWeb/src/skype_poll_processing.cpp13
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h30
-rw-r--r--protocols/SkypeWeb/src/skype_search.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp19
-rw-r--r--protocols/SkypeWeb/src/version.h2
14 files changed, 118 insertions, 125 deletions
diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp
index 818bb8dd1a..f3c8a4a154 100644
--- a/protocols/SkypeWeb/src/skype_avatars.cpp
+++ b/protocols/SkypeWeb/src/skype_avatars.cpp
@@ -133,16 +133,15 @@ void CSkypeProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cb
pszDest[tPathLen++] = '\\';
const TCHAR* szFileType = ProtoGetAvatarExtension(getByte(hContact, "AvatarType", PA_FORMAT_JPEG));
- CMStringA username(getStringA(hContact, SKYPE_SETTINGS_ID));
+ CMStringA username(ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)));
username.Replace("live:", "__live_");
username.Replace("facebook:", "__facebook_");
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s%s"), _A2T(username.GetBuffer()), szFileType);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S%s"), username.c_str(), szFileType);
}
void CSkypeProto::SetAvatarUrl(MCONTACT hContact, CMString &tszUrl)
{
- CMString oldUrl(getTStringA(hContact, "AvatarUrl"));
-
+ ptrT oldUrl(getTStringA(hContact, "AvatarUrl"));
if (tszUrl == oldUrl)
return;
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 3d9e6175a3..4b40ff5970 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -114,7 +114,7 @@ void CSkypeProto::OnLoadChats(const NETLIBHTTPREQUEST *response)
std::string syncState = metadata["syncState"].as_string();
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), RegToken), &CSkypeProto::OnSyncHistory);
+ PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), (char*)m_szRegToken), &CSkypeProto::OnSyncHistory);
for (size_t i = 0; i < conversations.size(); i++)
{
@@ -127,9 +127,9 @@ void CSkypeProto::OnLoadChats(const NETLIBHTTPREQUEST *response)
std::string conversationLink = lastMessage["conversationLink"].as_string();
if (conversationLink.find("/19:") != -1)
{
- ptrA skypename(ChatUrlToName(conversationLink.c_str()));
+ CMStringA skypename(ChatUrlToName(conversationLink.c_str()));
CMString topic(threadProperties["topic"].as_mstring());
- SendRequest(new GetChatInfoRequest(RegToken, skypename, Server), &CSkypeProto::OnGetChatInfo, topic.Detach());
+ SendRequest(new GetChatInfoRequest(m_szRegToken, skypename, m_szServer), &CSkypeProto::OnGetChatInfo, topic.Detach());
}
}
}
@@ -182,7 +182,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
if (hContact != NULL)
{
ptrA username(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID));
- SendRequest(new InviteUserToChatRequest(RegToken, chat_id, username, "User", Server));
+ SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, username, "User", m_szServer));
}
break;
}
@@ -206,13 +206,13 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
switch (gch->dwData)
{
case 10:
- SendRequest(new KickUserRequest(RegToken, chat_id, user_id, Server));
+ SendRequest(new KickUserRequest(m_szRegToken, chat_id, user_id, m_szServer));
break;
case 30:
- SendRequest(new InviteUserToChatRequest(RegToken, chat_id, user_id, "Admin", Server));
+ SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "Admin", m_szServer));
break;
case 40:
- SendRequest(new InviteUserToChatRequest(RegToken, chat_id, user_id, "User", Server));
+ SendRequest(new InviteUserToChatRequest(m_szRegToken, chat_id, user_id, "User", m_szServer));
break;
}
@@ -251,7 +251,7 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, reinterpret_cast<LPARAM>(&gce));
- SendRequest(new KickUserRequest(RegToken, _T2A(idT), SelfSkypeName, Server));
+ SendRequest(new KickUserRequest(m_szRegToken, _T2A(idT), m_szSelfSkypeName, m_szServer));
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
@@ -266,7 +266,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
//std::string skypeEditedId = node["skypeeditedid"].as_string();
std::string fromLink = node["from"].as_string();
- ptrA from(ContactUrlToName(fromLink.c_str()));
+ CMStringA from(ContactUrlToName(fromLink.c_str()));
time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());
@@ -274,11 +274,11 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
int emoteOffset = node["skypeemoteoffset"].as_int();
std::string conversationLink = node["conversationLink"].as_string();
- ptrA chatname(ChatUrlToName(conversationLink.c_str()));
+ CMStringA chatname(ChatUrlToName(conversationLink.c_str()));
CMString topic(node["threadtopic"].as_mstring());
if (FindChatRoom(chatname) == NULL)
- SendRequest(new GetChatInfoRequest(RegToken, chatname, Server), &CSkypeProto::OnGetChatInfo, topic.Detach());
+ SendRequest(new GetChatInfoRequest(m_szRegToken, chatname, m_szServer), &CSkypeProto::OnGetChatInfo, topic.Detach());
std::string messageType = node["messagetype"].as_string();
if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
@@ -287,7 +287,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
}
else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/AddMember"))
{
- ptrA xinitiator, xtarget, initiator, target;
+ ptrA xinitiator, xtarget, initiator;
//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("addmember"));
@@ -302,15 +302,14 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
xtarget = mir_t2a(xi.getText(xmlNode));
- target = ParseUrl(xtarget, "8:");
-
+ CMStringA target = ParseUrl(xtarget, "8:");
AddChatContact(_A2T(chatname), target, target, L"User");
}
xi.destroyNode(xml);
}
else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/DeleteMember"))
{
- ptrA xinitiator, xtarget, initiator, target;
+ ptrA xinitiator, xtarget;
//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("deletemember"));
@@ -326,16 +325,15 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
if (xtarget == NULL)
return;
- target = ParseUrl(xtarget, "8:");
- initiator = ParseUrl(xinitiator, "8:");
-
+ CMStringA target = ParseUrl(xtarget, "8:");
+ CMStringA initiator = ParseUrl(xinitiator, "8:");
RemoveChatContact(_A2T(chatname), target, target, true, initiator);
}
else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/TopicUpdate"))
{
//content=<topicupdate><eventtime>1429532702130</eventtime><initiator>8:user</initiator><value>test topic</value></topicupdate>
- ptrA xinitiator, value, initiator;
+ ptrA xinitiator, value;
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("topicupdate"));
if (xml != NULL) {
HXML xmlNode = xi.getChildByPath(xml, _T("initiator"), 0);
@@ -346,15 +344,15 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
xi.destroyNode(xml);
}
- initiator = ParseUrl(xinitiator, "8:");
+ CMStringA initiator = ParseUrl(xinitiator, "8:");
RenameChat(chatname, value);
ChangeChatTopic(chatname, value, initiator);
}
else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/RoleUpdate"))
{
//content=<roleupdate><eventtime>1429551258363</eventtime><initiator>8:user</initiator><target><id>8:user1</id><role>admin</role></target></roleupdate>
- ptrA xinitiator, xId, initiator, id, xRole;
+ ptrA xinitiator, xId, xRole;
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("roleupdate"));
if (xml != NULL) {
HXML xmlNode = xi.getChildByPath(xml, _T("initiator"), 0);
@@ -369,8 +367,9 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
xRole = xmlRole != NULL ? mir_t2a(xi.getText(xmlRole)) : NULL;
}
xi.destroyNode(xml);
- initiator = ParseUrl(xinitiator, "8:");
- id = ParseUrl(xId, "8:");
+
+ CMStringA initiator = ParseUrl(xinitiator, "8:");
+ CMStringA id = ParseUrl(xId, "8:");
GCDEST gcd = { m_szModuleName, _A2T(chatname), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -397,9 +396,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(RegToken, szChatId, time(NULL), szMessage, Server));
+ SendRequest(new SendChatActionRequest(m_szRegToken, szChatId, time(NULL), szMessage, m_szServer));
else
- SendRequest(new SendChatMessageRequest(RegToken, szChatId, time(NULL), szMessage, Server));
+ SendRequest(new SendChatMessageRequest(m_szRegToken, szChatId, time(NULL), szMessage, m_szServer));
}
void CSkypeProto::AddMessageToChat(const TCHAR *chat_id, const TCHAR *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
@@ -443,18 +442,18 @@ void CSkypeProto::OnGetChatInfo(const NETLIBHTTPREQUEST *response, void *p)
if (!properties["capabilities"] || properties["capabilities"].empty())
return;
- ptrA chatId(ChatUrlToName(root["messages"].as_string().c_str()));
- StartChatRoom(_A2T(chatId), mir_tstrdup(topic));
+ CMStringA chatId(ChatUrlToName(root["messages"].as_string().c_str()));
+ StartChatRoom(_A2T(chatId), topic);
for (size_t i = 0; i < members.size(); i++)
{
const JSONNode &member = members.at(i);
- ptrA username(ContactUrlToName(member["userLink"].as_string().c_str()));
+ CMStringA username(ContactUrlToName(member["userLink"].as_string().c_str()));
std::string role = member["role"].as_string();
if (!IsChatContact(_A2T(chatId), username))
AddChatContact(_A2T(chatId), username, username, _A2T(role.c_str()), true);
}
- PushRequest(new GetHistoryRequest(RegToken, chatId, 15, true, 0, Server), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryRequest(m_szRegToken, chatId, 15, true, 0, m_szServer), &CSkypeProto::OnGetServerHistory);
mir_free(topic);
}
@@ -655,7 +654,7 @@ INT_PTR CSkypeProto::GcCreateDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
TCHAR tszTitle[1024];
GetDlgItemText(hwndDlg, IDC_TITLE, tszTitle, SIZEOF(tszTitle));
- ppro->SendRequest(new CreateChatroomRequest(ppro->RegToken, uids, ppro->getStringA(SKYPE_SETTINGS_ID), ppro->Server));
+ ppro->SendRequest(new CreateChatroomRequest(ppro->m_szRegToken, uids, ptrA(ppro->getStringA(SKYPE_SETTINGS_ID)), ppro->m_szServer));
for (int i = 0; i < uids.getCount(); i++)
mir_free(uids[i]);
uids.destroy();
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 1ca0f61b94..4a1202a50b 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -299,14 +299,14 @@ INT_PTR CSkypeProto::OnGrantAuth(WPARAM hContact, LPARAM)
int CSkypeProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
if (hContact && !isChatRoom(hContact))
- PushRequest(new DeleteContactRequest(TokenSecret, db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)));
+ PushRequest(new DeleteContactRequest(m_szTokenSecret, db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)));
return 0;
}
INT_PTR CSkypeProto::BlockContact(WPARAM hContact, LPARAM)
{
if (IDYES == MessageBox(NULL, TranslateT("Are you sure?"), TranslateT("Warning"), MB_YESNOCANCEL | MB_ICONQUESTION))
- SendRequest(new BlockContactRequest(TokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnBlockContact, (void *)hContact);
+ SendRequest(new BlockContactRequest(m_szTokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnBlockContact, (void *)hContact);
return 0;
}
@@ -321,7 +321,7 @@ void CSkypeProto::OnBlockContact(const NETLIBHTTPREQUEST *response, void *p)
INT_PTR CSkypeProto::UnblockContact(WPARAM hContact, LPARAM)
{
- SendRequest(new UnblockContactRequest(TokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnUnblockContact, (void *)hContact);
+ SendRequest(new UnblockContactRequest(m_szTokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnUnblockContact, (void *)hContact);
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 507cedfc05..c21ee4573a 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -37,7 +37,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
bool markAllAsUnread = getBool("MarkMesUnread", true);
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new GetHistoryOnUrlRequest(syncState.c_str(), RegToken), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryOnUrlRequest(syncState.c_str(), m_szRegToken), &CSkypeProto::OnGetServerHistory);
for (int i = (int)conversations.size(); i >= 0; i--)
{
@@ -51,11 +51,11 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
std::string conversationLink = message["conversationLink"].as_string();
int emoteOffset = message["skypeemoteoffset"].as_int();
time_t timestamp = IsoToUnixTime(message["composetime"].as_string().c_str());
- ptrA skypename(ContactUrlToName(from.c_str()));
+ CMStringA skypename(ContactUrlToName(from.c_str()));
bool isEdited = message["skypeeditedid"];
- MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink.c_str())));
+ MCONTACT hContact = FindContact(ContactUrlToName(conversationLink.c_str()));
if (timestamp > db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0))
db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
@@ -106,7 +106,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
//content=<partlist type="started" alt=""><part identity="username"><name>user name</name></part></partlist>
int iType = 3, iDuration = 0;
- ptrA skypename(ContactUrlToName(from.c_str()));
+ CMStringA skypename(ContactUrlToName(from.c_str()));
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("partlist"));
if (xml != NULL)
{
@@ -173,10 +173,8 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("URIObject"));
if (xml != NULL)
{
- ptrA url(mir_t2a(xi.getAttrValue(xml, L"uri")));
- ptrA object(ParseUrl(url, "/objects/"));
-
- CMStringA data(FORMAT, "%s: https://api.asm.skype.com/s/i?%s", Translate("Image"), object);
+ CMStringA object(ParseUrl(_T2A(xi.getAttrValue(xml, L"uri")), "/objects/"));
+ CMStringA data(FORMAT, "%s: https://api.asm.skype.com/s/i?%s", Translate("Image"), object.c_str());
AddMessageToDb(hContact, timestamp, flags, clientMsgId.c_str(), data.GetBuffer());
}
@@ -184,7 +182,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
}
else if (conversationLink.find("/19:") != -1)
{
- ptrA chatname(ChatUrlToName(conversationLink.c_str()));
+ CMStringA chatname(ChatUrlToName(conversationLink.c_str()));
if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText"))
AddMessageToChat(_A2T(chatname), _A2T(skypename), content.c_str(), emoteOffset != NULL, emoteOffset, timestamp, true);
}
@@ -193,7 +191,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM)
{
- PushRequest(new GetHistoryRequest(RegToken, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 100, false, 0, Server), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryRequest(m_szRegToken, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)), 100, false, 0, m_szServer), &CSkypeProto::OnGetServerHistory);
return 0;
}
@@ -213,7 +211,7 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
std::string syncState = metadata["syncState"].as_string();
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), RegToken), &CSkypeProto::OnSyncHistory);
+ PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), (char*)m_szRegToken), &CSkypeProto::OnSyncHistory);
for (size_t i = 0; i < conversations.size(); i++)
{
@@ -227,14 +225,14 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
if (conversationLink.find("/8:") != -1)
{
- ptrA skypename(ContactUrlToName(conversationLink.c_str()));
+ CMStringA skypename(ContactUrlToName(conversationLink.c_str()));
MCONTACT hContact = FindContact(skypename);
if (hContact == NULL)
continue;
if (db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) < composeTime)
{
- PushRequest(new GetHistoryRequest(RegToken, skypename, 100, false, 0, Server), &CSkypeProto::OnGetServerHistory);
+ PushRequest(new GetHistoryRequest(m_szRegToken, skypename, 100, false, 0, m_szServer), &CSkypeProto::OnGetServerHistory);
}
}
}
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index b26516bc32..453ae85d0f 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -75,7 +75,7 @@ void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
return;
}
std::string token = json["skypetoken"].as_string();
- setString("TokenSecret", token.c_str());
+ setString("m_szTokenSecret", token.c_str());
int expiresIn = json["expiresIn"].as_int();
setDword("TokenExpiresIn", time(NULL) + expiresIn);
@@ -85,11 +85,13 @@ void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnLoginSuccess()
{
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_SUCCESS, NULL, 0);
- replaceStr(SelfSkypeName, getStringA(SKYPE_SETTINGS_ID));
- replaceStr(TokenSecret, getStringA("TokenSecret"));
- replaceStr(Server, getStringA("Server") != NULL ? getStringA("Server") : SKYPE_ENDPOINTS_HOST);
- SendRequest(new CreateEndpointRequest(TokenSecret, Server), &CSkypeProto::OnEndpointCreated);
- PushRequest(new GetProfileRequest(TokenSecret), &CSkypeProto::LoadProfile);
+ m_szSelfSkypeName = getStringA(SKYPE_SETTINGS_ID);
+ m_szTokenSecret = getStringA("TokenSecret");
+ m_szServer = getStringA("Server");
+ if (m_szServer == NULL)
+ m_szServer = mir_strdup(SKYPE_ENDPOINTS_HOST);
+ SendRequest(new CreateEndpointRequest(m_szTokenSecret, m_szServer), &CSkypeProto::OnEndpointCreated);
+ PushRequest(new GetProfileRequest(m_szTokenSecret), &CSkypeProto::LoadProfile);
if (!m_timer)
SkypeSetTimer(this);
@@ -127,8 +129,8 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
else if (!mir_strcmpi(response->headers[i].szName, "Location"))
{
CMStringA szValue = response->headers[i].szValue;
- Server = GetServerFromUrl(szValue);
- setString("Server", Server);
+ m_szServer = GetServerFromUrl(szValue).Detach();
+ setString("Server", m_szServer);
}
}
@@ -146,19 +148,19 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
if (response->resultCode == 401)
{
delSetting("TokenExpiresIn");
- SendRequest(new LoginOAuthRequest(SelfSkypeName, ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth);
+ SendRequest(new LoginOAuthRequest(m_szSelfSkypeName, ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth);
return;
}
else //it should be rewritten
{
- SendRequest(new CreateEndpointRequest(TokenSecret, Server), &CSkypeProto::OnEndpointCreated);
+ SendRequest(new CreateEndpointRequest(m_szTokenSecret, m_szServer), &CSkypeProto::OnEndpointCreated);
return;
}
}
- replaceStr(RegToken, getStringA("registrationToken"));
- replaceStr(EndpointId, getStringA("endpointId"));
- SendRequest(new CreateSubscriptionsRequest(RegToken, Server), &CSkypeProto::OnSubscriptionsCreated);
+ m_szRegToken = getStringA("registrationToken");
+ m_szEndpointId = getStringA("endpointId");
+ SendRequest(new CreateSubscriptionsRequest(m_szRegToken, m_szServer), &CSkypeProto::OnSubscriptionsCreated);
SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
}
@@ -173,14 +175,15 @@ void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
SetStatus(ID_STATUS_OFFLINE);
return;
}
+
SendPresence(true);
}
void CSkypeProto::SendPresence(bool isLogin)
{
ptrA epname;
- ptrT place(getTStringA("Place"));
+ ptrT place(getTStringA("Place"));
if (!getBool("UseHostName", false) && place && *place)
epname = mir_utf8encodeT(place);
else
@@ -190,15 +193,16 @@ void CSkypeProto::SendPresence(bool isLogin)
GetComputerName(compName, &size);
epname = mir_utf8encodeT(compName);
}
+
if (isLogin)
- PushRequest(new SendCapabilitiesRequest(RegToken, EndpointId, epname, Server), &CSkypeProto::OnCapabilitiesSended);
+ PushRequest(new SendCapabilitiesRequest(m_szRegToken, m_szEndpointId, epname, m_szServer), &CSkypeProto::OnCapabilitiesSended);
else
- PushRequest(new SendCapabilitiesRequest(RegToken, EndpointId, epname, Server));
+ PushRequest(new SendCapabilitiesRequest(m_szRegToken, m_szEndpointId, epname, m_szServer));
}
void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
{
- SendRequest(new SetStatusRequest(RegToken, MirandaToSkypeStatus(m_iDesiredStatus), Server), &CSkypeProto::OnStatusChanged);
+ SendRequest(new SetStatusRequest(m_szRegToken, MirandaToSkypeStatus(m_iDesiredStatus), m_szServer), &CSkypeProto::OnStatusChanged);
LIST<char> skypenames(1);
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
@@ -206,7 +210,7 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
if (!isChatRoom(hContact))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
}
- SendRequest(new CreateContactsSubscriptionRequest(RegToken, skypenames, Server));
+ SendRequest(new CreateContactsSubscriptionRequest(m_szRegToken, skypenames, m_szServer));
for (int i = 0; i < skypenames.getCount(); i++)
mir_free(skypenames[i]);
skypenames.destroy();
@@ -214,18 +218,18 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
m_hPollingThread = ForkThreadEx(&CSkypeProto::PollingThread, 0, NULL);
PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl"))), &CSkypeProto::OnReceiveAvatar, NULL);
- PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList);
+ PushRequest(new GetContactListRequest(m_szTokenSecret), &CSkypeProto::LoadContactList);
- SendRequest(new LoadChatsRequest(RegToken, Server), &CSkypeProto::OnLoadChats);
+ SendRequest(new LoadChatsRequest(m_szRegToken, m_szServer), &CSkypeProto::OnLoadChats);
if (getBool("AutoSync", true))
- PushRequest(new SyncHistoryFirstRequest(RegToken, 100, Server), &CSkypeProto::OnSyncHistory);
+ PushRequest(new SyncHistoryFirstRequest(m_szRegToken, 100, m_szServer), &CSkypeProto::OnSyncHistory);
if (response == NULL || response->pData == NULL)
return;
JSONNode root = JSONNode::parse(response->pData);
if (root)
- setString("SelfEndpointName", ptrA(SelfUrlToName(root["selfLink"].as_string().c_str())));
+ setString("SelfEndpointName", SelfUrlToName(root["selfLink"].as_string().c_str()));
}
void CSkypeProto::OnStatusChanged(const NETLIBHTTPREQUEST *response)
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 0cc32e4433..228d8bdc26 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// incoming message flow
int CSkypeProto::OnReceiveMessage(const char *messageId, const char *url, time_t timestamp, char *content, int emoteOffset, bool isRead)
{
- ptrA skypename(ContactUrlToName(url));
+ CMStringA skypename(ContactUrlToName(url));
debugLogA("Incoming message from %s", skypename);
MCONTACT hContact = AddContact(skypename, true);
@@ -68,9 +68,9 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
debugLogA(__FUNCTION__ " clientmsgid = %d", param->hMessage);
if (strncmp(szMessage, "/me ", 4) == 0)
- SendRequest(new SendActionRequest(RegToken, SelfSkypeName, param->hMessage, &szMessage[4], Server), &CSkypeProto::OnMessageSent, param);
+ SendRequest(new SendActionRequest(m_szRegToken, m_szSelfSkypeName, param->hMessage, &szMessage[4], m_szServer), &CSkypeProto::OnMessageSent, param);
else
- SendRequest(new SendMessageRequest(RegToken, username, param->hMessage, szMessage, Server), &CSkypeProto::OnMessageSent, param);
+ SendRequest(new SendMessageRequest(m_szRegToken, username, param->hMessage, szMessage, m_szServer), &CSkypeProto::OnMessageSent, param);
return param->hMessage;
}
@@ -135,8 +135,8 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
std::string conversationLink = node["conversationLink"].as_string();
std::string fromLink = node["from"].as_string();
- ptrA skypename(ContactUrlToName(conversationLink.c_str()));
- ptrA from(ContactUrlToName(fromLink.c_str()));
+ CMStringA skypename(ContactUrlToName(conversationLink.c_str()));
+ CMStringA from(ContactUrlToName(fromLink.c_str()));
std::string content = node["content"].as_string();
int emoteOffset = node["skypeemoteoffset"].as_int();
@@ -270,11 +270,8 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
HXML xml = xi.parseString(ptrT(mir_a2t(content.c_str())), 0, _T("URIObject"));
if (xml != NULL)
{
- ptrA url(mir_t2a(xi.getAttrValue(xml, L"uri")));
- ptrA object(ParseUrl(url, "/objects/"));
-
- CMStringA data(FORMAT, "%s: https://api.asm.skype.com/s/i?%s", Translate("Image"), object);
-
+ CMStringA object(ParseUrl(_T2A(xi.getAttrValue(xml, L"uri")), "/objects/"));
+ CMStringA data(FORMAT, "%s: https://api.asm.skype.com/s/i?%s", Translate("Image"), object.c_str());
AddMessageToDb(hContact, timestamp, DBEF_UTF, clientMsgId.c_str(), data.GetBuffer());
}
}
@@ -282,7 +279,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
//if (clientMsgId && (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText")))
//{
- // PushRequest(new MarkMessageReadRequest(skypename, RegToken, _ttoi(json_as_string(json_get(node, "id"))), timestamp, false, Server));
+ // PushRequest(new MarkMessageReadRequest(skypename, m_szRegToken, _ttoi(json_as_string(json_get(node, "id"))), timestamp, false, m_szServer));
//}
}
@@ -304,5 +301,5 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
time_t timestamp = dbei.timestamp;
- PushRequest(new MarkMessageReadRequest(username, RegToken, timestamp, timestamp, false, Server));
+ PushRequest(new MarkMessageReadRequest(username, m_szRegToken, timestamp, timestamp, false, m_szServer));
}
diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp
index cfb1d1dc69..fe6c892147 100644
--- a/protocols/SkypeWeb/src/skype_poll_processing.cpp
+++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp
@@ -21,8 +21,8 @@ void CSkypeProto::ProcessEndpointPresenceRes(const JSONNode &node)
{
debugLogA("CSkypeProto::ProcessEndpointPresenceRes");
std::string selfLink = node["selfLink"].as_string();
- ptrA skypename(ContactUrlToName(selfLink.c_str()));
- if (skypename == NULL)
+ CMStringA skypename(ContactUrlToName(selfLink.c_str()));
+ if (skypename.IsEmpty())
return;
MCONTACT hContact = FindContact(skypename);
@@ -83,10 +83,11 @@ void CSkypeProto::ProcessEndpointPresenceRes(const JSONNode &node)
break;
}
}
+ MirVer.AppendChar(' ');
if (iTyp == 125)
- MirVer.AppendFormat(" %s", version);
+ MirVer.Append(version.c_str());
else
- MirVer.AppendFormat(" %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ MirVer.Append(ParseUrl(skypeNameVersion.c_str(), "/"));
}
}
if (privateInfo != NULL)
@@ -106,7 +107,7 @@ void CSkypeProto::ProcessUserPresenceRes(const JSONNode &node)
std::string selfLink = node["selfLink"].as_string();
std::string status = node["status"].as_string();
- ptrA skypename;
+ CMStringA skypename;
if (selfLink.find("/8:") != std::string::npos)
{
@@ -117,7 +118,7 @@ void CSkypeProto::ProcessUserPresenceRes(const JSONNode &node)
skypename = SelfUrlToName(selfLink.c_str());
}
- if (skypename != NULL)
+ if (!skypename.IsEmpty())
{
if (IsMe(skypename))
{
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index afc4d32d72..5bab08dce0 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -64,7 +64,7 @@ void CSkypeProto::PollingThread(void*)
isTerminated = false;
while (!isTerminated && errors < POLLING_ERRORS_LIMIT)
{
- PollRequest *request = new PollRequest(RegToken, Server);
+ PollRequest *request = new PollRequest(m_szRegToken, m_szServer);
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 4b72a863ee..6d56dd99c7 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -224,7 +224,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
if (m_iStatus > ID_STATUS_CONNECTING + 1)
{
- SendRequest(new DeleteEndpointRequest(RegToken, EndpointId, Server));
+ SendRequest(new DeleteEndpointRequest(m_szRegToken, m_szEndpointId, m_szServer));
delSetting("registrationRoken");
delSetting("endpointId");
delSetting("expires");
@@ -259,7 +259,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
}
else
{
- SendRequest(new SetStatusRequest(RegToken, MirandaToSkypeStatus(m_iDesiredStatus)), &CSkypeProto::OnStatusChanged);
+ SendRequest(new SetStatusRequest(m_szRegToken, MirandaToSkypeStatus(m_iDesiredStatus)), &CSkypeProto::OnStatusChanged);
}
}
@@ -269,7 +269,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
int CSkypeProto::UserIsTyping(MCONTACT hContact, int type)
{
- SendRequest(new SendTypingRequest(RegToken, ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)), type, Server));
+ SendRequest(new SendTypingRequest(m_szRegToken, ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)), type, m_szServer));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index ca3ddc7a26..1c60444312 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -52,12 +52,12 @@ public:
//////////////////////////////////////////////////////////////////////////////////////
// Virtual functions
- virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
- virtual MCONTACT __cdecl AddToListByEvent(int flags, int iContact, MEVENT hDbEvent);
- virtual int __cdecl AuthRequest(MCONTACT hContact, const TCHAR* szMessage);
- virtual int __cdecl Authorize(MEVENT hDbEvent);
- virtual int __cdecl AuthDeny(MEVENT hDbEvent, const TCHAR* szReason);
- virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*);
+ virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
+ virtual MCONTACT __cdecl AddToListByEvent(int flags, int iContact, MEVENT hDbEvent);
+ virtual int __cdecl AuthRequest(MCONTACT hContact, const TCHAR* szMessage);
+ virtual int __cdecl Authorize(MEVENT hDbEvent);
+ virtual int __cdecl AuthDeny(MEVENT hDbEvent, const TCHAR* szReason);
+ virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*);
virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
virtual int __cdecl GetInfo(MCONTACT hContact, int infoType);
@@ -123,13 +123,7 @@ private:
m_hPopupClassNotify;
// accounts
-
- char
- *Server,
- *RegToken,
- *TokenSecret,
- *EndpointId,
- *SelfSkypeName;
+ ptrA m_szServer, m_szRegToken, m_szTokenSecret, m_szEndpointId, m_szSelfSkypeName;
static CSkypeProto* GetContactAccount(MCONTACT hContact);
@@ -322,14 +316,14 @@ private:
static LRESULT CALLBACK PopupDlgProcCall(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam);
- char *ParseUrl(const char *url, const char *token);
+ CMStringA ParseUrl(const char *url, const char *token);
void SetSrmmReadStatus(MCONTACT hContact);
- char *ChatUrlToName(const char *url);
- char *ContactUrlToName(const char *url);
- char *SelfUrlToName(const char *url);
- char *GetServerFromUrl(const char *url);
+ CMStringA ChatUrlToName(const char *url);
+ CMStringA ContactUrlToName(const char *url);
+ CMStringA SelfUrlToName(const char *url);
+ CMStringA GetServerFromUrl(const char *url);
LPCTSTR ClearText(CMString &value, const TCHAR *message);
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp
index 5bdd2c138a..16ea1fd67e 100644
--- a/protocols/SkypeWeb/src/skype_search.cpp
+++ b/protocols/SkypeWeb/src/skype_search.cpp
@@ -31,7 +31,7 @@ void CSkypeProto::SearchBasicThread(void* id)
ptrT idT((TCHAR *)id);
ptrA string(mir_urlEncode(T2Utf(idT)));
- SendRequest(new GetSearchRequest(TokenSecret, string), &CSkypeProto::OnSearch);
+ SendRequest(new GetSearchRequest(m_szTokenSecret, string), &CSkypeProto::OnSearch);
}
void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response)
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index f86f29376c..8b8d6594d8 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -49,7 +49,7 @@ void CSkypeProto::OnCreateTrouter(const NETLIBHTTPREQUEST *response)
TRouter.socketIo = socketio.as_string();
TRouter.url = url.as_string();
- SendRequest(new CreateTrouterPoliciesRequest(TokenSecret, TRouter.connId.c_str()), &CSkypeProto::OnTrouterPoliciesCreated);
+ SendRequest(new CreateTrouterPoliciesRequest(m_szTokenSecret, TRouter.connId.c_str()), &CSkypeProto::OnTrouterPoliciesCreated);
}
void CSkypeProto::OnTrouterPoliciesCreated(const NETLIBHTTPREQUEST *response)
@@ -109,7 +109,7 @@ void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response, void *p)
m_hTrouterThread = ForkThreadEx(&CSkypeProto::TRouterThread, 0, NULL);
if (!isHealth)
- SendRequest(new RegisterTrouterRequest(TokenSecret, TRouter.url.c_str(), TRouter.sessId.c_str()));
+ SendRequest(new RegisterTrouterRequest(m_szTokenSecret, TRouter.url.c_str(), TRouter.sessId.c_str()));
}
void CSkypeProto::OnHealth(const NETLIBHTTPREQUEST*)
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index d0cf4ed480..4b3a2471da 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -530,34 +530,35 @@ bool CSkypeProto::IsFileExists(std::tstring path)
// url parsing
-char *CSkypeProto::ParseUrl(const char *url, const char *token)
+CMStringA CSkypeProto::ParseUrl(const char *url, const char *token)
{
const char *start = strstr(url, token);
if (start == NULL)
- return NULL;
+ return CMStringA();
+
start = start + mir_strlen(token);
const char *end = strchr(start, '/');
if (end == NULL)
- return mir_strdup(start);
- return mir_strndup(start, end - start);
+ return CMStringA(start);
+ return CMStringA(start, end - start);
}
-char *CSkypeProto::ContactUrlToName(const char *url)
+CMStringA CSkypeProto::ContactUrlToName(const char *url)
{
return ParseUrl(url, "/8:");
}
-char *CSkypeProto::SelfUrlToName(const char *url)
+CMStringA CSkypeProto::SelfUrlToName(const char *url)
{
return ParseUrl(url, "/1:");
}
-char *CSkypeProto::ChatUrlToName(const char *url)
+CMStringA CSkypeProto::ChatUrlToName(const char *url)
{
return ParseUrl(url, "/19:");
}
-char *CSkypeProto::GetServerFromUrl(const char *url)
+CMStringA CSkypeProto::GetServerFromUrl(const char *url)
{
return ParseUrl(url, "://");
}
@@ -759,7 +760,7 @@ void CSkypeProto::ProcessTimer()
{
if (IsOnline())
{
- PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList);
+ PushRequest(new GetContactListRequest(m_szTokenSecret), &CSkypeProto::LoadContactList);
SendPresence(false);
if (!m_hTrouterThread)
SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
diff --git a/protocols/SkypeWeb/src/version.h b/protocols/SkypeWeb/src/version.h
index b8357a2fcc..e07f325cbf 100644
--- a/protocols/SkypeWeb/src/version.h
+++ b/protocols/SkypeWeb/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 12
#define __RELEASE_NUM 1
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>