name is saved when subscribing a new contact

This commit is contained in:
Yann Leboulanger 2003-11-01 19:41:35 +00:00
parent 49ac2dd720
commit aad2444309
5 changed files with 24 additions and 26 deletions

View File

@ -28,7 +28,7 @@ class GajimHub:
def __init__(self):
self.queues = {}
""" {event1:[queue1, queue2]} """
self.events = {'NOTIFY':[], 'MSG':[], 'ROSTER':[]}
self.events = {}
self.queueIn = self.newQueue('in', 100)
# END __init__
@ -49,7 +49,10 @@ class GajimHub:
def register(self, name, event):
""" Records a plugin from an event """
qu = self.queues[name]
self.events[event].append(qu)
if self.events.has_key(event) :
self.events[event].append(qu)
else :
self.events[event] = [qu]
# END register
def sendPlugin(self, event, data):

View File

@ -62,7 +62,7 @@ An example of usage for a simple client would be ( only psuedo code !)
"""
# $Id: jabber.py,v 1.30 2003/02/20 10:22:33 shire Exp $
# $Id: jabber.py,v 1.1.1.1 2003/10/22 18:45:18 tab Exp $
import xmlstream
import sha, time
@ -722,12 +722,16 @@ class Client(Connection):
"""
iq = Iq(type='set')
item = iq.setQuery(NS_ROSTER).insertTag('item')
item.putAtrr('jid', str(jid))
if name != None: item.putAtrr('name', name)
item.putAttr('jid', str(jid))
if name != None: item.putAttr('name', name)
if groups != None:
for group in groups:
item.insertTag('group').insertData(group)
dummy = self.sendAndWaitForResponse(iq) # Do we need to wait??
ID = self.getAnID()
iq.setID(ID)
ID = str(ID)
self.send(iq)
# dummy = self.SendAndWaitForResponse(iq) # Do we need to wait??
def removeRosterItem(self,jid):

View File

@ -70,6 +70,7 @@ class GajimCore:
jid = prs.getFrom()
self.hub.sendPlugin('SUBSCRIBED', {'jid':jid.getBasic(), \
'nom':jid.getNode()})
self.con.updateRosterItem(jid=jid.getBasic(), name=jid.getNode())
log.debug("we are now subscribed to %s" % who)
elif type == 'unsubscribe':
log.debug("unsubscribe request from %s" % who)
@ -81,7 +82,7 @@ class GajimCore:
def disconnectedCB(self, con):
log.debug("disconnectedCB")
# END disconenctedCB
def connect(self):
self.con = common.jabber.Client(host = \
self.cfgParser.Server_hostname, \
@ -103,24 +104,7 @@ class GajimCore:
self.con.requestRoster()
roster = self.con.getRoster().getRaw()
for jid in roster.keys():
if not roster[jid]['show']:
roster[jid]['show'] = roster[jid]['online']
if not roster[jid]['name']:
roster[jid]['name'] = ''
self.hub.sendPlugin('ROSTER', roster)
# tab_roster = {}
# for jid in roster.getJIDs():
# if roster.getShow(jid):
# show = roster.getShow(jid)
# else:
# show = roster.getOnline(jid)
# tab_roster[jid.getBasic()] = \
# {"Online":roster.getOnline(jid), "nom":jid.getNode(), \
# "server":jid.getDomain(), "resource":jid.getResource(), \
# "group":'general', "status":roster.getStatus(jid), \
# "show":show}
# self.hub.sendPlugin('ROSTER', tab_roster)
self.con.sendInitPresence()
self.connected = 1
else:
@ -180,5 +164,6 @@ def start():
gc.hub.register('gtkgui', 'ROSTER')
gc.hub.register('gtkgui', 'NOTIFY')
gc.hub.register('gtkgui', 'MSG')
gc.hub.register('gtkgui', 'SUBSCRIBED')
guiPl.load ()
gc.mainLoop()

View File

@ -1382,7 +1382,7 @@ David Ferlier (david@yazzy.org)</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>

View File

@ -161,7 +161,13 @@ class roster:
""" l_group = {name:iter} """
self.l_group = {}
for jid in tab.keys():
user1 = user(jid, tab[jid]['name'], tab[jid]['groups'], tab[jid]['show'], tab[jid]['status'], tab[jid]['sub'])
name = tab[jid]['name']
if not name :
name = ''
show = tab[jid]['show']
if not show :
show = 'offline'
user1 = user(jid, name, tab[jid]['groups'], show, tab[jid]['status'], tab[jid]['sub'])
self.l_contact[user1.jid] = {'user':user1, 'iter':[]}
if user1.groups == []:
user1.groups.append('general')