diff frontends/primitivus/primitivus @ 153:f197b52796ee

Primitivus: begining of management for actionResult
author Goffi <goffi@goffi.org>
date Sat, 31 Jul 2010 00:34:05 +0800
parents c8b231abfe96
children 13888bdb72b6
line wrap: on
line diff
--- a/frontends/primitivus/primitivus	Sat Jul 31 00:32:51 2010 +0800
+++ b/frontends/primitivus/primitivus	Sat Jul 31 00:34:05 2010 +0800
@@ -37,16 +37,9 @@
 from tools.jid  import JID"""
 import logging
 from logging import debug, info, error
-#import locale
 import sys, os
 from tools.jid  import JID
-#from curses import ascii
-#import locale
-#from signal import signal, SIGWINCH 
-#import fcntl
-#import struct
-#import termios
-#from boxsizer import BoxSizer
+from xmlui import XMLUI
 
 
 ### logging configuration FIXME: put this elsewhere ###
@@ -125,7 +118,7 @@
 
     def inputFilter(self, input, raw):
         for i in input:
-            if i.__class__==tuple:
+            if isinstance(i,tuple):
                 if i[0] == 'mouse press':
                     if i[1] == 4: #Mouse wheel up
                         input[input.index(i)] = 'up'
@@ -246,6 +239,33 @@
         if JID(self.contactList.selected).short != sender.short:
             self.contactList.putAlert(sender)
 
+    def actionResult(self, type, id, data):
+        if not id in self.current_action_ids:
+            debug (_('unknown id, ignoring'))
+            return
+        if type == "SUPPRESS":
+            self.current_action_ids.remove(id)
+        elif type == "XMLUI":
+            self.current_action_ids.remove(id)
+            debug (_("XML user interface received"))
+            misc = {}
+            #FIXME FIXME FIXME: must clean all this crap !
+            title = _('Form')
+            if data['type'] == _('registration'):
+                title = _('Registration')
+                misc['target'] = data['target']
+                misc['action_back'] = self.bridge.gatewayRegister
+            ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc)
+            assert(len(self.center_part.widget_list)==2)
+            self.center_part.widget_list[1] = ui
+            self.menu_roller.removeMenu(_('Chat menu'))
+            self.contactList.selected = None
+            self.redraw()
+        else:
+            error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
+            raise NotImplementedError
+
+    ##DIALOGS CALLBACKS##
     def onJoinRoom(self, button, edit):
         self.removePopUp()
         room_jid = JID(edit.get_edit_text())
@@ -298,9 +318,6 @@
             pop_up_widget = custom_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
             self.showPopUp(pop_up_widget)
 
-
-
-
     def onAboutRequest(self, menu):
         self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))