UPD: MacCloud/DropBox step-23: the infrastructure for managing Cloud Connection

This commit is contained in:
rich2014 2025-04-06 11:52:01 +08:00
commit 90604a968f
2 changed files with 38 additions and 14 deletions

View file

@ -422,26 +422,38 @@ var
begin
dropBoxConfig:= TDropBoxConfig.Create( 'ahj0s9xia6i61gh', 'dc2ea085a05ac273a://dropbox/auth' );
cloudDriverManager.register( TDropBoxClient );
driver:= cloudDriverManager.createInstance( 'DropBox' );
connection:= TCloudConnection.Create( 'rich', driver );
cloudConnectionManager.add( connection );
end;
{ TCloudRootListFolder }
procedure TCloudRootListFolder.listFolderBegin(const path: String);
var
cloudFile: TCloudFile;
procedure addNewCommand;
var
cloudFile: TCloudFile;
begin
cloudFile:= TCloudFile.Create;
cloudFile.name:= CONST_ADD_NEW_CONNECTION;
_list.Add( cloudFile );
end;
procedure addConnections;
var
cloudFile: TCloudFile;
connection: TCloudConnection;
i: Integer;
begin
for i:= 0 to cloudConnectionManager.connections.Count - 1 do begin;
connection:= TCloudConnection( cloudConnectionManager.connections[i] );
cloudFile:= TCloudFile.Create;
cloudFile.name:= connection.name;
_list.Add( cloudFile );
end;
end;
begin
_list:= TFPList.Create;
cloudFile:= TCloudFile.Create;
cloudFile.name:= CONST_ADD_NEW_CONNECTION;
_list.Add( cloudFile );
cloudFile:= TCloudFile.Create;
cloudFile.name:= 'rich';
_list.Add( cloudFile );
addNewCommand;
addConnections;
end;
function TCloudRootListFolder.listFolderGetNextFile: TCloudFile;

View file

@ -116,10 +116,12 @@ type
public
constructor Create;
destructor Destroy; override;
private
procedure setConnections( const connections: TCloudConnections );
public
procedure add( const connection: TCloudConnection );
function get( const name: String ): TCloudConnection;
property connections: TCloudConnections read _connections;
property connections: TCloudConnections read _connections write setConnections;
end;
var
@ -214,6 +216,16 @@ begin
FreeAndNil( _connections );
end;
procedure TCloudConnectionManager.setConnections(
const connections: TCloudConnections);
var
oldConnections: TCloudConnections;
begin
oldConnections:= _connections;
_connections:= connections;
FreeAndNil( oldConnections );
end;
procedure TCloudConnectionManager.add(const connection: TCloudConnection);
begin
_connections.Add( connection );