From c0df993c8f919be748f032ff6a695fc8ad5be056 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 12 Aug 2015 08:12:53 +0000 Subject: VKontakte: Code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@14922 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 12 +++++----- protocols/VKontakte/src/vk_chats.cpp | 20 ++++++++-------- protocols/VKontakte/src/vk_feed.cpp | 38 +++++++++++++++---------------- protocols/VKontakte/src/vk_history.cpp | 4 ++-- protocols/VKontakte/src/vk_messages.cpp | 6 ++--- protocols/VKontakte/src/vk_pollserver.cpp | 4 ++-- protocols/VKontakte/src/vk_proto.cpp | 2 +- protocols/VKontakte/src/vk_search.cpp | 2 +- protocols/VKontakte/src/vk_status.cpp | 2 +- protocols/VKontakte/src/vk_thread.cpp | 6 ++--- 10 files changed, 48 insertions(+), 48 deletions(-) diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index e9ef416b76..281447f3f5 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -846,7 +846,7 @@ CMString CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC) CMString tszLink, tszPreviewLink; for (int i = 0; i < _countof(szImageTypes); i++) { const JSONNode &n = jnPhoto[szImageTypes[i]]; - if (!n.isnull()) { + if (n) { tszLink = n.as_mstring(); break; } @@ -1029,7 +1029,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport tszText.IsEmpty() ? _T(" ") : tszText); const JSONNode &jnSubAttachments = jnWall["attachments"]; - if (!jnSubAttachments.isnull()) { + if (jnSubAttachments) { debugLogA("CVkProto::GetAttachmentDescr SubAttachments"); CMString tszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC); tszAttachmentDescr.Replace(_T("\n"), _T("\n\t")); @@ -1050,7 +1050,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport CMString tszLink; for (int i = 0; i < _countof(szImageTypes); i++) { const JSONNode &n = jnSticker[szImageTypes[i]]; - if (!n.isnull()) { + if (n) { tszLink = n.as_mstring(); break; } @@ -1088,7 +1088,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport CMString tszLink; for (int i = 0; i < _countof(szGiftTypes); i++) { const JSONNode &n = jnGift[szGiftTypes[i]]; - if (!n.isnull()) { + if (n) { tszLink = n.as_mstring(); break; } @@ -1141,7 +1141,7 @@ CMString CVkProto::GetFwdMessages(const JSONNode &jnMessages, BBCSupport iBBC) CMString tszBody(jnMsg["body"].as_mstring()); const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; - if (!jnFwdMessages.isnull()) { + if (jnFwdMessages) { CMString tszFwdMessages = GetFwdMessages(jnFwdMessages, iBBC == bbcNo ? iBBC : m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszFwdMessages = _T("\n") + tszFwdMessages; @@ -1149,7 +1149,7 @@ CMString CVkProto::GetFwdMessages(const JSONNode &jnMessages, BBCSupport iBBC) } const JSONNode &jnAttachments = jnMsg["attachments"]; - if (!jnAttachments.isnull()) { + if (jnAttachments) { CMString tszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszAttachmentDescr = _T("\n") + tszAttachmentDescr; diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 1f2968364e..7817a89f87 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -44,7 +44,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg) CMString tszTitle; c = new CVkChatInfo(id); - if (!jnDlg.isnull()) { + if (jnDlg) { tszTitle = jnDlg["title"].as_mstring(); c->m_tszTopic = mir_tstrdup(!tszTitle.IsEmpty() ? tszTitle : _T("")); } @@ -140,8 +140,8 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe return; const JSONNode &jnInfo = jnResponse["info"]; - if (!jnInfo.isnull()) { - if (!jnInfo["title"].isnull()) + if (jnInfo) { + if (jnInfo["title"]) SetChatTitle(cc, jnInfo["title"].as_mstring()); if (jnInfo["left"].as_bool() || jnInfo["kicked"].as_bool()) { @@ -153,7 +153,7 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } const JSONNode &jnUsers = jnResponse["users"]; - if (!jnUsers.isnull()) { + if (jnUsers) { for (int i = 0; i < cc->m_users.getCount(); i++) cc->m_users[i].m_bDel = true; @@ -233,10 +233,10 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } const JSONNode &jnMsgs = jnResponse["msgs"]; - if (!jnMsgs.isnull()) { + if (jnMsgs) { const JSONNode &jnItems = jnMsgs["items"]; - if (!jnItems.isnull()) { + if (jnItems) { for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { const JSONNode &jnMsg = (*it); if (!jnMsg) @@ -294,7 +294,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory) CMString tszBody(jnMsg["body"].as_mstring()); const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; - if (!jnFwdMessages.isnull()) { + if (jnFwdMessages) { CMString tszFwdMessages = GetFwdMessages(jnFwdMessages, bbcNo); if (!tszBody.IsEmpty()) tszFwdMessages = _T("\n") + tszFwdMessages; @@ -302,14 +302,14 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory) } const JSONNode &jnAttachments = jnMsg["attachments"]; - if (!jnAttachments.isnull()) { + if (jnAttachments) { CMString tszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo); if (!tszBody.IsEmpty()) tszAttachmentDescr = _T("\n") + tszAttachmentDescr; tszBody += tszAttachmentDescr; } - if (!jnMsg["action"].isnull()) { + if (jnMsg["action"]) { bIsAction = true; CMString tszAction = jnMsg["action"].as_mstring(); @@ -386,7 +386,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, bool bIsHistory) tszBody.Replace(_T("%"), _T("%%")); if (cc->m_bHistoryRead) { - if (!jnMsg["title"].isnull()) + if (jnMsg["title"]) SetChatTitle(cc, jnMsg["title"].as_mstring()); AppendChatMessage(cc, uid, msgTime, tszBody, bIsHistory, bIsAction); } diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 10bb7ac6df..a9c0b9eea3 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -98,7 +98,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST &vkUsers, const JSONNod const JSONNode &jnProfiles = jnResponse["profiles"]; - if (!jnProfiles.isnull()) + if (jnProfiles) for (auto it = jnProfiles.begin(); it != jnProfiles.end(); ++it) { const JSONNode &jnProfile = (*it); if (!jnProfile["id"]) @@ -118,7 +118,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST &vkUsers, const JSONNod } const JSONNode &jnGroups = jnResponse["groups"]; - if (!jnGroups.isnull()) + if (jnGroups) for (auto it = jnGroups.begin(); it != jnGroups.end(); ++it) { const JSONNode &jnProfile = (*it); if (!jnProfile["id"]) @@ -142,7 +142,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszType == _T("photo_tag")) { bPostLink = false; const JSONNode &jnPhotos = jnItem["photo_tags"]; - if (!jnPhotos.isnull()) { + if (jnPhotos) { const JSONNode &jnPhotoItems = jnPhotos["items"]; - if (!jnPhotoItems.isnull()) { + if (jnPhotoItems) { tszText = TranslateT("User was tagged in these photos:"); for (auto it = jnPhotoItems.begin(); it != jnPhotoItems.end(); ++it) tszText += _T("\n") + GetVkPhotoItem((*it), m_iBBCForNews); @@ -172,14 +172,14 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszType == _T("wall_photo")) { - if (!jnPhotoItem["post_id"].isnull()) { + if (jnPhotoItem["post_id"]) { bPostLink = true; iPostId = jnPhotoItem["post_id"].as_int(); break; // max 1 wall_photo when photo post_id !=0 @@ -192,7 +192,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszType == _T("post") || vkNewsItem->tszType.IsEmpty()) { bPostLink = true; const JSONNode &jnRepost = jnItem["copy_history"]; - if (!jnRepost.isnull()) { + if (jnRepost) { CVKNewsItem *vkRepost = GetVkNewsItem((*jnRepost.begin()), vkUsers, true); vkRepost->tszText.Replace(_T("\n"), _T("\n\t")); tszText += vkRepost->tszText; @@ -202,7 +202,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST vkNews(5, sttCompareVKNewsItems); - if (!jnItems.isnull()) + if (jnItems) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { CVKNewsItem *vkNewsItem = GetVkNewsItem((*it), vkUsers); if (!vkNewsItem) @@ -679,10 +679,10 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR CreateVkUserInfoList(vkUsers, jnNotifications); CreateVkUserInfoList(vkUsers, jnGroupInvates); - if (!jnNotifications.isnull()) { + if (jnNotifications) { const JSONNode &jnItems = jnNotifications["items"]; - if (!jnItems.isnull()) + if (jnItems) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { CVKNewsItem *vkNotificationItem = GetVkNotificationsItem((*it), vkUsers); if (!vkNotificationItem) @@ -695,10 +695,10 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR } - if (!jnGroupInvates.isnull()) { + if (jnGroupInvates) { const JSONNode &jnItems = jnGroupInvates["items"]; - if (!jnItems.isnull()) + if (jnItems) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { CVKNewsItem *vkNotificationItem = GetVkGroupInvates((*it), vkUsers); if (!vkNotificationItem) diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 0a06ea9569..b06784d39b 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -198,7 +198,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque int uid = jnMsg["user_id"].as_int(); const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; - if (!jnFwdMessages.isnull()) { + if (jnFwdMessages) { CMString tszFwdMessages = GetFwdMessages(jnFwdMessages, m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszFwdMessages = _T("\n") + tszFwdMessages; @@ -206,7 +206,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque } const JSONNode &jnAttachments = jnMsg["attachments"]; - if (!jnAttachments.isnull()) { + if (jnAttachments) { CMString tszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszAttachmentDescr = _T("\n") + tszAttachmentDescr; diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 16a2219a29..089957ba06 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -89,7 +89,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) if (reply->resultCode == 200) { JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); - if (!jnResponse.isnull()) { + if (jnResponse) { UINT mid; if (jnResponse.type() != JSON_STRING) mid = jnResponse.as_int(); @@ -216,7 +216,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe int uid = jnMsg["user_id"].as_int(); const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; - if (!jnFwdMessages.isnull()) { + if (jnFwdMessages) { CMString tszFwdMessages = GetFwdMessages(jnFwdMessages, m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszFwdMessages = _T("\n") + tszFwdMessages; @@ -224,7 +224,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } const JSONNode &jnAttachments = jnMsg["attachments"]; - if (!jnAttachments.isnull()) { + if (jnAttachments) { CMString tszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_iBBCForAttachments); if (!tszBody.IsEmpty()) tszAttachmentDescr = _T("\n") + tszAttachmentDescr; diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index dd1b4d22db..3faa43723c 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -204,7 +204,7 @@ int CVkProto::PollServer() if (reply->resultCode == 200) { JSONNode jnRoot = JSONNode::parse(reply->pData); const JSONNode &jnFailed = jnRoot["failed"]; - if (!jnFailed.isnull() && jnFailed.as_int() > 1) { + if (jnFailed && jnFailed.as_int() > 1) { RetrievePollingInfo(); retVal = -1; debugLogA("Polling key expired, restarting polling thread"); @@ -214,7 +214,7 @@ int CVkProto::PollServer() itoa(jnRoot["ts"].as_int(), ts, 10); m_pollingTs = mir_strdup(ts); const JSONNode &jnUpdates = jnRoot["updates"]; - if (!jnUpdates.isnull()) + if (jnUpdates) PollUpdates(jnUpdates); retVal = 1; } diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 70facbed3f..e3c0a67379 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -526,7 +526,7 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * if (reply->resultCode == 200) { JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); - if (!jnResponse.isnull()) { + if (jnResponse) { int iRet = jnResponse.as_int(); setByte(param->hContact, "Auth", 0); if (iRet == 2) { diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp index 26df986df8..a2fab4a335 100644 --- a/protocols/VKontakte/src/vk_search.cpp +++ b/protocols/VKontakte/src/vk_search.cpp @@ -113,7 +113,7 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) return; } - const JSONNode &jnItems = jnResponse["items"].isnull() ? jnResponse : jnResponse["items"]; + const JSONNode &jnItems = !jnResponse["items"] ? jnResponse : jnResponse["items"]; for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { const JSONNode &jnRecord = (*it); if (!jnRecord) diff --git a/protocols/VKontakte/src/vk_status.cpp b/protocols/VKontakte/src/vk_status.cpp index d8299db63e..97e3e8d3bd 100644 --- a/protocols/VKontakte/src/vk_status.cpp +++ b/protocols/VKontakte/src/vk_status.cpp @@ -159,7 +159,7 @@ void CVkProto::OnReceiveStatus(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) return; const JSONNode &jnAudio = jnResponse["audio"]; - if (jnAudio.isnull()) { + if (!jnAudio) { CMString tszStatusText(jnResponse["text"].as_mstring()); if (tszStatusText[0] != TCHAR(9835)) setTString("OldStatusMsg", tszStatusText); diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index da38e090f2..48e20824d6 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -342,7 +342,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) CMString tszOldListeningTo(ptrT(db_get_tsa(hContact, m_szModuleName, "ListeningTo"))); const JSONNode &jnAudio = jnItem["status_audio"]; - if (!jnAudio.isnull()) { + if (jnAudio) { CMString tszListeningTo(FORMAT, _T("%s - %s"), jnAudio["artist"].as_mstring(), jnAudio["title"].as_mstring()); if (tszListeningTo != tszOldListeningTo) { setTString(hContact, "ListeningTo", tszListeningTo); @@ -534,7 +534,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq const JSONNode &jnItems = jnResponse["items"]; - if (!jnItems.isnull()) + if (jnItems) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { MCONTACT hContact = SetContactInfo((*it), true); @@ -598,7 +598,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest* if (reply->resultCode == 200) { JSONNode jnRoot; const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot); - if (!jnResponse.isnull()) { + if (jnResponse) { CMString tszNick(ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick"))); if (tszNick.IsEmpty()) tszNick = TranslateT("(Unknown contact)"); -- cgit v1.2.3