Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
asyncipp.IPPConnection Class Reference
Inheritance diagram for asyncipp.IPPConnection:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def __del__
def destroy
def set_auth_info
def reconnect

Public Attributes

 queue
 thread
 bindings

Private Member Functions

def _reap_thread
def _make_binding
def _call_function

Private Attributes

 _parent

Detailed Description

This class starts a new thread to handle IPP operations.

Each IPP operation method takes optional reply_handler,
error_handler and auth_handler parameters.

If an operation requires a password to proceed, the auth_handler
function will be called.  The operation will continue once
set_auth_info (in this class) is called.

Once the operation has finished either reply_handler or
error_handler will be called.

Definition at line 210 of file asyncipp.py.


Constructor & Destructor Documentation

def asyncipp.IPPConnection.__init__ (   self,
  reply_handler = None,
  error_handler = None,
  auth_handler = None,
  user = None,
  host = None,
  port = None,
  encryption = None,
  parent = None 
)

Definition at line 227 of file asyncipp.py.

00227 
00228                   encryption=None, parent=None):
00229         debugprint ("New IPPConnection")
00230         self._parent = parent
00231         self.queue = Queue.Queue ()
00232         self.thread = _IPPConnectionThread (self.queue, self,
00233                                             reply_handler=reply_handler,
00234                                             error_handler=error_handler,
00235                                             auth_handler=auth_handler,
00236                                             user=user, host=host, port=port,
00237                                             encryption=encryption)
00238         self.thread.start ()
00239 
00240         methodtype = type (cups.Connection.getPrinters)
00241         bindings = []
00242         for fname in dir (cups.Connection):
00243             if fname[0] == ' ':
00244                 continue
00245             fn = getattr (cups.Connection, fname)
00246             if type (fn) != methodtype:
00247                 continue
00248             setattr (self, fname, self._make_binding (fn))
00249             bindings.append (fname)
00250 
00251         self.bindings = bindings
00252         debugprint ("+%s" % self)

Definition at line 253 of file asyncipp.py.

00253 
00254     def __del__ (self):
00255         debug.debugprint ("-%s" % self)


Member Function Documentation

def asyncipp.IPPConnection._call_function (   self,
  fn,
  args,
  kwds 
) [private]

Reimplemented in asyncipp.IPPAuthConnection.

Definition at line 286 of file asyncipp.py.

00286 
00287     def _call_function (self, fn, *args, **kwds):
00288         reply_handler = error_handler = auth_handler = False
00289         if kwds.has_key ("reply_handler"):
00290             reply_handler = kwds["reply_handler"]
00291             del kwds["reply_handler"]
00292         if kwds.has_key ("error_handler"):
00293             error_handler = kwds["error_handler"]
00294             del kwds["error_handler"]
00295         if kwds.has_key ("auth_handler"):
00296             auth_handler = kwds["auth_handler"]
00297             del kwds["auth_handler"]
00298 
00299         self.queue.put ((fn, args, kwds,
00300                          reply_handler, error_handler, auth_handler))

Here is the caller graph for this function:

def asyncipp.IPPConnection._make_binding (   self,
  fn 
) [private]

Definition at line 283 of file asyncipp.py.

00283 
00284     def _make_binding (self, fn):
00285         return lambda *args, **kwds: self._call_function (fn, *args, **kwds)

Here is the call graph for this function:

def asyncipp.IPPConnection._reap_thread (   self) [private]

Definition at line 264 of file asyncipp.py.

00264 
00265     def _reap_thread (self):
00266         if self.thread.idle:
00267             debugprint ("Putting None on the task queue")
00268             self.queue.put (None)
00269             self.queue.join ()
00270             return False
00271 
00272         debugprint ("Thread %s still processing tasks" % self.thread)
00273         return True

Here is the caller graph for this function:

Reimplemented in asyncipp.IPPAuthConnection.

Definition at line 256 of file asyncipp.py.

00256 
00257     def destroy (self):
00258         debugprint ("DESTROY: %s" % self)
00259         for binding in self.bindings:
00260             delattr (self, binding)
00261 
00262         if self.thread.isAlive ():
00263             gobject.timeout_add_seconds (1, self._reap_thread)

Here is the call graph for this function:

Here is the caller graph for this function:

def asyncipp.IPPConnection.reconnect (   self,
  user,
  reply_handler = None,
  error_handler = None 
)

Definition at line 278 of file asyncipp.py.

00278 
00279     def reconnect (self, user, reply_handler=None, error_handler=None):
00280         debugprint ("Reconnect...")
00281         self.queue.put ((True, (user,), {},
00282                          reply_handler, error_handler, False))

Here is the caller graph for this function:

def asyncipp.IPPConnection.set_auth_info (   self,
  password 
)
Call this from your auth_handler function.

Definition at line 274 of file asyncipp.py.

00274 
00275     def set_auth_info (self, password):
00276         """Call this from your auth_handler function."""
00277         self.thread.set_auth_info (password)


Member Data Documentation

Definition at line 229 of file asyncipp.py.

Definition at line 250 of file asyncipp.py.

Definition at line 230 of file asyncipp.py.

Definition at line 231 of file asyncipp.py.


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