Implement protocol->normalize_contact
This commit is contained in:
parent
69b64315ca
commit
dab7e05958
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "matrix-handles.h"
|
#include "matrix-handles.h"
|
||||||
|
|
||||||
|
#include <telepathy-glib/telepathy-glib.h>
|
||||||
|
|
||||||
#define MATRIX_DEBUG_FLAG MATRIX_DEBUG_PARSER
|
#define MATRIX_DEBUG_FLAG MATRIX_DEBUG_PARSER
|
||||||
#include "matrix-debug.h"
|
#include "matrix-debug.h"
|
||||||
|
|
||||||
@ -40,3 +42,20 @@ matrix_id_is_valid(const gchar *matrix_id, gboolean strict_mode)
|
|||||||
|
|
||||||
return TRUE;
|
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. I’m not
|
||||||
|
* sure it can be done with Matrix IDs. TODO: check if it can.
|
||||||
|
*/
|
||||||
|
return g_strdup(id);
|
||||||
|
}
|
||||||
|
@ -22,5 +22,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
gboolean matrix_id_is_valid(const gchar *matrix_id, gboolean strict_mode);
|
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__ */
|
#endif /* __MATRIX_HANDLES_H__ */
|
||||||
|
@ -83,6 +83,14 @@ new_connection(TpBaseProtocol *protocol G_GNUC_UNUSED,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
normalize_contact(TpBaseProtocol *protocol G_GNUC_UNUSED,
|
||||||
|
const gchar *contact,
|
||||||
|
GError **err)
|
||||||
|
{
|
||||||
|
return matrix_normalize_id(contact, err);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
matrix_protocol_class_init(MatrixProtocolClass *klass)
|
matrix_protocol_class_init(MatrixProtocolClass *klass)
|
||||||
{
|
{
|
||||||
@ -90,8 +98,8 @@ matrix_protocol_class_init(MatrixProtocolClass *klass)
|
|||||||
|
|
||||||
base_class->get_parameters = get_parameters;
|
base_class->get_parameters = get_parameters;
|
||||||
base_class->new_connection = new_connection;
|
base_class->new_connection = new_connection;
|
||||||
/*
|
|
||||||
base_class->normalize_contact = normalize_contact;
|
base_class->normalize_contact = normalize_contact;
|
||||||
|
/*
|
||||||
base_class->identify_account = identify_account;
|
base_class->identify_account = identify_account;
|
||||||
base_class->get_interfaces_array = get_interfaces_array;
|
base_class->get_interfaces_array = get_interfaces_array;
|
||||||
base_class->get_connection_details = get_connection_details;
|
base_class->get_connection_details = get_connection_details;
|
||||||
|
Loading…
Reference in New Issue
Block a user