Changeset 431 for ModularSystem


Ignore:
Timestamp:
Oct 25, 2012, 2:11:02 PM (12 years ago)
Author:
chronos
Message:
  • Added: ModuleManager modules updating notification using Update, BeginUpdate, EndUpdate.
  • Added: Module state Enabled and methods Enable and Disable.
  • Modified: Generalized dependency enumeration.
  • Added: Generalized module list forms for user control.
Location:
ModularSystem
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • ModularSystem/ModularSystem.lpk

    r428 r431  
    2020    <Description Value="Modular system"/>
    2121    <License Value="GNU/LGPLv3"/>
    22     <Version Minor="1"/>
    23     <Files Count="1">
     22    <Version Minor="2"/>
     23    <Files Count="2">
    2424      <Item1>
    2525        <Filename Value="UModularSystem.pas"/>
     
    2727        <UnitName Value="UModularSystem"/>
    2828      </Item1>
     29      <Item2>
     30        <Filename Value="UFormModuleList.pas"/>
     31        <UnitName Value="UFormModuleList"/>
     32      </Item2>
    2933    </Files>
    3034    <i18n>
     
    3438    </i18n>
    3539    <Type Value="RunAndDesignTime"/>
    36     <RequiredPkgs Count="2">
     40    <RequiredPkgs Count="3">
    3741      <Item1>
    38         <PackageName Value="Common"/>
     42        <PackageName Value="LCL"/>
    3943      </Item1>
    4044      <Item2>
     45        <PackageName Value="Common"/>
     46      </Item2>
     47      <Item3>
    4148        <PackageName Value="FCL"/>
    42       </Item2>
     49      </Item3>
    4350    </RequiredPkgs>
    4451    <UsageOptions>
     
    4855      <Version Value="2"/>
    4956    </PublishOptions>
     57    <CustomOptions Items="ExternHelp" Version="2">
     58      <_ExternHelp Items="Count"/>
     59    </CustomOptions>
    5060  </Package>
    5161</CONFIG>
  • ModularSystem/ModularSystem.pas

    r399 r431  
    88
    99uses
    10   UModularSystem, LazarusPackageIntf;
     10  UModularSystem, UFormModuleList, LazarusPackageIntf;
    1111
    1212implementation
  • ModularSystem/UModularSystem.pas

    r429 r431  
    66
    77uses
    8   Classes, SysUtils, Contnrs, URegistry;
     8  Classes, SysUtils, URegistry, SpecializedList;
    99
    1010type
    1111  TModuleManager = class;
     12  TModule = class;
     13  TListModule = class;
    1214
    1315  TAPI = class(TComponent)
    1416
    1517  end;
     18
     19  TModuleCondition = (mcAll, mcEnabled, mcNotEnabled, mcInstalled, mcNotInstalled,
     20    mcRunning, mcNotRunning);
     21  TModuleConditions = set of TModuleCondition;
     22  TModuleAction = (maStart, maStop, maInstall, maUninstall, maUpgrade, maEnable,
     23    maDisable);
     24  TModuleActions = array of TModuleAction;
    1625
    1726  { TModule }
     
    1928  TModule = class(TComponent)
    2029  private
     30    FCategory: string;
    2131    FEnabled: Boolean;
     32    FReleaseTime: TDateTime;
    2233    FRunning: Boolean;
    2334    FInstalled: Boolean;
     
    2839    FLicense: string;
    2940    FAuthor: string;
    30     FDependencies: TStringList;
    31     FDescription: TStringList;
     41    FDependencies: TListString;
     42    FDescription: TListString;
     43    FFileName: string;
     44    FWebSite: string;
    3245    procedure SetEnabled(AValue: Boolean);
    3346    procedure SetInstalled(AValue: Boolean);
     47    procedure SetManager(AValue: TModuleManager);
    3448    procedure SetRunning(AValue: Boolean);
    3549  protected
     
    4155  public
    4256    API: TAPI;
     57    procedure Enable;
     58    procedure Disable;
    4359    procedure Start;
    4460    procedure Stop;
     61    procedure Restart;
    4562    procedure Install;
    4663    procedure Uninstall;
     64    procedure Reinstall;
    4765    procedure Upgrade;
    48     procedure EnumModulesStart(ModuleList: TStringList);
    49     procedure EnumModulesStop(ModuleList: TStringList);
    50     procedure EnumModulesInstall(ModuleList: TStringList);
    51     procedure EnumModulesUninstall(ModuleList: TStringList);
     66    procedure EnumDependenciesCascade(ModuleList: TListModule;
     67      Conditions: TModuleConditions = [mcAll]);
     68    procedure EnumSuperiorDependenciesCascade(ModuleList: TListModule;
     69      Conditions: TModuleConditions = [mcAll]);
    5270    procedure SetInstalledState(Value: Boolean);
    5371    constructor Create(Owner: TComponent); override;
     
    5775    property Enabled: Boolean read FEnabled write SetEnabled;
    5876  published
    59     property Manager: TModuleManager read FManager;
     77    property Identification: string read FIdentification write FIdentification; // Unique system name
     78    property Manager: TModuleManager read FManager write SetManager;
    6079    property Version: string read FVersion write FVersion;
    61     property Identification: string read FIdentification write FIdentification;
     80    property ReleaseTime: TDateTime read FReleaseTime write FReleaseTime;
    6281    property Title: string read FTitle write FTitle;
    6382    property License: string read FLicense write FLicense;
    6483    property Author: string read FAuthor write FAuthor;
    65     property Dependencies: TStringList read FDependencies write FDependencies;
    66     property Description: TStringList read FDescription write FDescription;
    67   end;
    68 
    69   TModuleEvent = procedure (Sender: TObject; Module: TModule) of object;
    70 
     84    property Dependencies: TListString read FDependencies write FDependencies;
     85    property Description: TListString read FDescription write FDescription;
     86    property FileName: string read FFileName write FFileName;
     87    property Category: string read FCategory write FCategory;
     88    property WebSite: string read FWebSite write FWebSite;
     89    // Screenshots, reviews, icon, weak dependencies, ...
     90  end;
     91
     92  { TListModule }
     93
     94  TListModule = class(TListObject)
     95  private
     96  public
     97    procedure Perform(Actions: array of TModuleAction; Conditions: TModuleConditions = [mcAll]);
     98    function FindByName(Name: string): TModule;
     99  end;
     100
     101  TModuleManagerOption = (moAutoInstallOnRun, moAuto);
     102  TModuleManagerOptions = set of TModuleManagerOption;
    71103  { TModuleManager }
    72104
     
    74106  private
    75107    FAPI: TAPI;
    76     FOnModuleChange: TModuleEvent;
     108    FOnUpdate: TNotifyEvent;
     109    FUpdateCount: Integer;
     110    FOptions: TModuleManagerOptions;
    77111    procedure SetAPI(AValue: TAPI);
     112    procedure DoUpdate;
    78113  public
    79     Modules: TObjectList; // TObjectList<TModule>
    80     function FindModuleByName(Name: string): TModule;
     114    Modules: TListModule; // TObjectList<TModule>
    81115    function ModuleRunning(Name: string): Boolean;
    82     procedure StartDependencies(ModuleName: string; Dependencies: TStringList);
    83     procedure StopDependencies(ModuleName: string);
    84     procedure EnumModulesStart(Dependencies, ModuleList: TStringList);
    85     procedure EnumModulesStop(ModuleName: string; ModuleList: TStringList);
    86     procedure InstallDependencies(ModuleName: string; Dependencies: TStringList);
    87     procedure UninstallDependencies(ModuleName: string);
    88     procedure EnumModulesInstall(Dependencies, ModuleList: TStringList);
    89     procedure EnumModulesUninstall(ModuleName: string; ModuleList: TStringList);
    90     procedure RegisterModule(Module: TModule; Enabled: Boolean = True);
     116    procedure EnumDependenciesCascade(Module: TModule; ModuleList: TListModule;
     117      Conditions: TModuleConditions = [mcAll]);
     118    procedure EnumSuperiorDependenciesCascade(Module: TModule;
     119      ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
     120    procedure RegisterModule(Module: TModule);
    91121    procedure UnregisterModule(Module: TModule);
    92     procedure StartInstalled;
    93     procedure InstallEnabled;
    94     procedure StopAll;
    95     procedure UninstallAll;
    96122    procedure LoadFromRegistry(Context: TRegistryContext);
    97123    procedure SaveToRegistry(Context: TRegistryContext);
     124    procedure BeginUpdate;
     125    procedure EndUpdate;
     126    procedure Update;
    98127    constructor Create(AOwner: TComponent); override;
    99128    destructor Destroy; override;
    100129    property API: TAPI read FAPI write SetAPI;
    101     property OnModuleChange: TModuleEvent read FOnModuleChange write FOnModuleChange;
     130  published
     131    property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate;
     132    property Options: TModuleManagerOptions read FOptions write FOptions;
    102133  end;
    103134
     
    113144begin
    114145  RegisterComponents('ModularSystem', [TModuleManager, TModule]);
     146end;
     147
     148{ TListModule }
     149
     150procedure TListModule.Perform(Actions:  array of TModuleAction;
     151  Conditions: TModuleConditions = [mcAll]);
     152var
     153  I: Integer;
     154  A: Integer;
     155begin
     156  for I := 0 to Count - 1 do
     157  with TModule(Items[I]) do
     158    if (mcAll in Conditions) or
     159    (Running and (mcRunning in Conditions)) or
     160    (not Running and (mcNotRunning in Conditions)) or
     161    (Installed and (mcInstalled in Conditions)) or
     162    (not Installed and (mcNotInstalled in Conditions)) or
     163    (Enabled and (mcEnabled in Conditions)) or
     164    (not Enabled and (mcNotEnabled in Conditions)) then
     165    for A := 0 to High(Actions) do begin
     166      if Actions[A] = maStart then Start;
     167      if Actions[A] = maStop then Stop;
     168      if Actions[A] = maInstall then Install;
     169      if Actions[A] = maUninstall then Uninstall;
     170      if Actions[A] = maUpgrade then Upgrade;
     171      if Actions[A] = maEnable then Enabled := True;
     172      if Actions[A] = maDisable then Enabled := False;
     173    end;
     174end;
     175
     176function TListModule.FindByName(Name: string): TModule;
     177var
     178  I: Integer;
     179begin
     180  I := 0;
     181  while (I < Count) and (TModule(Items[I]).Identification <> Name) do Inc(I);
     182  if I < Count then Result := TModule(Items[I])
     183    else Result := nil;
    115184end;
    116185
     
    127196end;
    128197
    129 function TModuleManager.FindModuleByName(Name: string): TModule;
    130 var
    131   I: Integer;
    132 begin
    133   I := 0;
    134   while (I < Modules.Count) and (TModule(Modules[I]).Identification <> Name) do Inc(I);
    135   if I < Modules.Count then Result := TModule(Modules[I])
    136     else Result := nil;
     198procedure TModuleManager.DoUpdate;
     199begin
     200  if Assigned(FOnUpdate) then FOnUpdate(Self);
    137201end;
    138202
     
    141205  Module: TModule;
    142206begin
    143   Module := FindModuleByName(Name);
     207  Module := Modules.FindByName(Name);
    144208  if Assigned(Module) then begin
    145209    Result := Module.Running;
     
    147211end;
    148212
    149 procedure TModuleManager.StartDependencies(ModuleName: string; Dependencies: TStringList);
    150 var
    151   Module: TModule;
    152   I: Integer;
    153 begin
    154   for I := 0 to Dependencies.Count - 1 do begin
    155     Module := FindModuleByName(Dependencies[I]);
    156     if Assigned(Module) and Module.Enabled then begin
    157       if not Module.Running then Module.Start;
    158     end else raise Exception.CreateFmt(SModuleNotFound, [ModuleName, Dependencies[I]]);
    159   end;
    160 end;
    161 
    162 procedure TModuleManager.StopDependencies(ModuleName: string);
     213procedure TModuleManager.EnumDependenciesCascade(Module: TModule;
     214  ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
     215var
     216  DepModule: TModule;
     217  I: Integer;
     218begin
     219  for I := 0 to Module.Dependencies.Count - 1 do begin
     220    DepModule := Modules.FindByName(Module.Dependencies[I]);
     221    if Assigned(DepModule) then
     222    with DepModule do begin
     223      if (ModuleList.IndexOf(DepModule) = -1) and
     224        ((mcAll in Conditions) or
     225        (Running and (mcRunning in Conditions)) or
     226        (not Running and (mcNotRunning in Conditions)) or
     227        (Installed and (mcInstalled in Conditions)) or
     228        (not Installed and (mcNotInstalled in Conditions)) or
     229        (Enabled and (mcEnabled in Conditions)) or
     230        (not Enabled and (mcNotEnabled in Conditions))) then begin
     231          ModuleList.Add(DepModule);
     232          Self.EnumDependenciesCascade(DepModule, ModuleList);
     233        end;
     234    end else raise Exception.CreateFmt(SModuleNotFound, [DepModule.Identification]);
     235  end;
     236end;
     237
     238procedure TModuleManager.EnumSuperiorDependenciesCascade(Module: TModule;
     239  ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
    163240var
    164241  I: Integer;
     
    166243  for I := 0 to Modules.Count - 1 do
    167244  with TModule(Modules[I]) do begin
    168     if (Dependencies.IndexOf(ModuleName) <> - 1) and Running then Stop;
    169   end;
    170 end;
    171 
    172 procedure TModuleManager.EnumModulesStart(Dependencies,
    173   ModuleList: TStringList);
    174 var
    175   Module: TModule;
    176   I: Integer;
    177 begin
    178   for I := 0 to Dependencies.Count - 1 do begin
    179     Module := FindModuleByName(Dependencies[I]);
    180     if Assigned(Module) then begin
    181       if not Module.Running and (ModuleList.IndexOf(Module.Identification) = -1) then begin
    182         ModuleList.Add(Module.Identification);
    183         EnumModulesStart(Module.Dependencies, ModuleList);
    184       end;
    185     end else raise Exception.CreateFmt(SModuleNotFound, [Module.Identification]);
    186   end;
    187 end;
    188 
    189 procedure TModuleManager.EnumModulesStop(ModuleName: string;
    190   ModuleList: TStringList);
    191 var
    192   I: Integer;
    193 begin
    194   for I := 0 to Modules.Count - 1 do
    195   with TModule(Modules[I]) do begin
    196     if (Dependencies.IndexOf(ModuleName) <> -1) and Running and
    197       (ModuleList.IndexOf(Identification) = -1) then begin
    198       ModuleList.Add(Identification);
    199       Self.EnumModulesStop(Identification, ModuleList);
     245    if (Dependencies.IndexOf(Module.Identification) <> -1) and
     246      (ModuleList.IndexOf(TModule(Modules[I])) = -1) and
     247    ((mcAll in Conditions) or
     248    (Running and (mcRunning in Conditions)) or
     249    (not Running and (mcNotRunning in Conditions)) or
     250    (Installed and (mcInstalled in Conditions)) or
     251    (not Installed and (mcNotInstalled in Conditions)) or
     252    (Enabled and (mcEnabled in Conditions)) or
     253    (not Enabled and (mcNotEnabled in Conditions))) then begin
     254      ModuleList.Add(TModule(Modules[I]));
     255      Self.EnumSuperiorDependenciesCascade(TModule(Modules[I]), ModuleList);
    200256    end;
    201257  end;
    202258end;
    203259
    204 procedure TModuleManager.InstallDependencies(ModuleName: string;
    205   Dependencies: TStringList);
    206 var
    207   Module: TModule;
    208   I: Integer;
    209 begin
    210   for I := 0 to Dependencies.Count - 1 do begin
    211     Module := FindModuleByName(Dependencies[I]);
    212     if Assigned(Module) and Module.Enabled then begin
    213       if not Module.Installed then Module.Install;
    214     end else raise Exception.CreateFmt(SModuleNotFound, [ModuleName, Dependencies[I]]);
    215   end;
    216 end;
    217 
    218 procedure TModuleManager.UninstallDependencies(ModuleName: string);
    219 var
    220   I: Integer;
    221 begin
    222   for I := 0 to Modules.Count - 1 do
    223   with TModule(Modules[I]) do begin
    224     if (Dependencies.IndexOf(ModuleName) <> - 1) and Installed then Uninstall;
    225   end;
    226 end;
    227 
    228 procedure TModuleManager.EnumModulesInstall(Dependencies,
    229   ModuleList: TStringList);
    230 var
    231   Module: TModule;
    232   I: Integer;
    233 begin
    234   for I := 0 to Dependencies.Count - 1 do begin
    235     Module := FindModuleByName(Dependencies[I]);
    236     if Assigned(Module) then begin
    237       if not Module.Installed and (ModuleList.IndexOf(Module.Identification) = -1) then begin
    238         ModuleList.Add(Module.Identification);
    239         EnumModulesInstall(Module.Dependencies, ModuleList);
    240       end;
    241     end else raise Exception.CreateFmt(SModuleNotFound, [Module.Identification]);
    242   end;
    243 end;
    244 
    245 procedure TModuleManager.EnumModulesUninstall(ModuleName: string;
    246   ModuleList: TStringList);
    247 var
    248   I: Integer;
    249 begin
    250   for I := 0 to Modules.Count - 1 do
    251   with TModule(Modules[I]) do begin
    252     if (Dependencies.IndexOf(ModuleName) <> -1) and Installed and
    253       (ModuleList.IndexOf(Identification) = -1) then begin
    254       ModuleList.Add(Identification);
    255       Self.EnumModulesUninstall(Identification, ModuleList);
    256     end;
    257   end;
    258 end;
    259 
    260 procedure TModuleManager.RegisterModule(Module: TModule;
    261   Enabled: Boolean = True);
     260procedure TModuleManager.RegisterModule(Module: TModule);
    262261begin
    263262  Modules.Add(Module);
    264263  Module.FManager := Self;
    265264  Module.API := API;
    266   Module.Enabled := Enabled;
     265  Update;
    267266end;
    268267
     
    270269begin
    271270  Modules.Remove(Module);
    272 end;
    273 
    274 procedure TModuleManager.StartInstalled;
    275 var
    276   I: Integer;
    277 begin
    278   for I := 0 to Modules.Count - 1 do
    279   with TModule(Modules[I]) do
    280     if not Running and Installed then Start;
    281 end;
    282 
    283 procedure TModuleManager.InstallEnabled;
    284 var
    285   I: Integer;
    286 begin
    287   for I := 0 to Modules.Count - 1 do
    288   with TModule(Modules[I]) do
    289     if not Installed and Enabled then Install;
    290 end;
    291 
    292 procedure TModuleManager.StopAll;
    293 var
    294   I: Integer;
    295 begin
    296   for I := 0 to Modules.Count - 1 do
    297   with TModule(Modules[I]) do
    298     if Running then Stop;
    299 end;
    300 
    301 procedure TModuleManager.UninstallAll;
    302 var
    303   I: Integer;
    304 begin
    305   for I := 0 to Modules.Count - 1 do
    306   with TModule(Modules[I]) do
    307     if Installed then Uninstall;
     271  Update;
    308272end;
    309273
     
    311275begin
    312276  inherited;
    313   Modules := TObjectList.Create;
    314   //Modules.OwnsObjects := False;
     277  Modules := TListModule.Create;
     278  Modules.OwnsObjects := False;
    315279end;
    316280
    317281destructor TModuleManager.Destroy;
    318282begin
    319   StopAll;
     283  Modules.Perform([maStop]);
    320284  FreeAndNil(Modules);
    321285  inherited;
     
    332296    with TModule(Modules[I]) do begin
    333297      OpenKey(Context.Key + '\' + Identification, True);
    334       Running := ReadBoolWithDefault('Run', Enabled);
     298      Enabled := ReadBoolWithDefault('Enable', Enabled);
    335299    end;
    336300  finally
     
    347311    RootKey := Context.RootKey;
    348312    for I := 0 to Modules.Count - 1 do
    349     with TModule(Modules[I]) do
    350     if Enabled then begin
     313    with TModule(Modules[I]) do begin
    351314      OpenKey(Context.Key + '\' + Identification, True);
    352       WriteBool('Run', Running);
     315      WriteBool('Enable', Enabled);
    353316    end;
    354317  finally
    355318    Free;
    356319  end;
     320end;
     321
     322procedure TModuleManager.BeginUpdate;
     323begin
     324  Inc(FUpdateCount);
     325end;
     326
     327procedure TModuleManager.EndUpdate;
     328begin
     329  if FUpdateCount > 0 then Dec(FUpdateCount);
     330  if FUpdateCount = 0 then DoUpdate;
     331end;
     332
     333procedure TModuleManager.Update;
     334begin
     335  if FUpdateCount = 0 then DoUpdate;
    357336end;
    358337
     
    390369end;
    391370
     371procedure TModule.Enable;
     372var
     373  List: TListModule;
     374begin
     375  if Enabled then Exit;
     376  FEnabled := True;
     377  try
     378    List := TListModule.Create;
     379    List.OwnsObjects := False;
     380    EnumSuperiorDependenciesCascade(List);
     381    List.Perform([maEnable], [mcNotEnabled]);
     382  finally
     383    List.Free;
     384  end;
     385  Start; // Auto start enabled modules
     386  //Manager.Update;
     387end;
     388
     389procedure TModule.Disable;
     390var
     391  List: TListModule;
     392begin
     393  if not Enabled then Exit;
     394  if FRunning then Stop; // Auto stop running modules
     395  FEnabled := False;
     396  try
     397    List := TListModule.Create;
     398    List.OwnsObjects := False;
     399    EnumSuperiorDependenciesCascade(List);
     400    List.Perform([maDisable], [mcEnabled]);
     401  finally
     402    List.Free;
     403  end;
     404  Manager.Update;
     405end;
     406
    392407procedure TModule.SetInstalled(AValue: Boolean);
    393408begin
     
    396411end;
    397412
     413procedure TModule.SetManager(AValue: TModuleManager);
     414begin
     415  if FManager = AValue then Exit;
     416  if Assigned(FManager) then FManager.UnregisterModule(Self);
     417  FManager := AValue;
     418  if Assigned(FManager) then AValue.RegisterModule(Self);
     419end;
     420
    398421procedure TModule.SetEnabled(AValue: Boolean);
    399422begin
    400423  if FEnabled = AValue then Exit;
    401   FEnabled := AValue;
    402   if not FEnabled and FInstalled then Uninstall;
     424  if FEnabled then Enable else Disable;
    403425end;
    404426
    405427procedure TModule.Start;
     428var
     429  List: TListModule;
    406430begin
    407431  if not Enabled or Running then Exit;
    408   if not Installed then Install;
    409   Manager.StartDependencies(Identification, Dependencies);
     432  if not Installed then Install;  // Auto install not installed modules
     433  try
     434    List := TListModule.Create;
     435    List.OwnsObjects := False;
     436    EnumDependenciesCascade(List);
     437    List.Perform([maStart], [mcNotRunning]);
     438  finally
     439    List.Free;
     440  end;
    410441  DoStart;
    411442  FRunning := True;
     443  Manager.Update;
    412444end;
    413445
    414446procedure TModule.Stop;
     447var
     448  List: TListModule;
    415449begin
    416450  if not Running then Exit;
    417451  FRunning := False;
    418   Manager.StopDependencies(Identification);
     452  try
     453    List := TListModule.Create;
     454    List.OwnsObjects := False;
     455    EnumSuperiorDependenciesCascade(List);
     456    List.Perform([maStop], [mcRunning]);
     457  finally
     458    List.Free;
     459  end;
    419460  DoStop;
     461  Manager.Update;
     462end;
     463
     464procedure TModule.Restart;
     465begin
     466  Stop;
     467  Start;
    420468end;
    421469
    422470procedure TModule.Install;
    423 begin
    424   if not Enabled or Installed then Exit;
    425   Manager.InstallDependencies(Identification, Dependencies);
     471var
     472  List: TListModule;
     473begin
     474  if Installed then Exit;
     475  try
     476    List := TListModule.Create;
     477    List.OwnsObjects := False;
     478    EnumDependenciesCascade(List);
     479    List.Perform([maInstall], [mcNotInstalled]);
     480  finally
     481    List.Free;
     482  end;
    426483  FInstalled := True;
    427   if Assigned(Manager.FOnModuleChange) then
    428     Manager.FOnModuleChange(Manager, Self);
    429484  DoInstall;
     485  Enable; // Auto enable installed module
     486  Manager.Update;
    430487end;
    431488
    432489procedure TModule.Uninstall;
     490var
     491  List: TListModule;
    433492begin
    434493  if not Installed then Exit;
    435   if Running then Stop;
    436   Manager.UninstallDependencies(Identification);
     494  if Enabled then Disable; // Auto disable uninstalled module
     495  try
     496    List := TListModule.Create;
     497    List.OwnsObjects := False;
     498    EnumSuperiorDependenciesCascade(List);
     499    List.Perform([maUninstall], [mcInstalled]);
     500  finally
     501    List.Free;
     502  end;
    437503  FInstalled := False;
    438504  DoUninstall;
    439   if Assigned(Manager.FOnModuleChange) then
    440     Manager.FOnModuleChange(Manager, Self);
     505  Manager.Update;
     506end;
     507
     508procedure TModule.Reinstall;
     509begin
     510  Uninstall;
     511  Install;
    441512end;
    442513
     
    450521    Start;
    451522  end else DoUpgrade;
    452 end;
    453 
    454 procedure TModule.EnumModulesStart(ModuleList: TStringList);
     523  Manager.Update;
     524end;
     525
     526procedure TModule.EnumDependenciesCascade(ModuleList: TListModule;
     527  Conditions: TModuleConditions = [mcAll]);
    455528begin
    456529  ModuleList.Clear;
    457   Manager.EnumModulesStart(Dependencies, ModuleList);
    458 end;
    459 
    460 procedure TModule.EnumModulesStop(ModuleList: TStringList);
     530  Manager.EnumDependenciesCascade(Self, ModuleList, Conditions);
     531end;
     532
     533procedure TModule.EnumSuperiorDependenciesCascade(ModuleList: TListModule;
     534  Conditions: TModuleConditions = [mcAll]);
    461535begin
    462536  ModuleList.Clear;
    463   Manager.EnumModulesStop(Identification, ModuleList);
    464 end;
    465 
    466 procedure TModule.EnumModulesInstall(ModuleList: TStringList);
    467 begin
    468   ModuleList.Clear;
    469   Manager.EnumModulesInstall(Dependencies, ModuleList);
    470 end;
    471 
    472 procedure TModule.EnumModulesUninstall(ModuleList: TStringList);
    473 begin
    474   ModuleList.Clear;
    475   Manager.EnumModulesUninstall(Identification, ModuleList);
     537  Manager.EnumSuperiorDependenciesCascade(Self, ModuleList, Conditions);
    476538end;
    477539
     
    479541begin
    480542  FInstalled := Value;
    481   if Assigned(Manager.FOnModuleChange) then
    482     Manager.FOnModuleChange(Manager, Self);
     543  Manager.Update;
    483544end;
    484545
     
    486547begin
    487548  inherited;
    488   Dependencies := TStringList.Create;
    489   Description := TStringList.Create;
     549  Dependencies := TListString.Create;
     550  Description := TListString.Create;
    490551end;
    491552
Note: See TracChangeset for help on using the changeset viewer.