|
| 1 | +import { ClientInterface, systemBus } from 'dbus-next'; |
| 2 | + |
| 3 | +const bus = systemBus(); |
| 4 | + |
| 5 | +interface PackageKit extends ClientInterface { |
| 6 | + CreateTransaction(): Promise<string>; |
| 7 | +} |
| 8 | + |
| 9 | +async function testing() { |
| 10 | + const packageKitObj = await bus.getProxyObject( |
| 11 | + 'org.freedesktop.PackageKit', |
| 12 | + '/org/freedesktop/PackageKit' |
| 13 | + ); |
| 14 | + |
| 15 | + const packageKitInterface: ClientInterface = |
| 16 | + await packageKitObj.getInterface('org.freedesktop.PackageKit'); |
| 17 | + |
| 18 | + const packageKit = packageKitInterface as PackageKit; |
| 19 | + |
| 20 | + const transactionPath = await packageKit.CreateTransaction(); |
| 21 | + |
| 22 | + console.log('Transaction created', transactionPath); |
| 23 | + |
| 24 | + const transactionObj = await bus.getProxyObject( |
| 25 | + 'org.freedesktop.PackageKit', |
| 26 | + transactionPath |
| 27 | + ); |
| 28 | + |
| 29 | + const transactionInterface = await transactionObj.getInterface( |
| 30 | + 'org.freedesktop.PackageKit.Transaction' |
| 31 | + ); |
| 32 | + |
| 33 | + transactionInterface.on( |
| 34 | + 'Package', |
| 35 | + (info: number, packageId: string, summary: string) => { |
| 36 | + const [packageName, version, arch, repo] = packageId.split(';'); |
| 37 | + console.log('Package response', packageId); |
| 38 | + // transactionInterface.GetDetails([packageId]); |
| 39 | + } |
| 40 | + ); |
| 41 | + |
| 42 | + transactionInterface.on('Details', function () { |
| 43 | + console.log('Details response', arguments); |
| 44 | + }); |
| 45 | + |
| 46 | + // krita;1:5.0.2+dfsg-1build1;amd64;ubuntu-jammy-universe |
| 47 | + // await transactionInterface.GetPackages(0); |
| 48 | + // await transactionInterface.SearchNames(0, ['krita']); |
| 49 | + await transactionInterface.GetDetails([ |
| 50 | + 'krita;1:5.0.2+dfsg-1build1;amd64;ubuntu-jammy-universe', |
| 51 | + ]); |
| 52 | +} |
| 53 | + |
| 54 | +testing(); |
0 commit comments