summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/Services/microsoft_service.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-03 12:31:44 +0200
committerGeorge Hazan <ghazan@miranda.im>2018-05-03 12:32:36 +0200
commit48cb59cb5687303a608903259bb10eb9e6a9ee36 (patch)
treee7ef1bda96cac9fb9ed59ce7a29477a3d262c50e /plugins/CloudFile/src/Services/microsoft_service.cpp
parent89a1dbcab6947a68d81dd048e5d91cebdb0c2510 (diff)
CloudFile: thread functions rewritten using PROTO::ForkThread
Diffstat (limited to 'plugins/CloudFile/src/Services/microsoft_service.cpp')
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp
index 2843e66d0f..2a3f3c19b4 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.cpp
+++ b/plugins/CloudFile/src/Services/microsoft_service.cpp
@@ -60,7 +60,7 @@ void COneDriveService::Login(HWND owner)
return;
}
- COAuthDlg dlg(this, MICROSOFT_AUTH, RequestAccessTokenThread);
+ COAuthDlg dlg(this, MICROSOFT_AUTH, (MyThreadFunc)&COneDriveService::RequestAccessTokenThread);
dlg.SetParent(owner);
dlg.DoModal();
}
@@ -72,63 +72,60 @@ void COneDriveService::Logout()
delSetting("RefreshToken");
}
-unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param)
+void COneDriveService::RequestAccessTokenThread(void *param)
{
HWND hwndDlg = (HWND)param;
- COneDriveService *service = (COneDriveService*)owner;
- if (service->IsLoggedIn())
- service->Logout();
+ if (IsLoggedIn())
+ Logout();
char requestToken[128];
GetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, requestToken, _countof(requestToken));
OneDriveAPI::GetAccessTokenRequest request(requestToken);
- NLHR_PTR response(request.Send(service->m_hConnection));
+ NLHR_PTR response(request.Send(m_hConnection));
if (response == nullptr || response->resultCode != HTTP_CODE_OK) {
const char *error = response->dataLength
? response->pData
- : service->HttpStatusToError(response->resultCode);
+ : HttpStatusToError(response->resultCode);
- Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), error);
+ Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), error);
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
- return 0;
+ return;
}
JSONNode root = JSONNode::parse(response->pData);
if (root.empty()) {
- Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
ShowNotification(TranslateT("Server does not respond"), MB_ICONERROR);
EndDialog(hwndDlg, 0);
- return 0;
+ return;
}
JSONNode node = root.at("error_description");
if (!node.isnull()) {
CMStringW error_description = node.as_mstring();
- Netlib_Logf(service->m_hConnection, "%s: %s", service->GetAccountName(), service->HttpStatusToError(response->resultCode));
+ Netlib_Logf(m_hConnection, "%s: %s", GetAccountName(), HttpStatusToError(response->resultCode));
ShowNotification(error_description, MB_ICONERROR);
EndDialog(hwndDlg, 0);
- return 0;
+ return;
}
node = root.at("access_token");
- service->setString("TokenSecret", node.as_string().c_str());
+ setString("TokenSecret", node.as_string().c_str());
node = root.at("expires_in");
time_t expiresIn = time(nullptr) + node.as_int();
- service->setDword("ExpiresIn", expiresIn);
+ setDword("ExpiresIn", expiresIn);
node = root.at("refresh_token");
- service->setString("RefreshToken", node.as_string().c_str());
+ setString("RefreshToken", node.as_string().c_str());
SetDlgItemTextA(hwndDlg, IDC_OAUTH_CODE, "");
EndDialog(hwndDlg, 1);
-
- return 0;
}
void COneDriveService::HandleJsonError(JSONNode &node)