aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/Chat_Manager.xml31
-rw-r--r--extensions/misc.xml1
-rw-r--r--src/empathy-chat-manager.c73
-rw-r--r--src/empathy-chat-manager.h2
-rw-r--r--src/empathy-main-window.c6
5 files changed, 107 insertions, 6 deletions
diff --git a/extensions/Chat_Manager.xml b/extensions/Chat_Manager.xml
new file mode 100644
index 000000000..7a6fef8a3
--- /dev/null
+++ b/extensions/Chat_Manager.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" ?>
+<node name="/Chat_Manager"
+ xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+ <tp:copyright>Copyright (C) 2011 Collabora Ltd.</tp:copyright>
+ <tp:license xmlns="http://www.w3.org/1999/xhtml">
+ <p>This library 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 2.1 of the License, or (at your option) any later version.</p>
+
+<p>This library 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.</p>
+
+<p>You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p>
+ </tp:license>
+ <interface name="org.gnome.Empathy.ChatManager">
+
+ <method name="UndoClosedChat" tp:name-for-bindings="Undo_Closed_Chat">
+ <tp:docstring>
+ Ask the chat manager to undo closing a tab. If there is no tab
+ to be opened then return successfully.
+ </tp:docstring>
+ </method>
+
+ </interface>
+</node>
+<!-- vim:set sw=2 sts=2 et ft=xml: -->
diff --git a/extensions/misc.xml b/extensions/misc.xml
index b1f6e88eb..c3f06e54f 100644
--- a/extensions/misc.xml
+++ b/extensions/misc.xml
@@ -6,6 +6,7 @@
<xi:include href="Debug.xml" />
<xi:include href="Logger.xml" />
+<xi:include href="Chat_Manager.xml" />
<xi:include href="Connection_Interface_Renaming.xml" />
<xi:include href="Authentication_TLS_Certificate.xml" />
<xi:include href="Channel_Interface_Credentials_Storage.xml" />
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index 714939f53..bf870c8cc 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;
@@ -386,6 +395,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)
{
@@ -393,6 +418,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",
@@ -515,3 +541,48 @@ 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", EMPATHY_CHAT_BUS_NAME,
+ "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 (proxy);
+ 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__*/
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 0ac08c856..227160985 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1226,14 +1226,10 @@ main_window_key_press_event_cb (GtkWidget *window,
GdkEventKey *event,
gpointer user_data)
{
- EmpathyChatManager *chat_manager;
-
if (event->keyval == GDK_KEY_T
&& event->state & GDK_SHIFT_MASK
&& event->state & GDK_CONTROL_MASK) {
- chat_manager = empathy_chat_manager_dup_singleton ();
- empathy_chat_manager_undo_closed_chat (chat_manager);
- g_object_unref (chat_manager);
+ empathy_chat_manager_call_undo_closed_chat ();
}
return FALSE;
}