summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-13 20:12:06 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-13 20:12:06 +0000
commitf8830ba4d8827a9460de51e17ccd8caeed7217e2 (patch)
treec1c15b0590c89eff2644b1618982860634c497df /plugins
parent5865e7f3b1013d8540e8bd5a8a012da26d6f6768 (diff)
Dropbox: some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@13577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Dropbox/src/api/operations.h16
-rw-r--r--plugins/Dropbox/src/api/upload.h8
-rw-r--r--plugins/Dropbox/src/dropbox.cpp2
-rw-r--r--plugins/Dropbox/src/dropbox_commands.cpp6
-rw-r--r--plugins/Dropbox/src/dropbox_events.cpp3
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp21
6 files changed, 32 insertions, 24 deletions
diff --git a/plugins/Dropbox/src/api/operations.h b/plugins/Dropbox/src/api/operations.h
index 56578515b3..b94d90b4e7 100644
--- a/plugins/Dropbox/src/api/operations.h
+++ b/plugins/Dropbox/src/api/operations.h
@@ -4,8 +4,8 @@
class ShareRequest : public HttpRequest
{
public:
- ShareRequest(const char *token, const char *path, bool useShortUrl = true) :
- HttpRequest(REQUEST_POST, FORMAT, DROPBOX_API_URL "/shares/auto/%s", path)
+ ShareRequest(const char *token, const char *path, bool useShortUrl = true, const char *root = "auto") :
+ HttpRequest(REQUEST_POST, FORMAT, DROPBOX_API_URL "/shares/%s/%s", root, path)
{
if (!useShortUrl)
AddUrlParameter("short_url=false");
@@ -18,13 +18,13 @@ public:
class DeleteRequest : public HttpRequest
{
public:
- DeleteRequest(const char *token, const char *path) :
+ DeleteRequest(const char *token, const char *path, const char *root = "auto") :
HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/delete")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
- CMStringA data(CMStringDataFormat::FORMAT, "root=auto&path=%s", path);
+ CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
data.Replace('\\', '/');
SetData(data.GetBuffer(), data.GetLength());
}
@@ -33,13 +33,13 @@ public:
class CreateFolderRequest : public HttpRequest
{
public:
- CreateFolderRequest(const char *token, const char *path) :
+ CreateFolderRequest(const char *token, const char *path, const char *root = "auto") :
HttpRequest(REQUEST_POST, DROPBOX_API_URL "/fileops/create_folder")
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
- CMStringA data(CMStringDataFormat::FORMAT, "root=auto&path=%s", path);
+ CMStringA data(CMStringDataFormat::FORMAT, "root=%s&path=%s", root, path);
data.Replace('\\', '/');
SetData(data.GetBuffer(), data.GetLength());
}
@@ -48,8 +48,8 @@ public:
class GetMetadataRequest : public HttpRequest
{
public:
- GetMetadataRequest(const char *token, const char *path) :
- HttpRequest(REQUEST_GET, FORMAT, DROPBOX_API_URL "/metadata/auto/%s", path)
+ GetMetadataRequest(const char *token, const char *path, const char *root = "auto") :
+ HttpRequest(REQUEST_GET, FORMAT, DROPBOX_API_URL "/metadata/%s/%s", root, path)
{
AddBearerAuthHeader(token);
}
diff --git a/plugins/Dropbox/src/api/upload.h b/plugins/Dropbox/src/api/upload.h
index 5c2e41c792..a871940e20 100644
--- a/plugins/Dropbox/src/api/upload.h
+++ b/plugins/Dropbox/src/api/upload.h
@@ -4,8 +4,8 @@
class UploadFileRequest : public HttpRequest
{
public:
- UploadFileRequest(const char *token, const char *fileName, const char *data, int length) :
- HttpRequest(REQUEST_PUT, FORMAT, DROPBOX_APICONTENT_URL "/files_put/auto/%s", fileName)
+ UploadFileRequest(const char *token, const char *fileName, const char *data, int length, const char *root = "auto") :
+ HttpRequest(REQUEST_PUT, FORMAT, DROPBOX_APICONTENT_URL "/files_put/%s/%s", root, fileName)
{
AddBearerAuthHeader(token);
pData = (char*)data;
@@ -34,8 +34,8 @@ public:
dataLength = length;
}
- UploadFileChunkRequest(const char *token, const char *uploadId, const char *path) :
- HttpRequest(REQUEST_POST, FORMAT, DROPBOX_APICONTENT_URL "/commit_chunked_upload/auto/%s", path)
+ UploadFileChunkRequest(const char *token, const char *uploadId, const char *path, const char *root = "auto") :
+ HttpRequest(REQUEST_POST, FORMAT, DROPBOX_APICONTENT_URL "/commit_chunked_upload/%s/%s", root, path)
{
AddBearerAuthHeader(token);
AddHeader("Content-Type", "application/x-www-form-urlencoded");
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp
index 516a30941c..a370c7e559 100644
--- a/plugins/Dropbox/src/dropbox.cpp
+++ b/plugins/Dropbox/src/dropbox.cpp
@@ -141,6 +141,8 @@ void CDropbox::DestroyAccessToken()
if (hContact)
if (db_get_w(hContact, MODULE, "Status", ID_STATUS_ONLINE) == ID_STATUS_ONLINE)
db_set_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE);
+
+ ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_ONLINE, (WPARAM)ID_STATUS_OFFLINE);
}
UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp
index 739768d099..48d6cfa9b4 100644
--- a/plugins/Dropbox/src/dropbox_commands.cpp
+++ b/plugins/Dropbox/src/dropbox_commands.cpp
@@ -5,9 +5,9 @@ void CDropbox::CommandHelp(void *arg)
CommandParam *param = (CommandParam*)arg;
CMStringA help(Translate("Dropbox supports the following commands:")); help += "\n";
- help += "\"/content [dir]\" - "; help += Translate("shows all files in folder \"dir\" (\"dir\" can be omitted for root folder)"); help += "\n";
- help += "\"/share <path>\" - "; help += Translate("returns download link for file or folder with specified path (\"path\" is relative from root folder)"); help += "\n";
- help += "\"/delete <path>\" - "; help += Translate("deletes file or folder with specified path (\"path\" is relative from root folder)");
+ help += "\"/content [dir]\" \t- "; help += Translate("shows all files in folder \"dir\" (\"dir\" can be omitted for root folder)"); help += "\n";
+ help += "\"/share <path>\" \t- "; help += Translate("returns download link for file or folder with specified path (\"path\" is relative from root folder)"); help += "\n";
+ help += "\"/delete <path>\" \t- "; help += Translate("deletes file or folder with specified path (\"path\" is relative from root folder)");
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)help.GetBuffer());
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp
index 8673eb85b1..be1e5a72be 100644
--- a/plugins/Dropbox/src/dropbox_events.cpp
+++ b/plugins/Dropbox/src/dropbox_events.cpp
@@ -20,6 +20,9 @@ int CDropbox::OnModulesLoaded(WPARAM, LPARAM)
GetDefaultContact();
+ WORD status = ProtoGetStatus(0, 0);
+ ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, status);
+
if (ServiceExists(MS_BB_ADDBUTTON))
{
BBButton bbd = { sizeof(bbd) };
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index 37b807eedc..c32ebf1802 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -46,11 +46,14 @@ INT_PTR CDropbox::ProtoGetStatus(WPARAM, LPARAM)
INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
{
- if (!HasAccessToken())
- return ACKRESULT_FAILED;
-
CCSDATA *pccsd = (CCSDATA*)lParam;
+ if (!HasAccessToken())
+ {
+ ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send files when you are not authorized.");
+ return 0;
+ }
+
FileTransferParam *ftp = new FileTransferParam();
ftp->pfts.flags |= PFTS_SENDING;
ftp->pfts.hContact = pccsd->hContact;
@@ -124,9 +127,6 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
INT_PTR CDropbox::ProtoCancelFile(WPARAM, LPARAM lParam)
{
- if (!HasAccessToken())
- return ACKRESULT_FAILED;
-
CCSDATA *pccsd = (CCSDATA*)lParam;
HANDLE hTransfer = (HANDLE)pccsd->wParam;
@@ -141,11 +141,14 @@ INT_PTR CDropbox::ProtoCancelFile(WPARAM, LPARAM lParam)
INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
{
- if (!HasAccessToken())
- return ACKRESULT_FAILED;
-
CCSDATA *pccsd = (CCSDATA*)lParam;
+ if (!HasAccessToken())
+ {
+ ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send messages when you are not authorized.");
+ return 0;
+ }
+
char *message = NULL;
char *szMessage = (char*)pccsd->lParam;
if (pccsd->wParam & PREF_UNICODE)