Port ConnectionManager to Vala

This commit is contained in:
Gergely Polonkai 2016-03-11 01:44:35 +01:00
parent 5fc195d972
commit 2e5b5715ef
5 changed files with 68 additions and 121 deletions

View File

@ -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 \

View File

@ -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
* <http://www.gnu.org/licenses/>.
*/
#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)
{
}

View File

@ -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
* <http://www.gnu.org/licenses/>.
*/
#ifndef __CAUCHY_CONNECTION_MANAGER_H__
#define __CAUCHY_CONNECTION_MANAGER_H__
#include <glib-object.h>
#include <telepathy-glib/telepathy-glib.h>
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__ */

View File

@ -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
* <http://www.gnu.org/licenses/>.
*/
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());
// }
}

32
src/tp-base.vapi Normal file
View File

@ -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
* <http://www.gnu.org/licenses/>.
*/
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);
}
}