Commit b6adcd95 authored by Mohammed Sadiq's avatar Mohammed Sadiq Committed by Mohammed Sadiq
Browse files

ma-account: Add API to delete 3pid

parent a7bbbe46
......@@ -1450,6 +1450,59 @@ chatty_ma_account_get_3pid_finish (ChattyMaAccount *self,
return g_task_propagate_boolean (G_TASK (result), error);
}
static void
ma_delete_3pid_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
ChattyMaAccount *self;
g_autoptr(GTask) task = user_data;
GError *error = NULL;
g_assert (G_IS_TASK (task));
self = g_task_get_source_object (task);
g_assert (CHATTY_IS_MA_ACCOUNT (self));
matrix_api_delete_3pid_finish (self->matrix_api, result, &error);
if (error)
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
}
void
chatty_ma_account_delete_3pid_async (ChattyMaAccount *self,
const char *value,
ChattyIdType type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task = NULL;
g_return_if_fail (CHATTY_IS_MA_ACCOUNT (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
matrix_api_delete_3pid_async (self->matrix_api,
value, type, cancellable,
ma_delete_3pid_cb, task);
}
gboolean
chatty_ma_account_delete_3pid_finish (ChattyMaAccount *self,
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (CHATTY_IS_MA_ACCOUNT (self), FALSE);
g_return_val_if_fail (G_IS_TASK (result), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
void
chatty_ma_account_add_chat (ChattyMaAccount *self,
ChattyChat *chat)
......
......@@ -70,6 +70,15 @@ gboolean chatty_ma_account_get_3pid_finish (ChattyMaAccount *self,
GPtrArray **phones,
GAsyncResult *result,
GError **error);
void chatty_ma_account_delete_3pid_async (ChattyMaAccount *self,
const char *value,
ChattyIdType type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean chatty_ma_account_delete_3pid_finish (ChattyMaAccount *self,
GAsyncResult *result,
GError **error);
/* For tests */
void chatty_ma_account_add_chat (ChattyMaAccount *self,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment