Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/chat
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2006-05-05 19:37:56 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2006-05-05 19:37:56 (GMT)
commitf86977781e1885ca4e34b265181dfebff65ca347 (patch)
tree22a5122898fe4639a11d65da8b4f23b1efae4e78 /chat
parentd0613d2a42a062cf4d0b0c9c6ea32bfbb01f278d (diff)
Add a share button to the browser.
Diffstat (limited to 'chat')
-rwxr-xr-xchat/chat.py37
-rw-r--r--chat/network.py38
-rw-r--r--chat/p2p.py8
3 files changed, 32 insertions, 51 deletions
diff --git a/chat/chat.py b/chat/chat.py
index f4716ed..4201158 100755
--- a/chat/chat.py
+++ b/chat/chat.py
@@ -346,16 +346,37 @@ class GroupChat(Chat):
chat.activity_connect_to_shell()
chat.recv_message(sender, msg)
- def run(self):
- try:
- gtk.main()
- except KeyboardInterrupt:
- pass
+class ChatShell(dbus.service.Object):
+ instance = None
+ def get_instance():
+ if not ChatShell.instance:
+ ChatShell.instance = ChatShell()
+ return ChatShell.instance
+
+ get_instance = staticmethod(get_instance)
+
+ def __init__(self):
+ session_bus = dbus.SessionBus()
+ bus_name = dbus.service.BusName('com.redhat.Sugar.Chat', bus=session_bus)
+ object_path = '/com/redhat/Sugar/Chat'
+
+ dbus.service.Object.__init__(self, bus_name, object_path)
+
+ def open_group_chat(self):
+ group_chat = GroupChat()
+ group_chat.activity_connect_to_shell()
+
+ @dbus.service.method('com.redhat.Sugar.ChatShell')
+ def send_message(self, message):
+ pass
+
def main():
- app = GroupChat()
- app.activity_connect_to_shell()
- app.run()
+ ChatShell.get_instance().open_group_chat()
+ try:
+ gtk.main()
+ except KeyboardInterrupt:
+ pass
if __name__ == "__main__":
main()
diff --git a/chat/network.py b/chat/network.py
index 011c92f..dc80a94 100644
--- a/chat/network.py
+++ b/chat/network.py
@@ -75,44 +75,6 @@ class GlibXMLRPCServer(GlibTCPServer, SimpleXMLRPCServer.SimpleXMLRPCDispatcher)
SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
GlibTCPServer.__init__(self, addr, requestHandler)
- def _marshaled_dispatch(self, data, dispatch_method = None):
- """Dispatches an XML-RPC method from marshalled (XML) data.
-
- XML-RPC methods are dispatched from the marshalled (XML) data
- using the _dispatch method and the result is returned as
- marshalled data. For backwards compatibility, a dispatch
- function can be provided as an argument (see comment in
- SimpleXMLRPCRequestHandler.do_POST) but overriding the
- existing method through subclassing is the prefered means
- of changing method dispatch behavior.
- """
-
- params, method = xmlrpclib.loads(data)
-
- # generate response
- try:
- if dispatch_method is not None:
- response = dispatch_method(method, params)
- else:
- response = self._dispatch(method, params)
- # wrap response in a singleton tuple
- response = (response,)
- response = xmlrpclib.dumps(response, methodresponse=1)
- except Fault, fault:
- response = xmlrpclib.dumps(fault)
- except:
- set = sys.exc_type
- sev = sys.exc_value
- ser = sys.exc_traceback
-
- # report exception back to server
- response = xmlrpclib.dumps(xmlrpclib.Fault(1, "%s:%s" % (set, sev)))
-
- print "Exception while processing request:"
- traceback.print_exception(set, sev, ser)
-
- return response
-
class GroupChatController(object):
diff --git a/chat/p2p.py b/chat/p2p.py
index 2a91bee..381180b 100644
--- a/chat/p2p.py
+++ b/chat/p2p.py
@@ -2,7 +2,6 @@ import os
import pwd
import xmlrpclib
import socket
-import traceback
import presence
import BuddyList
@@ -15,6 +14,7 @@ class GroupRequestHandler(object):
def message(self, message):
address = network.get_authinfo()
self._group.recv(address[0], message)
+ return True
class Owner:
instance = None
@@ -93,11 +93,9 @@ class Group:
peer = xmlrpclib.ServerProxy(addr)
success = True
try:
- print self._serialize_msg(pipe_id, msg)
peer.message(self._serialize_msg(pipe_id, msg))
- except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError), e:
- print "Message Send Error:"
- traceback.print_exc()
+ except (socket.error, xmlrpclib.Fault), e:
+ print str(e)
success = False
return success