From 2eb921fdbae7be508cdd3e20c67760384d84348e Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 12 Aug 2015 06:28:26 +0000 Subject: VKontakte: update vk api version to 5.37 minor change for forward message formating code cleaning version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14921 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 12 +++++----- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_feed.cpp | 40 ++++++++++++++++----------------- protocols/VKontakte/src/vk_files.cpp | 2 +- protocols/VKontakte/src/vk_history.cpp | 2 +- protocols/VKontakte/src/vk_messages.cpp | 2 +- protocols/VKontakte/src/vk_options.cpp | 8 +++---- protocols/VKontakte/src/vk_proto.cpp | 6 +++-- protocols/VKontakte/src/vk_proto.h | 7 +++--- protocols/VKontakte/src/vk_queue.cpp | 6 ++--- protocols/VKontakte/src/vk_thread.cpp | 12 +++++----- 12 files changed, 53 insertions(+), 48 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 9952a2e950..e9ef416b76 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1058,7 +1058,7 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport res.AppendFormat(_T("%s"), tszLink); if (m_iIMGBBCSupport && iBBC != bbcNo) - res += SetBBCString(tszLink, iBBC, vkbbcImg); + res += SetBBCString(tszLink, iBBC, vkbbcImg); } } else if (tszType == _T("link")) { @@ -1069,13 +1069,13 @@ CMString CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport CMString tszUrl(jnLink["url"].as_mstring()); CMString tszTitle(jnLink["title"].as_mstring()); CMString tszDescription(jnLink["description"].as_mstring()); - CMString tszImage(jnLink["image_src"].as_mstring()); res.AppendFormat(_T("%s: %s"), SetBBCString(TranslateT("Link"), iBBC, vkbbcB), SetBBCString(tszTitle, iBBC, vkbbcUrl, tszUrl)); - if (!tszImage.IsEmpty()) - res.AppendFormat(_T("\n\t%s: %s"), TranslateT("Image"), SetBBCString(tszImage, m_iIMGBBCSupport ? iBBC : bbcNo, vkbbcImg)); + + if (!jnLink["photo"].isnull()) + res.AppendFormat(_T("\n\t%s"), GetVkPhotoItem(jnLink["photo"], iBBC)); if (!tszDescription.IsEmpty()) res.AppendFormat(_T("\n\t%s"), tszDescription); @@ -1158,9 +1158,11 @@ CMString CVkProto::GetFwdMessages(const JSONNode &jnMessages, BBCSupport iBBC) tszBody.Replace(_T("\n"), _T("\n\t")); CMString tszMes; - tszMes.AppendFormat(_T("%s %s %s %s:\n%s"), + TCHAR tcSplit = m_bSplitFormatFwdMsg ? '\n' : ' '; + tszMes.AppendFormat(_T("%s %s%c%s %s:\n\n%s\n"), SetBBCString(TranslateT("Message from"), iBBC, vkbbcB), SetBBCString(tszNick, iBBC, vkbbcUrl, tszUrl), + tcSplit, SetBBCString(TranslateT("at"), iBBC, vkbbcB), ttime, tszBody); diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 2765e7a603..87a4090093 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 1 -#define __BUILD_NUM 11 +#define __BUILD_NUM 12 #include diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index f19d71b582..f131ca8b35 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -67,7 +67,7 @@ along with this program. If not, see . #define VKERR_INVALID_FILENAME 301 // Invalid filename #define VKERR_INVALID_FILESIZE 302 // Invalid filesize -#define VK_API_VER "5.36" +#define VK_API_VER "5.37" #define VER_API CHAR_PARAM("v", VK_API_VER) #define VK_FEED_USER 2147483647L diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index e8c68db7a9..10bb7ac6df 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -103,7 +103,7 @@ void CVkProto::CreateVkUserInfoList(OBJLIST &vkUsers, const JSONNod const JSONNode &jnProfile = (*it); if (!jnProfile["id"]) continue; - LONG UserId = jnProfile["id"].as_int(); + LONG UserId = jnProfile["id"].as_int(); CMString tszNick(jnProfile["first_name"].as_mstring()); tszNick.AppendChar(' '); @@ -159,9 +159,9 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszType == _T("photo_tag")) { bPostLink = false; const JSONNode &jnPhotos = jnItem["photo_tags"]; - if (!jnPhotos.isnull()) { + if (!jnPhotos.isnull()) { const JSONNode &jnPhotoItems = jnPhotos["items"]; - if (!jnPhotoItems.isnull()) { + if (!jnPhotoItems.isnull()) { tszText = TranslateT("User was tagged in these photos:"); for (auto it = jnPhotoItems.begin(); it != jnPhotoItems.end(); ++it) tszText += _T("\n") + GetVkPhotoItem((*it), m_iBBCForNews); @@ -178,7 +178,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszType == _T("wall_photo")) { + if (i == 0 && vkNewsItem->tszType == _T("wall_photo")) { if (!jnPhotoItem["post_id"].isnull()) { bPostLink = true; iPostId = jnPhotoItem["post_id"].as_int(); @@ -209,7 +209,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLISTtszText.AppendFormat(_T("%s %s %s"), tszUsers, tszNotificationTranslate, tszGroupName); tszIds += tszId; - setTString("InviteGroupIds", tszIds); + setTString("InviteGroupIds", tszIds); - return vkNotification; + return vkNotification; } ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -540,7 +540,7 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime) } static int sttCompareVKNewsItems(const CVKNewsItem *p1, const CVKNewsItem *p2) -{ +{ int compareId = p1->tszId.Compare(p2->tszId); LONG compareUserId = p1->vkUser->m_UserId - p2->vkUser->m_UserId; LONG compareDate = (LONG)p1->tDate - (LONG)p2->tDate; @@ -588,7 +588,7 @@ void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *p vkNews.insert(vkNewsItem); } else - delete vkNewsItem; + delete vkNewsItem; } for (int i = 0; i < vkNews.getCount(); i++) @@ -620,7 +620,7 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime) Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveUnreadNotifications) << TCHAR_PARAM("code", code) - << VER_API); + << VER_API); setDword("LastNotificationsReqTime", (DWORD)time(NULL)); } @@ -700,11 +700,11 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR if (!jnItems.isnull()) for (auto it = jnItems.begin(); it != jnItems.end(); ++it) { - CVKNewsItem *vkNotificationItem = GetVkGroupInvates((*it), vkUsers); + CVKNewsItem *vkNotificationItem = GetVkGroupInvates((*it), vkUsers); if (!vkNotificationItem) - continue; + continue; if (vkNotification.find(vkNotificationItem) == NULL) - vkNotification.insert(vkNotificationItem); + vkNotification.insert(vkNotificationItem); else delete vkNotificationItem; } @@ -713,7 +713,7 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR bool bNotificationCommentAdded = false; bool bNotificationComment = false; for (int i = 0; i < vkNotification.getCount(); i++) - if (FilterNotification(&vkNotification[i], bNotificationComment)) { + if (FilterNotification(&vkNotification[i], bNotificationComment)) { AddFeedEvent(vkNotification[i].tszText, vkNotification[i].tDate); bNotificationCommentAdded = bNotificationComment || bNotificationCommentAdded; } diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index ce3e47326c..31f736a7be 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -297,7 +297,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) << VER_API; break; case CVkFileUploadParam::typeDoc: - upload = jnRoot["file"].as_mstring(); + upload = jnRoot["file"].as_mstring(); if (upload.IsEmpty()) { SendFileFiled(fup, _T("NotUpload Doc")); return; diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 20ea678ac1..0a06ea9569 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -186,7 +186,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque int mid = jnMsg["id"].as_int(); if (iLastMsgId < mid) - iLastMsgId = mid; + iLastMsgId = mid; char szMid[40]; _itoa(mid, szMid, 10); diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 182b0a18de..16a2219a29 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -94,7 +94,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) if (jnResponse.type() != JSON_STRING) mid = jnResponse.as_int(); else if (_stscanf(jnResponse.as_mstring(), _T("%d"), &mid) != 1) - mid = 0; + mid = 0; if (param->iMsgID != -1) m_sendIds.insert((HANDLE)mid); diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 1e3e44a21a..fbeb36b70e 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -384,7 +384,7 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar CheckDlgButton(hwndDlg, IDC_N_LIKES, ppro->m_bNotificationFilterLikes ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_N_REPOSTS, ppro->m_bNotificationFilterReposts ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_N_MENTIONS, ppro->m_bNotificationFilterMentions ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_N_INVITES, ppro->m_bNotificationFilterInvites ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_N_INVITES, ppro->m_bNotificationFilterInvites ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETRANGE, 0, MAKELONG(60*24, 1)); SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETPOS, 0, ppro->m_iNewsInterval); @@ -546,7 +546,7 @@ INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wPara CheckDlgButton(hwndDlg, IDC_ATTBBC_ADV, (ppro->m_iBBCForAttachments == bbcAdvanced) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOTEN_LINKS_FOR_AUDIO, ppro->m_bShortenLinksForAudio ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOTEN_LINKS_FOR_AUDIO, ppro->m_bShortenLinksForAudio ? BST_CHECKED : BST_UNCHECKED); return TRUE; @@ -572,7 +572,7 @@ INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wPara break; case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == PSN_APPLY) { + if (((LPNMHDR)lParam)->code == PSN_APPLY) { if (IsDlgButtonChecked(hwndDlg, IDC_IMG_OFF) == BST_CHECKED) ppro->m_iIMGBBCSupport = imgNo; if (IsDlgButtonChecked(hwndDlg, IDC_IMG_FULLSIZE) == BST_CHECKED) @@ -588,7 +588,7 @@ INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wPara if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_BASIC) == BST_CHECKED) ppro->m_iBBCForNews = bbcBasic; if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_ADV) == BST_CHECKED) - ppro->m_iBBCForNews = bbcAdvanced; + ppro->m_iBBCForNews = bbcAdvanced; ppro->setByte("BBCForNews", ppro->m_iBBCForNews); ppro->m_bUseBBCOnAttacmentsAsNews = IsDlgButtonChecked(hwndDlg, IDC_BBC_ATT_NEWS) == BST_CHECKED; diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 7ea79a813a..70facbed3f 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -119,6 +119,8 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_iInvisibleInterval = getDword("InvisibleInterval", 10); m_bShortenLinksForAudio = getBool("ShortenLinksForAudio", true); + + m_bSplitFormatFwdMsg = getBool("SplitFormatFwdMsg", true); m_bSetBroadcast = false; m_bNeedSendOnline = false; @@ -529,7 +531,7 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest * setByte(param->hContact, "Auth", 0); if (iRet == 2) { CMString msg, - tszNick = ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick")); + tszNick(ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick"))); if (tszNick.IsEmpty()) tszNick = TranslateT("(Unknown contact)"); msg.AppendFormat(TranslateT("User %s added as friend"), tszNick); @@ -579,7 +581,7 @@ int CVkProto::AuthDeny(MEVENT hDbEvent, const TCHAR*) } int CVkProto::UserIsTyping(MCONTACT hContact, int type) -{ +{ debugLogA("CVkProto::UserIsTyping"); if (PROTOTYPE_SELFTYPING_ON == type) { LONG userID = getDword(hContact, "ID", -1); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index b041ef89b9..38b7921016 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -353,7 +353,7 @@ struct CVkProto : public PROTO void AddFeedEvent(CMString& tszBody, time_t tTime); CVkUserInfo* GetVkUserInfo(LONG iUserId, OBJLIST &vkUsers); - void CreateVkUserInfoList(OBJLIST &vkUsers, const JSONNode &jnResponse); + void CreateVkUserInfoList(OBJLIST &vkUsers, const JSONNode &jnResponse); CVKNewsItem* GetVkNewsItem(const JSONNode &jnItem, OBJLIST &vkUsers, bool isRepost = false); @@ -384,7 +384,7 @@ struct CVkProto : public PROTO bool CheckMid(LIST &lList, int guid); - JSONNode& CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONNode &root); + JSONNode& CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONNode &root); bool CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &Node); void OnReceiveSmth(NETLIBHTTPREQUEST*, AsyncHttpRequest*); @@ -591,7 +591,8 @@ private: m_bUseBBCOnAttacmentsAsNews, m_bUseNonStandardUrlEncode, m_bSetBroadcast, - m_bShortenLinksForAudio; + m_bShortenLinksForAudio, + m_bSplitFormatFwdMsg; int m_iNewsInterval, m_iNotificationsInterval, diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 95493baed3..e553905e45 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -53,7 +53,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq) if (reply != NULL) { if (pReq->m_pFunc != NULL) (this->*(pReq->m_pFunc))(reply, pReq); // may be set pReq->bNeedsRestart - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)reply); } else if (pReq->bIsMainConn) { if (IsStatusConnecting(m_iStatus)) @@ -124,14 +124,14 @@ void CVkProto::WorkerThread(void*) Push(pReq); } - while (true) { + while (true) { WaitForSingleObject(m_evRequestsQueue, 1000); if (m_bTerminated) break; AsyncHttpRequest *pReq; bool need_sleep = false; - while (true) { + while (true) { { mir_cslock lck(m_csRequestsQueue); if (m_arRequestsQueue.getCount() == 0) diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 5ca562230d..da38e090f2 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -57,7 +57,7 @@ static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) vk_Instances[i]->debugLogA("Tic timer for %i - %s", i, vk_Instances[i]->m_szModuleName); vk_Instances[i]->SetServerStatus(vk_Instances[i]->m_iDesiredStatus); vk_Instances[i]->RetrieveUsersInfo(true); - vk_Instances[i]->RetrieveUnreadEvents(); + vk_Instances[i]->RetrieveUnreadEvents(); } } @@ -238,7 +238,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) RetrieveUserInfo(m_myUserId); RetrieveUnreadMessages(); RetrieveFriends(); - RetrievePollingInfo(); + RetrievePollingInfo(); } MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) @@ -343,7 +343,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()) { - CMString tszListeningTo(FORMAT, _T("%s - %s"), jnAudio["artist"].as_mstring(), jnAudio["title"].as_mstring()); + CMString tszListeningTo(FORMAT, _T("%s - %s"), jnAudio["artist"].as_mstring(), jnAudio["title"].as_mstring()); if (tszListeningTo != tszOldListeningTo) { setTString(hContact, "ListeningTo", tszListeningTo); setTString(hContact, "AudioUrl", jnAudio["url"].as_mstring()); @@ -491,8 +491,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe hContact = FindUser(userid, true); if (!getBool(hContact, "ReqAuth")) { RetrieveUserInfo(userid); - setByte(hContact, "ReqAuth", 1); - ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)hContact); + setByte(hContact, "ReqAuth", 1); + ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)hContact); } } } @@ -616,7 +616,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest* msg.AppendFormat(msgformat, tszNick); MsgPopup(param->hContact, msg, tszNick); - setByte(param->hContact, "Auth", 1); + setByte(param->hContact, "Auth", 1); } else { msg = TranslateT("User or request was not deleted"); -- cgit v1.2.3