diff --git a/Makefile.am b/Makefile.am index 4d5d49c2..3539e935 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,6 +21,7 @@ DISTCLEANFILES = \ intltool-update EXTRA_DIST = \ + COPYING.LIB \ intltool-merge.in \ intltool-update.in \ intltool-extract.in diff --git a/configure.ac b/configure.ac index fffb8690..70685674 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,6 @@ sugar/chat/Makefile sugar/chat/sketchpad/Makefile sugar/graphics/Makefile sugar/p2p/Makefile -sugar/p2p/model/Makefile sugar/presence/Makefile sugar/session/Makefile po/Makefile.in diff --git a/sugar/p2p/model/__init__.py b/services/presence/__init__.py similarity index 100% rename from sugar/p2p/model/__init__.py rename to services/presence/__init__.py diff --git a/sugar/p2p/Makefile.am b/sugar/p2p/Makefile.am index 71e79c67..6ec45539 100644 --- a/sugar/p2p/Makefile.am +++ b/sugar/p2p/Makefile.am @@ -1,5 +1,3 @@ -SUBDIRS = model - sugardir = $(pythondir)/sugar/p2p sugar_PYTHON = \ __init__.py \ diff --git a/sugar/p2p/model/AbstractModel.py b/sugar/p2p/model/AbstractModel.py deleted file mode 100644 index f34b4bd6..00000000 --- a/sugar/p2p/model/AbstractModel.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2006, Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -class AbstractModel: - def __init__(self): - self._listeners = [] - - def add_listener(self, listener): - self._listeners.append(listener) - - def _notify_model_change(self, key): - for listener in self._listeners: - listener(self, key) diff --git a/sugar/p2p/model/LocalModel.py b/sugar/p2p/model/LocalModel.py deleted file mode 100644 index ee266615..00000000 --- a/sugar/p2p/model/LocalModel.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2006, Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -import socket -import logging - -from sugar.p2p.Notifier import Notifier -from sugar.p2p.model.AbstractModel import AbstractModel -from sugar.p2p import network - -class ModelRequestHandler(object): - def __init__(self, model): - self._model = model - - def get_value(self, key): - return self._model.get_value(key) - - def set_value(self, key, value): - return self._model.set_value(key, value) - -class LocalModel(AbstractModel): - SERVICE_TYPE = "_olpc_model._tcp" - - def __init__(self, activity, pservice, service): - AbstractModel.__init__(self) - self._pservice = pservice - self._activity = activity - self._service = service - self._values = {} - - self._setup_service() - self._notifier = Notifier(service) - - def get_value(self, key): - return self._values[key] - - def set_value(self, key, value): - self._values[key] = value - self._notify_model_change(key) - self._notifier.notify(key) - - def _setup_service(self): - self._service = self._pservice.share_activity( - self._activity, stype = LocalModel.SERVICE_TYPE) - self._setup_server(self._service) - - # FIXME this is duplicated with StreamReader - def _setup_server(self, service): - port = service.get_port() - logging.debug('Start model server on port %d' % (port)) - p2p_server = network.GlibXMLRPCServer(("", port)) - p2p_server.register_instance(ModelRequestHandler(self)) - - def shutdown(self): - self._pservice.unregister_service(self._service) diff --git a/sugar/p2p/model/Makefile.am b/sugar/p2p/model/Makefile.am deleted file mode 100644 index 29253451..00000000 --- a/sugar/p2p/model/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -sugardir = $(pythondir)/sugar/p2p/model -sugar_PYTHON = \ - __init__.py \ - AbstractModel.py \ - LocalModel.py \ - RemoteModel.py diff --git a/sugar/p2p/model/RemoteModel.py b/sugar/p2p/model/RemoteModel.py deleted file mode 100644 index 4325c2de..00000000 --- a/sugar/p2p/model/RemoteModel.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2006, Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -import xmlrpclib -import logging - -from sugar.p2p.NotificationListener import NotificationListener -from sugar.p2p.model.AbstractModel import AbstractModel - -class RemoteModel(AbstractModel): - def __init__(self, service, notification_service): - AbstractModel.__init__(self) - - self._service = service - self._notification_service = notification_service - - addr = "http://%s:%d" % (service.get_address(), service.get_port()) - logging.debug('Setup remote model ' + addr) - self._client = xmlrpclib.ServerProxy(addr) - - self._setup_notification_listener() - - def get_value(self, key): - return self._client.get_value(key) - - def set_value(self, key, value): - self._client.set_value(key, value) - - def _setup_notification_listener(self): - self._notification = NotificationListener(self._notification_service) - self._notification.add_listener(self._notify_model_change) - - def shutdown(self): - pass diff --git a/sugar/setup.py b/sugar/setup.py old mode 100644 new mode 100755