summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-12-22 17:13:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-12-22 17:13:27 +0000
commit020323a39b43152782541fd3897e3d2f6c72cfd1 (patch)
treeb62f0effdf2f6dc2e992e1441f7d6f3dd46b2dff
parent8508d083487e03f6dd0371ab2c67ec0168c7b746 (diff)
Dropbox:
- contact menu to verify PF1_IMSEND flag to disable it for protocols that don't support sending IMs; - code cleaning; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15930 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Dropbox/src/dropbox.cpp50
-rw-r--r--plugins/Dropbox/src/dropbox_commands.cpp33
-rw-r--r--plugins/Dropbox/src/dropbox_events.cpp30
-rw-r--r--plugins/Dropbox/src/dropbox_menus.cpp26
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp39
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp39
-rw-r--r--plugins/Dropbox/src/dropbox_utils.cpp24
-rw-r--r--plugins/Dropbox/src/version.h2
8 files changed, 87 insertions, 156 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp
index c8c6b6eb81..880f8a07c8 100644
--- a/plugins/Dropbox/src/dropbox.cpp
+++ b/plugins/Dropbox/src/dropbox.cpp
@@ -40,11 +40,9 @@ MCONTACT CDropbox::GetDefaultContact()
if (!hDefaultContact)
hDefaultContact = db_find_first(MODULE);
- if (!hDefaultContact)
- {
+ if (!hDefaultContact) {
hDefaultContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (!Proto_AddToContact(hDefaultContact, MODULE))
- {
+ if (!Proto_AddToContact(hDefaultContact, MODULE)) {
db_set_s(NULL, MODULE, "Nick", MODULE);
db_set_s(hDefaultContact, MODULE, "Nick", MODULE);
db_set_ws(hDefaultContact, "CList", "MyHandle", L"Dropbox");
@@ -80,48 +78,42 @@ void CDropbox::RequestAccountInfo(void *p)
db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
JSONNode display_name = root.at("display_name");
- if (!display_name.empty())
- {
+ 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));
+ if (pos != -1) {
+ db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos + 1));
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
}
- else
- {
+ else {
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
db_unset(hContact, MODULE, "LastName");
}
}
JSONNode country = root.at("country");
- if (!country.empty())
- {
+ if (!country.empty()) {
std::string isocode = country.as_string();
if (isocode.empty())
db_unset(hContact, MODULE, "Country");
- else
- {
+ else {
char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
db_set_s(hContact, MODULE, "Country", szCountry);
}
}
JSONNode quota_info = root.at("quota_info");
- if (!quota_info.empty())
- {
+ if (!quota_info.empty()) {
ULONG lTotalQuota = quota_info.at("quota").as_int();
ULONG lNormalQuota = quota_info.at("normal").as_int();
ULONG lSharedQuota = quota_info.at("shared").as_int();
-
+
db_set_dw(hContact, MODULE, "SharedQuota", lSharedQuota);
db_set_dw(hContact, MODULE, "NormalQuota", lNormalQuota);
db_set_dw(hContact, MODULE, "TotalQuota", lTotalQuota);
-
- db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota)/(1024*1024), lTotalQuota/(1024*1024)));
+
+ db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024)));
}
}
@@ -156,8 +148,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
GetAccessTokenRequest request(requestToken);
NLHR_PTR response(request.Send(instance->hNetlibConnection));
- if (response == NULL)
- {
+ if (response == NULL) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText(HTTP_STATUS_ERROR));
if (hwndDlg)
SetDlgItemText(hwndDlg, IDC_AUTH_STATUS, TranslateT("server does not respond"));
@@ -167,8 +158,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
}
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- {
+ if (root.empty()) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText((HTTP_STATUS)response->resultCode));
if (hwndDlg)
SetDlgItemText(hwndDlg, IDC_AUTH_STATUS, TranslateT("server does not respond"));
@@ -178,8 +168,7 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
}
JSONNode node = root.at("error_description");
- if (node != JSONNULL)
- {
+ if (node != JSONNULL) {
ptrT error_description(mir_a2t_cp(node.as_string().c_str(), CP_UTF8));
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, HttpStatusToText((HTTP_STATUS)response->resultCode));
if (hwndDlg)
@@ -194,18 +183,15 @@ UINT CDropbox::RequestAccessTokenAsync(void *owner, void *param)
ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, (WPARAM)ID_STATUS_ONLINE);
MCONTACT hContact = instance->GetDefaultContact();
- if (hContact)
- {
+ if (hContact) {
if (db_get_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE)
db_set_w(hContact, MODULE, "Status", ID_STATUS_ONLINE);
}
- try
- {
+ try {
RequestAccountInfo(instance);
}
- catch (TransferException &ex)
- {
+ catch (TransferException &ex) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
return 0;
}
diff --git a/plugins/Dropbox/src/dropbox_commands.cpp b/plugins/Dropbox/src/dropbox_commands.cpp
index 83852b85aa..19b6baeb62 100644
--- a/plugins/Dropbox/src/dropbox_commands.cpp
+++ b/plugins/Dropbox/src/dropbox_commands.cpp
@@ -29,15 +29,13 @@ void CDropbox::CommandContent(void *arg)
GetMetadataRequest request(token, encodedPath);
NLHR_PTR response(request.Send(param->instance->hNetlibConnection));
- if (response == NULL || response->resultCode != HTTP_STATUS_OK)
- {
+ if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- {
+ if (root.empty()) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
@@ -46,14 +44,11 @@ void CDropbox::CommandContent(void *arg)
bool isDir = root.at("is_dir").as_bool();
if (!isDir)
message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is file")));
- else
- {
+ else {
JSONNode content = root.at("contents").as_array();
- for (size_t i = 0; i < content.size(); i++)
- {
+ for (size_t i = 0; i < content.size(); i++) {
JSONNode item = content[i];
- if (item.empty())
- {
+ if (item.empty()) {
if (i == 0)
message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is empty")));
break;
@@ -73,8 +68,7 @@ void CDropbox::CommandShare(void *arg)
CommandParam *param = (CommandParam*)arg;
char *path = (char*)param->data;
- if (path == NULL)
- {
+ if (path == NULL) {
CMStringA error(FORMAT, T2Utf(TranslateT("\"%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());
@@ -88,15 +82,13 @@ void CDropbox::CommandShare(void *arg)
ShareRequest request(token, encodedPath, useShortUrl);
NLHR_PTR response(request.Send(param->instance->hNetlibConnection));
- if (response == NULL || response->resultCode != HTTP_STATUS_OK)
- {
+ if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- {
+ if (root.empty()) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
@@ -111,8 +103,7 @@ void CDropbox::CommandDelete(void *arg)
CommandParam *param = (CommandParam*)arg;
char *path = (char*)param->data;
- if (path == NULL)
- {
+ if (path == NULL) {
CMStringA error(FORMAT, T2Utf(TranslateT("\"%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());
@@ -124,15 +115,13 @@ void CDropbox::CommandDelete(void *arg)
DeleteRequest request(token, encodedPath);
NLHR_PTR response(request.Send(param->instance->hNetlibConnection));
- if (response == NULL || response->resultCode != HTTP_STATUS_OK)
- {
+ if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
JSONNode root = JSONNode::parse(response->pData);
- if (root.empty())
- {
+ if (root.empty()) {
ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
return;
}
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp
index dd7ad44426..f8679362c6 100644
--- a/plugins/Dropbox/src/dropbox_events.cpp
+++ b/plugins/Dropbox/src/dropbox_events.cpp
@@ -22,8 +22,7 @@ int CDropbox::OnModulesLoaded(WPARAM, LPARAM)
WORD status = ProtoGetStatus(0, 0);
ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, status);
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
+ if (ServiceExists(MS_BB_ADDBUTTON)) {
BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
@@ -42,8 +41,7 @@ int CDropbox::OnModulesLoaded(WPARAM, LPARAM)
int CDropbox::OnPreShutdown(WPARAM, LPARAM)
{
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
+ if (ServiceExists(MS_BB_ADDBUTTON)) {
BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
@@ -56,8 +54,7 @@ int CDropbox::OnPreShutdown(WPARAM, LPARAM)
int CDropbox::OnContactDeleted(WPARAM hContact, LPARAM)
{
- if (mir_strcmpi(GetContactProto(hContact), MODULE) == 0)
- {
+ if (mir_strcmpi(GetContactProto(hContact), MODULE) == 0) {
if (HasAccessToken())
DestroyAccessToken();
hDefaultContact = NULL;
@@ -68,8 +65,7 @@ int CDropbox::OnContactDeleted(WPARAM hContact, LPARAM)
int CDropbox::OnSrmmWindowOpened(WPARAM, LPARAM lParam)
{
MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
- if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact)
- {
+ if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact) {
char *proto = GetContactProto(ev->hContact);
bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE;
WORD status = db_get_w(ev->hContact, proto, "Status", ID_STATUS_OFFLINE);
@@ -93,8 +89,7 @@ int CDropbox::OnSrmmWindowOpened(WPARAM, LPARAM lParam)
int CDropbox::OnTabSrmmButtonPressed(WPARAM, LPARAM lParam)
{
CustomButtonClickData *cbc = (CustomButtonClickData *)lParam;
- if (!mir_strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == BBB_ID_FILE_SEND && cbc->hContact)
- {
+ if (!mir_strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == BBB_ID_FILE_SEND && cbc->hContact) {
hTransferContact = cbc->hContact;
hTransferWindow = (HWND)CallService(MS_FILE_SENDFILE, GetDefaultContact(), 0);
@@ -125,8 +120,7 @@ void __stdcall EnableTabSrmmButtonSync(void *arg)
int CDropbox::OnFileDialogCancelled(WPARAM, LPARAM lParam)
{
HWND hwnd = (HWND)lParam;
- if (hTransferWindow == hwnd)
- {
+ if (hTransferWindow == hwnd) {
CallFunctionAsync(EnableTabSrmmButtonSync, (void*)hTransferContact);
hTransferContact = 0;
hTransferWindow = 0;
@@ -138,8 +132,7 @@ int CDropbox::OnFileDialogCancelled(WPARAM, LPARAM lParam)
int CDropbox::OnFileDialogSuccessed(WPARAM, LPARAM lParam)
{
HWND hwnd = (HWND)lParam;
- if (hTransferWindow == hwnd)
- {
+ if (hTransferWindow == hwnd) {
CallFunctionAsync(EnableTabSrmmButtonSync, (void*)hTransferContact);
hTransferWindow = 0;
}
@@ -154,23 +147,20 @@ int CDropbox::OnProtoAck(WPARAM, LPARAM lParam)
if (!mir_strcmp(ack->szModule, MODULE))
return 0; // don't rebroadcast our own acks
- if (ack->type == ACKTYPE_STATUS)
- {
+ if (ack->type == ACKTYPE_STATUS) {
WORD status = ack->lParam;
bool canSendOffline = (CallProtoService(ack->szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0;
MessageWindowInputData msgwi = { sizeof(msgwi) };
msgwi.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
- for (MCONTACT hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule))
- {
+ for (MCONTACT hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule)) {
msgwi.hContact = hContact;
MessageWindowData msgw;
msgw.cbSize = sizeof(msgw);
- if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgwi, (LPARAM)&msgw) && msgw.uState & MSG_WINDOW_STATE_EXISTS)
- {
+ if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&msgwi, (LPARAM)&msgw) && msgw.uState & MSG_WINDOW_STATE_EXISTS) {
BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
bbd.dwButtonID = BBB_ID_FILE_SEND;
diff --git a/plugins/Dropbox/src/dropbox_menus.cpp b/plugins/Dropbox/src/dropbox_menus.cpp
index 4740d75570..7fd0c9a3cb 100644
--- a/plugins/Dropbox/src/dropbox_menus.cpp
+++ b/plugins/Dropbox/src/dropbox_menus.cpp
@@ -27,22 +27,20 @@ void CDropbox::InitializeMenus()
int CDropbox::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
- if (!hContact)
- return 0;
-
bool bShow = false;
- if (HasAccessToken() && !hTransferContact && hContact != GetDefaultContact())
- {
- char *proto = GetContactProto(hContact);
- bool isContact = db_get_b(hContact, proto, "ChatRoom", 0) == 0;
- if (proto && isContact)
- {
- bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE;
- WORD status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
- bool canSendOffline = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0;
- if (isProtoOnline && (status != ID_STATUS_OFFLINE || canSendOffline))
- bShow = true;
+ char *proto = GetContactProto(hContact);
+ if (proto != NULL) {
+ bool bHasIM = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) != 0;
+ if (bHasIM && HasAccessToken() && !hTransferContact && hContact != GetDefaultContact()) {
+ bool isContact = db_get_b(hContact, proto, "ChatRoom", 0) == 0;
+ if (isContact) {
+ bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE;
+ WORD status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
+ bool canSendOffline = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0;
+ if (isProtoOnline && (status != ID_STATUS_OFFLINE || canSendOffline))
+ bShow = true;
+ }
}
}
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index ce27720305..d4cdd244c7 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -10,8 +10,7 @@ HANDLE CDropbox::CreateProtoServiceFunctionObj(const char *szService, MIRANDASER
INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM)
{
- switch (wParam)
- {
+ switch (wParam) {
case PFLAGNUM_1:
return PF1_IM | PF1_FILESEND;
case PFLAGNUM_2:
@@ -25,8 +24,7 @@ INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM)
INT_PTR CDropbox::ProtoGetName(WPARAM wParam, LPARAM lParam)
{
- if (lParam)
- {
+ if (lParam) {
mir_strncpy((char *)lParam, MODULE, wParam);
return 0;
}
@@ -48,8 +46,7 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA*)lParam;
- if (!HasAccessToken())
- {
+ if (!HasAccessToken()) {
ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send files when you are not authorized.");
return 0;
}
@@ -62,8 +59,7 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
TCHAR **paths = (TCHAR**)pccsd->lParam;
- for (int i = 0; paths[i]; i++)
- {
+ for (int i = 0; paths[i]; i++) {
if (PathIsDirectory(paths[i]))
ftp->totalFolders++;
else
@@ -76,12 +72,9 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
ftp->pfts.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * (ftp->pfts.totalFiles + 1));
ftp->pfts.ptszFiles[ftp->pfts.totalFiles] = NULL;
- for (int i = 0, j = 0, k = 0; paths[i]; i++)
- {
- if (PathIsDirectory(paths[i]))
- {
- if (!ftp->relativePathStart)
- {
+ for (int i = 0, j = 0, k = 0; paths[i]; i++) {
+ if (PathIsDirectory(paths[i])) {
+ if (!ftp->relativePathStart) {
TCHAR *rootFolder = paths[j];
TCHAR *relativePath = _tcsrchr(rootFolder, '\\') + 1;
ftp->relativePathStart = relativePath - rootFolder;
@@ -91,10 +84,8 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM, LPARAM lParam)
j++;
}
- else
- {
- if (!ftp->pfts.tszWorkingDir)
- {
+ else {
+ if (!ftp->pfts.tszWorkingDir) {
TCHAR *path = paths[j];
int length = _tcsrchr(path, '\\') - path;
ftp->pfts.tszWorkingDir = (TCHAR*)mir_alloc(sizeof(TCHAR) * (length + 1));
@@ -143,15 +134,13 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
{
CCSDATA *pccsd = (CCSDATA*)lParam;
- if (!HasAccessToken())
- {
+ if (!HasAccessToken()) {
ProtoBroadcastAck(MODULE, pccsd->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send messages when you are not authorized.");
return 0;
}
char *szMessage = (char*)pccsd->lParam;
- if (*szMessage == '/')
- {
+ if (*szMessage == '/') {
// parse commands
char *sep = strchr(szMessage, ' ');
if (sep != NULL) *sep = 0;
@@ -169,10 +158,8 @@ INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
{ "delete", &CDropbox::CommandDelete }
};
- for (int i = 0; i < _countof(commands); i++)
- {
- if (!mir_strcmp(szMessage+1, commands[i].szCommand))
- {
+ for (int i = 0; i < _countof(commands); i++) {
+ if (!mir_strcmp(szMessage + 1, commands[i].szCommand)) {
ULONG messageId = InterlockedIncrement(&hMessageProcess);
CommandParam *param = new CommandParam();
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index e1fe957b05..09fec2daf8 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -35,7 +35,7 @@ void CDropbox::SendFileChunkedNext(const char *data, size_t size, const char *up
NLHR_PTR response(request.Send(hNetlibConnection));
HandleHttpResponseError(response);
-
+
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
return;
@@ -76,7 +76,7 @@ void CDropbox::CreateDownloadUrl(const char *path, char *url)
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
return;
-
+
JSONNode node = root.at("url");
mir_strcpy(url, node.as_string().c_str());
}
@@ -88,20 +88,16 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ftp->hProcess, 0);
- try
- {
- if (ftp->ptszFolders)
- {
- for (int i = 0; ftp->ptszFolders[i]; i++)
- {
- if(ftp->isTerminated)
+ try {
+ if (ftp->ptszFolders) {
+ for (int i = 0; ftp->ptszFolders[i]; i++) {
+ if (ftp->isTerminated)
throw TransferException("Transfer was terminated");
ptrA utf8_folderName(mir_utf8encodeW(ftp->ptszFolders[i]));
instance->CreateFolder(utf8_folderName);
- if (!strchr(utf8_folderName, '\\'))
- {
+ if (!strchr(utf8_folderName, '\\')) {
char url[MAX_PATH];
instance->CreateDownloadUrl(utf8_folderName, url);
ftp->AddUrl(url);
@@ -109,8 +105,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
}
}
- for (int i = 0; ftp->pfts.ptszFiles[i]; i++)
- {
+ for (int i = 0; ftp->pfts.ptszFiles[i]; i++) {
if (ftp->isTerminated)
throw TransferException("Transfer was terminated");
@@ -142,10 +137,8 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
chunkSize = DROPBOX_FILE_CHUNK_SIZE;
char *data = (char*)mir_alloc(chunkSize);
- while (!feof(hFile) && fileSize != offset)
- {
- try
- {
+ while (!feof(hFile) && fileSize != offset) {
+ try {
if (ferror(hFile))
throw TransferException("Error while file sending");
@@ -162,8 +155,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
ftp->pfts.currentFileProgress += size;
ftp->pfts.totalProgress += size;
}
- catch (TransferException&)
- {
+ catch (TransferException&) {
mir_free(data);
fclose(hFile);
throw;
@@ -181,8 +173,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
instance->SendFileChunkedLast(utf8_fileName, uploadId);
- if (!_tcschr(fileName, L'\\'))
- {
+ if (!_tcschr(fileName, L'\\')) {
char url[MAX_PATH];
instance->CreateDownloadUrl(utf8_fileName, url);
ftp->AddUrl(url);
@@ -194,8 +185,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg)
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ftp->hProcess, 0);
}
}
- catch (TransferException &ex)
- {
+ catch (TransferException &ex) {
Netlib_Logf(instance->hNetlibConnection, "%s: %s", MODULE, ex.what());
ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ftp->hProcess, 0);
return ACKRESULT_FAILED;
@@ -214,8 +204,7 @@ UINT CDropbox::SendFilesAndReportAsync(void *owner, void *arg)
FileTransferParam *ftp = (FileTransferParam*)arg;
int res = SendFilesAsync(owner, arg);
- if (res)
- {
+ if (res) {
instance->transfers.remove(ftp);
delete ftp;
return res;
diff --git a/plugins/Dropbox/src/dropbox_utils.cpp b/plugins/Dropbox/src/dropbox_utils.cpp
index edde1243b6..aee70273eb 100644
--- a/plugins/Dropbox/src/dropbox_utils.cpp
+++ b/plugins/Dropbox/src/dropbox_utils.cpp
@@ -2,8 +2,7 @@
char* CDropbox::HttpStatusToText(HTTP_STATUS status)
{
- switch (status)
- {
+ switch (status) {
case HTTP_STATUS_ERROR:
return "Server does not respond";
case HTTP_STATUS_OK:
@@ -53,16 +52,14 @@ MEVENT CDropbox::AddEventToDb(MCONTACT hContact, WORD type, DWORD flags, DWORD c
void CDropbox::SendToContact(MCONTACT hContact, const char* data)
{
- if (hContact == GetDefaultContact())
- {
+ if (hContact == GetDefaultContact()) {
char *message = mir_utf8encode(data);
AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF, mir_strlen(message), (PBYTE)message);
return;
}
const char *szProto = GetContactProto(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE)
- {
+ if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) {
ptrT tszChatRoom(db_get_tsa(hContact, szProto, "ChatRoomID"));
GCDEST gcd = { szProto, tszChatRoom, GC_EVENT_SENDMESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -75,8 +72,7 @@ void CDropbox::SendToContact(MCONTACT hContact, const char* data)
return;
}
- if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)data) != ACKRESULT_FAILED)
- {
+ if (CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)data) != ACKRESULT_FAILED) {
char *message = mir_utf8encode(data);
AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, mir_strlen(message), (PBYTE)message);
}
@@ -89,8 +85,7 @@ void CDropbox::PasteToInputArea(MCONTACT hContact, const char* data)
mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
MessageWindowData mwd = { sizeof(MessageWindowData) };
- if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd))
- {
+ if (!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd)) {
HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
@@ -101,16 +96,13 @@ void CDropbox::PasteToInputArea(MCONTACT hContact, const char* data)
void CDropbox::PasteToClipboard(const char* data)
{
- if (OpenClipboard(NULL))
- {
+ if (OpenClipboard(NULL)) {
EmptyClipboard();
size_t size = sizeof(TCHAR) * (mir_strlen(data) + 1);
HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
- if (hClipboardData)
- {
+ if (hClipboardData) {
TCHAR *pchData = (TCHAR*)GlobalLock(hClipboardData);
- if (pchData)
- {
+ if (pchData) {
memcpy(pchData, (TCHAR*)data, size);
GlobalUnlock(hClipboardData);
SetClipboardData(CF_TEXT, hClipboardData);
diff --git a/plugins/Dropbox/src/version.h b/plugins/Dropbox/src/version.h
index caacfd20a7..b333726674 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 0
-#define __BUILD_NUM 7
+#define __BUILD_NUM 8
#include <stdver.h>