From 2db93e0b278176b4dd68e8565ddab139d86c6e7b Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 22 Apr 2016 15:25:57 +0000 Subject: Dropbox: links will never be short git-svn-id: http://svn.miranda-ng.org/main/trunk@16746 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/res/resource.rc | 2 +- plugins/Dropbox/src/api/account.h | 8 ++++---- plugins/Dropbox/src/api/operations.h | 10 ---------- plugins/Dropbox/src/dropbox.cpp | 2 +- plugins/Dropbox/src/dropbox_commands.cpp | 11 +++-------- plugins/Dropbox/src/dropbox_transfers.cpp | 11 +++-------- plugins/Dropbox/src/stdafx.h | 3 ++- plugins/Dropbox/src/version.h | 2 +- 8 files changed, 15 insertions(+), 34 deletions(-) diff --git a/plugins/Dropbox/res/resource.rc b/plugins/Dropbox/res/resource.rc index 193fb5ec19..75c512b647 100644 --- a/plugins/Dropbox/res/resource.rc +++ b/plugins/Dropbox/res/resource.rc @@ -77,7 +77,7 @@ BEGIN LTEXT "Initiate authorization",IDC_STATIC,29,71,109,16 PUSHBUTTON "Authorize",IDC_AUTHORIZE,144,68,153,14,BS_CENTER | WS_DISABLED GROUPBOX "Download link",IDC_STATIC,5,111,297,70 - CONTROL "Use shortened download links",IDC_URL_USE_SHORT,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,15,125,282,10 + CONTROL "Use shortened download links",IDC_URL_USE_SHORT,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,15,125,282,10 LTEXT "4.",IDC_STATIC,22,89,8,8 LTEXT "Check status of authorization",IDC_STATIC,30,89,108,17 CTEXT "",IDC_AUTH_STATUS,144,89,153,8 diff --git a/plugins/Dropbox/src/api/account.h b/plugins/Dropbox/src/api/account.h index 98ba370abe..6943bd29c3 100644 --- a/plugins/Dropbox/src/api/account.h +++ b/plugins/Dropbox/src/api/account.h @@ -5,7 +5,7 @@ class GetAccessTokenRequest : public HttpRequest { public: GetAccessTokenRequest(const char *requestToken) : - HttpRequest(REQUEST_POST, DROPBOX_API_OLD "/oauth2/token") + HttpRequest(REQUEST_POST, DROPBOX_API "/oauth2/token") { AddHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -16,11 +16,11 @@ public: } }; -class DisableAccessTokenRequest : public HttpRequest +class RevokeAccessTokenRequest : public HttpRequest { public: - DisableAccessTokenRequest() : - HttpRequest(REQUEST_POST, DROPBOX_API_OLD "/disable_access_token") + RevokeAccessTokenRequest() : + HttpRequest(REQUEST_POST, DROPBOX_API "/oauth2/token/revoke") { } }; diff --git a/plugins/Dropbox/src/api/operations.h b/plugins/Dropbox/src/api/operations.h index d50b99e734..01f428c88a 100644 --- a/plugins/Dropbox/src/api/operations.h +++ b/plugins/Dropbox/src/api/operations.h @@ -1,16 +1,6 @@ #ifndef _DROPBOX_API_OPERATIONS_H_ #define _DROPBOX_API_OPERATIONS_H_ -class ShareOldRequest : public HttpRequest -{ -public: - ShareOldRequest(const char *token, const char *path) : - HttpRequest(REQUEST_POST, HttpRequestUrlFormat::FORMAT, DROPBOX_API_OLD "/shares/auto/%s", path) - { - AddBearerAuthHeader(token); - } -}; - class ShareRequest : public HttpRequest { public: diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index 63b779c59c..2ceda25e0a 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -122,7 +122,7 @@ void CDropbox::RequestAccountInfo(void *p) void CDropbox::DestroyAccessToken() { - DisableAccessTokenRequest request; + RevokeAccessTokenRequest request; NLHR_PTR response(request.Send(hNetlibConnection)); db_unset(NULL, MODULE, "TokenSecret"); diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp index c4c1062573..4a369bb7f3 100644 --- a/plugins/Dropbox/src/dropbox_commands.cpp +++ b/plugins/Dropbox/src/dropbox_commands.cpp @@ -79,14 +79,9 @@ void CDropbox::CommandShare(void *arg) } ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); - bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; - HttpRequest *request; - if (useShortUrl) - request = new ShareOldRequest(token, path); - else - request = new ShareRequest(token, path); - NLHR_PTR response(request->Send(param->instance->hNetlibConnection)); - delete request; + //bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; + ShareRequest request(token, path); + NLHR_PTR response(request.Send(param->instance->hNetlibConnection)); if (response == NULL || response->resultCode != HTTP_STATUS_OK) { ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0); diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 4b54e4cd55..ebebed6fc3 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -76,14 +76,9 @@ void CDropbox::CreateFolder(const char *path) void CDropbox::CreateDownloadUrl(const char *path, char *url) { ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); - bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; - HttpRequest *request; - if (useShortUrl) - request = new ShareOldRequest(token, path); - else - request = new ShareRequest(token, path); - NLHR_PTR response(request->Send(hNetlibConnection)); - delete request; + //bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0; + ShareRequest request(token, path); + NLHR_PTR response(request.Send(hNetlibConnection)); HandleJsonResponseError(response); diff --git a/plugins/Dropbox/src/stdafx.h b/plugins/Dropbox/src/stdafx.h index ca6ad13383..06c01db459 100644 --- a/plugins/Dropbox/src/stdafx.h +++ b/plugins/Dropbox/src/stdafx.h @@ -41,7 +41,8 @@ class CDropbox; #define DROPBOX_API_VER "2" #define DROPBOX_WWW_URL "https://www.dropbox.com/1" #define DROPBOX_API_OLD "https://api.dropboxapi.com/1" -#define DROPBOX_API_RPC "https://api.dropboxapi.com/" DROPBOX_API_VER +#define DROPBOX_API "https://api.dropboxapi.com/" +#define DROPBOX_API_RPC DROPBOX_API DROPBOX_API_VER #define DROPBOX_API_CU "https://content.dropboxapi.com/" DROPBOX_API_VER #define DROPBOX_APP_KEY "fa8du7gkf2q8xzg" diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h index 75ee9ec7f6..929b1c61ae 100644 --- a/plugins/Dropbox/src/version.h +++ b/plugins/Dropbox/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 12 #define __RELEASE_NUM 2 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3