Skip to content
Snippets Groups Projects
Commit e8b6c78f authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

remove group iter from roster when empty

parent a833e968
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
""" """
# $Id: jabber.py,v 1.56 2004/01/08 15:48:59 snakeru Exp $ # $Id: jabber.py,v 1.4 2004/01/14 01:06:27 asterix86 Exp $
import xmlstream import xmlstream
import sha, time import sha, time
...@@ -373,18 +373,13 @@ def waitForResponse(self, ID, timeout=timeout): ...@@ -373,18 +373,13 @@ def waitForResponse(self, ID, timeout=timeout):
self.DEBUG("waiting for %s" % ustr(ID),DBG_NODE_IQ) self.DEBUG("waiting for %s" % ustr(ID),DBG_NODE_IQ)
while (not self._expected[ID]) and not has_timed_out: while (not self._expected[ID]) and not has_timed_out:
print "tjs pas"
if not self.process(0.2): return None if not self.process(0.2): return None
if timeout and (time.time() > abort_time): if timeout and (time.time() > abort_time):
print "Timeout"
has_timed_out = True has_timed_out = True
if has_timed_out: if has_timed_out:
print "\n timeOut "
self.lastErr = "Timeout" self.lastErr = "Timeout"
return None return None
print "On a eut la rep"
response = self._expected[ID] response = self._expected[ID]
print response
del self._expected[ID] del self._expected[ID]
if response.getErrorCode(): if response.getErrorCode():
self.lastErr = response.getError() self.lastErr = response.getError()
......
...@@ -112,7 +112,8 @@ def connect(self, account): ...@@ -112,7 +112,8 @@ def connect(self, account):
password = self.cfgParser.__getattr__("%s" % account+"_password") password = self.cfgParser.__getattr__("%s" % account+"_password")
ressource = self.cfgParser.__getattr__("%s" % account+"_ressource") ressource = self.cfgParser.__getattr__("%s" % account+"_ressource")
self.con = common.jabber.Client(host = \ self.con = common.jabber.Client(host = \
hostname, debug = [common.jabber.DBG_ALWAYS], log = sys.stderr) hostname, debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, connection=common.xmlstream.TCP, port=5222)
# hostname, debug = [common.jabber.DBG_ALWAYS], log = sys.stderr, connection=common.xmlstream.TCP_SSL, port=5223)
try: try:
self.con.connect() self.con.connect()
except IOError, e: except IOError, e:
......
...@@ -517,7 +517,7 @@ ...@@ -517,7 +517,7 @@
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property> <property name="wrap">True</property>
<property name="selectable">False</property> <property name="selectable">False</property>
<property name="xalign">0.95</property> <property name="xalign">0.95</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
...@@ -3231,7 +3231,7 @@ when NOT onlie</property> ...@@ -3231,7 +3231,7 @@ when NOT onlie</property>
<widget class="GtkDialog" id="Away_msg"> <widget class="GtkDialog" id="Away_msg">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">dialog1</property> <property name="title" translatable="yes">Message</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property> <property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property> <property name="modal">False</property>
...@@ -3952,18 +3952,4 @@ when NOT onlie</property> ...@@ -3952,18 +3952,4 @@ when NOT onlie</property>
</child> </child>
</widget> </widget>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<child>
<placeholder/>
</child>
</widget>
</glade-interface> </glade-interface>
...@@ -770,13 +770,19 @@ def add_user(self, u): ...@@ -770,13 +770,19 @@ def add_user(self, u):
if u.show != 'offline' or self.showOffline or 'Agents' in u.groups: if u.show != 'offline' or self.showOffline or 'Agents' in u.groups:
for g in u.groups: for g in u.groups:
if not self.l_group.has_key(g): if not self.l_group.has_key(g):
self.l_group[g] = {'iter':None, 'hide':False}
if not self.l_group[g]['iter']:
iterG = self.treestore.append(None, (self.pixbufs['closed'], g, 'group', FALSE, self.grpbgcolor, TRUE)) iterG = self.treestore.append(None, (self.pixbufs['closed'], g, 'group', FALSE, self.grpbgcolor, TRUE))
self.l_group[g] = iterG self.l_group[g] = {'iter':iterG, 'hide':False}
newgrp = 1 newgrp = 1
if g == 'Agents': if g == 'Agents':
iterU = self.treestore.append(self.l_group[g], (self.pixbufs[u.show], u.name, 'agent', FALSE, self.userbgcolor, TRUE)) iterU = self.treestore.append(self.l_group[g]['iter'], \
(self.pixbufs[u.show], u.name, 'agent', FALSE, \
self.userbgcolor, TRUE))
else: else:
iterU = self.treestore.append(self.l_group[g], (self.pixbufs[u.show], u.name, u.jid, TRUE, self.userbgcolor, TRUE)) iterU = self.treestore.append(self.l_group[g]['iter'], \
(self.pixbufs[u.show], u.name, u.jid, TRUE, \
self.userbgcolor, TRUE))
self.l_contact[u.jid]['iter'].append(iterU) self.l_contact[u.jid]['iter'].append(iterU)
if newgrp == 1: if newgrp == 1:
#expand new groups #expand new groups
...@@ -785,7 +791,8 @@ def add_user(self, u): ...@@ -785,7 +791,8 @@ def add_user(self, u):
def redraw_roster(self): def redraw_roster(self):
for j in self.l_contact.keys(): for j in self.l_contact.keys():
self.l_contact[j]['iter'] = [] self.l_contact[j]['iter'] = []
self.l_group = {} for g in self.l_group.keys():
self.l_group[g]['iter'] = None
self.draw_roster() self.draw_roster()
def draw_roster(self): def draw_roster(self):
...@@ -808,6 +815,9 @@ def mklists(self, tab): ...@@ -808,6 +815,9 @@ def mklists(self, tab):
show = 'offline' show = 'offline'
user1 = user(ji, name, tab[jid]['groups'], show, tab[jid]['status'], tab[jid]['sub'], '') user1 = user(ji, name, tab[jid]['groups'], show, tab[jid]['status'], tab[jid]['sub'], '')
self.l_contact[ji] = {'user':user1, 'iter':[]} self.l_contact[ji] = {'user':user1, 'iter':[]}
for i in tab[jid]['groups'] :
if not i in self.l_group.keys():
self.l_group[i] = {'iter':None, 'hide':False}
def update_iter(self, widget, path, iter, data): def update_iter(self, widget, path, iter, data):
jid = self.treestore.get_value(iter, 2) jid = self.treestore.get_value(iter, 2)
...@@ -829,7 +839,14 @@ def chg_status(self, jid, show, status): ...@@ -829,7 +839,14 @@ def chg_status(self, jid, show, status):
else: else:
if show == 'offline' and not self.showOffline: if show == 'offline' and not self.showOffline:
for i in self.l_contact[jid]['iter']: for i in self.l_contact[jid]['iter']:
self.treestore.remove(i) parent_i = self.treestore.iter_parent(i)
if self.treestore.iter_n_children(parent_i) == 1:
self.treestore.remove(i)
grp = self.treestore.get_value(parent_i, 1)
self.treestore.remove(parent_i)
self.l_group[grp]['iter'] = None
else:
self.treestore.remove(i)
self.l_contact[jid]['iter'] = [] self.l_contact[jid]['iter'] = []
else: else:
for i in self.l_contact[jid]['iter']: for i in self.l_contact[jid]['iter']:
...@@ -913,7 +930,7 @@ def init_tree(self): ...@@ -913,7 +930,7 @@ def init_tree(self):
self.treestore.clear() self.treestore.clear()
#l_contact = {jid:{'user':_, 'iter':[iter1, ...]] #l_contact = {jid:{'user':_, 'iter':[iter1, ...]]
self.l_contact = {} self.l_contact = {}
#l_group = {name:iter} #l_group = {name:{'iter':_, 'hide':Bool}
self.l_group = {} self.l_group = {}
def on_treeview_event(self, widget, event): def on_treeview_event(self, widget, event):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment