Changeset 361


Ignore:
Timestamp:
May 8, 2012, 10:24:35 PM (13 years ago)
Author:
chronos
Message:
Location:
PersistentData
Files:
10 added
7 edited

Legend:

Unmodified
Added
Removed
  • PersistentData/Backend/UPDClientINI.pas

    r345 r361  
    1313
    1414  TPDClientINI = class(TPDClient)
     15  public
    1516    IniFile: TIniFile;
    1617    //procedure GetItemList(Condition: TCondition; ItemList: TItemList); override;
    1718    //procedure SetItemList(Condition: TCondition; ItemList: TItemList); override;
    1819    FileName: string;
    19     constructor Create; override;
     20    constructor Create(AOwner: TComponent); override;
    2021    destructor Destroy; override;
    2122    procedure Connect; override;
     
    3940end;*)
    4041
    41 constructor TPDClientINI.Create;
     42constructor TPDClientINI.Create(AOwner: TComponent);
    4243begin
    43   inherited Create;
     44  inherited;
     45  BackendName := 'INI';
    4446end;
    4547
  • PersistentData/Backend/UPDClientMySQL.pas

    r345 r361  
    1414  TPDClientMySQL = class(TPDClient)
    1515  protected
     16    FHost: string;
     17    FPort: Word;
     18    FUser: string;
     19    FPassword: string;
     20    FDatabase: TSqlDatabase;
    1621    procedure InitSystemTypes; override;
    1722    function GetConnected: Boolean; override;
    1823    procedure Init; override;
    1924  public
    20     Database: TSqlDatabase;
    2125    procedure ObjectLoad(AObject: TObjectProxy); override;
    2226    procedure ObjectSave(AObject: TObjectProxy); override;
     
    2933    procedure Install;
    3034    procedure Uninstall;
    31     constructor Create; override;
     35    constructor Create(AOwner: TComponent); override;
    3236    destructor Destroy; override;
    3337    procedure Connect; override;
    3438    procedure Disconnect; override;
     39  published
     40    property Database: TSqlDatabase read FDatabase write FDatabase;
     41    property Host: string read FHost write FHost;
     42    property Port: Word read FPort write FPort;
     43    property User: string read FUser write FUser;
     44    property Password: string read FPassword write FPassword;
    3545  end;
    3646
     
    236246end;
    237247
    238 constructor TPDClientMySQL.Create;
     248constructor TPDClientMySQL.Create(AOwner: TComponent);
    239249begin
    240250  inherited;
    241   Database := TSqlDatabase.Create(nil);
     251  FDatabase := TSqlDatabase.Create(nil);
     252  BackendName := 'MySQL';
    242253end;
    243254
    244255destructor TPDClientMySQL.Destroy;
    245256begin
    246   FreeAndNil(Database);
     257  FreeAndNil(FDatabase);
    247258  inherited Destroy;
    248259end;
     
    250261procedure TPDClientMySQL.Connect;
    251262begin
    252   Database.Port := Port;
    253   Database.UserName := User;
    254   Database.Password := Password;
    255   Database.HostName := Host;
    256   Database.Database := Schema;
    257   Database.Connect;
    258   Init;
     263  if not Connected then begin
     264    Database.Port := Port;
     265    Database.UserName := User;
     266    Database.Password := Password;
     267    Database.HostName := Host;
     268    Database.Database := Schema;
     269    Database.Connect;
     270    Init;
     271  end;
    259272end;
    260273
    261274procedure TPDClientMySQL.Disconnect;
    262275begin
    263   Database.Disconnect;
     276  if Connected then Database.Disconnect;
    264277end;
    265278
  • PersistentData/Backend/UPDClientRegistry.pas

    r345 r361  
    1616    //procedure GetItemList(Condition: TCondition; ItemList: TItemList); override;
    1717    //procedure SetItemList(Condition: TCondition; ItemList: TItemList); override;
    18     constructor Create; override;
     18    constructor Create(AOwner: TComponent); override;
    1919    destructor Destroy; override;
    2020  end;
     
    3636end;*)
    3737
    38 constructor TPDClientRegistry.Create;
     38constructor TPDClientRegistry.Create(AOwner: TComponent);
    3939begin
     40  inherited;
    4041  Reg := TRegistry.Create;
    41   inherited Create;
     42  BackendName := 'Windows registry';
    4243end;
    4344
  • PersistentData/Backend/UPDClientXMLRPC.pas

    r340 r361  
    1313
    1414  TPDClientXMLRPC = class(TPDClient)
     15    constructor Create(AOwner: TComponent); override;
    1516  end;
    1617
     
    1819
    1920
     21{ TPDClientXMLRPC }
     22
     23constructor TPDClientXMLRPC.Create(AOwner: TComponent);
     24begin
     25  inherited Create(AOwner);
     26  BackendName := 'XMLRPC';
     27end;
     28
    2029end.
    2130
  • PersistentData/PersistentData.lpk

    r340 r361  
    1010      <SearchPaths>
    1111        <OtherUnitFiles Value="Backend"/>
    12         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\"/>
     12        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    1313      </SearchPaths>
    1414      <CodeGeneration>
     
    3030    <License Value="GNU/GPL"/>
    3131    <Version Minor="1"/>
    32     <Files Count="6">
     32    <Files Count="8">
    3333      <Item1>
    3434        <Filename Value="UPDServer.pas"/>
    35         <UnitName Value="UChronisServer"/>
     35        <UnitName Value="UPDServer"/>
    3636      </Item1>
    3737      <Item2>
    3838        <Filename Value="UPDClient.pas"/>
    39         <UnitName Value="UChronisClient"/>
     39        <UnitName Value="UPDClient"/>
    4040      </Item2>
    4141      <Item3>
    4242        <Filename Value="Backend\UPDClientXMLRPC.pas"/>
    43         <UnitName Value="UChronisClientXMLRPC"/>
     43        <UnitName Value="UPDClientXMLRPC"/>
    4444      </Item3>
    4545      <Item4>
    4646        <Filename Value="Backend\UPDClientINI.pas"/>
    47         <UnitName Value="UChronisClientDirect"/>
     47        <UnitName Value="UPDClientINI"/>
    4848      </Item4>
    4949      <Item5>
    5050        <Filename Value="Backend\UPDClientMySQL.pas"/>
    51         <UnitName Value="UChronisClientMySQL"/>
     51        <UnitName Value="UPDClientMySQL"/>
    5252      </Item5>
    5353      <Item6>
    5454        <Filename Value="Backend\UPDClientRegistry.pas"/>
    55         <UnitName Value="UChronisClientDirect"/>
     55        <UnitName Value="UPDClientRegistry"/>
    5656      </Item6>
     57      <Item7>
     58        <Filename Value="UPersistentData.pas"/>
     59        <HasRegisterProc Value="True"/>
     60        <UnitName Value="UPersistentData"/>
     61      </Item7>
     62      <Item8>
     63        <Filename Value="Backend\UPDClientMemory.pas"/>
     64        <UnitName Value="UPDClientMemory"/>
     65      </Item8>
    5766    </Files>
    5867    <Type Value="RunAndDesignTime"/>
  • PersistentData/PersistentData.pas

    r340 r361  
    99uses
    1010  UPDServer, UPDClient, UPDClientXMLRPC, UPDClientINI, UPDClientMySQL,
    11   UPDClientRegistry, LazarusPackageIntf;
     11  UPDClientRegistry, UPersistentData, UPDClientMemory, LazarusPackageIntf;
    1212
    1313implementation
     
    1515procedure Register;
    1616begin
     17  RegisterUnit('UPersistentData', @UPersistentData.Register);
    1718end;
    1819
  • PersistentData/UPDClient.pas

    r345 r361  
    8080  { TPDClient }
    8181
    82   TPDClient = class
     82  TPDClient = class(TComponent)
    8383  private
     84    FSchema: string;
     85    procedure SetConnected(AValue: Boolean);
    8486  protected
    8587    procedure InitSystemTypes; virtual;
    8688    procedure Init; virtual;
    8789    function GetConnected: Boolean; virtual;
     90    function GetConnectionString: string; virtual;
     91    procedure SetConnectionString(AValue: string); virtual;
    8892  public
    89     Host: string;
    90     Port: Word;
    91     Schema: string;
    92     User: string;
    93     Password: string;
    9493    Types: TPDTypeList;
    9594    Version: string;
     95    BackendName: string;
    9696    procedure ObjectLoad(AObject: TObjectProxy); virtual; abstract;
    9797    procedure ObjectSave(AObject: TObjectProxy); virtual; abstract;
     
    104104    procedure CheckTypes;
    105105    function TypeExists(Name: string): Boolean; virtual; abstract;
    106     constructor Create; virtual;
     106    constructor Create(AOwner: TComponent); override;
    107107    destructor Destroy; override;
    108108    procedure Connect; virtual;
     
    111111    procedure Uninstall; virtual;
    112112    procedure Update; virtual;
    113     property Connected: Boolean read GetConnected;
    114   end;
     113  published
     114    property Schema: string read FSchema write FSchema;
     115    property Connected: Boolean read GetConnected write SetConnected;
     116    property ConnectionString: string read GetConnectionString
     117      write SetConnectionString;
     118  end;
     119
     120  TPDClientClass = class of TPDClient;
    115121
    116122implementation
     
    238244
    239245{ TPDClient }
     246
     247function TPDClient.GetConnectionString: string;
     248begin
     249  Result := '';
     250end;
     251
     252procedure TPDClient.SetConnectionString(AValue: string);
     253begin
     254
     255end;
     256
     257procedure TPDClient.SetConnected(AValue: Boolean);
     258begin
     259  if AValue then Connect else Disconnect;
     260end;
    240261
    241262procedure TPDClient.InitSystemTypes;
     
    330351end;
    331352
    332 constructor TPDClient.Create;
    333 begin
     353constructor TPDClient.Create(AOwner: TComponent);
     354begin
     355  inherited;
    334356  Types := TPDTypeList.Create;
    335357  Types.Client := Self;
     
    345367procedure TPDClient.Connect;
    346368begin
    347   raise Exception.Create(SNotSupported);
    348369end;
    349370
    350371procedure TPDClient.Disconnect;
    351372begin
    352   raise Exception.Create(SNotSupported);
    353373end;
    354374
Note: See TracChangeset for help on using the changeset viewer.