mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: MacCloud/Options: step-125: check connection params in S3 Options Window
This commit is contained in:
parent
35d1d92111
commit
f36c3e9af4
3 changed files with 33 additions and 14 deletions
|
|
@ -155,16 +155,15 @@ type
|
|||
_authSession: TAWSAuthSession;
|
||||
_buckets: TS3Buckets;
|
||||
protected
|
||||
function getAllBuckets: TS3Buckets; virtual; abstract;
|
||||
function getConcreteClass: TCloudDriverClass; virtual; abstract;
|
||||
function getConnectionDataOfBucket( const name: String ): TAWSConnectionData;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
public
|
||||
function clone: TCloudDriver; override;
|
||||
public
|
||||
function createLister( const path: String ): TCloudDriverLister; override;
|
||||
function getAllBuckets: TS3Buckets; virtual; abstract;
|
||||
public
|
||||
function authorize: Boolean; override;
|
||||
procedure unauthorize; override;
|
||||
|
|
@ -586,6 +585,14 @@ end;
|
|||
|
||||
procedure TS3Buckets.add( const bucket: TS3Bucket );
|
||||
begin
|
||||
if (bucket.connectionData.bucketName=EmptyStr) or
|
||||
(bucket.connectionData.region=EmptyStr) or
|
||||
(bucket.connectionData.endPoint=EmptyStr)
|
||||
then begin
|
||||
bucket.Free;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
_items.Add( bucket );
|
||||
end;
|
||||
|
||||
|
|
@ -762,14 +769,6 @@ var
|
|||
|
||||
bucket:= TS3Bucket.Create;
|
||||
bucket.connectionData:= self.getDefaultConnectionData;
|
||||
if (bucket.connectionData.bucketName=EmptyStr) or
|
||||
(bucket.connectionData.region=EmptyStr) or
|
||||
(bucket.connectionData.endPoint=EmptyStr)
|
||||
then begin
|
||||
bucket.Free;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
_buckets.add( bucket );
|
||||
end;
|
||||
|
||||
|
|
@ -811,6 +810,7 @@ end;
|
|||
procedure TS3Client.setAccessKey(const accessKey: TAWSAccessKey);
|
||||
begin
|
||||
_authSession.accessKey:= accessKey;
|
||||
FreeAndNil( _buckets );
|
||||
end;
|
||||
|
||||
function TS3Client.getDefaultConnectionData: TAWSConnectionData;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ interface
|
|||
uses
|
||||
Classes, SysUtils,
|
||||
CocoaAll, uMiniCocoa,
|
||||
uAWSCore,
|
||||
uAWSCore, uS3Client,
|
||||
uWFXPlugin, uWFXUtil, uWFXOptionsCore,
|
||||
uMiniUtil;
|
||||
|
||||
|
|
@ -233,9 +233,27 @@ end;
|
|||
procedure TWFXS3PropertyView.saveConnection(sender: NSObject);
|
||||
var
|
||||
configItem: TWFXConnectionConfigItem;
|
||||
client: TAWSCloudDriver;
|
||||
client: TS3Client;
|
||||
data: TAWSConnectionData;
|
||||
accessKey: TAWSAccessKey;
|
||||
|
||||
procedure checkConnectionParams;
|
||||
var
|
||||
count: Integer;
|
||||
alert: NSAlert;
|
||||
begin
|
||||
count:= client.getAllBuckets.Count;
|
||||
if count > 0 then
|
||||
Exit;
|
||||
|
||||
alert:= NSAlert.new;
|
||||
alert.setMessageText( StringToNSString('Incomplete Parameters') );
|
||||
alert.setInformativeText( StringToNSString('Access Key ID and Secret Access Key are required, please make sure they are correct. If permissions are insufficient or you are setting "S3 Compatible", Region / Endpoint / Bucket is also required.') );
|
||||
alert.addButtonWithTitle( StringToNSString('OK') );
|
||||
alert.runModal;
|
||||
alert.release;
|
||||
end;
|
||||
|
||||
begin
|
||||
configItem:= _controller.currentConfigItem;
|
||||
if configItem = nil then
|
||||
|
|
@ -244,7 +262,7 @@ begin
|
|||
if _secretButton.state = NSOnState then
|
||||
_accessKeySecretTextField.setStringValue( _accessKeySecretPlainTextField.stringValue );
|
||||
|
||||
client:= TAWSCloudDriver( configItem.driver );
|
||||
client:= TS3Client( configItem.driver );
|
||||
|
||||
data.region:= _regionTextField.stringValue.UTF8String;
|
||||
data.endPoint:= _endPointTextField.stringValue.UTF8String;
|
||||
|
|
@ -258,6 +276,7 @@ begin
|
|||
client.setAccessKey( accessKey );
|
||||
|
||||
_controller.saveConnection( _nameTextField.stringValue );
|
||||
checkConnectionParams;
|
||||
end;
|
||||
|
||||
procedure TWFXS3PropertyView.initPropertyView;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ var
|
|||
alert:= NSAlert.new;
|
||||
alert.setMessageText( StringToNSString('Duplicate Name') );
|
||||
alert.setInformativeText( StringToNSString('Please rename the Connection before saving.') );
|
||||
alert.addButtonWithTitle( NSSTR('OK') );
|
||||
alert.addButtonWithTitle( StringToNSString('OK') );
|
||||
alert.runModal;
|
||||
alert.release;
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue