Delete unused p2p model code. Fix distcheck.

master
Marco Pesenti Gritti 18 years ago
parent c018f5075e
commit a3be4492b2

@ -21,6 +21,7 @@ DISTCLEANFILES = \
intltool-update
EXTRA_DIST = \
COPYING.LIB \
intltool-merge.in \
intltool-update.in \
intltool-extract.in

@ -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

@ -1,5 +1,3 @@
SUBDIRS = model
sugardir = $(pythondir)/sugar/p2p
sugar_PYTHON = \
__init__.py \

@ -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)

@ -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)

@ -1,6 +0,0 @@
sugardir = $(pythondir)/sugar/p2p/model
sugar_PYTHON = \
__init__.py \
AbstractModel.py \
LocalModel.py \
RemoteModel.py

@ -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
Loading…
Cancel
Save