summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/Services/microsoft_service.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-04-26 00:01:56 +0300
committeraunsane <aunsane@gmail.com>2017-04-26 00:02:28 +0300
commitc336d52ffabca5777b5c6666cff818ac742480bf (patch)
treed30c0a67c6dfa3ac06cd401c6973145f7e18509b /plugins/CloudFile/src/Services/microsoft_service.cpp
parentf6575a156251f15ca2c1b9d8042aa45fb62bf42a (diff)
CloudFile: OneDrive is worked now
Diffstat (limited to 'plugins/CloudFile/src/Services/microsoft_service.cpp')
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp
index d988ec222a..b8351019ed 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.cpp
+++ b/plugins/CloudFile/src/Services/microsoft_service.cpp
@@ -57,7 +57,9 @@ void COneDriveService::Login()
void COneDriveService::Logout()
{
- mir_forkthreadex(RevokeAccessTokenThread, this);
+ db_unset(NULL, GetModule(), "TokenSecret");
+ db_unset(NULL, GetModule(), "ExpiresIn");
+ db_unset(NULL, GetModule(), "RefreshToken");
}
unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param)
@@ -91,7 +93,7 @@ unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param)
return 0;
}
- JSONNode node = root.at("error");
+ 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->GetModule(), service->HttpStatusToError(response->resultCode));
@@ -116,17 +118,6 @@ unsigned COneDriveService::RequestAccessTokenThread(void *owner, void *param)
return 0;
}
-unsigned COneDriveService::RevokeAccessTokenThread(void *param)
-{
- //COneDriveService *service = (COneDriveService*)param;
-
- /*ptrA token(db_get_sa(NULL, service->GetModule(), "TokenSecret"));
- OneDriveAPI::RevokeAccessTokenRequest request(token);
- NLHR_PTR response(request.Send(service->hConnection));*/
-
- return 0;
-}
-
void COneDriveService::HandleJsonError(JSONNode &node)
{
JSONNode error = node.at("error");
@@ -139,10 +130,11 @@ void COneDriveService::HandleJsonError(JSONNode &node)
void COneDriveService::CreateUploadSession(char *uploadUri, const char *name, const char *parentId)
{
ptrA token(db_get_sa(NULL, GetModule(), "TokenSecret"));
- OneDriveAPI::CreateUploadSessionRequest request = mir_strlen(parentId)
- ? OneDriveAPI::CreateUploadSessionRequest(token, parentId, name)
- : OneDriveAPI::CreateUploadSessionRequest(token, name);
- NLHR_PTR response(request.Send(hConnection));
+ OneDriveAPI::CreateUploadSessionRequest *request = mir_strlen(parentId)
+ ? new OneDriveAPI::CreateUploadSessionRequest(token, parentId, name)
+ : new OneDriveAPI::CreateUploadSessionRequest(token, name);
+ NLHR_PTR response(request->Send(hConnection));
+ delete request;
JSONNode root = GetJsonResponse(response);
JSONNode node = root.at("uploadUrl");
@@ -190,8 +182,9 @@ void COneDriveService::CreateSharedLink(const char *itemId, char *url)
NLHR_PTR response(request.Send(hConnection));
JSONNode root = GetJsonResponse(response);
- JSONNode node = root.at("webUrl");
- mir_strcpy(url, node.as_string().c_str());
+ JSONNode node = root.at("link");
+ JSONNode webUrl = root.at("webUrl");
+ mir_strcpy(url, webUrl.as_string().c_str());
}
UINT COneDriveService::Upload(FileTransferParam *ftp)