From 9418930c2d211feca1ddeaafa160c3d8ca9a581a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 11 May 2015 17:13:29 +0000 Subject: - protocol icon is used in all menus & buttons; - code formatting git-svn-id: http://svn.miranda-ng.org/main/trunk@13551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_commands.cpp | 53 ++++++++++++-------------------- 1 file changed, 19 insertions(+), 34 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 52422ea779..2e8963caa1 100644 --- a/plugins/Dropbox/src/dropbox_commands.cpp +++ b/plugins/Dropbox/src/dropbox_commands.cpp @@ -4,7 +4,7 @@ void CDropbox::CommandHelp(void *arg) { CommandParam *param = (CommandParam*)arg; - CMStringA help = Translate("Dropbox supports the following commands:"); help += "\n"; + 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 \" - "; help += Translate("returns download link for file or folder with specified path (\"path\" is relative from root folder)"); help += "\n"; help += "\"/delete \" - "; help += Translate("deletes file or folder with specified path (\"path\" is relative from root folder)"); @@ -19,7 +19,7 @@ void CDropbox::CommandContent(void *arg) char *name = (char*)param->data; - CMStringA url = DROPBOX_API_URL "/metadata/" DROPBOX_API_ROOT; + CMStringA url(DROPBOX_API_URL "/metadata/" DROPBOX_API_ROOT); if (name) url.AppendFormat("/%s", ptrA(mir_utf8encode(name))); @@ -30,25 +30,20 @@ void CDropbox::CommandContent(void *arg) delete request; - if (response && response->resultCode == HTTP_STATUS_OK) - { + if (response && response->resultCode == HTTP_STATUS_OK) { CMStringA message; JSONROOT root(response->pData); - if (root) - { + if (root) { JSONNODE *node = json_get(root, "is_dir"); bool isDir = json_as_bool(node) > 0; if (!isDir) message.AppendFormat("\"%s\" %s", name, Translate("is file")); - else - { + else { JSONNODE *content = json_as_array(json_get(root, "contents")); - for (int i = 0;; i++) - { + for (int i = 0;; i++) { JSONNODE *item = json_at(content, i); - if (item == NULL) - { + if (item == NULL) { if (i == 0) message.AppendFormat("\"%s\" %s", name, Translate("is empty")); break; @@ -74,9 +69,8 @@ void CDropbox::CommandShare(void *arg) CommandParam *param = (CommandParam*)arg; char *name = (char*)param->data; - if (name) - { - CMStringA url = DROPBOX_API_URL "/shares/" DROPBOX_API_ROOT; + if (name) { + CMStringA url(DROPBOX_API_URL "/shares/" DROPBOX_API_ROOT); if (name) url.AppendFormat("/%s", ptrA(mir_utf8encode(name))); @@ -87,13 +81,11 @@ void CDropbox::CommandShare(void *arg) delete request; - if (response && response->resultCode == HTTP_STATUS_OK) - { + if (response && response->resultCode == HTTP_STATUS_OK) { CMStringA link; JSONROOT root(response->pData); - if (root) - { + if (root) { JSONNODE *node = json_get(root, "url"); link = mir_u2a(json_as_string(node)); ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); @@ -103,9 +95,8 @@ void CDropbox::CommandShare(void *arg) } } } - else - { - CMStringA error; error.AppendFormat(Translate("\"%s\" command has invalid parameter.\nUse \"/help\" for more info."), "/share"); + else { + CMStringA error(FORMAT, Translate("\"%s\" command has invalid parameter.\nUse \"/help\" for more info."), "/share"); ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer()); @@ -120,8 +111,7 @@ void CDropbox::CommandDelete(void *arg) CommandParam *param = (CommandParam*)arg; char *name = (char*)param->data; - if (name) - { + if (name) { CMStringA pparam = CMStringA("root=" DROPBOX_API_ROOT "&path=") + ptrA(mir_utf8encode(name)); HttpRequest *request = new HttpRequest(param->instance->hNetlibUser, REQUEST_POST, DROPBOX_API_URL "/fileops/delete"); @@ -134,25 +124,20 @@ void CDropbox::CommandDelete(void *arg) delete request; - if (response && response->resultCode == HTTP_STATUS_OK) - { + if (response && response->resultCode == HTTP_STATUS_OK) { JSONROOT root(response->pData); - if (root) - { + if (root) { JSONNODE *node = json_get(root, "is_deleted"); bool isDeleted = json_as_bool(node) > 0; - CMStringA message; - message.AppendFormat("%s %s", name, !isDeleted ? Translate("is not deleted") : Translate("is deleted")); + CMStringA message(FORMAT, "%s %s", name, !isDeleted ? Translate("is not deleted") : Translate("is deleted")); ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer()); - return; } } } - else - { - CMStringA error; error.AppendFormat(Translate("\"%s\" command has invalid parameter.\nUse \"/help\" for more info."), "/delete"); + else { + CMStringA error(FORMAT, Translate("\"%s\" command has invalid parameter.\nUse \"/help\" for more info."), "/delete"); ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0); CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)error.GetBuffer()); } -- cgit v1.2.3