Get the activity type from env, rather than requiring set_type
This commit is contained in:
parent
e0bd5d1df4
commit
956256313a
@ -88,7 +88,6 @@ class Activity(gtk.Window):
|
|||||||
|
|
||||||
self._shared = False
|
self._shared = False
|
||||||
self._activity_id = None
|
self._activity_id = None
|
||||||
self._default_type = None
|
|
||||||
self._service = None
|
self._service = None
|
||||||
self._pservice = PresenceService()
|
self._pservice = PresenceService()
|
||||||
|
|
||||||
@ -105,17 +104,12 @@ class Activity(gtk.Window):
|
|||||||
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
|
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
|
||||||
self._bus.start(self._pservice, self)
|
self._bus.start(self._pservice, self)
|
||||||
|
|
||||||
def set_type(self, activity_type):
|
|
||||||
"""Sets the activity type."""
|
|
||||||
self._activity_type = activity_type
|
|
||||||
self._default_type = activity.get_default_type(activity_type)
|
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
"""Gets the activity type."""
|
"""Gets the activity type."""
|
||||||
return self._activity_type
|
return env.get_bundle_service_name()
|
||||||
|
|
||||||
def get_default_type(self):
|
def get_default_type(self):
|
||||||
return self._default_type
|
return activity.get_default_type(self.get_type())
|
||||||
|
|
||||||
def get_shared(self):
|
def get_shared(self):
|
||||||
"""Returns TRUE if the activity is shared on the mesh."""
|
"""Returns TRUE if the activity is shared on the mesh."""
|
||||||
@ -134,14 +128,15 @@ class Activity(gtk.Window):
|
|||||||
|
|
||||||
# Publish the default service, it's a copy of
|
# Publish the default service, it's a copy of
|
||||||
# one of those we found on the network.
|
# one of those we found on the network.
|
||||||
services = activity_ps.get_services_of_type(self._default_type)
|
default_type = self.get_default_type()
|
||||||
|
services = activity_ps.get_services_of_type(default_type)
|
||||||
if len(services) > 0:
|
if len(services) > 0:
|
||||||
service = services[0]
|
service = services[0]
|
||||||
addr = service.get_address()
|
addr = service.get_address()
|
||||||
port = service.get_port()
|
port = service.get_port()
|
||||||
properties = service.get_published_values()
|
properties = service.get_published_values()
|
||||||
self._service = self._pservice.share_activity(
|
self._service = self._pservice.share_activity(
|
||||||
self, self._default_type, properties, addr, port)
|
self, default_type, properties, addr, port)
|
||||||
else:
|
else:
|
||||||
logging.error('Cannot join the activity')
|
logging.error('Cannot join the activity')
|
||||||
|
|
||||||
@ -149,7 +144,8 @@ class Activity(gtk.Window):
|
|||||||
"""Share the activity on the network."""
|
"""Share the activity on the network."""
|
||||||
logging.debug('Share activity %s on the network.' % self.get_id())
|
logging.debug('Share activity %s on the network.' % self.get_id())
|
||||||
|
|
||||||
self._service = self._pservice.share_activity(self, self._default_type)
|
default_type = self.get_default_type()
|
||||||
|
self._service = self._pservice.share_activity(self, default_type)
|
||||||
self._shared = True
|
self._shared = True
|
||||||
|
|
||||||
def execute(self, command, args):
|
def execute(self, command, args):
|
||||||
|
@ -61,7 +61,6 @@ class ActivityFactory(dbus.service.Object):
|
|||||||
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
|
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
|
||||||
def create(self):
|
def create(self):
|
||||||
activity = self._constructor()
|
activity = self._constructor()
|
||||||
activity.set_type(self._activity_type)
|
|
||||||
|
|
||||||
self._activities.append(activity)
|
self._activities.append(activity)
|
||||||
activity.connect('destroy', self._activity_destroy_cb)
|
activity.connect('destroy', self._activity_destroy_cb)
|
||||||
|
@ -30,6 +30,12 @@ def get_bundle_path():
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_bundle_service_name():
|
||||||
|
if os.environ.has_key('SUGAR_BUNDLE_SERVICE_NAME'):
|
||||||
|
return os.environ['SUGAR_BUNDLE_SERVICE_NAME']
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_profile_path():
|
def get_profile_path():
|
||||||
if os.environ.has_key('SUGAR_PROFILE'):
|
if os.environ.has_key('SUGAR_PROFILE'):
|
||||||
profile_id = os.environ['SUGAR_PROFILE']
|
profile_id = os.environ['SUGAR_PROFILE']
|
||||||
|
Loading…
Reference in New Issue
Block a user