diff --git a/sat b/sat.tac old mode 100755 new mode 100644 similarity index 96% rename from sat rename to sat.tac index 94d88073..d0407f9e --- a/sat +++ b/sat.tac @@ -20,6 +20,7 @@ along with this program. If not, see . """ +from twisted.application import internet, service from twisted.internet import glib2reactor, protocol glib2reactor.install() @@ -51,7 +52,7 @@ logging.basicConfig(level=logging.DEBUG, class SAT: def __init__(self): - self.reactor=reactor + #self.reactor=reactor self.memory=Memory() self.server_features=[] #XXX: temp dic, need to be transfered into self.memory in the future self.connected=False #FIXME: use twisted var instead @@ -97,18 +98,21 @@ class SAT: self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self) def connect(self): - print "Connect !" - if (self.connected): + print "connecting..." + + def getService(self): + print "GetService !" + """if (self.connected): info("already connected !") - return - info("Connecting...") + return""" + info("Getting client...") self.me = jid.JID(self.memory.getParamV("JabberID", "Connection")) self.factory = client.XMPPClientFactory(self.me, self.memory.getParamV("Password", "Connection")) self.factory.addBootstrap(xmlstream.STREAM_AUTHD_EVENT,self.authd) self.factory.addBootstrap(xmlstream.INIT_FAILED_EVENT,self.failed) - reactor.connectTCP(self.memory.getParamV("Server", "Connection"), 5222, self.factory) self.connectionStatus="online" #TODO: check if connection is OK self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory + return internet.TCPClient(self.memory.getParamV("Server", "Connection"), 5222, self.factory) def disconnect(self): if (not self.connected): @@ -367,8 +371,11 @@ class SAT: return data -app=SAT() #TODO: tmp, use twisted way instead -app.run() +application = service.Application('SàT') +sat = SAT() +service = sat.getService() +service.setServiceParent(application) -app.memory.save() #FIXME: not the best place -debug("Good Bye") + +#app.memory.save() #FIXME: not the best place +#debug("Good Bye")