[gnome-games/sudoku-tube] Split tube-handler into separate file
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/sudoku-tube] Split tube-handler into separate file
- Date: Wed, 24 Jun 2009 02:36:03 +0000 (UTC)
commit 7c1b3d5563d41db7dacc786317205d3b7462bbf9
Author: Zhang Sen <zh jesse gmail com>
Date: Wed Jun 24 10:35:20 2009 +0800
Split tube-handler into separate file
gnome-sudoku/src/lib/Makefile.am | 3 +-
gnome-sudoku/src/lib/main.py | 3 +-
gnome-sudoku/src/lib/tp_tube.py | 37 ----------------------------
gnome-sudoku/src/lib/tube_handler.py | 44 ++++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 39 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/Makefile.am b/gnome-sudoku/src/lib/Makefile.am
index 38b7a7f..e69cd56 100644
--- a/gnome-sudoku/src/lib/Makefile.am
+++ b/gnome-sudoku/src/lib/Makefile.am
@@ -25,4 +25,5 @@ gnomesudoku_PYTHON = \
sudoku_maker.py \
sudoku_thumber.py \
timer.py \
- tp_tube.py
+ tp_tube.py \
+ tube_handler.py
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index be4dd4b..2511cd1 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -27,6 +27,7 @@ from gtk_goodies import gconf_wrapper, Undo, dialog_extras
import contact_selector
import tp_tube
+import tube_handler
logging.basicConfig()
logger = logging.getLogger("main")
@@ -137,7 +138,7 @@ class UI (gconf_wrapper.GConfWrapper):
)
self.setup_gui()
- self.tube_handler = tp_tube.TubeHandler(self.tube_service)
+ self.tube_handler = tube_handler.TubeHandler(self.tube_service)
self.timer = timer.ActiveTimer(self.w)
self.won = False
diff --git a/gnome-sudoku/src/lib/tp_tube.py b/gnome-sudoku/src/lib/tp_tube.py
index 03956d8..a3b5c3e 100644
--- a/gnome-sudoku/src/lib/tp_tube.py
+++ b/gnome-sudoku/src/lib/tp_tube.py
@@ -2,10 +2,6 @@
import logging
-import dbus
-import dbus.service
-
-from telepathy.client.conn import Connection
from telepathy.client.channel import Channel
from telepathy.interfaces import (
CHANNEL_INTERFACE,
@@ -18,42 +14,9 @@ from telepathy.constants import (
TUBE_CHANNEL_STATE_OPEN,
TUBE_CHANNEL_STATE_REMOTE_PENDING)
-from dbus.mainloop.glib import DBusGMainLoop
-DBusGMainLoop(set_as_default=True)
-
logger = logging.getLogger("main.tp_tube")
-class TubeHandler(dbus.service.Object):
- """Listen to coming tube and emit a signal for it"""
-
- def __init__(self, service_name):
- logger.info("creating TubeHandler")
- tmp = service_name.replace('.', '_')
- handler_busname = "org.gnome.Empathy.DTubeHandler." + tmp
- handler_path = "/org/gnome/Empathy/DTubeHandler/" + tmp
- logger.debug("Bus name: %s" % handler_busname)
- logger.debug("Object path: %s" % handler_path)
-
- bus = dbus.SessionBus()
- # this bus_name has to be retained, so make it a instance attribute
- self.bus_name = dbus.service.BusName(handler_busname, bus)
- super(TubeHandler, self).__init__(bus, handler_path)
-
- @dbus.service.method(dbus_interface="org.gnome.Empathy.TubeHandler",
- in_signature='soouu', out_signature='')
- def HandleTube(self, bus_name, connection, channel, handle_type, handle):
- """Called when we are offered a tube"""
- conn = Connection(bus_name, connection)
- chan = Channel(bus_name, channel)
-
- address = chan[CHANNEL_TYPE_DBUS_TUBE].Accept(
- SOCKET_ACCESS_CONTROL_CREDENTIALS)
- tube_conn = dbus.connection.Connection(address)
-
- print 'emit a signal that connection is ready'
-
-
def tube_state_changed_cb(state):
if state == TUBE_CHANNEL_STATE_OPEN:
logger.info("Tube state changed ->open")
diff --git a/gnome-sudoku/src/lib/tube_handler.py b/gnome-sudoku/src/lib/tube_handler.py
new file mode 100644
index 0000000..8cbd80c
--- /dev/null
+++ b/gnome-sudoku/src/lib/tube_handler.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+import logging
+
+import dbus
+import dbus.service
+from dbus.mainloop.glib import DBusGMainLoop
+
+from telepathy.client.conn import Connection
+from telepathy.client.channel import Channel
+from telepathy.constants import SOCKET_ACCESS_CONTROL_CREDENTIALS
+from telepathy.interfaces import CHANNEL_TYPE_DBUS_TUBE
+
+DBusGMainLoop(set_as_default=True)
+logger = logging.getLogger("main.tubehandler")
+
+class TubeHandler(dbus.service.Object):
+ """Listen to coming tube and emit a signal for it"""
+
+ def __init__(self, service_name):
+ logger.info("creating TubeHandler")
+ tmp = service_name.replace('.', '_')
+ handler_busname = "org.gnome.Empathy.DTubeHandler." + tmp
+ handler_path = "/org/gnome/Empathy/DTubeHandler/" + tmp
+ logger.debug("Bus name: %s" % handler_busname)
+ logger.debug("Object path: %s" % handler_path)
+
+ bus = dbus.SessionBus()
+ # this bus_name has to be retained, so make it a instance attribute
+ self.bus_name = dbus.service.BusName(handler_busname, bus)
+ super(TubeHandler, self).__init__(bus, handler_path)
+
+ @dbus.service.method(dbus_interface="org.gnome.Empathy.TubeHandler",
+ in_signature='soouu', out_signature='')
+ def HandleTube(self, bus_name, connection, channel, handle_type, handle):
+ """Called when we are offered a tube"""
+ conn = Connection(bus_name, connection)
+ chan = Channel(bus_name, channel)
+
+ address = chan[CHANNEL_TYPE_DBUS_TUBE].Accept(
+ SOCKET_ACCESS_CONTROL_CREDENTIALS)
+ tube_conn = dbus.connection.Connection(address)
+
+ print 'emit a signal that connection is ready'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]