changeset 1:a06a151fc31f

Disconnect first draft
author Goffi <goffi@goffi.org>
date Sun, 18 Oct 2009 23:20:45 +0200
parents c4bc297b82f0
children c49345fd7737
files frontends/sat_bridge_frontend/DBus.py frontends/wix/main_window.py plugins/plugin_xep_0096.py sat sat_bridge/DBus.py
diffstat 5 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/sat_bridge_frontend/DBus.py	Sat Aug 29 13:34:59 2009 +0200
+++ b/frontends/sat_bridge_frontend/DBus.py	Sun Oct 18 23:20:45 2009 +0200
@@ -43,6 +43,9 @@
     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()
     
--- a/frontends/wix/main_window.py	Sat Aug 29 13:34:59 2009 +0200
+++ b/frontends/wix/main_window.py	Sun Oct 18 23:20:45 2009 +0200
@@ -36,10 +36,11 @@
 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 @@
         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 @@
 
         #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 @@
     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()
--- a/plugins/plugin_xep_0096.py	Sat Aug 29 13:34:59 2009 +0200
+++ b/plugins/plugin_xep_0096.py	Sun Oct 18 23:20:45 2009 +0200
@@ -25,7 +25,7 @@
 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",
--- a/sat	Sat Aug 29 13:34:59 2009 +0200
+++ b/sat	Sun Oct 18 23:20:45 2009 +0200
@@ -63,6 +63,7 @@
 
         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 @@
             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 @@
         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")
--- a/sat_bridge/DBus.py	Sat Aug 29 13:34:59 2009 +0200
+++ b/sat_bridge/DBus.py	Sun Oct 18 23:20:45 2009 +0200
@@ -80,6 +80,12 @@
         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):
         debug("getContacts...")