diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-07 12:31:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-07 12:31:01 +0000 |
commit | fc4ca4545540ba1f35e4e7ad01646edf11199b4e (patch) | |
tree | f5725c89e6674b73bed183af7530350ad25ddf65 | |
parent | 2e1ccca56dcd321148ac0e233dc88e553a951d0b (diff) |
ability to set the alternative VK domain
git-svn-id: http://svn.miranda-ng.org/main/trunk@7531 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 15 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 3 |
8 files changed, 32 insertions, 12 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index c2465f1919..e0d5cdc91c 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -48,9 +48,11 @@ BEGIN CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,55,174,12
GROUPBOX "Local settings",IDC_STATIC,4,73,293,33
LTEXT "Contact list group:",IDC_STATIC,12,88,146,8
- EDITTEXT IDC_GROUPNAME,167,85,121,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_GROUPNAME,167,86,121,12,ES_AUTOHSCROLL
GROUPBOX "Advanced",IDC_STATIC,4,108,293,108
CONTROL "Server-side delivery confirmation",IDC_DELIVERY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,121,278,10
+ LTEXT "VKontakte domain",IDC_STATIC,12,135,154,8
+ EDITTEXT IDC_VKDOMAIN,167,133,121,12,ES_AUTOHSCROLL
END
IDD_CAPTCHAFORM DIALOGEX 0, 0, 258, 224
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index fba3cf24a7..2de4898616 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -18,15 +18,16 @@ #define IDC_SUBMIT 1010
#define IDC_DELIVERY 1011
#define IDC_GROUPNAME 1012
+#define IDC_VKDOMAIN 1014
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1014
+#define _APS_NEXT_CONTROL_VALUE 1015
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 9550262153..ee882de9d9 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -17,9 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VK_APP_ID "3917910"
-#define VK_API_URL "api.vk.com"
-#define VK_REDIRECT_URL "http://" VK_API_URL "/blank.html"
-
#define VKPOLL_MSG_REMOVED 0
#define VKPOLL_MSG_NEWFLAGS 1
#define VKPOLL_MSG_ADDFLAGS 2
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index 6228cb3fae..b644e1e34d 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- CVkProto* ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
@@ -117,6 +117,7 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L SetDlgItemText(hwndDlg, IDC_PASSWORD, tszPassw);
SetDlgItemText(hwndDlg, IDC_GROUPNAME, ppro->getGroup());
+ SetDlgItemTextA(hwndDlg, IDC_VKDOMAIN, ppro->getDomain());
}
CheckDlgButton(hwndDlg, IDC_DELIVERY, ppro->m_bServerDelivery);
return TRUE;
@@ -130,6 +131,7 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case IDC_LOGIN:
case IDC_PASSWORD:
case IDC_GROUPNAME:
+ case IDC_VKDOMAIN:
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -143,7 +145,10 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- TCHAR str[128];
+ union {
+ TCHAR str[128];
+ char stra[256];
+ };
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
ppro->setTString("Login", str);
@@ -153,6 +158,12 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L ppro->setTString("ProtoGroup", str);
}
+ GetDlgItemTextA(hwndDlg, IDC_VKDOMAIN, stra, SIZEOF(stra));
+ if (strcmp(ppro->getDomain(), stra)) {
+ ppro->setDomain(stra);
+ ppro->setString("BaseDomain", stra);
+ }
+
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
ptrA szRawPasswd(mir_utf8encodeT(str));
if (szRawPasswd != NULL)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 1d45da95fe..3a4f28bb1d 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -42,6 +42,10 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : nlu.ptszDescriptiveName = descr;
m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ m_baseDomain = getStringA("BaseDomain");
+ if (m_baseDomain == NULL)
+ m_baseDomain = mir_strdup("vk.com");
+
m_defaultGroup = getTStringA("ProtoGroup");
if (m_defaultGroup == NULL)
m_defaultGroup = mir_tstrdup(_T("VKontakte"));
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 7b488f15ae..dbb5d68100 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -135,6 +135,9 @@ struct CVkProto : public PROTO<CVkProto> __forceinline LPCTSTR getGroup() const { return m_defaultGroup; }
__forceinline void setGroup(LPCTSTR grp) { m_defaultGroup = mir_tstrdup(grp); }
+ __forceinline LPCSTR getDomain() const { return m_baseDomain; }
+ __forceinline void setDomain(LPCSTR domain) { m_baseDomain = mir_strdup(domain); }
+
private:
LIST<AsyncHttpRequest> m_arRequestsQueue;
CRITICAL_SECTION m_csRequestsQueue;
@@ -189,7 +192,7 @@ private: bool m_bOnline;
LONG m_myUserId;
- ptrA m_szAccessToken;
+ ptrA m_baseDomain, m_szAccessToken;
ptrT m_defaultGroup;
UINT_PTR m_timer;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index b3ee1e9195..0b4c48140a 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -64,7 +64,7 @@ AsyncHttpRequest* CVkProto::PushAsyncHttpRequest(int iRequestType, LPCSTR szUrl, CMStringA url;
if (*szUrl == '/') { // relative url leads to a site
- url = ((bSecure) ? "https://" : "http://") + CMStringA(VK_API_URL);
+ url = ((bSecure) ? "https://api." : "http://api.") + CMStringA(m_baseDomain);
url += szUrl;
pReq->bIsMainConn = true;
}
@@ -105,11 +105,12 @@ void CVkProto::WorkerThread(void*) // try to receive a response from server
RetrieveMyInfo();
else {
+ CMStringA redirectUrl; redirectUrl.Format("http://api.%s/blank.html", m_baseDomain);
// Initialize new OAuth session
HttpParam params[] = {
{ "client_id", VK_APP_ID },
{ "scope", "friends,photos,audio,video,wall,messages,offline" },
- { "redirect_uri", VK_REDIRECT_URL },
+ { "redirect_uri", redirectUrl },
{ "display", "wap" },
{ "response_type", "token" }
};
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 088201e450..8c624d95d8 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -98,7 +98,8 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq if (reply->resultCode == 302) { // manual redirect
LPCSTR pszLocation = findHeader(reply, "Location");
if (pszLocation) {
- if ( !_strnicmp(pszLocation, VK_REDIRECT_URL, sizeof(VK_REDIRECT_URL)-1)) {
+ CMStringA redirectUrl; redirectUrl.Format("http://api.%s/blank.html", m_baseDomain);
+ if (!_strnicmp(pszLocation, redirectUrl, redirectUrl.GetLength())) {
m_szAccessToken = NULL;
LPCSTR p = strstr(pszLocation, VK_TOKEN_BEG);
if (p) {
|