Changeset 439 for ModularSystem/UModularSystem.pas
- Timestamp:
- Nov 19, 2012, 2:40:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ModularSystem/UModularSystem.pas
r431 r439 43 43 FFileName: string; 44 44 FWebSite: string; 45 FStartUpTime: TDateTime; 45 46 procedure SetEnabled(AValue: Boolean); 46 47 procedure SetInstalled(AValue: Boolean); … … 74 75 property Installed: Boolean read FInstalled write SetInstalled; 75 76 property Enabled: Boolean read FEnabled write SetEnabled; 77 property StartUpTime: TDateTime read FStartUpTime; 76 78 published 77 79 property Identification: string read FIdentification write FIdentification; // Unique system name … … 110 112 FOptions: TModuleManagerOptions; 111 113 procedure SetAPI(AValue: TAPI); 112 procedure DoUpdate ;114 procedure DoUpdate(Sender: TObject); 113 115 public 114 116 Modules: TListModule; // TObjectList<TModule> … … 122 124 procedure LoadFromRegistry(Context: TRegistryContext); 123 125 procedure SaveToRegistry(Context: TRegistryContext); 124 procedure BeginUpdate;125 procedure EndUpdate;126 procedure Update;127 126 constructor Create(AOwner: TComponent); override; 128 127 destructor Destroy; override; … … 154 153 A: Integer; 155 154 begin 155 try 156 BeginUpdate; 156 157 for I := 0 to Count - 1 do 157 158 with TModule(Items[I]) do … … 169 170 if Actions[A] = maUninstall then Uninstall; 170 171 if Actions[A] = maUpgrade then Upgrade; 171 if Actions[A] = maEnable then Enable d := True;172 if Actions[A] = maDisable then Enabled := False;172 if Actions[A] = maEnable then Enable; 173 if Actions[A] = maDisable then Disable; 173 174 end; 175 finally 176 EndUpdate; 177 end; 174 178 end; 175 179 … … 196 200 end; 197 201 198 procedure TModuleManager.DoUpdate ;202 procedure TModuleManager.DoUpdate(Sender: TObject); 199 203 begin 200 204 if Assigned(FOnUpdate) then FOnUpdate(Self); … … 263 267 Module.FManager := Self; 264 268 Module.API := API; 265 Update;269 Modules.Update; 266 270 end; 267 271 … … 269 273 begin 270 274 Modules.Remove(Module); 271 Update;275 Modules.Update; 272 276 end; 273 277 … … 277 281 Modules := TListModule.Create; 278 282 Modules.OwnsObjects := False; 283 Modules.OnUpdate := DoUpdate; 279 284 end; 280 285 … … 296 301 with TModule(Modules[I]) do begin 297 302 OpenKey(Context.Key + '\' + Identification, True); 298 Enabled := ReadBoolWithDefault('Enable', Enabled); 303 Installed := ReadBoolWithDefault('Installed', Installed); 304 Enabled := ReadBoolWithDefault('Enabled', Enabled); 299 305 end; 300 306 finally … … 313 319 with TModule(Modules[I]) do begin 314 320 OpenKey(Context.Key + '\' + Identification, True); 315 WriteBool('Enable', Enabled); 321 WriteBool('Enabled', Enabled); 322 WriteBool('Installed', Installed); 316 323 end; 317 324 finally 318 325 Free; 319 326 end; 320 end;321 322 procedure TModuleManager.BeginUpdate;323 begin324 Inc(FUpdateCount);325 end;326 327 procedure TModuleManager.EndUpdate;328 begin329 if FUpdateCount > 0 then Dec(FUpdateCount);330 if FUpdateCount = 0 then DoUpdate;331 end;332 333 procedure TModuleManager.Update;334 begin335 if FUpdateCount = 0 then DoUpdate;336 327 end; 337 328 … … 378 369 List := TListModule.Create; 379 370 List.OwnsObjects := False; 380 Enum SuperiorDependenciesCascade(List);371 EnumDependenciesCascade(List, [mcNotEnabled]); 381 372 List.Perform([maEnable], [mcNotEnabled]); 382 373 finally … … 397 388 List := TListModule.Create; 398 389 List.OwnsObjects := False; 399 EnumSuperiorDependenciesCascade(List );390 EnumSuperiorDependenciesCascade(List, [mcEnabled]); 400 391 List.Perform([maDisable], [mcEnabled]); 401 392 finally 402 393 List.Free; 403 394 end; 404 Manager. Update;395 Manager.Modules.Update; 405 396 end; 406 397 … … 422 413 begin 423 414 if FEnabled = AValue then Exit; 424 if FEnabledthen Enable else Disable;415 if AValue then Enable else Disable; 425 416 end; 426 417 … … 428 419 var 429 420 List: TListModule; 421 StartTime: TDateTime; 430 422 begin 431 423 if not Enabled or Running then Exit; … … 434 426 List := TListModule.Create; 435 427 List.OwnsObjects := False; 436 EnumDependenciesCascade(List );428 EnumDependenciesCascade(List, [mcNotRunning]); 437 429 List.Perform([maStart], [mcNotRunning]); 438 430 finally 439 431 List.Free; 440 432 end; 433 StartTime := Now; 441 434 DoStart; 435 FStartUpTime := Now - StartTime; 442 436 FRunning := True; 443 Manager. Update;437 Manager.Modules.Update; 444 438 end; 445 439 … … 453 447 List := TListModule.Create; 454 448 List.OwnsObjects := False; 455 EnumSuperiorDependenciesCascade(List );449 EnumSuperiorDependenciesCascade(List, [mcRunning]); 456 450 List.Perform([maStop], [mcRunning]); 457 451 finally … … 459 453 end; 460 454 DoStop; 461 Manager. Update;455 Manager.Modules.Update; 462 456 end; 463 457 … … 476 470 List := TListModule.Create; 477 471 List.OwnsObjects := False; 478 EnumDependenciesCascade(List );472 EnumDependenciesCascade(List, [mcNotInstalled]); 479 473 List.Perform([maInstall], [mcNotInstalled]); 480 474 finally … … 483 477 FInstalled := True; 484 478 DoInstall; 485 Enable; // Auto enable installed module486 Manager. Update;479 //Enable; // Auto enable installed module 480 Manager.Modules.Update; 487 481 end; 488 482 … … 496 490 List := TListModule.Create; 497 491 List.OwnsObjects := False; 498 EnumSuperiorDependenciesCascade(List );492 EnumSuperiorDependenciesCascade(List, [mcInstalled]); 499 493 List.Perform([maUninstall], [mcInstalled]); 500 494 finally … … 503 497 FInstalled := False; 504 498 DoUninstall; 505 Manager. Update;499 Manager.Modules.Update; 506 500 end; 507 501 … … 521 515 Start; 522 516 end else DoUpgrade; 523 Manager. Update;517 Manager.Modules.Update; 524 518 end; 525 519 … … 541 535 begin 542 536 FInstalled := Value; 543 Manager. Update;537 Manager.Modules.Update; 544 538 end; 545 539
Note:
See TracChangeset
for help on using the changeset viewer.