diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-07-13 08:25:04 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-07-13 08:25:04 +0000 |
commit | 46d6a43726d64a0d7f808ad55557bfc56b89f97d (patch) | |
tree | 4fea102a4cf636196b8ae6f6da8cdd627a4d14fe | |
parent | ffb9e28990704074a63fc87d1a92621727a4c951 (diff) |
VKontakte:
add ‘Send VK-objects links as attachments’ option
move ‘Use non-standard popups for news and event notifications’ option to View page
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@17090 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 10 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 40 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 10 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 1 |
10 files changed, 68 insertions, 11 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 7d5d902c4b..4b63787c43 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -73,7 +73,7 @@ BEGIN LEFTMARGIN, 4
RIGHTMARGIN, 298
TOPMARGIN, 7
- BOTTOMMARGIN, 177
+ BOTTOMMARGIN, 190
END
IDD_OPT_FEEDS, DIALOG
@@ -163,7 +163,7 @@ BEGIN CONTROL "Visit profile",IDC_SHOW_MENU6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,85,280,10
END
-IDD_OPT_VIEW DIALOGEX 0, 0, 304, 184
+IDD_OPT_VIEW DIALOGEX 0, 0, 304, 197
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -185,11 +185,13 @@ BEGIN CONTROL "basic ([b], [i], [u], [s])",IDC_ATTBBC_BASIC,"Button",BS_AUTORADIOBUTTON,12,121,129,10
CONTROL "advanced (+[url], [size], [color], [code])",IDC_ATTBBC_ADV,
"Button",BS_AUTORADIOBUTTON,154,110,129,10
- GROUPBOX "Other",IDC_STATIC,4,138,293,36
+ GROUPBOX "Other",IDC_STATIC,4,138,294,46
CONTROL "Process stickers as smileys",IDC_STICKERS_AS_SMYLES,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,149,278,10
CONTROL "Shorten links for audio attachments",IDC_SHOTEN_LINKS_FOR_AUDIO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,160,278,10
+ CONTROL "Use non-standard popups for news and event notifications",IDC_USENOSTDPOPUPS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,171,278,10
END
IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 232
@@ -264,7 +266,7 @@ BEGIN CONTROL "",IDC_SPIN_INT_INVIS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,244,63,14,14
CONTROL "Use non-standard urlEncode for sent messages (less traffic)",IDC_USENOSTDURLENCODE,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,78,278,10
- CONTROL "Use non-standard popups for news and event notifications",IDC_USENOSTDPOPUPS,
+ CONTROL "Send VK-objects links as attachments",IDC_SENDVKURLSASATTACH,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,89,278,10
GROUPBOX "When I ban user...",IDC_STATIC,4,102,293,33
CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,112,129,10
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 <stdver.h>
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<BYTE> bSplitFormatFwdMsg;
CMOption<BYTE> bSyncReadMessageStatusFromServer;
CMOption<BYTE> bLoadFullCList;
+ CMOption<BYTE> bSendVKLinksAsAttachments;
CMOption<BYTE> bShowProtoMenuItem0;
CMOption<BYTE> bShowProtoMenuItem1;
|