From 70da5fa7bd4000dbc2d7dbfaf6637372d1448c32 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 21 Feb 2007 19:15:39 +0000 Subject: More cleanups --- (limited to 'sugar/activity') diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py index 037e09f..e34b73e 100644 --- a/sugar/activity/Activity.py +++ b/sugar/activity/Activity.py @@ -15,77 +15,13 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -import os import logging -import dbus -import dbus.service import gtk -import gobject -import datetime from sugar.presence import PresenceService -from sugar.datastore import datastore -from sugar import activity +from sugar.activity.activityservice import ActivityService from sugar import env -import sugar.util - -_ACTIVITY_SERVICE_NAME = "org.laptop.Activity" -_ACTIVITY_SERVICE_PATH = "/org/laptop/Activity" -_ACTIVITY_INTERFACE = "org.laptop.Activity" - -class ActivityDbusService(dbus.service.Object): - """Base dbus service object that each Activity uses to export dbus methods. - - The dbus service is separate from the actual Activity object so that we can - tightly control what stuff passes through the dbus python bindings.""" - - def __init__(self, activity): - service_name = _ACTIVITY_SERVICE_NAME + '%d' % activity.window.xid - object_path = _ACTIVITY_SERVICE_PATH + "/%s" % activity.window.xid - - bus = dbus.SessionBus() - bus_name = dbus.service.BusName(service_name, bus=bus) - dbus.service.Object.__init__(self, bus_name, object_path) - - self._activity = activity - self._pservice = PresenceService.get_instance() - - @dbus.service.method(_ACTIVITY_INTERFACE) - def start(self, activity_id): - """Start the activity in unshared mode.""" - self._activity.start(activity_id) - - @dbus.service.method(_ACTIVITY_INTERFACE) - def join(self, activity_ps_path): - """Join the activity specified by its presence service path.""" - activity_ps = self._pservice.get(activity_ps_path) - return self._activity.join(activity_ps) - - @dbus.service.method(_ACTIVITY_INTERFACE) - def share(self): - """Called by the shell to request the activity to share itself on the network.""" - self._activity.share() - - @dbus.service.method(_ACTIVITY_INTERFACE) - def get_id(self): - """Get the activity identifier""" - return self._activity.get_id() - - @dbus.service.method(_ACTIVITY_INTERFACE) - def get_type(self): - """Get the activity type""" - return self._activity.get_type() - - @dbus.service.method(_ACTIVITY_INTERFACE) - def get_shared(self): - """Returns True if the activity is shared on the mesh.""" - return self._activity.get_shared() - - @dbus.service.method(_ACTIVITY_INTERFACE, - in_signature="sas", out_signature="b") - def execute(self, command, args): - return self._activity.execute(command, args) class Activity(gtk.Window): """Base Activity class that all other Activities derive from.""" @@ -94,12 +30,10 @@ class Activity(gtk.Window): gtk.Window.__init__(self) self.connect('destroy', self._destroy_cb) - #self.connect('notify::title', self._title_changed_cb) self._shared = False self._activity_id = None self._service = None - #self._journal_object = None self._pservice = PresenceService.get_instance() self.realize() @@ -108,7 +42,7 @@ class Activity(gtk.Window): group.realize() self.window.set_group(group.window) - self._bus = ActivityDbusService(self) + self._bus = ActivityService(self) def start(self, activity_id): """Start the activity.""" @@ -118,19 +52,8 @@ class Activity(gtk.Window): self._activity_id = activity_id - #ds = datastore.get_instance() - #self._journal_object = ds.create('', {}, self._activity_id) - # - #date = datetime.datetime.now() - #self._journal_jobject.set_properties({'date' : date, - # 'title' : self.get_title()}) - self.present() -# def get_journal_object(self): -# """Returns the journal object associated with the activity.""" -# return self._journal_object - def get_type(self): """Gets the activity type.""" return env.get_bundle_service_name() @@ -170,9 +93,6 @@ class Activity(gtk.Window): else: logging.error('Cannot join the activity') - #ds = datastore.get_instance() - #self._journal_object = ds.get_activity_object(self._activity_id) - self.present() def share(self): @@ -193,9 +113,3 @@ class Activity(gtk.Window): self._bus = None if self._service: self._pservice.unregister_service(self._service) - - def _title_changed_cb(self, window, spec): - pass -# jobject = self.get_journal_object() -# if jobject: -# jobject.set_properties({'title' : self.props.title}) diff --git a/sugar/activity/Makefile.am b/sugar/activity/Makefile.am index fb1066c..0ef3d78 100644 --- a/sugar/activity/Makefile.am +++ b/sugar/activity/Makefile.am @@ -4,6 +4,7 @@ sugar_PYTHON = \ Activity.py \ ActivityFactory.py \ activityfactoryservice.py \ + activityservice.py \ bundle.py \ bundlebuilder.py \ bundleregistry.py -- cgit v0.9.1