Correct remove transport bug
- deleting transport in roster was deleting every accounts in JMC (even those not registered by the user) darcs-hash:20060713120500-684f5-30ba3b058642b8df92e5b56ae34f78236ba6ff95.gz
This commit is contained in:
@@ -533,7 +533,8 @@ class MailComponent(Component):
|
|||||||
remove = iq.xpath_eval("r:query/r:remove", \
|
remove = iq.xpath_eval("r:query/r:remove", \
|
||||||
{"r" : "jabber:iq:register"})
|
{"r" : "jabber:iq:register"})
|
||||||
if remove:
|
if remove:
|
||||||
for jid, name in self.__storage.keys():
|
for name in self.__storage.keys((base_from_jid,)):
|
||||||
|
self.__logger.debug("Deleting " + name + " for " + base_from_jid)
|
||||||
p = Presence(from_jid = name + "@" + unicode(self.jid), \
|
p = Presence(from_jid = name + "@" + unicode(self.jid), \
|
||||||
to_jid = from_jid, \
|
to_jid = from_jid, \
|
||||||
stanza_type = "unsubscribe")
|
stanza_type = "unsubscribe")
|
||||||
@@ -542,7 +543,7 @@ class MailComponent(Component):
|
|||||||
to_jid = from_jid, \
|
to_jid = from_jid, \
|
||||||
stanza_type = "unsubscribed")
|
stanza_type = "unsubscribed")
|
||||||
self.stream.send(p)
|
self.stream.send(p)
|
||||||
del self.__storage[(jid, name)]
|
del self.__storage[(base_from_jid, name)]
|
||||||
p = Presence(from_jid = self.jid, to_jid = from_jid, \
|
p = Presence(from_jid = self.jid, to_jid = from_jid, \
|
||||||
stanza_type = "unsubscribe")
|
stanza_type = "unsubscribe")
|
||||||
self.stream.send(p)
|
self.stream.send(p)
|
||||||
@@ -693,13 +694,33 @@ class MailComponent(Component):
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
def __send_presence_available(self, name, to_account, to_jid, show, lang_class):
|
||||||
|
to_account.default_lang_class = lang_class
|
||||||
|
to_account.first_check = True
|
||||||
|
old_status = to_account.status
|
||||||
|
# Make available to receive mail only when online
|
||||||
|
if show is None:
|
||||||
|
to_account.status = "online" # TODO get real status = (not show)
|
||||||
|
else:
|
||||||
|
to_account.status = show
|
||||||
|
p = Presence(from_jid = name + "@" + \
|
||||||
|
unicode(self.jid), \
|
||||||
|
to_jid = to_jid, \
|
||||||
|
status = to_account.get_status_msg(), \
|
||||||
|
show = show, \
|
||||||
|
stanza_type = "available")
|
||||||
|
self.stream.send(p)
|
||||||
|
if to_account.store_password == False \
|
||||||
|
and old_status == "offline":
|
||||||
|
self.__ask_password(name, to_jid, lang_class, to_account)
|
||||||
|
|
||||||
""" Handle presence availability """
|
""" Handle presence availability """
|
||||||
def presence_available(self, stanza):
|
def presence_available(self, stanza):
|
||||||
self.__logger.debug("PRESENCE_AVAILABLE")
|
self.__logger.debug("PRESENCE_AVAILABLE")
|
||||||
from_jid = stanza.get_from()
|
from_jid = stanza.get_from()
|
||||||
base_from_jid = unicode(from_jid.bare())
|
base_from_jid = unicode(from_jid.bare())
|
||||||
lang_class = self.__lang.get_lang_class_from_node(stanza.get_node())
|
|
||||||
name = stanza.get_to().node
|
name = stanza.get_to().node
|
||||||
|
lang_class = self.__lang.get_lang_class_from_node(stanza.get_node())
|
||||||
show = stanza.get_show()
|
show = stanza.get_show()
|
||||||
self.__logger.debug("SHOW : " + str(show))
|
self.__logger.debug("SHOW : " + str(show))
|
||||||
if name:
|
if name:
|
||||||
@@ -713,25 +734,12 @@ class MailComponent(Component):
|
|||||||
show = show, \
|
show = show, \
|
||||||
stanza_type = "available")
|
stanza_type = "available")
|
||||||
self.stream.send(p)
|
self.stream.send(p)
|
||||||
|
for name in self.__storage.keys((base_from_jid,)):
|
||||||
|
account = self.__storage[(base_from_jid, name)]
|
||||||
|
self.__send_presence_available(name, account, from_jid, show, lang_class)
|
||||||
elif self.__storage.has_key((base_from_jid, name)):
|
elif self.__storage.has_key((base_from_jid, name)):
|
||||||
account = self.__storage[(base_from_jid, name)]
|
account = self.__storage[(base_from_jid, name)]
|
||||||
account.default_lang_class = lang_class
|
self.__send_presence_available(name, account, from_jid, show, lang_class)
|
||||||
old_status = account.status
|
|
||||||
# Make available to receive mail only when online
|
|
||||||
if show is None:
|
|
||||||
account.status = "online" # TODO get real status = (not show)
|
|
||||||
else:
|
|
||||||
account.status = show
|
|
||||||
p = Presence(from_jid = name + "@" + \
|
|
||||||
unicode(self.jid), \
|
|
||||||
to_jid = from_jid, \
|
|
||||||
status = account.get_status_msg(), \
|
|
||||||
show = show, \
|
|
||||||
stanza_type = "available")
|
|
||||||
self.stream.send(p)
|
|
||||||
if account.store_password == False \
|
|
||||||
and old_status == "offline":
|
|
||||||
self.__ask_password(name, from_jid, lang_class, account)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def __ask_password(self, name, from_jid, lang_class, account):
|
def __ask_password(self, name, from_jid, lang_class, account):
|
||||||
@@ -752,7 +760,7 @@ class MailComponent(Component):
|
|||||||
from_jid = stanza.get_from()
|
from_jid = stanza.get_from()
|
||||||
base_from_jid = unicode(from_jid.bare())
|
base_from_jid = unicode(from_jid.bare())
|
||||||
if stanza.get_to() == unicode(self.jid):
|
if stanza.get_to() == unicode(self.jid):
|
||||||
for jid, name in self.__storage.keys():
|
for name in self.__storage.keys((base_from_jid,)):
|
||||||
account = self.__storage[(base_from_jid, name)]
|
account = self.__storage[(base_from_jid, name)]
|
||||||
account.status = "offline"
|
account.status = "offline"
|
||||||
account.waiting_password_reply = False
|
account.waiting_password_reply = False
|
||||||
|
|||||||
Reference in New Issue
Block a user