1
{ Copyright (C) 2008-2009 Matthias Klumpp
6
This library is free software: you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free Software
10
This library is distributed in the hope that it will be useful, but WITHOUT
11
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License v3
15
along with this library. If not, see <http://www.gnu.org/licenses/>.}
16
//** Listaller library for all IPK installation related processes
22
cthreads, Classes, ipkHandle, SysUtils, Controls, liCommon, liTypes,
26
//////////////////////////////////////////////////////////////////////////////////////
27
//Exported helper functions
29
function li_new_stringlist: Pointer;cdecl;
31
Result:=TStringList.Create;
34
function li_free_stringlist(lst: PStringList): Boolean;cdecl;
44
function li_stringlist_read_line(lst: PStringList;ln: Integer): PChar;cdecl;
46
if (ln < lst^.Count)and(ln > -1) then
48
Result:=PChar(lst^[ln]);
49
end else Result:='List index out of bounds.';
52
function li_stringlist_write_line(lst: PStringList;ln: Integer;val: PChar): Boolean;cdecl;
54
if (ln < lst^.Count)and(ln > -1) then
58
end else Result:=false;
61
/////////////////////////////////////////////////////////////////////////////////////
64
//** Removes an application that was installed with an IPK package
65
function li_remove_ipk_installed_app(appname, appid: PChar;msgcall: TMessageCall;poschange: TProgressCall;fastmode: Boolean): Boolean;cdecl;
69
UninstallIPKApp(appname, appid,msgcall,poschange, fastmode, true)
75
//** Creates a new installation object
76
function li_setup_new: Pointer;cdecl;
78
Result:=TInstallation.Create;
81
//** Removes an TInstallation object
82
procedure li_setup_free(setup: PInstallation);cdecl;
87
//** Initializes the setup
88
function li_setup_init(setup: PInstallation;pkname: PChar): PChar;cdecl;
91
if not setup^.UserRequestRegistered then
93
p_warning('No user request callback is registered!');
97
setup^.Initialize(pkname);
99
Result:=PChar('Failed to initialize setup package '+ExtractFileName(pkname)+' !');
103
//** Register progress changes (main)
104
function li_setup_register_main_progress_call(setup: PInstallation;call: TProgressCall;user_data: Pointer): Boolean;cdecl;
108
setup^.RegOnProgressMainChange(call,user_data);
114
//** Register progress changes (extra)
115
function li_setup_register_extra_progress_call(setup: PInstallation;call: TProgressCall;user_data: Pointer): Boolean;cdecl;
119
setup^.RegOnProgressExtraChange(call,user_data);
126
function li_setup_register_message_call(setup: PInstallation;call: TMessageCall;user_data: Pointer): Boolean;cdecl;
130
setup^.RegOnMessage(call,user_data);
136
//** Step message call
137
function li_setup_register_step_message_call(setup: PInstallation;call: TMessageCall;user_data: Pointer): Boolean;cdecl;
141
setup^.RegOnStepMessage(call,user_data);
147
//** User request message call
148
function li_setup_register_user_request_call(setup: PInstallation;call: TRequestCall;user_data: Pointer): Boolean;cdecl;
152
setup^.RegOnUsrRequest(call,user_data);
158
//** Installation type
159
function li_setup_pkgtype(setup: PInstallation): TPkgType;cdecl;
161
Result:=setup^.pType;
164
//** Set installation testmode
165
procedure li_testmode(st: Boolean);cdecl;
170
//** Set actions which should be forced
171
procedure li_setup_set_forced(setup: PInstallation;str: PChar);cdecl;
173
setup^.ForceActions:=str;
176
//** Set TInstallation to superuser mode
177
procedure li_setup_set_su_mode(setup: PInstallation;b: Boolean);cdecl;
179
setup^.SuperuserMode:=b;
182
//** Read disallows property
183
function li_setup_disallows(setup: PInstallation): PChar;cdecl;
185
Result:=PChar(setup^.Disallows);
188
//** Read supported Linux distributions
189
function li_setup_supported_distributions(setup: PInstallation): PChar;cdecl;
191
Result:=PChar(setup^.Distris);
194
//** Check if application is installed
195
function li_is_ipk_app_installed(appname: PChar;appid: PChar): Boolean;cdecl;
197
Result:=IsPackageInstalled(appname,appid);
200
//** Readout application name
201
function li_setup_appname(setup: PInstallation): PChar;cdecl;
203
Result:=PChar(setup^.AppName);
207
function li_setup_appversion(setup: PInstallation): PChar;cdecl;
209
Result:=PChar(setup^.AppVersion);
213
function li_setup_pkgid(setup: PInstallation): PChar;cdecl;
215
Result:=PChar(setup^.ID);
219
function li_setup_long_description(setup: PInstallation; list: PStringList): Boolean;cdecl;
223
setup^.ReadDescription(list^);
229
//** Get wizard image patch
230
function li_setup_wizard_image_path(setup: PInstallation): PChar;cdecl;
232
Result:=PChar(setup^.WizImage);
236
function li_setup_license(setup: PInstallation; list: PStringList): Boolean;cdecl;
240
setup^.ReadLicense(list^);
246
//** Get profiles list
247
function li_setup_profiles_list(setup: PInstallation; list: PStringList): Boolean;cdecl;
251
setup^.ReadProfiles(list^);
257
//** Set current profile id
258
procedure li_setup_set_profileid(setup: PInstallation;id: ShortInt);cdecl;
260
setup^.SetCurProfile(id);
263
//** Set if update source should be registered
264
procedure li_setup_enable_usource_registering(setup: PInstallation;b: Boolean);cdecl;
266
setup^.RegisterUpdateSource:=b;
270
function li_setup_appicon(setup: PInstallation): PChar;cdecl;
272
Result:=PChar(setup^.AppIcon);
275
//** Read desktopfiles
276
function li_setup_desktopfiles(setup: PInstallation): PChar;cdecl;
278
Result:=PChar(setup^.DesktopFiles);
282
function li_setup_app_exec_command(setup: PInstallation): PChar;cdecl;
284
Result:=PChar(setup^.CMDLn);
287
//** Read path to file list
288
function li_setup_profile_current_filelist(setup: PInstallation): PChar;cdecl;
290
Result:=PChar(setup^.IFileInfo);
293
//** Starts the installation
294
function li_setup_start(setup: PInstallation): Boolean;cdecl;
296
Result:=setup^.DoInstallation;
299
//** Get dependencies
300
function li_setup_dependencies(setup: PInstallation; list: PStringList): Boolean;cdecl;
304
list^.Assign(setup^.ADeps);
310
////////////////////////////////////////////////////////////////////
313
//** Creates a new TAppManager object
314
function li_mgr_new: Pointer;cdecl;
316
Result:=TAppManager.Create;
319
//** Removes an TAppManager object
320
procedure li_mgr_free(mgr: PAppManager);cdecl;
325
//** Start loading list of applications
326
function li_mgr_load_apps(mgr: PAppManager): Boolean;cdecl;
330
if not mgr^.UserRequestRegistered then begin p_error('No user request callback was registered');exit;end;
338
//** Register message call
339
function li_mgr_register_msg_call(mgr: PAppManager;call: TMessageCall;user_data: Pointer): Boolean;cdecl;
343
mgr^.RegOnMessage(call,user_data);
349
//** Register application event to catch found apps
350
function li_mgr_register_app_call(mgr: PAppManager;call: TAppEvent): Boolean;cdecl;
354
mgr^.OnApplication:=call;
360
//** Register event to recieve current progress
361
function li_mgr_register_progress_call(mgr: PAppManager;call: TProgressCall;user_data: Pointer): Boolean;cdecl;
365
mgr^.RegOnProgress(call,user_data);
371
//** Register event to recieve user requests
372
function li_mgr_register_request_call(mgr: PAppManager;call: TRequestCall;user_data: Pointer): Boolean;cdecl;
376
mgr^.RegOnRequest(call,user_data);
382
//** Sets if aplications should work in root mode
383
procedure li_mgr_set_su_mode(mgr: PAppManager;md: Boolean);cdecl;
385
mgr^.SuperuserMode:=md;
388
//** Removes the application
389
function li_mgr_remove_app(mgr: PAppManager;obj: TAppInfo): Boolean;cdecl;
392
if not mgr^.UserRequestRegistered then begin p_error('You need to register a user request callback!');exit;end;
395
mgr^.UninstallApp(obj);
401
//** Check application dependencies
402
function li_mgr_check_apps(mgr: PAppManager;log: PStringList;root: Boolean): Boolean;cdecl;
403
procedure PerformCheck;
405
if not mgr^.CheckApps(log^,false,root) then
408
end else Result:=true;
413
else p_error('Check log != nil failed.');
416
//** Fix application dependencies
417
function li_mgr_fix_apps(mgr: PAppManager;log: PStringList;root: Boolean): Boolean;cdecl;
418
procedure PerformCheck;
420
if not mgr^.CheckApps(log^,true,root) then
423
end else Result:=true;
428
else p_error('Check log != nil failed.');
431
///////////////////////
433
//Stringlist functions
436
li_stringlist_read_line,
437
li_stringlist_write_line,
439
//TInstallation related functions
443
li_setup_set_su_mode,
444
li_setup_register_main_progress_call,
445
li_setup_register_extra_progress_call,
448
li_setup_supported_distributions,
452
li_setup_long_description,
453
li_setup_enable_usource_registering,
454
li_setup_wizard_image_path,
456
li_setup_profiles_list,
458
li_setup_desktopfiles,
459
li_setup_app_exec_command,
460
li_setup_profile_current_filelist,
461
li_setup_register_message_call,
462
li_setup_register_step_message_call,
463
li_setup_register_user_request_call,
465
li_setup_dependencies,
467
li_setup_set_profileid,
469
//Management functions
473
li_mgr_register_msg_call,
474
li_mgr_register_app_call,
475
li_mgr_register_progress_call,
476
li_mgr_register_request_call,
483
li_remove_ipk_installed_app,
485
li_is_ipk_app_installed;
487
{$IFDEF WINDOWS}{$R libinstaller.rc}{$ENDIF}