support of error messages

This commit is contained in:
Yann Leboulanger 2004-07-08 19:46:24 +00:00
parent 41d171fc68
commit 125cdb2a46
2 changed files with 18 additions and 2 deletions

View File

@ -118,8 +118,13 @@ class GajimCore:
def messageCB(self, con, msg):
"""Called when we recieve a message"""
self.hub.sendPlugin('MSG', self.connexions[con], \
(str(msg.getFrom()), msg.getBody()))
if msg.getType() == 'error':
self.hub.sendPlugin('MSGERROR', self.connexions[con], \
(str(msg.getFrom()), msg.getErrorCode(), msg.getError(), \
msg.getBody()))
else:
self.hub.sendPlugin('MSG', self.connexions[con], \
(str(msg.getFrom()), msg.getBody()))
# END messageCB
def presenceCB(self, con, prs):
@ -522,6 +527,7 @@ def loadPlugins(gc):
gc.hub.register(mod, 'STATUS')
gc.hub.register(mod, 'NOTIFY')
gc.hub.register(mod, 'MSG')
gc.hub.register(mod, 'MSGERROR')
gc.hub.register(mod, 'MSGSENT')
gc.hub.register(mod, 'SUBSCRIBED')
gc.hub.register(mod, 'UNSUBSCRIBED')

View File

@ -1590,6 +1590,14 @@ class plugin:
jid = string.replace(jid, '@', '')
self.roster.on_message(jid, array[1], account)
def handle_event_msgerror(self, account, array):
#('MSG', account, (user, error_code, error_msg, msg))
jid = string.split(array[0], '/')[0]
if string.find(jid, "@") <= 0:
jid = string.replace(jid, '@', '')
self.roster.on_message(jid, _("error while sending") + " \"%s\" ( %s )"%\
(array[3], array[2]), account)
def handle_event_subscribe(self, account, array):
#('SUBSCRIBE', account, (jid, text))
authorize_Window(self, array[0], array[1], account)
@ -1695,6 +1703,8 @@ class plugin:
self.handle_event_notify(ev[1], ev[2])
elif ev[0] == 'MSG':
self.handle_event_msg(ev[1], ev[2])
elif ev[0] == 'MSGERROR':
self.handle_event_msgerror(ev[1], ev[2])
elif ev[0] == 'SUBSCRIBE':
self.handle_event_subscribe(ev[1], ev[2])
elif ev[0] == 'SUBSCRIBED':