nickname for each account is save so that <nickname> is printed in chat windows instead of <moi>
This commit is contained in:
parent
387b5a9e96
commit
5bd5c76c0b
20
core/core.py
20
core/core.py
|
@ -46,9 +46,11 @@ class GajimCore:
|
|||
self.connexions = {}
|
||||
for a in self.accounts:
|
||||
self.connected[a] = 0
|
||||
self.myVCardID = []
|
||||
# END __init__
|
||||
|
||||
def init_cfg_file(self):
|
||||
"""Initialize configuration file"""
|
||||
fname = os.path.expanduser(CONFPATH)
|
||||
reps = string.split(fname, '/')
|
||||
del reps[0]
|
||||
|
@ -74,6 +76,7 @@ class GajimCore:
|
|||
# END init_cfg_file
|
||||
|
||||
def parse(self):
|
||||
"""Parse configuratoin file and create self.accounts"""
|
||||
self.cfgParser.parseCfgFile()
|
||||
self.accounts = {}
|
||||
accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ')
|
||||
|
@ -83,7 +86,8 @@ class GajimCore:
|
|||
self.accounts[a] = self.cfgParser.tab[a]
|
||||
|
||||
def vCardCB(self, con, vc):
|
||||
"""Called when we recieve a vCard"""
|
||||
"""Called when we recieve a vCard
|
||||
Parse the vCard and send it to plugins"""
|
||||
vcard = {'jid': vc.getFrom().getBasic()}
|
||||
if vc._getTag('vCard') == common.jabber.NS_VCARD:
|
||||
card = vc.getChildren()[0]
|
||||
|
@ -94,7 +98,11 @@ class GajimCore:
|
|||
vcard[info.getName()] = {}
|
||||
for c in info.getChildren():
|
||||
vcard[info.getName()][c.getName()] = c.getData()
|
||||
self.hub.sendPlugin('VCARD', self.connexions[con], vcard)
|
||||
if vc.getID() in self.myVCardID:
|
||||
self.myVCardID.remove(vc.getID())
|
||||
self.hub.sendPlugin('MYVCARD', self.connexions[con], vcard)
|
||||
else:
|
||||
self.hub.sendPlugin('VCARD', self.connexions[con], vcard)
|
||||
|
||||
def messageCB(self, con, msg):
|
||||
"""Called when we recieve a message"""
|
||||
|
@ -209,6 +217,12 @@ class GajimCore:
|
|||
self.hub.sendPlugin('STATUS', account, 'online')
|
||||
self.connexions[con] = account
|
||||
self.connected[account] = 1
|
||||
iq = common.jabber.Iq(type="get")
|
||||
iq._setTag('vCard', common.jabber.NS_VCARD)
|
||||
id = con.getAnID()
|
||||
iq.setID(id)
|
||||
con.send(iq)
|
||||
self.myVCardID.append(id)
|
||||
return con
|
||||
else:
|
||||
log.debug("Couldn't authentificate to %s" % hostname)
|
||||
|
@ -440,12 +454,14 @@ def loadPlugins(gc):
|
|||
gc.hub.register(mod, 'MSG')
|
||||
gc.hub.register(mod, 'MSGSENT')
|
||||
gc.hub.register(mod, 'SUBSCRIBED')
|
||||
gc.hub.register(mod, 'UNSUBSCRIBED')
|
||||
gc.hub.register(mod, 'SUBSCRIBE')
|
||||
gc.hub.register(mod, 'AGENTS')
|
||||
gc.hub.register(mod, 'AGENT_INFO')
|
||||
gc.hub.register(mod, 'QUIT')
|
||||
gc.hub.register(mod, 'ACC_OK')
|
||||
gc.hub.register(mod, 'CONFIG')
|
||||
gc.hub.register(mod, 'MYVCARD')
|
||||
gc.hub.register(mod, 'VCARD')
|
||||
gc.hub.register(mod, 'LOG_NB_LINE')
|
||||
gc.hub.register(mod, 'LOG_LINE')
|
||||
|
|
|
@ -118,6 +118,12 @@ class vCard_Window:
|
|||
warning_Window("You must be connected to publish your informations")
|
||||
return
|
||||
vcard = self.make_vcard()
|
||||
nick = ''
|
||||
if vcard.has_key('NICKNAME'):
|
||||
nick = vcard['NICKNAME']
|
||||
if nick == '':
|
||||
nick = self.plugin.accounts[self.account]['name']
|
||||
self.plugin.nicks[self.account] = nick
|
||||
self.plugin.send('VCARD', self.account, vcard)
|
||||
|
||||
def __init__(self, jid, plugin, account):
|
||||
|
@ -613,6 +619,7 @@ class accountPreference_Window:
|
|||
self.plugin.windows[name] = self.plugin.windows[self.account]
|
||||
self.plugin.queues[name] = self.plugin.queues[self.account]
|
||||
self.plugin.connected[name] = self.plugin.connected[self.account]
|
||||
self.plugin.nicks[name] = self.plugin.nicks[self.account]
|
||||
self.plugin.roster.groups[name] = \
|
||||
self.plugin.roster.groups[self.account]
|
||||
self.plugin.roster.contacts[name] = \
|
||||
|
@ -620,6 +627,7 @@ class accountPreference_Window:
|
|||
del self.plugin.windows[self.account]
|
||||
del self.plugin.queues[self.account]
|
||||
del self.plugin.connected[self.account]
|
||||
del self.plugin.nicks[self.account]
|
||||
del self.plugin.roster.groups[self.account]
|
||||
del self.plugin.roster.contacts[self.account]
|
||||
del self.plugin.accounts[self.account]
|
||||
|
@ -970,7 +978,7 @@ class message_Window:
|
|||
buffer.insert_with_tags_by_name(end_iter, txt+'\n', \
|
||||
'status')
|
||||
else:
|
||||
buffer.insert_with_tags_by_name(end_iter, '<moi> ', 'outgoing')
|
||||
buffer.insert_with_tags_by_name(end_iter, '<'+self.plugin.nicks[self.account]+'> ', 'outgoing')
|
||||
buffer.insert(end_iter, txt+'\n')
|
||||
else:
|
||||
buffer.insert_with_tags_by_name(end_iter, '<' + \
|
||||
|
@ -1309,6 +1317,7 @@ class roster_Window:
|
|||
self.tree.expand_row(model.get_path(iterG), FALSE)
|
||||
|
||||
def remove_user(self, user, account):
|
||||
"""Remove a user from the roster"""
|
||||
model = self.tree.get_model()
|
||||
for i in self.get_user_iter(user.jid, account):
|
||||
parent_i = model.iter_parent(i)
|
||||
|
@ -1317,6 +1326,13 @@ class roster_Window:
|
|||
model.remove(parent_i)
|
||||
|
||||
def mkmenu(self):
|
||||
"""create the browse agents and add sub menus"""
|
||||
if len(self.plugin.accounts.keys()) > 0:
|
||||
self.xml.get_widget('add').set_sensitive(True)
|
||||
self.xml.get_widget('browse_agents').set_sensitive(True)
|
||||
else:
|
||||
self.xml.get_widget('add').set_sensitive(False)
|
||||
self.xml.get_widget('browse_agents').set_sensitive(False)
|
||||
if len(self.plugin.accounts.keys()) > 1:
|
||||
#add
|
||||
menu_sub = gtk.Menu()
|
||||
|
@ -1341,9 +1357,6 @@ class roster_Window:
|
|||
#agents
|
||||
self.xml.get_widget('browse_agents').connect("activate", \
|
||||
self.on_browse, self.plugin.accounts.keys()[0])
|
||||
else:
|
||||
self.xml.get_widget('add').set_sensitive(False)
|
||||
self.xml.get_widget('browse_agents').set_sensitive(False)
|
||||
|
||||
def draw_roster(self):
|
||||
"""Clear and draw roster"""
|
||||
|
@ -1479,11 +1492,11 @@ class roster_Window:
|
|||
"""Make group's popup menu"""
|
||||
menu = gtk.Menu()
|
||||
item = gtk.MenuItem("grp1")
|
||||
menu.append(item)
|
||||
# menu.append(item)
|
||||
item = gtk.MenuItem("grp2")
|
||||
menu.append(item)
|
||||
# menu.append(item)
|
||||
item = gtk.MenuItem("grp3")
|
||||
menu.append(item)
|
||||
# menu.append(item)
|
||||
menu.popup(None, None, None, event.button, event.time)
|
||||
menu.show_all()
|
||||
|
||||
|
@ -2076,6 +2089,13 @@ class plugin:
|
|||
self.windows['accounts'].init_accounts()
|
||||
elif ev[0] == 'QUIT':
|
||||
self.roster.on_quit(self)
|
||||
elif ev[0] == 'MYVCARD':
|
||||
nick = ''
|
||||
if ev[2].has_key('NICKNAME'):
|
||||
nick = ev[2]['NICKNAME']
|
||||
if nick == '':
|
||||
nick = self.accounts[ev[1]]['name']
|
||||
self.nicks[ev[1]] = nick
|
||||
elif ev[0] == 'VCARD':
|
||||
if self.windows[ev[1]]['infos'].has_key(ev[2]['jid']):
|
||||
self.windows[ev[1]]['infos'][ev[2]['jid']].set_values(ev[2])
|
||||
|
@ -2112,7 +2132,7 @@ class plugin:
|
|||
self.roster.optionmenu.set_history(1)
|
||||
self.send('STATUS', None, ('away', 'auto away (idle)'))
|
||||
elif state == common.sleepy.STATE_XAWAY and self.config['autoxa']:
|
||||
#we go extanded away
|
||||
#we go extended away
|
||||
self.roster.optionmenu.set_history(2)
|
||||
self.send('STATUS',('xa', 'auto away (idel)'))
|
||||
self.sleeper_state = state
|
||||
|
@ -2139,12 +2159,14 @@ class plugin:
|
|||
self.windows = {'logs':{}}
|
||||
self.queues = {}
|
||||
self.connected = {}
|
||||
self.nicks = {}
|
||||
for a in self.accounts.keys():
|
||||
self.windows[a] = {}
|
||||
self.windows[a]['infos'] = {}
|
||||
self.windows[a]['chats'] = {}
|
||||
self.queues[a] = {}
|
||||
self.connected[a] = 0
|
||||
self.nicks[a] = self.accounts[a]['name']
|
||||
self.roster = roster_Window(self)
|
||||
gtk.timeout_add(100, self.read_queue)
|
||||
gtk.timeout_add(1000, self.read_sleepy)
|
||||
|
|
Loading…
Reference in New Issue