OSDN Git Service

Introduce uri opener.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Tue, 22 Aug 2006 15:08:37 +0000 (00:08 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Tue, 22 Aug 2006 15:08:37 +0000 (00:08 +0900)
src/Hage1/dbus_object.py
src/Hage1/uri_opener.py [new file with mode: 0644]
src/hage1

index 4eb0c11..b6038e9 100644 (file)
@@ -20,8 +20,7 @@ import dbus.service
 if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
     import dbus.glib
 
-import board_window
-import thread_window
+import uri_opener
 
 dbus_interface_name = "tk.tetteke.Hage1"
 
@@ -31,9 +30,5 @@ class DBusHage1Object(dbus.service.Object):
         dbus.service.Object.__init__(self, bus_name, object_path)
 
     @dbus.service.method(dbus_interface_name)
-    def open_board(self, uri):
-        board_window.open_board(uri)
-
-    @dbus.service.method(dbus_interface_name)
-    def open_thread(self, uri):
-        thread_window.open_thread(uri)
+    def open_uri(self, uri):
+        uri_opener.open_uri(uri)
diff --git a/src/Hage1/uri_opener.py b/src/Hage1/uri_opener.py
new file mode 100644 (file)
index 0000000..41b81d5
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (C) 2006 by Aiwota Programmer
+# aiwotaprog@tetteke.tk
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+import board_window
+import thread_window
+from BbsType import bbs_type_judge_uri
+
+def open_uri(uri):
+    bbs_type = bbs_type_judge_uri.get_type(uri)
+    if bbs_type.is_board():
+        board_window.open_board(uri)
+    elif bbs_type.is_thread():
+        thread_window.open_thread(uri)
+    else:
+        print "the uri represents neither board nor thread: ", uri
index 90b3cba..3c7a1ac 100755 (executable)
--- a/src/hage1
+++ b/src/hage1
@@ -31,6 +31,7 @@ from Hage1 import thread_window
 from Hage1 import board_window
 from Hage1 import config
 from Hage1 import dbus_object
+from Hage1 import uri_opener
 
 APPNAME = 'Hage1'
 APPVERSION = '0.1'
@@ -96,10 +97,7 @@ if __name__ == "__main__":
             from Hage1.BbsType import bbs_type_exception
             for uri in uris:
                 try:
-                    bbs_type = bbs_type_judge_uri.get_type(uri)
-                    if bbs_type.is_board():
-                        board_window.open_board(uri)
-                    thread_window.open_thread(uri)
+                    uri_opener.open_uri(uri)
                 except bbs_type_exception.BbsTypeError, msg:
                     print msg
             gtk.main()
@@ -115,9 +113,6 @@ if __name__ == "__main__":
             from Hage1.BbsType import bbs_type_exception
             for uri in uris:
                 try:
-                    bbs_type = bbs_type_judge_uri.get_type(uri)
-                    if bbs_type.is_board():
-                        iface.open_board(uri)
-                    iface.open_thread(uri)
+                    iface.open_uri(uri)
                 except bbs_type_exception.BbsTypeError, msg:
                     print msg