summaryrefslogtreecommitdiff
path: root/plugins/Dropbox
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-03-03 15:43:38 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-03-03 15:43:38 +0000
commite5287627d957b092d11ba8031e4d30dc7f79cbd5 (patch)
tree97aa1ecb756c4ec15c1999ee92efc2de551332d0 /plugins/Dropbox
parent999fdaa2662a1fe8937ec110232a78e87d79bfe7 (diff)
Dropbox: fallback to v1 api to support shorten urls
git-svn-id: http://svn.miranda-ng.org/main/trunk@16406 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox')
-rw-r--r--plugins/Dropbox/src/api/operations.h10
-rw-r--r--plugins/Dropbox/src/dropbox.cpp13
-rw-r--r--plugins/Dropbox/src/dropbox_commands.cpp11
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp11
4 files changed, 26 insertions, 19 deletions
diff --git a/plugins/Dropbox/src/api/operations.h b/plugins/Dropbox/src/api/operations.h
index 01f428c88a..d50b99e734 100644
--- a/plugins/Dropbox/src/api/operations.h
+++ b/plugins/Dropbox/src/api/operations.h
@@ -1,6 +1,16 @@
#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 a794e3bb17..fa31010600 100644
--- a/plugins/Dropbox/src/dropbox.cpp
+++ b/plugins/Dropbox/src/dropbox.cpp
@@ -94,19 +94,6 @@ void CDropbox::RequestAccountInfo(void *p)
if (!name.empty()) {
db_set_s(hContact, MODULE, "FirstName", name.at("given_name").as_string().c_str());
db_set_s(hContact, MODULE, "LastName", name.at("surname").as_string().c_str());
- /*JSONNode display_name = root.at("display_name");
- if (!display_name.empty()) {
- CMString tszDisplayName(display_name.as_mstring());
- int pos = tszDisplayName.ReverseFind(' ');
- if (pos != -1) {
- db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos + 1));
- db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
- }
- else {
- db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
- db_unset(hContact, MODULE, "LastName");
- }
- }*/
}
JSONNode country = root.at("country");
diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp
index 10efb39d44..7fef60be45 100644
--- a/plugins/Dropbox/src/dropbox_commands.cpp
+++ b/plugins/Dropbox/src/dropbox_commands.cpp
@@ -79,9 +79,14 @@ void CDropbox::CommandShare(void *arg)
}
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
- //bool useShortUrl = db_get_b(NULL, MODULE, "UseSortLinks", 1) > 0;
- ShareRequest request(token, path);
- NLHR_PTR response(request.Send(param->instance->hNetlibConnection));
+ 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;
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 801f2e344e..15fd919598 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -76,9 +76,14 @@ 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;
- ShareRequest request(token, path);
- NLHR_PTR response(request.Send(hNetlibConnection));
+ 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;
HandleJsonResponseError(response);