ptype = el.getAttribute("type")
if ptype and (ptype.startswith("subscribe") or ptype.startswith("unsubscribe")):
LogEvent(INFO, self.jabberID, "Parsed subscription presence packet")
- self.subscriptionReceived(toj.userhost(), ptype)
+ self.subscriptionReceived(fro, toj.userhost(), ptype)
else:
status = None
show = None
""" Override this method to be notified when presence is received """
pass
- def subscriptionReceived(self, source, subtype):
+ def subscriptionReceived(self, source, dest, subtype):
""" Override this method to be notified when a subscription packet is received """
pass
elif ptype and (ptype.startswith("subscribe") or ptype.startswith("unsubscribe")):
# They haven't logged in, and are trying to change subscription to a user
+ # No, lets not log them in. Lets send an error :)
+ jabw.sendPresence(self, fro, to, ptype="error")
+
# Lets log them in and then do it
- LogEvent(INFO, "", "Attempting to create a session to do subscription stuff.")
- s = session.makeSession(self, froj.userhost(), ulang)
- if s:
- self.sessions[froj.userhost()] = s
- LogEvent(INFO, "", "New session created.")
- # Tell the session there's a new resource
- s.handleResourcePresence(froj.userhost(), froj.resource, toj.userhost(), toj.resource, 0, None, None, None)
- # Send this subscription
- s.onPresence(el)
+ #LogEvent(INFO, "", "Attempting to create a session to do subscription stuff.")
+ #s = session.makeSession(self, froj.userhost(), ulang)
+ #if s:
+ # self.sessions[froj.userhost()] = s
+ # LogEvent(INFO, "", "New session created.")
+ # # Tell the session there's a new resource
+ # s.handleResourcePresence(froj.userhost(), froj.resource, toj.userhost(), toj.resource, 0, None, None, None)
+ # # Send this subscription
+ # s.onPresence(el)
class App:
del self.resourceList[resource]
self.legacycon.resourceOffline(resource)
- def subscriptionReceived(self, to, subtype):
+ def subscriptionReceived(self, fro, to, subtype):
""" Sends the subscription request to the legacy services handler """
if to.find('@') > 0:
- LogEvent(INFO, self.jabberID, "Passing subscription to legacy service.")
- self.contactList.jabberSubscriptionReceived(to, subtype)
+ if self.ready:
+ LogEvent(INFO, self.jabberID, "Passing subscription to legacy service.")
+ self.contactList.jabberSubscriptionReceived(to, subtype)
+ else:
+ self.sendPresence(fro, to, ptype="error")
else:
if subtype == "subscribe":
self.sendPresence(to=self.jabberID, fro=config.jid, ptype="subscribed")