To V0.3.4.0 Work-in-progress

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5712 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2017-01-27 10:38:53 +00:00
parent d76fc59786
commit 7046b88864
8 changed files with 484 additions and 91 deletions

View File

@@ -66,8 +66,8 @@ More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater
along with this library; if not, write to the Free Software Foundation, along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"/> "/>
<Version Minor="3" Release="3"/> <Version Minor="3" Release="4"/>
<Files Count="6"> <Files Count="7">
<Item1> <Item1>
<Filename Value="ulazautoupdate.pas"/> <Filename Value="ulazautoupdate.pas"/>
<HasRegisterProc Value="True"/> <HasRegisterProc Value="True"/>
@@ -94,6 +94,10 @@ More information in the Wiki Home Page http://wiki.freepascal.org/LazAutoUpdater
<Filename Value="open_ssl.pas"/> <Filename Value="open_ssl.pas"/>
<UnitName Value="open_ssl"/> <UnitName Value="open_ssl"/>
</Item6> </Item6>
<Item7>
<Filename Value="ushortcut.pas"/>
<UnitName Value="ushortcut"/>
</Item7>
</Files> </Files>
<i18n> <i18n>
<EnableI18N Value="True"/> <EnableI18N Value="True"/>

View File

@@ -9,7 +9,7 @@ interface
uses uses
ulazautoupdate, aboutlazautoupdateunit, VersionSupport, uappisrunning, ulazautoupdate, aboutlazautoupdateunit, VersionSupport, uappisrunning,
lazautoupdate_httpclient, open_ssl, LazarusPackageIntf; lazautoupdate_httpclient, open_ssl, ushortcut, LazarusPackageIntf;
implementation implementation

View File

@@ -66,6 +66,7 @@
</Target> </Target>
<SearchPaths> <SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/> <IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value=".."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<CodeGeneration> <CodeGeneration>

View File

@@ -35,8 +35,7 @@ uses
cthreads, cthreads,
{$ENDIF}{$ENDIF} {$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset Interfaces, // this includes the LCL widgetset
Forms, umainform, open_ssl Forms, umainform, open_ssl;
{ you can add units after this };
{$R *.res} {$R *.res}

View File

@@ -4,13 +4,13 @@
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="10"/> <Version Value="10"/>
<BuildModes Active="Win64"/> <BuildModes Active="Win64"/>
<Units Count="22"> <Units Count="28">
<Unit0> <Unit0>
<Filename Value="testapp.lpr"/> <Filename Value="testapp.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="6"/>
<CursorPos X="25" Y="28"/> <CursorPos X="25" Y="28"/>
<UsageCount Value="59"/> <UsageCount Value="63"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@@ -20,8 +20,8 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<TopLine Value="8"/> <TopLine Value="8"/>
<CursorPos X="55" Y="40"/> <CursorPos X="16" Y="15"/>
<UsageCount Value="59"/> <UsageCount Value="63"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
@@ -32,7 +32,7 @@
<WindowIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="31"/> <TopLine Value="31"/>
<CursorPos X="48" Y="14"/> <CursorPos X="48" Y="14"/>
<UsageCount Value="42"/> <UsageCount Value="46"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="..\lazautoupdate_httpclient.pas"/> <Filename Value="..\lazautoupdate_httpclient.pas"/>
@@ -43,15 +43,15 @@
<Unit4> <Unit4>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="117"/> <TopLine Value="450"/>
<CursorPos X="10" Y="118"/> <CursorPos X="60" Y="471"/>
<ExtraEditorCount Value="2"/> <ExtraEditorCount Value="2"/>
<ExtraEditor1> <ExtraEditor1>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<WindowIndex Value="1"/> <EditorIndex Value="1"/>
<TopLine Value="106"/> <TopLine Value="559"/>
<CursorPos X="38" Y="109"/> <CursorPos Y="583"/>
</ExtraEditor1> </ExtraEditor1>
<ExtraEditor2> <ExtraEditor2>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
@@ -59,7 +59,7 @@
<TopLine Value="-1"/> <TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/> <CursorPos X="-1" Y="-1"/>
</ExtraEditor2> </ExtraEditor2>
<UsageCount Value="29"/> <UsageCount Value="31"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
@@ -146,7 +146,7 @@
<WindowIndex Value="1"/> <WindowIndex Value="1"/>
<TopLine Value="132"/> <TopLine Value="132"/>
<CursorPos X="6" Y="338"/> <CursorPos X="6" Y="338"/>
<UsageCount Value="19"/> <UsageCount Value="21"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
@@ -184,130 +184,179 @@
<TopLine Value="290"/> <TopLine Value="290"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit21> </Unit21>
<Unit22>
<Filename Value="..\ushortcut.pas"/>
<EditorIndex Value="4"/>
<TopLine Value="29"/>
<CursorPos X="8" Y="45"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
<Filename Value="C:\laztrunk\fpc\packages\fcl-process\src\process.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="116"/>
<CursorPos X="24" Y="125"/>
<UsageCount Value="11"/>
</Unit23>
<Unit24>
<Filename Value="C:\laztrunk\fpc\packages\winunits-base\src\shlobj.pp"/>
<EditorIndex Value="5"/>
<TopLine Value="2203"/>
<CursorPos X="56" Y="2335"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit24>
<Unit25>
<Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\classesh.inc"/>
<EditorIndex Value="3"/>
<TopLine Value="399"/>
<CursorPos X="30" Y="426"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit25>
<Unit26>
<Filename Value="C:\laztrunk\fpc\rtl\win32\windows.pp"/>
<EditorIndex Value="-1"/>
<TopLine Value="12"/>
<CursorPos X="5" Y="39"/>
<UsageCount Value="10"/>
</Unit26>
<Unit27>
<Filename Value="..\aboutlazautoupdateunit.pas"/>
<EditorIndex Value="2"/>
<TopLine Value="65"/>
<CursorPos X="41" Y="86"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit27>
</Units> </Units>
<OtherDefines Count="1"> <OtherDefines Count="1">
<Define0 Value="DEBUGMODE"/> <Define0 Value="DEBUGMODE"/>
</OtherDefines> </OtherDefines>
<General>
<ActiveWindowIndexAtStart Value="1"/>
</General>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="99" Column="38" TopLine="64"/> <Caret Line="1804" Column="20" TopLine="1777"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="umainform.pas"/> <Filename Value="..\ushortcut.pas"/>
<Caret Line="127" Column="28" TopLine="123"/> <Caret Line="83" Column="34" TopLine="60"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ushortcut.pas"/>
<Caret Line="472" Column="22" TopLine="446"/> <Caret Line="52" Column="94" TopLine="30"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ushortcut.pas"/>
<Caret Line="1094" Column="27" TopLine="1082"/> <Caret Line="51" TopLine="10"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ushortcut.pas"/>
<Caret Line="1117" Column="23" TopLine="1082"/> <Caret Line="91" Column="6" TopLine="64"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ushortcut.pas"/>
<Caret Line="1120" Column="35" TopLine="1082"/> <Caret Line="149" Column="31"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1123" Column="35" TopLine="1082"/> <Caret Line="242" Column="24" TopLine="214"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1316" Column="25" TopLine="1298"/> <Caret Line="241" Column="34" TopLine="215"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1324" Column="23" TopLine="1298"/> <Caret Line="232" Column="37" TopLine="214"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="C:\laztrunk\fpc\rtl\objpas\classes\classesh.inc"/>
<Caret Line="1358" Column="73" TopLine="1264"/> <Caret Line="426" Column="30" TopLine="399"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2187" Column="58" TopLine="2140"/> <Caret Line="232" Column="36" TopLine="214"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2216" Column="15" TopLine="2169"/> <Caret Line="281" Column="45" TopLine="259"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2231" Column="46" TopLine="2205"/> <Caret Line="243" TopLine="223"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="133" TopLine="113"/> <Caret Line="241" Column="43" TopLine="214"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="19" Column="43" TopLine="7"/> <Caret Line="251" Column="21" TopLine="223"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="153" TopLine="123"/> <Caret Line="679" Column="49" TopLine="658"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="umainform.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="165" TopLine="124"/> <Caret Line="701" Column="38" TopLine="687"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="209" Column="24" TopLine="184"/> <Caret Line="457" Column="37" TopLine="444"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="193" Column="17" TopLine="184"/> <Caret Line="466" Column="23" TopLine="452"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1929" Column="33" TopLine="1904"/> <Caret Line="470" Column="40" TopLine="460"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2016" Column="108" TopLine="1984"/> <Caret Line="583" Column="36" TopLine="552"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="63" Column="65" TopLine="48"/> <Caret Line="553" TopLine="529"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="2019" Column="6" TopLine="1987"/> <Caret Line="545" Column="6" TopLine="523"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="1998" Column="5" TopLine="1987"/> <Caret Line="61" Column="74" TopLine="50"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="6" Column="10"/> <Caret Line="570" Column="28" TopLine="542"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="117" Column="48" TopLine="79"/> <Caret Line="621" Column="46" TopLine="582"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="118" Column="24" TopLine="80"/> <Caret Line="629" Column="65" TopLine="593"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="318" Column="28" TopLine="282"/> <Caret Line="637" Column="51" TopLine="615"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="922" Column="58" TopLine="884"/> <Caret Line="639" Column="8" TopLine="615"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\ulazautoupdate.pas"/> <Filename Value="..\ulazautoupdate.pas"/>
<Caret Line="934" Column="58" TopLine="896"/> <Caret Line="637" Column="50" TopLine="616"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>

View File

@@ -125,6 +125,8 @@ object mainform: Tmainform
GitHubProjectname = 'lazarusccr' GitHubProjectname = 'lazarusccr'
GitHubRepositoryName = 'TestApp' GitHubRepositoryName = 'TestApp'
GitHubBranchOrTag = 'updates' GitHubBranchOrTag = 'updates'
ShortCut.ShortcutName = 'AnotherName'
ShortCut.Category = scUtility
Left = 200 Left = 200
Top = 24 Top = 24
end end

View File

@@ -58,11 +58,11 @@ interface
uses uses
Forms, Classes, SysUtils, lazautoupdate_httpclient, strutils, Forms, Classes, SysUtils, lazautoupdate_httpclient, strutils,PropEdits,
LazUTF8, FileUtil, LazFileUtils, Dialogs, StdCtrls, LazUTF8, FileUtil, LazFileUtils, Dialogs, StdCtrls,
Buttons, DateUtils,{$IFDEF LINUX}process, asyncprocess,{$ENDIF}zipper, LResources, Buttons, DateUtils,{$IFDEF LINUX}process, asyncprocess,{$ENDIF}zipper, LResources,
VersionSupport, inifiles, aboutlazautoupdateunit, uappisrunning, LCLProc, VersionSupport, inifiles, aboutlazautoupdateunit, uappisrunning, LCLProc,
fileinfo, open_ssl, winpeimagereader {need this for reading exe info} fileinfo, open_ssl, ushortcut,winpeimagereader {need this for reading exe info}
, elfreader {needed for reading ELF executables} , elfreader {needed for reading ELF executables}
, machoreader {needed for reading MACH-O executables} , machoreader {needed for reading MACH-O executables}
{$IFDEF WINDOWS}, Windows, ShellAPI{$ENDIF}; // Thanks to Windows 10 and 704 error {$IFDEF WINDOWS}, Windows, ShellAPI{$ENDIF}; // Thanks to Windows 10 and 704 error
@@ -139,10 +139,10 @@ const
V0.3.1: Added SetExecutePermission (LINUX only) V0.3.1: Added SetExecutePermission (LINUX only)
V0.3.2: Bugfix for DoSilentUpdate V0.3.2: Bugfix for DoSilentUpdate
V0.3.3: Added event OnUpdate V0.3.3: Added event OnUpdate
V0.3.4: ?? V0.3.4: Added unit ushortcut (CreateDesktopShortCut) for installers
} }
C_TLazAutoUpdateComponentVersion = '0.3.3'; C_TLazAutoUpdateComponentVersion = '0.3.4.0';
C_TThreadedDownloadComponentVersion = '0.0.3'; C_TThreadedDownloadComponentVersion = '0.0.3.0';
{ {
V0.0.1: Initial alpha V0.0.1: Initial alpha
V0.0.2: Added fDebugmode to all classes and functions V0.0.2: Added fDebugmode to all classes and functions
@@ -228,6 +228,7 @@ resourcestring
'sClick OK to continue'; 'sClick OK to continue';
rsApplicationU = 'Application update'; rsApplicationU = 'Application update';
type type
// Dummy thread to initialise the threading system // Dummy thread to initialise the threading system
tc = class(tthread) tc = class(tthread)
@@ -247,7 +248,7 @@ type
end; end;
TThreadedDownload = class; // Forward declaration TThreadedDownload = class; // Forward declaration
TShortCutClass = class; // Forward declaration
{TLAZAUTOUPDATE} {TLAZAUTOUPDATE}
// Event declarations // Event declarations
TOnNewVersionAvailable = procedure(Sender: TObject; Newer: boolean; TOnNewVersionAvailable = procedure(Sender: TObject; Newer: boolean;
@@ -256,7 +257,7 @@ type
object; object;
TOnDebugEvent = procedure(Sender: TObject; lauMethodName, lauMessage: string) of TOnDebugEvent = procedure(Sender: TObject; lauMethodName, lauMessage: string) of
object; object;
TOnUpdated = Procedure(Sender:TObject;NewVersion,LauMessage:String) of Object; TOnUpdated = procedure(Sender: TObject; NewVersion, LauMessage: string) of object;
TLazAutoUpdate = class(TAboutLazAutoUpdate) TLazAutoUpdate = class(TAboutLazAutoUpdate)
private private
@@ -283,6 +284,7 @@ type
fShowDialogs: boolean; fShowDialogs: boolean;
fDownloadInprogress: boolean; fDownloadInprogress: boolean;
fWindowsAdminCheck: boolean; fWindowsAdminCheck: boolean;
fShortCutClass:TShortCutClass;
{$IFDEF UNIX} {$IFDEF UNIX}
FUpdateHMProcess: TAsyncProcess; FUpdateHMProcess: TAsyncProcess;
{$ENDIF} {$ENDIF}
@@ -319,8 +321,8 @@ type
function GetThreadDownloadReturnCode: integer; function GetThreadDownloadReturnCode: integer;
function IsOnlineVersionNewer(const sznewINIPath: string): boolean; function IsOnlineVersionNewer(const sznewINIPath: string): boolean;
function DoSilentUpdate: boolean; function DoSilentUpdate: boolean;
function GetUpdateSilentExe:String; function GetUpdateSilentExe: string;
function GetUpdateExe:String; function GetUpdateExe: string;
protected protected
public public
@@ -447,6 +449,37 @@ type
write fGitHubRepositoryName; write fGitHubRepositoryName;
// Default=master but any branchname or tagname is OK // Default=master but any branchname or tagname is OK
property GitHubBranchOrTag: string read fGitHubBranchOrTag write fGitHubBranchOrTag; property GitHubBranchOrTag: string read fGitHubBranchOrTag write fGitHubBranchOrTag;
property ShortCut:TShortCutClass read fShortCutClass write fShortCutClass;
end;
Type
TShortCutCategory = (scAudioVideo,scAudio,scDevelopment,
scEducation,scGame,scGraphics,scNetwork,scOffice,scScience,scSettings,
scSystem,scUtility);
// TShortCutCategoryFlags = Set of TShortCutCategory;
Type
TShortCutClass = Class(TPersistent)
private
// ShortCut stuff for CreateDesktopShortCut in ushortcut.pas
fShortCutTarget:String;
fShortCutTargetArguments:String;
fShortCutShortcutName:String;
fShortCutIconFileName:String;
fShortCutCategoryString:String;
fShortCutCategory:TShortCutCategory; // For easier property access
procedure SetShortCutCategoryString(ACategory:TShortCutCategory);
Public
constructor Create; // Constructor must be public
destructor Destroy; override; // Destructor must be public
published
property Target:String read fShortCutTarget write fShortCutTarget;
property TargetArguments:String read fShortCutTargetArguments write fShortCutTargetArguments;
property ShortcutName:String read fShortCutShortcutName write fShortCutShortcutName;
property IconFileName:String read fShortCutIconFileName write fShortCutIconFileName;
property Category:TShortCutCategory read fShortCutCategory write SetShortCutCategoryString;
end; end;
{TThreadedDownload } {TThreadedDownload }
@@ -512,10 +545,18 @@ type
procedure ShowProgress; procedure ShowProgress;
} }
end; end;
Type
// For the TShortCutClass filename properties (needs propedits unit)
TMyFileNamePropertyEditor = class(TFileNamePropertyEditor)
public
// Override the Edit method for total control
function GetFilter: string; override;
function GetDialogOptions: TOpenOptions; override;
function GetDialogTitle: string; override;
end;
// Non-threaded function
// Non-threaded version
function DownloadHTTP(URL, TargetFile: string; var ReturnCode, DownloadSize: integer; function DownloadHTTP(URL, TargetFile: string; var ReturnCode, DownloadSize: integer;
bIsSourceForge, fDebugMode: boolean): boolean; bIsSourceForge, fDebugMode: boolean): boolean;
@@ -527,8 +568,39 @@ procedure Register;
begin begin
{$I lazautoupdate_icon.lrs} {$I lazautoupdate_icon.lrs}
RegisterComponents('System', [TLazAutoUpdate]); RegisterComponents('System', [TLazAutoUpdate]);
// Register the custom property editors for the TShortCutClass filename properties
RegisterPropertyEditor(TypeInfo(String),
TShortCutClass, 'Target', TMyFileNamePropertyEditor);
RegisterPropertyEditor(TypeInfo(String),
TShortCutClass, 'IconFileName', TMyFileNamePropertyEditor);
end; end;
// Start Property editors for File type properties in TShortCutClass
function TMyFileNamePropertyEditor.GetFilter: string;
begin
{$IFDEF WINDOWS}
Result := 'Windows executable|*.exe|All Files|*.*';
{$ELSE}
{$IFDEF LINUX}
Result := 'Linux executable|*.|All Files|*.*';
{$ELSE}
Result := 'All Files|*.*';
{$ENDIF}
{$ENDIF}
end;
function TMyFileNamePropertyEditor.GetDialogOptions: TOpenOptions;
begin
// To see the full list, drop an OpenDialog onto a form and see the Options property
Result := [ofFileMustExist, ofPathMustExist];
end;
function TMyFileNamePropertyEditor.GetDialogTitle: string;
begin
Result := 'Choose Shortcut Target Filename';
end;
// End Property editors for File type properties in TShortCutClass
// Dummy thread to initialise the threading process // Dummy thread to initialise the threading process
procedure tc.Execute; procedure tc.Execute;
begin begin
@@ -544,6 +616,32 @@ begin
while MilliSecondOfTheDay(Now) < (ThisSecond + MillisecondDelay) do ; while MilliSecondOfTheDay(Now) < (ThisSecond + MillisecondDelay) do ;
end; end;
procedure TShortCutClass.SetShortCutCategoryString(ACategory:TShortCutCategory);
{
TShortCutCategory = (scAudioVideo,scAudio,scDevelopment,
scEducation,scGame,scGraphics,scNetwork,scOffice,scScience,scSettings,
scSystem,scUtility);
}
begin
If ACategory=fShortCutCategory then exit;
fShortCutCategoryString:='Unknown';
Case ACategory of
scAudioVideo:fShortCutCategoryString:='AudioVideo';
scAudio:fShortCutCategoryString:='Audio';
scDevelopment:fShortCutCategoryString:='Development';
scEducation:fShortCutCategoryString:='Education';
scGame:fShortCutCategoryString:='Game';
scGraphics:fShortCutCategoryString:='Graphics';
scNetwork:fShortCutCategoryString:='Network';
scOffice:fShortCutCategoryString:='Office';
scScience:fShortCutCategoryString:='Science';
scSettings:fShortCutCategoryString:='Settings';
scSystem:fShortCutCategoryString:='System';
scUtility:fShortCutCategoryString:='Utility';
end;
end;
procedure TLazAutoUpdate.DebugTest; procedure TLazAutoUpdate.DebugTest;
begin begin
ShowMessage(fApplicationVersionString); ShowMessage(fApplicationVersionString);
@@ -650,6 +748,15 @@ end;
{$ENDIF} {$ENDIF}
// === END WINDOWS PROCS ======================================================= // === END WINDOWS PROCS =======================================================
constructor TShortCutClass.Create;
begin
inherited Create; // TComponent method;
end;
destructor TShortCutClass.Destroy;
begin
inherited Destroy;
end;
constructor TLazAutoUpdate.Create(AOwner: TComponent); constructor TLazAutoUpdate.Create(AOwner: TComponent);
var var
@@ -667,6 +774,10 @@ begin
// Freed in Destroy // Freed in Destroy
fThreadDownload := TThreadedDownload.Create(); fThreadDownload := TThreadedDownload.Create();
fShortCutClass:=TShortCutClass.Create();
fShortCutClass.ShortcutName:='MyShortcutName';
fShortCutClass.TargetArguments:='';
fShortCutClass.Category:=scDevelopment;
// Leave URL and Filename to be set via properties // Leave URL and Filename to be set via properties
fComponentVersion := C_TLazAutoUpdateComponentVersion; fComponentVersion := C_TLazAutoUpdateComponentVersion;
// Unused // Unused
@@ -773,21 +884,23 @@ end;
destructor TLazAutoUpdate.Destroy; destructor TLazAutoUpdate.Destroy;
begin begin
FreeAndNil(fThreadDownload); FreeAndNil(fThreadDownload);
FreeAndNil(fShortCutClass);
inherited Destroy; inherited Destroy;
end; end;
function TLazAutoUpdate.GetUpdateSilentExe:String;
function TLazAutoUpdate.GetUpdateSilentExe: string;
begin begin
fUpdateSilentExe := C_LAUUPDATENAME; fUpdateSilentExe := C_LAUUPDATENAME;
If csDesigning in ComponentState then if csDesigning in ComponentState then
Result := 'lauupdate' Result := 'lauupdate'
else else
Result := fUpdateSilentExe; Result := fUpdateSilentExe;
end; end;
function TLazAutoUpdate.GetUpdateExe:String; function TLazAutoUpdate.GetUpdateExe: string;
begin begin
fUpdateExe := C_UPDATEHMNAME; fUpdateExe := C_UPDATEHMNAME;
If csDesigning in ComponentState then if csDesigning in ComponentState then
Result := 'updatehm' Result := 'updatehm'
else else
Result := fUpdateExe; Result := fUpdateExe;
@@ -2141,10 +2254,10 @@ begin
if cCount > 100000 then if cCount > 100000 then
begin begin
// Fire the OnUpdated event // Fire the OnUpdated event
If Assigned(fOnUpdated) then if Assigned(fOnUpdated) then
begin begin
fOnUpdated(Self, fGUIOnlineVersion, 'Unsuccessful update'); fOnUpdated(Self, fGUIOnlineVersion, 'Unsuccessful update');
Application.Processmessages; Application.ProcessMessages;
Sleep(100); Sleep(100);
end; end;
Break; // Get out of jail in case updatehm.exe fails to copy file Break; // Get out of jail in case updatehm.exe fails to copy file
@@ -2157,10 +2270,10 @@ begin
CreateLocalLauImportFile; // Creates a new import file in GetAppConfigDirUTF8 CreateLocalLauImportFile; // Creates a new import file in GetAppConfigDirUTF8
// Fire the OnUpdated event // Fire the OnUpdated event
If Assigned(fOnUpdated) then if Assigned(fOnUpdated) then
begin begin
fOnUpdated(Self, fGUIOnlineVersion, 'Successful update'); fOnUpdated(Self, fGUIOnlineVersion, 'Successful update');
Application.Processmessages; Application.ProcessMessages;
Sleep(100); Sleep(100);
end; end;

View File

@@ -0,0 +1,225 @@
unit ushortcut;
{
License
=======
LazAutoUpdate (c)2015 Gordon Bamber (minesadorada@charcodelvalle.com)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Linux Shortcut Info
===================
1. FreeDesktop Valid Categories
===============================
AudioVideo Application for presenting, creating, or processing multimedia (audio/video)
Audio An audio application Desktop entry must include AudioVideo as well
Audio A video application Desktop entry must include AudioVideo as well
Development An application for development
Education Educational software
Game A game
Graphics Application for viewing, creating, or processing graphics
Network Network application such as a web browser
Office An office type application
Science Scientific software
Settings Settings applications Entries may appear in a separate menu or as part of a "Control Center"
System System application, "System Tools" such as say a log viewer or network monitor
Utility Small utility application, "Accessories"
2. Example Desktop File
=======================
[Desktop Entry]
Version=1.0
Type=Application
Name=Foo Viewer
Comment=The best viewer for Foo objects available!
TryExec=fooview
Exec=fooview %F
Icon=fooview
MimeType=image/x-foo;
Actions=Gallery;Create;
[Desktop Action Gallery]
Exec=fooview --gallery
Name=Browse Gallery
[Desktop Action Create]
Exec=fooview --create-new
Name=Create a new Foo!
Icon=fooview-new
}
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LazUTF8, FileUtil, LazFileUtils
{$IFDEF LINUX}, process{$ENDIF}
{$IFDEF WINDOWS}, Windows, shlobj {for special folders}, ActiveX,
ComObj, ShellAPI{$ENDIF} ;
function CreateDesktopShortCut(Target, TargetArguments, ShortcutName,
IconFileName, Category: string): boolean;
implementation
{$IFDEF UNIX}
//Adapted from sysutils; Unix/Linux only
function XdgConfigHome: string;
{ Follows base-dir spec,
see [http://freedesktop.org/Standards/basedir-spec].
Always ends with PathDelim. }
begin
Result := GetEnvironmentVariable('XDG_CONFIG_HOME');
if (Result = '') then
Result := IncludeTrailingPathDelimiter(ExpandFileNameUTF8('~')) +
'.config' + DirectorySeparator
else
Result := IncludeTrailingPathDelimiter(Result);
end;
{$ENDIF UNIX}
{$IFDEF MSWINDOWS}
function CreateDesktopShortCut(Target, TargetArguments, ShortcutName,
IconFileName, Category: string): boolean;
var
IObject: IUnknown;
ISLink: IShellLink;
IPFile: IPersistFile;
PIDL: PItemIDList;
InFolder: array[0..MAX_PATH] of char;
LinkName: WideString;
begin
Result := True;
// Simple failure check
if not FileExistsUTF8(Target) then
Result := False;
if Result = False then
Exit;
try
{ Creates an instance of IShellLink }
IObject := CreateComObject(CLSID_ShellLink);
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
ISLink.SetPath(PChar(Target));
ISLink.SetArguments(PChar(TargetArguments));
ISLink.SetWorkingDirectory(PChar(ExtractFilePath(Target)));
// ISLink.SetIconLocation(Pchar(ExtractFilePath(Target) + IconFileName));
{ Get the desktop location }
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL);
SHGetPathFromIDList(PIDL, InFolder);
LinkName := IncludeTrailingPathDelimiter(InFolder) + ShortcutName + '.lnk';
{ Get rid of any existing shortcut first }
SysUtils.DeleteFile(LinkName);
{ Create the link }
IPFile.Save(PWChar(LinkName), False);
except
Result := False;
end;
end;
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
function CreateDesktopShortCut(Target, TargetArguments, ShortcutName,
IconFileName, Category: string): boolean;
var
XdgDesktopContent: TStringList;
XdgDesktopFile: string;
Aprocess: TProcess;
begin
// Suceed by default:
Result := True;
// Simple failure checks
if not FileExistsUTF8(Target) then
Result := False;
if not FileExistsUTF8(ExtractFilePath(Target) + IconFileName) then
Result := False;
if ShortCutName = '' then
Result := False;
if Result = False then
Exit;
if Category = '' then Category := 'Utility';
XdgDesktopFile := IncludeTrailingPathDelimiter(GetTempDir(False)) +
'fpcup-' + shortcutname + '.desktop';
XdgDesktopContent := TStringList.Create;
try
XdgDesktopContent.Add('[Desktop Entry]');
XdgDesktopContent.Add('Encoding=UTF-8');
XdgDesktopContent.Add('Type=Application');
XdgDesktopContent.Add('Icon=' + ExtractFilePath(Target) + IconFileName);
XdgDesktopContent.Add('Exec=' + Target + ' ' + TargetArguments);
XdgDesktopContent.Add('Name=' + ShortcutName);
XdgDesktopContent.Add('Category=' + Category + ';');
// We're going to try and call xdg-desktop-icon
// this may fail if shortcut exists already
AProcess := TProcess.Create(nil);
try
try
XdgDesktopContent.SaveToFile(XdgDesktopFile);
AProcess.Parameters.Add(XdgDesktopFile);
Aprocess.Executable := 'xdg-desktop-icon install';
Aprocess.WaitOnExit(2000);
Aprocess.Execute;
//OperationSucceeded:=(ExecuteCommand('xdg-desktop-icon install ' + XdgDesktopFile,false)=0);
except
Result := False;
end;
finally
AProcess.Free;
end;
if Result = False then
// Temp file is no longer needed....
try
DeleteFile(XdgDesktopFile);
finally
// Swallow, let filesystem maintenance clear it up
end;
finally
XdgDesktopContent.Free;
end;
end;
{$ENDIF UNIX}
{$IFDEF MSWINDOWS}
procedure DeleteDesktopShortcut(ShortcutName: string);
var
PIDL: PItemIDList;
InFolder: array[0..MAX_PATH] of char;
LinkName: WideString;
begin
{ Get the desktop location }
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL);
SHGetPathFromIDList(PIDL, InFolder);
LinkName := IncludeTrailingPathDelimiter(InFolder) + ShortcutName + '.lnk';
SysUtils.DeleteFile(LinkName);
end;
{$ENDIF MSWINDOWS}
end.