@@ -149,6 +149,7 @@ TPackageOptions = class(TPackageBaseObject)
149149 FExecuteProgram: WideString;
150150 FReadmeFile: TPackageContentFile;
151151 FGraphicFile: TPackageContentFile;
152+ FLicenseFile: TPackageContentFile;
152153 FLoadLegacy: Boolean;
153154 procedure SetReadmeFile (const Value : TPackageContentFile);
154155 procedure SetExecuteProgram (Value : WideString);
@@ -158,6 +159,9 @@ TPackageOptions = class(TPackageBaseObject)
158159 EventType: TPackageNotifyEventType; var FAllow: Boolean);
159160 procedure ReadmeRemoved (Sender: TObject;
160161 EventType: TPackageNotifyEventType; var FAllow: Boolean);
162+ procedure SetLicenseFile (const Value : TPackageContentFile);
163+ procedure LicenseRemoved (Sender: TObject;
164+ EventType: TPackageNotifyEventType; var FAllow: Boolean);
161165 public
162166 constructor Create(APackage: TPackage); override;
163167 destructor Destroy; override;
@@ -173,6 +177,7 @@ TPackageOptions = class(TPackageBaseObject)
173177 property ExecuteProgram: WideString read FExecuteProgram write SetExecuteProgram;
174178 property ReadmeFile: TPackageContentFile read FReadmeFile write SetReadmeFile;
175179 property GraphicFile: TPackageContentFile read FGraphicFile write SetGraphicFile;
180+ property LicenseFile: TPackageContentFile read FLicenseFile write SetLicenseFile;
176181 end ;
177182
178183 { Package Information }
@@ -561,6 +566,7 @@ implementation
561566 SJSON_Options_ExecuteProgram = ' executeProgram' ;
562567 SJSON_Options_ReadMeFile = ' readmeFile' ;
563568 SJSON_Options_GraphicFile = ' graphicFile' ;
569+ SJSON_Options_LicenseFile = ' licenseFile' ;
564570
565571 SJSON_Registry = ' registry' ;
566572 SJSON_Registry_Root = ' root' ;
@@ -655,6 +661,9 @@ procedure TPackageOptions.Assign(Source: TPackageOptions);
655661 if Assigned(Source.GraphicFile)
656662 then GraphicFile := Package.Files.FromFileName(Source.GraphicFile.FileName)
657663 else GraphicFile := nil ;
664+ if Assigned(Source.LicenseFile)
665+ then LicenseFile := Package.Files.FromFileName(Source.LicenseFile.FileName)
666+ else LicenseFile := nil ;
658667end ;
659668
660669constructor TPackageOptions.Create(APackage: TPackage);
@@ -668,6 +677,7 @@ destructor TPackageOptions.Destroy;
668677begin
669678 ReadmeFile := nil ;
670679 GraphicFile := nil ;
680+ LicenseFile := nil ;
671681 inherited Destroy;
672682end ;
673683
@@ -681,14 +691,21 @@ procedure TPackageOptions.GraphicRemoved(Sender: TObject; EventType: TPackageNot
681691 FGraphicFile := nil ;
682692end ;
683693
694+ procedure TPackageOptions.LicenseRemoved (Sender: TObject; EventType: TPackageNotifyEventType; var FAllow: Boolean);
695+ begin
696+ FLicenseFile := nil ;
697+ end ;
698+
684699procedure TPackageOptions.LoadXML (ARoot: IXMLNode);
685700begin
686701 FileVersion := XmlVarToStr(ARoot.ChildNodes[' System' ].ChildNodes[' FileVersion' ].NodeValue);
687702 ExecuteProgram := XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' ExecuteProgram' ].NodeValue);
688703 ReadmeFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' ReadMeFile' ].NodeValue));
689704 GraphicFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' GraphicFile' ].NodeValue));
705+ LicenseFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' LicenseFile' ].NodeValue));
690706 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
691707 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
708+ if Assigned(LicenseFile) then LicenseFile.AddNotifyObject(LicenseRemoved);
692709end ;
693710
694711procedure TPackageOptions.SaveXML (ARoot: IXMLNode);
@@ -699,6 +716,8 @@ procedure TPackageOptions.SaveXML(ARoot: IXMLNode);
699716 ARoot.ChildNodes[' Options' ].ChildNodes[' ReadMeFile' ].NodeValue := ReadmeFile.RelativeFileName;
700717 if Assigned(GraphicFile) then
701718 ARoot.ChildNodes[' Options' ].ChildNodes[' GraphicFile' ].NodeValue := GraphicFile.RelativeFileName;
719+ if Assigned(LicenseFile) then
720+ ARoot.ChildNodes[' Options' ].ChildNodes[' LicenseFile' ].NodeValue := LicenseFile.RelativeFileName;
702721end ;
703722
704723procedure TPackageOptions.LoadIni (AIni: TIniFile);
@@ -709,6 +728,7 @@ procedure TPackageOptions.LoadIni(AIni: TIniFile);
709728 GraphicFile := Package.Files.FromFileName(AIni.ReadString(' Package' , ' GraphicFile' , ' ' ));
710729 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
711730 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
731+ // LicenseFile not supported in ini
712732end ;
713733
714734procedure TPackageOptions.LoadJSON (ARoot: TJSONObject);
@@ -722,8 +742,10 @@ procedure TPackageOptions.LoadJSON(ARoot: TJSONObject);
722742 ExecuteProgram := GetJsonValueString(FOptions, SJSON_Options_ExecuteProgram);
723743 ReadmeFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_ReadMeFile));
724744 GraphicFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_GraphicFile));
745+ LicenseFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_LicenseFile));
725746 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
726747 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
748+ if Assigned(LicenseFile) then LicenseFile.AddNotifyObject(LicenseRemoved);
727749end ;
728750
729751procedure TPackageOptions.SaveIni (AIni: TIniFile);
@@ -734,6 +756,7 @@ procedure TPackageOptions.SaveIni(AIni: TIniFile);
734756 AIni.WriteString(' Package' , ' ReadMeFile' , ReadmeFile.RelativeFileName);
735757 if Assigned(GraphicFile) then
736758 AIni.WriteString(' Package' , ' GraphicFile' , GraphicFile.RelativeFileName);
759+ // licenseFile not supported in ini
737760end ;
738761
739762procedure TPackageOptions.SaveJSON (ARoot: TJSONObject);
@@ -753,6 +776,8 @@ procedure TPackageOptions.SaveJSON(ARoot: TJSONObject);
753776 FOptions.AddPair(SJSON_Options_ReadMeFile, ReadmeFile.RelativeFileName);
754777 if Assigned(GraphicFile) then
755778 FOptions.AddPair(SJSON_Options_GraphicFile, GraphicFile.RelativeFileName);
779+ if Assigned(LicenseFile) then
780+ FOptions.AddPair(SJSON_Options_LicenseFile, LicenseFile.RelativeFileName);
756781end ;
757782
758783procedure TPackageOptions.SetExecuteProgram (Value : WideString);
@@ -780,6 +805,19 @@ procedure TPackageOptions.SetGraphicFile(const Value: TPackageContentFile);
780805 end ;
781806end ;
782807
808+ procedure TPackageOptions.SetLicenseFile (const Value : TPackageContentFile);
809+ begin
810+ if Assigned(FLicenseFile) then FLicenseFile.RemoveNotifyObject(LicenseRemoved);
811+ if not Assigned(Value ) then
812+ FLicenseFile := nil
813+ else
814+ begin
815+ if Value .Package <> Package then raise EPackageInfo.CreateFmt(SGraphicNotOwnedCorrectly, [Value ]);
816+ FLicenseFile := Value ;
817+ FLicenseFile.AddNotifyObject(LicenseRemoved);
818+ end ;
819+ end ;
820+
783821procedure TPackageOptions.SetReadmeFile (const Value : TPackageContentFile);
784822begin
785823 if Assigned(FReadmeFile) then FReadmeFile.RemoveNotifyObject(ReadmeRemoved);
0 commit comments