diff --git a/browser/browser.py b/browser/browser.py index d77ed3bf..28834e6c 100755 --- a/browser/browser.py +++ b/browser/browser.py @@ -119,11 +119,10 @@ class NavigationToolbar(gtk.Toolbar): self.insert(separator, -1) separator.show() - item = gtk.MenuToolButton(None, "Share") - item.set_menu(gtk.Menu()) - item.connect("show-menu", self.__show_share_menu_cb) - toolbar.insert(item, -1) - item.show() + share = gtk.ToolButton("Share") + share.connect("clicked", self.__share_cb) + self.insert(share, -1) + share.show() separator = gtk.SeparatorToolItem() self.insert(separator, -1) @@ -149,26 +148,15 @@ class NavigationToolbar(gtk.Toolbar): def __reload_cb(self, button): self.embed.reload() - + + def __share_cb(self, button): + def __location_changed(self, embed): self._update_sensitivity() def __open_address_cb(self, address): self.embed.load_address(address) - def __show_share_menu_cb(self, button): - menu = gtk.Menu() - - item = gtk.MenuItem("Group", False) - item.connect("activate", self.__share_group_activate_cb) - menu.append(item) - item.show() - - button.set_menu(menu) - - def __share_group_activate_cb(self, item, link): - pass - class BrowserActivity(activity.Activity): def __init__(self, uri): activity.Activity.__init__(self) diff --git a/chat/chat.py b/chat/chat.py index f4716ede..42011584 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 011c92fc..dc80a943 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 2a91beee..381180b1 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