aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-25 20:23:50 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-06-22 15:23:26 +0800
commit24e45ffb59d929e39d8ceea3ef04c73a5bcfc912 (patch)
treee70b6d262c6e8092a30fd01376d2ecc38dbc2f2b
parent4f7fbd7ee74147e1f4897ca25d140da02ddceb93 (diff)
downloadgsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar.gz
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar.bz2
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar.lz
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar.xz
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.tar.zst
gsoc2013-empathy-24e45ffb59d929e39d8ceea3ef04c73a5bcfc912.zip
Use tp-glib password API (#651055)
-rw-r--r--libempathy-gtk/empathy-chat.c10
-rw-r--r--libempathy/empathy-tp-chat.c136
-rw-r--r--libempathy/empathy-tp-chat.h10
3 files changed, 8 insertions, 148 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index cd73c1f0d..69d81f993 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -3370,7 +3370,7 @@ provide_password_cb (GObject *tp_chat,
EmpathyChatPriv *priv = GET_PRIV (self);
GError *error = NULL;
- if (!empathy_tp_chat_provide_password_finish (EMPATHY_TP_CHAT (tp_chat), res,
+ if (!tp_channel_provide_password_finish (TP_CHANNEL (tp_chat), res,
&error)) {
DEBUG ("error: %s", error->message);
/* FIXME: what should we do if that's another error? Close the channel?
@@ -3434,7 +3434,7 @@ password_infobar_response_cb (GtkWidget *info_bar,
password = gtk_entry_get_text (GTK_ENTRY (data->entry));
- empathy_tp_chat_provide_password_async (priv->tp_chat, password,
+ tp_channel_provide_password_async (TP_CHANNEL (priv->tp_chat), password,
provide_password_cb, data);
gtk_widget_set_sensitive (data->button, FALSE);
@@ -3597,7 +3597,7 @@ provide_saved_password_cb (GObject *tp_chat,
EmpathyChatPriv *priv = GET_PRIV (self);
GError *error = NULL;
- if (!empathy_tp_chat_provide_password_finish (EMPATHY_TP_CHAT (tp_chat), res,
+ if (!tp_channel_provide_password_finish (TP_CHANNEL (tp_chat), res,
&error)) {
DEBUG ("error: %s", error->message);
/* FIXME: what should we do if that's another error? Close the channel?
@@ -3637,7 +3637,7 @@ chat_room_got_password_cb (GObject *source,
return;
}
- empathy_tp_chat_provide_password_async (priv->tp_chat, password,
+ tp_channel_provide_password_async (TP_CHANNEL (priv->tp_chat), password,
provide_saved_password_cb, self);
}
@@ -3646,7 +3646,7 @@ chat_password_needed_changed_cb (EmpathyChat *self)
{
EmpathyChatPriv *priv = GET_PRIV (self);
- if (empathy_tp_chat_password_needed (priv->tp_chat)) {
+ if (tp_channel_password_needed (TP_CHANNEL (priv->tp_chat))) {
empathy_keyring_get_room_password_async (priv->account,
empathy_tp_chat_get_id (priv->tp_chat),
chat_room_got_password_cb, self);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 63b1e87d6..18539d3e0 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -49,10 +49,6 @@ struct _EmpathyTpChatPrivate {
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 can_upgrade_to_muc;
GHashTable *messages_being_sent;
@@ -67,7 +63,6 @@ enum {
PROP_0,
PROP_ACCOUNT,
PROP_REMOTE_CONTACT,
- PROP_PASSWORD_NEEDED,
PROP_N_MESSAGES_SENDING,
};
@@ -860,19 +855,18 @@ tp_chat_finalize (GObject *object)
static void
check_almost_ready (EmpathyTpChat *self)
{
+ TpChannel *channel = (TpChannel *) self;
+
if (self->priv->ready_result == NULL)
return;
if (self->priv->user == NULL)
return;
- if (!self->priv->got_password_flags)
- return;
-
/* We need either the members (room) or the remote contact (private chat).
* If the chat is protected by a password we can't get these information so
* consider the chat as ready so it can be presented to the user. */
- if (!empathy_tp_chat_password_needed (self) && self->priv->members == NULL &&
+ if (!tp_channel_password_needed (channel) && self->priv->members == NULL &&
self->priv->remote_contact == NULL)
return;
@@ -1223,42 +1217,6 @@ tp_chat_got_self_contact_cb (TpConnection *connection,
}
static void
-password_flags_changed_cb (TpChannel *channel,
- guint added,
- guint removed,
- gpointer user_data,
- GObject *weak_object)
-{
- EmpathyTpChat *self = EMPATHY_TP_CHAT (weak_object);
- gboolean was_needed, needed;
-
- was_needed = empathy_tp_chat_password_needed (self);
-
- self->priv->password_flags |= added;
- self->priv->password_flags ^= removed;
-
- needed = empathy_tp_chat_password_needed (self);
-
- if (was_needed != needed)
- g_object_notify (G_OBJECT (self), "password-needed");
-}
-
-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);
-
- self->priv->got_password_flags = TRUE;
- self->priv->password_flags = password_flags;
-
- check_almost_ready (EMPATHY_TP_CHAT (self));
-}
-
-static void
tp_chat_get_property (GObject *object,
guint param_id,
GValue *value,
@@ -1273,9 +1231,6 @@ tp_chat_get_property (GObject *object,
case PROP_REMOTE_CONTACT:
g_value_set_object (value, self->priv->remote_contact);
break;
- case PROP_PASSWORD_NEEDED:
- g_value_set_boolean (value, empathy_tp_chat_password_needed (self));
- break;
case PROP_N_MESSAGES_SENDING:
g_value_set_uint (value,
g_hash_table_size (self->priv->messages_being_sent));
@@ -1362,14 +1317,6 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
G_PARAM_READABLE));
g_object_class_install_property (object_class,
- PROP_PASSWORD_NEEDED,
- g_param_spec_boolean ("password-needed",
- "password needed",
- "TRUE if a password is needed to join the channel",
- FALSE,
- G_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
PROP_N_MESSAGES_SENDING,
g_param_spec_uint ("n-messages-sending",
"Num Messages Sending",
@@ -1584,67 +1531,6 @@ empathy_tp_chat_acknowledge_all_messages (EmpathyTpChat *self)
(GSList *) empathy_tp_chat_get_pending_messages (self));
}
-gboolean
-empathy_tp_chat_password_needed (EmpathyTpChat *self)
-{
- return self->priv->password_flags & TP_CHANNEL_PASSWORD_FLAG_PROVIDE;
-}
-
-static void
-provide_password_cb (TpChannel *channel,
- gboolean correct,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- GSimpleAsyncResult *result = user_data;
-
- if (error != NULL) {
- g_simple_async_result_set_from_error (result, error);
- }
- else if (!correct) {
- /* The current D-Bus API is a bit weird so re-use the
- * AuthenticationFailed error */
- g_simple_async_result_set_error (result, TP_ERRORS,
- TP_ERROR_AUTHENTICATION_FAILED, "Wrong password");
- }
-
- g_simple_async_result_complete (result);
- g_object_unref (result);
-}
-
-void
-empathy_tp_chat_provide_password_async (EmpathyTpChat *self,
- const gchar *password,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *result;
-
- result = g_simple_async_result_new (G_OBJECT (self),
- callback, user_data,
- empathy_tp_chat_provide_password_finish);
-
- tp_cli_channel_interface_password_call_provide_password
- ((TpChannel *) self, -1, password, provide_password_cb, result,
- NULL, G_OBJECT (self));
-}
-
-gboolean
-empathy_tp_chat_provide_password_finish (EmpathyTpChat *self,
- GAsyncResult *result,
- GError **error)
-{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
- error))
- return FALSE;
-
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (self), empathy_tp_chat_provide_password_finish), FALSE);
-
- return TRUE;
-}
-
/**
* empathy_tp_chat_can_add_contact:
*
@@ -1849,22 +1735,6 @@ conn_prepared_cb (GObject *source,
NULL, NULL,
G_OBJECT (self), NULL);
}
-
- /* Check if the chat is password protected */
- if (tp_proxy_has_interface_by_id (self,
- TP_IFACE_QUARK_CHANNEL_INTERFACE_PASSWORD)) {
- self->priv->got_password_flags = FALSE;
-
- tp_cli_channel_interface_password_connect_to_password_flags_changed
- (channel, password_flags_changed_cb, self, NULL,
- G_OBJECT (self), NULL);
-
- tp_cli_channel_interface_password_call_get_password_flags
- (channel, -1, got_password_flags_cb, self, NULL, G_OBJECT (self));
- } else {
- /* No Password interface, so no need to fetch the password flags */
- self->priv->got_password_flags = TRUE;
- }
}
static void
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index 20ba02a68..0b28312b9 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -97,16 +97,6 @@ void empathy_tp_chat_acknowledge_messages (EmpathyTpChat *chat,
const GSList *messages);
void empathy_tp_chat_acknowledge_all_messages (EmpathyTpChat *chat);
-gboolean empathy_tp_chat_password_needed (EmpathyTpChat *chat);
-
-void empathy_tp_chat_provide_password_async (EmpathyTpChat *chat,
- const gchar *password,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-gboolean empathy_tp_chat_provide_password_finish (EmpathyTpChat *chat,
- GAsyncResult *result,
- GError **error);
gboolean empathy_tp_chat_can_add_contact (EmpathyTpChat *self);
void empathy_tp_chat_leave (EmpathyTpChat *chat,