summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-05-29 23:45:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-05-29 23:45:19 +0300
commitf63eb2bfc28dff8bbf9d56dd57b2bc6b53487f56 (patch)
treef2c2a56e945fc1ea44d5f22f95cd397a0d251fa2 /protocols/SkypeWeb
parent133826f5022c5b0d9beca9285d66afcb604e2fc4 (diff)
Skype:
- fixes #829; - massive code cleaning
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp6
-rw-r--r--protocols/SkypeWeb/src/requests/avatars.h2
-rw-r--r--protocols/SkypeWeb/src/requests/contacts.h2
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h4
-rw-r--r--protocols/SkypeWeb/src/skype_accounts.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_avatars.cpp30
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp260
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp86
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp38
-rw-r--r--protocols/SkypeWeb/src/skype_dialogs.cpp31
-rw-r--r--protocols/SkypeWeb/src/skype_events.cpp71
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp17
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp52
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp145
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp7
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp120
-rw-r--r--protocols/SkypeWeb/src/skype_mslogin.cpp55
-rw-r--r--protocols/SkypeWeb/src/skype_oauth.cpp34
-rw-r--r--protocols/SkypeWeb/src/skype_options.cpp8
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp83
-rw-r--r--protocols/SkypeWeb/src/skype_popups.cpp25
-rw-r--r--protocols/SkypeWeb/src/skype_profile.cpp29
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp84
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h4
-rw-r--r--protocols/SkypeWeb/src/skype_search.cpp10
-rw-r--r--protocols/SkypeWeb/src/skype_timers.cpp7
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp42
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp89
-rw-r--r--protocols/SkypeWeb/src/stdafx.h2
-rw-r--r--protocols/SkypeWeb/src/version.h2
30 files changed, 519 insertions, 828 deletions
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index db030aa10f..29341dc05a 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -92,11 +92,9 @@ unsigned int RequestQueue::WorkerThread(void *arg)
{
RequestQueue *queue = (RequestQueue*)arg;
- while (!queue->isTerminated)
- {
+ while (!queue->isTerminated) {
queue->hRequestQueueEvent.Wait();
- while (true)
- {
+ while (true) {
RequestQueueItem *item = NULL;
{
mir_cslock lock(queue->requestQueueLock);
diff --git a/protocols/SkypeWeb/src/requests/avatars.h b/protocols/SkypeWeb/src/requests/avatars.h
index 97b5460416..5f7c1ee36e 100644
--- a/protocols/SkypeWeb/src/requests/avatars.h
+++ b/protocols/SkypeWeb/src/requests/avatars.h
@@ -31,7 +31,7 @@ class SetAvatarRequest : public HttpRequest
{
public:
SetAvatarRequest(const PBYTE data, size_t dataSize, const char *szMime, LoginInfo &li) :
- HttpRequest(REQUEST_PUT, FORMAT, "api.skype.com/users/%s/profile/avatar", CMStringA(li.szSkypename.get()).MakeLower().c_str())
+ HttpRequest(REQUEST_PUT, FORMAT, "api.skype.com/users/%s/profile/avatar", li.szSkypename.MakeLower().c_str())
{
Headers
<< CHAR_VALUE("X-Skypetoken", li.api.szToken)
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h
index b2a93290e1..372b0b07e9 100644
--- a/protocols/SkypeWeb/src/requests/contacts.h
+++ b/protocols/SkypeWeb/src/requests/contacts.h
@@ -31,7 +31,7 @@ public:
<< CHAR_VALUE("Accept", "application/json");
}*/
GetContactListRequest(LoginInfo &li, const char *filter) :
- HttpRequest(REQUEST_GET, FORMAT, "contacts.skype.com/contacts/v1/users/%s/contacts", CMStringA(li.szSkypename).MakeLower().GetBuffer())
+ HttpRequest(REQUEST_GET, FORMAT, "contacts.skype.com/contacts/v1/users/%s/contacts", li.szSkypename.MakeLower().GetBuffer())
{
if (filter != NULL)
{
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index 71b4153d36..2b3b798db5 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -52,7 +52,7 @@ public:
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
CMStringA content;
- content.AppendFormat("%s %s", li.szSkypename, message);
+ content.AppendFormat("%s %s", li.szSkypename.c_str(), message);
JSONNode node;
node
@@ -60,7 +60,7 @@ public:
<< JSONNode("messagetype", "RichText")
<< JSONNode("contenttype", "text")
<< JSONNode("content", content)
- << JSONNode("skypeemoteoffset", (int)(mir_strlen(li.szSkypename) + 1));
+ << JSONNode("skypeemoteoffset", li.szSkypename.GetLength() + 1);
Body << VALUE(node.write().c_str());
}
diff --git a/protocols/SkypeWeb/src/skype_accounts.cpp b/protocols/SkypeWeb/src/skype_accounts.cpp
index 59ab76a9a9..7ea2416741 100644
--- a/protocols/SkypeWeb/src/skype_accounts.cpp
+++ b/protocols/SkypeWeb/src/skype_accounts.cpp
@@ -67,4 +67,4 @@ int CSkypeProto::OnAccountLoaded(WPARAM, LPARAM)
INT_PTR CSkypeProto::OnAccountManagerInit(WPARAM, LPARAM lParam)
{
return (INT_PTR)(CSkypeOptionsMain::CreateAccountManagerPage(this, (HWND)lParam))->GetHwnd();
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_avatars.cpp b/protocols/SkypeWeb/src/skype_avatars.cpp
index 02129aa9cc..92f536de6b 100644
--- a/protocols/SkypeWeb/src/skype_avatars.cpp
+++ b/protocols/SkypeWeb/src/skype_avatars.cpp
@@ -19,8 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
INT_PTR CSkypeProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
- switch (wParam)
- {
+ switch (wParam) {
case AF_MAXSIZE:
((POINT*)lParam)->x = 98;
((POINT*)lParam)->y = 98;
@@ -44,8 +43,7 @@ INT_PTR CSkypeProto::SvcGetAvatarCaps(WPARAM wParam, LPARAM lParam)
void CSkypeProto::ReloadAvatarInfo(MCONTACT hContact)
{
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
return;
}
@@ -169,23 +167,18 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM, LPARAM lParam)
wchar_t *path = (wchar_t*)lParam;
wchar_t avatarPath[MAX_PATH];
GetAvatarFileName(NULL, avatarPath, _countof(avatarPath));
- if (path != NULL)
- {
- if (CopyFile(path, avatarPath, FALSE))
- {
+ if (path != NULL) {
+ if (CopyFile(path, avatarPath, FALSE)) {
FILE *hFile = _wfopen(path, L"rb");
- if (hFile)
- {
+ if (hFile) {
fseek(hFile, 0, SEEK_END);
size_t length = ftell(hFile);
- if (length != -1)
- {
+ if (length != -1) {
rewind(hFile);
mir_ptr<BYTE> data((PBYTE)mir_alloc(length));
- if (data != NULL && fread(data, sizeof(BYTE), length, hFile) == length)
- {
+ if (data != NULL && fread(data, sizeof(BYTE), length, hFile) == length) {
const char *szMime = "image/jpeg";
if (fii)
szMime = fii->FI_GetFIFMimeType(fii->FI_GetFIFFromFilenameU(path));
@@ -200,13 +193,8 @@ INT_PTR CSkypeProto::SvcSetMyAvatar(WPARAM, LPARAM lParam)
}
return -1;
}
- else
- {
- if (IsFileExists(avatarPath))
- {
- DeleteFile(avatarPath);
- }
- }
+ else if (IsFileExists(avatarPath))
+ DeleteFile(avatarPath);
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 0d0f304798..2e476468af 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -39,11 +39,9 @@ void CSkypeProto::CloseAllChatChatSessions()
gci.pszModule = m_szModuleName;
int count = pci->SM_GetCount(m_szModuleName);
- for (int i = 0; i < count; i++)
- {
+ for (int i = 0; i < count; i++) {
gci.iItem = i;
- if (!Chat_GetInfo(&gci))
- {
+ if (!Chat_GetInfo(&gci)) {
Chat_Control(m_szModuleName, gci.pszID, SESSION_OFFLINE);
Chat_Terminate(m_szModuleName, gci.pszID);
}
@@ -88,8 +86,7 @@ void CSkypeProto::OnLoadChats(const NETLIBHTTPREQUEST *response)
if (totalCount >= 99 || conversations.size() >= 99)
PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), li), &CSkypeProto::OnSyncHistory);
- for (size_t i = 0; i < conversations.size(); i++)
- {
+ for (size_t i = 0; i < conversations.size(); i++) {
const JSONNode &conversation = conversations.at(i);
const JSONNode &threadProperties = conversation["threadProperties"];
const JSONNode &id = conversation["id"];
@@ -108,62 +105,60 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
{
GCHOOK *gch = (GCHOOK*)lParam;
if (!gch)
- {
return 1;
- }
- else if (mir_strcmp(gch->pDest->pszModule, m_szModuleName) != 0)
- {
+
+ if (mir_strcmp(gch->pDest->pszModule, m_szModuleName) != 0)
return 0;
- }
_T2A chat_id(gch->pDest->ptszID);
- switch (gch->pDest->iType)
- {
+ switch (gch->pDest->iType) {
case GC_USER_MESSAGE:
- {
OnSendChatMessage(gch->pDest->ptszID, gch->ptszText);
break;
- }
case GC_USER_PRIVMESS:
- {
- MCONTACT hContact = FindContact(_T2A(gch->ptszUID));
- if (hContact == NULL)
{
- hContact = AddContact(_T2A(gch->ptszUID), true);
- setWord(hContact, "Status", ID_STATUS_ONLINE);
- db_set_b(hContact, "CList", "Hidden", 1);
- setWString(hContact, "Nick", gch->ptszUID);
- db_set_dw(hContact, "Ignore", "Mask1", 0);
+ MCONTACT hContact = FindContact(_T2A(gch->ptszUID));
+ if (hContact == NULL) {
+ hContact = AddContact(_T2A(gch->ptszUID), true);
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
+ db_set_b(hContact, "CList", "Hidden", 1);
+ setWString(hContact, "Nick", gch->ptszUID);
+ db_set_dw(hContact, "Ignore", "Mask1", 0);
+ }
+ CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
}
- CallService(MS_MSG_SENDMESSAGEW, hContact, 0);
break;
- }
case GC_USER_LOGMENU:
- {
- switch (gch->dwData)
- {
- case 10: {
- CSkypeInviteDlg dlg(this);
-
- { mir_cslock lck(m_InviteDialogsLock); m_InviteDialogs.insert(&dlg); }
-
- if(!dlg.DoModal()) break;
- MCONTACT hContact = dlg.m_hContact;
- if (hContact != NULL)
+ switch (gch->dwData) {
+ case 10:
{
- SendRequest(new InviteUserToChatRequest(chat_id, Contacts[hContact], "User", li));
- }
+ CSkypeInviteDlg dlg(this);
+ {
+ mir_cslock lck(m_InviteDialogsLock);
+ m_InviteDialogs.insert(&dlg);
+ }
+
+ if (!dlg.DoModal())
+ break;
- { mir_cslock lck(m_InviteDialogsLock); m_InviteDialogs.remove(&dlg); }
+ MCONTACT hContact = dlg.m_hContact;
+ if (hContact != NULL)
+ SendRequest(new InviteUserToChatRequest(chat_id, Contacts[hContact], "User", li));
+ {
+ mir_cslock lck(m_InviteDialogsLock);
+ m_InviteDialogs.remove(&dlg);
+ }
+ }
break;
- }
+
case 20:
OnLeaveChatRoom(FindChatRoom(chat_id), NULL);
break;
+
case 30:
CMStringW newTopic = ChangeTopicForm();
if (!newTopic.IsEmpty())
@@ -171,83 +166,73 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
break;
}
break;
- }
case GC_USER_NICKLISTMENU:
- {
-
- _T2A user_id(gch->ptszUID);
-
-
- switch (gch->dwData)
{
- case 10:
- SendRequest(new KickUserRequest(chat_id, user_id, li));
- break;
- case 30:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin", li));
- break;
- case 40:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li));
- break;
- case 50:
- ptrW tnick_old(GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText)));
-
- ENTER_STRING pForm = { sizeof(pForm) };
- pForm.type = ESF_COMBO;
- pForm.recentCount = 0;
- pForm.caption = TranslateT("Enter new nickname");
- pForm.ptszInitVal = tnick_old;
- pForm.szModuleName = m_szModuleName;
- pForm.szDataPrefix = "renamenick_";
-
- if (EnterString(&pForm))
- {
- MCONTACT hChatContact = FindChatRoom(chat_id);
- if (hChatContact == NULL)
- break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
+ _T2A user_id(gch->ptszUID);
- ptrW tnick_new(pForm.ptszResult);
- bool reset = mir_wstrlen(tnick_new) == 0;
- if (reset)
- {
- // User fill blank name, which means we reset the custom nick
- db_unset(hChatContact, "UsersNicks", _T2A(gch->ptszUID));
- tnick_new = GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText));
+ switch (gch->dwData) {
+ case 10:
+ SendRequest(new KickUserRequest(chat_id, user_id, li));
+ break;
+ case 30:
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin", li));
+ break;
+ case 40:
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", li));
+ break;
+ case 50:
+ ptrW tnick_old(GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText)));
+
+ ENTER_STRING pForm = { sizeof(pForm) };
+ pForm.type = ESF_COMBO;
+ pForm.recentCount = 0;
+ pForm.caption = TranslateT("Enter new nickname");
+ pForm.ptszInitVal = tnick_old;
+ pForm.szModuleName = m_szModuleName;
+ pForm.szDataPrefix = "renamenick_";
+
+ if (EnterString(&pForm)) {
+ MCONTACT hChatContact = FindChatRoom(chat_id);
+ if (hChatContact == NULL)
+ break; // This probably shouldn't happen, but if chat is NULL for some reason, do nothing
+
+ ptrW tnick_new(pForm.ptszResult);
+ bool reset = mir_wstrlen(tnick_new) == 0;
+ if (reset) {
+ // User fill blank name, which means we reset the custom nick
+ db_unset(hChatContact, "UsersNicks", _T2A(gch->ptszUID));
+ tnick_new = GetChatContactNick(chat_id, _T2A(gch->ptszUID), _T2A(gch->ptszText));
+ }
+
+ if (!mir_wstrcmp(tnick_old, tnick_new))
+ break; // New nick is same, do nothing
+
+ GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_NICK };
+ GCEVENT gce = { &gcd };
+
+ gce.ptszNick = tnick_old;
+ gce.bIsMe = IsMe(user_id);
+ gce.ptszUID = gch->ptszUID;
+ gce.ptszText = tnick_new;
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.time = time(NULL);
+ Chat_Event(&gce);
+
+ if (!reset)
+ db_set_ws(hChatContact, "UsersNicks", _T2A(gch->ptszUID), tnick_new);
}
-
- if (!mir_wstrcmp(tnick_old, tnick_new))
- break; // New nick is same, do nothing
-
- GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_NICK };
- GCEVENT gce = { &gcd };
-
- gce.ptszNick = tnick_old;
- gce.bIsMe = IsMe(user_id);
- gce.ptszUID = gch->ptszUID;
- gce.ptszText = tnick_new;
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.time = time(NULL);
- Chat_Event(&gce);
-
- if (!reset)
- db_set_ws(hChatContact, "UsersNicks", _T2A(gch->ptszUID), tnick_new);
+ break;
}
-
break;
-
}
-
- break;
- }
}
return 0;
}
INT_PTR CSkypeProto::OnJoinChatRoom(WPARAM hContact, LPARAM)
{
- if (hContact)
- {
+ if (hContact) {
ptrW idT(getWStringA(hContact, "ChatRoomID"));
ptrW nameT(getWStringA(hContact, "Nick"));
StartChatRoom(idT, nameT != NULL ? nameT : idT);
@@ -260,8 +245,7 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
if (!IsOnline())
return 1;
- if (hContact && IDYES == MessageBox(NULL, TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION))
- {
+ if (hContact && IDYES == MessageBox(NULL, TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)) {
ptrW idT(getWStringA(hContact, "ChatRoomID"));
Chat_Control(m_szModuleName, idT, SESSION_OFFLINE);
Chat_Terminate(m_szModuleName, idT);
@@ -288,18 +272,16 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
std::string strContent = node["content"].as_string();
int nEmoteOffset = node["skypeemoteoffset"].as_int();
-
+
if (FindChatRoom(szConversationName) == NULL)
SendRequest(new GetChatInfoRequest(szConversationName, li), &CSkypeProto::OnGetChatInfo, szTopic.Detach());
std::string messageType = node["messagetype"].as_string();
- if (messageType == "Text" || messageType == "RichText")
- {
+ if (messageType == "Text" || messageType == "RichText") {
ptrA szClearedContent(messageType == "RichText" ? RemoveHtml(strContent.c_str()) : mir_strdup(strContent.c_str()));
AddMessageToChat(_A2T(szConversationName), _A2T(szFromSkypename), szClearedContent, nEmoteOffset != NULL, nEmoteOffset, timestamp);
}
- else if (messageType == "ThreadActivity/AddMember")
- {
+ else if (messageType == "ThreadActivity/AddMember") {
ptrA xinitiator, xtarget, initiator;
//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
@@ -307,8 +289,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
if (xml == NULL)
return;
- for (int i = 0; i < xmlGetChildCount(xml); i++)
- {
+ for (int i = 0; i < xmlGetChildCount(xml); i++) {
HXML xmlNode = xmlGetNthChild(xml, L"target", i);
if (xmlNode == NULL)
break;
@@ -320,8 +301,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
}
xmlDestroyNode(xml);
}
- else if (messageType == "ThreadActivity/DeleteMember")
- {
+ else if (messageType == "ThreadActivity/DeleteMember") {
ptrA xinitiator, xtarget;
//content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
@@ -343,8 +323,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
RemoveChatContact(_A2T(szConversationName), target, target, true, initiator);
}
- else if (messageType == "ThreadActivity/TopicUpdate")
- {
+ else if (messageType == "ThreadActivity/TopicUpdate") {
//content=<topicupdate><eventtime>1429532702130</eventtime><initiator>8:user</initiator><value>test topic</value></topicupdate>
ptrA xinitiator, value;
HXML xml = xmlParseString(ptrW(mir_utf8decodeW(strContent.c_str())), 0, L"topicupdate");
@@ -362,8 +341,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
RenameChat(szConversationName, value);
ChangeChatTopic(szConversationName, value, initiator);
}
- else if (messageType == "ThreadActivity/RoleUpdate")
- {
+ else if (messageType == "ThreadActivity/RoleUpdate") {
//content=<roleupdate><eventtime>1429551258363</eventtime><initiator>8:user</initiator><target><id>8:user1</id><role>admin</role></target></roleupdate>
ptrA xinitiator, xId, xRole;
HXML xml = xmlParseString(ptrW(mir_utf8decodeW(strContent.c_str())), 0, L"roleupdate");
@@ -372,15 +350,14 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
xinitiator = xmlNode != NULL ? mir_u2a(xmlGetText(xmlNode)) : NULL;
xmlNode = xmlGetChildByPath(xml, L"target", 0);
- if (xmlNode != NULL)
- {
+ if (xmlNode != NULL) {
HXML xmlId = xmlGetChildByPath(xmlNode, L"id", 0);
HXML xmlRole = xmlGetChildByPath(xmlNode, L"role", 0);
xId = xmlId != NULL ? mir_u2a(xmlGetText(xmlId)) : NULL;
xRole = xmlRole != NULL ? mir_u2a(xmlGetText(xmlRole)) : NULL;
}
xmlDestroyNode(xml);
-
+
CMStringA initiator = ParseUrl(xinitiator, "8:");
CMStringA id = ParseUrl(xId, "8:");
@@ -424,7 +401,7 @@ void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from,
{
GCDEST gcd = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
GCEVENT gce = { &gcd };
-
+
ptrW tnick(GetChatContactNick(_T2A(chat_id), _T2A(from), _T2A(from)));
gce.bIsMe = IsMe(_T2A(from));
@@ -435,15 +412,11 @@ void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from,
CMStringW tszText(ptrW(mir_utf8decodeW(content)));
tszText.Replace(L"%", L"%%");
- if (!isAction)
- {
+ if (!isAction) {
gce.ptszText = tszText;
gce.dwFlags = GCEF_ADDTOLOG;
}
- else
- {
- gce.ptszText = &(tszText.GetBuffer())[emoteOffset];
- }
+ else gce.ptszText = &(tszText.GetBuffer())[emoteOffset];
if (isLoading) gce.dwFlags = GCEF_NOTNOTIFY;
@@ -467,8 +440,7 @@ void CSkypeProto::OnGetChatInfo(const NETLIBHTTPREQUEST *response, void *p)
CMStringA chatId(UrlToSkypename(root["messages"].as_string().c_str()));
StartChatRoom(_A2T(chatId), topic);
- for (size_t i = 0; i < members.size(); i++)
- {
+ for (size_t i = 0; i < members.size(); i++) {
const JSONNode &member = members.at(i);
CMStringA username(UrlToSkypename(member["userLink"].as_string().c_str()));
@@ -516,7 +488,8 @@ char *CSkypeProto::GetChatUsers(const wchar_t *chat_id)
return gci.pszUsers;
}
-wchar_t* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, const char *name) {
+wchar_t* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, const char *name)
+{
// Check if there is custom nick for this chat contact
if (chat_id != NULL) {
if (wchar_t *tname = db_get_wsa(FindChatRoom(chat_id), "UsersNicks", id))
@@ -524,14 +497,12 @@ wchar_t* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, co
}
// Check if we have this contact in database
- if (IsMe(id))
- {
+ if (IsMe(id)) {
// Return my nick
if (wchar_t *tname = getWStringA(NULL, "Nick"))
return tname;
}
- else
- {
+ else {
MCONTACT hContact = FindContact(id);
if (hContact != NULL) {
// Primarily return custom name
@@ -583,15 +554,13 @@ void CSkypeProto::RemoveChatContact(const wchar_t *tchat_id, const char *id, con
GCDEST gcd = { m_szModuleName, tchat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART };
GCEVENT gce = { &gcd };
- if (isKick)
- {
+ if (isKick) {
gce.ptszUID = tid;
gce.ptszNick = tnick;
gce.ptszStatus = tinitiator;
gce.time = time(NULL);
}
- else
- {
+ else {
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = tnick;
gce.ptszUID = tid;
@@ -604,8 +573,7 @@ void CSkypeProto::RemoveChatContact(const wchar_t *tchat_id, const char *id, con
INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
{
- if (IsOnline())
- {
+ if (IsOnline()) {
CSkypeGCCreateDlg dlg(this);
{ mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.insert(&dlg); }
@@ -613,7 +581,7 @@ INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
if (!dlg.DoModal()) { return 1; }
SendRequest(new CreateChatroomRequest(dlg.m_ContactsList, li));
-
+
{ mir_cslock lck(m_GCCreateDialogsLock); m_GCCreateDialogs.remove(&dlg); }
return 0;
}
@@ -627,8 +595,7 @@ int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
if (mir_strcmpi(gcmi->pszModule, m_szModuleName)) return 0;
- if (gcmi->Type == MENU_ON_LOG)
- {
+ if (gcmi->Type == MENU_ON_LOG) {
static const struct gc_item Items[] =
{
{ LPGENW("&Invite user..."), 10, MENU_ITEM, FALSE },
@@ -637,8 +604,7 @@ int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
};
Chat_AddMenuItems(gcmi->hMenu, _countof(Items), Items);
}
- else if (gcmi->Type == MENU_ON_NICKLIST)
- {
+ else if (gcmi->Type == MENU_ON_NICKLIST) {
static const struct gc_item Items[] =
{
{ LPGENW("Kick &user"), 10, MENU_ITEM },
@@ -663,4 +629,4 @@ CMStringW CSkypeProto::ChangeTopicForm()
pForm.ptszInitVal = NULL;
pForm.szModuleName = m_szModuleName;
return (!EnterString(&pForm)) ? CMStringW() : CMStringW(ptrW(pForm.ptszResult));
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index d1781a386a..add5caadf7 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -25,8 +25,7 @@ WORD CSkypeProto::GetContactStatus(MCONTACT hContact)
void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status)
{
WORD oldStatus = GetContactStatus(hContact);
- if (oldStatus != status)
- {
+ if (oldStatus != status) {
setWord(hContact, "Status", status);
if (status == ID_STATUS_OFFLINE)
db_unset(hContact, m_szModuleName, "MirVer");
@@ -35,8 +34,7 @@ void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status)
void CSkypeProto::SetAllContactsStatus(WORD status)
{
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- {
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (!isChatRoom(hContact))
SetContactStatus(hContact, status);
}
@@ -72,8 +70,7 @@ MCONTACT CSkypeProto::GetContactFromAuthEvent(MEVENT hEvent)
MCONTACT CSkypeProto::FindContact(const char *skypename)
{
MCONTACT hContact = NULL;
- for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- {
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (!mir_strcmpi(skypename, Contacts[hContact]))
break;
}
@@ -84,16 +81,14 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
{
MCONTACT hContact = FindContact(skypename);
- if (!hContact)
- {
+ if (!hContact) {
hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, SKYPE_SETTINGS_ID, skypename);
DBVARIANT dbv;
- if (!getWString(SKYPE_SETTINGS_GROUP, &dbv))
- {
+ if (!getWString(SKYPE_SETTINGS_GROUP, &dbv)) {
db_set_ws(hContact, "CList", "Group", dbv.ptszVal);
db_free(&dbv);
}
@@ -117,8 +112,7 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response)
return;
const JSONNode &items = root.as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
@@ -128,12 +122,10 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response)
time_t eventTime = IsoToUnixTime(item["event_time_iso"].as_string().c_str());
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
+ if (hContact) {
time_t lastEventTime = db_get_dw(hContact, m_szModuleName, "LastAuthRequestTime", 0);
- if (lastEventTime < eventTime)
- {
+ if (lastEventTime < eventTime) {
db_set_dw(hContact, m_szModuleName, "LastAuthRequestTime", eventTime);
delSetting(hContact, "Auth");
@@ -161,16 +153,14 @@ void CSkypeProto::LoadContactsInfo(const NETLIBHTTPREQUEST *response)
return;
const JSONNode &items = root.as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
std::string skypename = item["username"].as_string();
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
+ if (hContact) {
UpdateProfileCountry(item, hContact);
UpdateProfileCity(item, hContact);
UpdateProfileXStatusMessage(item, hContact);
@@ -193,8 +183,7 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
LIST<char> skypenames(1);
bool loadAll = getBool("LoadAllContacts", false);
const JSONNode &items = root["contacts"].as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
@@ -208,29 +197,23 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
CMStringW last_name = name["surname"].as_mstring();
CMStringW avatar_url = item["avatar_url"].as_mstring();
std::string type = item["type"].as_string();
-
- if (type == "skype" || loadAll)
- {
+
+ if (type == "skype" || loadAll) {
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
- if (item["authorized"].as_bool())
- {
+ if (hContact) {
+ if (item["authorized"].as_bool()) {
delSetting(hContact, "Auth");
delSetting(hContact, "Grant");
}
else setByte(hContact, "Grant", 1);
- if (item["blocked"].as_bool())
- {
+ if (item["blocked"].as_bool()) {
db_set_dw(hContact, "Ignore", "Mask1", 127);
db_set_b(hContact, "CList", "Hidden", 1);
setByte(hContact, "IsBlocked", 1);
}
- else
- {
- if (db_get_b(hContact, m_szModuleName, "IsBlocked", 0))
- {
+ else {
+ if (db_get_b(hContact, m_szModuleName, "IsBlocked", 0)) {
db_set_dw(hContact, "Ignore", "Mask1", 0);
db_set_b(hContact, "CList", "Hidden", 0);
setByte(hContact, "IsBlocked", 0);
@@ -239,31 +222,28 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
setString(hContact, "Type", type.c_str());
- if (display_name)
- setWString(hContact, "Nick", display_name);
- if (first_name)
- setWString(hContact, "FirstName", first_name);
+ if (display_name)
+ setWString(hContact, "Nick", display_name);
+ if (first_name)
+ setWString(hContact, "FirstName", first_name);
if (last_name)
- setWString(hContact, "LastName", last_name);
+ setWString(hContact, "LastName", last_name);
- if (item["mood"])
- {
+ if (item["mood"]) {
db_set_utf(hContact, "CList", "StatusMsg", ptrA(RemoveHtml(item["mood"].as_string().c_str())));
}
SetAvatarUrl(hContact, avatar_url);
ReloadAvatarInfo(hContact);
- for (size_t j = 0; j < phones.size(); j++)
- {
+ for (size_t j = 0; j < phones.size(); j++) {
const JSONNode &phone = phones.at(j);
if (!phone)
break;
CMStringW number = phone["number"].as_mstring();
- switch (phone["type"].as_int())
- {
+ switch (phone["type"].as_int()) {
case 0:
setWString(hContact, "Phone", number);
break;
@@ -273,22 +253,20 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
}
}
- if (type == "skype") skypenames.insert(mir_strdup(skypename.c_str()));
+ if (type == "skype")
+ skypenames.insert(mir_strdup(skypename.c_str()));
}
}
}
- if (skypenames.getCount() > 0)
- {
+ if (skypenames.getCount() > 0) {
int i = 0;
- do
- {
+ do {
LIST<char> users(1);
for (; i < skypenames.getCount() && users.getCount() <= 50; i++)
users.insert(skypenames[i]);
PushRequest(new GetContactsInfoRequest(li, users), &CSkypeProto::LoadContactsInfo);
- }
- while(i < skypenames.getCount());
+ } while (i < skypenames.getCount());
FreeList(skypenames);
skypenames.destroy();
@@ -355,4 +333,4 @@ void CSkypeProto::OnUnblockContact(const NETLIBHTTPREQUEST *response, void *p)
db_set_dw(hContact, "Ignore", "Mask1", 0);
db_set_b(hContact, "CList", "Hidden", 0);
db_set_b(hContact, m_szModuleName, "IsBlocked", 0);
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index 2dbe2ced90..8bd6ab79e7 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -39,8 +39,7 @@ MEVENT CSkypeProto::GetMessageFromDb(MCONTACT hContact, const char *messageId, L
size_t messageIdLength = mir_strlen(messageId);
mir_cslock lock(messageSyncLock);
- for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent))
- {
+ for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {
DBEVENTINFO dbei = {};
dbei.cbBlob = db_event_getBlobSize(hDbEvent);
@@ -86,28 +85,24 @@ MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *
db_event_get(hEvent, &dbei);
JSONNode jMsg = JSONNode::parse((char*)dbei.pBlob);
- if (jMsg)
- {
+ if (jMsg) {
JSONNode &jEdits = jMsg["edits"];
- if (jEdits)
- {
- for (auto it = jEdits.begin(); it != jEdits.end(); ++it)
- {
+ if (jEdits) {
+ for (auto it = jEdits.begin(); it != jEdits.end(); ++it) {
const JSONNode &jEdit = *it;
if (jEdit["time"].as_int() == edit_time)
return hEvent;
}
JSONNode jEdit;
- jEdit
+ jEdit
<< JSONNode("time", (long)edit_time)
<< JSONNode("text", szContent);
jEdits << jEdit;
}
}
- else
- {
+ else {
jMsg = JSONNode();
JSONNode jOriginalMsg; jOriginalMsg.set_name("original_message");
JSONNode jEdits(JSON_ARRAY); jEdits.set_name("edits");
@@ -119,28 +114,28 @@ MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *
jMsg << jOriginalMsg;
- jEdit
+ jEdit
<< JSONNode("time", (long)edit_time)
<< JSONNode("text", szContent);
- jEdits << jEdit;
- jMsg << jEdits;
+ jEdits << jEdit;
+ jMsg << jEdits;
}
- db_event_delete(hContact, hEvent);
+ db_event_delete(hContact, hEvent);
return AddDbEvent(SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE, hContact, dbei.timestamp, dbei.flags, jMsg.write().c_str(), szUid);
}
MEVENT CSkypeProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob)
{
DBEVENTINFO dbei = {};
- dbei.szModule = m_szModuleName;
+ dbei.szModule = m_szModuleName;
dbei.timestamp = timestamp;
dbei.eventType = type;
- dbei.cbBlob = cbBlob;
- dbei.pBlob = pBlob;
- dbei.flags = flags;
+ dbei.cbBlob = cbBlob;
+ dbei.pBlob = pBlob;
+ dbei.flags = flags;
return db_event_add(hContact, &dbei);
}
@@ -155,8 +150,7 @@ void CSkypeProto::InitDBEvents()
dbEventType.iconService = MODULE "/GetEventIcon";
dbEventType.textService = MODULE "/GetEventText";
- for (size_t i = 0; i < _countof(g_SkypeDBTypes); i++)
- {
+ for (size_t i = 0; i < _countof(g_SkypeDBTypes); i++) {
SkypeDBType &cur = g_SkypeDBTypes[i];
dbEventType.eventType = cur.type;
@@ -167,4 +161,4 @@ void CSkypeProto::InitDBEvents()
dbEventType.flags &= (~cur.flags);
}
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_dialogs.cpp b/protocols/SkypeWeb/src/skype_dialogs.cpp
index 21fcd6b56a..f37232a728 100644
--- a/protocols/SkypeWeb/src/skype_dialogs.cpp
+++ b/protocols/SkypeWeb/src/skype_dialogs.cpp
@@ -19,14 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CSkypeProto::CloseDialogs()
{
- {
- mir_cslock lck(m_GCCreateDialogsLock);
+ { mir_cslock lck(m_GCCreateDialogsLock);
for (int i = 0; i < m_GCCreateDialogs.getCount(); i++)
m_GCCreateDialogs[i]->Close();
}
- {
- mir_cslock lck(m_InviteDialogsLock);
+ { mir_cslock lck(m_InviteDialogsLock);
for (int i = 0; i < m_InviteDialogs.getCount(); i++)
m_InviteDialogs[i]->Close();
}
@@ -34,17 +32,15 @@ void CSkypeProto::CloseDialogs()
//CSkypeInvideDlg
CSkypeInviteDlg::CSkypeInviteDlg(CSkypeProto *proto) :
-CSkypeDlgBase(proto, IDD_GC_INVITE, false), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_combo(this, IDC_CONTACT), m_hContact(NULL)
+ CSkypeDlgBase(proto, IDD_GC_INVITE, false), m_ok(this, IDOK), m_cancel(this, IDCANCEL), m_combo(this, IDC_CONTACT), m_hContact(NULL)
{
m_ok.OnClick = Callback(this, &CSkypeInviteDlg::btnOk_OnOk);
}
void CSkypeInviteDlg::OnInitDialog()
{
- for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName))
- {
- if (!m_proto->isChatRoom(hContact))
- {
+ for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
+ if (!m_proto->isChatRoom(hContact)) {
wchar_t *ptszNick = pcli->pfnGetContactDisplayName(hContact, 0);
m_combo.AddString(ptszNick, hContact);
}
@@ -63,6 +59,7 @@ CSkypeGCCreateDlg::CSkypeGCCreateDlg(CSkypeProto *proto) :
m_ok.OnClick = Callback(this, &CSkypeGCCreateDlg::btnOk_OnOk);
m_clc.OnListRebuilt = Callback(this, &CSkypeGCCreateDlg::FilterList);
}
+
CSkypeGCCreateDlg::~CSkypeGCCreateDlg()
{
CSkypeProto::FreeList(m_ContactsList);
@@ -80,14 +77,10 @@ void CSkypeGCCreateDlg::OnInitDialog()
void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*)
{
- for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName))
- {
- if (!m_proto->isChatRoom(hContact))
- {
- if (HANDLE hItem = m_clc.FindContact(hContact))
- {
- if (m_clc.GetCheck(hItem))
- {
+ for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
+ if (!m_proto->isChatRoom(hContact)) {
+ if (HANDLE hItem = m_clc.FindContact(hContact)) {
+ if (m_clc.GetCheck(hItem)) {
char *szName = mir_strdup(m_proto->Contacts[hContact]);
if (szName != NULL)
m_ContactsList.insert(szName);
@@ -95,7 +88,7 @@ void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*)
}
}
}
- m_ContactsList.insert(m_proto->li.szSkypename);
+ m_ContactsList.insert(m_proto->li.szSkypename.GetBuffer());
EndDialog(m_hwnd, m_ContactsList.getCount());
}
@@ -120,4 +113,4 @@ void CSkypeGCCreateDlg::ResetListOptions(CCtrlClc *)
m_clc.SetHideOfflineRoot(true);
for (int i = 0; i <= FONTID_MAX; i++)
m_clc.SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp
index 4e07fb6f26..ad278aeee7 100644
--- a/protocols/SkypeWeb/src/skype_events.cpp
+++ b/protocols/SkypeWeb/src/skype_events.cpp
@@ -22,21 +22,18 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
{
DBEVENTINFO *dbei = (DBEVENTINFO*)pEvent;
- CMStringA szText;
+ CMStringA szText;
BOOL bUseBB = db_get_b(NULL, dbei->szModule, "UseBBCodes", 1);
- switch (dbei->eventType)
- {
+ switch (dbei->eventType) {
case SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE:
{
JSONNode jMsg = JSONNode::parse((char*)dbei->pBlob);
- if (jMsg)
- {
+ if (jMsg) {
JSONNode &jOriginalMsg = jMsg["original_message"];
szText.AppendFormat(bUseBB ? Translate("[b]Original message:[/b]\n%s\n") : Translate("Original message:\n%s\n"), mir_utf8decodeA(jOriginalMsg["text"].as_string().c_str()));
JSONNode &jEdits = jMsg["edits"];
- for (auto it = jEdits.begin(); it != jEdits.end(); ++it)
- {
+ for (auto it = jEdits.begin(); it != jEdits.end(); ++it) {
const JSONNode &jEdit = *it;
time_t time = jEdit["time"].as_int();
@@ -45,10 +42,9 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
szText.AppendFormat(bUseBB ? Translate("[b]Edited at %s:[/b]\n%s\n") : Translate("Edited at %s:\n%s\n"), szTime, mir_utf8decodeA(jEdit["text"].as_string().c_str()));
}
-
+
}
- else
- {
+ else {
szText = INVALID_DATA;
}
break;
@@ -57,39 +53,31 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
case SKYPE_DB_EVENT_TYPE_CALL_INFO:
{
HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"partlist");
- if (xml != NULL)
- {
+ if (xml != NULL) {
ptrA type(mir_u2a(xmlGetAttrValue(xml, L"type")));
bool bType = (!mir_strcmpi(type, "started")) ? 1 : 0;
time_t callDuration = 0;
- for (int i = 0; i < xmlGetChildCount(xml); i++)
- {
- HXML xmlPart = xmlGetNthChild(xml, L"part", i);
- if (xmlPart != NULL)
- {
+ for (int i = 0; i < xmlGetChildCount(xml); i++) {
+ HXML xmlPart = xmlGetNthChild(xml, L"part", i);
+ if (xmlPart != NULL) {
HXML xmlDuration = xmlGetChildByPath(xmlPart, L"duration", 0);
-
- if (xmlDuration != NULL)
- {
+
+ if (xmlDuration != NULL) {
callDuration = _wtol(xmlGetText(xmlDuration));
break;
}
}
}
- if (bType)
- {
+ if (bType) {
szText = Translate("Call");
}
- else
- {
- if (callDuration == 0)
- {
+ else {
+ if (callDuration == 0) {
szText = Translate("Call missed");
}
- else
- {
+ else {
char szTime[100];
strftime(szTime, sizeof(szTime), "%X", gmtime(&callDuration));
szText.Format(Translate("Call ended (%s)"), szTime);
@@ -97,8 +85,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
}
xmlDestroyNode(xml);
}
- else
- {
+ else {
szText = INVALID_DATA;
}
break;
@@ -106,18 +93,14 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO:
{
HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"files");
- if (xml != NULL)
- {
- for (int i = 0; i < xmlGetChildCount(xml); i++)
- {
+ if (xml != NULL) {
+ for (int i = 0; i < xmlGetChildCount(xml); i++) {
LONGLONG fileSize = 0;
HXML xmlNode = xmlGetNthChild(xml, L"file", i);
- if (xmlNode != NULL)
- {
+ if (xmlNode != NULL) {
fileSize = _wtol(xmlGetAttrValue(xmlNode, L"size"));
char *fileName = _T2A(xmlGetText(xmlNode));
- if (fileName != NULL)
- {
+ if (fileName != NULL) {
szText.AppendFormat(Translate("File transfer:\n\tFile name: %s \n\tSize: %lld bytes \n"), fileName, fileSize);
}
@@ -125,8 +108,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
}
xmlDestroyNode(xml);
}
- else
- {
+ else {
szText = INVALID_DATA;
}
}
@@ -137,18 +119,15 @@ INT_PTR CSkypeProto::GetEventText(WPARAM pEvent, LPARAM datatype)
case SKYPE_DB_EVENT_TYPE_URIOBJ:
{
HXML xml = xmlParseString(ptrW(mir_utf8decodeW((char*)dbei->pBlob)), 0, L"URIObject");
- if (xml != NULL)
- {
+ if (xml != NULL) {
//szText.Append(_T2A(xmlGetText(xml)));
HXML xmlA = xmlGetChildByPath(xml, L"a", 0);
- if (xmlA != NULL)
- {
+ if (xmlA != NULL) {
szText += T2Utf(xmlGetAttrValue(xmlA, L"href"));
}
xmlDestroyNode(xml);
}
- else
- {
+ else {
szText = INVALID_DATA;
}
}
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp
index aa26123f46..17efd46bc0 100644
--- a/protocols/SkypeWeb/src/skype_files.cpp
+++ b/protocols/SkypeWeb/src/skype_files.cpp
@@ -4,8 +4,7 @@
HANDLE CSkypeProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles)
{
- if (IsOnline())
- {
+ if (IsOnline()) {
CFileUploadParam *fup = new CFileUploadParam(hContact, szDescription, ppszFiles);
ForkThread(&CSkypeProto::SendFileThread, (void*)fup);
return (HANDLE)fup;
@@ -33,8 +32,7 @@ void CSkypeProto::SendFileThread(void *p)
void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *arg)
{
CFileUploadParam *fup = (CFileUploadParam*)arg;
- if (response && response->pData)
- {
+ if (response && response->pData) {
JSONNode node = JSONNode::parse((char*)response->pData);
std::string strObjectId = node["id"].as_string();
fup->uid = mir_strdup(strObjectId.c_str());
@@ -44,13 +42,13 @@ void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *ar
fseek(pFile, 0, SEEK_END);
long lFileLen = ftell(pFile);
- if(lFileLen < 1) {
+ if (lFileLen < 1) {
fclose(pFile);
return;
}
fseek(pFile, 0, SEEK_SET);
-
+
mir_ptr<BYTE> pData((BYTE*)mir_alloc(lFileLen));
long lBytes = (long)fread(pData, sizeof(BYTE), lFileLen, pFile);
@@ -69,8 +67,7 @@ void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *ar
void CSkypeProto::OnASMObjectUploaded(const NETLIBHTTPREQUEST *response, void *arg)
{
CFileUploadParam *fup = (CFileUploadParam*)arg;
- if (response == nullptr)
- {
+ if (response == nullptr) {
FILETRANSFER_FAILED(fup);
return;
}
@@ -86,7 +83,7 @@ void CSkypeProto::OnASMObjectUploaded(const NETLIBHTTPREQUEST *response, void *a
xmlAddAttr(xmlOrigName, L"v", tszFile);
HXML xmlSize = xmlAddChild(xml, L"FileSize", nullptr);
xmlAddAttr(xmlSize, L"v", CMStringW(FORMAT, L"%d", fup->size));
-
+
xmlAddAttr(xml, L"Type", L"File.1");
xmlAddAttr(xml, L"uri", CMStringW(FORMAT, L"https://api.asm.skype.com/v1/objects/%s", _A2T(fup->uid)));
xmlAddAttr(xml, L"url_thumbnail", CMStringW(FORMAT, L"https://api.asm.skype.com/v1/objects/%s/views/thumbnail", _A2T(fup->uid)));
@@ -95,4 +92,4 @@ void CSkypeProto::OnASMObjectUploaded(const NETLIBHTTPREQUEST *response, void *a
xmlDestroyNode(xml);
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)fup);
delete fup;
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 0baf127e7b..c7d10ef54b 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -39,8 +39,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
if (totalCount >= 99 || conversations.size() >= 99)
PushRequest(new GetHistoryOnUrlRequest(syncState.c_str(), li), &CSkypeProto::OnGetServerHistory);
- for (int i = (int)conversations.size(); i >= 0; i--)
- {
+ for (int i = (int)conversations.size(); i >= 0; i--) {
const JSONNode &message = conversations.at(i);
CMStringA szMessageId = message["clientmessageid"] ? message["clientmessageid"].as_string().c_str() : message["skypeeditedid"].as_string().c_str();
@@ -56,7 +55,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
bool isEdited = message["skypeeditedid"];
MCONTACT hContact = FindContact(UrlToSkypename(conversationLink.c_str()));
-
+
if (timestamp > db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0))
db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
@@ -68,46 +67,36 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
if (IsMe(skypename))
iFlags |= DBEF_SENT;
- if (strstr(conversationLink.c_str(), "/8:"))
- {
- if (messageType == "Text" || messageType == "RichText")
- {
+ if (strstr(conversationLink.c_str(), "/8:")) {
+ if (messageType == "Text" || messageType == "RichText") {
ptrA szMessage(messageType == "RichText" ? RemoveHtml(content.c_str()) : mir_strdup(content.c_str()));
MEVENT dbevent = GetMessageFromDb(hContact, szMessageId);
- if (isEdited && dbevent != NULL)
- {
+ if (isEdited && dbevent != NULL) {
AppendDBEvent(hContact, dbevent, szMessage, szMessageId, timestamp);
}
else AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, iFlags, &szMessage[emoteOffset], szMessageId);
}
- else if (messageType == "Event/Call")
- {
+ else if (messageType == "Event/Call") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (messageType == "RichText/Files")
- {
+ else if (messageType == "RichText/Files") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (messageType == "RichText/UriObject")
- {
+ else if (messageType == "RichText/UriObject") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
- else if (messageType == "RichText/Contacts")
- {
+ else if (messageType == "RichText/Contacts") {
ProcessContactRecv(hContact, timestamp, content.c_str(), szMessageId);
}
- else
- {
+ else {
AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
}
- else if (conversationLink.find("/19:") != -1)
- {
+ else if (conversationLink.find("/19:") != -1) {
CMStringA chatname(UrlToSkypename(conversationLink.c_str()));
ptrA szMessage(messageType == "RichText" ? RemoveHtml(content.c_str()) : mir_strdup(content.c_str()));
- if (messageType == "Text" || messageType == "RichText")
- {
+ if (messageType == "Text" || messageType == "RichText") {
AddMessageToChat(_A2T(chatname), _A2T(skypename), szMessage, emoteOffset != NULL, emoteOffset, timestamp, true);
}
}
@@ -138,24 +127,19 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
if (totalCount >= 99 || conversations.size() >= 99)
PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), li), &CSkypeProto::OnSyncHistory);
- for (size_t i = 0; i < conversations.size(); i++)
- {
+ for (size_t i = 0; i < conversations.size(); i++) {
const JSONNode &conversation = conversations.at(i);
const JSONNode &lastMessage = conversation["lastMessage"];
- if (lastMessage)
- {
+ if (lastMessage) {
std::string strConversationLink = lastMessage["conversationLink"].as_string();
- if (strConversationLink.find("/8:") != -1)
- {
+ if (strConversationLink.find("/8:") != -1) {
CMStringA szSkypename = UrlToSkypename(strConversationLink.c_str());
time_t composeTime(IsoToUnixTime(lastMessage["composetime"].as_string().c_str()));
MCONTACT hContact = FindContact(szSkypename);
- if (hContact != NULL)
- {
- if (getDword(hContact, "LastMsgTime", 0) < composeTime)
- {
+ if (hContact != NULL) {
+ if (getDword(hContact, "LastMsgTime", 0) < composeTime) {
PushRequest(new GetHistoryRequest(szSkypename, 100, false, 0, li), &CSkypeProto::OnGetServerHistory);
}
}
@@ -164,4 +148,4 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
}
m_bHistorySynced = true;
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 98ccf8b66c..b49ed92647 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -29,21 +29,15 @@ void CSkypeProto::Login()
li.szSkypename = getStringA(SKYPE_SETTINGS_ID);
pass_ptrA szPassword(getStringA(SKYPE_SETTINGS_PASSWORD));
- if (li.szSkypename == NULL || szPassword == NULL)
- {
+ if (li.szSkypename.IsEmpty() || szPassword == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
return;
- }
+ }
+
m_bHistorySynced = m_bThreadsTerminated = false;
if ((tokenExpires - 1800) > time(NULL))
OnLoginSuccess();
- /*else
- {
- if (strchr(li.szSkypename, '@'))
- SendRequest(new LoginMSRequest(), &CSkypeProto::OnMSLoginFirst);
- else
- SendRequest(new LoginOAuthRequest((char*)li.szSkypename, szPassword), &CSkypeProto::OnLoginOAuth);
- }*/
+
PushRequest(new OAuthRequest(), &CSkypeProto::OnOAuthStart);
}
@@ -51,54 +45,43 @@ void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
{
if (!IsStatusConnecting(m_iStatus)) return;
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
JSONNode json = JSONNode::parse(response->pData);
- if (!json)
- {
+ if (!json) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
- if (response->resultCode != 200)
- {
+ if (response->resultCode != 200) {
int error = 0;
- if (json["status"])
- {
+ if (json["status"]) {
const JSONNode &status = json["status"];
- if (status["code"])
- {
- switch(status["code"].as_int())
- {
+ if (status["code"]) {
+ switch (status["code"].as_int()) {
case 40002:
- {
- ShowNotification(L"Skype", TranslateT("Authentication failed. Invalid username."), NULL, 1);
- error = LOGINERR_BADUSERID;
- break;
- }
+ ShowNotification(L"Skype", TranslateT("Authentication failed. Invalid username."), NULL, 1);
+ error = LOGINERR_BADUSERID;
+ break;
+
case 40120:
- {
- ShowNotification(L"Skype", TranslateT("Authentication failed. Bad username or password."), NULL, 1);
- error = LOGINERR_WRONGPASSWORD;
- break;
- }
+ ShowNotification(L"Skype", TranslateT("Authentication failed. Bad username or password."), NULL, 1);
+ error = LOGINERR_WRONGPASSWORD;
+ break;
+
case 40121:
- {
- ShowNotification(L"Skype", TranslateT("Too many failed authentication attempts with given username or IP."), NULL, 1);
- error = LOGIN_ERROR_TOOMANY_REQUESTS;
- break;
- }
- default:
- {
- ShowNotification(L"Skype", status["text"] ? status["text"].as_mstring() : TranslateT("Authentication failed. Unknown error."), NULL, 1);
- error = LOGIN_ERROR_UNKNOWN;
- }
+ ShowNotification(L"Skype", TranslateT("Too many failed authentication attempts with given username or IP."), NULL, 1);
+ error = LOGIN_ERROR_TOOMANY_REQUESTS;
+ break;
+
+ default:
+ ShowNotification(L"Skype", status["text"] ? status["text"].as_mstring() : TranslateT("Authentication failed. Unknown error."), NULL, 1);
+ error = LOGIN_ERROR_UNKNOWN;
}
}
}
@@ -108,8 +91,7 @@ void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
return;
}
- if (!json["skypetoken"] || !json["expiresIn"])
- {
+ if (!json["skypetoken"] || !json["expiresIn"]) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -120,9 +102,11 @@ void CSkypeProto::OnLoginOAuth(const NETLIBHTTPREQUEST *response)
OnLoginSuccess();
}
+
void CSkypeProto::OnLoginSuccess()
{
- if (!IsStatusConnecting(m_iStatus)) return;
+ if (!IsStatusConnecting(m_iStatus))
+ return;
m_bThreadsTerminated = false;
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_SUCCESS, NULL, 0);
@@ -140,22 +124,18 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
m_iStatus++;
- if (response == NULL)
- {
+ if (response == NULL) {
debugLogA(__FUNCTION__ ": failed to get create endpoint");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
- for (int i = 0; i < response->headersCount; i++)
- {
- if (!mir_strcmpi(response->headers[i].szName, "Set-RegistrationToken"))
- {
+ for (int i = 0; i < response->headersCount; i++) {
+ if (!mir_strcmpi(response->headers[i].szName, "Set-RegistrationToken")) {
CMStringA szValue = response->headers[i].szValue, szCookieName, szCookieVal;
int iStart = 0;
- while (true)
- {
+ while (true) {
CMStringA szToken = szValue.Tokenize(";", iStart).Trim();
if (iStart == -1)
break;
@@ -168,58 +148,48 @@ void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response)
li.endpoint.szToken = szCookieVal.Detach();
else if (szCookieName == "endpointId")
li.endpoint.szId = szCookieVal.Detach();
-
}
}
- else if (!mir_strcmpi(response->headers[i].szName, "Location"))
- {
+ else if (!mir_strcmpi(response->headers[i].szName, "Location")) {
CMStringA szValue = response->headers[i].szValue;
li.endpoint.szServer = GetServerFromUrl(szValue).Detach();
setString("Server", li.endpoint.szServer);
}
-
}
- if (m_iStatus++ > SKYPE_MAX_CONNECT_RETRIES)
- {
+ if (m_iStatus++ > SKYPE_MAX_CONNECT_RETRIES) {
debugLogA(__FUNCTION__ ": failed to create endpoint (too many connect retries)");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
- if (response->resultCode != 201)
- {
- if (response->resultCode == 401)
- {
+ if (response->resultCode != 201) {
+ if (response->resultCode == 401) {
delSetting("TokenExpiresIn");
- SendRequest(new LoginOAuthRequest((char*)li.szSkypename, pass_ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth);
+ SendRequest(new LoginOAuthRequest(li.szSkypename, pass_ptrA(getStringA(SKYPE_SETTINGS_PASSWORD))), &CSkypeProto::OnLoginOAuth);
return;
}
- else if (response->resultCode == 400)
- {
+ if (response->resultCode == 400) {
delSetting("TokenExpiresIn");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
- else //it should be rewritten
- {
- SendRequest(new CreateEndpointRequest(li), &CSkypeProto::OnEndpointCreated);
- return;
- }
+ // it should be rewritten
+ SendRequest(new CreateEndpointRequest(li), &CSkypeProto::OnEndpointCreated);
+ return;
}
-
SendRequest(new CreateSubscriptionsRequest(li), &CSkypeProto::OnSubscriptionsCreated);
}
void CSkypeProto::OnSubscriptionsCreated(const NETLIBHTTPREQUEST *response)
{
- if (!IsStatusConnecting(m_iStatus)) return;
+ if (!IsStatusConnecting(m_iStatus))
+ return;
- if (response == NULL)
- {
+ if (response == NULL) {
debugLogA(__FUNCTION__ ": failed to create subscription");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
@@ -235,8 +205,7 @@ void CSkypeProto::SendPresence(bool isLogin)
if (!m_opts.bUseHostnameAsPlace && m_opts.wstrPlace && *m_opts.wstrPlace)
epname = mir_utf8encodeW(m_opts.wstrPlace);
- else
- {
+ else {
wchar_t compName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = _countof(compName);
GetComputerName(compName, &size);
@@ -245,16 +214,16 @@ void CSkypeProto::SendPresence(bool isLogin)
if (isLogin)
SendRequest(new SendCapabilitiesRequest(epname, li), &CSkypeProto::OnCapabilitiesSended);
- else
+ else
PushRequest(new SendCapabilitiesRequest(epname, li));
}
void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
{
- if (!IsStatusConnecting(m_iStatus)) return;
+ if (!IsStatusConnecting(m_iStatus))
+ return;
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -264,10 +233,9 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
LIST<char> skypenames(1);
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- {
if (!isChatRoom(hContact))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
- }
+
SendRequest(new CreateContactsSubscriptionRequest(skypenames, li));
FreeList(skypenames);
skypenames.destroy();
@@ -278,7 +246,7 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
PushRequest(new GetContactListRequest(li, NULL), &CSkypeProto::LoadContactList);
PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl"))), &CSkypeProto::OnReceiveAvatar, NULL);
-
+
if (m_opts.bAutoHistorySync)
PushRequest(new SyncHistoryFirstRequest(100, li), &CSkypeProto::OnSyncHistory);
@@ -291,8 +259,7 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnStatusChanged(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
debugLogA(__FUNCTION__ ": failed to change status");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
@@ -300,8 +267,7 @@ void CSkypeProto::OnStatusChanged(const NETLIBHTTPREQUEST *response)
}
JSONNode json = JSONNode::parse(response->pData);
- if (!json)
- {
+ if (!json) {
debugLogA(__FUNCTION__ ": failed to change status");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
@@ -315,8 +281,7 @@ void CSkypeProto::OnStatusChanged(const NETLIBHTTPREQUEST *response)
}
int iNewStatus = SkypeToMirandaStatus(nStatus.as_string().c_str());
- if (iNewStatus == ID_STATUS_OFFLINE)
- {
+ if (iNewStatus == ID_STATUS_OFFLINE) {
debugLogA(__FUNCTION__ ": failed to change status");
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
index c9c12d6553..f603d9e2ec 100644
--- a/protocols/SkypeWeb/src/skype_menus.cpp
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -28,9 +28,7 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
return 0;
if (isChatRoom(hContact))
- {
return 0;
- }
bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
@@ -42,7 +40,6 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
Menu_ShowItem(ContactMenuItems[CMI_BLOCK], true);
Menu_ShowItem(ContactMenuItems[CMI_UNBLOCK], isCtrlPressed || isBlocked);
Menu_ShowItem(ContactMenuItems[CMI_GETSERVERHISTORY], true);
-
return 0;
}
@@ -93,7 +90,7 @@ void CSkypeProto::InitMenus()
mi.name.w = LPGENW("Block contact");
mi.position = CMI_POSITION + CMI_BLOCK;
mi.hIcolibItem = GetIconHandle(IDI_BLOCKUSER);
- SET_UID(mi ,0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32);
+ SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32);
ContactMenuItems[CMI_BLOCK] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockContact>);
@@ -118,4 +115,4 @@ int CSkypeProto::OnInitStatusMenu()
mi.hIcolibItem = GetIconHandle(IDI_CONFERENCE);
Menu_AddProtoMenuItem(&mi, m_szModuleName);
return 0;
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 62beabe57d..25cdb67cf9 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* MESSAGE RECEIVING */
// incoming message flow
-int CSkypeProto::OnReceiveMessage(MCONTACT hContact, const char *szContent, const char *szMessageId, time_t timestamp, int emoteOffset, bool isRead)
+int CSkypeProto::OnReceiveMessage(MCONTACT hContact, const char *szContent, const char *szMessageId, time_t timestamp, int emoteOffset, bool isRead)
{
PROTORECVEVENT recv = { 0 };
recv.timestamp = timestamp;
@@ -45,8 +45,7 @@ struct SendMessageParam
// outcoming message flow
int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
{
- if (!IsOnline())
- {
+ if (!IsOnline()) {
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)Translate("You cannot send when you are offline."));
return 0;
}
@@ -76,17 +75,12 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
HANDLE hMessage = (HANDLE)param->hMessage;
delete param;
- if (response != NULL)
- {
- if (response->resultCode == 201)
- {
- if (m_OutMessages.getIndex(hMessage) != -1)
- {
- if (response->pData != NULL)
- {
+ if (response != NULL) {
+ if (response->resultCode == 201) {
+ if (m_OutMessages.getIndex(hMessage) != -1) {
+ if (response->pData != NULL) {
JSONNode jRoot = JSONNode::parse(response->pData);
- if (m_mpOutMessages.find(hMessage) == m_mpOutMessages.end())
- {
+ if (m_mpOutMessages.find(hMessage) == m_mpOutMessages.end()) {
m_mpOutMessages[hMessage] = std::stoull(jRoot["OriginalArrivalTime"].as_string()) / 1000;
}
}
@@ -97,17 +91,14 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
}
}
}
- else
- {
+ else {
std::string strError = Translate("Unknown error!");
- if (response->pData != NULL)
- {
+ if (response->pData != NULL) {
JSONNode jRoot = JSONNode::parse(response->pData);
const JSONNode &jErr = jRoot["errorCode"];
- if(jErr)
- {
+ if (jErr) {
strError = jErr.as_string();
}
}
@@ -115,8 +106,7 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, hMessage, (LPARAM)strError.c_str());
}
}
- else
- {
+ else {
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, hMessage, (LPARAM)(Translate("Network error!")));
}
}
@@ -129,8 +119,7 @@ int CSkypeProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
return 0;
char *message = (char*)evt->dbei->pBlob;
- if (strncmp(message, "/me ", 4) == 0)
- {
+ if (strncmp(message, "/me ", 4) == 0) {
evt->dbei->cbBlob = evt->dbei->cbBlob - 4;
memmove(evt->dbei->pBlob, &evt->dbei->pBlob[4], evt->dbei->cbBlob);
evt->dbei->eventType = SKYPE_DB_EVENT_TYPE_ACTION;
@@ -142,8 +131,7 @@ int CSkypeProto::OnPreCreateMessage(WPARAM, LPARAM lParam)
evt->dbei->cbBlob += messageId.GetLength();
auto it = m_mpOutMessages.find((HANDLE)evt->seq);
- if (it != m_mpOutMessages.end())
- {
+ if (it != m_mpOutMessages.end()) {
evt->dbei->timestamp = it->second;
m_mpOutMessages.erase(it);
}
@@ -164,7 +152,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
ptrA szClearedContent(strMessageType == "RichText" ? RemoveHtml(strContent.c_str()) : mir_strdup(strContent.c_str()));
bool bEdited = node["skypeeditedid"];
- time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());
+ time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str());
int nEmoteOffset = atoi(node["skypeemoteoffset"].as_string().c_str());
@@ -173,24 +161,18 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
if (m_bHistorySynced)
db_set_dw(hContact, m_szModuleName, "LastMsgTime", (DWORD)timestamp);
- if (strMessageType == "Control/Typing")
- {
+ if (strMessageType == "Control/Typing") {
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_INFINITE);
}
- else if (strMessageType == "Control/ClearTyping")
- {
+ else if (strMessageType == "Control/ClearTyping") {
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
}
- else if (strMessageType == "Text" || strMessageType == "RichText")
- {
- if (IsMe(szFromSkypename))
- {
+ else if (strMessageType == "Text" || strMessageType == "RichText") {
+ if (IsMe(szFromSkypename)) {
HANDLE hMessage = (HANDLE)(std::stoull(szMessageId.GetString()));
- if (m_OutMessages.getIndex(hMessage) != -1)
- {
+ if (m_OutMessages.getIndex(hMessage) != -1) {
auto it = m_mpOutMessages.find(hMessage);
- if (it == m_mpOutMessages.end())
- {
+ if (it == m_mpOutMessages.end()) {
m_mpOutMessages[hMessage] = timestamp;
}
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, hMessage, 0);
@@ -199,55 +181,44 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
m_OutMessages.remove(hMessage);
}
}
- else
- {
- AddDbEvent(nEmoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact,
+ else {
+ AddDbEvent(nEmoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact,
timestamp, DBEF_UTF | DBEF_SENT, &szClearedContent[nEmoteOffset], szMessageId);
}
}
- else
- {
+ else {
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
MEVENT hDbEvent = GetMessageFromDb(hContact, szMessageId);
- if (bEdited && hDbEvent != NULL)
- {
+ if (bEdited && hDbEvent != NULL) {
AppendDBEvent(hContact, hDbEvent, szClearedContent, szMessageId, timestamp);
}
- else
- {
+ else {
OnReceiveMessage(hContact, szClearedContent, szMessageId, timestamp, nEmoteOffset);
}
}
}
- else if (strMessageType == "Event/Call")
- {
+ else if (strMessageType == "Event/Call") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
- else if (strMessageType == "RichText/Files")
- {
+ else if (strMessageType == "RichText/Files") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
- else if (strMessageType == "RichText/UriObject")
- {
+ else if (strMessageType == "RichText/UriObject") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
- else if (strMessageType == "RichText/Contacts")
- {
+ else if (strMessageType == "RichText/Contacts") {
ProcessContactRecv(hContact, timestamp, strContent.c_str(), szMessageId);
}
- else if (strMessageType == "RichText/Media_FlikMsg")
- {
+ else if (strMessageType == "RichText/Media_FlikMsg") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_MOJI, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
- else if (strMessageType == "RichText/Media_GenericFile")
- {
+ else if (strMessageType == "RichText/Media_GenericFile") {
AddDbEvent(SKYPE_DB_EVENT_TYPE_FILE, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
//else if (messageType == "Event/SkypeVideoMessage") {}
//else if (messageType.c_str() == "RichText/Location") {}
- else
- {
+ else {
AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
}
@@ -262,12 +233,12 @@ int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent)
void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
{
debugLogA(__FUNCTION__);
-
+
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
time_t timestamp = dbei.timestamp;
- if(db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300))
+ if (db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300))
PushRequest(new MarkMessageReadRequest(Contacts[hContact], timestamp, timestamp, false, li));
}
@@ -275,20 +246,17 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId)
{
HXML xmlNode = xmlParseString(mir_utf8decodeW(szContent), 0, L"contacts");
- if (xmlNode)
- {
+ if (xmlNode) {
int nCount = 0;
PROTOSEARCHRESULT **psr;
- for (int i = 0; i < xmlGetChildCount(xmlNode); i++) nCount++;
+ for (int i = 0; i < xmlGetChildCount(xmlNode); i++)
+ nCount++;
- if (psr = (PROTOSEARCHRESULT**)mir_calloc(sizeof(PROTOSEARCHRESULT*) * nCount))
- {
+ if (psr = (PROTOSEARCHRESULT**)mir_calloc(sizeof(PROTOSEARCHRESULT*) * nCount)) {
nCount = 0;
- for (int i = 0; i < xmlGetChildCount(xmlNode); i++)
- {
+ for (int i = 0; i < xmlGetChildCount(xmlNode); i++) {
HXML xmlContact = xmlGetNthChild(xmlNode, L"c", i);
- if (xmlContact != NULL)
- {
+ if (xmlContact != NULL) {
const wchar_t *tszContactId = xmlGetAttrValue(xmlContact, L"s");
//const wchar_t *tszContactName = xmlGetAttrValue(xmlContact, L"f");
@@ -300,8 +268,7 @@ void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const
nCount++;
}
}
- if (nCount)
- {
+ if (nCount) {
PROTORECVEVENT pre = { 0 };
pre.timestamp = (DWORD)timestamp;
pre.szMessage = (char*)psr;
@@ -316,8 +283,7 @@ void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const
pre.lParam = (LPARAM)b;
ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
- for (DWORD i = 0; i < *((PDWORD)b); i++)
- {
+ for (DWORD i = 0; i < *((PDWORD)b); i++) {
mir_free(psr[i]->id.w);
mir_free(psr[i]);
}
@@ -326,4 +292,4 @@ void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const
mir_free(psr);
}
}
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_mslogin.cpp b/protocols/SkypeWeb/src/skype_mslogin.cpp
index 9f8a7e0f26..c0bf3036b8 100644
--- a/protocols/SkypeWeb/src/skype_mslogin.cpp
+++ b/protocols/SkypeWeb/src/skype_mslogin.cpp
@@ -19,8 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -33,16 +32,14 @@ void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response)
regex = "<input type=\"hidden\" name=\"PPFT\" id=\"i0327\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
std::string PPTF = match[1];
-
- for (int i = 0; i < response->headersCount; i++)
- {
+
+ for (int i = 0; i < response->headersCount; i++) {
if (mir_strcmpi(response->headers[i].szName, "Set-Cookie"))
continue;
@@ -54,13 +51,12 @@ void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response)
CMStringA mscookies(FORMAT, "MSPRequ=%s;MSPOK=%s;CkTst=G%lld;", scookies["MSPRequ"].c_str(), scookies["MSPOK"].c_str(), time(NULL));
- SendRequest (new LoginMSRequest(ptrA(getStringA(SKYPE_SETTINGS_ID)), ptrA(getStringA(SKYPE_SETTINGS_PASSWORD)), mscookies.c_str(), PPTF.c_str()), &CSkypeProto::OnMSLoginSecond);
+ SendRequest(new LoginMSRequest(ptrA(getStringA(SKYPE_SETTINGS_ID)), ptrA(getStringA(SKYPE_SETTINGS_PASSWORD)), mscookies.c_str(), PPTF.c_str()), &CSkypeProto::OnMSLoginSecond);
}
void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -72,13 +68,10 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response)
ptrA szContent(response->pData);
regex = "<meta name=\"PageID\" content=\"(.+?)\"/>";
- if (std::regex_search(content, match, regex))
- {
- if (match[1] == "i5600")
- {
+ if (std::regex_search(content, match, regex)) {
+ if (match[1] == "i5600") {
CMStringA szCookies;
- for (int i = 0; i < response->headersCount; i++)
- {
+ for (int i = 0; i < response->headersCount; i++) {
if (mir_strcmpi(response->headers[i].szName, "Set-Cookie"))
continue;
@@ -91,7 +84,7 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response)
CMStringA url(GetStringChunk(szContent, "urlPost:'", "'"));
CMStringA ppft(GetStringChunk(szContent, "sFT:'", "'"));
-
+
ptrA code(mir_utf8encodeW(RunConfirmationCode()));
@@ -100,11 +93,8 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response)
}
}
-
regex = "<input type=\"hidden\" name=\"t\" id=\"t\" value=\"(.+?)\">";
-
- if (!std::regex_search(content, match, regex))
- {
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -116,8 +106,7 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -129,8 +118,7 @@ void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response)
regex = "<input type=\"hidden\" name=\"t\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -142,8 +130,7 @@ void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnMSLoginEnd(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -153,19 +140,17 @@ void CSkypeProto::OnMSLoginEnd(const NETLIBHTTPREQUEST *response)
std::smatch match;
std::string content = response->pData;
- regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
std::string token = match[1];
- setString("TokenSecret", token.c_str());
- regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
+ setString("TokenSecret", token.c_str());
+ regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
- if (std::regex_search(content, match, regex))
- {
+ if (std::regex_search(content, match, regex)) {
std::string expiresIn = match[1];
int seconds = atoi(expiresIn.c_str());
setDword("TokenExpiresIn", time(NULL) + seconds);
@@ -183,4 +168,4 @@ CMStringW CSkypeProto::RunConfirmationCode()
pForm.ptszInitVal = NULL;
pForm.szModuleName = m_szModuleName;
return (!EnterString(&pForm)) ? CMStringW() : CMStringW(ptrW(pForm.ptszResult));
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_oauth.cpp b/protocols/SkypeWeb/src/skype_oauth.cpp
index f09a5674bb..17d6455a82 100644
--- a/protocols/SkypeWeb/src/skype_oauth.cpp
+++ b/protocols/SkypeWeb/src/skype_oauth.cpp
@@ -19,8 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void CSkypeProto::OnOAuthStart(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -33,16 +32,14 @@ void CSkypeProto::OnOAuthStart(const NETLIBHTTPREQUEST *response)
regex = "<input type=\"hidden\" name=\"PPFT\" id=\"i0327\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
std::string PPTF = match[1];
-
- for (int i = 0; i < response->headersCount; i++)
- {
+
+ for (int i = 0; i < response->headersCount; i++) {
if (mir_strcmpi(response->headers[i].szName, "Set-Cookie"))
continue;
@@ -61,8 +58,7 @@ void CSkypeProto::OnOAuthStart(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnOAuthAuthorize(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -73,8 +69,7 @@ void CSkypeProto::OnOAuthAuthorize(const NETLIBHTTPREQUEST *response)
std::string content = response->pData;
regex = "<input type=\"hidden\" name=\"t\" id=\"t\" value=\"(.+?)\">";
- if (!std::regex_search(content, match, regex))
- {
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -86,8 +81,7 @@ void CSkypeProto::OnOAuthAuthorize(const NETLIBHTTPREQUEST *response)
void CSkypeProto::OnOAuthEnd(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
@@ -97,23 +91,21 @@ void CSkypeProto::OnOAuthEnd(const NETLIBHTTPREQUEST *response)
std::smatch match;
std::string content = response->pData;
- regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
+ if (!std::regex_search(content, match, regex)) {
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN);
SetStatus(ID_STATUS_OFFLINE);
return;
}
std::string token = match[1];
- setString("TokenSecret", token.c_str());
- regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
+ setString("TokenSecret", token.c_str());
+ regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
- if (std::regex_search(content, match, regex))
- {
+ if (std::regex_search(content, match, regex)) {
std::string expiresIn = match[1];
int seconds = atoi(expiresIn.c_str());
setDword("TokenExpiresIn", time(NULL) + seconds);
}
OnLoginSuccess();
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_options.cpp b/protocols/SkypeWeb/src/skype_options.cpp
index a754ca76b2..6dbb16d822 100644
--- a/protocols/SkypeWeb/src/skype_options.cpp
+++ b/protocols/SkypeWeb/src/skype_options.cpp
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
CSkypeOptionsMain::CSkypeOptionsMain(CSkypeProto *proto, int idDialog)
-: CSkypeDlgBase(proto, idDialog, false),
+ : CSkypeDlgBase(proto, idDialog, false),
m_skypename(this, IDC_SKYPENAME),
m_password(this, IDC_PASSWORD),
m_group(this, IDC_GROUP),
@@ -53,10 +53,10 @@ void CSkypeOptionsMain::OnInitDialog()
void CSkypeOptionsMain::OnApply()
{
- ptrA szNewSkypename(m_skypename.GetTextA()),
- szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID));
+ ptrA szNewSkypename(m_skypename.GetTextA()),
+ szOldSkypename(m_proto->getStringA(SKYPE_SETTINGS_ID));
pass_ptrA szNewPassword(m_password.GetTextA()),
- szOldPassword(m_proto->getStringA("Password"));
+ szOldPassword(m_proto->getStringA("Password"));
if (mir_strcmpi(szNewSkypename, szOldSkypename) || mir_strcmp(szNewPassword, szOldPassword))
m_proto->delSetting("TokenExpiresIn");
m_proto->setString(SKYPE_SETTINGS_ID, szNewSkypename);
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 459e45ebe8..1439d9f00f 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -22,56 +22,45 @@ void CSkypeProto::PollingThread(void*)
debugLogA(__FUNCTION__ ": entering");
int nErrors = 0;
- while (!m_bThreadsTerminated)
- {
+ while (!m_bThreadsTerminated) {
m_hPollingEvent.Wait();
nErrors = 0;
PollRequest *request = new PollRequest(li);
- while ((nErrors < POLLING_ERRORS_LIMIT) && m_iStatus != ID_STATUS_OFFLINE)
- {
+ while ((nErrors < POLLING_ERRORS_LIMIT) && m_iStatus != ID_STATUS_OFFLINE) {
request->nlc = m_pollingConnection;
NLHR_PTR response(request->Send(m_hNetlibUser));
- if (response == NULL)
- {
+ if (response == NULL) {
nErrors++;
m_pollingConnection = nullptr;
continue;
}
- if (response->resultCode == 200)
- {
+ if (response->resultCode == 200) {
nErrors = 0;
- if (response->pData)
- {
+ if (response->pData) {
char *pData = mir_strdup(response->pData);
- if (pData != NULL)
- {
+ if (pData != NULL) {
ForkThread(&CSkypeProto::ParsePollData, pData);
}
- else
- {
+ else {
debugLogA(__FUNCTION__ ": memory overflow !!!");
break;
}
}
}
- else
- {
+ else {
nErrors++;
- if (response->pData)
- {
+ if (response->pData) {
JSONNode root = JSONNode::parse(response->pData);
const JSONNode &error = root["errorCode"];
- if (error != NULL)
- {
+ if (error != NULL) {
int errorCode = error.as_int();
- if (errorCode == 729)
- {
+ if (errorCode == 729) {
break;
}
}
@@ -81,8 +70,7 @@ void CSkypeProto::PollingThread(void*)
}
delete request;
- if (m_iStatus != ID_STATUS_OFFLINE)
- {
+ if (m_iStatus != ID_STATUS_OFFLINE) {
debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
SetStatus(ID_STATUS_OFFLINE);
}
@@ -104,31 +92,25 @@ void CSkypeProto::ParsePollData(void *pData)
const JSONNode &node = data["eventMessages"];
if (!node) return;
- for (auto it = node.begin(); it != node.end(); ++it)
- {
+ for (auto it = node.begin(); it != node.end(); ++it) {
const JSONNode &message = *it;
const JSONNode &resType = message["resourceType"];
const JSONNode &resource = message["resource"];
std::string resourceType = resType.as_string();
- if (resourceType == "NewMessage")
- {
+ if (resourceType == "NewMessage") {
ProcessNewMessage(resource);
}
- else if (resourceType == "UserPresence")
- {
+ else if (resourceType == "UserPresence") {
ProcessUserPresence(resource);
}
- else if (resourceType == "EndpointPresence")
- {
+ else if (resourceType == "EndpointPresence") {
ProcessEndpointPresence(resource);
}
- else if (resourceType == "ConversationUpdate")
- {
+ else if (resourceType == "ConversationUpdate") {
ProcessConversationUpdate(resource);
}
- else if (resourceType == "ThreadUpdate")
- {
+ else if (resourceType == "ThreadUpdate") {
ProcessThreadUpdate(resource);
}
}
@@ -147,14 +129,12 @@ void CSkypeProto::ProcessEndpointPresence(const JSONNode &node)
const JSONNode &publicInfo = node["publicInfo"];
const JSONNode &privateInfo = node["privateInfo"];
CMStringA MirVer;
- if (publicInfo)
- {
+ if (publicInfo) {
std::string skypeNameVersion = publicInfo["skypeNameVersion"].as_string();
std::string version = publicInfo["version"].as_string();
std::string typ = publicInfo["typ"].as_string();
int iTyp = atoi(typ.c_str());
- switch (iTyp)
- {
+ switch (iTyp) {
case 0:
case 1:
MirVer.Append("Skype (Web) " + ParseUrl(version.c_str(), "/"));
@@ -187,14 +167,12 @@ void CSkypeProto::ProcessEndpointPresence(const JSONNode &node)
MirVer.AppendFormat("Miranda NG Skype %s", version.c_str());
break;
default:
- MirVer.Append("Skype (Unknown)");
+ MirVer.Append("Skype (Unknown)");
}
}
- if (privateInfo != NULL)
- {
+ if (privateInfo != NULL) {
std::string epname = privateInfo["epname"].as_string();
- if (!epname.empty())
- {
+ if (!epname.empty()) {
MirVer.AppendFormat(" [%s]", epname.c_str());
}
}
@@ -209,22 +187,17 @@ void CSkypeProto::ProcessUserPresence(const JSONNode &node)
std::string status = node["status"].as_string();
CMStringA skypename = UrlToSkypename(selfLink.c_str());
- if (!skypename.IsEmpty())
- {
- if (IsMe(skypename))
- {
+ if (!skypename.IsEmpty()) {
+ if (IsMe(skypename)) {
int iNewStatus = SkypeToMirandaStatus(status.c_str());
if (iNewStatus == ID_STATUS_OFFLINE) return;
int old_status = m_iStatus;
m_iDesiredStatus = iNewStatus;
m_iStatus = iNewStatus;
if (old_status != iNewStatus)
- {
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus);
- }
}
- else
- {
+ else {
MCONTACT hContact = FindContact(skypename);
if (hContact != NULL)
SetContactStatus(hContact, SkypeToMirandaStatus(status.c_str()));
@@ -244,5 +217,5 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node)
OnChatEvent(node);
}
-void CSkypeProto::ProcessConversationUpdate(const JSONNode&){}
-void CSkypeProto::ProcessThreadUpdate(const JSONNode&){} \ No newline at end of file
+void CSkypeProto::ProcessConversationUpdate(const JSONNode&) {}
+void CSkypeProto::ProcessThreadUpdate(const JSONNode&) {} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_popups.cpp b/protocols/SkypeWeb/src/skype_popups.cpp
index d3ffa065b3..4babb8941c 100644
--- a/protocols/SkypeWeb/src/skype_popups.cpp
+++ b/protocols/SkypeWeb/src/skype_popups.cpp
@@ -42,9 +42,7 @@ void CSkypeProto::InitPopups()
void CSkypeProto::UninitPopups()
{
for (int i = 0; i < m_PopupClasses.getCount(); i++)
- {
Popup_UnregisterClass(m_PopupClasses[i]);
- }
}
void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *message, MCONTACT hContact, int type)
@@ -55,23 +53,18 @@ void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *messag
if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
CMStringA className(FORMAT, "%s_", m_szModuleName);
- switch (type)
- {
+ switch (type) {
case 1:
- {
- className.Append("Error");
- break;
- }
+ className.Append("Error");
+ break;
+
case SKYPE_DB_EVENT_TYPE_INCOMING_CALL:
- {
- className.Append("Call");
- break;
- }
+ className.Append("Call");
+ break;
+
default:
- {
- className.Append("Notification");
- break;
- }
+ className.Append("Notification");
+ break;
}
POPUPDATACLASS ppd = { sizeof(ppd) };
diff --git a/protocols/SkypeWeb/src/skype_profile.cpp b/protocols/SkypeWeb/src/skype_profile.cpp
index 6b4e4892e9..b2dc58160d 100644
--- a/protocols/SkypeWeb/src/skype_profile.cpp
+++ b/protocols/SkypeWeb/src/skype_profile.cpp
@@ -274,7 +274,7 @@ void CSkypeProto::UpdateProfileDisplayName(const JSONNode &root, MCONTACT hConta
else if (lastname)
setWString(hContact, "Nick", lastname);
else {
-
+
const JSONNode &node = root["displayname"];
CMStringW displayname((!node) ? root["username"].as_mstring() : node.as_mstring());
if (!displayname.IsEmpty() && displayname != "null")
@@ -296,16 +296,14 @@ void CSkypeProto::UpdateProfileGender(const JSONNode &root, MCONTACT hContact)
void CSkypeProto::UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact)
{
CMStringW birthday = root["birthday"].as_mstring();
- if (!birthday.IsEmpty() && birthday != "null")
- {
+ if (!birthday.IsEmpty() && birthday != "null") {
int d, m, y;
swscanf(birthday.GetBuffer(), L"%d-%d-%d", &y, &m, &d);
setWord(hContact, "BirthYear", y);
setByte(hContact, "BirthDay", d);
setByte(hContact, "BirthMonth", m);
}
- else
- {
+ else {
delSetting(hContact, "BirthYear");
delSetting(hContact, "BirthDay");
delSetting(hContact, "BirthMonth");
@@ -315,8 +313,7 @@ void CSkypeProto::UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact)
void CSkypeProto::UpdateProfileCountry(const JSONNode &root, MCONTACT hContact)
{
std::string isocode = root["country"].as_string();
- if (!isocode.empty() && isocode != "null")
- {
+ if (!isocode.empty() && isocode != "null") {
char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
setString(hContact, "Country", country);
}
@@ -371,11 +368,9 @@ void CSkypeProto::UpdateProfileAbout(const JSONNode &root, MCONTACT hContact)
void CSkypeProto::UpdateProfileEmails(const JSONNode &root, MCONTACT hContact)
{
const JSONNode &node = root["emails"];
- if (node)
- {
+ if (node) {
const JSONNode &items = node.as_array();
- for (size_t i = 0; i < min(items.size(), 3); i++)
- {
+ for (size_t i = 0; i < min(items.size(), 3); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
@@ -384,8 +379,7 @@ void CSkypeProto::UpdateProfileEmails(const JSONNode &root, MCONTACT hContact)
setWString(hContact, name, item.as_mstring());
}
}
- else
- {
+ else {
delSetting(hContact, "e-mail0");
delSetting(hContact, "e-mail1");
delSetting(hContact, "e-mail2");
@@ -431,8 +425,7 @@ void CSkypeProto::UpdateProfileXStatusMessage(const JSONNode &root, MCONTACT hCo
void CSkypeProto::UpdateProfileAvatar(const JSONNode &root, MCONTACT hContact)
{
CMStringW province = root["avatarUrl"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- {
+ if (!province.IsEmpty() && province != "null") {
SetAvatarUrl(hContact, province);
ReloadAvatarInfo(hContact);
}
@@ -460,8 +453,10 @@ void CSkypeProto::LoadProfile(const NETLIBHTTPREQUEST *response, void *arg)
return;
}
- if (username != li.szSkypename.get())
- li.szSkypename = mir_strdup(username.c_str());
+ if (li.szSkypename != username.c_str())
+ li.szMyname = username.c_str();
+ else
+ li.szMyname = li.szSkypename;
UpdateProfileFirstName(root, hContact);
UpdateProfileLastName(root, hContact);
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index fc9f9fea9a..36871f56d0 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -19,25 +19,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) :
PROTO<CSkypeProto>(protoName, userName),
- m_PopupClasses(1),
- m_InviteDialogs(1),
- m_GCCreateDialogs(1),
- m_OutMessages(3, PtrKeySortT),
- m_bThreadsTerminated(0),
- m_TrouterConnection(0),
- m_pollingConnection(0),
- m_opts(this),
- Contacts(this)
+ m_PopupClasses(1),
+ m_InviteDialogs(1),
+ m_GCCreateDialogs(1),
+ m_OutMessages(3, PtrKeySortT),
+ m_bThreadsTerminated(0),
+ m_TrouterConnection(0),
+ m_pollingConnection(0),
+ m_opts(this),
+ Contacts(this)
{
InitNetwork();
requestQueue = new RequestQueue(m_hNetlibUser);
CreateProtoService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
- CreateProtoService(PS_GETAVATARINFO, &CSkypeProto::SvcGetAvatarInfo);
- CreateProtoService(PS_GETAVATARCAPS, &CSkypeProto::SvcGetAvatarCaps);
- CreateProtoService(PS_GETMYAVATAR, &CSkypeProto::SvcGetMyAvatar);
- CreateProtoService(PS_SETMYAVATAR, &CSkypeProto::SvcSetMyAvatar);
+ CreateProtoService(PS_GETAVATARINFO, &CSkypeProto::SvcGetAvatarInfo);
+ CreateProtoService(PS_GETAVATARCAPS, &CSkypeProto::SvcGetAvatarCaps);
+ CreateProtoService(PS_GETMYAVATAR, &CSkypeProto::SvcGetMyAvatar);
+ CreateProtoService(PS_SETMYAVATAR, &CSkypeProto::SvcSetMyAvatar);
CreateProtoService("/IncomingCallCLE", &CSkypeProto::OnIncomingCallCLE);
CreateProtoService("/IncomingCallPP", &CSkypeProto::OnIncomingCallPP);
@@ -61,18 +61,16 @@ CSkypeProto::~CSkypeProto()
{
requestQueue->Stop();
delete requestQueue;
-
+
UnInitNetwork();
UninitPopups();
- if (m_hPollingThread)
- {
+ if (m_hPollingThread) {
TerminateThread(m_hPollingThread, NULL);
m_hPollingThread = NULL;
}
- if (m_hTrouterThread)
- {
+ if (m_hTrouterThread) {
TerminateThread(m_hTrouterThread, NULL);
m_hTrouterThread = NULL;
}
@@ -90,14 +88,13 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
m_hPollingEvent.Set();
m_hTrouterEvent.Set();
-
+
return 0;
}
DWORD_PTR CSkypeProto::GetCaps(int type, MCONTACT)
{
- switch (type)
- {
+ switch (type) {
case PFLAGNUM_1:
return PF1_IM | PF1_AUTHREQ | PF1_CHAT | PF1_BASICSEARCH | PF1_MODEMSG | PF1_FILE;
case PFLAGNUM_2:
@@ -122,20 +119,17 @@ int CSkypeProto::SetAwayMsg(int, const wchar_t *msg)
HANDLE CSkypeProto::GetAwayMsg(MCONTACT hContact)
{
- PushRequest(new GetProfileRequest(li, Contacts[hContact]), [this, hContact](const NETLIBHTTPREQUEST *response)
- {
+ PushRequest(new GetProfileRequest(li, Contacts[hContact]), [this, hContact](const NETLIBHTTPREQUEST *response) {
if (!response || !response->pData)
return;
JSONNode root = JSONNode::parse(response->pData);
- if (JSONNode &mood = root["mood"])
- {
+ if (JSONNode &mood = root["mood"]) {
CMStringW str = mood.as_mstring();
this->ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)str.c_str());
}
- else
- {
+ else {
this->ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
});
@@ -149,12 +143,12 @@ MCONTACT CSkypeProto::AddToList(int, PROTOSEARCHRESULT *psr)
if (psr->id.a == NULL)
return NULL;
MCONTACT hContact;
-
+
if (psr->flags & PSR_UNICODE)
hContact = AddContact(T2Utf(psr->id.w));
- else
+ else
hContact = AddContact(psr->id.a);
-
+
return hContact;
}
@@ -174,7 +168,7 @@ MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent)
return NULL;
DB_AUTH_BLOB blob(dbei.pBlob);
-
+
MCONTACT hContact = AddContact(blob.get_email());
return hContact;
}
@@ -232,8 +226,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
if (iNewStatus == m_iDesiredStatus)
return 0;
- switch (iNewStatus)
- {
+ switch (iNewStatus) {
case ID_STATUS_FREECHAT:
case ID_STATUS_ONTHEPHONE:
iNewStatus = ID_STATUS_ONLINE;
@@ -256,16 +249,14 @@ int CSkypeProto::SetStatus(int iNewStatus)
int old_status = m_iStatus;
m_iDesiredStatus = iNewStatus;
- if (iNewStatus == ID_STATUS_OFFLINE)
- {
- if (m_iStatus > ID_STATUS_CONNECTING + 1)
- {
+ if (iNewStatus == ID_STATUS_OFFLINE) {
+ if (m_iStatus > ID_STATUS_CONNECTING + 1) {
SendRequest(new DeleteEndpointRequest(li));
}
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
// logout
requestQueue->Stop();
-
+
CloseDialogs();
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, ID_STATUS_OFFLINE);
@@ -273,17 +264,14 @@ int CSkypeProto::SetStatus(int iNewStatus)
SetAllContactsStatus(ID_STATUS_OFFLINE);
return 0;
}
- else
- {
+ else {
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
- {
+ else {
SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus), li), &CSkypeProto::OnStatusChanged);
}
}
@@ -300,8 +288,7 @@ int CSkypeProto::UserIsTyping(MCONTACT hContact, int type)
int CSkypeProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam)
{
- switch (iEventType)
- {
+ switch (iEventType) {
case EV_PROTO_ONLOAD:
return OnAccountLoaded(wParam, lParam);
@@ -336,8 +323,7 @@ int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
pBlob = (PBYTE)mir_calloc(cbBlob);
- for (i = 0, pCurBlob = pBlob; i < nCount; i++)
- {
+ for (i = 0, pCurBlob = pBlob; i < nCount; i++) {
//mir_strcpy((char*)pCurBlob, _T2A(isrList[i]->nick.w));
pCurBlob += mir_strlen((PCHAR)pCurBlob) + 1;
@@ -352,4 +338,4 @@ int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
mir_free(pBlob);
return 0;
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index b1a006fc19..079ee35d09 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -381,8 +381,8 @@ private:
{ return (m_iStatus > ID_STATUS_OFFLINE);
}
- __forceinline bool IsMe(const char *szSkypename)
- { return (!mir_strcmpi(szSkypename, li.szSkypename) || !mir_strcmp(szSkypename, ptrA(getStringA("SelfEndpointName"))));
+ __forceinline bool IsMe(const char *str)
+ { return (!mir_strcmpi(str, li.szMyname) || !mir_strcmp(str, ptrA(getStringA("SelfEndpointName"))));
}
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob);
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp
index 37c3805244..55f6e2ba7c 100644
--- a/protocols/SkypeWeb/src/skype_search.cpp
+++ b/protocols/SkypeWeb/src/skype_search.cpp
@@ -26,8 +26,7 @@ HANDLE CSkypeProto::SearchBasic(const wchar_t* id)
void CSkypeProto::SearchBasicThread(void* id)
{
debugLogA("CSkypeProto::OnSearchBasicThread");
- if (IsOnline())
- {
+ if (IsOnline()) {
ptrA szString(mir_urlEncode(T2Utf((wchar_t*)id)));
SendRequest(new GetSearchRequest(szString, li), &CSkypeProto::OnSearch);
}
@@ -54,8 +53,7 @@ void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response)
}
const JSONNode &items = root["results"].as_array();
- for (auto it = items.begin(); it != items.end(); ++it)
- {
+ for (auto it = items.begin(); it != items.end(); ++it) {
const JSONNode &item = (*it)["nodeProfileData"];
std::string skypeId = item["skypeId"].as_string();
@@ -67,6 +65,6 @@ void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response)
psr.nick.a = const_cast<char*>(name.c_str());
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
}
-
+
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_timers.cpp b/protocols/SkypeWeb/src/skype_timers.cpp
index 6d30fcbb94..30ac71e60f 100644
--- a/protocols/SkypeWeb/src/skype_timers.cpp
+++ b/protocols/SkypeWeb/src/skype_timers.cpp
@@ -22,12 +22,9 @@ mir_cs CSkypeProto::accountsLock;
void CSkypeProto::ProcessTimer()
{
- if (IsOnline())
- {
+ if (IsOnline()) {
PushRequest(new GetContactListRequest(li, NULL), &CSkypeProto::LoadContactList);
SendPresence(false);
- //if (!m_hTrouterThread)
- // SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter);
}
}
@@ -35,9 +32,7 @@ void CALLBACK CSkypeProto::TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
mir_cslock lck(accountsLock);
for (int i = 0; i < Accounts.getCount(); i++)
- {
Accounts[i]->ProcessTimer();
- }
}
void CSkypeProto::SkypeSetTimer()
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index 6b0f7b8ad4..1fee70ed46 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -82,8 +82,7 @@ LBL_Error:
void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response)
{
- if (response == NULL || response->pData == NULL)
- {
+ if (response == NULL || response->pData == NULL) {
debugLogA("Failed to establish a TRouter connection.");
return;
}
@@ -92,12 +91,11 @@ void CSkypeProto::OnGetTrouter(const NETLIBHTTPREQUEST *response)
int iStart = 0;
CMStringA szToken = data.Tokenize(":", iStart).Trim();
TRouter.sessId = szToken.GetString();
-
+
m_hTrouterEvent.Set();
m_hTrouterHealthEvent.Set();
- if ((time(NULL) - TRouter.lastRegistrationTime) >= 3600)
- {
+ if ((time(NULL) - TRouter.lastRegistrationTime) >= 3600) {
SendRequest(new RegisterTrouterRequest(li, TRouter.url.c_str(), TRouter.sessId.c_str()));
TRouter.lastRegistrationTime = time(NULL);
}
@@ -122,35 +120,29 @@ void CSkypeProto::TRouterThread(void*)
int errors = 0;
- while (!m_bThreadsTerminated)
- {
+ while (!m_bThreadsTerminated) {
m_hTrouterEvent.Wait();
errors = 0;
TrouterPollRequest *request = new TrouterPollRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid, TRouter.sessId);
- while (errors < POLLING_ERRORS_LIMIT && m_iStatus > ID_STATUS_OFFLINE)
- {
+ while (errors < POLLING_ERRORS_LIMIT && m_iStatus > ID_STATUS_OFFLINE) {
request->nlc = m_TrouterConnection;
NLHR_PTR response(request->Send(m_hNetlibUser));
-
- if (response == NULL)
- {
+
+ if (response == NULL) {
m_TrouterConnection = nullptr;
errors++;
continue;
}
- if (response->resultCode == 200)
- {
+ if (response->resultCode == 200) {
errors = 0;
- if (response->pData)
- {
+ if (response->pData) {
char *json = strstr(response->pData, "{");
- if (json != NULL)
- {
+ if (json != NULL) {
JSONNode root = JSONNode::parse(json);
std::string szBody = root["body"].as_string();
const JSONNode &headers = root["headers"];
@@ -159,8 +151,7 @@ void CSkypeProto::TRouterThread(void*)
}
}
}
- else
- {
+ else {
errors++;
SendRequest(new HealthTrouterRequest(TRouter.ccid.c_str()), &CSkypeProto::OnHealth);
@@ -170,8 +161,7 @@ void CSkypeProto::TRouterThread(void*)
}
delete request;
- if (m_iStatus != ID_STATUS_OFFLINE)
- {
+ if (m_iStatus != ID_STATUS_OFFLINE) {
debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
SetStatus(ID_STATUS_OFFLINE);
}
@@ -189,13 +179,11 @@ void CSkypeProto::OnTrouterEvent(const JSONNode &body, const JSONNode &)
std::string gp = body["gp"].as_string();
int evt = body["evt"].as_int();
- switch (evt)
- {
+ switch (evt) {
case 100: //incoming call
{
std::string callId = body["convoCallId"].as_string();
- if (!uid.empty())
- {
+ if (!uid.empty()) {
MCONTACT hContact = AddContact(uid.c_str(), true);
MEVENT hEvent = AddDbEvent(SKYPE_DB_EVENT_TYPE_INCOMING_CALL, hContact, time(NULL), DBEF_READ, gp.c_str(), callId.c_str());
@@ -247,4 +235,4 @@ INT_PTR CSkypeProto::OnIncomingCallPP(WPARAM wParam, LPARAM hContact)
NotifyEventHooks(g_hCallEvent, (WPARAM)hContact, (LPARAM)0);
return 0;
-} \ No newline at end of file
+}
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 3f91e7242f..a88f281e6c 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -347,10 +347,8 @@ char *CSkypeProto::RemoveHtml(const char *text)
std::string new_string = "";
std::string data = text;
- for (std::string::size_type i = 0; i < data.length(); i++)
- {
- if (data.at(i) == '<')
- {
+ for (std::string::size_type i = 0; i < data.length(); i++) {
+ if (data.at(i) == '<') {
i = data.find(">", i);
if (i == std::string::npos)
break;
@@ -358,71 +356,57 @@ char *CSkypeProto::RemoveHtml(const char *text)
continue;
}
- if (data.at(i) == '&')
- {
+ if (data.at(i) == '&') {
std::string::size_type begin = i;
i = data.find(";", i);
- if (i == std::string::npos)
- {
+ if (i == std::string::npos) {
i = begin;
}
else {
std::string entity = data.substr(begin + 1, i - begin - 1);
bool found = false;
- if (entity.length() > 1 && entity.at(0) == '#')
- {
+ if (entity.length() > 1 && entity.at(0) == '#') {
// Numeric replacement
bool hex = false;
- if (entity.at(1) == 'x')
- {
+ if (entity.at(1) == 'x') {
hex = true;
entity = entity.substr(2);
}
- else
- {
+ else {
entity = entity.substr(1);
}
- if (!entity.empty())
- {
+ if (!entity.empty()) {
found = true;
errno = 0;
unsigned long value = strtoul(entity.c_str(), NULL, hex ? 16 : 10);
- if (errno != 0)
- { // error with conversion in strtoul, ignore the result
+ if (errno != 0) { // error with conversion in strtoul, ignore the result
found = false;
}
- else if (value <= 127)
- { // U+0000 .. U+007F
+ else if (value <= 127) { // U+0000 .. U+007F
new_string += (char)value;
}
- else if (value >= 128 && value <= 2047)
- { // U+0080 .. U+07FF
+ else if (value >= 128 && value <= 2047) { // U+0080 .. U+07FF
new_string += (char)(192 + (value / 64));
new_string += (char)(128 + (value % 64));
}
- else if (value >= 2048 && value <= 65535)
- { // U+0800 .. U+FFFF
+ else if (value >= 2048 && value <= 65535) { // U+0800 .. U+FFFF
new_string += (char)(224 + (value / 4096));
new_string += (char)(128 + ((value / 64) % 64));
new_string += (char)(128 + (value % 64));
}
- else
- {
+ else {
new_string += (char)((value >> 24) & 0xFF);
new_string += (char)((value >> 16) & 0xFF);
new_string += (char)((value >> 8) & 0xFF);
- new_string += (char)((value)& 0xFF);
+ new_string += (char)((value) & 0xFF);
}
}
}
- else
- {
+ else {
// Keyword replacement
- for (int j = 0; j < _countof(htmlEntities); j++)
- {
- if (!mir_strcmpi(entity.c_str(), htmlEntities[j].entity))
- {
+ for (int j = 0; j < _countof(htmlEntities); j++) {
+ if (!mir_strcmpi(entity.c_str(), htmlEntities[j].entity)) {
new_string += htmlEntities[j].symbol;
found = true;
break;
@@ -445,8 +429,7 @@ char *CSkypeProto::RemoveHtml(const char *text)
const char *CSkypeProto::MirandaToSkypeStatus(int status)
{
- switch (status)
- {
+ switch (status) {
case ID_STATUS_AWAY:
return "Away";
@@ -490,7 +473,7 @@ CMStringA CSkypeProto::ParseUrl(const char *url, const char *token)
const char *start = strstr(url, token);
if (start == NULL)
return CMStringA();
-
+
start = start + mir_strlen(token);
const char *end = strchr(start, '/');
if (end == NULL)
@@ -503,7 +486,7 @@ CMStringA CSkypeProto::GetStringChunk(const char *haystack, const char *start, c
const char *sstart = strstr(haystack, start);
if (sstart == NULL)
return CMStringA();
-
+
sstart = sstart + mir_strlen(start);
const char *send = strstr(sstart, end);
if (send == NULL)
@@ -559,13 +542,10 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam)
*(szSecondParam++) = 0;
// no command or message command
- if (!szCommand || (szCommand && !mir_wstrcmpi(szCommand, L"chat")))
- {
- if (szSecondParam)
- {
+ if (!szCommand || (szCommand && !mir_wstrcmpi(szCommand, L"chat"))) {
+ if (szSecondParam) {
wchar_t *szChatId = wcsstr(szSecondParam, L"id=");
- if (szChatId)
- {
+ if (szChatId) {
szChatId += 5;
StartChatRoom(szChatId, szChatId);
return 0;
@@ -575,18 +555,19 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam)
CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, NULL);
return 0;
}
- else if (!mir_wstrcmpi(szCommand, L"call"))
- {
+
+ if (!mir_wstrcmpi(szCommand, L"call")) {
MCONTACT hContact = AddContact(_T2A(szJid), true);
NotifyEventHooks(g_hCallEvent, (WPARAM)hContact, (LPARAM)0);
return 0;
}
- else if (!mir_wstrcmpi(szCommand, L"userinfo")){ return 0; }
- else if (!mir_wstrcmpi(szCommand, L"add"))
- {
+
+ if (!mir_wstrcmpi(szCommand, L"userinfo"))
+ return 0;
+
+ if (!mir_wstrcmpi(szCommand, L"add")) {
MCONTACT hContact = FindContact(_T2A(szJid));
- if (hContact == NULL)
- {
+ if (hContact == NULL) {
PROTOSEARCHRESULT psr = { 0 };
psr.cbSize = sizeof(psr);
psr.id.w = mir_wstrdup(szJid);
@@ -602,16 +583,16 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam)
}
return 0;
}
- if (!mir_wstrcmpi(szCommand, L"sendfile"))
- {
+
+ if (!mir_wstrcmpi(szCommand, L"sendfile")) {
MCONTACT hContact = AddContact(_T2A(szJid), true);
CallService(MS_FILE_SENDFILE, hContact, NULL);
return 1;
}
+
if (!mir_wstrcmpi(szCommand, L"voicemail"))
- {
return 1;
- }
+
return 1;
}
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h
index 5e53f526da..b5e39887e4 100644
--- a/protocols/SkypeWeb/src/stdafx.h
+++ b/protocols/SkypeWeb/src/stdafx.h
@@ -80,7 +80,7 @@ struct LoginInfo
ptrA szServer;
} endpoint;
- ptrA szSkypename;
+ CMStringA szSkypename, szMyname;
};
diff --git a/protocols/SkypeWeb/src/version.h b/protocols/SkypeWeb/src/version.h
index e1c640d7a3..70693f538f 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 2
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>