Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-11-08 13:37:10 (GMT)
committer Simon McVittie <simon.mcvittie@collabora.co.uk>2007-11-08 13:37:10 (GMT)
commit31b7bd4fe26f1aaed2328611b51255a90b996067 (patch)
tree04155f1d0e9a67191e80c4e86dcf063479f0333d
parent4c8ab4306822e9db652b4f2b6b4d6d96d3804156 (diff)
When calling ShareActivity(), allow private, tags, color to be set by putting them in the properties dict, which was previously ignored (#4660)
-rw-r--r--NEWS3
-rw-r--r--src/presenceservice.py55
2 files changed, 42 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index e06a66f..4e62ef8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+* #4660: when calling ShareActivity(), allow private, tags, color to be set
+ by putting them in the properties dict, which was previously ignored (smcv)
+
Snapshot 944c5280b4
* #4585: Watch activity unique names on D-Bus for disappearences, implying
diff --git a/src/presenceservice.py b/src/presenceservice.py
index 03a8aaf..d098366 100644
--- a/src/presenceservice.py
+++ b/src/presenceservice.py
@@ -728,16 +728,6 @@ class PresenceService(ExportedGObject):
else:
return self._owner.object_path()
- @dbus.service.method(PRESENCE_INTERFACE, in_signature="sssa{sv}",
- out_signature="o", async_callbacks=('async_cb', 'async_err_cb'),
- sender_keyword='sender')
- def ShareActivity(self, actid, atype, name, properties, async_cb,
- async_err_cb, sender):
- _logger.debug('ShareActivity(actid=%r, atype=%r, name=%r, '
- 'properties=%r)', actid, atype, name, properties)
- self._share_activity(actid, atype, name, properties, True,
- async_cb, async_err_cb, sender)
-
def _get_preferred_plugin(self):
for tp in self._plugins:
if tp in self._connected_plugins:
@@ -757,29 +747,62 @@ class PresenceService(ExportedGObject):
for tp in self._handles_buddies:
tp.cleanup()
- def _share_activity(self, actid, atype, name, properties, private,
- async_cb, async_err_cb, sender):
+ @dbus.service.method(PRESENCE_INTERFACE, in_signature="sssa{sv}",
+ out_signature="o", async_callbacks=('async_cb', 'async_err_cb'),
+ sender_keyword='sender')
+ def ShareActivity(self, actid, atype, name, properties, async_cb,
+ async_err_cb, sender):
"""Create the shared Activity.
actid -- XXX
atype -- XXX
name -- XXX
properties -- XXX
- private -- bool: True for by-invitation-only sharing,
- False for publicly advertised sharing
async_cb -- function: Callback for success
async_err_cb -- function: Callback for failure
sender -- unique name of activity
"""
+ _logger.debug('ShareActivity(actid=%r, atype=%r, name=%r, '
+ 'properties=%r)', actid, atype, name, properties)
+
+ # FIXME: we should support the properties dict better.
+ # However, at the moment the only properties not already given
+ # by a separate argument are 'tags', 'color' and 'private', so let's
+ # hard-code support for those and only those. See #4660
+ private = properties.pop('private', True)
+ color = properties.pop('color', self._owner.props.color)
+ tags = properties.pop('tags', u'')
+
+ try:
+ if isinstance(color, unicode):
+ color = color.encode('ascii')
+ elif not isinstance(color, str):
+ raise ValueError('"color" property must be str or unicode')
+
+ if not isinstance(tags, unicode):
+ raise ValueError('"tags" property must be Unicode string')
+
+ if not isinstance(private, (dbus.Boolean, bool)):
+ raise ValueError('"private" property must be boolean')
+
+ if properties:
+ raise ValueError('Unsupported properties given: <%s>'
+ % ', '.join(properties.iterkeys()))
+ except ValueError, e:
+ async_err_cb(e)
+ return
+
objid = self._get_next_object_id()
# XXX: is the preferred Telepathy plugin always the right way to
# share the activity?
- color = self._owner.props.color
+ # We set private=True here - when the activity becomes shared
+ # via join(), we'll set private to the correct value.
activity = Activity(self._session_bus, objid, self,
self._get_preferred_plugin(), 0,
id=actid, type=atype,
name=name, color=color, local=True,
- private=private)
+ private=True, tags=tags)
+
activity.connect("validity-changed",
self._activity_validity_changed_cb)
activity.connect("disappeared", self._activity_disappeared_cb)