Implement protocol->normalize_contact

This commit is contained in:
Gergely Polonkai 2015-12-09 13:25:57 +01:00
parent 69b64315ca
commit dab7e05958
3 changed files with 29 additions and 1 deletions

View File

@ -18,6 +18,8 @@
#include "matrix-handles.h"
#include <telepathy-glib/telepathy-glib.h>
#define MATRIX_DEBUG_FLAG MATRIX_DEBUG_PARSER
#include "matrix-debug.h"
@ -40,3 +42,20 @@ matrix_id_is_valid(const gchar *matrix_id, gboolean strict_mode)
return TRUE;
}
gchar *
matrix_normalize_id(const gchar *id, GError **err)
{
if (!matrix_id_is_valid(id, FALSE)) {
g_set_error(err,
TP_ERROR, TP_ERROR_INVALID_HANDLE,
"Invalid Matrix ID");
return NULL;
}
/* telepathy-idle sets the nickname to lowercase here. Im not
* sure it can be done with Matrix IDs. TODO: check if it can.
*/
return g_strdup(id);
}

View File

@ -22,5 +22,6 @@
#include <glib.h>
gboolean matrix_id_is_valid(const gchar *matrix_id, gboolean strict_mode);
gchar *matrix_normalize_id(const gchar *id, GError **err);
#endif /* __MATRIX_HANDLES_H__ */

View File

@ -83,6 +83,14 @@ new_connection(TpBaseProtocol *protocol G_GNUC_UNUSED,
NULL);
}
static gchar *
normalize_contact(TpBaseProtocol *protocol G_GNUC_UNUSED,
const gchar *contact,
GError **err)
{
return matrix_normalize_id(contact, err);
}
static void
matrix_protocol_class_init(MatrixProtocolClass *klass)
{
@ -90,8 +98,8 @@ matrix_protocol_class_init(MatrixProtocolClass *klass)
base_class->get_parameters = get_parameters;
base_class->new_connection = new_connection;
/*
base_class->normalize_contact = normalize_contact;
/*
base_class->identify_account = identify_account;
base_class->get_interfaces_array = get_interfaces_array;
base_class->get_connection_details = get_connection_details;