new indentation
This commit is contained in:
parent
125cdb2a46
commit
60fdfc66e5
|
@ -24,45 +24,45 @@ import common.thread
|
||||||
""" Hub definitions """
|
""" Hub definitions """
|
||||||
|
|
||||||
class GajimHub:
|
class GajimHub:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.queues = {}
|
self.queues = {}
|
||||||
""" {event1:[queue1, queue2]} """
|
# {event1:[queue1, queue2]}
|
||||||
self.events = {}
|
self.events = {}
|
||||||
self.queueIn = self.newQueue('in', 100)
|
self.queueIn = self.newQueue('in', 100)
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
def newQueue(self, name, size):
|
def newQueue(self, name, size):
|
||||||
""" Creates a new queue """
|
""" Creates a new queue """
|
||||||
qu = Queue.Queue(size)
|
qu = Queue.Queue(size)
|
||||||
self.queues[name] = qu
|
self.queues[name] = qu
|
||||||
return qu
|
return qu
|
||||||
# END newQueue
|
# END newQueue
|
||||||
|
|
||||||
def newPlugin(self, name):
|
def newPlugin(self, name):
|
||||||
"""Creates a new Plugin """
|
"""Creates a new Plugin """
|
||||||
qu = self.newQueue(name, 100)
|
qu = self.newQueue(name, 100)
|
||||||
pl = common.plugin.GajimPlugin(name, qu, self.queueIn)
|
pl = common.plugin.GajimPlugin(name, qu, self.queueIn)
|
||||||
return pl
|
return pl
|
||||||
# END newPlugin
|
# END newPlugin
|
||||||
|
|
||||||
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]
|
||||||
if self.events.has_key(event) :
|
if self.events.has_key(event) :
|
||||||
self.events[event].append(qu)
|
self.events[event].append(qu)
|
||||||
else :
|
else :
|
||||||
self.events[event] = [qu]
|
self.events[event] = [qu]
|
||||||
# END register
|
# END register
|
||||||
|
|
||||||
def sendPlugin(self, event, con, data):
|
def sendPlugin(self, event, con, data):
|
||||||
""" Sends an event to registered plugins
|
""" Sends an event to registered plugins
|
||||||
NOTIFY : ('NOTIFY', (user, status, message))
|
NOTIFY : ('NOTIFY', (user, status, message))
|
||||||
MSG : ('MSG', (user, msg))
|
MSG : ('MSG', (user, msg))
|
||||||
ROSTER : ('ROSTER', {jid:{'status':_, 'name':_, 'show':_, 'groups':[], 'online':_, 'ask':_, 'sub':_} ,jid:{}})
|
ROSTER : ('ROSTER', {jid:{'status':_, 'name':_, 'show':_, 'groups':[], 'online':_, 'ask':_, 'sub':_} ,jid:{}})
|
||||||
SUBSCRIBED : ('SUBSCRIBED', {'jid':_, 'nom':_, 'server':_, 'resource':_, 'status':_, 'show':_})"""
|
SUBSCRIBED : ('SUBSCRIBED', {'jid':_, 'nom':_, 'server':_, 'resource':_, 'status':_, 'show':_})"""
|
||||||
|
|
||||||
if self.events.has_key(event):
|
if self.events.has_key(event):
|
||||||
for i in self.events[event]:
|
for i in self.events[event]:
|
||||||
i.put((event, con, data))
|
i.put((event, con, data))
|
||||||
# END sendPlugin
|
# END sendPlugin
|
||||||
# END GajimHub
|
# END GajimHub
|
||||||
|
|
Loading…
Reference in New Issue