X-Git-Url: https://code.delx.au/pymsnt/blobdiff_plain/cbe38882237ba2dff9191c266ddc04a5e78ebba4..ab3667805a3bb1f43d9a3dcbfe74d3d15b0ea0fa:/src/main.py diff --git a/src/main.py b/src/main.py index 6be4c74..eb90dd4 100644 --- a/src/main.py +++ b/src/main.py @@ -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: