Make bundle registry a singleton. Get the object path from the registry.
This commit is contained in:
@@ -25,6 +25,7 @@ import gobject
|
||||
import gtk
|
||||
|
||||
from sugar.presence.PresenceService import PresenceService
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar.activity.bundle import Bundle
|
||||
from sugar import logger
|
||||
|
||||
@@ -90,14 +91,14 @@ class ActivityCreationHandler(gobject.GObject):
|
||||
([gobject.TYPE_PYOBJECT]))
|
||||
}
|
||||
|
||||
def __init__(self, activity_name):
|
||||
def __init__(self, service_name):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
factory_name = activity_name
|
||||
factory_path = get_path(factory_name)
|
||||
registry = bundleregistry.get_registry()
|
||||
bundle = registry.get_bundle(service_name)
|
||||
|
||||
proxy_obj = bus.get_object(factory_name, factory_path)
|
||||
bus = dbus.SessionBus()
|
||||
proxy_obj = bus.get_object(service_name, bundle.get_object_path())
|
||||
factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
|
||||
|
||||
factory.create(reply_handler=self._reply_handler, error_handler=self._error_handler)
|
||||
@@ -113,9 +114,9 @@ class ActivityCreationHandler(gobject.GObject):
|
||||
logging.debug("Couldn't create activity: %s" % err)
|
||||
self.emit('error', err)
|
||||
|
||||
def create(activity_name):
|
||||
def create(service_name):
|
||||
"""Create a new activity from its name."""
|
||||
return ActivityCreationHandler(activity_name)
|
||||
return ActivityCreationHandler(service_name)
|
||||
|
||||
def start_factory(activity_class, bundle_path):
|
||||
"""Start the activity factory."""
|
||||
|
||||
@@ -71,6 +71,10 @@ class Bundle:
|
||||
"""Get the activity service name"""
|
||||
return self._service_name
|
||||
|
||||
def get_object_path(self):
|
||||
"""Get the path to the service object"""
|
||||
return '/' + self._service_name.replace('.', '/')
|
||||
|
||||
def get_default_type(self):
|
||||
"""Get the type of the main network service which tracks presence
|
||||
and provides info about the activity, for example the title."""
|
||||
|
||||
@@ -73,3 +73,14 @@ class BundleRegistry(gobject.GObject):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_registry():
|
||||
return _bundle_registry
|
||||
|
||||
_bundle_registry = BundleRegistry()
|
||||
|
||||
for path in env.get_data_dirs():
|
||||
bundles_path = os.path.join(path, 'activities')
|
||||
_bundle_registry.add_search_path(bundles_path)
|
||||
|
||||
_bundle_registry.add_search_path(env.get_user_activities_dir())
|
||||
|
||||
Reference in New Issue
Block a user