gtkgui plugin ask roster when it starts (in case an account is already conected)\nthread in started in plugin.py

This commit is contained in:
Yann Leboulanger 2004-08-01 16:25:41 +00:00
parent d50105fbca
commit 9fc8e66770
4 changed files with 24 additions and 15 deletions

View File

@ -22,15 +22,15 @@ import common.thread
""" Plugin definitions """
class GajimPlugin:
def __init__(self, name, queueIn, queueOut):
""" queueIn is a queue to interact from the hub to the plugin """
self.name = name
self.queueIn = queueIn
self.queueOut= queueOut
# END __init__
def __init__(self, name, queueIn, queueOut):
""" queueIn is a queue to interact from the hub to the plugin """
self.name = name
self.queueIn = queueIn
self.queueOut= queueOut
# END __init__
def load(self):
self.thr = common.thread.GajimThread(self.name, self.queueIn, \
self.queueOut)
# END load
def load(self):
thr = common.thread.GajimThread(self.name, self.queueIn, self.queueOut)
thr.start()
# END load
# END GajimPlugin

View File

@ -30,7 +30,6 @@ class GajimThread(threading.Thread):
self.queueOut = queueOut
threading.Thread.__init__(self, target = self.run, \
name = name)
self.start()
# END __init__
def run(self):

View File

@ -306,7 +306,7 @@ class GajimCore:
roster = con.getRoster().getRaw()
if not roster :
roster = {}
self.hub.sendPlugin('ROSTER', account, roster)
self.hub.sendPlugin('ROSTER', account, (0, roster))
self.connected[account] = 1
return con
else:
@ -362,6 +362,13 @@ class GajimCore:
con.disconnect()
self.hub.sendPlugin('QUIT', None, ())
return 1
#('ASK_ROSTER', account, queue_for_response)
elif ev[0] == 'ASK_ROSTER':
roster = {}
if con:
roster = con.getRoster().getRaw()
self.hub.sendPlugin('ROSTER', ev[1], (self.connected[ev[1]], \
roster), ev[2])
#('ASK_CONFIG', account, (who_ask, section, default_config))
elif ev[0] == 'ASK_CONFIG':
if ev[2][1] == 'accounts':

View File

@ -1577,12 +1577,14 @@ class plugin:
#Save messages
temp_q.put(ev)
def handle_event_roster(self, account, array):
self.roster.mklists(array, account)
def handle_event_roster(self, account, data):
#('ROSTER', account, (state, array))
statuss = ['offline', 'online', 'away', 'xa', 'dnd', 'invisible']
self.roster.on_status_changed(account, statuss[data[0]])
self.roster.mklists(data[1], account)
self.roster.draw_roster()
def handle_event_warning(self, unused, msg):
#('ROSTER', account, array)
warning_Window(msg)
def handle_event_status(self, account, status):
@ -1848,6 +1850,7 @@ class plugin:
#1:online and use sleeper
#2:autoaway and use sleeper
#3:autoxa and use sleeper
self.send('ASK_ROSTER', a, self.queueIN)
self.roster = roster_Window(self)
gtk.timeout_add(100, self.read_queue)
gtk.timeout_add(1000, self.read_sleepy)