diff --git a/dfeet/_introspect_parser.py b/dfeet/_introspect_parser.py index 370d9e7..656f672 100644 --- a/dfeet/_introspect_parser.py +++ b/dfeet/_introspect_parser.py @@ -26,6 +26,8 @@ class _Parser(object): __slots__ = ('map', 'in_iface', 'in_method', + 'in_signal', + 'in_property', 'in_sig', 'out_sig', 'node_level', @@ -35,6 +37,7 @@ class _Parser(object): self.in_iface = '' self.in_method = '' self.in_signal = '' + self.in_property = '' self.in_sig = '' self.out_sig = '' self.node_level = 0 @@ -68,6 +71,10 @@ class _Parser(object): elif (self.in_signal and name == 'arg'): if attributes.get('direction', 'in') == 'in': self.in_sig += attributes['type'] + elif (not self.in_property and name == 'property'): + self.in_property = attributes['name'] + self.in_sig = attributes['type'] + self.out_sig = attributes['access'] def EndElementHandler(self, name): @@ -78,7 +85,7 @@ class _Parser(object): self.in_iface = '' elif (self.in_method and name == 'method'): if not self.map['interfaces'].has_key(self.in_iface): - self.map['interfaces'][self.in_iface]={'methods':{}, 'signals':{}} + self.map['interfaces'][self.in_iface]={'methods':{}, 'signals':{}, 'properties':{}} if self.map['interfaces'][self.in_iface]['methods'].has_key(self.in_method): print "ERROR: Some clever service is trying to be cute and has the same method name in the same interface" @@ -90,16 +97,28 @@ class _Parser(object): self.out_sig = '' elif (self.in_signal and name == 'signal'): if not self.map['interfaces'].has_key(self.in_iface): - self.map['interfaces'][self.in_iface]={'methods':{}, 'signals':{}} + self.map['interfaces'][self.in_iface]={'methods':{}, 'signals':{}, 'properties':{}} if self.map['interfaces'][self.in_iface]['signals'].has_key(self.in_signal): print "ERROR: Some clever service is trying to be cute and has the same signal name in the same interface" else: self.map['interfaces'][self.in_iface]['signals'][self.in_signal] = (self.in_sig, self.out_sig) - self.in_signal = '' self.in_sig = '' + self.out_sig = '' + elif (self.in_property and name == 'property'): + if not self.map['interfaces'].has_key(self.in_iface): + self.map['interfaces'][self.in_iface]={'methods':{}, 'signals':{}, 'properties':{}} + + if self.map['interfaces'][self.in_iface]['properties'].has_key(self.in_property): + print "ERROR: Some clever service is trying to be cute and has the same property name in the same interface" + else: + self.map['interfaces'][self.in_iface]['properties'][self.in_property] = (self.in_sig, self.out_sig) + + self.in_property = '' + self.in_sig = '' + self.out_sig = '' def process_introspection_data(data): diff --git a/dfeet/introspect_data.py b/dfeet/introspect_data.py index 5540b9a..e4dac89 100644 --- a/dfeet/introspect_data.py +++ b/dfeet/introspect_data.py @@ -234,6 +234,25 @@ class Signal(Node): return result +class Property(Node): + # tree path = (0,x,0,y,2,z) + def __init__(self, model, parent, property, insig): + self.property = property + self.insig = insig + + Node.__init__(self, model, parent) + + def dbus_call(self, bus, name, *args): + # for testing out properties + # this is not implemented yet + pass + + def __str__(self): + result = self.property + '(' + result += dbus_utils.sig_to_string(self.insig) + ')' + + return result + class MethodLabel(Node): # tree path = (0,x,0,y,0) def __init__(self, model, parent): @@ -274,6 +293,26 @@ class SignalLabel(Node): def __str__(self): return self._label +class PropertyLabel(Node): + # tree path = (0,x,0,y,2) + def __init__(self, model, parent): + Node.__init__(self, model, parent) + self.set_expanded(True) + self._label = 'Properties' + + def add(self, data): + property_list = data.keys() + property_list.sort() + for property_name in property_list: + property = Property(self.model, self, property_name, data[property_name]) + self._add_child(property, None) + + def to_markup_str(self): + return '' + gobject.markup_escape_text(self._label) + '' + + def __str__(self): + return self._label + class Interface(Node): # tree path = (0,x,0,y) def __init__(self, model, parent, interface): @@ -283,6 +322,7 @@ class Interface(Node): def add(self, data): method_data = data['methods'] signal_data = data['signals'] + property_data = data['properties'] methods = MethodLabel(self.model, self) self._add_child(methods, method_data) @@ -290,6 +330,9 @@ class Interface(Node): signals = SignalLabel(self.model, self) self._add_child(signals, signal_data) + properties = PropertyLabel(self.model, self) + self._add_child(properties, property_data) + def __str__(self): return self.iface @@ -367,8 +410,10 @@ class IntrospectData(gtk.GenericTreeModel): (0,x,0,y) - interface (0,x,0,y,0) - "Methods" (0,x,0,y,1) - "Signals" + (0,x,0,y,2) - "Properties" (0,x,0,y,0,z) - method signature (0,x,0,y,1,z) - signal signature + (0,x,0,y,1,z) - property signature """