name is saved when subscribing a new contact
This commit is contained in:
parent
49ac2dd720
commit
aad2444309
|
@ -28,7 +28,7 @@ class GajimHub:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.queues = {}
|
self.queues = {}
|
||||||
""" {event1:[queue1, queue2]} """
|
""" {event1:[queue1, queue2]} """
|
||||||
self.events = {'NOTIFY':[], 'MSG':[], 'ROSTER':[]}
|
self.events = {}
|
||||||
self.queueIn = self.newQueue('in', 100)
|
self.queueIn = self.newQueue('in', 100)
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
|
@ -49,7 +49,10 @@ class GajimHub:
|
||||||
def register(self, name, event):
|
def register(self, name, event):
|
||||||
""" Records a plugin from an event """
|
""" Records a plugin from an event """
|
||||||
qu = self.queues[name]
|
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
|
# END register
|
||||||
|
|
||||||
def sendPlugin(self, event, data):
|
def sendPlugin(self, event, data):
|
||||||
|
|
|
@ -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 xmlstream
|
||||||
import sha, time
|
import sha, time
|
||||||
|
@ -722,12 +722,16 @@ class Client(Connection):
|
||||||
"""
|
"""
|
||||||
iq = Iq(type='set')
|
iq = Iq(type='set')
|
||||||
item = iq.setQuery(NS_ROSTER).insertTag('item')
|
item = iq.setQuery(NS_ROSTER).insertTag('item')
|
||||||
item.putAtrr('jid', str(jid))
|
item.putAttr('jid', str(jid))
|
||||||
if name != None: item.putAtrr('name', name)
|
if name != None: item.putAttr('name', name)
|
||||||
if groups != None:
|
if groups != None:
|
||||||
for group in groups:
|
for group in groups:
|
||||||
item.insertTag('group').insertData(group)
|
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):
|
def removeRosterItem(self,jid):
|
||||||
|
|
21
core/core.py
21
core/core.py
|
@ -70,6 +70,7 @@ class GajimCore:
|
||||||
jid = prs.getFrom()
|
jid = prs.getFrom()
|
||||||
self.hub.sendPlugin('SUBSCRIBED', {'jid':jid.getBasic(), \
|
self.hub.sendPlugin('SUBSCRIBED', {'jid':jid.getBasic(), \
|
||||||
'nom':jid.getNode()})
|
'nom':jid.getNode()})
|
||||||
|
self.con.updateRosterItem(jid=jid.getBasic(), name=jid.getNode())
|
||||||
log.debug("we are now subscribed to %s" % who)
|
log.debug("we are now subscribed to %s" % who)
|
||||||
elif type == 'unsubscribe':
|
elif type == 'unsubscribe':
|
||||||
log.debug("unsubscribe request from %s" % who)
|
log.debug("unsubscribe request from %s" % who)
|
||||||
|
@ -81,7 +82,7 @@ class GajimCore:
|
||||||
def disconnectedCB(self, con):
|
def disconnectedCB(self, con):
|
||||||
log.debug("disconnectedCB")
|
log.debug("disconnectedCB")
|
||||||
# END disconenctedCB
|
# END disconenctedCB
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.con = common.jabber.Client(host = \
|
self.con = common.jabber.Client(host = \
|
||||||
self.cfgParser.Server_hostname, \
|
self.cfgParser.Server_hostname, \
|
||||||
|
@ -103,24 +104,7 @@ class GajimCore:
|
||||||
|
|
||||||
self.con.requestRoster()
|
self.con.requestRoster()
|
||||||
roster = self.con.getRoster().getRaw()
|
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)
|
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.con.sendInitPresence()
|
||||||
self.connected = 1
|
self.connected = 1
|
||||||
else:
|
else:
|
||||||
|
@ -180,5 +164,6 @@ def start():
|
||||||
gc.hub.register('gtkgui', 'ROSTER')
|
gc.hub.register('gtkgui', 'ROSTER')
|
||||||
gc.hub.register('gtkgui', 'NOTIFY')
|
gc.hub.register('gtkgui', 'NOTIFY')
|
||||||
gc.hub.register('gtkgui', 'MSG')
|
gc.hub.register('gtkgui', 'MSG')
|
||||||
|
gc.hub.register('gtkgui', 'SUBSCRIBED')
|
||||||
guiPl.load ()
|
guiPl.load ()
|
||||||
gc.mainLoop()
|
gc.mainLoop()
|
||||||
|
|
|
@ -1382,7 +1382,7 @@ David Ferlier (david@yazzy.org)</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="editable">True</property>
|
<property name="editable">True</property>
|
||||||
<property name="justification">GTK_JUSTIFY_LEFT</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="cursor_visible">True</property>
|
||||||
<property name="pixels_above_lines">0</property>
|
<property name="pixels_above_lines">0</property>
|
||||||
<property name="pixels_below_lines">0</property>
|
<property name="pixels_below_lines">0</property>
|
||||||
|
|
|
@ -161,7 +161,13 @@ class roster:
|
||||||
""" l_group = {name:iter} """
|
""" l_group = {name:iter} """
|
||||||
self.l_group = {}
|
self.l_group = {}
|
||||||
for jid in tab.keys():
|
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':[]}
|
self.l_contact[user1.jid] = {'user':user1, 'iter':[]}
|
||||||
if user1.groups == []:
|
if user1.groups == []:
|
||||||
user1.groups.append('general')
|
user1.groups.append('general')
|
||||||
|
|
Loading…
Reference in New Issue