| 1 |
#!/usr/bin/python3 |
| 2 |
|
| 3 |
## system-config-printer |
| 4 |
|
| 5 |
## Copyright (C) 2010 Red Hat, Inc. |
| 6 |
## Author: Tim Waugh <[email protected]> |
| 7 |
|
| 8 |
## This program is free software; you can redistribute it and/or modify |
| 9 |
## it under the terms of the GNU General Public License as published by |
| 10 |
## the Free Software Foundation; either version 2 of the License, or |
| 11 |
## (at your option) any later version. |
| 12 |
|
| 13 |
## This program is distributed in the hope that it will be useful, |
| 14 |
## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
## GNU General Public License for more details. |
| 17 |
|
| 18 |
## You should have received a copy of the GNU General Public License |
| 19 |
## along with this program; if not, write to the Free Software |
| 20 |
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 |
|
| 22 |
import dbus |
| 23 |
import dbus.glib |
| 24 |
import dbus.service |
| 25 |
from . import _debugprint, set_debugprint_fn |
| 26 |
|
| 27 |
class PrinterDriversInstaller(dbus.service.Object): |
| 28 |
DBUS_PATH = "/com/redhat/PrinterDriversInstaller" |
| 29 |
DBUS_IFACE = "com.redhat.PrinterDriversInstaller" |
| 30 |
DBUS_OBJ = "com.redhat.PrinterDriversInstaller" |
| 31 |
|
| 32 |
def __init__ (self, bus): |
| 33 |
self.bus = bus |
| 34 |
bus_name = dbus.service.BusName (self.DBUS_OBJ, bus=bus) |
| 35 |
dbus.service.Object.__init__ (self, bus_name, self.DBUS_PATH) |
| 36 |
|
| 37 |
@dbus.service.method(DBUS_IFACE, |
| 38 |
in_signature="sss", |
| 39 |
async_callbacks=("reply_handler", |
| 40 |
"error_handler")) |
| 41 |
def InstallDrivers (self, mfg, mdl, cmd, |
| 42 |
reply_handler, error_handler): |
| 43 |
bus = dbus.SessionBus () |
| 44 |
obj = bus.get_object ("org.freedesktop.PackageKit", |
| 45 |
"/org/freedesktop/PackageKit") |
| 46 |
proxy = dbus.Interface (obj, "org.freedesktop.PackageKit.Modify") |
| 47 |
xid = 0 |
| 48 |
resources = ["MFG:%s;MDL:%s;" % (mfg, mdl)] |
| 49 |
interaction = "hide-finished" |
| 50 |
_debugprint ("Calling InstallPrinterDrivers (%s, %s, %s)" % |
| 51 |
(repr (xid), repr (resources), repr (interaction))) |
| 52 |
proxy.InstallPrinterDrivers (dbus.UInt32 (xid), |
| 53 |
resources, interaction, |
| 54 |
reply_handler=reply_handler, |
| 55 |
error_handler=error_handler, |
| 56 |
timeout=3600) |
| 57 |
|
| 58 |
def client_test(): |
| 59 |
bus = dbus.SystemBus () |
| 60 |
import sys |
| 61 |
obj = bus.get_object (PrinterDriversInstaller.DBUS_OBJ, |
| 62 |
PrinterDriversInstaller.DBUS_PATH) |
| 63 |
proxy = dbus.Interface (obj, PrinterDriversInstaller.DBUS_IFACE) |
| 64 |
print (proxy.InstallDrivers ("MFG", "MDL", "CMD")) |