From fc46c19a61d26fb610d173bb8fc5420eea966caa Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 19 Feb 2014 19:07:45 +0000 Subject: Dropbox: - global object replaced by singleton - added ability to upload folders git-svn-id: http://svn.miranda-ng.org/main/trunk@8183 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'plugins/Dropbox/src/dropbox.cpp') diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index fa2d5cbc86..ed705d6dea 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -1,6 +1,6 @@ #include "dropbox.h" -CDropbox::CDropbox() +void CDropbox::Init() { PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE }; pd.szName = MODULE; @@ -28,7 +28,7 @@ bool CDropbox::HasAccessToken() return db_get_sa(NULL, MODULE, "TokenSecret") != NULL; } -void CDropbox::RequestAcceessToken() +void CDropbox::RequestAcceessToken(MCONTACT hContact) { ShellExecuteA(NULL, "open", DROPBOX_WWW_URL DROPBOX_API_VER "/oauth2/authorize?response_type=code&client_id=" DROPBOX_API_KEY, NULL, NULL, SW_SHOWDEFAULT); @@ -71,7 +71,6 @@ void CDropbox::RequestAcceessToken() ptrA access_token = ptrA(mir_u2a(json_as_string(node))); db_set_s(NULL, MODULE, "TokenSecret", access_token); - MCONTACT hContact = GetDefaultContact(); if (hContact) { node = json_get(root, "uid"); @@ -107,20 +106,34 @@ void CDropbox::RequestAcceessToken() } } -void CDropbox::DestroyAcceessToken() +void CDropbox::DestroyAcceessToken(MCONTACT hContact) { HttpRequest *request = new HttpRequest(hNetlibUser, REQUEST_POST, DROPBOX_API_URL "/disable_access_token"); - //request->SendAsync(&CDropboxProto::AsyncFunc); NETLIBHTTPREQUEST *response = request->Send(); delete request; mir_free(response); db_unset(NULL, MODULE, "TokenSecret"); - MCONTACT hContact = GetDefaultContact(); if (hContact) { if (db_get_w(hContact, MODULE, "Status", ID_STATUS_ONLINE) == ID_STATUS_ONLINE) db_set_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE); } +} + +void CDropbox::RequeriedAccessAsync(void *arg) +{ + MCONTACT hContact = (MCONTACT)arg; + + if (hContact && MessageBox( + NULL, + TranslateT("Are you sure you want to requeried access?"), + TranslateT("Requeried access"), + MB_YESNO | MB_ICONQUESTION) == IDYES) + { + if (HasAccessToken()) + Singleton::GetInstance()->DestroyAcceessToken(hContact); + Singleton::GetInstance()->RequestAcceessToken(hContact); + } } \ No newline at end of file -- cgit v1.2.3