Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ppdsloader.PPDsLoader Class Reference

List of all members.

Public Member Functions

def __init__
def run
def __del__
def destroy
def get_installed_files
def get_ppds
def get_ppdsmatch_result
def get_error

Private Member Functions

def _dialog_response
def _query_cups
def _cups_connect_reply
def _cups_reply
def _cups_error
def _query_packagekit
def _packagekit_reply
def _packagekit_error
def _query_jockey
def _jockey_reply
def _jockey_error

Private Attributes

 _device_id
 _device_uri
 _device_make_and_model
 _parent
 _host
 _encryption
 _language
 _installed_files
 _conn
 _ppds
 _exc
 _ppdsmatch_result
 _jockey_queried
 _local_cups
 _bus
 _dialog
 _devid_dict
 _gpk_device_id
 _need_requery_cups

Static Private Attributes

dictionary __gsignals__

Detailed Description

1. If PackageKit support is available, and this is a local server,
try to use PackageKit to install relevant drivers.  We do this
because we can only make the right choice about the "best" driver
when the full complement of drivers is there to choose from.

2. Fetch the list of available drivers from CUPS.

3. If Jockey is available, and there is no appropriate driver
available, try to use Jockey to install one.

4. If Jockey was able to install one, fetch the list of available
drivers again.

Definition at line 34 of file ppdsloader.py.


Constructor & Destructor Documentation

def ppdsloader.PPDsLoader.__init__ (   self,
  device_id = None,
  parent = None,
  device_uri = None,
  host = None,
  encryption = None,
  language = None,
  device_make_and_model = None 
)

Definition at line 56 of file ppdsloader.py.

00056 
00057                   device_make_and_model=None):
00058         gobject.GObject.__init__ (self)
00059         debugprint ("+%s" % self)
00060         self._device_id = device_id
00061         self._device_uri = device_uri
00062         self._device_make_and_model = device_make_and_model
00063         self._parent = parent
00064         self._host = host
00065         self._encryption = encryption
00066         self._language = language
00067 
00068         self._installed_files = []
00069         self._conn = None
00070         self._ppds = None
00071         self._exc = None
00072 
00073         self._ppdsmatch_result = None
00074         self._jockey_queried = False
00075         self._local_cups = (self._host == None or
00076                             self._host == "localhost" or
00077                             self._host[0] == '/')
00078         try:
00079             self._bus = dbus.SessionBus ()
00080         except:
00081             debugprint ("Failed to get session bus")
00082             self._bus = None
00083 
00084         fmt = _("Searching")
00085         self._dialog = gtk.MessageDialog (parent=parent,
00086                                           flags=gtk.DIALOG_MODAL |
00087                                           gtk.DIALOG_DESTROY_WITH_PARENT,
00088                                           type=gtk.MESSAGE_INFO,
00089                                           buttons=gtk.BUTTONS_CANCEL,
00090                                           message_format=fmt)
00091 
00092         self._dialog.format_secondary_text (_("Searching for drivers"))
00093 
00094         self._dialog.connect ("response", self._dialog_response)

Definition at line 108 of file ppdsloader.py.

00108 
00109     def __del__ (self):
00110         debugprint ("-%s" % self)


Member Function Documentation

def ppdsloader.PPDsLoader._cups_connect_reply (   self,
  conn,
  UNUSED 
) [private]

Definition at line 151 of file ppdsloader.py.

00151 
00152     def _cups_connect_reply (self, conn, UNUSED):
00153         conn._begin_operation (_("fetching PPDs"))
00154         conn.getPPDs2 (reply_handler=self._cups_reply,
00155                        error_handler=self._cups_error)

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._cups_error (   self,
  conn,
  exc 
) [private]

Definition at line 196 of file ppdsloader.py.

00196 
00197     def _cups_error (self, conn, exc):
00198         conn.destroy ()
00199         self._conn = None
00200         self._ppds = None
00201         if self._dialog != None:
00202             self._dialog.destroy ()
00203             self._dialog = None
00204 
00205         self.emit ('finished')

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._cups_reply (   self,
  conn,
  result 
) [private]

Definition at line 156 of file ppdsloader.py.

00156 
00157     def _cups_reply (self, conn, result):
00158         ppds = cupshelpers.ppds.PPDs (result, language=self._language)
00159         self._ppds = ppds
00160         self._need_requery_cups = False
00161         if self._device_id:
00162             fit = ppds.\
00163                 getPPDNamesFromDeviceID (self._devid_dict["MFG"],
00164                                          self._devid_dict["MDL"],
00165                                          self._devid_dict["DES"],
00166                                          self._devid_dict["CMD"],
00167                                          self._device_uri,
00168                                          self._device_make_and_model)
00169 
00170             ppdnamelist = ppds.\
00171                 orderPPDNamesByPreference (fit.keys (),
00172                                            self._installed_files,
00173                                            devid=self._devid_dict,
00174                                            fit=fit)
00175             self._ppdsmatch_result = (fit, ppdnamelist)
00176 
00177             ppdname = ppdnamelist[0]
00178             if (self._bus and
00179                 not fit[ppdname].startswith ("exact") and
00180                 not self._jockey_queried and
00181                 self._local_cups):
00182                 # Try to install packages using jockey if
00183                 # - there's no appropriate driver (PPD) locally available
00184                 # - we are configuring local CUPS server
00185                 self._jockey_queried = True
00186                 self._query_jockey ()
00187                 return
00188 
00189         conn.destroy ()
00190         self._conn = None
00191         if self._dialog != None:
00192             self._dialog.destroy ()
00193             self._dialog = None
00194 
00195         self.emit ('finished')

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._dialog_response (   self,
  dialog,
  response 
) [private]

Definition at line 135 of file ppdsloader.py.

00135 
00136     def _dialog_response (self, dialog, response):
00137         dialog.destroy ()
00138         self._dialog = None
00139         self.emit ('finished')

def ppdsloader.PPDsLoader._jockey_error (   self,
  exc 
) [private]

Definition at line 265 of file ppdsloader.py.

00265 
00266     def _jockey_error (self, exc):
00267         debugprint ("Got Jockey error: %s" % exc)
00268         if self._need_requery_cups:
00269             self._query_cups ()
00270         else:
00271             if self._conn != None:
00272                 self._conn.destroy ()
00273                 self._conn = None
00274 
00275             if self._dialog != None:
00276                 self._dialog.destroy ()
00277                 self._dialog = None
00278 
00279             self.emit ('finished')
00280 
00281 gobject.type_register(PPDsLoader)

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._jockey_reply (   self,
  conn,
  result 
) [private]

Definition at line 257 of file ppdsloader.py.

00257 
00258     def _jockey_reply (self, conn, result):
00259         debugprint ("Got Jockey result: %s" % repr (result))
00260         try:
00261             self._installed_files = result[1]
00262         except:
00263             self._installed_files = []
00264         self._query_cups ()

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._packagekit_error (   self,
  exc 
) [private]

Definition at line 239 of file ppdsloader.py.

00239 
00240     def _packagekit_error (self, exc):
00241         debugprint ("Got PackageKit error: %s" % exc)
00242         if self._dialog:
00243             self._dialog.show_all ()
00244             self._query_cups ()

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._packagekit_reply (   self) [private]

Definition at line 232 of file ppdsloader.py.

00232 
00233     def _packagekit_reply (self):
00234         debugprint ("Got PackageKit reply")
00235         self._need_requery_cups = True
00236         if self._dialog:
00237             self._dialog.show_all ()
00238             self._query_cups ()

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._query_cups (   self) [private]

Definition at line 140 of file ppdsloader.py.

00140 
00141     def _query_cups (self):
00142         debugprint ("Asking CUPS for PPDs")
00143         if (not self._conn):
00144             c = asyncconn.Connection (host=self._host,
00145                                       encryption=self._encryption,
00146                                       reply_handler=self._cups_connect_reply,
00147                                       error_handler=self._cups_error)
00148             self._conn = c
00149         else:
00150             self._cups_connect_reply(self._conn, None)

Here is the call graph for this function:

Here is the caller graph for this function:

def ppdsloader.PPDsLoader._query_jockey (   self) [private]

Definition at line 245 of file ppdsloader.py.

00245 
00246     def _query_jockey (self):
00247         debugprint ("Asking Jockey to install drivers")
00248         try:
00249             obj = self._bus.get_object ("com.ubuntu.DeviceDriver", "/GUI")
00250             jockey = dbus.Interface (obj, "com.ubuntu.DeviceDriver")
00251             r = jockey.search_driver ("printer_deviceid:%s" % self._device_id,
00252                                       reply_handler=self._jockey_reply,
00253                                       error_handler=self._jockey_error,
00254                                       timeout=3600)
00255         except Exception, e:
00256             self._jockey_error (e)

Here is the call graph for this function:

def ppdsloader.PPDsLoader._query_packagekit (   self) [private]

Definition at line 206 of file ppdsloader.py.

00206 
00207     def _query_packagekit (self):
00208         debugprint ("Asking PackageKit to install drivers")
00209         try:
00210             xid = self._parent.window.xid
00211         except:
00212             xid = 0
00213 
00214         try:
00215             obj = self._bus.get_object ("org.freedesktop.PackageKit",
00216                                         "/org/freedesktop/PackageKit")
00217             proxy = dbus.Interface (obj, "org.freedesktop.PackageKit.Modify")
00218             resources = [self._gpk_device_id]
00219             interaction = "hide-finished"
00220             debugprint ("Calling InstallPrinterDrivers (%s, %s, %s)" %
00221                         (repr (xid), repr (resources), repr (interaction)))
00222             proxy.InstallPrinterDrivers (dbus.UInt32 (xid),
00223                                          resources, interaction,
00224                                          reply_handler=self._packagekit_reply,
00225                                          error_handler=self._packagekit_error,
00226                                          timeout=3600)
00227         except Exception, e:
00228             debugprint ("Failed to talk to PackageKit: %s" % e)
00229             if self._dialog:
00230                 self._dialog.show_all ()
00231                 self._query_cups ()

Here is the call graph for this function:

Definition at line 111 of file ppdsloader.py.

00111 
00112     def destroy (self):
00113         debugprint ("DESTROY: %s" % self)
00114         if self._dialog:
00115             self._dialog.destroy ()
00116             self._dialog = None
00117 
00118         self._parent = None
00119 
00120         if self._conn:
00121             self._conn.destroy ()
00122             self._conn = None

Definition at line 132 of file ppdsloader.py.

00132 
00133     def get_error (self):
00134         return self._exc

Definition at line 123 of file ppdsloader.py.

00123 
00124     def get_installed_files (self):
00125         return self._installed_files

Definition at line 126 of file ppdsloader.py.

00126 
00127     def get_ppds (self):
00128         return self._ppds

Definition at line 129 of file ppdsloader.py.

00129 
00130     def get_ppdsmatch_result (self):
00131         return self._ppdsmatch_result

def ppdsloader.PPDsLoader.run (   self)

Definition at line 95 of file ppdsloader.py.

00095 
00096     def run (self):
00097         self._dialog.show_all ()
00098 
00099         if self._device_id:
00100             self._devid_dict = cupshelpers.parseDeviceID (self._device_id)
00101 
00102         if self._local_cups and self._device_id and self._bus:
00103             self._gpk_device_id = "MFG:%s;MDL:%s;" % (self._devid_dict["MFG"],
00104                                                       self._devid_dict["MDL"])
00105             self._query_packagekit ()
00106         else:
00107             self._query_cups ()


Member Data Documentation

dictionary ppdsloader.PPDsLoader.__gsignals__ [static, private]
Initial value:
{
        'finished': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
        }

Definition at line 50 of file ppdsloader.py.

Definition at line 78 of file ppdsloader.py.

Definition at line 68 of file ppdsloader.py.

Definition at line 59 of file ppdsloader.py.

Definition at line 61 of file ppdsloader.py.

Definition at line 60 of file ppdsloader.py.

Definition at line 99 of file ppdsloader.py.

Definition at line 84 of file ppdsloader.py.

Definition at line 64 of file ppdsloader.py.

Definition at line 70 of file ppdsloader.py.

Definition at line 102 of file ppdsloader.py.

Definition at line 63 of file ppdsloader.py.

Definition at line 67 of file ppdsloader.py.

Definition at line 73 of file ppdsloader.py.

Definition at line 65 of file ppdsloader.py.

Definition at line 74 of file ppdsloader.py.

Definition at line 159 of file ppdsloader.py.

Definition at line 62 of file ppdsloader.py.

Definition at line 69 of file ppdsloader.py.

Definition at line 72 of file ppdsloader.py.


The documentation for this class was generated from the following file: