menu for bookmarks now works

This commit is contained in:
Yann Leboulanger 2005-06-11 17:21:30 +00:00
parent a516bbcab5
commit 665d7b8a58
2 changed files with 34 additions and 28 deletions

View file

@ -118,7 +118,7 @@ class Connection:
'AGENT_INFO_INFO': [], 'QUIT': [], 'ACC_OK': [], 'MYVCARD': [], 'AGENT_INFO_INFO': [], 'QUIT': [], 'ACC_OK': [], 'MYVCARD': [],
'OS_INFO': [], 'VCARD': [], 'GC_MSG': [], 'GC_SUBJECT': [], 'OS_INFO': [], 'VCARD': [], 'GC_MSG': [], 'GC_SUBJECT': [],
'GC_CONFIG': [], 'BAD_PASSPHRASE': [], 'ROSTER_INFO': [], 'GC_CONFIG': [], 'BAD_PASSPHRASE': [], 'ROSTER_INFO': [],
'ERROR_ANSWER': [], 'BOOKMARK': [],} 'ERROR_ANSWER': [], 'BOOKMARKS': [],}
self.name = name self.name = name
self.connected = 0 # offline self.connected = 0 # offline
self.connection = None # xmpppy instance self.connection = None # xmpppy instance
@ -546,39 +546,39 @@ class Connection:
self.dispatch('ROSTER', roster) self.dispatch('ROSTER', roster)
def _PrivateCB(self, con, iq_obj): def _PrivateCB(self, con, iq_obj):
""" '''
Private Data (JEP 048 and 049) Private Data (JEP 048 and 049)
""" '''
gajim.log.debug("PrivateCB") gajim.log.debug('PrivateCB')
storage = iq_obj.getTag("query").getTag("storage") storage = iq_obj.getTag('query').getTag('storage')
try: try:
ns = storage.getNamespace() ns = storage.getNamespace()
except AttributeError: except AttributeError:
#Its a result for a 'set' Iq, so we don't do anything here #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 #Bookmarked URLs and Conferences
#http://www.jabber.org/jeps/jep-0048.html #http://www.jabber.org/jeps/jep-0048.html
confs = storage.getTags("conference") confs = storage.getTags('conference')
urls = storage.getTags("url") urls = storage.getTags('url')
for conf in confs: for conf in confs:
bm = { 'name':conf.getAttr('name'), bm = { 'name': conf.getAttr('name'),
'jid':conf.getAttr('jid'), 'jid': conf.getAttr('jid'),
'autojoin':conf.getAttr('autojoin'), 'autojoin': conf.getAttr('autojoin'),
'password':conf.getTagData('password'), 'password': conf.getTagData('password'),
'nick':conf.getTagData('nick') } 'nick': conf.getTagData('nick') }
self.dispatch("BOOKMARK", bm)
self.bookmarks.append(bm) self.bookmarks.append(bm)
self.dispatch('BOOKMARKS', self.bookmarks)
if bm['autojoin']=="1": # if bm['autojoin'] == '1':
jid = common.xmpp.protocol.JID(conf.getAttr("jid")) # jid = common.xmpp.protocol.JID(conf.getAttr('jid'))
server = jid.getDomain() # server = jid.getDomain()
room = jid.getNode() # room = jid.getNode()
gc = self.join_gc(bm['nick'], room, server, bm['password']) # gc = self.join_gc(bm['nick'], room, server, bm['password'])
elif ns=="gajim:prefs": elif ns == 'gajim:prefs':
#Preferences data #Preferences data
#http://www.jabber.org/jeps/jep-0049.html #http://www.jabber.org/jeps/jep-0049.html
#TODO: implement this #TODO: implement this

View file

@ -572,13 +572,19 @@ class Interface:
user.groups = array[4] user.groups = array[4]
self.roster.draw_contact(jid, account) self.roster.draw_contact(jid, account)
def handle_event_bookmark(self, account, bm): def handle_event_bookmarks(self, account, bms):
#('BOOKMARK', account, {name,jid,autojoin,password,nick}) #('BOOKMARKS', account, [{name,jid,autojoin,password,nick}, {}])
#We received a bookmark item from the server (JEP48) #We received a bookmark item from the server (JEP48)
#Open GC window if neccessary #Auto join GC windows if neccessary
if bm['autojoin'] == '1': for bm in bms:
self.roster.join_gc_room(account, bm) 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): def read_sleepy(self):
'''Check if we are idle''' '''Check if we are idle'''
@ -742,7 +748,7 @@ class Interface:
conn.register_handler('GC_CONFIG', self.handle_event_gc_config) conn.register_handler('GC_CONFIG', self.handle_event_gc_config)
conn.register_handler('BAD_PASSPHRASE', self.handle_event_bad_passphrase) conn.register_handler('BAD_PASSPHRASE', self.handle_event_bad_passphrase)
conn.register_handler('ROSTER_INFO', self.handle_event_roster_info) 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): def process_connections(self):
try: try: