aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-tp-chat.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-11 20:07:39 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-13 23:59:22 +0800
commitdd2c190bbbdbeec07e3923eb9d99af7d0e84b055 (patch)
treeebf1d4d142d517c5987b6b0a52ef4cb6ffb7080f /libempathy/empathy-tp-chat.c
parent07e4c25c4a39705b7b6ecaaac6c8e001d611a713 (diff)
downloadgsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar.gz
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar.bz2
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar.lz
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar.xz
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.tar.zst
gsoc2013-empathy-dd2c190bbbdbeec07e3923eb9d99af7d0e84b055.zip
tp-chat: add API to check if a password is required
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r--libempathy/empathy-tp-chat.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 79136156a..73c446a7d 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -55,6 +55,10 @@ typedef struct {
GQueue *pending_messages_queue;
gboolean had_properties_list;
GPtrArray *properties;
+ TpChannelPasswordFlags password_flags;
+ /* TRUE if we fetched the password flag of the channel or if it's not needed
+ * (channel doesn't implement the Password interface) */
+ gboolean got_password_flags;
gboolean ready;
} EmpathyTpChatPriv;
@@ -1035,6 +1039,20 @@ tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
}
+static void
+got_password_flags_cb (TpChannel *proxy,
+ guint password_flags,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ EmpathyTpChat *self = EMPATHY_TP_CHAT (weak_object);
+ EmpathyTpChatPriv *priv = GET_PRIV (self);
+
+ priv->got_password_flags = TRUE;
+ priv->password_flags = password_flags;
+}
+
static GObject *
tp_chat_constructor (GType type,
guint n_props,
@@ -1105,6 +1123,17 @@ tp_chat_constructor (GType type,
G_OBJECT (chat), NULL);
}
+ /* Check if the chat is password protected */
+ if (tp_proxy_has_interface_by_id (priv->channel,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_PASSWORD)) {
+ priv->got_password_flags = FALSE;
+ tp_cli_channel_interface_password_call_get_password_flags (priv->channel,
+ -1, got_password_flags_cb, chat, NULL, chat);
+ } else {
+ /* No Password interface, so no need to fetch the password flags */
+ priv->got_password_flags = TRUE;
+ }
+
return chat;
}
@@ -1477,3 +1506,10 @@ empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat,
g_list_free (msgs);
}
+gboolean
+empathy_tp_chat_password_needed (EmpathyTpChat *self)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (self);
+
+ return priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE;
+}