Show
Ignore:
Timestamp:
08/31/07 11:08:17 (15 months ago)
Author:
asterix
Message:

use new dataform widget in register agent window. Remove no more used old DataFormWindow?.

Location:
branches/gajim_0.11.1/src/common
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.1/src/common/connection_handlers.py

    r8668 r8669  
    593593                self.connection.SendAndCallForResponse(iq, self._ReceivedRegInfo, 
    594594                        {'agent': agent}) 
    595          
    596         def build_data_from_dict(self, query, config): 
    597                 x = query.setTag(common.xmpp.NS_DATA + ' x', attrs = {'type': 'submit'}) 
    598                 i = 0 
    599                 while config.has_key(i): 
    600                         if not config[i].has_key('type'): 
    601                                 i += 1 
    602                                 continue 
    603                         if config[i]['type'] == 'fixed': 
    604                                 i += 1 
    605                                 continue 
    606                         tag = x.addChild('field') 
    607                         if config[i].has_key('var'): 
    608                                 tag.setAttr('var', config[i]['var']) 
    609                         if config[i].has_key('values'): 
    610                                 for val in config[i]['values']: 
    611                                         if val == False: 
    612                                                 val = '0' 
    613                                         elif val == True: 
    614                                                 val = '1' 
    615                                         # Force to create a new child 
    616                                         tag.addChild('value').addData(val) 
    617                         i += 1 
    618          
     595 
    619596        def register_agent(self, agent, info, is_form = False): 
    620597                if not self.connection: 
     
    623600                        iq = common.xmpp.Iq('set', common.xmpp.NS_REGISTER, to = agent) 
    624601                        query = iq.getTag('query') 
    625                         self.build_data_from_dict(query, info) 
     602                        info.setAttr('type', 'submit') 
     603                        query.addChild(node = info) 
    626604                        self.connection.send(iq) 
    627605                else: 
     
    17961774                                keyID, timestamp, contact_nickname)) 
    17971775        # END presenceCB 
     1776 
    17981777        def _StanzaArrivedCB(self, con, obj): 
    17991778                self.last_io = gajim.idlequeue.current_time() 
    1800          
    1801          
    1802         def parse_data_form(self, node): 
    1803                 dic = {} 
    1804                 tag = node.getTag('title') 
    1805                 if tag: 
    1806                         dic['title'] = tag.getData() 
    1807                 tag = node.getTag('instructions') 
    1808                 if tag: 
    1809                         dic['instructions'] = tag.getData() 
    1810                 i = 0 
    1811                 for child in node.getChildren(): 
    1812                         if child.getName() != 'field': 
    1813                                 continue 
    1814                         var = child.getAttr('var') 
    1815                         ctype = child.getAttr('type') 
    1816                         label = child.getAttr('label') 
    1817                         if not var and ctype != 'fixed': # We must have var if type != fixed 
    1818                                 continue 
    1819                         dic[i] = {} 
    1820                         if var: 
    1821                                 dic[i]['var'] = var 
    1822                         if ctype: 
    1823                                 dic[i]['type'] = ctype 
    1824                         if label: 
    1825                                 dic[i]['label'] = label 
    1826                         tags = child.getTags('value') 
    1827                         if len(tags): 
    1828                                 dic[i]['values'] = [] 
    1829                                 for tag in tags: 
    1830                                         data = tag.getData() 
    1831                                         if ctype == 'boolean': 
    1832                                                 if data in ('yes', 'true', 'assent', '1'): 
    1833                                                         data = True 
    1834                                                 else: 
    1835                                                         data = False 
    1836                                         dic[i]['values'].append(data) 
    1837                         tag = child.getTag('desc') 
    1838                         if tag: 
    1839                                 dic[i]['desc'] = tag.getData() 
    1840                         option_tags = child.getTags('option') 
    1841                         if len(option_tags): 
    1842                                 dic[i]['options'] = {} 
    1843                                 j = 0 
    1844                                 for option_tag in option_tags: 
    1845                                         dic[i]['options'][j] = {} 
    1846                                         label = option_tag.getAttr('label') 
    1847                                         tags = option_tag.getTags('value') 
    1848                                         dic[i]['options'][j]['values'] = [] 
    1849                                         for tag in tags: 
    1850                                                 dic[i]['options'][j]['values'].append(tag.getData()) 
    1851                                         if not label: 
    1852                                                 label = dic[i]['options'][j]['values'][0] 
    1853                                         dic[i]['options'][j]['label'] = label 
    1854                                         j += 1 
    1855                                 if not dic[i].has_key('values'): 
    1856                                         dic[i]['values'] = [dic[i]['options'][0]['values'][0]] 
    1857                         i += 1 
    1858                 return dic 
    18591779 
    18601780        def _MucOwnerCB(self, con, iq_obj): 
  • branches/gajim_0.11.1/src/common/connection.py

    r8668 r8669  
    223223                                is_form = data[2] 
    224224                                if is_form: 
    225                                         conf = self.parse_data_form(data[1]) 
     225                                        conf = data[1] 
    226226                                else: 
    227227                                        conf = data[1].asDict()