summaryrefslogtreecommitdiff
path: root/gabble
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-11-17 17:42:43 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2011-11-18 10:44:42 +0000
commitce06c87a88c630ff54bdffa756d852274c67d993 (patch)
treee80cdc92ccb0a742b6273169bf995875b28bd94d /gabble
parent2e670c2c3b3646aa155cf7e44af4eccd7678fa29 (diff)
console UI: add a page for sending arbitrary stanzas
Diffstat (limited to 'gabble')
-rwxr-xr-xgabble/plugins/telepathy-gabble-xmpp-console51
1 files changed, 50 insertions, 1 deletions
diff --git a/gabble/plugins/telepathy-gabble-xmpp-console b/gabble/plugins/telepathy-gabble-xmpp-console
index c96413e93..1505e2ddb 100755
--- a/gabble/plugins/telepathy-gabble-xmpp-console
+++ b/gabble/plugins/telepathy-gabble-xmpp-console
@@ -63,6 +63,7 @@ class StanzaViewer(Gtk.ScrolledWindow):
def append_stanza(self, xml):
pretty = minidom.parseString(xml).toprettyxml()
+ pretty = pretty.replace('<?xml version="1.0" ?>\n', '')
i = self.b.get_end_iter()
self.b.insert(i, pretty + '\n')
@@ -70,6 +71,9 @@ class StanzaViewer(Gtk.ScrolledWindow):
i = self.b.get_end_iter()
self.b.insert(i, '<!-- %s -->\n' % text)
+ def tell_me_everything(self):
+ return self.b.get_property('text')
+
class SpinWrapper(Gtk.Notebook):
PRIMARY_PAGE = 0
SPINNER_PAGE = 1
@@ -204,6 +208,45 @@ class IQPage(Page):
self.result_nb.stop_spinning()
+class StanzaPage(Page):
+ def __init__(self, console_proxy):
+ Page.__init__(self, console_proxy)
+
+ title = self.add_title("Enter a complete stanza:")
+
+ self.sv = StanzaViewer()
+ self.sv.view.set_editable(True)
+ self.sv.append_stanza("<message to='t-pain@test.collabora.co.uk' type='chat'><body>Been on any nice boats recently?</body></message>")
+
+ self.spin_wrapper = SpinWrapper(self.sv)
+ self.attach_next_to(self.spin_wrapper, title, Gtk.PositionType.BOTTOM,
+ 2, 1)
+
+ self.result_label = self.add_label('', self.spin_wrapper)
+ self.result_label.set_property('hexpand', True)
+ self.result_label.set_line_wrap(True)
+
+ b = Gtk.Button.new_with_mnemonic("_Send")
+ b.connect('clicked', self.__send_stanza)
+ b.set_property('hexpand', False)
+ self.attach_next_to(b, self.result_label, Gtk.PositionType.RIGHT, 1, 1)
+
+ def __send_stanza(self, button):
+ self.console_proxy.SendStanza('(s)', self.sv.tell_me_everything(),
+ result_handler=self.__send_stanza_cb)
+ self.spin_wrapper.start_spinning()
+
+ def __send_stanza_cb(self, proxy, result, user_data):
+ if isinstance(result, Exception):
+ # FIXME: this sucks. You can't just get the free text bit without
+ # the D-Bus error bit.
+ t = result.message
+ else:
+ t = "yes sir, captain tightpants"
+
+ self.result_label.set_text(t)
+ self.spin_wrapper.stop_spinning()
+
class SnoopyPage(Page):
def __init__(self, console_proxy):
Page.__init__(self, console_proxy)
@@ -250,7 +293,8 @@ class SnoopyPage(Page):
class Window(Gtk.Window):
IQ_PAGE = 0
- SNOOPY_PAGE = 1
+ STANZA_PAGE = 1
+ SNOOPY_PAGE = 2
def __init__(self, bus, connection_bus_name):
Gtk.Window.__init__(self)
@@ -284,6 +328,11 @@ plugin installed.""" % locals()
Gtk.Label.new_with_mnemonic("_IQ console"),
self.IQ_PAGE)
+ self.stanza = StanzaPage(self.console_proxy)
+ self.nb.insert_page(self.stanza,
+ Gtk.Label.new_with_mnemonic("Send a s_tanza"),
+ self.STANZA_PAGE)
+
self.snoopy = SnoopyPage(self.console_proxy)
self.nb.insert_page(self.snoopy,
Gtk.Label.new_with_mnemonic("_Monitor network traffic"),