changeset 375:502489e17685

D-Bus constructor: add Constructors specific flags (--flags argument) dbus-xml constructor now as annotation flag to add Qt annotation usefull for the Qt frontend (bellaciao)
author Goffi <goffi@goffi.org>
date Mon, 08 Aug 2011 23:04:19 +0200
parents 193fd5995430
children 9ffae6abdb05
files src/bridge/bridge_constructor/bridge_contructor.py src/bridge/bridge_constructor/bridge_template.ini
diffstat 2 files changed, 26 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/bridge_contructor.py	Thu Jul 28 03:02:31 2011 +0200
+++ b/src/bridge/bridge_constructor/bridge_contructor.py	Mon Aug 08 23:04:19 2011 +0200
@@ -482,7 +482,14 @@
         Constructor.__init__(self, bridge_template, options)
         
         self.template="dbus_xml_template.xml" 
-        self.core_dest="org.goffi.sat.xml" 
+        self.core_dest="org.goffi.sat.xml"
+        self.default_annotation = { 'a{ss}': 'StringDict',
+                                    'a(sa{ss}as)': 'QList<ContactT>',
+                                    'a{i(ss)}': 'HistoryT',
+                                    'a(sss)': 'QList<MenuT>',
+                                    'a{sa{s(sia{ss})}}': 'PresenceStatusT',
+                                    'a{sa{ss}}': 'ActionResultExtDataT',
+                                  }
 
     def generateCoreSide(self):
         try:
@@ -510,8 +517,15 @@
                 arg_elt = doc.createElement('arg')
                 arg_elt.setAttribute('name', args_doc[idx][0] if args_doc.has_key(idx) else "arg_%i" % idx)
                 arg_elt.setAttribute('type', arg)
-                arg_elt.setAttribute('direction', 'in' if function["type"]=='method' else 'out')
+                _direction = 'in' if function["type"]=='method' else 'out'
+                arg_elt.setAttribute('direction', _direction)
                 new_elt.appendChild(arg_elt)
+                if "annotation" in self.options.flags:
+                    if arg in self.default_annotation:
+                        annot_elt = doc.createElement("annotation")
+                        annot_elt.setAttribute('name', "com.trolltech.QtDBus.QtTypeName.In%d" % idx)
+                        annot_elt.setAttribute('value', self.default_annotation[arg])
+                        new_elt.appendChild(annot_elt)
                 idx+=1
             
             if function['sig_out']:
@@ -519,6 +533,12 @@
                 arg_elt.setAttribute('type', function['sig_out'])
                 arg_elt.setAttribute('direction', 'out')
                 new_elt.appendChild(arg_elt)
+                if "annotation" in self.options.flags:
+                    if function['sig_out'] in self.default_annotation:
+                        annot_elt = doc.createElement("annotation")
+                        annot_elt.setAttribute('name', "com.trolltech.QtDBus.QtTypeName.Out0")
+                        annot_elt.setAttribute('value', self.default_annotation[function['sig_out']])
+                        new_elt.appendChild(annot_elt)
 
             interface_elt.appendChild(new_elt)
 
@@ -564,9 +584,12 @@
                     help=("Add debug information printing"))
         parser.add_option("--no_unicode", action="store_false", dest="unicode", default=True,
                     help=("Remove unicode type protection from string results"))
+        parser.add_option("--flags", action="store", type="string", 
+                    help=("Constructors' specific flags, comma separated"))
 
 
         (self.options, args) = parser.parse_args()
+        self.options.flags = self.options.flags.split(',') if self.options.flags else []
         return args
 
     def go(self):
--- a/src/bridge/bridge_constructor/bridge_template.ini	Thu Jul 28 03:02:31 2011 +0200
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Mon Aug 08 23:04:19 2011 +0200
@@ -400,7 +400,7 @@
 doc_param_0=from_jid: source JID
 doc_param_1=to_jid: dest JID
 doc_param_2=size: size of the history (0 for the whole history)
-doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (from_jid, to_jid)
+doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (from_jid, message)
 
 [addContact]
 type=method