From 4215d0551c9436351e06f8fe366b11ab1f06a476 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 18 Oct 2009 23:20:45 +0200 Subject: [PATCH] Disconnect first draft --- frontends/sat_bridge_frontend/DBus.py | 3 +++ frontends/wix/main_window.py | 14 ++++++++++---- plugins/plugin_xep_0096.py | 2 +- sat | 7 +++++++ sat_bridge/DBus.py | 6 ++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/frontends/sat_bridge_frontend/DBus.py b/frontends/sat_bridge_frontend/DBus.py index 2c1c27f7..dee6cc95 100755 --- a/frontends/sat_bridge_frontend/DBus.py +++ b/frontends/sat_bridge_frontend/DBus.py @@ -43,6 +43,9 @@ class DBusBridgeFrontend(BridgeFrontend): def connect(self): return self.db_comm_iface.connect() + def disconnect(self): + return self.db_comm_iface.disconnect() + def getContacts(self): return self.db_comm_iface.getContacts() diff --git a/frontends/wix/main_window.py b/frontends/wix/main_window.py index 55657c54..b7b4f677 100644 --- a/frontends/wix/main_window.py +++ b/frontends/wix/main_window.py @@ -36,10 +36,11 @@ from quick_frontend.quick_app import QuickApp msgOFFLINE = "offline" msgONLINE = "online" idCONNECT = 1 -idEXIT = 2 -idPARAM = 3 -idADD_CONTACT = 4 -idREMOVE_CONTACT = 5 +idDISCONNECT = 2 +idEXIT = 3 +idPARAM = 4 +idADD_CONTACT = 5 +idREMOVE_CONTACT = 6 const_DEFAULT_GROUP = "Unclassed" const_STATUS = {"Online":"", "Want to discuss":"chat", @@ -190,6 +191,7 @@ class MainWindow(wx.Frame, QuickApp): info("Creating menus") connectMenu = wx.Menu() connectMenu.Append(idCONNECT, "&Connect CTRL-c"," Connect to the server") + connectMenu.Append(idDISCONNECT, "&Disconnect CTRL-d"," Disconnect from the server") connectMenu.Append(idPARAM,"&Parameters"," Configure the program") connectMenu.AppendSeparator() connectMenu.Append(idEXIT,"E&xit"," Terminate the program") @@ -203,6 +205,7 @@ class MainWindow(wx.Frame, QuickApp): #events wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) + wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) wx.EVT_MENU(self, idPARAM, self.onParam) wx.EVT_MENU(self, idEXIT, self.onExit) wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact) @@ -316,6 +319,9 @@ class MainWindow(wx.Frame, QuickApp): def onConnectRequest(self, e): self.bridge.connect() + def onDisconnectRequest(self, e): + self.bridge.disconnect() + def __updateStatus(self): show = const_STATUS[self.statusBox.GetValue()] status = self.statusTxt.GetValue() diff --git a/plugins/plugin_xep_0096.py b/plugins/plugin_xep_0096.py index ad907c6b..756779f3 100755 --- a/plugins/plugin_xep_0096.py +++ b/plugins/plugin_xep_0096.py @@ -25,7 +25,7 @@ from twisted.internet import protocol from twisted.words.protocols.jabber import client, jid, xmlstream, error import os.path from twisted.internet import reactor #FIXME best way ??? - +import pdb PLUGIN_INFO = { "name": "XEP 0096 Plugin", diff --git a/sat b/sat index 7cf2fc7e..94d88073 100755 --- a/sat +++ b/sat @@ -63,6 +63,7 @@ class SAT: self.bridge=DBusBridge() self.bridge.register("connect", self.connect) + self.bridge.register("disconnect", self.disconnect) self.bridge.register("getContacts", self.memory.getContacts) self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus) self.bridge.register("sendMessage", self.sendMessage) @@ -96,6 +97,7 @@ class SAT: self.plugins[plug_info['import_name']] = getattr(mod, plug_info['main'])(self) def connect(self): + print "Connect !" if (self.connected): info("already connected !") return @@ -108,6 +110,11 @@ class SAT: self.connectionStatus="online" #TODO: check if connection is OK self.connected=True #TODO: use startedConnecting and clientConnectionLost of XMPPClientFactory + def disconnect(self): + if (not self.connected): + info("not connected !") + return + info("Disconnecting...") def run(self): debug("running app") diff --git a/sat_bridge/DBus.py b/sat_bridge/DBus.py index 1990610e..9806b950 100755 --- a/sat_bridge/DBus.py +++ b/sat_bridge/DBus.py @@ -79,6 +79,12 @@ class DbusObject(dbus.service.Object): info ("Connection asked") return self.cb["connect"]() + @dbus.service.method("org.goffi.SAT.communication", + in_signature='', out_signature='') + def disconnect(self): + info ("Disconnection asked") + return self.cb["disconnect"]() + @dbus.service.method("org.goffi.SAT.communication", in_signature='', out_signature='a(sa{ss}as)') def getContacts(self):