Browse Source

Add a 'Donate' link to the installer

Antony Male 8 years ago
parent
commit
4d86a6a806
2 changed files with 166 additions and 143 deletions
  1. 165 142
      installer/common.iss
  2. 1 1
      installer/x64/installer-x64.iss

+ 165 - 142
installer/common.iss

@@ -1,51 +1,50 @@
-
-#define AppExeName "SyncTrayzor.exe"
-#define AppRoot "..\.."
-#define AppSrc AppRoot + "\src\SyncTrayzor"
-#define AppBin AppRoot +"\bin\" + Arch + "\Release"
-#define AppExe AppBin + "\SyncTrayzor.exe"
-#define AppName GetStringFileInfo(AppExe, "ProductName")
-#define AppVersion GetFileVersion(AppExe)
-#define AppPublisher "SyncTrayzor"
-#define AppURL "https://github.com/canton7/SyncTrayzor"
-#define AppDataFolder "SyncTrayzor"
+#define AppExeName "SyncTrayzor.exe"
+#define AppRoot "..\.."
+#define AppSrc AppRoot + "\src\SyncTrayzor"
+#define AppBin AppRoot +"\bin\" + Arch + "\Release"
+#define AppExe AppBin + "\SyncTrayzor.exe"
+#define AppName GetStringFileInfo(AppExe, "ProductName")
+#define AppVersion GetFileVersion(AppExe)
+#define AppPublisher "SyncTrayzor"
+#define AppURL "https://github.com/canton7/SyncTrayzor"
+#define AppDataFolder "SyncTrayzor"
 #define RunRegKey "Software\Microsoft\Windows\CurrentVersion\Run"
-#define DotNetInstallerExe "dotNet451Setup.exe"
-
-
-[Setup]
-AppId={{#AppId}
-AppName={#AppName} ({#Arch})
-AppVersion={#AppVersion}
-;AppVerName={#AppName} {#AppVersion}
-AppPublisher={#AppPublisher}
-AppPublisherURL={#AppURL}
-AppSupportURL={#AppURL}
-AppUpdatesURL={#AppURL}
-DefaultDirName={pf}\{#AppName}
-DefaultGroupName={#AppName}
-AllowNoIcons=yes
-LicenseFile={#AppRoot}\LICENSE.txt
-OutputDir="."
-OutputBaseFilename={#AppName}Setup-{#Arch}
+#define DotNetInstallerExe "dotNet451Setup.exe"
+#define DonateUrl = "https://synctrayzor.antonymale.co.uk/donate"
+
+[Setup]
+AppId={{#AppId}
+AppName={#AppName} ({#Arch})
+AppVersion={#AppVersion}
+;AppVerName={#AppName} {#AppVersion}
+AppPublisher={#AppPublisher}
+AppPublisherURL={#AppURL}
+AppSupportURL={#AppURL}
+AppUpdatesURL={#AppURL}
+DefaultDirName={pf}\{#AppName}
+DefaultGroupName={#AppName}
+AllowNoIcons=yes
+LicenseFile={#AppRoot}\LICENSE.txt
+OutputDir="."
+OutputBaseFilename={#AppName}Setup-{#Arch}
 SetupIconFile={#AppSrc}\Icons\default.ico
-WizardSmallImageFile=..\icon.bmp
-Compression=lzma2/max
-;Compression=None
-SolidCompression=yes
-PrivilegesRequired=admin
-CloseApplications=yes
-RestartApplications=no
-; If we try and close CefSharp.BrowserSubprocess.exe we'll fail - it doesn't respond well
-; However if we close *just* SyncTrayzor, that will take care of shutting down CefSharp and syncthing
-CloseApplicationsFilter=SyncTrayzor.exe
-TouchDate=current
-#if "x64" == Arch
-ArchitecturesInstallIn64BitMode=x64
-ArchitecturesAllowed=x64
-#endif
-
-[Languages]
+WizardSmallImageFile=..\icon.bmp
+;Compression=lzma2/max
+Compression=None
+SolidCompression=yes
+PrivilegesRequired=admin
+CloseApplications=yes
+RestartApplications=no
+; If we try and close CefSharp.BrowserSubprocess.exe we'll fail - it doesn't respond well
+; However if we close *just* SyncTrayzor, that will take care of shutting down CefSharp and syncthing
+CloseApplicationsFilter=SyncTrayzor.exe
+TouchDate=current
+#if "x64" == Arch
+ArchitecturesInstallIn64BitMode=x64
+ArchitecturesAllowed=x64
+#endif
+
+[Languages]
 Name: "english"; MessagesFile: "compiler:Default.isl"
 
 [CustomMessages]
@@ -55,44 +54,44 @@ DotNetFrameworkFailed1602=.NET Framework installation was cancelled. This instal
 DotNetFrameworkFailed1603=A fatal error occurred while installing the .NET Framework. Please fix the error, then run the installer again.
 DotNetFrameworkFailed5100=Your computer does not meet the requirements of the .NET Framework. Please consult the documentation.
 DotNetFrameworkFailedOther=The .NET Framework installer exited with an unexpected status code "%1". Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this installation and fix the problem if it did not.
-
-[Tasks]
-Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
-
-[Dirs]
-Name: "{userappdata}\{#AppDataFolder}"
-
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Dirs]
+Name: "{userappdata}\{#AppDataFolder}"
+
 [Files]
 ; Near the beginning, as it's extracted first and this makes it cheaper
 Source: "..\{#DotNetInstallerExe}"; DestDir: {tmp}; Flags: dontcopy nocompression noencryption
-
-Source: "{#AppBin}\*"; DestDir: "{app}"; Excludes: "*.xml,*.vshost.*,*.config,*.log,FluentValidation.resources.dll,System.Windows.Interactivity.resources.dll,syncthing.exe,data,logs,ffmpegsumo.dll,d3dcompiler_43.dll,d3dcompiler_47.dll,libEGL.dll,libGLESv2.dll,pdf.dll"; Flags: ignoreversion recursesubdirs
-Source: "{#AppBin}\SyncTrayzor.exe.Installer.config"; DestDir: "{app}"; DestName: "SyncTrayzor.exe.config"; Flags: ignoreversion
-Source: "{#AppSrc}\Icons\default.ico"; DestDir: "{app}"; Flags: ignoreversion
-Source: "{#AppRoot}\*.md"; DestDir: "{app}"; Flags: ignoreversion
-Source: "{#AppRoot}\*.txt"; DestDir: "{app}"; Flags: ignoreversion
-Source: "*.dll"; DestDir: "{app}"; Flags: ignoreversion
-Source: "syncthing.exe"; DestDir: "{app}"; DestName: "syncthing.exe"; Flags: ignoreversion
-
-[Icons]
-Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}"
-Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
-Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon
-
-[Run]
-Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
-
+
+Source: "{#AppBin}\*"; DestDir: "{app}"; Excludes: "*.xml,*.vshost.*,*.config,*.log,FluentValidation.resources.dll,System.Windows.Interactivity.resources.dll,syncthing.exe,data,logs,ffmpegsumo.dll,d3dcompiler_43.dll,d3dcompiler_47.dll,libEGL.dll,libGLESv2.dll,pdf.dll"; Flags: ignoreversion recursesubdirs
+Source: "{#AppBin}\SyncTrayzor.exe.Installer.config"; DestDir: "{app}"; DestName: "SyncTrayzor.exe.config"; Flags: ignoreversion
+Source: "{#AppSrc}\Icons\default.ico"; DestDir: "{app}"; Flags: ignoreversion
+Source: "{#AppRoot}\*.md"; DestDir: "{app}"; Flags: ignoreversion
+Source: "{#AppRoot}\*.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: "*.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "syncthing.exe"; DestDir: "{app}"; DestName: "syncthing.exe"; Flags: ignoreversion
+
+[Icons]
+Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}"
+Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
+Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
+
 [Code]
 var
   GlobalRestartRequired: boolean;
-
-function DotNetIsMissing(): Boolean;
-var 
-  Exists: Boolean;
-  Release: Cardinal;
-begin
-  Exists := RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', Release);
-  Result := not Exists or (Release < 378758);
+
+function DotNetIsMissing(): Boolean;
+var 
+  Exists: Boolean;
+  Release: Cardinal;
+begin
+  Exists := RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', Release);
+  Result := not Exists or (Release < 378758);
 end;
 
 // Adapted from https://blogs.msdn.microsoft.com/davidrickard/2015/07/17/installing-net-framework-4-5-automatically-with-inno-setup/
@@ -141,63 +140,85 @@ begin
     WizardForm.StatusLabel.Caption := StatusText;
     WizardForm.ProgressGauge.Style := npbstNormal;
   end;
-end;
-
-procedure BumpInstallCount;
-var
-  FileContents: AnsiString;
-  InstallCount: integer;
-begin
-  { Increment the install count in InstallCount.txt if it exists, or create it with the contents '1' if it doesn't }
-  if LoadStringFromFile(ExpandConstant('{app}\InstallCount.txt'), FileContents) then
-  begin
-    InstallCount := StrTointDef(Trim(string(FileContents)), 0) + 1;
-  end
-  else
-  begin
-    InstallCount := 1;
-  end;
-
-  SaveStringToFile(ExpandConstant('{app}\InstallCount.txt'), IntToStr(InstallCount), False);
-end;
-
-procedure CurStepChanged(CurStep: TSetupStep);
-var
-  FindRec: TFindRec;
-  FolderPath: String;
-  FilePath: String;
-begin
-  if CurStep = ssInstall then
-  begin
-    BumpInstallCount();
-
-    { We might be being run from ProcessRunner.exe, *and* we might be trying to update it. Funsies. Let's rename it (which Windows lets us do) }
-    DeleteFile(ExpandConstant('{app}\ProcessRunner.exe.old'));
-    RenameFile(ExpandConstant('{app}\ProcessRunner.exe'), ExpandConstant('{app}\ProcessRunner.exe.old'));
-
-    Log(ExpandConstant('Looking for resource files in {app}\*'));
-    { Remove resource files. This means that out-of-date languages will be removed, which (as a last-ditch resore) will alert maintainers that something's wrong }
-    if FindFirst(ExpandConstant('{app}\*'), FindRec) then
-    begin
-      try
-        repeat
-          if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and (FindRec.Name <> '.') and (FindRec.Name <> '..') then
-          begin
-            FolderPath :=  ExpandConstant('{app}\') + FindRec.Name;
-            FilePath := FolderPath + '\SyncTrayzor.resources.dll';
-            if DeleteFile(FilePath) then
-            begin
-              Log('Deleted ' + FilePath);
-              if DelTree(FolderPath, True, False, False) then
-                Log('Deleted ' + FolderPath);
-            end;
-          end;
-        until not FindNext(FindRec);
-      finally
-        FindClose(FindRec);
-      end;
-    end;
-  end
+end;
+
+procedure BumpInstallCount;
+var
+  FileContents: AnsiString;
+  InstallCount: integer;
+begin
+  { Increment the install count in InstallCount.txt if it exists, or create it with the contents '1' if it doesn't }
+  if LoadStringFromFile(ExpandConstant('{app}\InstallCount.txt'), FileContents) then
+  begin
+    InstallCount := StrTointDef(Trim(string(FileContents)), 0) + 1;
+  end
+  else
+  begin
+    InstallCount := 1;
+  end;
+
+  SaveStringToFile(ExpandConstant('{app}\InstallCount.txt'), IntToStr(InstallCount), False);
+end;
+
+procedure URLLabelOnClick(Sender: TObject);
+var
+	ErrorCode: Integer;
+begin
+	ShellExec('open', '{#DonateUrl}', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
+end;
+
+procedure InitializeWizard;
+var
+  URLLabel: TNewStaticText;
+begin
+  URLLabel := TNewStaticText.Create(WizardForm);
+  URLLabel.Caption := 'Donate';
+  URLLabel.Cursor := crHand;
+  URLLabel.Parent := WizardForm;
+  URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
+	URLLabel.Font.Color := clBlue;
+	URLLabel.Top := WizardForm.ClientHeight - URLLabel.Height - 15;
+  URLLabel.Left := ScaleX(10)
+  URLLabel.OnClick := @URLLabelOnClick;
+end;
+
+procedure CurStepChanged(CurStep: TSetupStep);
+var
+  FindRec: TFindRec;
+  FolderPath: String;
+  FilePath: String;
+begin
+  if CurStep = ssInstall then
+  begin
+    BumpInstallCount();
+
+    { We might be being run from ProcessRunner.exe, *and* we might be trying to update it. Funsies. Let's rename it (which Windows lets us do) }
+    DeleteFile(ExpandConstant('{app}\ProcessRunner.exe.old'));
+    RenameFile(ExpandConstant('{app}\ProcessRunner.exe'), ExpandConstant('{app}\ProcessRunner.exe.old'));
+
+    Log(ExpandConstant('Looking for resource files in {app}\*'));
+    { Remove resource files. This means that out-of-date languages will be removed, which (as a last-ditch resore) will alert maintainers that something's wrong }
+    if FindFirst(ExpandConstant('{app}\*'), FindRec) then
+    begin
+      try
+        repeat
+          if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0) and (FindRec.Name <> '.') and (FindRec.Name <> '..') then
+          begin
+            FolderPath :=  ExpandConstant('{app}\') + FindRec.Name;
+            FilePath := FolderPath + '\SyncTrayzor.resources.dll';
+            if DeleteFile(FilePath) then
+            begin
+              Log('Deleted ' + FilePath);
+              if DelTree(FolderPath, True, False, False) then
+                Log('Deleted ' + FolderPath);
+            end;
+          end;
+        until not FindNext(FindRec);
+      finally
+        FindClose(FindRec);
+      end;
+    end;
+  end
 end;
 
 function PrepareToInstall(var NeedsRestart: Boolean): String;
@@ -215,10 +236,12 @@ end;
 function NeedRestart(): Boolean;
 begin
   Result := GlobalRestartRequired;
-end;
-
-[UninstallDelete]
-Type: files; Name: "{app}\ProcessRunner.exe.old"
-Type: files; Name: "{app}\InstallCount.txt"
-Type: filesandordirs; Name: "{userappdata}\{#AppDataFolder}"
-Type: filesandordirs; Name: "{localappdata}\{#AppDataFolder}"
+end;
+
+[UninstallDelete]
+Type: files; Name: "{app}\ProcessRunner.exe.old"
+Type: files; Name: "{app}\InstallCount.txt"
+Type: filesandordirs; Name: "{userappdata}\{#AppDataFolder}"
+Type: filesandordirs; Name: "{localappdata}\{#AppDataFolder}"
+
+

+ 1 - 1
installer/x64/installer-x64.iss

@@ -1,4 +1,4 @@
 #define Arch "x64"
 #define AppId "{c004dcef-b848-46a5-9c30-4dbf736396fa}"
 
-#include "../common.iss"
+#include "../common.iss"