@@ -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 }
@@ -509,6 +514,7 @@ implementation
509514 SPackageInfoTooNew = ' The package file is version %s. This version can only read version ' +SKeymanVersion+' and older files.' ;
510515 SReadmeNotOwnedCorrectly = ' The readme file '' %s'' referred to is not part of the package.' ;
511516 SGraphicNotOwnedCorrectly = ' The graphic file '' %s'' referred to is not part of the package.' ;
517+ SLicenseNotOwnedCorrectly = ' The license file '' %s'' referred to is not part of the package.' ;
512518 SFileNotOwnedCorrectly = ' The file '' %s'' referred to is not part of the package.' ;
513519 SDisplayFontNotOwnedCorrectly = ' The display font file '' %s'' referred to is not part of the package.' ;
514520 SOSKFontNotOwnedCorrectly = ' The OSK font file '' %s'' referred to is not part of the package.' ;
@@ -561,6 +567,7 @@ implementation
561567 SJSON_Options_ExecuteProgram = ' executeProgram' ;
562568 SJSON_Options_ReadMeFile = ' readmeFile' ;
563569 SJSON_Options_GraphicFile = ' graphicFile' ;
570+ SJSON_Options_LicenseFile = ' licenseFile' ;
564571
565572 SJSON_Registry = ' registry' ;
566573 SJSON_Registry_Root = ' root' ;
@@ -655,6 +662,9 @@ procedure TPackageOptions.Assign(Source: TPackageOptions);
655662 if Assigned(Source.GraphicFile)
656663 then GraphicFile := Package.Files.FromFileName(Source.GraphicFile.FileName)
657664 else GraphicFile := nil ;
665+ if Assigned(Source.LicenseFile)
666+ then LicenseFile := Package.Files.FromFileName(Source.LicenseFile.FileName)
667+ else LicenseFile := nil ;
658668end ;
659669
660670constructor TPackageOptions.Create(APackage: TPackage);
@@ -668,6 +678,7 @@ destructor TPackageOptions.Destroy;
668678begin
669679 ReadmeFile := nil ;
670680 GraphicFile := nil ;
681+ LicenseFile := nil ;
671682 inherited Destroy;
672683end ;
673684
@@ -681,14 +692,21 @@ procedure TPackageOptions.GraphicRemoved(Sender: TObject; EventType: TPackageNot
681692 FGraphicFile := nil ;
682693end ;
683694
695+ procedure TPackageOptions.LicenseRemoved (Sender: TObject; EventType: TPackageNotifyEventType; var FAllow: Boolean);
696+ begin
697+ FLicenseFile := nil ;
698+ end ;
699+
684700procedure TPackageOptions.LoadXML (ARoot: IXMLNode);
685701begin
686702 FileVersion := XmlVarToStr(ARoot.ChildNodes[' System' ].ChildNodes[' FileVersion' ].NodeValue);
687703 ExecuteProgram := XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' ExecuteProgram' ].NodeValue);
688704 ReadmeFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' ReadMeFile' ].NodeValue));
689705 GraphicFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' GraphicFile' ].NodeValue));
706+ LicenseFile := Package.Files.FromFileName(XmlVarToStr(ARoot.ChildNodes[' Options' ].ChildNodes[' LicenseFile' ].NodeValue));
690707 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
691708 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
709+ if Assigned(LicenseFile) then LicenseFile.AddNotifyObject(LicenseRemoved);
692710end ;
693711
694712procedure TPackageOptions.SaveXML (ARoot: IXMLNode);
@@ -699,6 +717,8 @@ procedure TPackageOptions.SaveXML(ARoot: IXMLNode);
699717 ARoot.ChildNodes[' Options' ].ChildNodes[' ReadMeFile' ].NodeValue := ReadmeFile.RelativeFileName;
700718 if Assigned(GraphicFile) then
701719 ARoot.ChildNodes[' Options' ].ChildNodes[' GraphicFile' ].NodeValue := GraphicFile.RelativeFileName;
720+ if Assigned(LicenseFile) then
721+ ARoot.ChildNodes[' Options' ].ChildNodes[' LicenseFile' ].NodeValue := LicenseFile.RelativeFileName;
702722end ;
703723
704724procedure TPackageOptions.LoadIni (AIni: TIniFile);
@@ -709,6 +729,7 @@ procedure TPackageOptions.LoadIni(AIni: TIniFile);
709729 GraphicFile := Package.Files.FromFileName(AIni.ReadString(' Package' , ' GraphicFile' , ' ' ));
710730 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
711731 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
732+ // LicenseFile not supported in ini
712733end ;
713734
714735procedure TPackageOptions.LoadJSON (ARoot: TJSONObject);
@@ -722,8 +743,10 @@ procedure TPackageOptions.LoadJSON(ARoot: TJSONObject);
722743 ExecuteProgram := GetJsonValueString(FOptions, SJSON_Options_ExecuteProgram);
723744 ReadmeFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_ReadMeFile));
724745 GraphicFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_GraphicFile));
746+ LicenseFile := Package.Files.FromFileName(GetJsonValueString(FOptions, SJSON_Options_LicenseFile));
725747 if Assigned(ReadmeFile) then ReadmeFile.AddNotifyObject(ReadmeRemoved);
726748 if Assigned(GraphicFile) then GraphicFile.AddNotifyObject(GraphicRemoved);
749+ if Assigned(LicenseFile) then LicenseFile.AddNotifyObject(LicenseRemoved);
727750end ;
728751
729752procedure TPackageOptions.SaveIni (AIni: TIniFile);
@@ -734,6 +757,7 @@ procedure TPackageOptions.SaveIni(AIni: TIniFile);
734757 AIni.WriteString(' Package' , ' ReadMeFile' , ReadmeFile.RelativeFileName);
735758 if Assigned(GraphicFile) then
736759 AIni.WriteString(' Package' , ' GraphicFile' , GraphicFile.RelativeFileName);
760+ // licenseFile not supported in ini
737761end ;
738762
739763procedure TPackageOptions.SaveJSON (ARoot: TJSONObject);
@@ -753,6 +777,8 @@ procedure TPackageOptions.SaveJSON(ARoot: TJSONObject);
753777 FOptions.AddPair(SJSON_Options_ReadMeFile, ReadmeFile.RelativeFileName);
754778 if Assigned(GraphicFile) then
755779 FOptions.AddPair(SJSON_Options_GraphicFile, GraphicFile.RelativeFileName);
780+ if Assigned(LicenseFile) then
781+ FOptions.AddPair(SJSON_Options_LicenseFile, LicenseFile.RelativeFileName);
756782end ;
757783
758784procedure TPackageOptions.SetExecuteProgram (Value : WideString);
@@ -780,6 +806,19 @@ procedure TPackageOptions.SetGraphicFile(const Value: TPackageContentFile);
780806 end ;
781807end ;
782808
809+ procedure TPackageOptions.SetLicenseFile (const Value : TPackageContentFile);
810+ begin
811+ if Assigned(FLicenseFile) then FLicenseFile.RemoveNotifyObject(LicenseRemoved);
812+ if not Assigned(Value ) then
813+ FLicenseFile := nil
814+ else
815+ begin
816+ if Value .Package <> Package then raise EPackageInfo.CreateFmt(SLicenseNotOwnedCorrectly, [Value ]);
817+ FLicenseFile := Value ;
818+ FLicenseFile.AddNotifyObject(LicenseRemoved);
819+ end ;
820+ end ;
821+
783822procedure TPackageOptions.SetReadmeFile (const Value : TPackageContentFile);
784823begin
785824 if Assigned(FReadmeFile) then FReadmeFile.RemoveNotifyObject(ReadmeRemoved);
0 commit comments