diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-06 00:00:43 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-06 00:00:43 +0300 |
commit | de898be6a2857dababe3eaa2bfb394a9ea92ecbe (patch) | |
tree | 69543eead49b6038d88e14cfc4f4856ca27a1cee | |
parent | 35e2289786a7f1542573d1a58ebc971970ea981c (diff) |
CloudFile: no need to create fake protocol instances just for search
-rw-r--r-- | plugins/CloudFile/src/cloud_file.h | 20 | ||||
-rw-r--r-- | plugins/CloudFile/src/events.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/main.cpp | 1 | ||||
-rw-r--r-- | plugins/CloudFile/src/menus.cpp | 3 | ||||
-rw-r--r-- | plugins/CloudFile/src/services.cpp | 15 | ||||
-rw-r--r-- | plugins/CloudFile/src/srmm.cpp | 3 | ||||
-rw-r--r-- | plugins/CloudFile/src/stdafx.h | 2 |
7 files changed, 17 insertions, 31 deletions
diff --git a/plugins/CloudFile/src/cloud_file.h b/plugins/CloudFile/src/cloud_file.h index 3c6ba9b7ac..8d69e0f864 100644 --- a/plugins/CloudFile/src/cloud_file.h +++ b/plugins/CloudFile/src/cloud_file.h @@ -52,24 +52,4 @@ public: virtual UINT Upload(FileTransferParam *ftp) = 0; }; -class CCloudServiceSearch : public CCloudService -{ -protected: - void HandleJsonError(JSONNode&) override { } - -public: - CCloudServiceSearch(const char *search) - : CCloudService(search, nullptr) { } - - const char* GetModuleName() const override { return nullptr; } - - int GetIconId() const override { return NULL; } - - bool IsLoggedIn() override { return false; } - void Login() override { } - void Logout() override { } - - UINT Upload(FileTransferParam*) override { return 0; } -}; - #endif //_CLOUD_SERVICE_H_
\ No newline at end of file diff --git a/plugins/CloudFile/src/events.cpp b/plugins/CloudFile/src/events.cpp index aa79ee3288..f8770b5574 100644 --- a/plugins/CloudFile/src/events.cpp +++ b/plugins/CloudFile/src/events.cpp @@ -36,7 +36,8 @@ static int OnFileDialogCanceled(WPARAM hContact, LPARAM) int OnModulesLoaded(WPARAM, LPARAM) { - + InitializeMenus(); + HookEvent(ME_PROTO_ACK, OnProtoAck); // options @@ -51,6 +52,5 @@ int OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_MSG_BUTTONPRESSED, OnSrmmButtonPressed); HookTemporaryEvent(ME_MSG_TOOLBARLOADED, OnSrmmToolbarLoaded); - return 0; }
\ No newline at end of file diff --git a/plugins/CloudFile/src/main.cpp b/plugins/CloudFile/src/main.cpp index c01ca5eba7..91d8a82f7c 100644 --- a/plugins/CloudFile/src/main.cpp +++ b/plugins/CloudFile/src/main.cpp @@ -35,7 +35,6 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); InitializeIcons(); - InitializeMenus(); InitializeServices(); return 0; diff --git a/plugins/CloudFile/src/menus.cpp b/plugins/CloudFile/src/menus.cpp index 311b17b7e6..c0ed61285b 100644 --- a/plugins/CloudFile/src/menus.cpp +++ b/plugins/CloudFile/src/menus.cpp @@ -17,8 +17,7 @@ void InitializeMenus() ptrA defaultService(db_get_sa(NULL, MODULE, "DefaultService")); if (defaultService) { - CCloudServiceSearch search(defaultService); - CCloudService *service = Services.find(&search); + CCloudService *service = FindService(defaultService); if (service) { mi.name.a = LPGEN("Upload"); mi.pszService = MODULE "/Default/Upload"; diff --git a/plugins/CloudFile/src/services.cpp b/plugins/CloudFile/src/services.cpp index 0b9e062b09..28cda47967 100644 --- a/plugins/CloudFile/src/services.cpp +++ b/plugins/CloudFile/src/services.cpp @@ -7,6 +7,15 @@ static int CompareServices(const CCloudService *p1, const CCloudService *p2) LIST<CCloudService> Services(10, CompareServices); +CCloudService* FindService(const char *szProto) +{ + for (auto &it : Services) + if (!mir_strcmp(it->GetAccountName(), szProto)) + return it; + + return nullptr; +} + static INT_PTR GetService(WPARAM wParam, LPARAM lParam) { ptrA accountName(mir_strdup((char*)wParam)); @@ -15,8 +24,7 @@ static INT_PTR GetService(WPARAM wParam, LPARAM lParam) if (accountName == nullptr) return 2; - CCloudServiceSearch search(accountName); - CCloudService *service = Services.find(&search); + CCloudService *service = FindService(accountName); if (service == nullptr) return 3; @@ -58,8 +66,7 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) if (accountName == nullptr) return 2; - CCloudServiceSearch search(uploadData->accountName); - CCloudService *service = Services.find(&search); + CCloudService *service = FindService(uploadData->accountName); if (service == nullptr) return 3; diff --git a/plugins/CloudFile/src/srmm.cpp b/plugins/CloudFile/src/srmm.cpp index 8e400bbdbf..2a49cdb7ef 100644 --- a/plugins/CloudFile/src/srmm.cpp +++ b/plugins/CloudFile/src/srmm.cpp @@ -45,8 +45,7 @@ int OnSrmmButtonPressed(WPARAM, LPARAM lParam) if (cbc->flags != BBCF_ARROWCLICKED) { ptrA defaultService(db_get_sa(NULL, MODULE, "DefaultService")); if (defaultService) { - CCloudServiceSearch search(defaultService); - CCloudService *service = Services.find(&search); + CCloudService *service = FindService(defaultService); if (service) service->OpenUploadDialog(cbc->hContact); return 0; diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index b35ab0ed8c..b6ffbed338 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -113,4 +113,6 @@ void PasteToInputArea(MCONTACT hContact, const wchar_t *data); void PasteToClipboard(const wchar_t *data); void Report(MCONTACT hContact, const wchar_t *data); +CCloudService* FindService(const char *szProto); + #endif //_COMMON_H_
\ No newline at end of file |