diff options
Diffstat (limited to 'plugins/CloudFile')
-rw-r--r-- | plugins/CloudFile/src/file_transfer.h | 6 | ||||
-rw-r--r-- | plugins/CloudFile/src/services.cpp | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/plugins/CloudFile/src/file_transfer.h b/plugins/CloudFile/src/file_transfer.h index ab83d7db2e..ced06a2f04 100644 --- a/plugins/CloudFile/src/file_transfer.h +++ b/plugins/CloudFile/src/file_transfer.h @@ -91,10 +91,10 @@ public: return m_description.GetString(); } - const int GetSharedLinks(const char **result) const + const const char** GetSharedLinks(size_t &count) const { - result = (const char**)m_links.getArray(); - return m_links.getCount(); + count = m_links.getCount(); + return (const char**)m_links.getArray(); } void Terminate() diff --git a/plugins/CloudFile/src/services.cpp b/plugins/CloudFile/src/services.cpp index 76f35938b4..039c1ce19f 100644 --- a/plugins/CloudFile/src/services.cpp +++ b/plugins/CloudFile/src/services.cpp @@ -19,15 +19,18 @@ static INT_PTR GetService(WPARAM wParam, LPARAM lParam) accountName = db_get_sa(NULL, MODULE, "DefaultService"); if (accountName == nullptr) return 2; + CCloudServiceSearch search(accountName); CCloudService *service = Services.find(&search); if (service == nullptr) return 3; + CFSERVICEINFO *info = (CFSERVICEINFO*)lParam; if (info != nullptr) { info->accountName = service->GetAccountName(); info->userName = service->GetUserName(); } + return 0; } @@ -36,6 +39,7 @@ static INT_PTR EnumServices(WPARAM wParam, LPARAM lParam) CFSERVICEINFO info = {}; enumCFServiceFunc enumFunc = (enumCFServiceFunc)wParam; void *param = (void*)lParam; + for (auto &service : Services) { info.accountName = service->GetAccountName(); info.userName = service->GetUserName(); @@ -43,6 +47,7 @@ static INT_PTR EnumServices(WPARAM wParam, LPARAM lParam) if (res != 0) return res; } + return 0; } @@ -52,11 +57,12 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) if (uploadData == nullptr) return 1; - ptrA accountName(mir_strdup((char*)wParam)); - if (!accountName || !mir_strlen(uploadData->accountName)) + ptrA accountName(mir_strdup(uploadData->accountName)); + if (!mir_strlen(accountName)) accountName = db_get_sa(NULL, MODULE, "DefaultService"); if (accountName == nullptr) return 2; + CCloudServiceSearch search(uploadData->accountName); CCloudService *service = Services.find(&search); if (service == nullptr) @@ -80,10 +86,9 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) int res = service->Upload(ftp); if (res == ACKRESULT_SUCCESS && lParam) { CFUPLOADRESULT *result = (CFUPLOADRESULT*)lParam; - const char **links = nullptr; - int linkCount = ftp->GetSharedLinks(links); - result->links = (char**)mir_calloc(sizeof(char*) * linkCount); - for (int i = 0; i < linkCount; i++) + const char **links = ftp->GetSharedLinks(result->linkCount); + result->links = (char**)mir_calloc(sizeof(char*) * result->linkCount); + for (int i = 0; i < result->linkCount; i++) result->links[i] = mir_strdup(links[i]); result->description = mir_wstrdup(ftp->GetDescription()); } |