summaryrefslogtreecommitdiff
path: root/plugins/CloudFile
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-04-11 23:37:53 +0300
committeraunsane <aunsane@gmail.com>2018-04-11 23:38:18 +0300
commit98c8a49c029397c7e5b81e19292681f24a533e0e (patch)
treeace75eb705f679ed1e69742dcef85d1b2242f578 /plugins/CloudFile
parent21fe9b80ff4030f76f68a90726bc29e49627414c (diff)
CloudFile: Add "grant acess" link to CloudFile accounts (fixed #1260)
Diffstat (limited to 'plugins/CloudFile')
-rw-r--r--plugins/CloudFile/res/resource.rc23
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.cpp10
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.h2
-rw-r--r--plugins/CloudFile/src/Services/google_service.cpp7
-rw-r--r--plugins/CloudFile/src/Services/google_service.h2
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.cpp3
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.h2
-rw-r--r--plugins/CloudFile/src/Services/yandex_service.cpp7
-rw-r--r--plugins/CloudFile/src/Services/yandex_service.h2
-rw-r--r--plugins/CloudFile/src/cloud_file.cpp10
-rw-r--r--plugins/CloudFile/src/cloud_file.h4
-rw-r--r--plugins/CloudFile/src/options.cpp43
-rw-r--r--plugins/CloudFile/src/options.h22
-rw-r--r--plugins/CloudFile/src/resource.h9
-rw-r--r--plugins/CloudFile/src/stdafx.h3
15 files changed, 130 insertions, 19 deletions
diff --git a/plugins/CloudFile/res/resource.rc b/plugins/CloudFile/res/resource.rc
index ac6165d105..ff523095fd 100644
--- a/plugins/CloudFile/res/resource.rc
+++ b/plugins/CloudFile/res/resource.rc
@@ -113,6 +113,15 @@ BEGIN
CONTROL "Go to this link",IDC_OAUTH_AUTHORIZE,"Hyperlink",WS_GROUP | WS_TABSTOP | 0x1,7,18,179,8
END
+IDD_ACCMGR DIALOGEX 0, 0, 188, 126
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ PUSHBUTTON "Request access",IDC_REQUESTACCESS,15,19,73,14
+ PUSHBUTTON "Revoke access",IDC_REVOKEACCESS,100,19,73,14
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -129,6 +138,11 @@ BEGIN
0
END
+IDD_ACCMGR AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -157,6 +171,15 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 76
END
+
+ IDD_ACCMGR, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 181
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 119
+ HORZGUIDE, 33
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp
index 459983b935..34e779df1c 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.cpp
+++ b/plugins/CloudFile/src/Services/dropbox_service.cpp
@@ -39,9 +39,11 @@ bool CDropboxService::IsLoggedIn()
return true;
}
-void CDropboxService::Login()
+void CDropboxService::Login(HWND owner)
{
- COAuthDlg(this, DROPBOX_API_AUTH, RequestAccessTokenThread).DoModal();
+ COAuthDlg dlg(this, DROPBOX_API_AUTH, RequestAccessTokenThread);
+ dlg.SetParent(owner);
+ dlg.DoModal();
}
void CDropboxService::Logout()
@@ -104,6 +106,10 @@ unsigned CDropboxService::RevokeAccessTokenThread(void *param)
DropboxAPI::RevokeAccessTokenRequest request(token);
NLHR_PTR response(request.Send(service->m_hConnection));
+ service->delSetting("ExpiresIn");
+ service->delSetting("TokenSecret");
+ service->delSetting("RefreshToken");
+
return 0;
}
diff --git a/plugins/CloudFile/src/Services/dropbox_service.h b/plugins/CloudFile/src/Services/dropbox_service.h
index fa481183c3..5289dc321c 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.h
+++ b/plugins/CloudFile/src/Services/dropbox_service.h
@@ -27,7 +27,7 @@ public:
int GetIconId() const override;
bool IsLoggedIn() override;
- void Login() override;
+ void Login(HWND owner = nullptr) override;
void Logout() override;
UINT Upload(FileTransferParam *ftp) override;
diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp
index 605d023200..fe5baa91e3 100644
--- a/plugins/CloudFile/src/Services/google_service.cpp
+++ b/plugins/CloudFile/src/Services/google_service.cpp
@@ -41,7 +41,7 @@ bool CGDriveService::IsLoggedIn()
return now < expiresIn;
}
-void CGDriveService::Login()
+void CGDriveService::Login(HWND owner)
{
ptrA token(getStringA("TokenSecret"));
ptrA refreshToken(getStringA("RefreshToken"));
@@ -62,6 +62,7 @@ void CGDriveService::Login()
}
COAuthDlg dlg(this, GOOGLE_AUTH, RequestAccessTokenThread);
+ dlg.SetParent(owner);
dlg.DoModal();
}
@@ -137,6 +138,10 @@ unsigned CGDriveService::RevokeAccessTokenThread(void *param)
GDriveAPI::RevokeAccessTokenRequest request(token);
NLHR_PTR response(request.Send(service->m_hConnection));
+ service->delSetting("ExpiresIn");
+ service->delSetting("TokenSecret");
+ service->delSetting("RefreshToken");
+
return 0;
}
diff --git a/plugins/CloudFile/src/Services/google_service.h b/plugins/CloudFile/src/Services/google_service.h
index 9da2f14e5f..717e6314b0 100644
--- a/plugins/CloudFile/src/Services/google_service.h
+++ b/plugins/CloudFile/src/Services/google_service.h
@@ -26,7 +26,7 @@ public:
int GetIconId() const override;
bool IsLoggedIn() override;
- void Login() override;
+ void Login(HWND owner = nullptr) override;
void Logout() override;
UINT Upload(FileTransferParam *ftp) override;
diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp
index 4b598e9bfb..05c4c5ca81 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.cpp
+++ b/plugins/CloudFile/src/Services/microsoft_service.cpp
@@ -41,7 +41,7 @@ bool COneDriveService::IsLoggedIn()
return now < expiresIn;
}
-void COneDriveService::Login()
+void COneDriveService::Login(HWND owner)
{
ptrA refreshToken(getStringA("RefreshToken"));
if (refreshToken && refreshToken[0]) {
@@ -61,6 +61,7 @@ void COneDriveService::Login()
}
COAuthDlg dlg(this, MICROSOFT_AUTH, RequestAccessTokenThread);
+ dlg.SetParent(owner);
dlg.DoModal();
}
diff --git a/plugins/CloudFile/src/Services/microsoft_service.h b/plugins/CloudFile/src/Services/microsoft_service.h
index f9e41a93c5..8ae162d45e 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.h
+++ b/plugins/CloudFile/src/Services/microsoft_service.h
@@ -25,7 +25,7 @@ public:
int GetIconId() const override;
bool IsLoggedIn() override;
- void Login() override;
+ void Login(HWND owner = nullptr) override;
void Logout() override;
UINT Upload(FileTransferParam *ftp) override;
diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp
index f0b09adf4b..c3e32aa8c8 100644
--- a/plugins/CloudFile/src/Services/yandex_service.cpp
+++ b/plugins/CloudFile/src/Services/yandex_service.cpp
@@ -41,7 +41,7 @@ bool CYandexService::IsLoggedIn()
return now < expiresIn;
}
-void CYandexService::Login()
+void CYandexService::Login(HWND owner)
{
ptrA token(getStringA("TokenSecret"));
ptrA refreshToken(getStringA("RefreshToken"));
@@ -65,6 +65,7 @@ void CYandexService::Login()
}
COAuthDlg dlg(this, YANDEX_AUTH, RequestAccessTokenThread);
+ dlg.SetParent(owner);
dlg.DoModal();
}
@@ -139,6 +140,10 @@ unsigned CYandexService::RevokeAccessTokenThread(void *param)
YandexAPI::RevokeAccessTokenRequest request(token);
NLHR_PTR response(request.Send(service->m_hConnection));
+ service->delSetting("ExpiresIn");
+ service->delSetting("TokenSecret");
+ service->delSetting("RefreshToken");
+
return 0;
}
diff --git a/plugins/CloudFile/src/Services/yandex_service.h b/plugins/CloudFile/src/Services/yandex_service.h
index 76a12feef0..fa18e0f2f2 100644
--- a/plugins/CloudFile/src/Services/yandex_service.h
+++ b/plugins/CloudFile/src/Services/yandex_service.h
@@ -26,7 +26,7 @@ public:
int GetIconId() const override;
bool IsLoggedIn() override;
- void Login() override;
+ void Login(HWND owner = nullptr) override;
void Logout() override;
UINT Upload(FileTransferParam *ftp) override;
diff --git a/plugins/CloudFile/src/cloud_file.cpp b/plugins/CloudFile/src/cloud_file.cpp
index 6d92528f8a..0c2f048cd8 100644
--- a/plugins/CloudFile/src/cloud_file.cpp
+++ b/plugins/CloudFile/src/cloud_file.cpp
@@ -11,6 +11,8 @@ CCloudService::CCloudService(const char *protoName, const wchar_t *userName)
nlu.szSettingsModule = (char*)protoName;
nlu.szDescriptiveName.w = (wchar_t*)userName;
m_hConnection = Netlib_RegisterUser(&nlu);
+
+ CreateProtoService(PS_CREATEACCMGRUI, &CCloudService::OnAccountManagerInit);
}
CCloudService::~CCloudService()
@@ -100,6 +102,14 @@ int CCloudService::OnEvent(PROTOEVENTTYPE iEventType, WPARAM, LPARAM)
return 1;
}
+INT_PTR CCloudService::OnAccountManagerInit(WPARAM, LPARAM lParam)
+{
+ CAccountManagerDlg *page = new CAccountManagerDlg(this);
+ page->SetParent((HWND)lParam);
+ page->Show();
+ return (INT_PTR)page->GetHwnd();
+}
+
std::string CCloudService::PreparePath(const char *path)
{
std::string newPath = path;
diff --git a/plugins/CloudFile/src/cloud_file.h b/plugins/CloudFile/src/cloud_file.h
index 8d69e0f864..3130b2ef65 100644
--- a/plugins/CloudFile/src/cloud_file.h
+++ b/plugins/CloudFile/src/cloud_file.h
@@ -14,6 +14,8 @@ protected:
int m_hLangpack;
HNETLIBUSER m_hConnection;
+ INT_PTR __cdecl OnAccountManagerInit(WPARAM, LPARAM);
+
// utils
std::string PreparePath(const char *path);
@@ -44,7 +46,7 @@ public:
virtual int GetIconId() const = 0;
virtual bool IsLoggedIn() = 0;
- virtual void Login() = 0;
+ virtual void Login(HWND owner = nullptr) = 0;
virtual void Logout() = 0;
void OpenUploadDialog(MCONTACT hContact);
diff --git a/plugins/CloudFile/src/options.cpp b/plugins/CloudFile/src/options.cpp
index 3c7850ee22..32eb485a31 100644
--- a/plugins/CloudFile/src/options.cpp
+++ b/plugins/CloudFile/src/options.cpp
@@ -1,6 +1,6 @@
#include "stdafx.h"
-COptionsMain::COptionsMain()
+COptionsMainDlg::COptionsMainDlg()
: CPluginDlgBase(hInstance, IDD_OPTIONS_MAIN, MODULE),
m_defaultService(this, IDC_DEFAULTSERVICE),
m_doNothingOnConflict(this, IDC_DONOTHINGONCONFLICT),
@@ -17,7 +17,7 @@ COptionsMain::COptionsMain()
CreateLink(m_urlCopyToClipboard, "UrlCopyToClipboard", DBVT_BYTE, 0);
}
-void COptionsMain::OnInitDialog()
+void COptionsMainDlg::OnInitDialog()
{
CDlgBase::OnInitDialog();
@@ -52,7 +52,7 @@ void COptionsMain::OnInitDialog()
}
}
-void COptionsMain::OnApply()
+void COptionsMainDlg::OnApply()
{
int iItem = m_defaultService.GetCurSel();
CCloudService *service = (CCloudService*)m_defaultService.GetItemData(iItem);
@@ -79,8 +79,43 @@ int OnOptionsInitialized(WPARAM wParam, LPARAM)
odp.szGroup.w = LPGENW("Services");
//odp.szTab.w = LPGENW("General");
- odp.pDialog = new COptionsMain();
+ odp.pDialog = new COptionsMainDlg();
Options_AddPage(wParam, &odp);
return 0;
}
+
+/////////////////////////////////////////////////////////////////////////////////
+
+CAccountManagerDlg::CAccountManagerDlg(CCloudService *service)
+ : CProtoDlgBase(service, IDD_ACCMGR),
+ m_requestAccess(this, IDC_REQUESTACCESS),
+ m_revokeAccess(this, IDC_REVOKEACCESS)
+{
+ m_requestAccess.OnClick = Callback(this, &CAccountManagerDlg::RequestAccess_OnClick);
+ m_revokeAccess.OnClick = Callback(this, &CAccountManagerDlg::RevokeAccess_OnClick);
+}
+
+void CAccountManagerDlg::OnInitDialog()
+{
+ ptrA token(m_proto->getStringA("TokenSecret"));
+ m_requestAccess.Enable(!token);
+ m_revokeAccess.Enable(token);
+}
+
+void CAccountManagerDlg::RequestAccess_OnClick(CCtrlButton*)
+{
+ m_proto->Login(m_hwnd);
+ ptrA token(m_proto->getStringA("TokenSecret"));
+ m_requestAccess.Enable(!token);
+ m_revokeAccess.Enable(token);
+}
+
+void CAccountManagerDlg::RevokeAccess_OnClick(CCtrlButton*)
+{
+ m_proto->Logout();
+ m_requestAccess.Enable();
+ m_revokeAccess.Disable();
+}
+
+/////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/CloudFile/src/options.h b/plugins/CloudFile/src/options.h
index 7b16de5db6..ba7682aef7 100644
--- a/plugins/CloudFile/src/options.h
+++ b/plugins/CloudFile/src/options.h
@@ -1,7 +1,7 @@
#ifndef _OPTIONS_H_
#define _OPTIONS_H_
-class COptionsMain : public CPluginDlgBase
+class COptionsMainDlg : public CPluginDlgBase
{
private:
CCtrlCombo m_defaultService;
@@ -19,7 +19,25 @@ protected:
void OnApply();
public:
- COptionsMain();
+ COptionsMainDlg();
+};
+
+/////////////////////////////////////////////////////////////////////////////////
+
+class CAccountManagerDlg : public CProtoDlgBase<CCloudService>
+{
+private:
+ CCtrlButton m_requestAccess;
+ CCtrlButton m_revokeAccess;
+
+protected:
+ void OnInitDialog();
+
+ void RequestAccess_OnClick(CCtrlButton*);
+ void RevokeAccess_OnClick(CCtrlButton*);
+
+public:
+ CAccountManagerDlg(CCloudService *service);
};
#endif //_OPTIONS_H_ \ No newline at end of file
diff --git a/plugins/CloudFile/src/resource.h b/plugins/CloudFile/src/resource.h
index aa5daf96da..d839f15da4 100644
--- a/plugins/CloudFile/src/resource.h
+++ b/plugins/CloudFile/src/resource.h
@@ -1,9 +1,10 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by D:\Projects\c++\miranda-ng\plugins\CloudFile\res\resource.rc
+// Used by D:\Projects\miranda-ng\miranda-ng\plugins\CloudFile\res\resource.rc
//
#define IDOK 1
#define IDCANCEL 2
+#define IDD_ACCMGR 9
#define IDI_UPLOAD 101
#define IDI_DROPBOX 102
#define IDI_GDRIVE 103
@@ -22,14 +23,16 @@
#define IDC_URL_COPYTOMIA 1023
#define IDC_URL_AUTOSEND 1024
#define IDC_AUTH_TEXT 1031
+#define IDC_REQUESTACCESS 1033
+#define IDC_REVOKEACCESS 1034
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 132
+#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1033
+#define _APS_NEXT_CONTROL_VALUE 1034
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h
index b6ffbed338..9e91769740 100644
--- a/plugins/CloudFile/src/stdafx.h
+++ b/plugins/CloudFile/src/stdafx.h
@@ -36,6 +36,9 @@
#include "version.h"
#include "resource.h"
+
+class CCloudService;
+
#include "options.h"
extern HINSTANCE hInstance;