diff options
author | Joe Barnett <jbarnett@stanfordalumni.org> | 2012-05-23 16:00:38 -0700 |
---|---|---|
committer | Joe Barnett <jbarnett@stanfordalumni.org> | 2012-05-23 16:00:38 -0700 |
commit | 30e6a3521b8435eaded73977d661b8a54004f553 (patch) | |
tree | 9818879bf4e78f6af9b2f5dea14acc60c66f0e11 | |
parent | ef12f9364e8b577660938fe67fec248fe187b6f5 (diff) |
some muc manager/channel
-rw-r--r-- | src/kindling-muc-channel.c | 64 | ||||
-rw-r--r-- | src/kindling-muc-channel.h | 55 | ||||
-rw-r--r-- | src/kindling-muc-manager.c | 12 | ||||
-rw-r--r-- | src/kindling-roomlist-manager.c | 2 |
4 files changed, 132 insertions, 1 deletions
diff --git a/src/kindling-muc-channel.c b/src/kindling-muc-channel.c new file mode 100644 index 0000000..9a9ca7d --- /dev/null +++ b/src/kindling-muc-channel.c @@ -0,0 +1,64 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * telepathy-kindling + * Copyright (C) Joe Barnett 2012 <jbarnett@taplop> + * +telepathy-kindling 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-kindling 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 this program. If not, see <http://www.gnu.org/licenses/>."; + */ + +#include "kindling-muc-channel.h" +#include <telepathy-glib/base-channel.h> +#include <telepathy-glib/message-mixin.h> +#include <dbus/dbus-glib.h> + + +static void subject_iface_init(gpointer, gpointer); + +G_DEFINE_TYPE_WITH_CODE (KindlingMUCChannel, kindling_muc_channel, TP_TYPE_BASE_CHANNEL, + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_TYPE_TEXT, tp_message_mixin_text_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_MESSAGES, tp_message_mixin_messages_iface_init); + G_IMPLEMENT_INTERFACE(TP_TYPE_SVC_CHANNEL_INTERFACE_SUBJECT, subject_iface_init); + ); + +static void +kindling_muc_channel_init (KindlingMUCChannel *kindling_muc_channel) +{ + + + /* TODO: Add initialization code here */ +} + +static void +kindling_muc_channel_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + + G_OBJECT_CLASS (kindling_muc_channel_parent_class)->finalize (object); +} + +static void +kindling_muc_channel_class_init (KindlingMUCChannelClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = kindling_muc_channel_finalize; +} + +static void kindling_muc_channel_set_subject (TpSvcChannelInterfaceSubject *iface, const gchar *subject, DBusGMethodInvocation *context) { +} + +static void subject_iface_init(gpointer g_iface, gpointer iface_data) { + TpSvcChannelInterfaceSubjectClass *klass = g_iface; + tp_svc_channel_interface_subject_implement_set_subject (klass, kindling_muc_channel_set_subject); +} diff --git a/src/kindling-muc-channel.h b/src/kindling-muc-channel.h new file mode 100644 index 0000000..dd06149 --- /dev/null +++ b/src/kindling-muc-channel.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * telepathy-kindling + * Copyright (C) Joe Barnett 2012 <jbarnett@taplop> + * +telepathy-kindling 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-kindling 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 this program. If not, see <http://www.gnu.org/licenses/>."; + */ + +#ifndef _KINDLING_MUC_CHANNEL_H_ +#define _KINDLING_MUC_CHANNEL_H_ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define KINDLING_TYPE_MUC_CHANNEL (kindling_muc_channel_get_type ()) +#define KINDLING_MUC_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KINDLING_TYPE_MUC_CHANNEL, KindlingMUCChannel)) +#define KINDLING_MUC_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KINDLING_TYPE_MUC_CHANNEL, KindlingMUCChannelClass)) +#define KINDLING_IS_MUC_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KINDLING_TYPE_MUC_CHANNEL)) +#define KINDLING_IS_MUC_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KINDLING_TYPE_MUC_CHANNEL)) +#define KINDLING_MUC_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KINDLING_TYPE_MUC_CHANNEL, KindlingMUCChannelClass)) + +typedef struct _KindlingMUCChannelClass KindlingMUCChannelClass; +typedef struct _KindlingMUCChannel KindlingMUCChannel; + + + +struct _KindlingMUCChannelClass +{ + GObjectClass parent_class; +}; + +struct _KindlingMUCChannel +{ + GObject parent_instance; + + +}; + +GType kindling_muc_channel_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _KINDLING_MUC_CHANNEL_H_ */ diff --git a/src/kindling-muc-manager.c b/src/kindling-muc-manager.c index 25a84cd..51e56dd 100644 --- a/src/kindling-muc-manager.c +++ b/src/kindling-muc-manager.c @@ -120,6 +120,14 @@ static void kindling_muc_manager_type_foreach_channel_class(GType type, TpChanne g_hash_table_destroy(table); } +static void _channel_closed_cb(KindlingMUCChannel *chan, gpointer user_data) { + KindlingMUCManager *manager = KINDLING_MUC_MANAGER(user_data); + KindlingMUCManagerPrivate *priv = KINDLING_MUC_MANAGER_GET_PRIVATE(manager); + TpHandle handle; + g_object_get(chan, "handle", &handle, NULL); + g_hash_table_remove(priv->channels, GUINT_TO_POINTER(handle)); +} + static gboolean kindling_muc_manager_handle_channel(TpChannelManager *manager, gpointer request_token, GHashTable *request_properties, @@ -157,6 +165,10 @@ static gboolean kindling_muc_manager_handle_channel(TpChannelManager *manager, return TRUE; } else { // create channel + channel = g_object_new (KINDLING_TYPE_MUC_CHANNEL, "connection", priv->conn, NULL); + g_signal_connect(channel, "closed", (GCallback)_channel_closed_cb, manager); + g_hash_table_insert(priv->channels, GUINT_TO_POINTER(handle), channel); + return TRUE; } return FALSE; } diff --git a/src/kindling-roomlist-manager.c b/src/kindling-roomlist-manager.c index 7084755..34f5990 100644 --- a/src/kindling-roomlist-manager.c +++ b/src/kindling-roomlist-manager.c @@ -22,6 +22,7 @@ telepathy-kindling is free software: you can redistribute it and/or modify it #include "kindling-connection.h" #include <telepathy-glib/channel-manager.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/dbus.h> static void _roomlist_manager_iface_init(gpointer, gpointer); @@ -91,7 +92,6 @@ static void kindling_roomlist_manager_class_init (KindlingRoomlistManagerClass *klass) { GObjectClass* object_class = G_OBJECT_CLASS (klass); - GObjectClass* parent_class = G_OBJECT_CLASS (klass); GParamSpec *param_spec; g_type_class_add_private (klass, sizeof(KindlingRoomlistManagerPrivate)); |