]> code.delx.au - pymsnt/blobdiff - src/main.py
Made no reactor error a bit clearer.
[pymsnt] / src / main.py
index 6be4c742b811403765ba08a646d28df013c6f307..eb90dd4e467c6951346c9ab3a3697f9cb7a393b4 100644 (file)
@@ -25,7 +25,7 @@ except:
                                        from twisted.internet import default as bestreactor
                                        print selectWarning
                                except:
-                                       print "Unable to find a reactor.\nExiting..."
+                                       print "Unable to find a reactor. Please make sure you have Twisted properly installed.\nExiting..."
                                        sys.exit(1)
 bestreactor.install()
 
@@ -116,7 +116,7 @@ class PyTransport(component.Service):
        def __init__(self):
                LogEvent(INFO)
                try:
-                       LogEvent(INFO, msg="SVN r" + svninfo.getSVNVersion())
+                       LogEvent(INFO, msg="SVN r" + str(svninfo.getSVNVersion()))
                except:
                        pass
 
@@ -260,6 +260,7 @@ class PyTransport(component.Service):
                                        body = child.__str__()
                        LogEvent(INFO, "", "Sending error response to a message outside of session.")
                        jabw.sendErrorMessage(self, fro, to, "auth", "not-authorized", lang.get(ulang).notLoggedIn, body)
+                       jabw.sendPresence(self, fro, to, ptype="unavailable")
        
        def onPresence(self, el):
                fro = el.getAttribute("from")
@@ -298,25 +299,24 @@ class PyTransport(component.Service):
                                
                                elif el.getAttribute("type") != "error":
                                        LogEvent(INFO, "", "Sending unavailable presence to non-logged in user.")
-                                       pres = Element((None, "presence"))
-                                       pres.attributes["from"] = to
-                                       pres.attributes["to"] = fro
-                                       pres.attributes["type"] = "unavailable"
-                                       self.send(pres)
+                                       jabw.sendPresence(self, fro, to, ptype="unavailable")
                                        return
                        
                        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: