bridge refactoring: categories are now core and plugin instead of communication and request

This commit is contained in:
Goffi 2011-07-06 01:04:24 +02:00
commit b3322dabae
4 changed files with 161 additions and 142 deletions

View file

@ -344,7 +344,7 @@ class DbusConstructor(Constructor):
completion = {
'sig_in':function['sig_in'] or '',
'sig_out':function['sig_out'] or '',
'category':'REQ' if function['category'] == 'request' else 'COMM',
'category':'PLUGIN' if function['category'] == 'plugin' else 'CORE',
'name':section,
'args':self.getArguments(function['sig_in'], name=arg_doc, default=default )
}
@ -419,7 +419,7 @@ class DbusConstructor(Constructor):
completion = {
'sig_in':function['sig_in'] or '',
'sig_out':function['sig_out'] or '',
'category':'req' if function['category'] == 'request' else 'comm',
'category':'plugin' if function['category'] == 'plugin' else 'core',
'name':section,
'args':self.getArguments(function['sig_in'], name=arg_doc, default=default)
}

View file

@ -6,21 +6,21 @@ doc_profile_key=profile_key: Profile key which can be either a magic (eg: @DEFAU
[connected]
type=signal
category=communication
category=core
sig_in=s
doc=Connection is done
doc_param_0=%(doc_profile)s
[disconnected]
type=signal
category=communication
category=core
sig_in=s
doc=Connection is finished or lost
doc_param_0=%(doc_profile)s
[connectionError]
type=signal
category=communication
category=core
sig_in=ss
doc=Something went wront with the connection
doc_param_0=error_type: Why the connection got wrong, can be
@ -29,7 +29,7 @@ doc_param_1=%(doc_profile)s
[newContact]
type=signal
category=communication
category=core
sig_in=sa{ss}ass
doc=New contact received in roster
doc_param_0=contact: JID from who the message is comming
@ -43,7 +43,7 @@ doc_param_3=%(doc_profile)s
[newMessage]
type=signal
category=communication
category=core
sig_in=sssss
doc=A message has been received
doc_param_0=from_jid: JID where the message is comming from
@ -54,7 +54,7 @@ doc_param_4=%(doc_profile)s
[newAlert]
type=signal
category=communication
category=core
sig_in=ssss
doc=A new alert happened
doc_param_0=message: Body of the alert
@ -66,7 +66,7 @@ doc_param_3=%(doc_profile)s
[presenceUpdate]
type=signal
category=communication
category=core
sig_in=ssia{ss}s
doc=Somebody changed his presence informations.
doc_param_0=entity: JID from which we have presence informations
@ -77,7 +77,7 @@ doc_param_4=%(doc_profile)s
[subscribe]
type=signal
category=communication
category=core
sig_in=sss
doc=Somebody wants to be added in roster
doc_param_0=sub_type: Subscription states (see RFC 3921 #9)
@ -86,7 +86,7 @@ doc_param_2=%(doc_profile)s
[paramUpdate]
type=signal
category=communication
category=core
sig_in=ssss
doc=A parameter has been changed
doc_param_0=name: Name of the updated parameter
@ -96,7 +96,7 @@ doc_param_3=%(doc_profile)s
[contactDeleted]
type=signal
category=communication
category=core
sig_in=ss
doc=A contact has been supressed from roster
doc_param_0=entity: JID of the contact removed from roster
@ -104,7 +104,7 @@ doc_param_1=%(doc_profile)s
[askConfirmation]
type=signal
category=request
category=core
sig_in=ssa{ss}
doc=A confirmation is needed for an action
doc_param_0=conf_type: Type of the confirmation, can be:
@ -115,7 +115,7 @@ doc_param_2=data: conf_type dependent data
[actionResult]
type=signal
category=request
category=core
sig_in=ssa{ss}
doc=Requested result of an action
doc_param_0=answer_type: Type of the answer, can be:
@ -128,7 +128,7 @@ doc_param_2=data: answer_type specific data
[actionResultExt]
type=signal
category=request
category=core
sig_in=ssa{sa{ss}}
doc=Requested result of an action (Extended)
doc_param_0=answer_type: Same as for [actionResult] but with the following additional one:
@ -138,24 +138,25 @@ doc_param_2=data: answer_type specific data
[updatedValue]
type=signal
category=request
sig_in=sa{ss}
category=core
sig_in=sa{ss}s
doc=A value has been updated
doc_param_0=name: Name of the updated value
doc_param_1=value: New value
doc_param_2=%(doc_profile)s
;methods
[getVersion]
type=method
category=request
category=core
sig_in=
sig_out=s
doc=Get "Salut à Toi" version
[getProfileName]
type=method
category=request
category=core
sig_in=s
sig_out=s
param_0_default="@DEFAULT@"
@ -165,14 +166,14 @@ doc_return=Real profile name, or empty string if the profile doesn't exist
[getProfilesList]
type=method
category=request
category=core
sig_in=
sig_out=as
doc=Get all profiles
[createProfile]
type=method
category=request
category=core
sig_in=s
sig_out=i
doc=Create a new profile
@ -183,7 +184,7 @@ doc_return=status of the creation:
[deleteProfile]
type=method
category=request
category=core
sig_in=s
sig_out=i
doc=Delete a profile
@ -195,7 +196,7 @@ doc_return=status of the deletion:
[registerNewAccount]
deprecated=
type=method
category=communication
category=core
sig_in=ssssi
sig_out=s
param_4_default=5222
@ -208,7 +209,7 @@ doc_param_4=port: port of the server to register to
[connect]
type=method
category=communication
category=core
sig_in=s
sig_out=
param_0_default="@DEFAULT@"
@ -218,7 +219,7 @@ doc_param_0=%(doc_profile_key)s
[asyncConnect]
async=
type=method
category=communication
category=core
sig_in=s
sig_out=
param_0_default="@DEFAULT@"
@ -227,7 +228,7 @@ doc_param_0=%(doc_profile_key)s
[disconnect]
type=method
category=communication
category=core
sig_in=s
sig_out=
param_0_default="@DEFAULT@"
@ -236,7 +237,7 @@ doc_param_0=%(doc_profile_key)s
[isConnected]
type=method
category=communication
category=core
sig_in=s
sig_out=b
param_0_default="@DEFAULT@"
@ -245,7 +246,7 @@ doc_param_0=%(doc_profile_key)s
[getContacts]
type=method
category=communication
category=core
sig_in=s
sig_out=a(sa{ss}as)
param_0_default="@DEFAULT@"
@ -258,7 +259,7 @@ doc_return=array of tuples with the following values:
[getPresenceStatus]
type=method
category=communication
category=core
sig_in=s
sig_out=a{sa{s(sia{ss})}}
param_0_default="@DEFAULT@"
@ -269,7 +270,7 @@ doc_return=Dict of presence with bare JID of contact as key, and value as follow
[getWaitingSub]
type=method
category=communication
category=core
sig_in=s
sig_out=a{ss}
param_0_default="@DEFAULT@"
@ -279,7 +280,7 @@ doc_return=Dict where contact JID is the key, and value is the subscription type
[sendMessage]
type=method
category=communication
category=core
sig_in=sssss
sig_out=
param_2_default=''
@ -294,7 +295,7 @@ doc_param_4=%(doc_profile_key)s
[setPresence]
type=method
category=communication
category=core
sig_in=ssia{ss}s
sig_out=
param_0_default=''
@ -311,7 +312,7 @@ doc_param_4=%(doc_profile_key)s
[subscription]
type=method
category=communication
category=core
sig_in=sss
sig_out=
param_2_default="@DEFAULT@"
@ -322,7 +323,7 @@ doc_param_2=%(doc_profile_key)s
[getConfig]
type=method
category=communication
category=core
sig_in=ss
sig_out=s
doc=get main configuration option
@ -331,7 +332,7 @@ doc_param_1=name: name of the option
[setParam]
type=method
category=communication
category=core
sig_in=ssss
sig_out=
param_3_default="@DEFAULT@"
@ -343,7 +344,7 @@ doc_param_3=%(doc_profile_key)s
[getParamA]
type=method
category=communication
category=core
sig_in=ssss
sig_out=s
param_2_default="value"
@ -356,7 +357,7 @@ doc_param_3=%(doc_profile_key)s
[getParamsUI]
type=method
category=communication
category=core
sig_in=s
sig_out=s
param_0_default="@DEFAULT@"
@ -365,7 +366,7 @@ doc_param_0=%(doc_profile_key)s
[getParams]
type=method
category=communication
category=core
sig_in=s
sig_out=s
param_0_default="@DEFAULT@"
@ -374,7 +375,7 @@ doc_param_0=%(doc_profile_key)s
[getParamsForCategory]
type=method
category=communication
category=core
sig_in=ss
sig_out=s
param_1_default="@DEFAULT@"
@ -384,7 +385,7 @@ doc_param_1=%(doc_profile_key)s
[getParamsCategories]
type=method
category=communication
category=core
sig_in=
sig_out=as
doc=Get all categories currently existing in parameters
@ -392,7 +393,7 @@ doc_return=list of categories
[getHistory]
type=method
category=communication
category=core
sig_in=ssi
sig_out=a{i(ss)}
doc=Get history of a communication between two entities
@ -403,7 +404,7 @@ doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a
[addContact]
type=method
category=communication
category=core
sig_in=ss
sig_out=
param_1_default="@DEFAULT@"
@ -413,7 +414,7 @@ doc_param_1=%(doc_profile_key)s
[updateContact]
type=method
category=communication
category=core
sig_in=ssass
sig_out=
param_3_default="@DEFAULT@"
@ -425,7 +426,7 @@ doc_param_3=%(doc_profile_key)s
[delContact]
type=method
category=communication
category=core
sig_in=ss
sig_out=
param_1_default="@DEFAULT@"
@ -435,7 +436,7 @@ doc_param_1=%(doc_profile_key)s
[launchAction]
type=method
category=request
category=core
sig_in=sa{ss}s
sig_out=s
param_2_default="@DEFAULT@"
@ -447,7 +448,7 @@ doc_param_2=%(doc_profile_key)s
[confirmationAnswer]
type=method
category=request
category=core
sig_in=sba{ss}
sig_out=
doc=Give answer to a confirmation request
@ -457,7 +458,7 @@ doc_param_2=data: action specific data
[getProgress]
type=method
category=request
category=core
sig_in=s
sig_out=a{ss}
doc=Get progress information for an action
@ -468,7 +469,7 @@ doc_return=dict with progress information:
[getMenus]
type=method
category=request
category=core
sig_in=
sig_out=a(sss)
doc=Get all additional menus
@ -480,7 +481,7 @@ doc_return=list of tuple with the following value:
[getMenuHelp]
type=method
category=request
category=core
sig_in=sss
sig_out=s
param_2="NORMAL"
@ -492,7 +493,7 @@ doc_return=Help string
[callMenu]
type=method
category=request
category=core
sig_in=ssss
sig_out=s
doc=Execute action associated with a menu

View file

@ -28,8 +28,8 @@ from logging import debug, info
const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
const_OBJ_PATH = '/org/goffi/SAT/bridge'
const_COMM_SUFFIX = ".communication"
const_REQ_SUFFIX = ".request"
const_CORE_SUFFIX = ".core"
const_PLUGIN_SUFFIX = ".plugin"
class DbusObject(dbus.service.Object):
@ -43,6 +43,14 @@ class DbusObject(dbus.service.Object):
### signals ###
@dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX,
signature='')
def dummySignal(self):
#FIXME: workaround for addSignal (doesn't work if one method doensn't
# already exist for plugins), probably missing some initialisation, need
# further investigations
pass
##SIGNALS_PART##
### methods ###

View file

@ -21,12 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from bridge_frontend import BridgeFrontend
import dbus, dbus.glib
from logging import debug
from logging import debug, error
const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
const_OBJ_PATH = '/org/goffi/SAT/bridge'
const_COMM_SUFFIX = ".communication"
const_REQ_SUFFIX = ".request"
const_CORE_SUFFIX = ".core"
const_PLUGIN_SUFFIX = ".plugin"
class BridgeExceptionNoService(Exception):
pass
@ -37,97 +37,99 @@ class DBusBridgeFrontend(BridgeFrontend):
self.sessions_bus = dbus.SessionBus()
self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
const_OBJ_PATH)
self.db_comm_iface = dbus.Interface(self.db_object,
dbus_interface=const_INT_PREFIX + const_COMM_SUFFIX)
self.db_req_iface = dbus.Interface(self.db_object,
dbus_interface=const_INT_PREFIX + const_REQ_SUFFIX)
self.db_core_iface = dbus.Interface(self.db_object,
dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX)
self.db_plugin_iface = dbus.Interface(self.db_object,
dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX)
except dbus.exceptions.DBusException,e:
if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown':
raise BridgeExceptionNoService
else:
raise e
#props = self.db_comm_iface.getProperties()
#props = self.db_core_iface.getProperties()
def register(self, functionName, handler, iface="communication"):
if iface == "communication":
self.db_comm_iface.connect_to_signal(functionName, handler)
elif iface == "request":
self.db_req_iface.connect_to_signal(functionName, handler)
def register(self, functionName, handler, iface="core"):
if iface == "core":
self.db_core_iface.connect_to_signal(functionName, handler)
elif iface == "plugin":
self.db_plugin_iface.connect_to_signal(functionName, handler)
else:
error(_('Unknown interface'))
##METHODS_PART##
#methods from plugins
def getRoomJoined(self, profile_key='@DEFAULT@'):
return self.db_comm_iface.getRoomJoined(profile_key)
return self.db_plugin_iface.getRoomJoined(profile_key)
def getRoomSubjects(self, profile_key='@DEFAULT@'):
return self.db_comm_iface.getRoomSubjects(profile_key)
return self.db_plugin_iface.getRoomSubjects(profile_key)
def joinMUC(self, service, roomId, nick, profile_key='@DEFAULT@'):
return self.db_comm_iface.joinMUC(service, roomId, nick, profile_key)
return self.db_plugin_iface.joinMUC(service, roomId, nick, profile_key)
def tarotGameLaunch(self, players, profile_key='@DEFAULT@'):
return self.db_comm_iface.tarotGameLaunch(players, profile_key)
return self.db_plugin_iface.tarotGameLaunch(players, profile_key)
def tarotGameCreate(self, room_jid, players, profile_key='@DEFAULT@'):
return self.db_comm_iface.tarotGameCreate(room_jid, players, profile_key)
return self.db_plugin_iface.tarotGameCreate(room_jid, players, profile_key)
def tarotGameReady(self, player, referee, profile_key='@DEFAULT@'):
return self.db_comm_iface.tarotGameReady(player, referee, profile_key)
return self.db_plugin_iface.tarotGameReady(player, referee, profile_key)
def tarotGameContratChoosed(self, player, referee, contrat, profile_key='@DEFAULT@'):
return self.db_comm_iface.tarotGameContratChoosed(player, referee, contrat, profile_key)
return self.db_plugin_iface.tarotGameContratChoosed(player, referee, contrat, profile_key)
def tarotGamePlayCards(self, player, referee, cards, profile_key='@DEFAULT@'):
return self.db_comm_iface.tarotGamePlayCards(player, referee, cards, profile_key)
return self.db_plugin_iface.tarotGamePlayCards(player, referee, cards, profile_key)
def quizGameLaunch(self, players, profile_key='@DEFAULT@'):
return self.db_comm_iface.quizGameLaunch(players, profile_key)
return self.db_plugin_iface.quizGameLaunch(players, profile_key)
def quizGameCreate(self, room_jid, players, profile_key='@DEFAULT@'):
return self.db_comm_iface.quizGameCreate(room_jid, players, profile_key)
return self.db_plugin_iface.quizGameCreate(room_jid, players, profile_key)
def quizGameReady(self, player, referee, profile_key='@DEFAULT@'):
return self.db_comm_iface.quizGameReady(player, referee, profile_key)
return self.db_plugin_iface.quizGameReady(player, referee, profile_key)
def quizGameAnswer(self, player, referee, answer, profile_key='@DEFAULT@'):
return self.db_comm_iface.quizGameAnswer(player, referee, answer, profile_key)
return self.db_plugin_iface.quizGameAnswer(player, referee, answer, profile_key)
def sendFile(self, to, path, profile_key='@DEFAULT@'):
return self.db_comm_iface.sendFile(to, path, profile_key)
return self.db_plugin_iface.sendFile(to, path, profile_key)
def findGateways(self, target, profile_key='@DEFAULT@'):
return self.db_comm_iface.findGateways(target, profile_key)
return self.db_plugin_iface.findGateways(target, profile_key)
def getCard(self, target, profile_key='@DEFAULT@'):
return self.db_comm_iface.getCard(target, profile_key)
return self.db_plugin_iface.getCard(target, profile_key)
def getCardCache(self, target):
return self.db_comm_iface.getCardCache(target)
return self.db_plugin_iface.getCardCache(target)
def getAvatarFile(self, hash):
return self.db_comm_iface.getAvatarFile(hash)
return self.db_plugin_iface.getAvatarFile(hash)
def in_band_register(self, target, profile_key='@DEFAULT@'):
return self.db_comm_iface.in_band_register(target, profile_key)
return self.db_plugin_iface.in_band_register(target, profile_key)
def gatewayRegister(self, action, target, data, profile_key='@DEFAULT@'):
if data == None:
data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature
return self.db_req_iface.gatewayRegister(action, target, data, profile_key)
return self.db_plugin_iface.gatewayRegister(action, target, data, profile_key)
def getLastMicroblogs(self, jid, max_items, profile_key='@DEFAULT@', callback=None, errback=None):
return self.db_comm_iface.getLastMicroblogs(jid, max_items, profile_key, reply_handler=callback, error_handler=errback)
return self.db_plugin_iface.getLastMicroblogs(jid, max_items, profile_key, reply_handler=callback, error_handler=errback)
def getMblogNodes(self, profile_key='@DEFAULT@', callback=None, errback=None):
return self.db_comm_iface.getMblogNodes(profile_key, reply_handler=callback, error_handler=errback)
return self.db_plugin_iface.getMblogNodes(profile_key, reply_handler=callback, error_handler=errback)
def sendGroupBlog(self, groups, message, profile_key='@DEFAULT@'):
return self.db_comm_iface.sendGroupBlog(groups, message, profile_key)
return self.db_plugin_iface.sendGroupBlog(groups, message, profile_key)
def sendPersonalEvent(self, event_type, data, profile_key='@DEFAULT@'):
return self.db_comm_iface.sendPersonalEvent(event_type, data, profile_key)
return self.db_plugin_iface.sendPersonalEvent(event_type, data, profile_key)
def setMicroblogAccess(self, access="presence", profile_key='@DEFAULT@', callback=None, errback=None):
return self.db_comm_iface.setMicroblogAccess(access, profile_key, reply_handler=callback, error_handler=errback)
return self.db_plugin_iface.setMicroblogAccess(access, profile_key, reply_handler=callback, error_handler=errback)