diff options
Diffstat (limited to 'plugins/CloudFile/src/Services/microsoft_service.cpp')
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_service.cpp | 33 |
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) |