Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/model
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-03-09 03:17:33 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-03-09 03:17:33 (GMT)
commit8dc201bc5f166a84a50535252d35e8f9586813e4 (patch)
treeacaf5b7d0172dad33117405573dad65c067c4f6f /shell/model
parent5210231e8fc9845f46ccdb57164b50a56ecdc02b (diff)
Expose owner details through the Shell's DBus service
For security, we need the PresenceService to listen for changes to the owner's attributes, like changed color, nickname, icon, and current activity, rather than having D-Bus API in the PS itself that any process could call. So, the shell provides signals when these attributes change, which the PS listens to and pushes out over the network accordingly.
Diffstat (limited to 'shell/model')
-rw-r--r--shell/model/Owner.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/shell/model/Owner.py b/shell/model/Owner.py
index 9b5ef9b..760697a 100644
--- a/shell/model/Owner.py
+++ b/shell/model/Owner.py
@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import gobject
import os
import random
import base64
@@ -30,11 +31,24 @@ from model.Invites import Invites
PRESENCE_SERVICE_TYPE = "_presence_olpc._tcp"
-class ShellOwner(object):
+class ShellOwner(gobject.GObject):
+ __gtype_name__ = "ShellOwner"
+
+ __gsignals__ = {
+ 'nick-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_STRING])),
+ 'color-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT])),
+ 'icon-changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ([gobject.TYPE_PYOBJECT]))
+ }
+
"""Class representing the owner of this machine/instance. This class
runs in the shell and serves up the buddy icon and other stuff. It's the
server portion of the Owner, paired with the client portion in Buddy.py."""
def __init__(self):
+ gobject.GObject.__init__(self)
+
self._nick = profile.get_nick_name()
user_dir = env.get_profile_path()
@@ -45,12 +59,14 @@ class ShellOwner(object):
continue
fd = open(os.path.join(user_dir, fname), "r")
self._icon = fd.read()
- if self._icon:
- # Get the icon's hash
- import md5, binascii
- digest = md5.new(self._icon).digest()
- self._icon_hash = util.printable_hash(digest)
fd.close()
+ if not self._icon:
+ raise RuntimeError("No buddy icon exists")
+
+ # Get the icon's hash
+ import md5, binascii
+ digest = md5.new(self._icon).digest()
+ self._icon_hash = util.printable_hash(digest)
break
self._pservice = PresenceService.get_instance()
@@ -60,6 +76,7 @@ class ShellOwner(object):
self._last_activity_update = time.time()
self._pending_activity_update_timer = None
self._pending_activity_update = None
+ self._current_activity = None
def get_invites(self):
return self._invites
@@ -94,6 +111,7 @@ class ShellOwner(object):
self._last_activity_update = time.time()
self._pending_activity_update_timer = None
if self._pending_activity_update:
+ self.emit('current-activity-changed', self._pending_activity_update)
logging.debug("*** Updating current activity to %s" % self._pending_activity_update)
self._service.set_published_value('curact', dbus.String(self._pending_activity_update))
return False