Ich hab mal versucht, nur die Anforderungen des Beispiels hier
http://www.packagekit.org/pk-faq.html#session-methods" onclick="window.open(this.href);return false; auf Pascal zu übersetzen.
Ich habe nicht die geringste Ahnung, ob das geht. Hab's nicht getestet und verstehe auch nichts von PackageKit.
Aber eine geringe Chance besteht. Falls es nicht geht, kannste selber noch feilen.
Kompilieren und Linken sollte es schon mal.
Code: Alles auswählen
unit dbusglib;
{$MODE objfpc}{$H+}
interface
uses
Classes, SysUtils, glib2, dbus;
type
PDBusGConnection = Pointer;
PDBusGMessage = Pointer;
PDBusGMethodInvocation = Pointer;
PDBusGObjectInfo = Pointer;
PDBusGProxy = Pointer;
PDBusGProxyCall = Pointer;
const External_library = 'dbus-glib-1';
const G_TYPE_STRV: GType = 0;
function dbus_g_proxy_new_for_name(connection: pDBusGConnection; name: pchar; path: pchar; dinterface: pchar): PDBusGProxy; cdecl; external External_library name 'dbus_g_proxy_new_for_name';
function dbus_g_bus_get(_type: DBusBusType; error: PpGError): PDBusGConnection; cdecl; external External_library name 'dbus_g_bus_get';
function dbus_g_proxy_call(proxy: pDBusGProxy; method: pchar; error: PpGError; first_arg_type: GType; args: array of const): gboolean; cdecl; external External_library name 'dbus_g_proxy_call';
function g_strv_get_type: gulong; cdecl; external gobjectlib name 'g_strv_get_type';
procedure InstallPackage;
implementation
procedure InstallPackage;
var connection: PDBusGConnection;
proxy: PDBusGProxy;
error: PGError = nil;
ret: gboolean;
arg: PPchar;
ast: string;
begin
connection := dbus_g_bus_get(DBUS_BUS_SESSION, nil);
proxy := dbus_g_proxy_new_for_name(connection,
'org.freedesktop.PackageKit',
'/org/freedesktop/PackageKit',
'org.freedesktop.PackageKit.Modify');
ast := 'openoffice-clipart '; //Achtung, Space am Schluss evtl wichtig.
arg := StringToPPchar(ast, 0);
ret := dbus_g_proxy_call(proxy, 'InstallPackageNames', @error,
G_TYPE_STRV, [arg,
G_TYPE_STRING, '',
G_TYPE_INVALID, G_TYPE_INVALID]);
if not ret then
begin
g_warning('failed: %s', [error^.message]);
g_error_free(error);
end;
end;
initialization
g_type_init;
G_TYPE_STRV := g_strv_get_type;
end.