diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-01-27 07:01:46 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-01-27 07:01:46 +0000 |
commit | 950aaf82c22eede84e5e36f77181274144ce8b7d (patch) | |
tree | 6c90a492741a92a8291944f5077c99fd10012a50 /protocols/VKontakte | |
parent | 24c5c5da5e34c0cfb1f6798afb3029f85d5dd062 (diff) |
VKontakte:
add option for non-standard (by VEG) urlDecode message
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11923 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 28 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 44 | ||||
-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.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 4 |
10 files changed, 77 insertions, 23 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 8528209951..f8458123cd 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -71,7 +71,7 @@ BEGIN LEFTMARGIN, 4
RIGHTMARGIN, 297
TOPMARGIN, 7
- BOTTOMMARGIN, 157
+ BOTTOMMARGIN, 169
END
IDD_OPT_MAIN, DIALOG
@@ -189,29 +189,31 @@ BEGIN CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,0,49,174,12
END
-IDD_OPT_ADV DIALOGEX 0, 0, 304, 167
+IDD_OPT_ADV DIALOGEX 0, 0, 304, 179
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Advanced",IDC_STATIC,4,8,293,48
+ GROUPBOX "Advanced",IDC_STATIC,4,8,293,57
CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,278,10
CONTROL "Always notify as unread for all incoming message",IDC_MESASUREAD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,278,10
CONTROL "Force online status upon user activity",IDC_FORCE_ONLINE_ON_ACT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,278,10
- GROUPBOX "When I ban user...",IDC_STATIC,4,58,293,33
- CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,68,129,10
- CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,79,129,10
+ CONTROL "Use non-standard urlEncode for sent messages (less traffic)",IDC_USENOSTDURLENCODE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,278,10
+ GROUPBOX "When I ban user...",IDC_STATIC,4,66,293,33
+ CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,76,129,10
+ CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,87,129,10
CONTROL "Remove from friend list",IDC_REMOVE_FROM_FRENDLIST,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,68,141,10
- CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,79,141,10
- GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,94,293,58,WS_GROUP
- CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,105,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,76,141,10
+ CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,87,141,10
+ GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,102,293,58,WS_GROUP
+ CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,113,278,10
CONTROL "as regular status for unknown music and audio status otherwise",IDC_SEND_MUSIC_BROADCAST_AND_STATUS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,116,278,11
- CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,127,278,10
- CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,138,278,10
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,124,278,11
+ CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,135,278,10
+ CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,146,278,10
END
IDD_OPT_MAIN DIALOGEX 0, 0, 304, 213
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 9576d09224..b49d4424e2 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -80,6 +80,48 @@ HANDLE GetIconHandle(int iCommand) /////////////////////////////////////////////////////////////////////////////////////////
+static const char szHexDigits[] = "0123456789ABCDEF";
+
+char* ExpUrlEncode(const char *szUrl, bool strict)
+{
+ if (szUrl == NULL)
+ return NULL;
+
+ const BYTE *s;
+ int outputLen;
+ for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++) {
+ if ((*s & 0x80 && !strict) || // UTF-8 multibyte
+ ('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '~' || *s == '-' || *s == '_' || *s == '.' || *s == ' ') outputLen++;
+ else outputLen += 3;
+ }
+
+ char *szOutput = (char*)mir_alloc(outputLen + 1);
+ if (szOutput == NULL)
+ return NULL;
+
+ char *d = szOutput;
+ for (s = (const BYTE*)szUrl; *s; s++) {
+ if ((*s & 0x80 && !strict) || // UTF-8 multibyte
+ ('0' <= *s && *s <= '9') || //0-9
+ ('A' <= *s && *s <= 'Z') || //ABC...XYZ
+ ('a' <= *s && *s <= 'z') || //abc...xyz
+ *s == '~' || *s == '-' || *s == '_' || *s == '.') *d++ = *s;
+ else if (*s == ' ') *d++ = '+';
+ else {
+ *d++ = '%';
+ *d++ = szHexDigits[*s >> 4];
+ *d++ = szHexDigits[*s & 0xF];
+ }
+ }
+ *d = '\0';
+ return szOutput;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
AsyncHttpRequest::AsyncHttpRequest()
{
cbSize = sizeof(NETLIBHTTPREQUEST);
@@ -91,6 +133,7 @@ AsyncHttpRequest::AsyncHttpRequest() bNeedsRestart = false;
bIsMainConn = false;
m_pFunc = NULL;
+ bExpUrlEncode = false;
}
AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
@@ -98,6 +141,7 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url cbSize = sizeof(NETLIBHTTPREQUEST);
m_bApiReq = true;
bIsMainConn = false;
+ bExpUrlEncode = ppro->m_bUseNonStandardUrlEncode;
AddHeader("Connection", "keep-alive");
AddHeader("Accept-Encoding", "booo");
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index 3beec16457..bba391dc78 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -93,6 +93,7 @@ #define IDC_ATTBBC_BASIC 1085
#define IDC_ATTBBC_ADV 1086
#define IDC_BBC_ATT_NEWS 1087
+#define IDC_USENOSTDURLENCODE 1088
// Next default values for new objects
//
@@ -101,7 +102,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1088
+#define _APS_NEXT_CONTROL_VALUE 1089
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index d82be5d6f4..57af18735a 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 0
-#define __BUILD_NUM 41
+#define __BUILD_NUM 43
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 2a20d681ad..61addafec7 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -86,4 +86,6 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField); bool tlstrstr(TCHAR* _s1, TCHAR* _s2);
void InitIcons(void);
-HANDLE GetIconHandle(int iCommand);
\ No newline at end of file +HANDLE GetIconHandle(int iCommand);
+
+char* ExpUrlEncode(const char *szUrl, bool strict = false);
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 8b1a567ad2..aec5954217 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -113,7 +113,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc) debugLogA("CVkProto::RetrieveChantInfo(%d)", cc->m_chatid);
if (!IsOnline())
return;
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveChatInfo)
<< CHAR_PARAM("code", szQuery)
<< VER_API)->pUserInfo = cc;
}
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 9caec1fb78..abc53e5ccd 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -245,6 +245,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_USENOSTDURLENCODE, ppro->m_bUseNonStandardUrlEncode ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CLEAR_SERVER_HISTORY, ppro->m_bClearServerHistory ? BST_CHECKED : BST_UNCHECKED);
@@ -263,6 +264,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam case IDC_HIDECHATS:
case IDC_MESASUREAD:
case IDC_FORCE_ONLINE_ON_ACT:
+ case IDC_USENOSTDURLENCODE:
case IDC_REPORT_ABUSE:
case IDC_CLEAR_SERVER_HISTORY:
case IDC_REMOVE_FROM_FRENDLIST:
@@ -285,12 +287,12 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
-
-
-
ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
+ ppro->m_bUseNonStandardUrlEncode = IsDlgButtonChecked(hwndDlg, IDC_USENOSTDURLENCODE) == BST_CHECKED;
+ ppro->setByte("UseNonStandardUrlEncode", ppro->m_bUseNonStandardUrlEncode);
+
ppro->m_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED;
ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index fffb4eafed..9bfe354b60 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -107,6 +107,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bNotificationFilterReposts = getBool("NotificationFilterComments", true);
m_bNotificationFilterMentions = getBool("NotificationFilterMentions", true);
+ m_bUseNonStandardUrlEncode = getBool("UseNonStandardUrlEncode", false);
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
vk_Instances.insert(this);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index c77952393e..b55bc4f68a 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -52,6 +52,7 @@ struct AsyncHttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject void *pUserInfo;
int m_iRetry;
bool m_bApiReq;
+ bool bExpUrlEncode;
bool bNeedsRestart, bIsMainConn;
};
@@ -581,7 +582,8 @@ private: m_bNotificationFilterLikes,
m_bNotificationFilterReposts,
m_bNotificationFilterMentions,
- m_bUseBBCOnAttacmentsAsNews;
+ m_bUseBBCOnAttacmentsAsNews,
+ m_bUseNonStandardUrlEncode;
int m_iNewsInterval,
m_iNotificationsInterval,
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 1fdc21242c..a4c7b59ee4 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -159,7 +159,7 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM ¶m) CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
- s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(param.szValue)));
+ s.AppendFormat("%s=%s", param.szName, ptrA(pReq->bExpUrlEncode ? ExpUrlEncode(param.szValue) : mir_urlEncode(param.szValue)));
return pReq;
}
@@ -169,6 +169,6 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const TCHAR_PARAM ¶m) CMStringA &s = pReq->m_szParam;
if (!s.IsEmpty())
s.AppendChar('&');
- s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(szValue)));
+ s.AppendFormat("%s=%s", param.szName, ptrA(pReq->bExpUrlEncode ? ExpUrlEncode(szValue) : mir_urlEncode(szValue)));
return pReq;
}
|