|
|
@ -1,78 +1,78 @@
|
|
|
|
import pcop
|
|
|
|
import pcop
|
|
|
|
|
|
|
|
|
|
|
|
def registeredApplications():
|
|
|
|
def registeredApplications():
|
|
|
|
"""Return a list of current DCOP registered applications."""
|
|
|
|
"""Return a list of current DCOP registered applications."""
|
|
|
|
return pcop.app_list()
|
|
|
|
return pcop.app_list()
|
|
|
|
|
|
|
|
|
|
|
|
def apps():
|
|
|
|
def apps():
|
|
|
|
"""Return a list of current DCOP registered applications."""
|
|
|
|
"""Return a list of current DCOP registered applications."""
|
|
|
|
return pcop.app_list()
|
|
|
|
return pcop.app_list()
|
|
|
|
|
|
|
|
|
|
|
|
def anyAppCalled(appName):
|
|
|
|
def anyAppCalled(appName):
|
|
|
|
"""Return any application instance called appName, or None if none currently registered."""
|
|
|
|
"""Return any application instance called appName, or None if none currently registered."""
|
|
|
|
for app in apps():
|
|
|
|
for app in apps():
|
|
|
|
if appName==app or appName+'-'==app[:len(appName)+1]:
|
|
|
|
if appName==app or appName+'-'==app[:len(appName)+1]:
|
|
|
|
return DCOPApplication(app)
|
|
|
|
return DCOPApplication(app)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def registerAs(appid, addpid=1):
|
|
|
|
def registerAs(appid, addpid=1):
|
|
|
|
"""Register the application with DCOP and return the ID. This is needed in order to receive DCOP requests."""
|
|
|
|
"""Register the application with DCOP and return the ID. This is needed in order to receive DCOP requests."""
|
|
|
|
return pcop.register_as(appid,addpid)
|
|
|
|
return pcop.register_as(appid,addpid)
|
|
|
|
|
|
|
|
|
|
|
|
def processEvents():
|
|
|
|
def processEvents():
|
|
|
|
"""Process any waiting QT events, then return."""
|
|
|
|
"""Process any waiting QT events, then return."""
|
|
|
|
pcop.process_events()
|
|
|
|
pcop.process_events()
|
|
|
|
|
|
|
|
|
|
|
|
def connectDCOPSignal(sender,senderObj,signal,receiverObj,slot,vol=1):
|
|
|
|
def connectDCOPSignal(sender,senderObj,signal,receiverObj,slot,vol=1):
|
|
|
|
"""Connect a dcop signal"""
|
|
|
|
"""Connect a dcop signal"""
|
|
|
|
return pcop.connect_dcop_signal(sender,senderObj,signal,receiverObj,slot,vol)
|
|
|
|
return pcop.connect_dcop_signal(sender,senderObj,signal,receiverObj,slot,vol)
|
|
|
|
|
|
|
|
|
|
|
|
def disconnectDCOPSignal(sender,senderObj,signal,receiverObj,slot):
|
|
|
|
def disconnectDCOPSignal(sender,senderObj,signal,receiverObj,slot):
|
|
|
|
"""Connect a dcop signal"""
|
|
|
|
"""Connect a dcop signal"""
|
|
|
|
return pcop.disconnect_dcop_signal(sender,senderObj,signal,receiverObj,slot)
|
|
|
|
return pcop.disconnect_dcop_signal(sender,senderObj,signal,receiverObj,slot)
|
|
|
|
|
|
|
|
|
|
|
|
class DCOPApplication(object):
|
|
|
|
class DCOPApplication(object):
|
|
|
|
def __init__( self, name ):
|
|
|
|
def __init__( self, name ):
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__( self, item ):
|
|
|
|
def __getattr__( self, item ):
|
|
|
|
if item == "__repr__":
|
|
|
|
if item == "__repr__":
|
|
|
|
return object.__repr__
|
|
|
|
return object.__repr__
|
|
|
|
if item == "__str__":
|
|
|
|
if item == "__str__":
|
|
|
|
return object.__str__
|
|
|
|
return object.__str__
|
|
|
|
if item == "__call__":
|
|
|
|
if item == "__call__":
|
|
|
|
return object.__call__
|
|
|
|
return object.__call__
|
|
|
|
if item == "_objects_":
|
|
|
|
if item == "_objects_":
|
|
|
|
return pcop.obj_list(self.name)
|
|
|
|
return pcop.obj_list(self.name)
|
|
|
|
return DCOPObject( self.name, item )
|
|
|
|
return DCOPObject( self.name, item )
|
|
|
|
|
|
|
|
|
|
|
|
def _object_(self, object):
|
|
|
|
def _object_(self, object):
|
|
|
|
return DCOPObject( self.name, object )
|
|
|
|
return DCOPObject( self.name, object )
|
|
|
|
|
|
|
|
|
|
|
|
class DCOPObject(object):
|
|
|
|
class DCOPObject(object):
|
|
|
|
def __init__( self, appname, name ):
|
|
|
|
def __init__( self, appname, name ):
|
|
|
|
self.appname = appname
|
|
|
|
self.appname = appname
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__( self ):
|
|
|
|
def __repr__( self ):
|
|
|
|
return "DCOPObject(%s,%s)" % ( self.appname, self.name )
|
|
|
|
return "DCOPObject(%s,%s)" % ( self.appname, self.name )
|
|
|
|
|
|
|
|
|
|
|
|
def __str__( self ):
|
|
|
|
def __str__( self ):
|
|
|
|
return "DCOPObject(%s,%s)" % ( self.appname, self.name )
|
|
|
|
return "DCOPObject(%s,%s)" % ( self.appname, self.name )
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__( self, item ):
|
|
|
|
def __getattr__( self, item ):
|
|
|
|
if item == "__repr__":
|
|
|
|
if item == "__repr__":
|
|
|
|
return object.__repr__
|
|
|
|
return object.__repr__
|
|
|
|
if item == "__str__":
|
|
|
|
if item == "__str__":
|
|
|
|
return object.__str__
|
|
|
|
return object.__str__
|
|
|
|
if item == "__call__":
|
|
|
|
if item == "__call__":
|
|
|
|
return object.__call__
|
|
|
|
return object.__call__
|
|
|
|
if item == "_methods_":
|
|
|
|
if item == "_methods_":
|
|
|
|
return pcop.method_list( self.appname, self.name )
|
|
|
|
return pcop.method_list( self.appname, self.name )
|
|
|
|
return DCOPMethod( self.appname, self.name, item )
|
|
|
|
return DCOPMethod( self.appname, self.name, item )
|
|
|
|
|
|
|
|
|
|
|
|
def _method_(self, method):
|
|
|
|
def _method_(self, method):
|
|
|
|
return DCOPMethod( self.appname, self.name, method )
|
|
|
|
return DCOPMethod( self.appname, self.name, method )
|
|
|
|
|
|
|
|
|
|
|
|
class DCOPMethod(object):
|
|
|
|
class DCOPMethod(object):
|
|
|
|
def __init__( self, appname, objname, name ):
|
|
|
|
def __init__( self, appname, objname, name ):
|
|
|
@ -80,43 +80,43 @@ class DCOPMethod(object):
|
|
|
|
self.objname = objname
|
|
|
|
self.objname = objname
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__( self ):
|
|
|
|
def __repr__( self ):
|
|
|
|
return "DCOPMethod(%s,%s,%s)" % ( self.appname, self.objname, self.name )
|
|
|
|
return "DCOPMethod(%s,%s,%s)" % ( self.appname, self.objname, self.name )
|
|
|
|
|
|
|
|
|
|
|
|
def __str__( self ):
|
|
|
|
def __str__( self ):
|
|
|
|
return "DCOPMethod(%s,%s,%s)" % ( self.appname, self.objname, self.name )
|
|
|
|
return "DCOPMethod(%s,%s,%s)" % ( self.appname, self.objname, self.name )
|
|
|
|
|
|
|
|
|
|
|
|
def __call__( self, *args ):
|
|
|
|
def __call__( self, *args ):
|
|
|
|
return pcop.dcop_call( self.appname, self.objname, self.name, args )
|
|
|
|
return pcop.dcop_call( self.appname, self.objname, self.name, args )
|
|
|
|
|
|
|
|
|
|
|
|
class DCOPServer(object):
|
|
|
|
class DCOPServer(object):
|
|
|
|
def __init__( self, appid, addpid = 1):
|
|
|
|
def __init__( self, appid, addpid = 1):
|
|
|
|
self.app_id = pcop.register_as(appid, addpid)
|
|
|
|
self.app_id = pcop.register_as(appid, addpid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DCOPServerObject:
|
|
|
|
class DCOPServerObject:
|
|
|
|
"""Inherit from this class to DCOP enabled your object.
|
|
|
|
"""Inherit from this class to DCOP enabled your object.
|
|
|
|
|
|
|
|
|
|
|
|
Remember to call the base class constructor, and in your own constructor
|
|
|
|
Remember to call the base class constructor, and in your own constructor
|
|
|
|
you should called setMethods to set the methods to DCOP enable.
|
|
|
|
you should called setMethods to set the methods to DCOP enable.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, objName=None):
|
|
|
|
def __init__(self, objName=None):
|
|
|
|
"""objName is the name of the object. If omitted, it will default to a hex
|
|
|
|
"""objName is the name of the object. If omitted, it will default to a hex
|
|
|
|
address. It is best to supply it."""
|
|
|
|
address. It is best to supply it."""
|
|
|
|
if objName:
|
|
|
|
if objName:
|
|
|
|
self.dcop_obj = pcop.create_dcop_object(self, objName)
|
|
|
|
self.dcop_obj = pcop.create_dcop_object(self, objName)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.dcop_obj = pcop.create_dcop_object(self)
|
|
|
|
self.dcop_obj = pcop.create_dcop_object(self)
|
|
|
|
|
|
|
|
|
|
|
|
def setMethods(self, methods):
|
|
|
|
def setMethods(self, methods):
|
|
|
|
"""Set the method list for this object.
|
|
|
|
"""Set the method list for this object.
|
|
|
|
|
|
|
|
|
|
|
|
methods is a list of tuple pairs. Each pair consists of the
|
|
|
|
methods is a list of tuple pairs. Each pair consists of the
|
|
|
|
method signature and the Python method that handles it.
|
|
|
|
method signature and the Python method that handles it.
|
|
|
|
|
|
|
|
|
|
|
|
For example, setMethods([ ('TQString cheeseType()', self.cheese_type),
|
|
|
|
For example, setMethods([ ('TQString cheeseType()', self.cheese_type),
|
|
|
|
('void setGreatWines(bool perthPink, bool hobartMuddy, bool chateauChunder)')
|
|
|
|
('void setGreatWines(bool perthPink, bool hobartMuddy, bool chateauChunder)')
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
pcop.set_method_list(self.dcop_obj, methods)
|
|
|
|
pcop.set_method_list(self.dcop_obj, methods)
|
|
|
|
|
|
|
|
|
|
|
|