we can now remove agents from roaster
This commit is contained in:
parent
f67f86ab67
commit
792aeb573f
3 changed files with 41 additions and 12 deletions
22
core/core.py
22
core/core.py
|
@ -364,20 +364,32 @@ class GajimCore:
|
|||
#('DENY', account, jid)
|
||||
elif ev[0] == 'DENY':
|
||||
con.send(common.jabber.Presence(ev[2], 'unsubscribed'))
|
||||
#('UNSUB', accountjid)
|
||||
#('UNSUB', account, jid)
|
||||
elif ev[0] == 'UNSUB':
|
||||
delauth = 1
|
||||
if self.cfgParser.Core.has_key('delauth'):
|
||||
delauth = self.cfgParser.Core['delauth']
|
||||
else:
|
||||
delauth = 1
|
||||
delroster = 1
|
||||
if self.cfgParser.Core.has_key('delroster'):
|
||||
delroster = self.cfgParser.Core['delroster']
|
||||
else:
|
||||
delroster = 1
|
||||
if delauth:
|
||||
con.send(common.jabber.Presence(ev[2], 'unsubscribe'))
|
||||
if delroster:
|
||||
con.removeRosterItem(ev[2])
|
||||
#('UNSUB_AGENT', account, agent)
|
||||
elif ev[0] == 'UNSUB_AGENT':
|
||||
con.removeRosterItem(ev[2])
|
||||
con.requestRegInfo(ev[2])
|
||||
agent_info = con.getRegInfo()
|
||||
key = agent_info['key']
|
||||
iq = common.jabber.Iq(to=ev[2], type="set")
|
||||
q = iq.setQuery(common.jabber.NS_REGISTER)
|
||||
q.insertTag('remove')
|
||||
q.insertTag('key').insertData(key)
|
||||
id = con.getAnID()
|
||||
iq.setID(id)
|
||||
con.send(iq)
|
||||
self.hub.sendPlugin('AGENT_REMOVED', ev[1], ev[2])
|
||||
#('UPDUSER', account, (jid, name, groups))
|
||||
elif ev[0] == 'UPDUSER':
|
||||
con.updateRosterItem(jid=ev[2][0], name=ev[2][1], \
|
||||
|
|
|
@ -31,6 +31,7 @@ gtk.glade.bindtextdomain (APP, i18n.DIR)
|
|||
gtk.glade.textdomain (APP)
|
||||
|
||||
from dialogs import *
|
||||
import gtkgui
|
||||
|
||||
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
||||
|
||||
|
@ -642,6 +643,10 @@ class agentRegistration_Window:
|
|||
send registration info to the core"""
|
||||
for name in self.entries.keys():
|
||||
self.infos[name] = self.entries[name].get_text()
|
||||
user1 = gtkgui.user(self.agent, self.agent, ['Agents'], 'offline', 'offline', \
|
||||
'from', '', 0)
|
||||
self.plugin.roster.contacts[self.account][self.agent] = [user1]
|
||||
self.plugin.roster.add_user_to_roster(self.agent, self.account)
|
||||
self.plugin.send('REG_AGENT', self.account, self.agent)
|
||||
widget.get_toplevel().destroy()
|
||||
|
||||
|
|
|
@ -614,6 +614,15 @@ class roster_Window:
|
|||
"""When an agent is requested to log in or off"""
|
||||
self.plugin.send('AGENT_LOGGING', account, (jid, state))
|
||||
|
||||
def on_remove_agent(self, widget, jid, account):
|
||||
"""When an agent is requested to log in or off"""
|
||||
window = confirm_Window(_("Are you sure you want to remove the agent %s from your roster ?") % jid)
|
||||
if window.wait() == gtk.RESPONSE_OK:
|
||||
self.plugin.send('UNSUB_AGENT', account, jid)
|
||||
for u in self.contacts[account][jid]:
|
||||
self.remove_user(u, account)
|
||||
del self.contacts[account][u.jid]
|
||||
|
||||
def on_rename(self, widget, iter, path, user):
|
||||
model = self.tree.get_model()
|
||||
model.set_value(iter, 1, user.name)
|
||||
|
@ -707,7 +716,15 @@ class roster_Window:
|
|||
if self.contacts[account][jid][0].show == 'offline':
|
||||
item.set_sensitive(FALSE)
|
||||
menu.append(item)
|
||||
item.connect("activate", self.on_agent_logging, jid, 'unavailable', account)
|
||||
item.connect("activate", self.on_agent_logging, jid, 'unavailable', \
|
||||
account)
|
||||
|
||||
item = gtk.MenuItem()
|
||||
menu.append(item)
|
||||
|
||||
item = gtk.MenuItem(_("Remove"))
|
||||
menu.append(item)
|
||||
item.connect("activate", self.on_remove_agent, jid, account)
|
||||
|
||||
menu.popup(None, None, None, event.button, event.time)
|
||||
menu.show_all()
|
||||
|
@ -1477,12 +1494,7 @@ class plugin:
|
|||
user1.priority = priority
|
||||
if string.find(jid, "@") <= 0:
|
||||
#It must be an agent
|
||||
if not self.roster.contacts[account].has_key(ji):
|
||||
user1 = user(ji, ji, ['Agents'], array[1], \
|
||||
array[2], 'from', resource, 0)
|
||||
self.roster.contacts[account][ji] = [user1]
|
||||
self.roster.add_user_to_roster(ji, account)
|
||||
else:
|
||||
if self.roster.contacts[account].has_key(ji):
|
||||
#Update existing iter
|
||||
self.roster.redraw_jid(ji, account)
|
||||
elif self.roster.contacts[account].has_key(ji):
|
||||
|
|
Loading…
Add table
Reference in a new issue