diff --git a/core/core.py b/core/core.py
index 726619235..fb3a20931 100644
--- a/core/core.py
+++ b/core/core.py
@@ -480,6 +480,17 @@ class GajimCore:
self.hub.sendPlugin('STATUS', self.connexions[con], 'offline')
# END disconenctedCB
+ def rosterSetCB(self, con, iq_obj):
+ for item in iq_obj.getQueryNode().getChildren():
+ jid = item.getAttr('jid')
+ name = item.getAttr('name')
+ sub = item.getAttr('subscription')
+ ask = item.getAttr('ask')
+ groups = []
+ for group in item.getTags("group"):
+ groups.append(group.getData())
+ self.hub.sendPlugin('ROSTER_INFO', self.connexions[con], (jid, name, sub, ask, groups))
+
def connect(self, account):
"""Connect and authentificate to the Jabber server"""
hostname = self.cfgParser.tab[account]["hostname"]
@@ -511,6 +522,8 @@ class GajimCore:
con.registerHandler('message', self.messageCB)
con.registerHandler('presence', self.presenceCB)
con.registerHandler('iq',self.vCardCB,'result')#common.jabber.NS_VCARD)
+ con.registerHandler('iq',self.rosterSetCB,'set', \
+ common.jabber.NS_ROSTER)
try:
con.connect()
except IOError, e:
diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py
index 0e8518430..3fe762aa2 100644
--- a/plugins/gtkgui/config.py
+++ b/plugins/gtkgui/config.py
@@ -915,7 +915,7 @@ class agentRegistration_Window:
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, '')
+ '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)
diff --git a/plugins/gtkgui/dialogs.py b/plugins/gtkgui/dialogs.py
index 7eb5d896f..61f1a296c 100644
--- a/plugins/gtkgui/dialogs.py
+++ b/plugins/gtkgui/dialogs.py
@@ -180,6 +180,10 @@ class infoUser_Window:
self.xml.get_widget('label_name').set_text(user.name)
self.xml.get_widget('label_id').set_text(user.jid)
self.xml.get_widget('label_sub').set_text(user.sub)
+ if user.ask:
+ self.xml.get_widget('label_ask').set_text(user.ask)
+ else:
+ self.xml.get_widget('label_ask').set_text('None')
self.xml.get_widget('entry_name').set_text(user.name)
acct = self.plugin.accounts[account]
log = 1
diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade
index 724ca33b2..0fe39cf66 100644
--- a/plugins/gtkgui/gtkgui.glade
+++ b/plugins/gtkgui/gtkgui.glade
@@ -5424,30 +5424,6 @@ when NOT online
-
-
- True
- sub
- False
- False
- GTK_JUSTIFY_LEFT
- False
- False
- 0
- 0.5
- 5
- 5
-
-
- 1
- 2
- 4
- 5
- fill
-
-
-
-
5
@@ -5470,6 +5446,86 @@ when NOT online
+
+
+
+ True
+ False
+ 0
+
+
+
+ 100
+ True
+
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0
+ 0.5
+ 5
+ 5
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+ Ask :
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+
+ True
+
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
+ 0
+ False
+ False
+
+
+
+
+ 1
+ 2
+ 4
+ 5
+ fill
+ fill
+
+
False
diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py
index baa4e6ea6..ab57ae4aa 100644
--- a/plugins/gtkgui/gtkgui.py
+++ b/plugins/gtkgui/gtkgui.py
@@ -161,19 +161,21 @@ class user:
self.show = ''
self.status = ''
self.sub = ''
+ self.ask = ''
self.resource = ''
- self.priority = 0
+ self.priority = 1
self.keyID = ''
- elif len(args) == 9:
+ elif len(args) == 10:
self.jid = args[0]
self.name = args[1]
self.groups = args[2]
self.show = args[3]
self.status = args[4]
self.sub = args[5]
- self.resource = args[6]
- self.priority = args[7]
- self.keyID = args[8]
+ self.ask = args[6]
+ self.resource = args[7]
+ self.priority = args[8]
+ self.keyID = args[9]
else: raise TypeError, _('bad arguments')
@@ -953,16 +955,22 @@ class roster_Window:
if len(users) > 1:
name += " (" + str(len(users)) + ")"
prio = 0
- show = users[0].show
+ user = users[0]
for u in users:
if u.priority > prio:
prio = u.priority
- show = u.show
+ user = u
for iter in iters:
if self.plugin.queues[account].has_key(jid):
img = self.pixbufs['message']
else:
- img = self.pixbufs[show]
+ if user.sub == 'none':
+ if user.ask == 'subscribe':
+ img = self.pixbufs['requested']
+ else:
+ img = self.pixbufs['not in list']
+ else:
+ img = self.pixbufs[user.show]
model.set_value(iter, 0, img)
model.set_value(iter, 1, name)
@@ -1048,7 +1056,8 @@ class roster_Window:
show = 'offline'
user1 = user(ji, name, array[jid]['groups'], show, \
- array[jid]['status'], array[jid]['sub'], resource, 0, '')
+ array[jid]['status'], array[jid]['sub'], array[jid]['ask'], \
+ resource, 0, '')
#when we draw the roster, we can't have twice the same user with
# 2 resources
self.contacts[account][ji] = [user1]
@@ -1298,7 +1307,7 @@ class roster_Window:
self.plugin.send('SUB', account, (jid, txt))
if not self.contacts[account].has_key(jid):
user1 = user(jid, jid, ['general'], 'requested', \
- 'requested', 'sub', '', 0, '')
+ 'requested', 'none', 'subscribe', '', 0, '')
self.contacts[account][jid] = [user1]
self.add_user_to_roster(jid, account)
@@ -1452,7 +1461,7 @@ class roster_Window:
"""when we receive a message"""
if not self.contacts[account].has_key(jid):
user1 = user(jid, jid, ['not in list'], \
- 'not in list', 'not in list', 'none', '', 0, '')
+ 'not in list', 'not in list', 'none', None, '', 0, '')
self.contacts[account][jid] = [user1]
self.add_user_to_roster(jid, account)
iters = self.get_user_iter(jid, account)
@@ -1544,7 +1553,6 @@ class roster_Window:
self.close_all(self.plugin.windows)
self.plugin.systray.t.destroy()
gtk.main_quit()
-# gtk.gdk.threads_leave()
def on_row_activated(self, widget, path, col=0):
"""When an iter is dubble clicked :
@@ -2155,8 +2163,8 @@ class plugin:
user1 = self.roster.contacts[account][ji][0]
if (resources != [''] and (len(luser) != 1 or
luser[0].show != 'offline')) and not string.find(jid, "@") <= 0:
- user1 = user(user1.jid, user1.name, user1.groups, \
- user1.show, user1.status, user1.sub, user1.resource, \
+ user1 = user(user1.jid, user1.name, user1.groups, user1.show, \
+ user1.status, user1.sub, user1.ask, user1.resource, \
user1.priority, user1.keyID)
luser.append(user1)
user1.resource = resource
@@ -2207,7 +2215,7 @@ class plugin:
self.roster.redraw_jid(u.jid, account)
else:
user1 = user(jid, jid, ['general'], 'online', \
- 'online', 'to', array[2], 0, '')
+ 'online', 'to', '', array[2], 0, '')
self.roster.contacts[account][jid] = [user1]
self.roster.add_user_to_roster(jid, account)
warning_Window(_("You are now authorized by %s") % jid)
@@ -2317,6 +2325,24 @@ class plugin:
if self.windows.has_key('gpg_keys'):
self.windows['gpg_keys'].fill_tree(keys)
+ def handle_event_roster_info(self, account, array):
+ #('ROSTER_INFO', account, (jid, name, sub, ask, groups))
+ jid = array[0]
+ if not self.roster.contacts[account].has_key(jid):
+ return
+ users = self.roster.contacts[account][jid]
+ if not (array[2] or array[3]):
+ self.roster.remove_user(users[0], account)
+ del self.roster.contacts[account][jid]
+ #TODO if it was the only one in its group, remove the group
+ return
+ for user in users:
+ user.name = array[1]
+ user.sub = array[2]
+ user.ask = array[3]
+ user.groups = array[4]
+ self.roster.redraw_jid(jid, account)
+
def read_queue(self):
"""Read queue from the core and execute commands from it"""
while self.queueIN.empty() == 0:
@@ -2363,6 +2389,8 @@ class plugin:
self.handle_event_bad_passphrase(ev[1], ev[2])
elif ev[0] == 'GPG_SECRETE_KEYS':
self.handle_event_gpg_secrete_keys(ev[1], ev[2])
+ elif ev[0] == 'ROSTER_INFO':
+ self.handle_event_roster_info(ev[1], ev[2])
return 1
def read_sleepy(self):
@@ -2401,7 +2429,8 @@ class plugin:
'NOTIFY', 'MSG', 'MSGERROR', 'SUBSCRIBED', 'UNSUBSCRIBED', \
'SUBSCRIBE', 'AGENTS', 'AGENT_INFO', 'REG_AGENT_INFO', 'QUIT', \
'ACC_OK', 'CONFIG', 'MYVCARD', 'VCARD', 'LOG_NB_LINE', 'LOG_LINE', \
- 'VISUAL', 'GC_MSG', 'BAD_PASSPHRASE', 'GPG_SECRETE_KEYS'])
+ 'VISUAL', 'GC_MSG', 'BAD_PASSPHRASE', 'GPG_SECRETE_KEYS', \
+ 'ROSTER_INFO'])
self.send('ASK_CONFIG', None, ('GtkGui', 'GtkGui', {'autopopup':1,\
'autopopupaway':1,\
'showoffline':0,\