]> code.delx.au - pymsnt/commitdiff
Subscription requests outside of sessions are now responded to with an error
authorjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Wed, 31 May 2006 10:41:48 +0000 (10:41 +0000)
committerjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Wed, 31 May 2006 10:41:48 +0000 (10:41 +0000)
git-svn-id: http://delx.cjb.net/svn/pymsnt/trunk@169 55fbd22a-6204-0410-b2f0-b6c764c7e90a

committer: jamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>

src/jabw.py
src/main.py
src/session.py

index 95ba8693ec2898865eb02d8457d49dad2df5a5db..e6f2897302744288a6dd37df0396c0fc149cb954 100644 (file)
@@ -253,7 +253,7 @@ class JabberConnection:
                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
@@ -299,7 +299,7 @@ class JabberConnection:
                """ 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
        
index a2a5b105c9cca7efe9ea7da13b25626b2d345b3c..f153b5a8bb6544a7f65c6742d2dc912918f84c0c 100644 (file)
@@ -304,16 +304,19 @@ class PyTransport(component.Service):
                        
                        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:
index 19dfd305e72ce2af3adaea79ea2a7c7aaa0db212..f4d11bd629650f682ab478cb6e509c249117a281 100644 (file)
@@ -329,11 +329,14 @@ class Session(jabw.JabberConnection):
                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")