From 2e5b5715effe427dc5404b0ef026bbea4a50dce0 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 11 Mar 2016 01:44:35 +0100 Subject: [PATCH] Port ConnectionManager to Vala --- src/Makefile.am | 9 +++-- src/cauchy-connection-manager.c | 64 ------------------------------ src/cauchy-connection-manager.h | 54 ------------------------- src/cauchy-connection-manager.vala | 30 ++++++++++++++ src/tp-base.vapi | 32 +++++++++++++++ 5 files changed, 68 insertions(+), 121 deletions(-) delete mode 100644 src/cauchy-connection-manager.c delete mode 100644 src/cauchy-connection-manager.h create mode 100644 src/cauchy-connection-manager.vala create mode 100644 src/tp-base.vapi diff --git a/src/Makefile.am b/src/Makefile.am index a33edce..22e6358 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,9 +3,14 @@ CLEANFILES = $(BUILT_SOURCES) $(man_MANS) libexec_PROGRAMS = telepathy-cauchy -AM_VALAFLAGS = -C --pkg=telepathy-glib +AM_VALAFLAGS = \ + -C \ + tp-base.vapi \ + --pkg=telepathy-glib \ + $(NULL) libtp_cauchy_convenience_la_VALA_SOURCES = \ + cauchy-connection-manager.vala \ $(NULL) vala-stamp: $(libtp_cauchy_convenience_la_VALA_SOURCES) @@ -33,8 +38,6 @@ $(libtp_cauchy_convenience_la_VALA_SOURCES:.vala=.c): vala-stamp libcauchy_convenience_la_SOURCES = \ $(libtp_cauchy_convenience_la_VALA_SOURCES:.vala=.c) \ - cauchy-connection-manager.c \ - cauchy-connection-manager.h \ cauchy-connection.c \ cauchy-connection.h \ cauchy-protocol.c \ diff --git a/src/cauchy-connection-manager.c b/src/cauchy-connection-manager.c deleted file mode 100644 index de9033b..0000000 --- a/src/cauchy-connection-manager.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of telepathy-cauchy - * - * telepathy-cauchy 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-cauchy 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-cauchy. If not, see - * . - */ - -#include "cauchy-connection-manager.h" -#include "cauchy-protocol.h" -#include "cauchy-debug.h" - -G_DEFINE_TYPE(CauchyConnectionManager, cauchy_connection_manager, TP_TYPE_BASE_CONNECTION_MANAGER); - -static void -cauchy_connection_manager_finalize(GObject *gobject) -{ - cauchy_debug_free(); - - G_OBJECT_CLASS(cauchy_connection_manager_parent_class)->finalize(gobject); -} - -static void -cauchy_connection_manager_constructed(GObject *gobject) -{ - TpBaseConnectionManager *base = (TpBaseConnectionManager *)gobject; - TpBaseProtocol *p; - void (*constructed)(GObject *) = ((GObjectClass *)cauchy_connection_manager_parent_class)->constructed; - - if (constructed != NULL) { - constructed(gobject); - } - - p = cauchy_protocol_new(); - tp_base_connection_manager_add_protocol(base, p); - g_object_unref(p); -} - -static void -cauchy_connection_manager_class_init(CauchyConnectionManagerClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - TpBaseConnectionManagerClass *parent_class = TP_BASE_CONNECTION_MANAGER_CLASS(klass); - - parent_class->cm_dbus_name = "cauchy"; - - gobject_class->finalize = cauchy_connection_manager_finalize; - gobject_class->constructed = cauchy_connection_manager_constructed; -} - -static void -cauchy_connection_manager_init(CauchyConnectionManager *connection_manager) -{ -} diff --git a/src/cauchy-connection-manager.h b/src/cauchy-connection-manager.h deleted file mode 100644 index 3f70b16..0000000 --- a/src/cauchy-connection-manager.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of telepathy-cauchy - * - * telepathy-cauchy 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-cauchy 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-cauchy. If not, see - * . - */ - -#ifndef __CAUCHY_CONNECTION_MANAGER_H__ -#define __CAUCHY_CONNECTION_MANAGER_H__ - -#include -#include - -G_BEGIN_DECLS - -/* TYPE MACROS */ - -#define CAUCHY_TYPE_CONNECTION_MANAGER (cauchy_connection_manager_get_type()) -#define CAUCHY_CONNECTION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CAUCHY_TYPE_CONNECTION_MANAGER, CauchyConnectionManager)) -#define CAUCHY_CONNECTION_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CAUCHY_TYPE_CONNECTION_MANAGER, CauchyConnectionManagerClass)) -#define CAUCHY_IS_CONNECTION_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CAUCHY_TYPE_CONNECTION_MANAGER)) -#define CAUCHY_IS_CONNECTION_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), CAUCHY_TYPE_CONNECTION_MANAGER)) -#define CAUCHY_CONNECTION_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), CAUCHY_TYPE_CONNECTION_MANAGER, CauchyConnectionManagerClass)) - -typedef struct _CauchyConnectionManager CauchyConnectionManager; -typedef struct _CauchyConnectionManagerClass CauchyConnectionManagerClass; - -struct _CauchyConnectionManagerClass { - TpBaseConnectionManagerClass parent_class; -}; - -struct _CauchyConnectionManager { - /* Parent instance structure */ - TpBaseConnection parent; - - /* Instance members */ -}; - -GType cauchy_connection_manager_get_type(void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __CAUCHY_CONNECTION_MANAGER_H__ */ diff --git a/src/cauchy-connection-manager.vala b/src/cauchy-connection-manager.vala new file mode 100644 index 0000000..dceb6fa --- /dev/null +++ b/src/cauchy-connection-manager.vala @@ -0,0 +1,30 @@ +/* + * This file is part of telepathy-cauchy + * + * telepathy-cauchy 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-cauchy 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-cauchy. If not, see + * . + */ + +using TelepathyGLib; + +[DBUS (name = "org.freedesktop.Telepathy.ConnectionManager.cauchy")] +public class Cauchy.ConnectionManager : BaseConnectionManager { + class construct { + cm_dbus_name = "cauchy"; + } + + // construct { + // add_protocol(new Protocol()); + // } +} diff --git a/src/tp-base.vapi b/src/tp-base.vapi new file mode 100644 index 0000000..1efdd04 --- /dev/null +++ b/src/tp-base.vapi @@ -0,0 +1,32 @@ +/* + * This file is part of telepathy-cauchy + * + * telepathy-cauchy 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-cauchy 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-cauchy. If not, see + * . + */ + +namespace TelepathyGLib { + public abstract class BaseProtocol {} + + [CCode (cheader_filename = "telepathy-glib/telepathy-glib.h")] + public abstract class BaseConnectionManager : GLib.Object { + public class string cm_dbus_name; + + [CCode (has_construct_function = false)] + public BaseConnectionManager(); + + public void + add_protocol(BaseProtocol protocol); + } +} \ No newline at end of file