aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2011-05-16 22:12:59 +0800
committerJonny Lamb <jonnylamb@gnome.org>2011-05-16 22:12:59 +0800
commit52e1e2fbdafd993933ba7866847ddbbedd7a2748 (patch)
tree90e010ac412a17cff8c374c502401cde0f644b8e /src
parent0261661359b354ee0bbc61898ebec8ede7ac5b2b (diff)
downloadgsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar.gz
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar.bz2
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar.lz
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar.xz
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.tar.zst
gsoc2013-empathy-52e1e2fbdafd993933ba7866847ddbbedd7a2748.zip
chat-manager: expose UndoClosedChat over DBus
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-manager.c72
-rw-r--r--src/empathy-chat-manager.h2
2 files changed, 73 insertions, 1 deletions
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index a90c2d08c..36f9512c7 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -18,6 +18,7 @@
*/
#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/proxy-subclass.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-request-util.h>
@@ -30,6 +31,8 @@
#include "empathy-chat-manager.h"
+#include <extensions/extensions.h>
+
enum {
CLOSED_CHATS_CHANGED,
DISPLAYED_CHATS_CHANGED,
@@ -38,7 +41,13 @@ enum {
static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE(EmpathyChatManager, empathy_chat_manager, G_TYPE_OBJECT)
+static void svc_iface_init (gpointer, gpointer);
+
+G_DEFINE_TYPE_WITH_CODE (EmpathyChatManager, empathy_chat_manager,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (EMP_TYPE_SVC_CHAT_MANAGER,
+ svc_iface_init)
+ )
/* private structure */
typedef struct _EmpathyChatManagerPriv EmpathyChatManagerPriv;
@@ -363,6 +372,22 @@ empathy_chat_manager_constructor (GType type,
}
static void
+empathy_chat_manager_constructed (GObject *obj)
+{
+ TpDBusDaemon *dbus_daemon;
+
+ dbus_daemon = tp_dbus_daemon_dup (NULL);
+
+ if (dbus_daemon != NULL)
+ {
+ tp_dbus_daemon_register_object (dbus_daemon,
+ "/org/gnome/Empathy/ChatManager", obj);
+
+ g_object_unref (dbus_daemon);
+ }
+}
+
+static void
empathy_chat_manager_class_init (
EmpathyChatManagerClass *empathy_chat_manager_class)
{
@@ -370,6 +395,7 @@ empathy_chat_manager_class_init (
object_class->finalize = empathy_chat_manager_finalize;
object_class->constructor = empathy_chat_manager_constructor;
+ object_class->constructed = empathy_chat_manager_constructed;
signals[CLOSED_CHATS_CHANGED] =
g_signal_new ("closed-chats-changed",
@@ -453,3 +479,47 @@ empathy_chat_manager_get_num_closed_chats (EmpathyChatManager *self)
return g_queue_get_length (priv->closed_queue);
}
+
+static void
+empathy_chat_manager_dbus_undo_closed_chat (EmpSvcChatManager *manager,
+ DBusGMethodInvocation *context)
+{
+ empathy_chat_manager_undo_closed_chat ((EmpathyChatManager *) manager);
+
+ emp_svc_chat_manager_return_from_undo_closed_chat (context);
+}
+
+static void
+svc_iface_init (gpointer g_iface,
+ gpointer iface_data)
+{
+ EmpSvcChatManagerClass *klass = (EmpSvcChatManagerClass *) g_iface;
+
+#define IMPLEMENT(x) emp_svc_chat_manager_implement_##x (\
+ klass, empathy_chat_manager_dbus_##x)
+ IMPLEMENT(undo_closed_chat);
+#undef IMPLEMENT
+}
+
+void
+empathy_chat_manager_call_undo_closed_chat (void)
+{
+ TpDBusDaemon *dbus_daemon = tp_dbus_daemon_dup (NULL);
+ TpProxy *proxy;
+
+ if (dbus_daemon == NULL)
+ return;
+
+ proxy = g_object_new (TP_TYPE_PROXY,
+ "dbus-daemon", dbus_daemon,
+ "dbus-connection", tp_proxy_get_dbus_connection (TP_PROXY (dbus_daemon)),
+ "bus-name", "org.freedesktop.Telepathy.Client.Empathy.Chat",
+ "object-path", "/org/gnome/Empathy/ChatManager",
+ NULL);
+
+ tp_proxy_add_interface_by_id (proxy, EMP_IFACE_QUARK_CHAT_MANAGER);
+
+ emp_cli_chat_manager_call_undo_closed_chat (proxy, -1, NULL, NULL, NULL, NULL);
+
+ g_object_unref (dbus_daemon);
+}
diff --git a/src/empathy-chat-manager.h b/src/empathy-chat-manager.h
index 6d249b3e4..88632b4dd 100644
--- a/src/empathy-chat-manager.h
+++ b/src/empathy-chat-manager.h
@@ -65,6 +65,8 @@ void empathy_chat_manager_closed_chat (EmpathyChatManager *self,
void empathy_chat_manager_undo_closed_chat (EmpathyChatManager *self);
guint empathy_chat_manager_get_num_closed_chats (EmpathyChatManager *self);
+void empathy_chat_manager_call_undo_closed_chat (void);
+
G_END_DECLS
#endif /* #ifndef __EMPATHY_CHAT_MANAGER_H__*/