2006-07-15 12:31:06 +02:00
|
|
|
import xml.sax.saxutils
|
|
|
|
|
2006-07-14 15:47:42 +02:00
|
|
|
import gobject
|
|
|
|
|
2006-07-14 16:40:45 +02:00
|
|
|
from sugar.presence.PresenceService import PresenceService
|
|
|
|
|
2006-07-14 15:47:42 +02:00
|
|
|
class ActivityInfo:
|
|
|
|
def __init__(self, service):
|
|
|
|
self._service = service
|
|
|
|
|
|
|
|
def get_id(self):
|
2006-07-26 12:57:54 +02:00
|
|
|
activity_id = self._service.get_id()
|
2006-07-15 12:31:06 +02:00
|
|
|
|
|
|
|
def get_type(self):
|
2006-07-26 12:57:54 +02:00
|
|
|
# FIXME
|
|
|
|
return "_web_olpc._udp"
|
2006-07-14 15:47:42 +02:00
|
|
|
|
|
|
|
def get_title(self):
|
2006-07-26 12:57:54 +02:00
|
|
|
return "FIXME Title"
|
2006-07-15 12:31:06 +02:00
|
|
|
|
|
|
|
def get_service(self):
|
|
|
|
return self._service
|
2006-07-14 15:47:42 +02:00
|
|
|
|
|
|
|
class ActivitiesModel(gobject.GObject):
|
|
|
|
__gsignals__ = {
|
|
|
|
'activity-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
|
|
|
([gobject.TYPE_PYOBJECT])),
|
2006-07-14 16:40:45 +02:00
|
|
|
'activity-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
|
|
|
([gobject.TYPE_PYOBJECT]))
|
2006-07-14 15:47:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self):
|
2006-07-14 16:40:45 +02:00
|
|
|
gobject.GObject.__init__(self)
|
2006-07-14 15:47:42 +02:00
|
|
|
|
|
|
|
self._activities = []
|
|
|
|
|
2006-07-20 10:12:42 +02:00
|
|
|
self._pservice = PresenceService()
|
2006-07-23 16:21:00 +02:00
|
|
|
self._pservice.connect("activity-appeared", self._on_activity_announced_cb)
|
2006-07-14 15:47:42 +02:00
|
|
|
|
|
|
|
def add_activity(self, service):
|
|
|
|
activity_info = ActivityInfo(service)
|
|
|
|
self._activities.append(activity_info)
|
|
|
|
self.emit('activity-added', activity_info)
|
|
|
|
|
|
|
|
def __iter__(self):
|
2006-07-14 16:40:45 +02:00
|
|
|
return self._activities.__iter__()
|
2006-07-14 15:47:42 +02:00
|
|
|
|
2006-07-26 02:04:15 +02:00
|
|
|
def _on_activity_announced_cb(self, pservice, activity):
|
2006-07-26 12:57:54 +02:00
|
|
|
self.add_activity(activity)
|