From 46d6a43726d64a0d7f808ad55557bfc56b89f97d Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 13 Jul 2016 08:25:04 +0000 Subject: =?UTF-8?q?VKontakte:=20add=20=E2=80=98Send=20VK-objects=20links?= =?UTF-8?q?=20as=20attachments=E2=80=99=20option=20move=20=E2=80=98Use=20n?= =?UTF-8?q?on-standard=20popups=20for=20news=20and=20event=20notifications?= =?UTF-8?q?=E2=80=99=20option=20to=20View=20page=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@17090 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 40 +++++++++++++++++++++++++++++++++ protocols/VKontakte/src/resource.h | 3 ++- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_messages.cpp | 10 ++++++++- protocols/VKontakte/src/vk_options.cpp | 8 ++++--- protocols/VKontakte/src/vk_options.h | 3 ++- protocols/VKontakte/src/vk_proto.h | 1 + protocols/VKontakte/src/vk_struct.cpp | 1 + protocols/VKontakte/src/vk_struct.h | 1 + 9 files changed, 62 insertions(+), 7 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 1996ad9bdd..34ee94993d 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -21,6 +21,9 @@ static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", " static const char *szGiftTypes[] = { "thumb_256", "thumb_96", "thumb_48" }; +static const char *szVKUrls[] = { "http://vk.com/", "https://vk.com/", "http://new.vk.com/", "https://new.vk.com/", "http://m.vk.com/", "https://m.vk.com/" }; +static const char *szAttachmentMasks[] = { "wall%d_%d", "video%d_%d", "photo%d_%d", "audio%d_%d", "doc%d_%d", "market%d_%d" }; + JSONNode nullNode(JSON_NULL); bool IsEmpty(LPCTSTR str) @@ -733,6 +736,43 @@ char* CVkProto::GetStickerId(const char *Msg, int &stickerid) return retMsg; } +CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg) +{ + if (IsEmpty(Msg)) + return CMStringA(); + + const char *pos = NULL; + for (int i = 0; i < _countof(szVKUrls) && !pos; i++) { + pos = strstr(Msg, szVKUrls[i]); + if (pos) { + pos += mir_strlen(szVKUrls[i]); + break; + } + } + + if (!pos || pos >= (Msg + mir_strlen(Msg))) + return CMStringA(); + + int iRes = 0, + iOwner = 0, + iId = 0; + + for (int i = 0; i < _countof(szAttachmentMasks); i++) { + iRes = sscanf(pos, szAttachmentMasks[i], &iOwner, &iId); + if (iRes == 2) { + CMStringA szAttacment(FORMAT, szAttachmentMasks[i], iOwner, iId); + CMStringA szAttacment2 = GetAttachmentsFromMessage(pos + szAttacment.GetLength()); + if (!szAttacment2.IsEmpty()) + szAttacment += "," + szAttacment2; + return szAttacment; + } + else if (iRes == 1) + break; + } + + return GetAttachmentsFromMessage(pos); +} + int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index e5db19f100..a54c792242 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -124,6 +124,7 @@ #define IDC_COMBO_MARKASREAD 1108 #define IDC_COMBO_SYNCHISTORY 1109 #define IDC_N_FRIENDACCEPTED 1110 +#define IDC_SENDVKURLSASATTACH 1111 // Next default values for new objects // @@ -132,7 +133,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 123 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1111 +#define _APS_NEXT_CONTROL_VALUE 1112 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index e5c54ccf68..dfccb9463b 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 2 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index f5a6726bc0..02c84f8e78 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -62,8 +62,16 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) if (StickerId) pReq << INT_PARAM("sticker_id", StickerId); - else + else { pReq << CHAR_PARAM("message", szMsg); + if (m_vkOptions.bSendVKLinksAsAttachments) { + CMStringA szAttachments = GetAttachmentsFromMessage(szMsg); + if (!szAttachments.IsEmpty()) { + debugLogA("CVkProto::SendMsg Attachments = %s", szAttachments); + pReq << CHAR_PARAM("attachment", szAttachments); + } + } + } if (!bIsChat) pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId); diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 096599c20a..67a2bc45f2 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -226,7 +226,7 @@ CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto): m_cbForceInvisibleStatus(this, IDC_FORCE_ONLINE_ON_ACT), m_edtInvInterval(this, IDC_ED_INT_INVIS), m_spInvInterval(this, IDC_SPIN_INT_INVIS), - m_cbUseNonStandardNotifications(this, IDC_USENOSTDPOPUPS), + m_cbSendVKLinksAsAttachments(this, IDC_SENDVKURLSASATTACH), m_cbUseNonStandardUrlEncode(this, IDC_USENOSTDURLENCODE), m_cbReportAbuse(this, IDC_REPORT_ABUSE), m_cbClearServerHistory(this, IDC_CLEAR_SERVER_HISTORY), @@ -243,7 +243,7 @@ CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto): CreateLink(m_cbMesAsUnread, m_proto->m_vkOptions.bMesAsUnread); CreateLink(m_cbForceInvisibleStatus, m_proto->m_vkOptions.bUserForceInvisibleOnActivity); CreateLink(m_edtInvInterval, m_proto->m_vkOptions.iInvisibleInterval); - CreateLink(m_cbUseNonStandardNotifications, m_proto->m_vkOptions.bUseNonStandardNotifications); + CreateLink(m_cbSendVKLinksAsAttachments, m_proto->m_vkOptions.bSendVKLinksAsAttachments); CreateLink(m_cbUseNonStandardUrlEncode, m_proto->m_vkOptions.bUseNonStandardUrlEncode); CreateLink(m_cbReportAbuse, m_proto->m_vkOptions.bReportAbuse); CreateLink(m_cbClearServerHistory, m_proto->m_vkOptions.bClearServerHistory); @@ -407,11 +407,13 @@ CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto): m_cbBBCForAttachmentsBasic(this, IDC_ATTBBC_BASIC), m_cbBBCForAttachmentsAdvanced(this, IDC_ATTBBC_ADV), m_cbStikersAsSmyles(this, IDC_STICKERS_AS_SMYLES), - m_cbShortenLinksForAudio(this, IDC_SHOTEN_LINKS_FOR_AUDIO) + m_cbShortenLinksForAudio(this, IDC_SHOTEN_LINKS_FOR_AUDIO), + m_cbUseNonStandardNotifications(this, IDC_USENOSTDPOPUPS) { CreateLink(m_cbUseBBCOnAttacmentsAsNews, m_proto->m_vkOptions.bUseBBCOnAttacmentsAsNews); CreateLink(m_cbStikersAsSmyles, m_proto->m_vkOptions.bStikersAsSmyles); CreateLink(m_cbShortenLinksForAudio, m_proto->m_vkOptions.bShortenLinksForAudio); + CreateLink(m_cbUseNonStandardNotifications, m_proto->m_vkOptions.bUseNonStandardNotifications); } void CVkOptionViewForm::OnInitDialog() diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h index 52bb746b0c..2db33a8bbf 100644 --- a/protocols/VKontakte/src/vk_options.h +++ b/protocols/VKontakte/src/vk_options.h @@ -76,8 +76,8 @@ class CVkOptionAdvancedForm : public CVkDlgBase CCtrlEdit m_edtInvInterval; CCtrlButton m_spInvInterval; - CCtrlCheck m_cbUseNonStandardNotifications; CCtrlCheck m_cbUseNonStandardUrlEncode; + CCtrlCheck m_cbSendVKLinksAsAttachments; CCtrlCheck m_cbReportAbuse; CCtrlCheck m_cbClearServerHistory; @@ -164,6 +164,7 @@ class CVkOptionViewForm : public CVkDlgBase CCtrlCheck m_cbStikersAsSmyles; CCtrlCheck m_cbShortenLinksForAudio; + CCtrlCheck m_cbUseNonStandardNotifications; public: CVkOptionViewForm(CVkProto *proto); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index f9af337d48..ce1f7f02ed 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -337,6 +337,7 @@ private: void SetSrmmReadStatus(MCONTACT hContact); void MarkDialogAsRead(MCONTACT hContact); char* GetStickerId(const char *Msg, int& stickerid); + CMStringA GetAttachmentsFromMessage(const char * Msg); CMString SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent); CMString GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC); CMString SetBBCString(LPCTSTR tszString, BBCSupport iBBC, VKBBCType bbcType, LPCTSTR tszAddString = NULL); diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp index 59c354325a..a5a158ac28 100644 --- a/protocols/VKontakte/src/vk_struct.cpp +++ b/protocols/VKontakte/src/vk_struct.cpp @@ -204,6 +204,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) : bNotificationFilterInvites(proto, "NotificationFilterInvites", true), bNotificationFilterAcceptedFriends(proto, "NotificationFilterAcceptedFriends", true), + bSendVKLinksAsAttachments(proto, "SendVKLinksAsAttachments", true), bUseNonStandardNotifications(proto, "UseNonStandardNotifications", false), bUseNonStandardUrlEncode(proto, "UseNonStandardUrlEncode", true), bShortenLinksForAudio(proto, "ShortenLinksForAudio", true), diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index d8ef6f4104..b7c7f3c9be 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -334,6 +334,7 @@ struct CVKOptions { CMOption bSplitFormatFwdMsg; CMOption bSyncReadMessageStatusFromServer; CMOption bLoadFullCList; + CMOption bSendVKLinksAsAttachments; CMOption bShowProtoMenuItem0; CMOption bShowProtoMenuItem1; -- cgit v1.2.3