~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/fppkg/src/laz_pkgrepos.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
unit laz_pkgrepos;
 
2
 
 
3
{$mode objfpc}{$H+}
 
4
 
 
5
interface
 
6
 
 
7
uses
 
8
  SysUtils, Classes, ComCtrls,
 
9
  fprepos;
 
10
 
 
11
type
 
12
 
 
13
  { TLazFPPackage }
 
14
 
 
15
  TLazFPPackage = Class(TFPPackage)
 
16
  private
 
17
    FLazarusPackageFiles: TStrings;
 
18
    function GetLazarusPackageFiles: TStrings;
 
19
  protected
 
20
    procedure LoadUnitConfigFromStringlist(Const AStringList: TStrings); override;
 
21
  public
 
22
    function HasLazarusPackageFiles: boolean;
 
23
    property LazarusPackageFiles: TStrings read GetLazarusPackageFiles;
 
24
    destructor Destroy; override;
 
25
  end;
 
26
 
 
27
  { TLazFPRepository }
 
28
 
 
29
  TLazFPRepository = Class(TFPRepository)
 
30
  protected
 
31
    procedure CreatePackages; override;
 
32
  end;
 
33
 
 
34
type
 
35
  TLazPackageData = record
 
36
    Name: string;
 
37
    InstalledVersion: string;
 
38
    AvialableVersion: string;
 
39
    Description: string;
 
40
    Keywords: string;
 
41
    Category: string;
 
42
    State: string;
 
43
    Support: string;
 
44
    Author: string;
 
45
    License: string;
 
46
    HomepageURL: string;
 
47
    DownloadURL: string;
 
48
    FileName: string;
 
49
    Email: string;
 
50
    OS: string;
 
51
    CPU: string;
 
52
  end;
 
53
 
 
54
  TPackageSortType = (stNone);
 
55
 
 
56
  { TLazPackages }
 
57
 
 
58
  TLazPackages = class(TObject)
 
59
    FPkgData: array of TLazPackageData;
 
60
  private
 
61
    FCount: integer;
 
62
    FSort: TPackageSortType;
 
63
    FSortType: TPackageSortType;
 
64
    function GetPkgData(index: integer): TLazPackageData;
 
65
    procedure SetSort(const AValue: TPackageSortType);
 
66
    procedure SetSortType(const AValue: TPackageSortType);
 
67
 
 
68
  public
 
69
    constructor Create;
 
70
    destructor Destroy; override;
 
71
 
 
72
    property PkgData[index: integer]: TLazPackageData read GetPkgData;
 
73
    property Count: integer read FCount;
 
74
    procedure Add(Pkg: TLazPackageData);
 
75
    procedure Clear;
 
76
 
 
77
    property SortType: TPackageSortType read FSortType write SetSortType;
 
78
    procedure Sort;
 
79
    function FindPackage(const AName: string): TLazPackageData;
 
80
  end;
 
81
 
 
82
procedure Laz_ListPackages;
 
83
 
 
84
var
 
85
  Laz_Packages: TLazPackages;
 
86
 
 
87
implementation
 
88
 
 
89
uses
 
90
  pkgglobals,
 
91
  pkgrepos;
 
92
 
 
93
function Laz_PackageInstalledVersionStr(const AName:String;const ShowUsed: boolean = false;const Local: boolean = false):string;
 
94
var
 
95
  P: TFPPackage;
 
96
begin
 
97
  P := InstalledRepository.FindPackage(AName);
 
98
  if P <> nil then
 
99
    Result := P.Version.AsString
 
100
  else
 
101
    Result := '-';
 
102
end;
 
103
 
 
104
function GetPackage(const AName: string): TFPPackage;
 
105
begin
 
106
  Result := AvailableRepository.FindPackage(AName);
 
107
 
 
108
  if not Assigned(Result) then
 
109
    Result := InstalledRepository.FindPackage(AName);
 
110
end;
 
111
 
 
112
procedure Laz_ListPackages;
 
113
var
 
114
  i: integer;
 
115
  SL: TStringList;
 
116
  PackageName: string;
 
117
  pkg: TLazPackageData;
 
118
  P: TFPPackage;
 
119
begin
 
120
  SL := TStringList.Create;
 
121
  SL.Sorted := True;
 
122
  SL.Duplicates := dupIgnore;
 
123
 
 
124
  for i := 0 to AvailableRepository.PackageCount - 1 do
 
125
    SL.Add(AvailableRepository.Packages[i].Name);
 
126
 
 
127
  for i := 0 to InstalledRepository.PackageCount - 1 do
 
128
    SL.Add(InstalledRepository.Packages[i].Name);
 
129
 
 
130
  Laz_Packages.Clear;
 
131
 
 
132
  for i := 0 to SL.Count - 1 do
 
133
  begin
 
134
    PackageName := SL[i];
 
135
    if (PackageName <> CmdLinePackageName) and (PackageName <>
 
136
      CurrentDirPackageName) then
 
137
    begin
 
138
      pkg.Name := PackageName;
 
139
 
 
140
      pkg.State := PackageInstalledStateStr(PackageName);
 
141
      pkg.InstalledVersion := PackageInstalledVersionStr(PackageName);
 
142
      pkg.AvialableVersion := PackageAvailableVersionStr(PackageName);
 
143
 
 
144
      P := GetPackage(PackageName);
 
145
      if Assigned(P) then
 
146
      begin
 
147
        pkg.Description := P.Description;
 
148
        pkg.Author := P.Author;
 
149
        pkg.HomepageURL := P.HomepageURL;
 
150
        pkg.DownloadURL := P.DownloadURL;
 
151
        pkg.FileName := P.FileName;
 
152
        pkg.Email := P.Email;
 
153
        pkg.OS := OSesToString(P.OSes);
 
154
        pkg.CPU := CPUSToString(P.CPUs);
 
155
      end;
 
156
 
 
157
      Laz_Packages.Add(pkg);
 
158
    end;
 
159
  end;
 
160
 
 
161
  FreeAndNil(SL);
 
162
end;
 
163
 
 
164
{ TLazFPPackage }
 
165
 
 
166
function TLazFPPackage.GetLazarusPackageFiles: TStrings;
 
167
begin
 
168
  if not assigned(FLazarusPackageFiles) then
 
169
    FLazarusPackageFiles := TStringList.Create;
 
170
  Result := FLazarusPackageFiles;
 
171
end;
 
172
 
 
173
procedure TLazFPPackage.LoadUnitConfigFromStringlist(const AStringList: TStrings);
 
174
var
 
175
  S: String;
 
176
begin
 
177
  inherited LoadUnitConfigFromStringlist(AStringList);
 
178
  S:=AStringList.Values['LazarusPackageFiles'];
 
179
  if s <> '' then
 
180
    LazarusPackageFiles.CommaText:=s;
 
181
end;
 
182
 
 
183
function TLazFPPackage.HasLazarusPackageFiles: boolean;
 
184
begin
 
185
  result := assigned(FLazarusPackageFiles) and (FLazarusPackageFiles.Count>0);
 
186
end;
 
187
 
 
188
destructor TLazFPPackage.Destroy;
 
189
begin
 
190
  FLazarusPackageFiles.Free;
 
191
  inherited Destroy;
 
192
end;
 
193
 
 
194
{ TLazFPRepository }
 
195
 
 
196
procedure TLazFPRepository.CreatePackages;
 
197
begin
 
198
  FPackages:=TFPPackages.Create(TLazFPPackage);
 
199
  FPackages.StreamVersion:=StreamVersion;
 
200
end;
 
201
 
 
202
{ TLazPackages }
 
203
 
 
204
function TLazPackages.GetPkgData(index: integer): TLazPackageData;
 
205
begin
 
206
  Result := FPkgData[index];
 
207
end;
 
208
 
 
209
procedure TLazPackages.SetSort(const AValue: TPackageSortType);
 
210
begin
 
211
  if FSort = AValue then
 
212
    exit;
 
213
  FSort := AValue;
 
214
end;
 
215
 
 
216
procedure TLazPackages.SetSortType(const AValue: TPackageSortType);
 
217
begin
 
218
  if FSortType = AValue then
 
219
    exit;
 
220
  FSortType := AValue;
 
221
end;
 
222
 
 
223
constructor TLazPackages.Create;
 
224
begin
 
225
  Clear;
 
226
 
 
227
  SortType := stNone;
 
228
end;
 
229
 
 
230
destructor TLazPackages.Destroy;
 
231
begin
 
232
  Clear;
 
233
  inherited Destroy;
 
234
end;
 
235
 
 
236
procedure TLazPackages.Add(Pkg: TLazPackageData);
 
237
begin
 
238
  Inc(FCount);
 
239
 
 
240
  SetLength(FPkgData, FCount);
 
241
  FPkgData[FCount - 1] := Pkg;
 
242
end;
 
243
 
 
244
procedure TLazPackages.Clear;
 
245
begin
 
246
  FCount := 0;
 
247
  SetLength(FPkgData, FCount);
 
248
end;
 
249
 
 
250
procedure TLazPackages.Sort;
 
251
begin
 
252
  case SortType of
 
253
    //no sorting
 
254
    stNone:
 
255
  end;
 
256
end;
 
257
 
 
258
function TLazPackages.FindPackage(const AName: string): TLazPackageData;
 
259
var
 
260
  i: integer;
 
261
begin
 
262
  for i := 0 to Count - 1 do
 
263
    if FPkgData[i].Name = AName then
 
264
    begin
 
265
      Result := FPkgData[i];
 
266
      exit;
 
267
    end;
 
268
end;
 
269
 
 
270
initialization
 
271
  Laz_Packages := TLazPackages.Create;
 
272
 
 
273
finalization
 
274
  FreeAndNil(Laz_Packages);
 
275
 
 
276
end.
 
277