diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-10-28 14:53:04 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-11 16:49:16 +0000 |
commit | 712b3b082f740d1be16b7c74ad7a457aa91947c6 (patch) | |
tree | 0c0340a000f74386d2032e6b47cf2c576de0f702 | |
parent | a7cff4b6a4801259ab9190a29f99a185b10e0962 (diff) |
TpPresenceStatusSpec: add some accessors
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71048
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 4 | ||||
-rw-r--r-- | telepathy-glib/presence-mixin.c | 101 | ||||
-rw-r--r-- | telepathy-glib/presence-mixin.h | 16 |
3 files changed, 108 insertions, 13 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 36845e623..c8cef3d83 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -2301,6 +2301,10 @@ TP_CONTACTS_MIXIN <FILE>presence-mixin</FILE> TpPresenceStatusOptionalArgumentSpec TpPresenceStatusSpec +tp_presence_status_spec_can_set_on_self +tp_presence_status_spec_get_name +tp_presence_status_spec_get_presence_type +tp_presence_status_spec_has_message TpPresenceMixinStatusAvailableFunc TpPresenceMixinGetContactStatusesFunc TpPresenceMixinSetOwnStatusFunc diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c index de0158e8f..f8d44b816 100644 --- a/telepathy-glib/presence-mixin.c +++ b/telepathy-glib/presence-mixin.c @@ -1257,25 +1257,15 @@ tp_presence_mixin_get_simple_presence_dbus_property (GObject *object, for (i=0; mixin_cls->statuses[i].name != NULL; i++) { - const TpPresenceStatusOptionalArgumentSpec *specs; - int j; - gboolean message = FALSE; + gboolean message; /* we include statuses here even if they're not available * to set on yourself */ if (!check_status_available (object, mixin_cls, i, NULL, FALSE)) continue; - specs = mixin_cls->statuses[i].optional_arguments; - - for (j = 0; specs != NULL && specs[j].name != NULL; j++) - { - if (!tp_strdiff (specs[j].name, "message")) - { - message = TRUE; - break; - } - } + message = tp_presence_status_spec_has_message ( + &mixin_cls->statuses[i]); status = tp_value_array_build (3, G_TYPE_UINT, (guint) mixin_cls->statuses[i].presence_type, @@ -1591,3 +1581,88 @@ tp_presence_mixin_simple_presence_register_with_contacts_mixin (GObject *obj) tp_presence_mixin_simple_presence_fill_contact_attributes); } +/** + * tp_presence_status_spec_get_presence_type: + * @self: a presence status specification + * + * Return the category into which this presence type falls. For instance, + * for XMPP's "" (do not disturb) status, this would return + * %TP_CONNECTION_PRESENCE_TYPE_BUSY. + * + * Returns: a #TpConnectionPresenceType + * Since: 0.UNRELEASED + */ +TpConnectionPresenceType +tp_presence_status_spec_get_presence_type (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, TP_CONNECTION_PRESENCE_TYPE_UNSET); + + return self->presence_type; +} + +/** + * tp_presence_status_spec_get_name: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: (transfer none): the name of this presence status, + * such as "available" or "out-to-lunch". + * Since: 0.UNRELEASED + */ +const gchar * +tp_presence_status_spec_get_name (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, NULL); + + return self->name; +} + +/** + * tp_presence_status_spec_can_set_on_self: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: %TRUE if the user can set this presence status on themselves (most + * statuses), or %FALSE if they cannot directly set it on + * themselves (typically used for %TP_CONNECTION_PRESENCE_TYPE_OFFLINE + * and %TP_CONNECTION_PRESENCE_TYPE_ERROR) + * Since: 0.UNRELEASED + */ +gboolean +tp_presence_status_spec_can_set_on_self (const TpPresenceStatusSpec *self) +{ + g_return_val_if_fail (self != NULL, FALSE); + + return self->self; +} + +/** + * tp_presence_status_spec_has_message: + * @self: a presence status specification + * + * <!-- --> + * + * Returns: %TRUE if this presence status is accompanied by an optional + * human-readable message + * Since: 0.UNRELEASED + */ +gboolean +tp_presence_status_spec_has_message (const TpPresenceStatusSpec *self) +{ + const TpPresenceStatusOptionalArgumentSpec *arg; + + g_return_val_if_fail (self != NULL, FALSE); + + if (self->optional_arguments == NULL) + return FALSE; + + for (arg = self->optional_arguments; arg->name != NULL; arg++) + { + if (!tp_strdiff (arg->name, "message") && !tp_strdiff (arg->dtype, "s")) + return TRUE; + } + + return FALSE; +} diff --git a/telepathy-glib/presence-mixin.h b/telepathy-glib/presence-mixin.h index 63d2c7e38..6654c5b8c 100644 --- a/telepathy-glib/presence-mixin.h +++ b/telepathy-glib/presence-mixin.h @@ -56,6 +56,22 @@ struct _TpPresenceStatusSpec { gpointer _future2; }; +_TP_AVAILABLE_IN_UNRELEASED +TpConnectionPresenceType tp_presence_status_spec_get_presence_type ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_UNRELEASED +const gchar *tp_presence_status_spec_get_name ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_UNRELEASED +gboolean tp_presence_status_spec_can_set_on_self ( + const TpPresenceStatusSpec *self); + +_TP_AVAILABLE_IN_UNRELEASED +gboolean tp_presence_status_spec_has_message ( + const TpPresenceStatusSpec *self); + typedef struct _TpPresenceStatus TpPresenceStatus; struct _TpPresenceStatus { |