From 665d7b8a58d1dd23c4c8a10f2e038a25c00a1faa Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 11 Jun 2005 17:21:30 +0000 Subject: [PATCH] menu for bookmarks now works --- src/common/connection.py | 44 ++++++++++++++++++++-------------------- src/gajim.py | 18 ++++++++++------ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index 847d84fda..7224977cf 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -118,7 +118,7 @@ class Connection: 'AGENT_INFO_INFO': [], 'QUIT': [], 'ACC_OK': [], 'MYVCARD': [], 'OS_INFO': [], 'VCARD': [], 'GC_MSG': [], 'GC_SUBJECT': [], 'GC_CONFIG': [], 'BAD_PASSPHRASE': [], 'ROSTER_INFO': [], - 'ERROR_ANSWER': [], 'BOOKMARK': [],} + 'ERROR_ANSWER': [], 'BOOKMARKS': [],} self.name = name self.connected = 0 # offline self.connection = None # xmpppy instance @@ -546,39 +546,39 @@ class Connection: self.dispatch('ROSTER', roster) def _PrivateCB(self, con, iq_obj): - """ + ''' Private Data (JEP 048 and 049) - """ - gajim.log.debug("PrivateCB") - storage = iq_obj.getTag("query").getTag("storage") + ''' + gajim.log.debug('PrivateCB') + storage = iq_obj.getTag('query').getTag('storage') try: ns = storage.getNamespace() except AttributeError: #Its a result for a 'set' Iq, so we don't do anything here - return + return - if ns=="storage:bookmarks": + if ns == 'storage:bookmarks': #Bookmarked URLs and Conferences #http://www.jabber.org/jeps/jep-0048.html - confs = storage.getTags("conference") - urls = storage.getTags("url") + confs = storage.getTags('conference') + urls = storage.getTags('url') for conf in confs: - bm = { 'name':conf.getAttr('name'), - 'jid':conf.getAttr('jid'), - 'autojoin':conf.getAttr('autojoin'), - 'password':conf.getTagData('password'), - 'nick':conf.getTagData('nick') } + bm = { 'name': conf.getAttr('name'), + 'jid': conf.getAttr('jid'), + 'autojoin': conf.getAttr('autojoin'), + 'password': conf.getTagData('password'), + 'nick': conf.getTagData('nick') } - self.dispatch("BOOKMARK", bm) self.bookmarks.append(bm) + self.dispatch('BOOKMARKS', self.bookmarks) - if bm['autojoin']=="1": - jid = common.xmpp.protocol.JID(conf.getAttr("jid")) - server = jid.getDomain() - room = jid.getNode() - gc = self.join_gc(bm['nick'], room, server, bm['password']) - - elif ns=="gajim:prefs": +# if bm['autojoin'] == '1': +# jid = common.xmpp.protocol.JID(conf.getAttr('jid')) +# server = jid.getDomain() +# room = jid.getNode() +# gc = self.join_gc(bm['nick'], room, server, bm['password']) + + elif ns == 'gajim:prefs': #Preferences data #http://www.jabber.org/jeps/jep-0049.html #TODO: implement this diff --git a/src/gajim.py b/src/gajim.py index ef27d0123..98358dba3 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -572,13 +572,19 @@ class Interface: user.groups = array[4] self.roster.draw_contact(jid, account) - def handle_event_bookmark(self, account, bm): - #('BOOKMARK', account, {name,jid,autojoin,password,nick}) + def handle_event_bookmarks(self, account, bms): + #('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}]) #We received a bookmark item from the server (JEP48) - #Open GC window if neccessary - if bm['autojoin'] == '1': - self.roster.join_gc_room(account, bm) + #Auto join GC windows if neccessary + for bm in bms: + if bm['autojoin'] == '1': + self.roster.join_gc_room(account, bm) + room, server = bm['jid'].split('@') + gajim.connections[account].join_gc(bm['nick'], room, server, + bm['password']) + self.roster.make_menu() + def read_sleepy(self): '''Check if we are idle''' @@ -742,7 +748,7 @@ class Interface: conn.register_handler('GC_CONFIG', self.handle_event_gc_config) conn.register_handler('BAD_PASSPHRASE', self.handle_event_bad_passphrase) conn.register_handler('ROSTER_INFO', self.handle_event_roster_info) - conn.register_handler('BOOKMARK', self.handle_event_bookmark) + conn.register_handler('BOOKMARKS', self.handle_event_bookmarks) def process_connections(self): try: