diff options
Diffstat (limited to 'plugins/CloudFile/src')
-rw-r--r-- | plugins/CloudFile/src/Services/dropbox_service.cpp | 26 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/google_service.cpp | 24 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_service.cpp | 22 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/yandex_service.cpp | 26 | ||||
-rw-r--r-- | plugins/CloudFile/src/cloud_file.cpp | 28 | ||||
-rw-r--r-- | plugins/CloudFile/src/cloud_file.h | 7 | ||||
-rw-r--r-- | plugins/CloudFile/src/events.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/menus.cpp | 32 | ||||
-rw-r--r-- | plugins/CloudFile/src/services.cpp | 9 | ||||
-rw-r--r-- | plugins/CloudFile/src/stdafx.h | 3 |
11 files changed, 107 insertions, 78 deletions
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp index 16a9ee659f..f92787dec9 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.cpp +++ b/plugins/CloudFile/src/Services/dropbox_service.cpp @@ -61,17 +61,17 @@ unsigned CDropboxService::RequestAccessTokenThread(void *owner, void *param) GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken)); DropboxAPI::GetAccessTokenRequest request(requestToken); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); if (response == nullptr || response->resultCode != HTTP_CODE_OK) { - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError()); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError()); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } JSONNode root = JSONNode::parse(response->pData); if (root.empty()) { - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification((wchar_t*)error_description, MB_ICONERROR); return 0; } @@ -79,7 +79,7 @@ unsigned CDropboxService::RequestAccessTokenThread(void *owner, void *param) JSONNode node = root.at("error_description"); if (!node.isnull()) { ptrW error_description(mir_a2u_cp(node.as_string().c_str(), CP_UTF8)); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification((wchar_t*)error_description, MB_ICONERROR); return 0; } @@ -101,7 +101,7 @@ unsigned CDropboxService::RevokeAccessTokenThread(void *param) ptrA token(db_get_sa(NULL, service->GetAccountName(), "TokenSecret")); DropboxAPI::RevokeAccessTokenRequest request(token); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); return 0; } @@ -120,7 +120,7 @@ void CDropboxService::UploadFile(const char *data, size_t size, char *path) ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); BYTE strategy = db_get_b(NULL, MODULE, "ConflictStrategy", OnConflict::REPLACE); DropboxAPI::UploadFileRequest request(token, path, data, size, (OnConflict)strategy); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("path_lower"); @@ -131,7 +131,7 @@ void CDropboxService::CreateUploadSession(const char *chunk, size_t chunkSize, c { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); DropboxAPI::CreateUploadSessionRequest request(token, chunk, chunkSize); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("session_id"); @@ -142,7 +142,7 @@ void CDropboxService::UploadFileChunk(const char *chunk, size_t chunkSize, const { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); DropboxAPI::UploadFileChunkRequest request(token, sessionId, offset, chunk, chunkSize); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); } @@ -152,7 +152,7 @@ void CDropboxService::CommitUploadSession(const char *data, size_t size, const c ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); BYTE strategy = db_get_b(NULL, MODULE, "ConflictStrategy", OnConflict::REPLACE); DropboxAPI::CommitUploadSessionRequest request(token, sessionId, offset, path, data, size, (OnConflict)strategy); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("path_lower"); @@ -163,7 +163,7 @@ void CDropboxService::CreateFolder(const char *path) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); DropboxAPI::CreateFolderRequest request(token, path); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -178,7 +178,7 @@ void CDropboxService::CreateSharedLink(const char *path, char *url) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); DropboxAPI::CreateSharedLinkRequest shareRequest(token, path); - NLHR_PTR response(shareRequest.Send(hConnection)); + NLHR_PTR response(shareRequest.Send(m_hConnection)); if (response == nullptr) throw Exception(HttpStatusToError()); @@ -206,7 +206,7 @@ void CDropboxService::CreateSharedLink(const char *path, char *url) throw Exception(tag.c_str()); DropboxAPI::GetSharedLinkRequest getRequest(token, path); - response = getRequest.Send(hConnection); + response = getRequest.Send(m_hConnection); root = GetJsonResponse(response); @@ -303,7 +303,7 @@ UINT CDropboxService::Upload(FileTransferParam *ftp) } while (ftp->NextFile()); } catch (Exception &ex) { - Netlib_Logf(hConnection, "%s: %s", MODULE, ex.what()); + Netlib_Logf(m_hConnection, "%s: %s", MODULE, ex.what()); ftp->SetStatus(ACKRESULT_FAILED); return ACKRESULT_FAILED; } diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp index 3877506b0f..dda31097da 100644 --- a/plugins/CloudFile/src/Services/google_service.cpp +++ b/plugins/CloudFile/src/Services/google_service.cpp @@ -46,7 +46,7 @@ void CGDriveService::Login() ptrA refreshToken(db_get_sa(NULL, GetAccountName(), "RefreshToken")); if (token && refreshToken && refreshToken[0]) { GDriveAPI::RefreshTokenRequest request(refreshToken); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); @@ -81,21 +81,21 @@ unsigned CGDriveService::RequestAccessTokenThread(void *owner, void *param) GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken)); GDriveAPI::GetAccessTokenRequest request(requestToken); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); if (response == nullptr || response->resultCode != HTTP_CODE_OK) { const char *error = response->dataLength ? response->pData : service->HttpStatusToError(response->resultCode); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), error); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), error); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } JSONNode root = JSONNode::parse(response->pData); if (root.empty()) { - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } @@ -103,7 +103,7 @@ unsigned CGDriveService::RequestAccessTokenThread(void *owner, void *param) JSONNode node = root.at("error_description"); if (!node.isnull()) { ptrW error_description(mir_a2u_cp(node.as_string().c_str(), CP_UTF8)); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification((wchar_t*)error_description, MB_ICONERROR); return 0; } @@ -131,7 +131,7 @@ unsigned CGDriveService::RevokeAccessTokenThread(void *param) ptrA token(db_get_sa(NULL, service->GetAccountName(), "TokenSecret")); GDriveAPI::RevokeAccessTokenRequest request(token); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); return 0; } @@ -149,7 +149,7 @@ void CGDriveService::UploadFile(const char *parentId, const char *name, const ch { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); GDriveAPI::UploadFileRequest request(token, parentId, name, data, size); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("id"); @@ -160,7 +160,7 @@ void CGDriveService::CreateUploadSession(const char *parentId, const char *name, { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); GDriveAPI::CreateUploadSessionRequest request(token, parentId, name); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -181,7 +181,7 @@ void CGDriveService::CreateUploadSession(const char *parentId, const char *name, void CGDriveService::UploadFileChunk(const char *uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize, char *fileId) { GDriveAPI::UploadFileChunkRequest request(uploadUri, chunk, chunkSize, offset, fileSize); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -202,7 +202,7 @@ void CGDriveService::CreateFolder(const char *path, char *folderId) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); GDriveAPI::CreateFolderRequest request(token, path); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("id"); @@ -213,7 +213,7 @@ void CGDriveService::CreateSharedLink(const char *itemId, char *url) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); GDriveAPI::GrantPermissionsRequest request(token, itemId); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -296,7 +296,7 @@ UINT CGDriveService::Upload(FileTransferParam *ftp) } while (ftp->NextFile()); } catch (Exception &ex) { - Netlib_Logf(hConnection, "%s: %s", MODULE, ex.what()); + Netlib_Logf(m_hConnection, "%s: %s", MODULE, ex.what()); ftp->SetStatus(ACKRESULT_FAILED); return ACKRESULT_FAILED; } diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp index ec211f1244..6f5dfca836 100644 --- a/plugins/CloudFile/src/Services/microsoft_service.cpp +++ b/plugins/CloudFile/src/Services/microsoft_service.cpp @@ -46,7 +46,7 @@ void COneDriveService::Login() ptrA refreshToken(db_get_sa(NULL, GetAccountName(), "RefreshToken")); if (token && refreshToken && refreshToken[0]) { OneDriveAPI::RefreshTokenRequest request(refreshToken); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); @@ -83,21 +83,21 @@ unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param) GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken)); OneDriveAPI::GetAccessTokenRequest request(requestToken); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); if (response == nullptr || response->resultCode != HTTP_CODE_OK) { const char *error = response->dataLength ? response->pData : service->HttpStatusToError(response->resultCode); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), error); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), error); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } JSONNode root = JSONNode::parse(response->pData); if (root.empty()) { - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } @@ -105,7 +105,7 @@ unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param) JSONNode node = root.at("error_description"); if (!node.isnull()) { ptrW error_description(mir_a2u_cp(node.as_string().c_str(), CP_UTF8)); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification((wchar_t*)error_description, MB_ICONERROR); return 0; } @@ -143,7 +143,7 @@ void COneDriveService::UploadFile(const char *parentId, const char *name, const OneDriveAPI::UploadFileRequest *request = mir_strlen(parentId) ? new OneDriveAPI::UploadFileRequest(token, parentId, name, data, size, (OnConflict)strategy) : new OneDriveAPI::UploadFileRequest(token, name, data, size, (OnConflict)strategy); - NLHR_PTR response(request->Send(hConnection)); + NLHR_PTR response(request->Send(m_hConnection)); delete request; JSONNode root = GetJsonResponse(response); @@ -158,7 +158,7 @@ void COneDriveService::CreateUploadSession(const char *parentId, const char *nam OneDriveAPI::CreateUploadSessionRequest *request = mir_strlen(parentId) ? new OneDriveAPI::CreateUploadSessionRequest(token, parentId, name, (OnConflict)strategy) : new OneDriveAPI::CreateUploadSessionRequest(token, name, (OnConflict)strategy); - NLHR_PTR response(request->Send(hConnection)); + NLHR_PTR response(request->Send(m_hConnection)); delete request; JSONNode root = GetJsonResponse(response); @@ -169,7 +169,7 @@ void COneDriveService::CreateUploadSession(const char *parentId, const char *nam void COneDriveService::UploadFileChunk(const char *uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize, char *fileId) { OneDriveAPI::UploadFileChunkRequest request(uploadUri, chunk, chunkSize, offset, fileSize); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -190,7 +190,7 @@ void COneDriveService::CreateFolder(const char *path, char *folderId) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); OneDriveAPI::CreateFolderRequest request(token, path); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("id"); @@ -201,7 +201,7 @@ void COneDriveService::CreateSharedLink(const char *itemId, char *url) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); OneDriveAPI::CreateSharedLinkRequest request(token, itemId); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("link"); @@ -281,7 +281,7 @@ UINT COneDriveService::Upload(FileTransferParam *ftp) } while (ftp->NextFile()); } catch (Exception &ex) { - Netlib_Logf(hConnection, "%s: %s", MODULE, ex.what()); + Netlib_Logf(m_hConnection, "%s: %s", MODULE, ex.what()); ftp->SetStatus(ACKRESULT_FAILED); return ACKRESULT_FAILED; } diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp index cf4c5786e0..176bcd21a6 100644 --- a/plugins/CloudFile/src/Services/yandex_service.cpp +++ b/plugins/CloudFile/src/Services/yandex_service.cpp @@ -46,7 +46,7 @@ void CYandexService::Login() ptrA refreshToken(db_get_sa(NULL, GetAccountName(), "RefreshToken")); if (token && refreshToken && refreshToken[0]) { YandexAPI::RefreshTokenRequest request(refreshToken); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); @@ -84,21 +84,21 @@ unsigned CYandexService::RequestAccessTokenThread(void *owner, void *param) GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken)); YandexAPI::GetAccessTokenRequest request(requestToken); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); if (response == nullptr || response->resultCode != HTTP_CODE_OK) { const char *error = response->dataLength ? response->pData : service->HttpStatusToError(response->resultCode); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), error); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), error); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } JSONNode root = JSONNode::parse(response->pData); if (root.empty()) { - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification(TranslateT("server does not respond"), MB_ICONERROR); return 0; } @@ -106,7 +106,7 @@ unsigned CYandexService::RequestAccessTokenThread(void *owner, void *param) JSONNode node = root.at("error_description"); if (!node.isnull()) { ptrW error_description(mir_a2u_cp(node.as_string().c_str(), CP_UTF8)); - Netlib_Logf(service->hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); + Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode)); //ShowNotification((wchar_t*)error_description, MB_ICONERROR); return 0; } @@ -134,7 +134,7 @@ unsigned CYandexService::RevokeAccessTokenThread(void *param) ptrA token(db_get_sa(NULL, service->GetAccountName(), "TokenSecret")); YandexAPI::RevokeAccessTokenRequest request(token); - NLHR_PTR response(request.Send(service->hConnection)); + NLHR_PTR response(request.Send(service->m_hConnection)); return 0; } @@ -153,7 +153,7 @@ void CYandexService::CreateUploadSession(const char *path, char *uploadUri) ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); BYTE strategy = db_get_b(NULL, MODULE, "ConflictStrategy", OnConflict::REPLACE); YandexAPI::GetUploadUrlRequest request(token, path, (OnConflict)strategy); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); JSONNode root = GetJsonResponse(response); JSONNode node = root.at("href"); @@ -163,7 +163,7 @@ void CYandexService::CreateUploadSession(const char *path, char *uploadUri) void CYandexService::UploadFile(const char *uploadUri, const char *data, size_t size) { YandexAPI::UploadFileRequest request(uploadUri, data, size); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -176,7 +176,7 @@ void CYandexService::UploadFile(const char *uploadUri, const char *data, size_t void CYandexService::UploadFileChunk(const char *uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize) { YandexAPI::UploadFileChunkRequest request(uploadUri, chunk, chunkSize, offset, fileSize); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); HandleHttpError(response); @@ -191,7 +191,7 @@ void CYandexService::CreateFolder(const char *path) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); YandexAPI::CreateFolderRequest request(token, path); - NLHR_PTR response(request.Send(hConnection)); + NLHR_PTR response(request.Send(m_hConnection)); GetJsonResponse(response); } @@ -200,12 +200,12 @@ void CYandexService::CreateSharedLink(const char *path, char *url) { ptrA token(db_get_sa(NULL, GetAccountName(), "TokenSecret")); YandexAPI::PublishRequest publishRequest(token, path); - NLHR_PTR response(publishRequest.Send(hConnection)); + NLHR_PTR response(publishRequest.Send(m_hConnection)); GetJsonResponse(response); YandexAPI::GetResourcesRequest resourcesRequest(token, path); - response = resourcesRequest.Send(hConnection); + response = resourcesRequest.Send(m_hConnection); JSONNode root = GetJsonResponse(response); JSONNode link = root.at("public_url"); @@ -284,7 +284,7 @@ UINT CYandexService::Upload(FileTransferParam *ftp) } while (ftp->NextFile()); } catch (Exception &ex) { - Netlib_Logf(hConnection, "%s: %s", MODULE, ex.what()); + Netlib_Logf(m_hConnection, "%s: %s", MODULE, ex.what()); ftp->SetStatus(ACKRESULT_FAILED); return ACKRESULT_FAILED; } diff --git a/plugins/CloudFile/src/cloud_file.cpp b/plugins/CloudFile/src/cloud_file.cpp index 7e3652122d..ed265f71aa 100644 --- a/plugins/CloudFile/src/cloud_file.cpp +++ b/plugins/CloudFile/src/cloud_file.cpp @@ -3,17 +3,25 @@ CCloudService::CCloudService(const char *protoName, const wchar_t *userName) : PROTO<CCloudService>(protoName, userName) { + MUUID muidLast = MIID_LAST; + m_hLangpack = GetPluginLangId(muidLast, 0); + NETLIBUSER nlu = {}; nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_UNICODE; nlu.szSettingsModule = (char*)protoName; nlu.szDescriptiveName.w = (wchar_t*)userName; - hConnection = Netlib_RegisterUser(&nlu); + m_hConnection = Netlib_RegisterUser(&nlu); } CCloudService::~CCloudService() { - Netlib_CloseHandle(hConnection); - hConnection = nullptr; + Netlib_CloseHandle(m_hConnection); + m_hConnection = nullptr; +} + +int CCloudService::GetId() const +{ + return m_hLangpack; } const char* CCloudService::GetAccountName() const @@ -36,6 +44,20 @@ DWORD_PTR CCloudService::GetCaps(int type, MCONTACT) } } +int CCloudService::OnEvent(PROTOEVENTTYPE iEventType, WPARAM, LPARAM) +{ + switch (iEventType) { + case EV_PROTO_ONLOAD: + AddServiceMenuItem(this); + return 0; + + case EV_PROTO_ONERASE: + KillModuleMenus(m_hLangpack); + return 0; + } + return 1; +} + void CCloudService::Report(MCONTACT hContact, const wchar_t *data) { if (db_get_b(NULL, MODULE, "UrlAutoSend", 1)) diff --git a/plugins/CloudFile/src/cloud_file.h b/plugins/CloudFile/src/cloud_file.h index 678aabc86f..ebf6a6c6fe 100644 --- a/plugins/CloudFile/src/cloud_file.h +++ b/plugins/CloudFile/src/cloud_file.h @@ -11,8 +11,8 @@ enum OnConflict class CCloudService : public PROTO<CCloudService> { protected: - int id; - HNETLIBUSER hConnection; + int m_hLangpack; + HNETLIBUSER m_hConnection; // utils char* PreparePath(const char *oldPath, char *newPath); @@ -31,11 +31,14 @@ public: virtual ~CCloudService(); DWORD_PTR __cdecl GetCaps(int type, MCONTACT) override; + int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM, LPARAM) override; + int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer) override; HANDLE __cdecl SendFile(MCONTACT hContact, const wchar_t *msg, wchar_t **ppszFiles) override; static INT_PTR SendFileInterceptor(WPARAM wParam, LPARAM lParam); + int GetId() const; virtual const char* GetModuleName() const = 0; const char* GetAccountName() const; const wchar_t* GetUserName() const; diff --git a/plugins/CloudFile/src/events.cpp b/plugins/CloudFile/src/events.cpp index c38f89058c..0812f3f5cf 100644 --- a/plugins/CloudFile/src/events.cpp +++ b/plugins/CloudFile/src/events.cpp @@ -2,8 +2,8 @@ int OnModulesLoaded(WPARAM, LPARAM) { - InitializeIcons(); - InitializeMenus(); + + //InitializeMenus(); // options HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized); diff --git a/plugins/CloudFile/src/main.cpp b/plugins/CloudFile/src/main.cpp index a1dae8c146..6d83c5d98e 100644 --- a/plugins/CloudFile/src/main.cpp +++ b/plugins/CloudFile/src/main.cpp @@ -37,7 +37,9 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_PROTO_ACK, OnProtoAck); HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - InitServices(); + InitializeIcons(); + InitializeMenus(); + InitializeServices(); return 0; } diff --git a/plugins/CloudFile/src/menus.cpp b/plugins/CloudFile/src/menus.cpp index 900e47e636..9bb7ccda8d 100644 --- a/plugins/CloudFile/src/menus.cpp +++ b/plugins/CloudFile/src/menus.cpp @@ -30,29 +30,35 @@ void InitializeMenus() mi.hIcon = LoadIconEx(IDI_UPLOAD); hContactMenu = Menu_AddContactMenuItem(&mi); - if (defaultService) + /*if (defaultService) return; UNSET_UID(mi); mi.root = hContactMenu; - for (int i = 0; i < Services.getCount(); i++) { - CCloudService *service = Services[i]; - CMStringA serviceName(FORMAT, "/%s/Upload", service->GetAccountName()); - mi.pszService = serviceName.GetBuffer(); - mi.flags = CMIF_SYSTEM | CMIF_UNICODE; - mi.name.w = (wchar_t*)service->GetUserName(); - mi.position = i; - mi.hIcolibItem = GetIconHandle(service->GetIconId()); - Menu_AddContactMenuItem(&mi); - CreateServiceFunctionObj(mi.pszService, UploadMenuCommand, service); - } + for (auto &service : Services) + AddServiceMenuItem(service);*/ +} + +void AddServiceMenuItem(const CCloudService *service) +{ + CMenuItem mi; + mi.root = hContactMenu; + CMStringA serviceName(FORMAT, "/%s/Upload", service->GetAccountName()); + mi.pszService = serviceName.GetBuffer(); + mi.hLangpack = service->GetId(); + mi.flags = CMIF_SYSTEM | CMIF_UNICODE; + mi.name.w = (wchar_t*)service->GetUserName(); + mi.position = Services.getCount(); + mi.hIcolibItem = GetIconHandle(service->GetIconId()); + Menu_AddContactMenuItem(&mi); + CreateServiceFunctionObj(mi.pszService, UploadMenuCommand, (void*)service); } int OnPrebuildContactMenu(WPARAM hContact, LPARAM) { - Menu_ShowItem(hContactMenu, CanSendToContact(hContact)); + //Menu_ShowItem(hContactMenu, CanSendToContact(hContact)); return 0; }
\ No newline at end of file diff --git a/plugins/CloudFile/src/services.cpp b/plugins/CloudFile/src/services.cpp index 039c1ce19f..2921296434 100644 --- a/plugins/CloudFile/src/services.cpp +++ b/plugins/CloudFile/src/services.cpp @@ -7,11 +7,6 @@ static int CompareServices(const CCloudService *p1, const CCloudService *p2) LIST<CCloudService> Services(10, CompareServices); -static INT_PTR GetServiceCount(WPARAM, LPARAM) -{ - return Services.getCount(); -} - static INT_PTR GetService(WPARAM wParam, LPARAM lParam) { ptrA accountName(mir_strdup((char*)wParam)); @@ -88,7 +83,7 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) CFUPLOADRESULT *result = (CFUPLOADRESULT*)lParam; const char **links = ftp->GetSharedLinks(result->linkCount); result->links = (char**)mir_calloc(sizeof(char*) * result->linkCount); - for (int i = 0; i < result->linkCount; i++) + for (size_t i = 0; i < result->linkCount; i++) result->links[i] = mir_strdup(links[i]); result->description = mir_wstrdup(ftp->GetDescription()); } @@ -99,7 +94,7 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) return res; } -void InitServices() +void InitializeServices() { PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; pd.type = PROTOTYPE_PROTOCOL; diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index 1e36ae0c91..9fc15e219d 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -74,7 +74,7 @@ public: #include "Services\microsoft_service.h" #include "Services\yandex_service.h" extern LIST<CCloudService> Services; -void InitServices(); +void InitializeServices(); // events int OnModulesLoaded(WPARAM, LPARAM); @@ -90,6 +90,7 @@ HICON LoadIconEx(int iconId, bool big = false); // menus extern HGENMENU hContactMenu; void InitializeMenus(); +void AddServiceMenuItem(const CCloudService *service); int OnPrebuildContactMenu(WPARAM, LPARAM); // srmm |