From ac60e6cd374568da60bf732a8018f94d48ee9dd7 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 13 May 2015 15:21:50 +0000 Subject: Dropbox: - fixed commands sending - removed status changing git-svn-id: http://svn.miranda-ng.org/main/trunk@13571 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_commands.cpp | 70 ++++++++++++++------------------ 1 file changed, 31 insertions(+), 39 deletions(-) (limited to 'plugins/Dropbox/src/dropbox_commands.cpp') diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp index 3ce87a7c3b..739768d099 100644 --- a/plugins/Dropbox/src/dropbox_commands.cpp +++ b/plugins/Dropbox/src/dropbox_commands.cpp @@ -18,55 +18,47 @@ void CDropbox::CommandContent(void *arg) CommandParam *param = (CommandParam*)arg; char *path = (char*)param->data; - if (path) + if (path == NULL) + path = ""; + + ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); + ptrA encodedPath(mir_utf8encode(path)); + GetMetadataRequest request(token, encodedPath); + mir_ptr response(request.Send(param->instance->hNetlibConnection)); + + if (response && response->resultCode == HTTP_STATUS_OK) { - ptrA token(db_get_sa(NULL, MODULE, "TokenSecret")); - ptrA encodedPath(mir_utf8encode(path)); - GetMetadataRequest request(token, encodedPath); - mir_ptr response(request.Send(param->instance->hNetlibConnection)); + CMStringA message; - if (response && response->resultCode == HTTP_STATUS_OK) + JSONROOT root(response->pData); + if (root) { - CMStringA message; - - JSONROOT root(response->pData); - if (root) + JSONNODE *node = json_get(root, "is_dir"); + bool isDir = json_as_bool(node) > 0; + if (!isDir) + message.AppendFormat("\"%s\" %s", path, Translate("is file")); + else { - JSONNODE *node = json_get(root, "is_dir"); - bool isDir = json_as_bool(node) > 0; - if (!isDir) - message.AppendFormat("\"%s\" %s", path, Translate("is file")); - else - { - JSONNODE *content = json_as_array(json_get(root, "contents")); - for (int i = 0;; i++) { - JSONNODE *item = json_at(content, i); - if (item == NULL) { - if (i == 0) - message.AppendFormat("\"%s\" %s", path, Translate("is empty")); - break; - } - - ptrA subName(mir_u2a(json_as_string(json_get(item, "path")))); - message.AppendFormat("%s\n", (subName[0] == '/') ? &subName[1] : subName); + JSONNODE *content = json_as_array(json_get(root, "contents")); + for (int i = 0;; i++) { + JSONNODE *item = json_at(content, i); + if (item == NULL) { + if (i == 0) + message.AppendFormat("\"%s\" %s", path, Translate("is empty")); + break; } + + ptrA subName(mir_u2a(json_as_string(json_get(item, "path")))); + message.AppendFormat("%s\n", (subName[0] == '/') ? &subName[1] : subName); } + } - ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); - CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer()); + ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); + CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer()); - return; - } + return; } } - else - { - CMStringA error(FORMAT, Translate("\"%s\" command has invalid parameter.\nUse \"/help\" for more info."), "/content"); - ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); - CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer()); - - return; - } ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0); } -- cgit v1.2.3