mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: MacCloud: step-79: for the previous four Cloud Drivers, extract TTokenCloudDriver / TCloudDriverAuthSession / TTokenCloudDriverConfig abstract layer
This commit is contained in:
parent
96265e6ba3
commit
eced841224
7 changed files with 102 additions and 88 deletions
|
|
@ -33,7 +33,7 @@ type
|
|||
procedure listFolderFirst; override;
|
||||
procedure listFolderContinue; override;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session; const path: String ); override;
|
||||
constructor Create( const authSession: TCloudDriverAuthSession; const path: String ); override;
|
||||
end;
|
||||
|
||||
{ TBoxDownloadSession }
|
||||
|
|
@ -81,7 +81,7 @@ type
|
|||
class function driverName: String; override;
|
||||
class function createInstance: TCloudDriver; override;
|
||||
public
|
||||
constructor Create( const config: TCloudDriverConfig );
|
||||
constructor Create( const config: TTokenCloudDriverConfig );
|
||||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function createLister( const path: String ): TCloudDriverLister; override;
|
||||
|
|
@ -102,7 +102,7 @@ type
|
|||
end;
|
||||
|
||||
var
|
||||
boxConfig: TCloudDriverConfig;
|
||||
boxConfig: TTokenCloudDriverConfig;
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ begin
|
|||
_hasMore:= ( _offset < _total );
|
||||
end;
|
||||
|
||||
constructor TBoxListFolderSession.Create( const authSession: TCloudDriverOAuth2Session; const path: String );
|
||||
constructor TBoxListFolderSession.Create( const authSession: TCloudDriverAuthSession; const path: String );
|
||||
var
|
||||
truePath: String;
|
||||
begin
|
||||
|
|
@ -511,7 +511,7 @@ begin
|
|||
Result:= TBoxClient.Create( boxConfig );
|
||||
end;
|
||||
|
||||
constructor TBoxClient.Create(const config: TCloudDriverConfig);
|
||||
constructor TBoxClient.Create(const config: TTokenCloudDriverConfig);
|
||||
var
|
||||
params: TCloudDriverOAuth2SessionParams;
|
||||
begin
|
||||
|
|
@ -532,7 +532,7 @@ var
|
|||
newClient: TBoxClient;
|
||||
begin
|
||||
newClient:= TBoxClient.Create( _config );
|
||||
newClient._authSession:= self._authSession.clone( newClient );
|
||||
newClient._authSession:= TCloudDriverOAuth2Session( self._authSession.clone(newClient) );
|
||||
Result:= newClient;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ type
|
|||
TBoxClientUtil = class
|
||||
public
|
||||
class function pathToFolderID(
|
||||
const authSession: TCloudDriverOAuth2Session;
|
||||
const authSession: TCloudDriverAuthSession;
|
||||
const path: String;
|
||||
const raiseException: Boolean = True ): String;
|
||||
class function pathToFileID(
|
||||
|
|
@ -47,11 +47,11 @@ type
|
|||
|
||||
TBoxPathToIDSession = class
|
||||
private
|
||||
_authSession: TCloudDriverOAuth2Session;
|
||||
_authSession: TCloudDriverAuthSession;
|
||||
private
|
||||
function pathToID( const path: String; const uri: String; const raiseException: Boolean ): String;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session );
|
||||
constructor Create( const authSession: TCloudDriverAuthSession );
|
||||
function pathToFolderID( const path: String; const raiseException: Boolean = True ): String;
|
||||
function pathToFileID( const path: String; const raiseException: Boolean = True ): String;
|
||||
end;
|
||||
|
|
@ -109,7 +109,7 @@ implementation
|
|||
|
||||
{ TBoxPathToIDSession }
|
||||
|
||||
constructor TBoxPathToIDSession.Create( const authSession: TCloudDriverOAuth2Session);
|
||||
constructor TBoxPathToIDSession.Create( const authSession: TCloudDriverAuthSession);
|
||||
begin
|
||||
_authSession:= authSession;
|
||||
end;
|
||||
|
|
@ -204,7 +204,7 @@ begin
|
|||
end;
|
||||
|
||||
class function TBoxClientUtil.pathToFolderID(
|
||||
const authSession: TCloudDriverOAuth2Session;
|
||||
const authSession: TCloudDriverAuthSession;
|
||||
const path: String;
|
||||
const raiseException: Boolean ): String;
|
||||
var
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type
|
|||
procedure listFolderFirst; override;
|
||||
procedure listFolderContinue; override;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session; const path: String ); override;
|
||||
constructor Create( const authSession: TCloudDriverAuthSession; const path: String ); override;
|
||||
end;
|
||||
|
||||
{ TDropBoxDownloadSession }
|
||||
|
|
@ -77,7 +77,7 @@ type
|
|||
class function driverName: String; override;
|
||||
class function createInstance: TCloudDriver; override;
|
||||
public
|
||||
constructor Create( const config: TCloudDriverConfig );
|
||||
constructor Create( const config: TTokenCloudDriverConfig );
|
||||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function createLister( const path: String ): TCloudDriverLister; override;
|
||||
|
|
@ -98,7 +98,7 @@ type
|
|||
end;
|
||||
|
||||
var
|
||||
dropBoxConfig: TCloudDriverConfig;
|
||||
dropBoxConfig: TTokenCloudDriverConfig;
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
constructor TDropBoxListFolderSession.Create( const authSession: TCloudDriverOAuth2Session; const path: String );
|
||||
constructor TDropBoxListFolderSession.Create( const authSession: TCloudDriverAuthSession; const path: String );
|
||||
var
|
||||
truePath: String;
|
||||
begin
|
||||
|
|
@ -628,7 +628,7 @@ begin
|
|||
Result:= TDropBoxClient.Create( dropBoxConfig );
|
||||
end;
|
||||
|
||||
constructor TDropBoxClient.Create(const config: TCloudDriverConfig);
|
||||
constructor TDropBoxClient.Create(const config: TTokenCloudDriverConfig);
|
||||
var
|
||||
params: TCloudDriverOAuth2SessionParams;
|
||||
begin
|
||||
|
|
@ -649,7 +649,7 @@ var
|
|||
newClient: TDropBoxClient;
|
||||
begin
|
||||
newClient:= TDropBoxClient.Create( _config );
|
||||
newClient._authSession:= self._authSession.clone( newClient );
|
||||
newClient._authSession:= TCloudDriverOAuth2Session( self._authSession.clone(newClient) );
|
||||
Result:= newClient;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type
|
|||
procedure listFolderFirst; override;
|
||||
procedure listFolderContinue; override;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session; const path: String ); override;
|
||||
constructor Create( const authSession: TCloudDriverAuthSession; const path: String ); override;
|
||||
end;
|
||||
|
||||
{ TOneDriveDownloadSession }
|
||||
|
|
@ -74,7 +74,7 @@ type
|
|||
class function driverName: String; override;
|
||||
class function createInstance: TCloudDriver; override;
|
||||
public
|
||||
constructor Create( const config: TCloudDriverConfig );
|
||||
constructor Create( const config: TTokenCloudDriverConfig );
|
||||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function createLister( const path: String ): TCloudDriverLister; override;
|
||||
|
|
@ -95,7 +95,7 @@ type
|
|||
end;
|
||||
|
||||
var
|
||||
oneDriveConfig: TCloudDriverConfig;
|
||||
oneDriveConfig: TTokenCloudDriverConfig;
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ begin
|
|||
_hasMore:= (_nextLink <> EmptyStr);
|
||||
end;
|
||||
|
||||
constructor TOneDriveListFolderSession.Create( const authSession: TCloudDriverOAuth2Session; const path: String );
|
||||
constructor TOneDriveListFolderSession.Create( const authSession: TCloudDriverAuthSession; const path: String );
|
||||
var
|
||||
truePath: String;
|
||||
begin
|
||||
|
|
@ -535,7 +535,7 @@ begin
|
|||
Result:= TOneDriveClient.Create( oneDriveConfig );
|
||||
end;
|
||||
|
||||
constructor TOneDriveClient.Create(const config: TCloudDriverConfig);
|
||||
constructor TOneDriveClient.Create(const config: TTokenCloudDriverConfig);
|
||||
var
|
||||
params: TCloudDriverOAuth2SessionParams;
|
||||
begin
|
||||
|
|
@ -556,7 +556,7 @@ var
|
|||
newClient: TOneDriveClient;
|
||||
begin
|
||||
newClient:= TOneDriveClient.Create( _config );
|
||||
newClient._authSession:= _authSession.clone( newClient );
|
||||
newClient._authSession:= TCloudDriverOAuth2Session( self._authSession.clone(newClient) );
|
||||
Result:= newClient;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ type
|
|||
|
||||
TCloudDriverResultProcessFunc = procedure ( const cloudDriverResult: TCloudDriverResult );
|
||||
|
||||
{ TCloudDriverConfig }
|
||||
{ TTokenCloudDriverConfig }
|
||||
|
||||
TCloudDriverConfig = class
|
||||
TTokenCloudDriverConfig = class
|
||||
private
|
||||
_clientID: String;
|
||||
_listenURI: String;
|
||||
|
|
@ -45,11 +45,11 @@ type
|
|||
property listenURI: String read _listenURI;
|
||||
end;
|
||||
|
||||
TCloudDriverConfigPtr = ^TCloudDriverConfig;
|
||||
TTokenCloudDriverConfigPtr = ^TTokenCloudDriverConfig;
|
||||
|
||||
{ TCloudDriverConfigWithSecret }
|
||||
{ TTokenCloudDriverConfigWithSecret }
|
||||
|
||||
TCloudDriverConfigWithSecret = class( TCloudDriverConfig )
|
||||
TTokenCloudDriverConfigWithSecret = class( TTokenCloudDriverConfig )
|
||||
private
|
||||
_clientSecret: String;
|
||||
public
|
||||
|
|
@ -125,8 +125,6 @@ type
|
|||
function authorize: Boolean; virtual; abstract;
|
||||
procedure unauthorize; virtual; abstract;
|
||||
function authorized: Boolean; virtual; abstract;
|
||||
function getToken: TCloudDriverToken; virtual; abstract;
|
||||
procedure setToken( const token: TCloudDriverToken ); virtual; abstract;
|
||||
public
|
||||
procedure download(
|
||||
const serverPath: String;
|
||||
|
|
@ -170,7 +168,7 @@ type
|
|||
{ TCloudDriverOAuth2SessionParams }
|
||||
|
||||
TCloudDriverOAuth2SessionParams = record
|
||||
config: TCloudDriverConfig;
|
||||
config: TTokenCloudDriverConfig;
|
||||
resultProcessFunc: TCloudDriverResultProcessFunc;
|
||||
scope: String;
|
||||
OAUTH2_URI: String;
|
||||
|
|
@ -180,13 +178,21 @@ type
|
|||
AUTH_TYPE: String;
|
||||
end;
|
||||
|
||||
{ TCloudDriverAuthSession }
|
||||
|
||||
TCloudDriverAuthSession = class
|
||||
public
|
||||
procedure setAuthHeader( const http: TMiniHttpClient ); virtual; abstract;
|
||||
function clone( const driver: TCloudDriver ): TCloudDriverAuthSession; virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TCloudDriverOAuth2Session }
|
||||
|
||||
TCloudDriverOAuth2Session = class
|
||||
TCloudDriverOAuth2Session = class( TCloudDriverAuthSession )
|
||||
strict protected
|
||||
_driver: TCloudDriver;
|
||||
_params: TCloudDriverOAuth2SessionParams;
|
||||
_config: TCloudDriverConfig;
|
||||
_config: TTokenCloudDriverConfig;
|
||||
_state: String;
|
||||
_code: String;
|
||||
_token: TCloudDriverToken;
|
||||
|
|
@ -211,12 +217,11 @@ type
|
|||
public
|
||||
constructor Create( const driver: TCloudDriver; const params: TCloudDriverOAuth2SessionParams );
|
||||
destructor Destroy; override;
|
||||
function clone( const driver: TCloudDriver ): TCloudDriverOAuth2Session; virtual; abstract;
|
||||
public
|
||||
function authorize: Boolean;
|
||||
procedure unauthorize;
|
||||
function authorized: Boolean;
|
||||
procedure setAuthHeader( http: TMiniHttpClient );
|
||||
procedure setAuthHeader( const http: TMiniHttpClient ); override;
|
||||
procedure setToken( const token: TCloudDriverToken );
|
||||
function getToken: TCloudDriverToken;
|
||||
end;
|
||||
|
|
@ -251,7 +256,7 @@ type
|
|||
|
||||
TCloudDriverListFolderSession = class
|
||||
protected
|
||||
_authSession: TCloudDriverOAuth2Session;
|
||||
_authSession: TCloudDriverAuthSession;
|
||||
_path: String;
|
||||
_files: TCloudFiles;
|
||||
_hasMore: Boolean;
|
||||
|
|
@ -259,7 +264,7 @@ type
|
|||
procedure listFolderFirst; virtual; abstract;
|
||||
procedure listFolderContinue; virtual; abstract;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session; const path: String ); virtual;
|
||||
constructor Create( const authSession: TCloudDriverAuthSession; const path: String ); virtual;
|
||||
destructor Destroy; override;
|
||||
function getNextFile: TCloudFile;
|
||||
end;
|
||||
|
|
@ -352,7 +357,7 @@ type
|
|||
public
|
||||
constructor Create(
|
||||
const sessionClass: TCloudDriverListFolderSessionClass;
|
||||
const authSession: TCloudDriverOAuth2Session;
|
||||
const authSession: TCloudDriverAuthSession;
|
||||
const path: String );
|
||||
destructor Destroy; override;
|
||||
procedure listFolderBegin; override;
|
||||
|
|
@ -360,15 +365,24 @@ type
|
|||
procedure listFolderEnd; override;
|
||||
end;
|
||||
|
||||
|
||||
{ TTokenCloudDriver }
|
||||
|
||||
TTokenCloudDriver = class( TCloudDriver )
|
||||
public
|
||||
function getToken: TCloudDriverToken; virtual; abstract;
|
||||
procedure setToken( const token: TCloudDriverToken ); virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TOAuth2SessionCloudDriver }
|
||||
|
||||
TOAuth2SessionCloudDriver = class( TCloudDriver )
|
||||
TOAuth2SessionCloudDriver = class( TTokenCloudDriver )
|
||||
protected
|
||||
_config: TCloudDriverConfig;
|
||||
_config: TTokenCloudDriverConfig;
|
||||
_authSession: TCloudDriverOAuth2Session;
|
||||
public
|
||||
constructor Create(
|
||||
const config: TCloudDriverConfig );
|
||||
const config: TTokenCloudDriverConfig );
|
||||
destructor Destroy; override;
|
||||
public
|
||||
function authorize: Boolean; override;
|
||||
|
|
@ -383,9 +397,9 @@ var
|
|||
|
||||
implementation
|
||||
|
||||
{ TCloudDriverConfig }
|
||||
{ TTokenCloudDriverConfig }
|
||||
|
||||
constructor TCloudDriverConfig.Create(
|
||||
constructor TTokenCloudDriverConfig.Create(
|
||||
const aClientID: String;
|
||||
const aListenURI: String );
|
||||
begin
|
||||
|
|
@ -393,9 +407,9 @@ begin
|
|||
_listenURI:= aListenURI;
|
||||
end;
|
||||
|
||||
{ TCloudDriverConfigWithSecret }
|
||||
{ TTokenCloudDriverConfigWithSecret }
|
||||
|
||||
constructor TCloudDriverConfigWithSecret.Create(const aClientID: String;
|
||||
constructor TTokenCloudDriverConfigWithSecret.Create(const aClientID: String;
|
||||
const aClientSecret: String; const aListenURI: String);
|
||||
begin
|
||||
Inherited Create( aClientID, aListenURI );
|
||||
|
|
@ -460,7 +474,7 @@ end;
|
|||
{ TCloudDriverListFolderSession }
|
||||
|
||||
constructor TCloudDriverListFolderSession.Create(
|
||||
const authSession: TCloudDriverOAuth2Session; const path: String);
|
||||
const authSession: TCloudDriverAuthSession; const path: String);
|
||||
begin
|
||||
_authSession:= authSession;
|
||||
_files:= TCloudFiles.Create;
|
||||
|
|
@ -568,7 +582,7 @@ end;
|
|||
|
||||
constructor TCloudDriverDefaultLister.Create(
|
||||
const sessionClass: TCloudDriverListFolderSessionClass;
|
||||
const authSession: TCloudDriverOAuth2Session;
|
||||
const authSession: TCloudDriverAuthSession;
|
||||
const path: String);
|
||||
begin
|
||||
_listFolderSession:= sessionClass.Create( authSession, path );
|
||||
|
|
@ -830,7 +844,7 @@ begin
|
|||
Result:= (_token.access <> EmptyStr);
|
||||
end;
|
||||
|
||||
procedure TCloudDriverOAuth2Session.setAuthHeader(http: TMiniHttpClient);
|
||||
procedure TCloudDriverOAuth2Session.setAuthHeader( const http: TMiniHttpClient );
|
||||
var
|
||||
access: String;
|
||||
begin
|
||||
|
|
@ -898,7 +912,7 @@ procedure TCloudDriverOAuth2SecretSession.onRequestToken( const queryItems: TQue
|
|||
var
|
||||
secret: String;
|
||||
begin
|
||||
secret:= TCloudDriverConfigWithSecret(_config).clientSecret;
|
||||
secret:= TTokenCloudDriverConfigWithSecret(_config).clientSecret;
|
||||
queryItems.Add( 'client_secret', secret );
|
||||
end;
|
||||
|
||||
|
|
@ -912,7 +926,7 @@ var
|
|||
queryItems: TQueryItemsDictonary;
|
||||
secret: String;
|
||||
begin
|
||||
secret:= TCloudDriverConfigWithSecret(_config).clientSecret;
|
||||
secret:= TTokenCloudDriverConfigWithSecret(_config).clientSecret;
|
||||
queryItems:= TQueryItemsDictonary.Create;
|
||||
queryItems.Add( 'client_id', _config.clientID );
|
||||
queryItems.Add( 'client_secret', secret );
|
||||
|
|
@ -980,7 +994,7 @@ end;
|
|||
{ TOAuth2SessionCloudDriver }
|
||||
|
||||
constructor TOAuth2SessionCloudDriver.Create(
|
||||
const config: TCloudDriverConfig );
|
||||
const config: TTokenCloudDriverConfig );
|
||||
begin
|
||||
_config:= config;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type
|
|||
procedure listFolderFirst; override;
|
||||
procedure listFolderContinue; override;
|
||||
public
|
||||
constructor Create( const authSession: TCloudDriverOAuth2Session; const path: String ); override;
|
||||
constructor Create( const authSession: TCloudDriverAuthSession; const path: String ); override;
|
||||
end;
|
||||
|
||||
{ TYandexDownloadSession }
|
||||
|
|
@ -77,7 +77,7 @@ type
|
|||
class function driverName: String; override;
|
||||
class function createInstance: TCloudDriver; override;
|
||||
public
|
||||
constructor Create( const config: TCloudDriverConfig );
|
||||
constructor Create( const config: TTokenCloudDriverConfig );
|
||||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function createLister( const path: String ): TCloudDriverLister; override;
|
||||
|
|
@ -98,7 +98,7 @@ type
|
|||
end;
|
||||
|
||||
var
|
||||
yandexConfig: TCloudDriverConfig;
|
||||
yandexConfig: TTokenCloudDriverConfig;
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ begin
|
|||
_hasMore:= ( _offset < _total );
|
||||
end;
|
||||
|
||||
constructor TYandexListFolderSession.Create( const authSession: TCloudDriverOAuth2Session; const path: String );
|
||||
constructor TYandexListFolderSession.Create( const authSession: TCloudDriverAuthSession; const path: String );
|
||||
var
|
||||
truePath: String;
|
||||
begin
|
||||
|
|
@ -516,7 +516,7 @@ begin
|
|||
Result:= TYandexClient.Create( yandexConfig );
|
||||
end;
|
||||
|
||||
constructor TYandexClient.Create(const config: TCloudDriverConfig);
|
||||
constructor TYandexClient.Create(const config: TTokenCloudDriverConfig);
|
||||
var
|
||||
params: TCloudDriverOAuth2SessionParams;
|
||||
begin
|
||||
|
|
@ -537,7 +537,7 @@ var
|
|||
newClient: TYandexClient;
|
||||
begin
|
||||
newClient:= TYandexClient.Create( _config );
|
||||
newClient._authSession:= _authSession.clone( newClient );
|
||||
newClient._authSession:= TCloudDriverOAuth2Session( self._authSession.clone(newClient) );
|
||||
Result:= newClient;
|
||||
end;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,80 +52,80 @@ implementation
|
|||
|
||||
type
|
||||
|
||||
{ TTokenCloudDriverConfig }
|
||||
{ TMacTokenCloudDriverConfig }
|
||||
|
||||
TTokenCloudDriverConfig = class( TMacCloudDriverConfig )
|
||||
TMacTokenCloudDriverConfig = class( TMacCloudDriverConfig )
|
||||
class procedure loadSecurity( const driver: TCloudDriver; const params: NSDictionary ); override;
|
||||
class procedure saveSecurity( const driver: TCloudDriver; const params: NSMutableDictionary ); override;
|
||||
class procedure loadCommon( const params: NSDictionary ); override;
|
||||
class procedure saveCommon( const params: NSMutableDictionary ); override;
|
||||
class function cloudDriverConfigPtr: TCloudDriverConfigPtr; virtual; abstract;
|
||||
class function cloudDriverConfigPtr: TTokenCloudDriverConfigPtr; virtual; abstract;
|
||||
class function cloudDriverClass: TCloudDriverClass; virtual; abstract;
|
||||
end;
|
||||
|
||||
{ TDropBoxCloudDriverConfig }
|
||||
|
||||
TDropBoxCloudDriverConfig = class( TTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TCloudDriverConfigPtr; override;
|
||||
TDropBoxCloudDriverConfig = class( TMacTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TTokenCloudDriverConfigPtr; override;
|
||||
class function cloudDriverClass: TCloudDriverClass; override;
|
||||
end;
|
||||
|
||||
{ TYandexCloudDriverConfig }
|
||||
|
||||
TYandexCloudDriverConfig = class( TTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TCloudDriverConfigPtr; override;
|
||||
TYandexCloudDriverConfig = class( TMacTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TTokenCloudDriverConfigPtr; override;
|
||||
class function cloudDriverClass: TCloudDriverClass; override;
|
||||
end;
|
||||
|
||||
{ TOneDriveCloudDriverConfig }
|
||||
|
||||
TOneDriveCloudDriverConfig = class( TTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TCloudDriverConfigPtr; override;
|
||||
TOneDriveCloudDriverConfig = class( TMacTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TTokenCloudDriverConfigPtr; override;
|
||||
class function cloudDriverClass: TCloudDriverClass; override;
|
||||
end;
|
||||
|
||||
{ TBoxCloudDriverConfig }
|
||||
|
||||
TBoxCloudDriverConfig = class( TTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TCloudDriverConfigPtr; override;
|
||||
TBoxCloudDriverConfig = class( TMacTokenCloudDriverConfig )
|
||||
class function cloudDriverConfigPtr: TTokenCloudDriverConfigPtr; override;
|
||||
class function cloudDriverClass: TCloudDriverClass; override;
|
||||
end;
|
||||
|
||||
{ TTokenCloudDriverConfig }
|
||||
{ TMacTokenCloudDriverConfig }
|
||||
|
||||
class procedure TTokenCloudDriverConfig.loadCommon(const params: NSDictionary);
|
||||
class procedure TMacTokenCloudDriverConfig.loadCommon(const params: NSDictionary);
|
||||
var
|
||||
clientID: String;
|
||||
clientSecret: String;
|
||||
listenURI: String;
|
||||
oldCloudDriverConfig: TCloudDriverConfig;
|
||||
oldCloudDriverConfig: TTokenCloudDriverConfig;
|
||||
begin
|
||||
clientID:= TJsonUtil.getString( params, 'clientID' );
|
||||
clientSecret:= TJsonUtil.getString( params, 'clientSecret' );
|
||||
listenURI:= TJsonUtil.getString( params, 'listenURI' );
|
||||
oldCloudDriverConfig:= self.cloudDriverConfigPtr^;
|
||||
if clientSecret = EmptyStr then begin
|
||||
self.cloudDriverConfigPtr^:= TCloudDriverConfig.Create( clientID, listenURI );
|
||||
self.cloudDriverConfigPtr^:= TTokenCloudDriverConfig.Create( clientID, listenURI );
|
||||
end else begin
|
||||
self.cloudDriverConfigPtr^:= TCloudDriverConfigWithSecret.Create( clientID, clientSecret, listenURI );
|
||||
self.cloudDriverConfigPtr^:= TTokenCloudDriverConfigWithSecret.Create( clientID, clientSecret, listenURI );
|
||||
end;
|
||||
if Assigned(oldCloudDriverConfig) then
|
||||
oldCloudDriverConfig.Free;
|
||||
cloudDriverManager.register( self.cloudDriverClass );
|
||||
end;
|
||||
|
||||
class procedure TTokenCloudDriverConfig.saveCommon(const params: NSMutableDictionary);
|
||||
class procedure TMacTokenCloudDriverConfig.saveCommon(const params: NSMutableDictionary);
|
||||
var
|
||||
cloudDriverConfig: TCloudDriverConfig;
|
||||
cloudDriverConfig: TTokenCloudDriverConfig;
|
||||
begin
|
||||
cloudDriverConfig:= self.cloudDriverConfigPtr^;
|
||||
TJsonUtil.setString( params, 'clientID', cloudDriverConfig.clientID );
|
||||
TJsonUtil.setString( params, 'listenURI', cloudDriverConfig.listenURI );
|
||||
if cloudDriverConfig is TCloudDriverConfigWithSecret then
|
||||
TJsonUtil.setString( params, 'clientSecret', TCloudDriverConfigWithSecret(cloudDriverConfig).clientSecret );
|
||||
if cloudDriverConfig is TTokenCloudDriverConfigWithSecret then
|
||||
TJsonUtil.setString( params, 'clientSecret', TTokenCloudDriverConfigWithSecret(cloudDriverConfig).clientSecret );
|
||||
end;
|
||||
|
||||
class procedure TTokenCloudDriverConfig.loadSecurity(
|
||||
class procedure TMacTokenCloudDriverConfig.loadSecurity(
|
||||
const driver: TCloudDriver; const params: NSDictionary);
|
||||
var
|
||||
token: TCloudDriverToken;
|
||||
|
|
@ -136,10 +136,10 @@ begin
|
|||
TJsonUtil.getString( jsonToken, 'access' ),
|
||||
TJsonUtil.getString( jsonToken, 'refresh' ),
|
||||
TJsonUtil.getDateTime( jsonToken, 'accessExpirationTime' ) );
|
||||
driver.setToken( token );
|
||||
TTokenCloudDriver(driver).setToken( token );
|
||||
end;
|
||||
|
||||
class procedure TTokenCloudDriverConfig.saveSecurity(
|
||||
class procedure TMacTokenCloudDriverConfig.saveSecurity(
|
||||
const driver: TCloudDriver; const params: NSMutableDictionary);
|
||||
var
|
||||
client: TDropBoxClient absolute driver;
|
||||
|
|
@ -157,7 +157,7 @@ end;
|
|||
|
||||
{ TDropBoxCloudDriverConfig }
|
||||
|
||||
class function TDropBoxCloudDriverConfig.cloudDriverConfigPtr: TCloudDriverConfigPtr;
|
||||
class function TDropBoxCloudDriverConfig.cloudDriverConfigPtr: TTokenCloudDriverConfigPtr;
|
||||
begin
|
||||
Result:= @dropBoxConfig;
|
||||
end;
|
||||
|
|
@ -169,7 +169,7 @@ end;
|
|||
|
||||
{ TYandexCloudDriverConfig }
|
||||
|
||||
class function TYandexCloudDriverConfig.cloudDriverConfigPtr: TCloudDriverConfigPtr;
|
||||
class function TYandexCloudDriverConfig.cloudDriverConfigPtr: TTokenCloudDriverConfigPtr;
|
||||
begin
|
||||
Result:= @yandexConfig;
|
||||
end;
|
||||
|
|
@ -181,7 +181,7 @@ end;
|
|||
|
||||
{ TOneDriveCloudDriverConfig }
|
||||
|
||||
class function TOneDriveCloudDriverConfig.cloudDriverConfigPtr: TCloudDriverConfigPtr;
|
||||
class function TOneDriveCloudDriverConfig.cloudDriverConfigPtr: TTokenCloudDriverConfigPtr;
|
||||
begin
|
||||
Result:= @oneDriveConfig;
|
||||
end;
|
||||
|
|
@ -193,7 +193,7 @@ end;
|
|||
|
||||
{ TBoxCloudDriverConfig }
|
||||
|
||||
class function TBoxCloudDriverConfig.cloudDriverConfigPtr: TCloudDriverConfigPtr;
|
||||
class function TBoxCloudDriverConfig.cloudDriverConfigPtr: TTokenCloudDriverConfigPtr;
|
||||
begin
|
||||
Result:= @boxConfig;
|
||||
end;
|
||||
|
|
@ -424,19 +424,19 @@ begin
|
|||
macCloudDriverConfigManager:= TMacCloudConfigManager.Create;
|
||||
|
||||
macCloudDriverConfigManager.register( TDropBoxClient.driverName, TDropBoxCloudDriverConfig );
|
||||
dropBoxConfig:= TCloudDriverConfig.Create( 'ahj0s9xia6i61gh', 'dc2ea085a05ac273a://dropbox/auth' );
|
||||
dropBoxConfig:= TTokenCloudDriverConfig.Create( 'ahj0s9xia6i61gh', 'dc2ea085a05ac273a://dropbox/auth' );
|
||||
cloudDriverManager.register( TDropBoxClient );
|
||||
|
||||
macCloudDriverConfigManager.register( TYandexClient.driverName, TYandexCloudDriverConfig );
|
||||
yandexConfig:= TCloudDriverConfig.Create( 'eaf0c133568a46a0bd986bffb48c62b6', 'dc2ea085a05ac273a://yandex/auth' );
|
||||
yandexConfig:= TTokenCloudDriverConfig.Create( 'eaf0c133568a46a0bd986bffb48c62b6', 'dc2ea085a05ac273a://yandex/auth' );
|
||||
cloudDriverManager.register( TYandexClient );
|
||||
|
||||
macCloudDriverConfigManager.register( TOneDriveClient.driverName, TOneDriveCloudDriverConfig );
|
||||
oneDriveConfig:= TCloudDriverConfig.Create( '', 'dc2ea085a05ac273a://onedrive/auth' );
|
||||
oneDriveConfig:= TTokenCloudDriverConfig.Create( '', 'dc2ea085a05ac273a://onedrive/auth' );
|
||||
cloudDriverManager.register( TOneDriveClient );
|
||||
|
||||
macCloudDriverConfigManager.register( TBoxClient.driverName, TBoxCloudDriverConfig );
|
||||
boxConfig:= TCloudDriverConfigWithSecret.Create( '', '', 'dc2ea085a05ac273a://box/auth' );
|
||||
boxConfig:= TTokenCloudDriverConfigWithSecret.Create( '', '', 'dc2ea085a05ac273a://box/auth' );
|
||||
cloudDriverManager.register( TBoxClient );
|
||||
end;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue