summaryrefslogtreecommitdiff
path: root/telepathy-glib/base-protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'telepathy-glib/base-protocol.c')
-rw-r--r--telepathy-glib/base-protocol.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/telepathy-glib/base-protocol.c b/telepathy-glib/base-protocol.c
index e18507d78..5c831d0d6 100644
--- a/telepathy-glib/base-protocol.c
+++ b/telepathy-glib/base-protocol.c
@@ -513,7 +513,7 @@ tp_cm_param_filter_string_nonempty (const TpCMParamSpec *paramspec,
* @get_connection_details: a callback used to implement the Protocol D-Bus
* properties that represent details of the connections provided by this
* protocol
- * @get_statuses: a callback used to implement the Protocol.Interface.Presence
+ * @dup_statuses: a callback used to implement the Protocol.Interface.Presence
* interface's Statuses property. Since 0.13.5
* @get_avatar_details: a callback used to implement the
* Protocol.Interface.Avatars interface's properties. Since 0.13.7
@@ -565,6 +565,8 @@ struct _TpBaseProtocolPrivate
gchar *english_name;
gchar *vcard_field;
AvatarSpecs avatar_specs;
+ /* (element-type Tp.PresenceStatusSpec) (transfer full) */
+ GList *statuses;
};
enum
@@ -698,10 +700,11 @@ tp_base_protocol_constructed (GObject *object)
TP_TYPE_SVC_PROTOCOL_INTERFACE_AVATARS1);
}
- if (cls->get_statuses != NULL)
+ if (cls->dup_statuses != NULL)
{
object_skeleton_take_svc_interface (skel,
TP_TYPE_SVC_PROTOCOL_INTERFACE_PRESENCE1);
+ self->priv->statuses = cls->dup_statuses (self);
}
if (TP_IS_PROTOCOL_ADDRESSING (self))
@@ -812,7 +815,7 @@ tp_base_protocol_get_immutable_properties (TpBaseProtocol *self)
TP_IFACE_PROTOCOL_INTERFACE_ADDRESSING1, "AddressableURISchemes",
NULL);
- if (cls->get_statuses != NULL)
+ if (cls->dup_statuses != NULL)
tp_dbus_properties_mixin_fill_properties_hash ((GObject *) self, table,
TP_IFACE_PROTOCOL_INTERFACE_PRESENCE1, "Statuses",
NULL);
@@ -886,6 +889,9 @@ tp_base_protocol_finalize (GObject *object)
g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST,
self->priv->requestable_channel_classes);
+ g_list_free_full (self->priv->statuses,
+ (GDestroyNotify) tp_presence_status_spec_unref);
+
if (finalize != NULL)
finalize (object);
}
@@ -938,26 +944,25 @@ protocol_prop_presence_getter (GObject *object,
{
case PPP_STATUSES:
{
- const TpPresenceStatusSpec *status =
- tp_base_protocol_get_statuses (self);
+ const GList *iter;
GHashTable *ret = g_hash_table_new_full (
g_str_hash, g_str_equal,
g_free, (GDestroyNotify) tp_value_array_free);
- for (; status->name != NULL; status++)
+ for (iter = self->priv->statuses; iter != NULL; iter = iter->next)
{
+ TpPresenceStatusSpec *status = iter->data;
GValueArray *val = NULL;
gchar *key = NULL;
- gboolean settable = status->self;
- gboolean message = (settable && status->has_message);
- TpConnectionPresenceType type = status->presence_type;
- key = g_strdup (status->name);
+ key = g_strdup (tp_presence_status_spec_get_name (status));
val = tp_value_array_build (3,
- G_TYPE_UINT, type,
- G_TYPE_BOOLEAN, settable,
- G_TYPE_BOOLEAN, message,
+ G_TYPE_UINT,
+ tp_presence_status_spec_get_presence_type (status),
+ G_TYPE_BOOLEAN,
+ tp_presence_status_spec_can_set_on_self (status),
+ G_TYPE_BOOLEAN, tp_presence_status_spec_has_message (status),
G_TYPE_INVALID);
g_hash_table_insert (ret, key, val);
@@ -1229,34 +1234,30 @@ tp_base_protocol_init (TpBaseProtocol *self)
}
/**
- * tp_base_protocol_get_statuses:
+ * tp_base_protocol_dup_statuses:
* @self: a Protocol object
*
* Get the statuses supported by this object. Subclasses implement this via
- * the #TpBaseProtocolClass.get_statuses virtual method.
+ * the #TpBaseProtocolClass.dup_statuses virtual method.
*
* If the object does not implement the Protocol.Interface.Presences
* interface, it need not implement this virtual method.
*
- * Returns: an array of #TpPresenceStatusSpec structs describing the
- * standard statuses supported by this protocol, with a final element
- * whose name element is guaranteed to be %NULL. The array must remain
- * valid at least as long as @self does.
- *
- * Since: 0.13.5
+ * Returns: (element-type Tp.PresenceStatusSpec): a list
+ * of #TpPresenceStatusSpec structs describing the
+ * standard statuses supported by this protocol.
*/
-const TpPresenceStatusSpec *
-tp_base_protocol_get_statuses (TpBaseProtocol *self)
+GList *
+tp_base_protocol_dup_statuses (TpBaseProtocol *self)
{
- static const TpPresenceStatusSpec none[] = { { NULL } };
TpBaseProtocolClass *cls = TP_BASE_PROTOCOL_GET_CLASS (self);
g_return_val_if_fail (cls != NULL, NULL);
- if (cls->get_statuses != NULL)
- return cls->get_statuses (self);
+ if (cls->dup_statuses != NULL)
+ return cls->dup_statuses (self);
- return none;
+ return NULL;
}
/**