Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-12-18 12:56:41 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-12-18 12:56:41 (GMT)
commit956256313a7a5401c45685b756b7cde59db9d209 (patch)
tree7af7fc65fc36fbe44b64591142628a0c292c8853 /sugar
parente0bd5d1df41f1d77ae8bd66c3c2a0ab9143595cb (diff)
Get the activity type from env, rather than requiring set_type
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/Activity.py18
-rw-r--r--sugar/activity/ActivityFactory.py1
-rw-r--r--sugar/env.py6
3 files changed, 13 insertions, 12 deletions
diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py
index 215ee85..df05b8a 100644
--- a/sugar/activity/Activity.py
+++ b/sugar/activity/Activity.py
@@ -88,7 +88,6 @@ class Activity(gtk.Window):
self._shared = False
self._activity_id = None
- self._default_type = None
self._service = None
self._pservice = PresenceService()
@@ -105,17 +104,12 @@ class Activity(gtk.Window):
self._bus = ActivityDbusService(bus_name, get_object_path(xid))
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):
"""Gets the activity type."""
- return self._activity_type
+ return env.get_bundle_service_name()
def get_default_type(self):
- return self._default_type
+ return activity.get_default_type(self.get_type())
def get_shared(self):
"""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
# 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:
service = services[0]
addr = service.get_address()
port = service.get_port()
properties = service.get_published_values()
self._service = self._pservice.share_activity(
- self, self._default_type, properties, addr, port)
+ self, default_type, properties, addr, port)
else:
logging.error('Cannot join the activity')
@@ -149,7 +144,8 @@ class Activity(gtk.Window):
"""Share the activity on the network."""
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
def execute(self, command, args):
diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py
index 4acb9b6..64c4fed 100644
--- a/sugar/activity/ActivityFactory.py
+++ b/sugar/activity/ActivityFactory.py
@@ -61,7 +61,6 @@ class ActivityFactory(dbus.service.Object):
@dbus.service.method("com.redhat.Sugar.ActivityFactory")
def create(self):
activity = self._constructor()
- activity.set_type(self._activity_type)
self._activities.append(activity)
activity.connect('destroy', self._activity_destroy_cb)
diff --git a/sugar/env.py b/sugar/env.py
index 6b59ab5..1c7164c 100644
--- a/sugar/env.py
+++ b/sugar/env.py
@@ -30,6 +30,12 @@ def get_bundle_path():
else:
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():
if os.environ.has_key('SUGAR_PROFILE'):
profile_id = os.environ['SUGAR_PROFILE']