Implement protocol->get_connection_details

This commit is contained in:
Gergely Polonkai 2015-12-09 14:00:10 +01:00
parent 00bda02bc9
commit 392f8307cb
8 changed files with 259 additions and 1 deletions

View File

@ -14,6 +14,10 @@ libmatrix_convenience_la_SOURCES = \
matrix-handles.h \ matrix-handles.h \
matrix-connection.c \ matrix-connection.c \
matrix-connection.h \ matrix-connection.h \
matrix-im-manager.c \
matrix-im-manager.h \
matrix-muc-manager.c \
matrix-muc-manager.h \
$(NULL) $(NULL)
nodist_libmatrix_convenience_la_SOURCES = \ nodist_libmatrix_convenience_la_SOURCES = \

View File

@ -38,6 +38,17 @@ enum {
PROP_COUNT PROP_COUNT
}; };
static const gchar *interfaces_always_present[] = {
TP_IFACE_CONNECTION_INTERFACE_ALIASING,
/*
TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO,
MATRIX_IFACE_CONNECTION_INTERFACE_RENAMING,
*/
TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
NULL
};
G_DEFINE_TYPE_WITH_CODE( G_DEFINE_TYPE_WITH_CODE(
MatrixConnection, matrix_connection, TP_TYPE_BASE_CONNECTION, MatrixConnection, matrix_connection, TP_TYPE_BASE_CONNECTION,
G_IMPLEMENT_INTERFACE( G_IMPLEMENT_INTERFACE(
@ -414,3 +425,11 @@ matrix_connection_init(MatrixConnection *connection)
tp_base_connection_register_with_contacts_mixin( tp_base_connection_register_with_contacts_mixin(
(TpBaseConnection *)connection); (TpBaseConnection *)connection);
} }
const gchar * const *
matrix_connection_get_implemented_interfaces(void)
{
/* We dont have any conditionally implemented interfaces */
return interfaces_always_present;
}

View File

@ -51,6 +51,8 @@ struct _MatrixConnectionClass {
GType matrix_connection_get_type(void) G_GNUC_CONST; GType matrix_connection_get_type(void) G_GNUC_CONST;
const gchar * const *matrix_connection_get_implemented_interfaces(void);
G_END_DECLS G_END_DECLS
#endif /* __MATRIX_CONNECTION_H__ */ #endif /* __MATRIX_CONNECTION_H__ */

45
src/matrix-im-manager.c Normal file
View File

@ -0,0 +1,45 @@
/*
* This file is part of telepathy-matrix
*
* telepathy-matrix is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* telepathy-matrix is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with telepathy-matrix. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "matrix-im-manager.h"
typedef struct _MatrixIMManagerPrivate {
/* TODO: You must add something here, or GLib will produce warnings! */
} MatrixIMManagerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(MatrixIMManager, matrix_im_manager, G_TYPE_OBJECT);
static void
matrix_im_manager_finalize(GObject *gobject)
{
g_signal_handlers_destroy(gobject);
G_OBJECT_CLASS(matrix_im_manager_parent_class)->finalize(gobject);
}
static void
matrix_im_manager_class_init(MatrixIMManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = matrix_im_manager_finalize;
}
static void
matrix_im_manager_init(MatrixIMManager *im_manager)
{
}

51
src/matrix-im-manager.h Normal file
View File

@ -0,0 +1,51 @@
/*
* This file is part of telepathy-matrix
*
* telepathy-matrix is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* telepathy-matrix is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with telepathy-matrix. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __MATRIX_IM_MANAGER_H__
#define __MATRIX_IM_MANAGER_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define MATRIX_TYPE_IM_MANAGER (matrix_im_manager_get_type())
#define MATRIX_IM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_IM_MANAGER, MatrixIMManager))
#define MATRIX_IM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_IM_MANAGER, MatrixIMManagerClass))
#define MATRIX_IS_IM_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_IM_MANAGER))
#define MATRIX_IS_IM_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_IM_MANAGER))
#define MATRIX_IM_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_IM_MANAGER, MatrixIMManagerClass))
typedef struct _MatrixIMManager MatrixIMManager;
typedef struct _MatrixIMManagerClass MatrixIMManagerClass;
struct _MatrixIMManager {
/* Parent instance structure */
GObject parent_instance;
/* Instance members */
};
struct _MatrixIMManagerClass {
GObjectClass parent_class;
};
GType matrix_im_manager_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif /* __MATRIX_IM_MANAGER_H__ */

45
src/matrix-muc-manager.c Normal file
View File

@ -0,0 +1,45 @@
/*
* This file is part of telepathy-matrix
*
* telepathy-matrix is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* telepathy-matrix is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with telepathy-matrix. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "matrix-muc-manager.h"
typedef struct _MatrixMUCManagerPrivate {
/* TODO: You must add something here, or GLib will produce warnings! */
} MatrixMUCManagerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(MatrixMUCManager, matrix_muc_manager, G_TYPE_OBJECT);
static void
matrix_muc_manager_finalize(GObject *gobject)
{
g_signal_handlers_destroy(gobject);
G_OBJECT_CLASS(matrix_muc_manager_parent_class)->finalize(gobject);
}
static void
matrix_muc_manager_class_init(MatrixMUCManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gobject_class->finalize = matrix_muc_manager_finalize;
}
static void
matrix_muc_manager_init(MatrixMUCManager *muc_manager)
{
}

51
src/matrix-muc-manager.h Normal file
View File

@ -0,0 +1,51 @@
/*
* This file is part of telepathy-matrix
*
* telepathy-matrix is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* telepathy-matrix is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with telepathy-matrix. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __MATRIX_MUC_MANAGER_H__
#define __MATRIX_MUC_MANAGER_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define MATRIX_TYPE_MUC_MANAGER (matrix_muc_manager_get_type())
#define MATRIX_MUC_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_MUC_MANAGER, MatrixMUCManager))
#define MATRIX_MUC_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_MUC_MANAGER, MatrixMUCManagerClass))
#define MATRIX_IS_MUC_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_MUC_MANAGER))
#define MATRIX_IS_MUC_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_MUC_MANAGER))
#define MATRIX_MUC_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_MUC_MANAGER, MatrixMUCManagerClass))
typedef struct _MatrixMUCManager MatrixMUCManager;
typedef struct _MatrixMUCManagerClass MatrixMUCManagerClass;
struct _MatrixMUCManager {
/* Parent instance structure */
GObject parent_instance;
/* Instance members */
};
struct _MatrixMUCManagerClass {
GObjectClass parent_class;
};
GType matrix_muc_manager_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif /* __MATRIX_MUC_MANAGER_H__ */

View File

@ -19,10 +19,15 @@
#include "matrix-protocol.h" #include "matrix-protocol.h"
#include "matrix-handles.h" #include "matrix-handles.h"
#include "matrix-connection.h" #include "matrix-connection.h"
#include "matrix-im-manager.h"
#include "matrix-muc-manager.h"
#include <dbus/dbus-protocol.h> #include <dbus/dbus-protocol.h>
#define PROTOCOL_NAME "matrix" #define PROTOCOL_NAME "matrix"
#define ICON_NAME "im-" PROTOCOL_NAME
#define ENGLISH_NAME "Matrix"
#define VCARD_FIELD_NAME "x-" PROTOCOL_NAME
static gboolean filter_account(const TpCMParamSpec *, GValue *, GError **); static gboolean filter_account(const TpCMParamSpec *, GValue *, GError **);
@ -125,6 +130,42 @@ get_interfaces_array(TpBaseProtocol *protocol)
return interfaces; return interfaces;
} }
static void
get_connection_details(TpBaseProtocol *protocol,
GStrv *connection_interfaces,
GType **channel_managers,
gchar **icon_name,
gchar **english_name,
gchar **vcard_field)
{
if (connection_interfaces != NULL) {
*connection_interfaces = g_strdupv(
(GStrv)matrix_connection_get_implemented_interfaces());
}
if (channel_managers != NULL) {
GType types[] = {
MATRIX_TYPE_IM_MANAGER,
MATRIX_TYPE_MUC_MANAGER,
G_TYPE_INVALID
};
*channel_managers = g_memdup(types, sizeof(types));
}
if (icon_name != NULL) {
*icon_name = g_strdup(ICON_NAME);
}
if (vcard_field != NULL) {
*vcard_field = g_strdup(VCARD_FIELD_NAME);
}
if (english_name != NULL) {
*english_name = g_strdup(ENGLISH_NAME);
}
}
static void static void
matrix_protocol_class_init(MatrixProtocolClass *klass) matrix_protocol_class_init(MatrixProtocolClass *klass)
{ {
@ -135,8 +176,8 @@ matrix_protocol_class_init(MatrixProtocolClass *klass)
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;
/*
base_class->dup_authentication_types = dup_authentication_types; base_class->dup_authentication_types = dup_authentication_types;
*/ */
} }