mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: MacCloud/DropBox step-26: support unauthorize
This commit is contained in:
parent
6ba66fdb58
commit
3090277c21
3 changed files with 74 additions and 14 deletions
|
|
@ -91,6 +91,8 @@ type
|
|||
function clone: TDropBoxAuthPKCESession;
|
||||
public
|
||||
function authorize: Boolean;
|
||||
procedure unauthorize;
|
||||
function authorized: Boolean;
|
||||
procedure setAuthHeader( http: TMiniHttpClient );
|
||||
end;
|
||||
|
||||
|
|
@ -204,6 +206,8 @@ type
|
|||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function authorize: Boolean; override;
|
||||
procedure unauthorize; override;
|
||||
function authorized: Boolean; override;
|
||||
public
|
||||
procedure listFolderBegin( const path: String ); override;
|
||||
function listFolderGetNextFile: TCloudFile; override;
|
||||
|
|
@ -627,12 +631,22 @@ begin
|
|||
requestAuthorization;
|
||||
TThread.Synchronize( TThread.CurrentThread, @waitAuthorizationAndPrompt );
|
||||
requestToken;
|
||||
Result:= (_token.access <> EmptyStr);
|
||||
Result:= self.authorized;
|
||||
finally
|
||||
_lockObject.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDropBoxAuthPKCESession.unauthorize;
|
||||
begin
|
||||
_token.invalid;
|
||||
end;
|
||||
|
||||
function TDropBoxAuthPKCESession.authorized: Boolean;
|
||||
begin
|
||||
Result:= (_token.access <> EmptyStr);
|
||||
end;
|
||||
|
||||
procedure TDropBoxAuthPKCESession.setAuthHeader(http: TMiniHttpClient);
|
||||
var
|
||||
access: String;
|
||||
|
|
@ -1130,6 +1144,16 @@ begin
|
|||
Result:= _authSession.authorize;
|
||||
end;
|
||||
|
||||
procedure TDropBoxClient.unauthorize;
|
||||
begin
|
||||
_authSession.unauthorize;
|
||||
end;
|
||||
|
||||
function TDropBoxClient.authorized: Boolean;
|
||||
begin
|
||||
Result:= _authSession.authorized;
|
||||
end;
|
||||
|
||||
procedure TDropBoxClient.listFolderBegin(const path: String);
|
||||
begin
|
||||
if Assigned(_listFolderSession) then
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ type
|
|||
function clone: TCloudDriver; virtual; abstract;
|
||||
public
|
||||
function authorize: Boolean; virtual; abstract;
|
||||
procedure unauthorize; virtual; abstract;
|
||||
function authorized: Boolean; virtual; abstract;
|
||||
public
|
||||
procedure download(
|
||||
const serverPath: String;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ type
|
|||
procedure addConnection( sender: NSObject ); message 'TCloudConfigItemsController_addConnection:';
|
||||
procedure removeConnection( sender: NSObject ); message 'TCloudConfigItemsController_removeConnection:';
|
||||
procedure saveConnection( sender: NSObject ); message 'TCloudConfigItemsController_saveConnection:';
|
||||
procedure connect( sender: NSObject ); message 'TCloudConfigItemsController_connect:';
|
||||
procedure connectOrDisconnect( sender: NSObject ); message 'TCloudConfigItemsController_connectOrDisconnect:';
|
||||
function currentConfigItem: TConnectionConfigItem; message 'TCloudConfigItemsController_currentConfigItem';
|
||||
procedure onSelectedConnectionChanged( const selectedIndex: Integer );
|
||||
message 'TCloudConfigItemsController_onSelectedConnectionChanged:';
|
||||
|
|
@ -89,8 +89,11 @@ type
|
|||
private
|
||||
controller: TCloudConfigItemsController;
|
||||
nameTextField: NSTextField;
|
||||
connectButton: NSButton;
|
||||
statusImageview: NSImageView;
|
||||
public
|
||||
procedure loadConnectionProperties( const index: Integer ); message 'TPropertyView_loadConnectionProperties:';
|
||||
procedure updateConnectStatus; message 'TPropertyView_updateConnectStatus';
|
||||
end;
|
||||
|
||||
{ TCloudOptionsWindow }
|
||||
|
|
@ -112,7 +115,7 @@ type
|
|||
procedure addConnection( sender: NSObject );
|
||||
procedure removeConnection( sender: NSObject );
|
||||
procedure saveConnection( sender: NSObject );
|
||||
procedure connect( sender: NSObject );
|
||||
procedure connectOrDisconnect( sender: NSObject );
|
||||
function currentConfigItem: TConnectionConfigItem;
|
||||
procedure onSelectedConnectionChanged( const selectedIndex: Integer );
|
||||
public
|
||||
|
|
@ -129,6 +132,25 @@ begin
|
|||
if configItem = nil then
|
||||
Exit;
|
||||
self.nameTextField.setStringValue( configItem.name );
|
||||
self.updateConnectStatus;
|
||||
end;
|
||||
|
||||
procedure TPropertyView.updateConnectStatus;
|
||||
var
|
||||
configItem: TConnectionConfigItem;
|
||||
connectButtonText: String;
|
||||
statusImageName: NSString;
|
||||
begin
|
||||
configItem:= controller.currentConfigItem;
|
||||
if configItem.driver.authorized then begin
|
||||
statusImageName:= NSImageNameStatusAvailable;
|
||||
connectButtonText:= 'Disconnect';
|
||||
end else begin
|
||||
statusImageName:= NSImageNameStatusUnavailable;
|
||||
connectButtonText:= 'Connect';
|
||||
end;
|
||||
self.statusImageView.setImage( NSImage.imageNamed(statusImageName) );
|
||||
self.connectButton.setTitle( StringToNSString(connectButtonText) );
|
||||
end;
|
||||
|
||||
{ TConnectionConfigItem }
|
||||
|
|
@ -272,12 +294,18 @@ begin
|
|||
self.connectionListView.selectRow_byExtendingSelection( currentIndex, False );
|
||||
end;
|
||||
|
||||
procedure TCloudOptionsWindow.connect(sender: NSObject);
|
||||
procedure TCloudOptionsWindow.connectOrDisconnect(sender: NSObject);
|
||||
var
|
||||
configItem: TConnectionConfigItem;
|
||||
driver: TCloudDriver;
|
||||
begin
|
||||
configItem:= self.currentConfigItem;
|
||||
configItem.driver.authorize;
|
||||
driver:= configItem.driver;
|
||||
if driver.authorized then
|
||||
driver.unauthorize
|
||||
else
|
||||
driver.authorize;
|
||||
self.propertyView.updateConnectStatus;
|
||||
end;
|
||||
|
||||
function TCloudOptionsWindow.currentConfigItem: TConnectionConfigItem;
|
||||
|
|
@ -413,7 +441,8 @@ var
|
|||
var
|
||||
nameLabel: NSTextField;
|
||||
nameTextField: NSTextField;
|
||||
connectionButton: NSButton;
|
||||
connectButton: NSButton;
|
||||
statusImageView: NSImageView;
|
||||
saveButton: NSButton;
|
||||
noteTextView: NSTextView;
|
||||
begin
|
||||
|
|
@ -432,15 +461,20 @@ var
|
|||
rightView.addSubview( nameTextField );
|
||||
nameTextField.release;
|
||||
|
||||
connectionButton:= NSButton.alloc.initWithFrame( NSMakeRect(70,450,80,22) );
|
||||
connectionButton.setBezelStyle( NSRoundedBezelStyle );
|
||||
connectionButton.setTitle( NSSTR('Connect') );
|
||||
connectionButton.setTarget( win );
|
||||
connectionButton.setAction( ObjCSelector('TCloudConfigItemsController_connect:') );
|
||||
rightView.addSubView( connectionButton );
|
||||
connectionButton.release;
|
||||
statusImageView:= NSImageView.alloc.initWithFrame( NSMakeRect(350,503,16,16) );
|
||||
rightView.statusImageview:= statusImageView;
|
||||
rightView.addSubview( statusImageView );
|
||||
statusImageView.release;
|
||||
|
||||
saveButton:= NSButton.alloc.initWithFrame( NSMakeRect(200,450,80,22) );
|
||||
connectButton:= NSButton.alloc.initWithFrame( NSMakeRect(80,450,100,22) );
|
||||
connectButton.setBezelStyle( NSRoundedBezelStyle );
|
||||
connectButton.setTarget( win );
|
||||
connectButton.setAction( ObjCSelector('TCloudConfigItemsController_connectOrDisconnect:') );
|
||||
rightView.connectButton:= connectButton;
|
||||
rightView.addSubView( connectButton );
|
||||
connectButton.release;
|
||||
|
||||
saveButton:= NSButton.alloc.initWithFrame( NSMakeRect(200,450,100,22) );
|
||||
saveButton.setBezelStyle( NSRoundedBezelStyle );
|
||||
saveButton.setTitle( NSSTR('Save') );
|
||||
saveButton.setTarget( win );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue