summaryrefslogtreecommitdiff
path: root/protocols/CloudFile/src/Services
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-04-11 13:40:09 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-04-11 13:40:09 +0300
commitc0ff932b9b6ba685160204fee0af84930f7aa922 (patch)
tree6b922da9dd5705c168d40f2eb691e453ddbf0713 /protocols/CloudFile/src/Services
parent99584f314758d7ee3ef5faead704546ad0fdc10a (diff)
fixes #4975 (CloudFile: нужно убирать учётку из подменю в меню контакта при её отключении) + some code cleaning
Diffstat (limited to 'protocols/CloudFile/src/Services')
-rw-r--r--protocols/CloudFile/src/Services/dropbox_service.cpp37
-rw-r--r--protocols/CloudFile/src/Services/dropbox_service.h1
-rw-r--r--protocols/CloudFile/src/Services/google_service.cpp43
-rw-r--r--protocols/CloudFile/src/Services/google_service.h1
-rw-r--r--protocols/CloudFile/src/Services/microsoft_service.cpp33
-rw-r--r--protocols/CloudFile/src/Services/microsoft_service.h1
-rw-r--r--protocols/CloudFile/src/Services/yandex_service.cpp37
-rw-r--r--protocols/CloudFile/src/Services/yandex_service.h1
8 files changed, 57 insertions, 97 deletions
diff --git a/protocols/CloudFile/src/Services/dropbox_service.cpp b/protocols/CloudFile/src/Services/dropbox_service.cpp
index 92b00fc493..3bcefc8c77 100644
--- a/protocols/CloudFile/src/Services/dropbox_service.cpp
+++ b/protocols/CloudFile/src/Services/dropbox_service.cpp
@@ -23,16 +23,7 @@ CDropboxService::CDropboxService(const char *protoName, const wchar_t *userName)
PROTO_INTERFACE* CDropboxService::Init(const char *moduleName, const wchar_t *userName)
{
- CDropboxService *proto = new CDropboxService(moduleName, userName);
- Services.insert(proto);
- return proto;
-}
-
-int CDropboxService::UnInit(PROTO_INTERFACE *proto)
-{
- Services.remove((CDropboxService *)proto);
- delete proto;
- return 0;
+ return new CDropboxService(moduleName, userName);
}
const char* CDropboxService::GetModuleName() const
@@ -76,10 +67,10 @@ void CDropboxService::RequestAccessTokenThread(void *param)
GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken));
DropboxAPI::GetAccessTokenRequest request(requestToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError());
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError());
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -87,7 +78,7 @@ void CDropboxService::RequestAccessTokenThread(void *param)
JSONNode root = JSONNode::parse(response->body);
if (root.empty()) {
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -96,14 +87,14 @@ void CDropboxService::RequestAccessTokenThread(void *param)
JSONNode node = root.at("error_description");
if (!node.isnull()) {
CMStringW error_description = node.as_mstring();
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(error_description, MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
}
node = root.at("access_token");
- db_set_s(0, GetAccountName(), "TokenSecret", node.as_string().c_str());
+ db_set_s(0, m_szModuleName, "TokenSecret", node.as_string().c_str());
SetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, "");
@@ -114,7 +105,7 @@ void CDropboxService::RevokeAccessTokenThread(void *)
{
ptrA token(getStringA("TokenSecret"));
DropboxAPI::RevokeAccessTokenRequest request(token);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
delSetting("ExpiresIn");
delSetting("TokenSecret");
@@ -135,7 +126,7 @@ auto CDropboxService::UploadFile(const char *data, size_t size, const std::strin
ptrA token(getStringA("TokenSecret"));
uint8_t strategy = g_plugin.getByte("ConflictStrategy", OnConflict::REPLACE);
DropboxAPI::UploadFileRequest request(token, path.c_str(), data, size, (OnConflict)strategy);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["path_lower"].as_string();
@@ -145,7 +136,7 @@ auto CDropboxService::CreateUploadSession(const char *chunk, size_t chunkSize)
{
ptrA token(getStringA("TokenSecret"));
DropboxAPI::CreateUploadSessionRequest request(token, chunk, chunkSize);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["session_id"].as_string();
@@ -155,7 +146,7 @@ void CDropboxService::UploadFileChunk(const std::string &sessionId, const char *
{
ptrA token(getStringA("TokenSecret"));
DropboxAPI::UploadFileChunkRequest request(token, sessionId.c_str(), offset, chunk, chunkSize);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
}
@@ -164,7 +155,7 @@ auto CDropboxService::CommitUploadSession(const std::string &sessionId, const ch
ptrA token(getStringA("TokenSecret"));
uint8_t strategy = g_plugin.getByte("ConflictStrategy", OnConflict::REPLACE);
DropboxAPI::CommitUploadSessionRequest request(token, sessionId.c_str(), offset, path.c_str(), data, size, (OnConflict)strategy);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["path_lower"].as_string();
@@ -174,7 +165,7 @@ void CDropboxService::CreateFolder(const std::string &path)
{
ptrA token(getStringA("TokenSecret"));
DropboxAPI::CreateFolderRequest request(token, path.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response == nullptr)
throw Exception(HttpStatusToError());
@@ -196,7 +187,7 @@ auto CDropboxService::CreateSharedLink(const std::string &path)
{
ptrA token(getStringA("TokenSecret"));
DropboxAPI::CreateSharedLinkRequest shareRequest(token, path.c_str());
- NLHR_PTR response(shareRequest.Send(m_hConnection));
+ NLHR_PTR response(shareRequest.Send(m_hNetlibUser));
if (response && HTTP_CODE_SUCCESS(response->resultCode)) {
JSONNode root = GetJsonResponse(response);
@@ -221,7 +212,7 @@ auto CDropboxService::CreateSharedLink(const std::string &path)
throw Exception(tag.c_str());
DropboxAPI::GetSharedLinkRequest getRequest(token, path.c_str());
- response = getRequest.Send(m_hConnection);
+ response = getRequest.Send(m_hNetlibUser);
root = GetJsonResponse(response);
diff --git a/protocols/CloudFile/src/Services/dropbox_service.h b/protocols/CloudFile/src/Services/dropbox_service.h
index 5166a9c17c..61b04f357c 100644
--- a/protocols/CloudFile/src/Services/dropbox_service.h
+++ b/protocols/CloudFile/src/Services/dropbox_service.h
@@ -22,7 +22,6 @@ public:
CDropboxService(const char *protoName, const wchar_t *userName);
static PROTO_INTERFACE* Init(const char *szModuleName, const wchar_t *szUserName);
- static int UnInit(PROTO_INTERFACE *);
const char* GetModuleName() const override;
diff --git a/protocols/CloudFile/src/Services/google_service.cpp b/protocols/CloudFile/src/Services/google_service.cpp
index fea2c3b2b4..2da3212b88 100644
--- a/protocols/CloudFile/src/Services/google_service.cpp
+++ b/protocols/CloudFile/src/Services/google_service.cpp
@@ -24,16 +24,7 @@ CGDriveService::CGDriveService(const char *protoName, const wchar_t *userName) :
PROTO_INTERFACE* CGDriveService::Init(const char *moduleName, const wchar_t *userName)
{
- CGDriveService *proto = new CGDriveService(moduleName, userName);
- Services.insert(proto);
- return proto;
-}
-
-int CGDriveService::UnInit(PROTO_INTERFACE *proto)
-{
- Services.remove((CGDriveService*)proto);
- delete proto;
- return 0;
+ return new CGDriveService(moduleName, userName);
}
const char* CGDriveService::GetModuleName() const
@@ -62,7 +53,7 @@ void CGDriveService::Login(HWND owner)
ptrA refreshToken(getStringA("RefreshToken"));
if (token && refreshToken && refreshToken[0]) {
GDriveAPI::RefreshTokenRequest request(refreshToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
@@ -97,14 +88,14 @@ void CGDriveService::RequestAccessTokenThread(void *param)
GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken));
GDriveAPI::GetAccessTokenRequest request(requestToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
const char *error = response && response->body.GetLength()
? response->body
: HttpStatusToError(response ? response->resultCode : 0);
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), error);
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, error);
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -112,7 +103,7 @@ void CGDriveService::RequestAccessTokenThread(void *param)
JSONNode root = JSONNode::parse(response->body);
if (root.empty()) {
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -121,21 +112,21 @@ void CGDriveService::RequestAccessTokenThread(void *param)
JSONNode node = root.at("error_description");
if (!node.isnull()) {
CMStringW error_description = node.as_mstring();
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(error_description, MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
}
node = root.at("access_token");
- db_set_s(0, GetAccountName(), "TokenSecret", node.as_string().c_str());
+ db_set_s(0, m_szModuleName, "TokenSecret", node.as_string().c_str());
node = root.at("expires_in");
time_t expiresIn = time(0) + node.as_int();
- db_set_dw(0, GetAccountName(), "ExpiresIn", expiresIn);
+ db_set_dw(0, m_szModuleName, "ExpiresIn", expiresIn);
node = root.at("refresh_token");
- db_set_s(0, GetAccountName(), "RefreshToken", node.as_string().c_str());
+ db_set_s(0, m_szModuleName, "RefreshToken", node.as_string().c_str());
SetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, "");
@@ -144,9 +135,9 @@ void CGDriveService::RequestAccessTokenThread(void *param)
void CGDriveService::RevokeAccessTokenThread(void*)
{
- ptrA token(db_get_sa(0, GetAccountName(), "TokenSecret"));
+ ptrA token(db_get_sa(0, m_szModuleName, "TokenSecret"));
GDriveAPI::RevokeAccessTokenRequest request(token);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
delSetting("ExpiresIn");
delSetting("TokenSecret");
@@ -166,7 +157,7 @@ auto CGDriveService::UploadFile(const std::string &parentId, const std::string &
{
ptrA token(getStringA("TokenSecret"));
GDriveAPI::UploadFileRequest request(token, parentId.c_str(), fileName.c_str(), data, size);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["id"].as_string();
}
@@ -175,7 +166,7 @@ auto CGDriveService::CreateUploadSession(const std::string &parentId, const std:
{
ptrA token(getStringA("TokenSecret"));
GDriveAPI::CreateUploadSessionRequest request(token, parentId.c_str(), fileName.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
@@ -190,7 +181,7 @@ auto CGDriveService::CreateUploadSession(const std::string &parentId, const std:
auto CGDriveService::UploadFileChunk(const std::string &uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize)
{
GDriveAPI::UploadFileChunkRequest request(uploadUri.c_str(), chunk, chunkSize, offset, fileSize);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response->resultCode == HTTP_CODE_PERMANENT_REDIRECT)
return std::string();
@@ -211,7 +202,7 @@ auto CGDriveService::CreateFolder(const std::string &parentId, const std::string
{
ptrA token(getStringA("TokenSecret"));
GDriveAPI::GetFolderRequest getFolderRequest(token, parentId.c_str(), name.c_str());
- NLHR_PTR response(getFolderRequest.Send(m_hConnection));
+ NLHR_PTR response(getFolderRequest.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
JSONNode files = root["files"].as_array();
@@ -219,7 +210,7 @@ auto CGDriveService::CreateFolder(const std::string &parentId, const std::string
return files[(size_t)0]["id"].as_string();
GDriveAPI::CreateFolderRequest createFolderRequest(token, parentId.c_str(), name.c_str());
- response = createFolderRequest.Send(m_hConnection);
+ response = createFolderRequest.Send(m_hNetlibUser);
root = GetJsonResponse(response);
return root["id"].as_string();
@@ -229,7 +220,7 @@ auto CGDriveService::CreateSharedLink(const std::string &itemId)
{
ptrA token(getStringA("TokenSecret"));
GDriveAPI::GrantPermissionsRequest request(token, itemId.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
diff --git a/protocols/CloudFile/src/Services/google_service.h b/protocols/CloudFile/src/Services/google_service.h
index 7133ab9a52..1d0c09b159 100644
--- a/protocols/CloudFile/src/Services/google_service.h
+++ b/protocols/CloudFile/src/Services/google_service.h
@@ -21,7 +21,6 @@ public:
CGDriveService(const char *protoName, const wchar_t *userName);
static PROTO_INTERFACE* Init(const char *szModuleName, const wchar_t *szUserName);
- static int UnInit(PROTO_INTERFACE*);
const char* GetModuleName() const override;
diff --git a/protocols/CloudFile/src/Services/microsoft_service.cpp b/protocols/CloudFile/src/Services/microsoft_service.cpp
index 17115235cd..d444b4133a 100644
--- a/protocols/CloudFile/src/Services/microsoft_service.cpp
+++ b/protocols/CloudFile/src/Services/microsoft_service.cpp
@@ -23,16 +23,7 @@ COneDriveService::COneDriveService(const char *protoName, const wchar_t *userNam
PROTO_INTERFACE* COneDriveService::Init(const char *moduleName, const wchar_t *userName)
{
- COneDriveService *proto = new COneDriveService(moduleName, userName);
- Services.insert(proto);
- return proto;
-}
-
-int COneDriveService::UnInit(PROTO_INTERFACE *proto)
-{
- Services.remove((COneDriveService *)proto);
- delete proto;
- return 0;
+ return new COneDriveService(moduleName, userName);
}
const char* COneDriveService::GetModuleName() const
@@ -60,12 +51,12 @@ void COneDriveService::Login(HWND owner)
ptrA refreshToken(getStringA("RefreshToken"));
if (refreshToken && refreshToken[0]) {
OneDriveAPI::RefreshTokenRequest request(refreshToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
JSONNode node = root.at("access_token");
- db_set_s(0, GetAccountName(), "TokenSecret", node.as_string().c_str());
+ db_set_s(0, m_szModuleName, "TokenSecret", node.as_string().c_str());
node = root.at("expires_in");
time_t expiresIn = time(0) + node.as_int();
@@ -97,14 +88,14 @@ void COneDriveService::RequestAccessTokenThread(void *param)
GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken));
OneDriveAPI::GetAccessTokenRequest request(requestToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
const char *error = response->body.GetLength()
? response->body
: HttpStatusToError(response->resultCode);
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), error);
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, error);
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -112,7 +103,7 @@ void COneDriveService::RequestAccessTokenThread(void *param)
JSONNode root = JSONNode::parse(response->body);
if (root.empty()) {
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -121,7 +112,7 @@ void COneDriveService::RequestAccessTokenThread(void *param)
JSONNode node = root.at("error_description");
if (!node.isnull()) {
CMStringW error_description = node.as_mstring();
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(error_description, MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -158,7 +149,7 @@ auto COneDriveService::UploadFile(const std::string &parentId, const std::string
OneDriveAPI::UploadFileRequest *request = !parentId.empty()
? new OneDriveAPI::UploadFileRequest(token, parentId.c_str(), fileName.c_str(), data, size, (OnConflict)strategy)
: new OneDriveAPI::UploadFileRequest(token, fileName.c_str(), data, size, (OnConflict)strategy);
- NLHR_PTR response(request->Send(m_hConnection));
+ NLHR_PTR response(request->Send(m_hNetlibUser));
delete request;
JSONNode root = GetJsonResponse(response);
@@ -172,7 +163,7 @@ auto COneDriveService::CreateUploadSession(const std::string &parentId, const st
OneDriveAPI::CreateUploadSessionRequest *request = !parentId.empty()
? new OneDriveAPI::CreateUploadSessionRequest(token, parentId.c_str(), fileName.c_str(), (OnConflict)strategy)
: new OneDriveAPI::CreateUploadSessionRequest(token, fileName.c_str(), (OnConflict)strategy);
- NLHR_PTR response(request->Send(m_hConnection));
+ NLHR_PTR response(request->Send(m_hNetlibUser));
delete request;
JSONNode root = GetJsonResponse(response);
@@ -182,7 +173,7 @@ auto COneDriveService::CreateUploadSession(const std::string &parentId, const st
auto COneDriveService::UploadFileChunk(const std::string &uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize)
{
OneDriveAPI::UploadFileChunkRequest request(uploadUri.c_str(), chunk, chunkSize, offset, fileSize);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
@@ -203,7 +194,7 @@ auto COneDriveService::CreateFolder(const std::string &path)
{
ptrA token(getStringA("TokenSecret"));
OneDriveAPI::CreateFolderRequest request(token, path.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["id"].as_string();
@@ -213,7 +204,7 @@ auto COneDriveService::CreateSharedLink(const std::string &itemId)
{
ptrA token(getStringA("TokenSecret"));
OneDriveAPI::CreateSharedLinkRequest request(token, itemId.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["link"]["webUrl"].as_string();
diff --git a/protocols/CloudFile/src/Services/microsoft_service.h b/protocols/CloudFile/src/Services/microsoft_service.h
index b8fe3c2bde..02c631f442 100644
--- a/protocols/CloudFile/src/Services/microsoft_service.h
+++ b/protocols/CloudFile/src/Services/microsoft_service.h
@@ -20,7 +20,6 @@ public:
COneDriveService(const char *protoName, const wchar_t *userName);
static PROTO_INTERFACE* Init(const char *szModuleName, const wchar_t *szUserName);
- static int UnInit(PROTO_INTERFACE *);
const char* GetModuleName() const override;
diff --git a/protocols/CloudFile/src/Services/yandex_service.cpp b/protocols/CloudFile/src/Services/yandex_service.cpp
index e252eed161..a8ee11e9f2 100644
--- a/protocols/CloudFile/src/Services/yandex_service.cpp
+++ b/protocols/CloudFile/src/Services/yandex_service.cpp
@@ -23,16 +23,7 @@ CYandexService::CYandexService(const char *protoName, const wchar_t *userName) :
PROTO_INTERFACE* CYandexService::Init(const char *moduleName, const wchar_t *userName)
{
- CYandexService *proto = new CYandexService(moduleName, userName);
- Services.insert(proto);
- return proto;
-}
-
-int CYandexService::UnInit(PROTO_INTERFACE *proto)
-{
- Services.remove((CYandexService*)proto);
- delete proto;
- return 0;
+ return new CYandexService(moduleName, userName);
}
const char* CYandexService::GetModuleName() const
@@ -61,7 +52,7 @@ void CYandexService::Login(HWND owner)
ptrA refreshToken(getStringA("RefreshToken"));
if (token && refreshToken && refreshToken[0]) {
YandexAPI::RefreshTokenRequest request(refreshToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
@@ -99,12 +90,12 @@ void CYandexService::RequestAccessTokenThread(void *param)
GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken));
YandexAPI::GetAccessTokenRequest request(requestToken);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
if (response) {
const char *error = response->body.GetLength() ? response->body : HttpStatusToError(response->resultCode);
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), error);
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, error);
}
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
@@ -113,7 +104,7 @@ void CYandexService::RequestAccessTokenThread(void *param)
JSONNode root = JSONNode::parse(response->body);
if (root.empty()) {
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -122,7 +113,7 @@ void CYandexService::RequestAccessTokenThread(void *param)
JSONNode node = root.at("error_description");
if (!node.isnull()) {
CMStringW error_description = node.as_mstring();
- Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hNetlibUser, "%s: %s", m_szModuleName, HttpStatusToError(response->resultCode));
ShowNotification(error_description, MB_ICONERROR);
EndDialog(hwndDlg, 0);
return;
@@ -145,9 +136,9 @@ void CYandexService::RequestAccessTokenThread(void *param)
void CYandexService::RevokeAccessTokenThread(void*)
{
- ptrA token(db_get_sa(0, GetAccountName(), "TokenSecret"));
+ ptrA token(db_get_sa(0, m_szModuleName, "TokenSecret"));
YandexAPI::RevokeAccessTokenRequest request(token);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
delSetting("ExpiresIn");
delSetting("TokenSecret");
@@ -168,7 +159,7 @@ auto CYandexService::CreateUploadSession(const std::string &path)
ptrA token(getStringA("TokenSecret"));
uint8_t strategy = g_plugin.getByte("ConflictStrategy", OnConflict::REPLACE);
YandexAPI::GetUploadUrlRequest request(token, path.c_str(), (OnConflict)strategy);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
JSONNode root = GetJsonResponse(response);
return root["href"].as_string();
@@ -177,7 +168,7 @@ auto CYandexService::CreateUploadSession(const std::string &path)
void CYandexService::UploadFile(const std::string &uploadUri, const char *data, size_t size)
{
YandexAPI::UploadFileRequest request(uploadUri.c_str(), data, size);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
@@ -190,7 +181,7 @@ void CYandexService::UploadFile(const std::string &uploadUri, const char *data,
void CYandexService::UploadFileChunk(const std::string &uploadUri, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize)
{
YandexAPI::UploadFileChunkRequest request(uploadUri.c_str(), chunk, chunkSize, offset, fileSize);
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
HandleHttpError(response);
@@ -205,7 +196,7 @@ void CYandexService::CreateFolder(const std::string &path)
{
ptrA token(getStringA("TokenSecret"));
YandexAPI::CreateFolderRequest request(token, path.c_str());
- NLHR_PTR response(request.Send(m_hConnection));
+ NLHR_PTR response(request.Send(m_hNetlibUser));
if (HTTP_CODE_SUCCESS(response->resultCode)) {
GetJsonResponse(response);
@@ -224,12 +215,12 @@ auto CYandexService::CreateSharedLink(const std::string &path)
{
ptrA token(getStringA("TokenSecret"));
YandexAPI::PublishRequest publishRequest(token, path.c_str());
- NLHR_PTR response(publishRequest.Send(m_hConnection));
+ NLHR_PTR response(publishRequest.Send(m_hNetlibUser));
GetJsonResponse(response);
YandexAPI::GetResourcesRequest resourcesRequest(token, path.c_str());
- response = resourcesRequest.Send(m_hConnection);
+ response = resourcesRequest.Send(m_hNetlibUser);
JSONNode root = GetJsonResponse(response);
return root["public_url"].as_string();
diff --git a/protocols/CloudFile/src/Services/yandex_service.h b/protocols/CloudFile/src/Services/yandex_service.h
index c83a49f22c..c6566667d1 100644
--- a/protocols/CloudFile/src/Services/yandex_service.h
+++ b/protocols/CloudFile/src/Services/yandex_service.h
@@ -21,7 +21,6 @@ public:
CYandexService(const char *protoName, const wchar_t *userName);
static PROTO_INTERFACE* Init(const char *szModuleName, const wchar_t *szUserName);
- static int UnInit(PROTO_INTERFACE *);
const char* GetModuleName() const override;