Menu

Commit [r2544]  Maximize  Restore  History

Some name changes in TFirstRun and TFirstRunMgr to clarify that methods referring to a config file actual refer to USER config file.

Required changes to using code.

delphidabbler 2012-12-08

changed /branches/portable/Src/FirstRun.FmV4ConfigDlg.pas
changed /branches/portable/Src/FirstRun.UMain.pas
/branches/portable/Src/FirstRun.FmV4ConfigDlg.pas Diff Switch to side-by-side view
--- a/branches/portable/Src/FirstRun.FmV4ConfigDlg.pas
+++ b/branches/portable/Src/FirstRun.FmV4ConfigDlg.pas
@@ -209,7 +209,7 @@
 
 function TV4ConfigDlg.ConfigFileAvailable: Boolean;
 begin
-  Result := fFirstRun.HaveOldCfgFile;
+  Result := fFirstRun.HaveOldUserCfgFile;
 end;
 
 procedure TV4ConfigDlg.ConfigForm;
@@ -463,8 +463,8 @@
   Actions := GetUpdateActions;
   if uaCopyCfgFile in Actions then
   begin
-    fFirstRun.BringForwardCfgFile;
-    fFirstRun.UpdateCfgFile(fCfgChanges);
+    fFirstRun.BringForwardUserCfgFile;
+    fFirstRun.UpdateUserCfgFile(fCfgChanges);
   end;
   if uaCopyUserDB in Actions then
     fFirstRun.BringForwardUserDB;
/branches/portable/Src/FirstRun.UMain.pas Diff Switch to side-by-side view
--- a/branches/portable/Src/FirstRun.UMain.pas
+++ b/branches/portable/Src/FirstRun.UMain.pas
@@ -53,7 +53,7 @@
       fInstallInfo: TInstallInfo;
       ///  <summary>Object that interogates and updates user's config file.
       ///  </summary>
-      fConfigFile: TUserConfigFileUpdater;
+      fUserConfigFile: TUserConfigFileUpdater;
       ///  <summary>Object used to copy forward older versions of user database.
       ///  </summary>
       fDatabase: TUserDatabaseUpdater;
@@ -69,23 +69,23 @@
     destructor Destroy; override;
     ///  <summary>Checks if a user config file exists for an earlier CodeSnip
     ///  installation.</summary>
-    function HaveOldCfgFile: Boolean;
+    function HaveOldUserCfgFile: Boolean;
     ///  <summary>Copies user config file from an earlier CodeSnip installation.
     ///  </summary>
-    procedure BringForwardCfgFile;
+    procedure BringForwardUserCfgFile;
     ///  <summary>Updates current version's user config file in place as
     ///  necessary and notifies caller of changes via Changes parameter.
     /// </summary>
-    procedure UpdateCfgFile(out Changes: TFirstRunCfgChangeSet);
+    procedure UpdateUserCfgFile(out Changes: TFirstRunCfgChangeSet);
     ///  <summary>Checks if a user database exist for an earlier CodeSnip
     ///  installation.</summary>
     function HaveOldUserDB: Boolean;
     ///  <summary>Copies user database from an earlier CodeSnip installation.
     ///  </summary>
     procedure BringForwardUserDB;
-    ///  <summary>Creates a new, empty, Unicode encoded config file for current
-    ///  installation.</summary>
-    procedure CreateEmptyCfgFile;
+    ///  <summary>Creates a new, empty, Unicode encoded per-user config file for
+    ///  current installation.</summary>
+    procedure CreateEmptyUserCfgFile;
     ///  <summary>
     function IsProgramUpdated: Boolean;
   end;
@@ -106,7 +106,7 @@
   strict private
     ///  <summary>Checks if user config file exists for current program version.
     ///  </summary>
-    class function CfgFileExists: Boolean;
+    class function UserCfgFileExists: Boolean;
     ///  <summary>Determines if this is first time this major version of the
     ///  program has been run.</summary>
     class function IsFirstRun: Boolean;
@@ -138,11 +138,11 @@
 
 { TFirstRun }
 
-procedure TFirstRun.BringForwardCfgFile;
-begin
-  Assert(HaveOldCfgFile,
-    ClassName + '.BringForwardCfgFile: Old config file does not exist');
-  fConfigFile.CopyFile(
+procedure TFirstRun.BringForwardUserCfgFile;
+begin
+  Assert(HaveOldUserCfgFile,
+    ClassName + '.BringForwardUserCfgFile: Old config file does not exist');
+  fUserConfigFile.CopyFile(
     fInstallInfo.PreviousUserConfigFileName,
     fInstallInfo.IsPreviousUserConfigFileANSI
   );
@@ -159,7 +159,7 @@
 begin
   inherited Create;
   fInstallInfo := TInstallInfo.Create;
-  fConfigFile := TUserConfigFileUpdater.Create(
+  fUserConfigFile := TUserConfigFileUpdater.Create(
     fInstallInfo.CurrentUserConfigFileName
   );
   fDatabase := TUserDatabaseUpdater.Create(
@@ -167,15 +167,15 @@
   );
 end;
 
-procedure TFirstRun.CreateEmptyCfgFile;
-begin
-  fConfigFile.CreateNewFile;
+procedure TFirstRun.CreateEmptyUserCfgFile;
+begin
+  fUserConfigFile.CreateNewFile;
 end;
 
 destructor TFirstRun.Destroy;
 begin
   fDatabase.Free;
-  fConfigFile.Free;
+  fUserConfigFile.Free;
   fInstallInfo.Free;
   inherited;
 end;
@@ -183,11 +183,11 @@
 {$IFNDEF PORTABLE}
 function TFirstRun.HasOldStyleProxyPwd: Boolean;
 begin
-  Result := (fConfigFile.FileVer <= 6) and fConfigFile.HasProxyPassword;
+  Result := (fUserConfigFile.FileVer <= 6) and fUserConfigFile.HasProxyPassword;
 end;
 {$ENDIF}
 
-function TFirstRun.HaveOldCfgFile: Boolean;
+function TFirstRun.HaveOldUserCfgFile: Boolean;
 begin
   Result := TFile.Exists(fInstallInfo.PreviousUserConfigFileName);
 end;
@@ -199,10 +199,10 @@
 
 function TFirstRun.IsProgramUpdated: Boolean;
 begin
-  Result := fConfigFile.IsCurrentProgramVer;
-end;
-
-procedure TFirstRun.UpdateCfgFile(out Changes: TFirstRunCfgChangeSet);
+  Result := fUserConfigFile.IsCurrentProgramVer;
+end;
+
+procedure TFirstRun.UpdateUserCfgFile(out Changes: TFirstRunCfgChangeSet);
 begin
   Changes := [];
 
@@ -210,51 +210,46 @@
   case fInstallInfo.InstallID of
     piOriginal:
     begin
-      fConfigFile.UpdateFromOriginal;
+      fUserConfigFile.UpdateFromOriginal;
       Include(Changes, frcHiliter);
       Include(Changes, frcRegistration);
       Include(Changes, frcSourceFormat);
     end;
     piV1_9, piV2:
     begin
-      fConfigFile.DeleteHighligherPrefs;
+      fUserConfigFile.DeleteHighligherPrefs;
       Include(Changes, frcHiliter);
     end;
     piV3:
     begin
       if HasOldStyleProxyPwd then
       begin
-        fConfigFile.DeleteProxyPassword;
+        fUserConfigFile.DeleteProxyPassword;
         Include(Changes, frcProxyPwd);
       end;
     end;
   end;
   {$ENDIF}
 
-  if fConfigFile.FileVer < 6 then
+  if fUserConfigFile.FileVer < 6 then
     // User ini file versions before 6 don't have the Prefs:CodeGen section and
     // default entries for predefined warnings.
     // NOTE: This works for a new config file providing it has not been stamped:
     // we rely on this for portable version.
-    fConfigFile.CreateDefaultCodeGenEntries;
+    fUserConfigFile.CreateDefaultCodeGenEntries;
 
   {$IFNDEF PORTABLE}
-  if fConfigFile.FileVer < 9 then
+  if fUserConfigFile.FileVer < 9 then
   begin
-    fConfigFile.DeleteDetailsPaneIndex; // can be v8 file even tho not supported
-    fConfigFile.UpdateCodeGenEntries;
+    fUserConfigFile.DeleteDetailsPaneIndex;
+    fUserConfigFile.UpdateCodeGenEntries;
   end;
   {$ENDIF}
 
-  fConfigFile.Stamp;
+  fUserConfigFile.Stamp;
 end;
 
 { TFirstRunMgr }
-
-class function TFirstRunMgr.CfgFileExists: Boolean;
-begin
-  Result := TFile.Exists(TInstallInfo.CurrentUserConfigFileName);
-end;
 
 class procedure TFirstRunMgr.Execute;
 var
@@ -269,10 +264,10 @@
       if FR.HaveOldCfgFile or FR.HaveOldUserDB then
         TV4ConfigDlg.Execute(Application, FR);
       {$ENDIF}
-      if not CfgFileExists then
+      if not UserCfgFileExists then
       begin
-        FR.CreateEmptyCfgFile;
-        FR.UpdateCfgFile(Changes);
+        FR.CreateEmptyUserCfgFile;
+        FR.UpdateUserCfgFile(Changes);
       end;
     finally
       FR.Free;
@@ -282,7 +277,7 @@
   begin
     FR := TFirstRun.Create;
     try
-      FR.UpdateCfgFile(Changes);
+      FR.UpdateUserCfgFile(Changes);
     finally
       FR.Free;
     end;
@@ -291,7 +286,7 @@
 
 class function TFirstRunMgr.IsFirstRun: Boolean;
 begin
-  Result := not CfgFileExists;
+  Result := not UserCfgFileExists;
 end;
 
 class function TFirstRunMgr.IsProgramUpdated: Boolean;
@@ -301,5 +296,10 @@
   );
 end;
 
+class function TFirstRunMgr.UserCfgFileExists: Boolean;
+begin
+  Result := TFile.Exists(TInstallInfo.CurrentUserConfigFileName);
+end;
+
 end.
 
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.