comparison sat @ 1:a06a151fc31f

Disconnect first draft
author Goffi <goffi@goffi.org>
date Sun, 18 Oct 2009 23:20:45 +0200
parents c4bc297b82f0
children
comparison
equal deleted inserted replaced
0:c4bc297b82f0 1:a06a151fc31f
61 self._progress_cb_map = {} #callback called when a progress is requested (key = progress id) 61 self._progress_cb_map = {} #callback called when a progress is requested (key = progress id)
62 self.plugins = {} 62 self.plugins = {}
63 63
64 self.bridge=DBusBridge() 64 self.bridge=DBusBridge()
65 self.bridge.register("connect", self.connect) 65 self.bridge.register("connect", self.connect)
66 self.bridge.register("disconnect", self.disconnect)
66 self.bridge.register("getContacts", self.memory.getContacts) 67 self.bridge.register("getContacts", self.memory.getContacts)
67 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus) 68 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
68 self.bridge.register("sendMessage", self.sendMessage) 69 self.bridge.register("sendMessage", self.sendMessage)
69 self.bridge.register("setParam", self.setParam) 70 self.bridge.register("setParam", self.setParam)
70 self.bridge.register("getParam", self.memory.getParam) 71 self.bridge.register("getParam", self.memory.getParam)
94 plug_info = mod.PLUGIN_INFO 95 plug_info = mod.PLUGIN_INFO
95 info ("importing plugin: %s", plug_info['name']) 96 info ("importing plugin: %s", plug_info['name'])
96 self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self) 97 self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self)
97 98
98 def connect(self): 99 def connect(self):
100 print "Connect !"
99 if (self.connected): 101 if (self.connected):
100 info("already connected !") 102 info("already connected !")
101 return 103 return
102 info("Connecting...") 104 info("Connecting...")
103 self.me = jid.JID(self.memory.getParamV("JabberID", "Connection")) 105 self.me = jid.JID(self.memory.getParamV("JabberID", "Connection"))
106 self.factory.addBootstrap(xmlstream.INIT_FAILED_EVENT,self.failed) 108 self.factory.addBootstrap(xmlstream.INIT_FAILED_EVENT,self.failed)
107 reactor.connectTCP(self.memory.getParamV("Server", "Connection"), 5222, self.factory) 109 reactor.connectTCP(self.memory.getParamV("Server", "Connection"), 5222, self.factory)
108 self.connectionStatus="online" #TODO: check if connection is OK 110 self.connectionStatus="online" #TODO: check if connection is OK
109 self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory 111 self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory
110 112
113 def disconnect(self):
114 if (not self.connected):
115 info("not connected !")
116 return
117 info("Disconnecting...")
111 118
112 def run(self): 119 def run(self):
113 debug("running app") 120 debug("running app")
114 reactor.run() 121 reactor.run()
115 122