2006-10-15 01:24:45 +02:00
|
|
|
# Copyright (C) 2006, Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2006-10-31 13:10:34 +01:00
|
|
|
import os
|
|
|
|
|
2006-09-15 12:40:46 +02:00
|
|
|
from sugar.presence import PresenceService
|
2006-10-29 19:05:09 +01:00
|
|
|
from sugar.activity.bundleregistry import BundleRegistry
|
2006-09-15 16:19:56 +02:00
|
|
|
from model.Friends import Friends
|
2006-09-25 16:01:11 +02:00
|
|
|
from model.MeshModel import MeshModel
|
2006-09-15 12:52:37 +02:00
|
|
|
from model.Owner import ShellOwner
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2006-09-27 23:51:56 +02:00
|
|
|
class ShellModel:
|
2006-09-15 12:40:46 +02:00
|
|
|
def __init__(self):
|
|
|
|
self._current_activity = None
|
|
|
|
|
|
|
|
PresenceService.start()
|
|
|
|
self._pservice = PresenceService.get_instance()
|
|
|
|
|
2006-09-27 23:51:56 +02:00
|
|
|
self._owner = ShellOwner()
|
2006-09-15 12:40:46 +02:00
|
|
|
self._owner.announce()
|
2006-10-29 19:05:09 +01:00
|
|
|
|
2006-09-15 16:19:56 +02:00
|
|
|
self._friends = Friends()
|
2006-09-25 16:01:11 +02:00
|
|
|
self._mesh = MeshModel()
|
|
|
|
|
2006-10-29 19:05:09 +01:00
|
|
|
self._bundle_registry = BundleRegistry()
|
2006-10-31 13:10:34 +01:00
|
|
|
|
|
|
|
path = os.path.expanduser('~/Activities')
|
|
|
|
self._bundle_registry.add_search_path(path)
|
|
|
|
|
|
|
|
if os.environ.has_key('XDG_DATA_DIRS'):
|
|
|
|
for path in os.environ['XDG_DATA_DIRS'].split(':'):
|
|
|
|
bundles_path = os.path.join(path, 'activities')
|
|
|
|
self._bundle_registry.add_search_path(bundles_path)
|
2006-10-29 19:05:09 +01:00
|
|
|
|
|
|
|
def get_bundle_registry(self):
|
|
|
|
return self._bundle_registry
|
|
|
|
|
2006-09-25 16:01:11 +02:00
|
|
|
def get_mesh(self):
|
|
|
|
return self._mesh
|
2006-09-15 12:40:46 +02:00
|
|
|
|
|
|
|
def get_friends(self):
|
2006-09-15 16:19:56 +02:00
|
|
|
return self._friends
|
2006-09-15 12:40:46 +02:00
|
|
|
|
|
|
|
def get_invites(self):
|
2006-09-15 16:19:56 +02:00
|
|
|
return self._owner.get_invites()
|
2006-09-15 12:40:46 +02:00
|
|
|
|
|
|
|
def get_owner(self):
|
|
|
|
return self._owner
|
|
|
|
|
2006-09-18 11:48:33 +02:00
|
|
|
def set_current_activity(self, activity_id):
|
|
|
|
self._current_activity = activity_id
|
2006-09-27 23:51:56 +02:00
|
|
|
self._owner.set_current_activity(activity_id)
|
2006-09-15 12:40:46 +02:00
|
|
|
|
|
|
|
def get_current_activity(self):
|
|
|
|
return self._current_activity
|