コード例 #1
0
ファイル: gtk_menuactions.py プロジェクト: rudresh2319/Xpra
def get_menu_interface(bus_name, object_path):
    bus = init_session_bus()
    obj = bus.get_object(bus_name, object_path)
    log("%s:%s=%s", bus_name, object_path, obj)
    menu_iface = dbus.Interface(obj, MENUS)
    log("%s(%s)=%s", MENUS, obj, menu_iface)
    return menu_iface
コード例 #2
0
 def __init__(self, *args):
     gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
     self.set_size_request(320, 500)
     self.connect("delete_event", gtk.mainquit)
     vbox = gtk.VBox()
     self.add(vbox)
     vbox.add(gtk.Label("Delay before actions:"))
     self.delay_entry = gtk.Entry(max=10)
     self.delay_entry.set_text("0")
     vbox.add(self.delay_entry)
     vbox.add(gtk.Label("App ID:"))
     self.app_id_entry = gtk.Entry(max=40)
     self.app_id_entry.set_text("org.xpra.ExampleMenu")
     vbox.add(self.app_id_entry)
     self.app_path_entry = gtk.Entry(max=40)
     self.app_path_entry.set_text("/org/xpra/ExampleMenu")
     vbox.add(self.app_path_entry)
     btn = gtk.Button("Publish Menu")
     btn.connect("clicked", self.delayed_call, self.publish_menu)
     vbox.add(btn)
     btn = gtk.Button("Remove Menu")
     btn.connect("clicked", self.delayed_call, self.remove_menu)
     vbox.add(btn)
     btn = gtk.Button("Toggle Menu")
     btn.connect("clicked", self.delayed_call, self.toggle_menu)
     vbox.add(btn)
     btn = gtk.Button("New Window")
     btn.connect("clicked", self.delayed_call, self.new_window)
     vbox.add(btn)
     #no services to begin with:
     self.window_actions_service, self.app_actions_service, self.menus_service = None, None, None
     from xpra.dbus.common import init_session_bus
     self.session_bus = init_session_bus(private=True)
     self.init_defaults()
コード例 #3
0
ファイル: gtk_menuactions.py プロジェクト: ljmljz/xpra
def get_menu_interface(bus_name, object_path):
    bus = init_session_bus()
    obj = bus.get_object(bus_name, object_path)
    log("%s:%s=%s", bus_name, object_path, obj)
    menu_iface = dbus.Interface(obj, MENUS)
    log("%s(%s)=%s", MENUS, obj, menu_iface)
    return menu_iface
コード例 #4
0
ファイル: gtk_menuactions.py プロジェクト: ljmljz/xpra
def get_actions_interface(bus_name, object_path):
    bus = init_session_bus()
    obj = bus.get_object(bus_name, object_path)
    log("%s:%s=%s", bus_name, object_path, obj)
    actions_iface = dbus.Interface(obj, ACTIONS)
    log("%s(%s)=%s", ACTIONS, obj, actions_iface)
    return actions_iface
コード例 #5
0
ファイル: gtk_menuactions.py プロジェクト: rudresh2319/Xpra
def get_actions_interface(bus_name, object_path):
    bus = init_session_bus()
    obj = bus.get_object(bus_name, object_path)
    log("%s:%s=%s", bus_name, object_path, obj)
    actions_iface = dbus.Interface(obj, ACTIONS)
    log("%s(%s)=%s", ACTIONS, obj, actions_iface)
    return actions_iface
コード例 #6
0
ファイル: set_gtk_menu.py プロジェクト: ljmljz/xpra
 def __init__(self, *args):
     gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
     self.set_size_request(320, 500)
     self.connect("delete_event", gtk.mainquit)
     vbox = gtk.VBox()
     self.add(vbox)
     vbox.add(gtk.Label("Delay before actions:"))
     self.delay_entry = gtk.Entry(max=10)
     self.delay_entry.set_text("0")
     vbox.add(self.delay_entry)
     vbox.add(gtk.Label("App ID:"))
     self.app_id_entry = gtk.Entry(max=40)
     self.app_id_entry.set_text("org.xpra.ExampleMenu")
     vbox.add(self.app_id_entry)
     self.app_path_entry = gtk.Entry(max=40)
     self.app_path_entry.set_text("/org/xpra/ExampleMenu")
     vbox.add(self.app_path_entry)
     btn = gtk.Button("Publish Menu")
     btn.connect("clicked", self.delayed_call, self.publish_menu)
     vbox.add(btn)
     btn = gtk.Button("Remove Menu")
     btn.connect("clicked", self.delayed_call, self.remove_menu)
     vbox.add(btn)
     btn = gtk.Button("Toggle Menu")
     btn.connect("clicked", self.delayed_call, self.toggle_menu)
     vbox.add(btn)
     btn = gtk.Button("New Window")
     btn.connect("clicked", self.delayed_call, self.new_window)
     vbox.add(btn)
     #no services to begin with:
     self.window_actions_service, self.app_actions_service, self.menus_service = None, None, None
     from xpra.dbus.common import init_session_bus
     self.session_bus = init_session_bus(private=True)
     self.init_defaults()
コード例 #7
0
 def __init__(self, server=None, extra=""):
     bus = init_session_bus()
     name = BUS_NAME
     if extra:
         name += extra.replace(".", "_").replace(":", "_")
     super().__init__(bus, server, name)
     self._properties.update({
         "idle-timeout"          : ("idle_timeout",          ni),
         "server-idle-timeout"   : ("server_idle_timeout",   ni),
         "name"                  : ("session_name",          ns),
         })
コード例 #8
0
def register(notify_callback=None, close_callback=None, replace=False):
    from xpra.dbus.common import init_session_bus
    bus = init_session_bus()
    flags = dbus.bus.NAME_FLAG_DO_NOT_QUEUE
    if replace:
        flags |= dbus.bus.NAME_FLAG_REPLACE_EXISTING
    request = bus.request_name(BUS_NAME, flags)
    log("notifications: bus name '%s', request=%s" % (BUS_NAME, request))
    if request==dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        raise Exception("the name '%s' is already claimed on the session bus" % BUS_NAME)
    return DBUSNotificationsForwarder(bus, notify_callback, close_callback)
コード例 #9
0
def register(notify_callback=None, close_callback=None, replace=False):
    from xpra.dbus.common import init_session_bus
    bus = init_session_bus()
    flags = dbus.bus.NAME_FLAG_DO_NOT_QUEUE
    if replace:
        flags |= dbus.bus.NAME_FLAG_REPLACE_EXISTING
    request = bus.request_name(BUS_NAME, flags)
    if request==dbus.bus.REQUEST_NAME_REPLY_EXISTS:
        raise Exception("the name '%s' is already claimed on the session bus" % BUS_NAME)
    log("notifications: bus name '%s', request=%s" % (BUS_NAME, request))
    return DBUSNotificationsForwarder(bus, notify_callback, close_callback)
コード例 #10
0
ファイル: dbus_source.py プロジェクト: ljmljz/xpra
 def __init__(self, source=None, extra=""):
     self.source = source
     session_bus = init_session_bus()
     name = BUS_NAME
     self.path = PATH + str(sequence.increase())
     if extra:
         name += extra
     bus_name = dbus.service.BusName(name, session_bus)
     dbus.service.Object.__init__(self, bus_name, self.path)
     self.log("(%s)", source)
     self._properties = {"bell"              : ("send_bell",             ni),
                         "cursors"           : ("send_cursors",          ni),
                         "notifications"     : ("send_notifications",    ni),
                         }
コード例 #11
0
ファイル: dbus_source.py プロジェクト: DiGuoZhiMeng/Xpra
 def __init__(self, source=None, extra=""):
     self.source = source
     session_bus = init_session_bus()
     name = BUS_NAME
     self.path = PATH + str(sequence.increase())
     if extra:
         name += extra.replace(".", "_").replace(":", "_")
     bus_name = dbus.service.BusName(name, session_bus)
     dbus.service.Object.__init__(self, bus_name, self.path)
     self.log("(%s)", source)
     self._properties = {"bell"              : ("send_bell",             ni),
                         "cursors"           : ("send_cursors",          ni),
                         "notifications"     : ("send_notifications",    ni),
                         }
コード例 #12
0
ファイル: dbus_server.py プロジェクト: rudresh2319/Xpra
 def __init__(self, server=None, extra=""):
     self.server = server
     session_bus = init_session_bus()
     name = BUS_NAME
     path = PATH
     if extra:
         name += extra
     bus_name = dbus.service.BusName(name, session_bus)
     dbus.service.Object.__init__(self, bus_name, path)
     self.log("(%s)", server)
     self._properties = {"idle-timeout"          : ("idle_timeout",          ni),
                         "server-idle-timeout"   : ("server_idle_timeout",   ni),
                         "name"                  : ("session_name",          ns),
                         "sharing"               : ("sharing",               nb),
                         }
コード例 #13
0
ファイル: dbus_server.py プロジェクト: ljmljz/xpra
 def __init__(self, server=None, extra=""):
     self.server = server
     session_bus = init_session_bus()
     name = BUS_NAME
     path = PATH
     if extra:
         name += extra
     bus_name = dbus.service.BusName(name, session_bus)
     dbus.service.Object.__init__(self, bus_name, path)
     self.log("(%s)", server)
     self._properties = {"idle-timeout"          : ("idle_timeout",          ni),
                         "server-idle-timeout"   : ("server_idle_timeout",   ni),
                         "name"                  : ("session_name",          ns),
                         "sharing"               : ("sharing",               nb),
                         }
コード例 #14
0
    def setup_dbus_signals(self):
        try:
            import xpra.dbus
            assert xpra.dbus
        except ImportError as e:
            dbuslog("setup_dbus_signals()", exc_info=True)
            dbuslog.info("dbus support is not installed")
            dbuslog.info(" no support for power events")
            return
        try:
            from xpra.dbus.common import init_system_bus, init_session_bus
        except ImportError as e:
            dbuslog("setup_dbus_signals()", exc_info=True)
            dbuslog.error("Error: dbus bindings are missing,")
            dbuslog.error(" cannot setup event listeners:")
            dbuslog.error(" %s", e)
            return

        try:
            bus = init_system_bus()
            self.system_bus = bus
            dbuslog("setup_dbus_signals() system bus=%s", bus)
        except Exception as e:
            dbuslog("setup_dbus_signals()", exc_info=True)
            dbuslog.error("Error setting up dbus signals:")
            dbuslog.error(" %s", e)
        else:
            #the UPower signals:
            try:
                bus_name = 'org.freedesktop.UPower'
                dbuslog("bus has owner(%s)=%s", bus_name,
                        bus.name_has_owner(bus_name))
                iface_name = 'org.freedesktop.UPower'
                self.upower_resuming_match = bus.add_signal_receiver(
                    self.resuming_callback, 'Resuming', iface_name, bus_name)
                self.upower_sleeping_match = bus.add_signal_receiver(
                    self.sleeping_callback, 'Sleeping', iface_name, bus_name)
                dbuslog(
                    "listening for 'Resuming' and 'Sleeping' signals on %s",
                    iface_name)
            except Exception as e:
                dbuslog("failed to setup UPower event listener: %s", e)

            #the "logind" signals:
            try:
                bus_name = 'org.freedesktop.login1'
                dbuslog("bus has owner(%s)=%s", bus_name,
                        bus.name_has_owner(bus_name))

                def sleep_event_handler(suspend):
                    if suspend:
                        self.sleeping_callback()
                    else:
                        self.resuming_callback()

                iface_name = 'org.freedesktop.login1.Manager'
                self.login1_match = bus.add_signal_receiver(
                    sleep_event_handler, 'PrepareForSleep', iface_name,
                    bus_name)
                dbuslog("listening for 'PrepareForSleep' signal on %s",
                        iface_name)
            except Exception as e:
                dbuslog("failed to setup login1 event listener: %s", e)

        if DBUS_SCREENSAVER:
            try:
                session_bus = init_session_bus()
                self.session_bus = session_bus
                dbuslog("setup_dbus_signals() session bus=%s", session_bus)
            except Exception as e:
                dbuslog("setup_dbus_signals()", exc_info=True)
                dbuslog.error("Error setting up dbus signals:")
                dbuslog.error(" %s", e)
            else:
                #screensaver signals:
                try:
                    bus_name = "org.gnome.ScreenSaver"
                    iface_name = bus_name
                    self.screensaver_match = bus.add_signal_receiver(
                        self.ActiveChanged, "ActiveChanged", iface_name,
                        bus_name)
                    dbuslog("listening for 'ActiveChanged' signal on %s",
                            iface_name)
                except Exception as e:
                    dbuslog.warn(
                        "Warning: failed to setup screensaver event listener: %s",
                        e)
コード例 #15
0
 def __init__(self):
     from xpra.dbus.common import init_session_bus
     self.bus = init_session_bus()
コード例 #16
0
ファイル: menu.py プロジェクト: rudresh2319/Xpra
def setup_dbus_window_menu(add,
                           wid,
                           menus,
                           application_action_callback=None,
                           window_action_callback=None):
    def nomenu():
        #tell caller to clear all properties if they exist:
        return {
            "_GTK_APP_MENU_OBJECT_PATH": None,
            "_GTK_WINDOW_OBJECT_PATH": None,
            "_GTK_APPLICATION_OBJECT_PATH": None,
            "_GTK_UNIQUE_BUS_NAME": None,
            "_GTK_APPLICATION_ID": None
        }

    if add is False:
        return nomenu()
    global window_menu_services, window_menus, fallback_menus
    if len(menus) == 0 and fallback_menus:
        menus = fallback_menus
    #ie: menu = {
    #         'enabled': True,
    #         'application-id':         'org.xpra.ExampleMenu',
    #         'application-actions':    {'quit': (True, '', ()), 'about': (True, '', ()), 'help': (True, '', ()), 'custom': (True, '', ()), 'activate-tab': (True, 's', ()), 'preferences': (True, '', ())},
    #         'window-actions':         {'edit-profile': (True, 's', ()), 'reset': (True, 'b', ()), 'about': (True, '', ()), 'help': (True, '', ()), 'fullscreen': (True, '', (0,)), 'detach-tab': (True, '', ()), 'save-contents': (True, '', ()), 'zoom': (True, 'i', ()), 'move-tab': (True, 'i', ()), 'new-terminal': (True, '(ss)', ()), 'switch-tab': (True, 'i', ()), 'new-profile': (True, '', ()), 'close': (True, 's', ()), 'show-menubar': (True, '', (1,)), 'select-all': (True, '', ()), 'copy': (True, '', ()), 'paste': (True, 's', ()), 'find': (True, 's', ()), 'preferences': (True, '', ())},
    #         'window-menu':            {0:
    #               {0: ({':section': (0, 1)}, {':section': (0, 2)}, {':section': (0, 3)}),
    #                1: ({'action': 'win.new-terminal', 'target': ('default', 'default'), 'label': '_New Terminal'},),
    #                2: ({'action': 'app.preferences', 'label': '_Preferences'},),
    #                3: ({'action': 'app.help', 'label': '_Help'}, {'action': 'app.about', 'label': '_About'}, {'action': 'app.quit', 'label': '_Quit'}),
    #                }
    #             }
    #           }
    enabled = menus.get("enabled", False)
    app_actions_service, window_actions_service, window_menu_service = None, None, None

    def remove_services(*_args):
        """ removes all the services if they are not longer used by any windows """
        for x in (app_actions_service, window_actions_service,
                  window_menu_service):
            if x:
                if x not in window_menu_services.values():
                    try:
                        x.remove_from_connection()
                    except Exception as e:
                        log.warn("Error removing %s: %s", x, e)
        try:
            del window_menus[wid]
        except:
            pass

    if enabled:
        m = typedict(menus)
        app_id = bytestostr(
            m.strget("application-id", b"org.xpra.Window%i" % wid)).decode()
        app_actions = m.dictget("application-actions")
        window_actions = m.dictget("window-actions")
        window_menu = m.dictget("window-menu")
    if wid in window_menus:
        #update, destroy or re-create the services:
        app_actions_service, window_actions_service, window_menu_service, cur_app_id = window_menus[
            wid]
        if not enabled or cur_app_id != app_id:
            remove_services(
            )  #falls through to re-create them if enabled is True
            app_actions_service, window_actions_service, window_menu_service = None, None, None
        else:
            #update them:
            app_actions_service.set_actions(app_actions)
            window_actions_service.set_actions(window_actions)
            window_menu_service.set_menus(window_menu)
            return
    if not enabled:
        #tell caller to clear all properties if they exist:
        return nomenu()
    #make or re-use services:
    try:
        NAME_PREFIX = "org.xpra."
        from xpra.dbus.common import init_session_bus
        from xpra.dbus.gtk_menuactions import Menus, Actions
        session_bus = init_session_bus()
        bus_name = session_bus.get_unique_name().decode()
        name = app_id
        for strip in ("org.", "gtk.", "xpra.", "gnome."):
            if name.startswith(strip):
                name = name[len(strip):]
        name = NAME_PREFIX + name
        log("normalized named(%s)=%s", app_id, name)

        def get_service(service_class, name, path, *args):
            """ find the service by name and path, or create one """
            service = window_menu_services.get((service_class, name, path))
            if service is None:
                service = service_class(name, path, session_bus, *args)
                window_menu_services[(service_class, name, path)] = service
            return service

        app_path = strtobytes("/" + name.replace(".", "/")).decode()
        app_actions_service = get_service(Actions, name, app_path, app_actions,
                                          application_action_callback)

        #this one should be unique and therefore not re-used? (only one "window_action_callback"..)
        window_path = u"%s/window/%s" % (app_path, wid)
        window_actions_service = get_service(Actions, name, window_path,
                                             window_actions,
                                             window_action_callback)

        menu_path = u"%s/menus/appmenu" % app_path
        window_menu_service = get_service(Menus, app_id, menu_path,
                                          window_menu)
        window_menus[
            wid] = app_actions_service, window_actions_service, window_menu_service, app_id

        return {
            "_GTK_APP_MENU_OBJECT_PATH": ("utf8", menu_path),
            "_GTK_WINDOW_OBJECT_PATH": ("utf8", window_path),
            "_GTK_APPLICATION_OBJECT_PATH": ("utf8", app_path),
            "_GTK_UNIQUE_BUS_NAME": ("utf8", bus_name),
            "_GTK_APPLICATION_ID": ("utf8", app_id),
        }
    except Exception:
        log.error("Error: cannot parse or apply menu:", exc_info=True)
        remove_services()
        return nomenu()
コード例 #17
0
ファイル: menu.py プロジェクト: ljmljz/xpra
def setup_dbus_window_menu(add, wid, menus, application_action_callback=None, window_action_callback=None):
    def nomenu():
        #tell caller to clear all properties if they exist:
        return {
                "_GTK_APP_MENU_OBJECT_PATH"     : None,
                "_GTK_WINDOW_OBJECT_PATH"       : None,
                "_GTK_APPLICATION_OBJECT_PATH"  : None,
                "_GTK_UNIQUE_BUS_NAME"          : None,
                "_GTK_APPLICATION_ID"           : None
                }
    if add is False:
        return nomenu()
    global window_menu_services, window_menus, fallback_menus
    if len(menus)==0 and fallback_menus:
        menus = fallback_menus
    #ie: menu = {
    #         'enabled': True,
    #         'application-id':         'org.xpra.ExampleMenu',
    #         'application-actions':    {'quit': (True, '', ()), 'about': (True, '', ()), 'help': (True, '', ()), 'custom': (True, '', ()), 'activate-tab': (True, 's', ()), 'preferences': (True, '', ())},
    #         'window-actions':         {'edit-profile': (True, 's', ()), 'reset': (True, 'b', ()), 'about': (True, '', ()), 'help': (True, '', ()), 'fullscreen': (True, '', (0,)), 'detach-tab': (True, '', ()), 'save-contents': (True, '', ()), 'zoom': (True, 'i', ()), 'move-tab': (True, 'i', ()), 'new-terminal': (True, '(ss)', ()), 'switch-tab': (True, 'i', ()), 'new-profile': (True, '', ()), 'close': (True, 's', ()), 'show-menubar': (True, '', (1,)), 'select-all': (True, '', ()), 'copy': (True, '', ()), 'paste': (True, 's', ()), 'find': (True, 's', ()), 'preferences': (True, '', ())},
    #         'window-menu':            {0:
    #               {0: ({':section': (0, 1)}, {':section': (0, 2)}, {':section': (0, 3)}),
    #                1: ({'action': 'win.new-terminal', 'target': ('default', 'default'), 'label': '_New Terminal'},),
    #                2: ({'action': 'app.preferences', 'label': '_Preferences'},),
    #                3: ({'action': 'app.help', 'label': '_Help'}, {'action': 'app.about', 'label': '_About'}, {'action': 'app.quit', 'label': '_Quit'}),
    #                }
    #             }
    #           }
    enabled = menus.get("enabled", False)
    app_actions_service, window_actions_service, window_menu_service = None, None, None
    def remove_services(*args):
        """ removes all the services if they are not longer used by any windows """
        for x in (app_actions_service, window_actions_service, window_menu_service):
            if x:
                if x not in window_menu_services.values():
                    try:
                        x.remove_from_connection()
                    except Exception as e:
                        log.warn("Error removing %s: %s", x, e)
        try:
            del window_menus[wid]
        except:
            pass
    if enabled:
        m = typedict(menus)
        app_id          = bytestostr(m.strget("application-id", b"org.xpra.Window%i" % wid)).decode()
        app_actions     = m.dictget("application-actions")
        window_actions  = m.dictget("window-actions")
        window_menu     = m.dictget("window-menu")
    if wid in window_menus:
        #update, destroy or re-create the services:
        app_actions_service, window_actions_service, window_menu_service, cur_app_id = window_menus[wid]
        if not enabled or cur_app_id!=app_id:
            remove_services()   #falls through to re-create them if enabled is True
            app_actions_service, window_actions_service, window_menu_service = None, None, None
        else:
            #update them:
            app_actions_service.set_actions(app_actions)
            window_actions_service.set_actions(window_actions)
            window_menu_service.set_menus(window_menu)
            return
    if not enabled:
        #tell caller to clear all properties if they exist:
        return nomenu()
    #make or re-use services:
    try:
        NAME_PREFIX = "org.xpra."
        from xpra.util import strtobytes
        from xpra.dbus.common import init_session_bus
        from xpra.dbus.gtk_menuactions import Menus, Actions
        session_bus = init_session_bus()
        bus_name = session_bus.get_unique_name().decode()
        name = app_id
        for strip in ("org.", "gtk.", "xpra.", "gnome."):
            if name.startswith(strip):
                name = name[len(strip):]
        name = NAME_PREFIX + name
        log("normalized named(%s)=%s", app_id, name)

        def get_service(service_class, name, path, *args):
            """ find the service by name and path, or create one """
            service = window_menu_services.get((service_class, name, path))
            if service is None:
                service = service_class(name, path, session_bus, *args)
                window_menu_services[(service_class, name, path)] = service
            return service

        app_path = strtobytes("/"+name.replace(".", "/")).decode()
        app_actions_service = get_service(Actions, name, app_path, app_actions, application_action_callback)

        #this one should be unique and therefore not re-used? (only one "window_action_callback"..)
        window_path = u"%s/window/%s" % (app_path, wid)
        window_actions_service = get_service(Actions, name, window_path, window_actions, window_action_callback)

        menu_path = u"%s/menus/appmenu" % app_path
        window_menu_service = get_service(Menus, app_id, menu_path, window_menu)
        window_menus[wid] = app_actions_service, window_actions_service, window_menu_service, app_id

        return {
                "_GTK_APP_MENU_OBJECT_PATH"     : ("utf8", menu_path),
                "_GTK_WINDOW_OBJECT_PATH"       : ("utf8", window_path),
                "_GTK_APPLICATION_OBJECT_PATH"  : ("utf8", app_path),
                "_GTK_UNIQUE_BUS_NAME"          : ("utf8", bus_name),
                "_GTK_APPLICATION_ID"           : ("utf8", app_id),
               }
    except Exception:
        log.error("Error: cannot parse or apply menu:", exc_info=True)
        remove_services()
        return nomenu()
コード例 #18
0
ファイル: helper.py プロジェクト: svn2github/Xpra
 def __init__(self):
     from xpra.dbus.common import init_session_bus
     self.bus = init_session_bus()
コード例 #19
0
ファイル: proxy_dbus_server.py プロジェクト: frostbane/xpra
 def __init__(self, server=None):
     if os.getuid() == 0:
         bus = init_system_bus()
     else:
         bus = init_session_bus()
     super().__init__(bus, server, BUS_NAME)
コード例 #20
0
ファイル: proxy_dbus_server.py プロジェクト: rudresh2319/Xpra
 def __init__(self, server=None):
     if os.getuid() == 0:
         bus = init_system_bus()
     else:
         bus = init_session_bus()
     DBUS_Server_Base.__init__(self, bus, server, BUS_NAME)