Browse Source

Added WebUpdate

Simon Grossenbacher 7 years ago
parent
commit
9bffaa6750
8 changed files with 113 additions and 15 deletions
  1. 1 0
      .gitignore
  2. BIN
      RESTDebugger.exe
  3. 2 0
      Update/MakeInstaller.cmd
  4. 8 7
      prj/RESTDebugger.dproj
  5. BIN
      prj/RESTDebugger.res
  6. 5 5
      prj/RESTDebugger.stat
  7. 0 1
      src/_frmMain.dfm
  8. 97 2
      src/_frmMain.pas

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/Update/Update.exe

BIN
RESTDebugger.exe


+ 2 - 0
Update/MakeInstaller.cmd

@@ -0,0 +1,2 @@
+del %~dp0Update.exe
+"C:\Program Files\7-Zip\7z.exe" a -SFX -mx9 %~dp0Update.exe "%~dp0..\RESTDebugger.exe" "%~dp0..\Example Config.rdproj" "%~dp0..\ssleay32.dll" "%~dp0..\libeay32.dll"

+ 8 - 7
prj/RESTDebugger.dproj

@@ -1,7 +1,7 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     <PropertyGroup>
         <ProjectGuid>{EAAEC73B-CF16-46C3-A598-65374DE332E9}</ProjectGuid>
-        <ProjectVersion>18.2</ProjectVersion>
+        <ProjectVersion>18.3</ProjectVersion>
         <FrameworkType>VCL</FrameworkType>
         <MainSource>RESTDebugger.dpr</MainSource>
         <Base>True</Base>
@@ -86,9 +86,9 @@
     <PropertyGroup Condition="'$(Base_Win64)'!=''">
         <UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
         <UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
-        <VerInfo_Keys>FileVersion=1.1.6.20;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
+        <VerInfo_Keys>FileVersion=1.1.6.25;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
         <VerInfo_Release>6</VerInfo_Release>
-        <VerInfo_Build>20</VerInfo_Build>
+        <VerInfo_Build>25</VerInfo_Build>
         <Icon_MainIcon>RESTDebugger_Icon.ico</Icon_MainIcon>
         <VerInfo_Locale>1033</VerInfo_Locale>
         <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace>
@@ -115,8 +115,8 @@
     </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
         <BT_BuildType>Debug</BT_BuildType>
-        <VerInfo_Keys>FileVersion=1.1.6.20;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
-        <VerInfo_Build>20</VerInfo_Build>
+        <VerInfo_Keys>FileVersion=1.1.6.25;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
+        <VerInfo_Build>25</VerInfo_Build>
         <VerInfo_Release>6</VerInfo_Release>
         <VerInfo_Locale>1033</VerInfo_Locale>
         <AppEnableHighDPI>true</AppEnableHighDPI>
@@ -124,6 +124,7 @@
         <Icon_MainIcon>RESTDebugger_Icon.ico</Icon_MainIcon>
         <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
         <VerInfo_MinorVer>1</VerInfo_MinorVer>
+        <Debugger_RunParams>/update</Debugger_RunParams>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_2)'!=''">
         <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
@@ -140,9 +141,9 @@
     </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
         <BT_BuildType>Debug</BT_BuildType>
-        <VerInfo_Keys>FileVersion=1.1.6.20;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
+        <VerInfo_Keys>FileVersion=1.1.6.25;ProductVersion=1.0.0.0;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
         <VerInfo_Release>6</VerInfo_Release>
-        <VerInfo_Build>20</VerInfo_Build>
+        <VerInfo_Build>25</VerInfo_Build>
         <AppEnableHighDPI>true</AppEnableHighDPI>
         <AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
         <VerInfo_Locale>1033</VerInfo_Locale>

BIN
prj/RESTDebugger.res


+ 5 - 5
prj/RESTDebugger.stat

@@ -1,10 +1,10 @@
 [Stats]
-EditorSecs=19447
-DesignerSecs=5690
+EditorSecs=19625
+DesignerSecs=5709
 InspectorSecs=3051
-CompileSecs=952718
-OtherSecs=4986
+CompileSecs=1006032
+OtherSecs=5049
 StartTime=27.10.2016 18:27:37
 RealKeys=0
 EffectiveKeys=0
-DebugSecs=14375
+DebugSecs=14411

+ 0 - 1
src/_frmMain.dfm

@@ -484,7 +484,6 @@ object frmMain: TfrmMain
           Top = 11
           Caption = 'Use basic authentication'
           TabOrder = 0
-          Width = 139
         end
         object edtAuthUsername: TcxTextEdit
           Left = 15

+ 97 - 2
src/_frmMain.pas

@@ -194,6 +194,7 @@ type
     procedure DoGETRequest(const AMethodType: TMethodType);
     procedure DoPOSTRequest(const AMethodType: TMethodType);
     procedure UpdateEditor(const AText: string);
+    procedure CheckForUpdate;
   public
     MainConfig: TJSONConfig;
     ActiveEditor: TSynEdit;
@@ -222,7 +223,7 @@ implementation
 {$R *.dfm}
 
 uses System.NetEncoding, System.UITypes, _EncryptStr, JsonDataObjects, IdGlobal, System.IOUtils, uRwXmlDOM,
-  _frmBiggerEditor, IdUri, _frmSearch;
+  _frmBiggerEditor, IdUri, _frmSearch, ShellApi;
 
 procedure TfrmMain.tbbtnRunClick(Sender: TObject);
 begin
@@ -394,6 +395,92 @@ begin
   SaveProject;
 end;
 
+procedure TfrmMain.CheckForUpdate;
+begin
+  TThread.CreateAnonymousThread(
+  procedure
+  var
+    HTTP: TIdHTTP;
+    bNewVersion: Boolean;
+    strlist: TStringList;
+    fs: TFileStream;
+    UpdateFile: TStringList;
+  begin
+    bNewVersion := False;
+    HTTP := TIdHTTP.Create(nil);
+    strlist := TStringList.Create;
+    try
+      try
+        strlist.Text := HTTP.Get('https://www.simnet.cx/WebUpdate/RESTDebugger/Update.txt');
+      except
+        bNewVersion := False;
+        raise;
+      end;
+
+      if strlist.Count = 2 then
+      begin
+        if strlist[0] = GetAppVersion then
+        begin
+          bNewVersion := False;
+        end
+        else
+        begin
+          DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe');
+          fs := TFileStream.Create(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe', fmCreate);
+          try
+            try
+              HTTP.Get(strlist[1], fs);
+            except
+              bNewVersion := False;
+              raise;
+            end;
+          finally
+            fs.Free;
+          end;
+
+          bNewVersion := True;
+        end;
+      end;
+    finally
+      strlist.Free;
+      HTTP.Free;
+
+      TThread.Synchronize(TThread.CurrentThread,
+      procedure
+      begin
+        if bNewVersion then
+        begin
+          //Create Update file and start it
+          UpdateFile := TStringList.Create;
+          try
+            UpdateFile.Add('timeout 1');
+            UpdateFile.Add('taskkill /F /IM RESTDebugger.exe');
+            UpdateFile.Add('"%~dp0Update.exe" -o"' + ExtractFilePath(ParamStr(0)) + '" -y');
+            UpdateFile.Add('start "" "' + ParamStr(0) + '" "/updated"');
+            UpdateFile.Add('del "%~dp0Update.exe"');
+            UpdateFile.Add('del "%~dp0Update.cmd"');
+            UpdateFile.SaveToFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
+          finally
+            UpdateFile.Free;
+          end;
+
+          if MessageDlg('Es ist eine neue Software Version verfügbar. Möchten Sie diese nun installieren?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
+          begin
+            ShellExecute(handle, 'open', PChar(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd'), nil, nil, SW_HIDE);
+            Close;
+          end
+          else
+          begin
+            //CleanUp temp files
+            DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
+            DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe');
+          end;
+        end;
+      end);
+    end;
+  end).Start;
+end;
+
 procedure TfrmMain.comboMethodPropertiesChange(Sender: TObject);
 begin
   tabPostData.TabVisible := (comboMethod.ItemIndex = 1) or (comboMethod.ItemIndex = 2) or (comboMethod.ItemIndex = 3);
@@ -865,7 +952,7 @@ begin
   end
   else
   begin
-    if ParamStr(1) <> '' then
+    if (ParamStr(1) <> '') and not (LowerCase(ParamStr(1)) = '/updated') then
     begin
       FActiveProject := ParamStr(1);
       FIsTempProjectLoaded := False;
@@ -959,6 +1046,14 @@ begin
   gsSearchTextHistory := MainConfig.ReadString('Search', 'gsSearchTextHistory', gsSearchTextHistory);
   gsReplaceText := MainConfig.ReadString('Search', 'gsReplaceText', gsReplaceText);
   gsReplaceTextHistory := MainConfig.ReadString('Search', 'gsReplaceTextHistory', gsReplaceTextHistory);
+
+
+  CheckForUpdate;
+
+  if LowerCase(ParamStr(1)) = '/updated' then
+  begin
+    //ShowMessage('updated');
+  end;
 end;
 
 function TfrmMain.GetAppVersion: string;