~ubuntu-branches/ubuntu/precise/empathy/precise-proposed-201205180810

« back to all changes in this revision

Viewing changes to debian/patches/20_libindicate.patch

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis, Brian Curtis, Ken VanDine
  • Date: 2011-06-01 10:35:24 UTC
  • mfrom: (1.1.70 upstream) (6.3.44 experimental)
  • Revision ID: james.westby@ubuntu.com-20110601103524-wx3wgp71394730jt
Tags: 3.1.1-1ubuntu1
[ Brian Curtis ]
* Merge with Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Drop geoclue/mapping build-depends (they are in Universe)
  - Add Vcz-Bzr link
  - Add Suggests on telepathy-idle
  - Bump telepathy-butterfly, telepathy-haze to recommends
  - Don't recommend the freedesktop sound theme we have an ubuntu one
  - Add build depend for libunity-dev
* debian/rules:
  - Use autoreconf.mk
  - Disable map and location
* debian/empathy.install:
  - Install message indicator configuration
* debian/indicators/empathy:
  - Message indicator configuration
* debian/patches/01_lpi.patch:
  - Add Launchpad integration
* debian/patches/10_use_notify_osd_icons.patch:
  - Use the notify-osd image for new messages
* debian/patches/34_start_raised_execpt_in_session.patch
  - If not started with the session, we should always raise
* debian/patches/36_chat_window_default_size.patch:
  - Make the default chat window size larger
* debian/patches/37_facebook_default.patch:
  - Make facebook the default chat account type
* debian/patches/38_lp_569289.patch
  - Set freenode as default IRC network for new IRC accounts 
* debian/patches/41_unity_launcher_progress.patch
  - Display file transfer progress in the unity launcher

[ Ken VanDine ]
* debian/control
  - build depend on libgcr-3-dev instead of libgcr-dev
  - dropped build depends for libindicate, we will use telepathy-indicator
  - Depend on dconf-gsettings-backend | gsettings-backend
  - Added a Recommends for telepathy-indicator
* +debian/empathy.gsettings-override
  - Added an override for notifications-focus
* debian/patches/series
  - commented out 23_idomessagedialog_for_voip_and_ft.patch, until ido has 
    been ported to gtk3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=== modified file 'configure.ac'
2
 
Index: empathy-2.34.0/configure.ac
3
 
===================================================================
4
 
--- empathy-2.34.0.orig/configure.ac    2011-03-24 12:46:07.198547066 -0400
5
 
+++ empathy-2.34.0/configure.ac 2011-03-24 12:46:24.808547063 -0400
6
 
@@ -56,6 +56,8 @@
7
 
 NETWORK_MANAGER_REQUIRED=0.7.0
8
 
 WEBKIT_REQUIRED=1.1.15
9
 
 GNOME_CONTROL_CENTER_GTK3_REQUIRED=2.31.4
10
 
+INDICATE_REQUIRED=0.4.91
11
 
+INDICATE_GTK_REQUIRED=0.4.91
12
 
 
13
 
 # telepathy-yell
14
 
 prev_top_build_prefix=$ac_top_build_prefix
15
 
@@ -480,6 +482,34 @@
16
 
 AC_SUBST(MEEGO_LIBS)
17
 
 
18
 
 # -----------------------------------------------------------
19
 
+# libindicate
20
 
+# -----------------------------------------------------------
21
 
+AC_ARG_ENABLE(libindicate,
22
 
+              AS_HELP_STRING([--enable-libindicate=@<:@no/yes/auto@:>@],
23
 
+                             [build libindicate support]), ,
24
 
+                             enable_libindicate=auto)
25
 
+
26
 
+if test "x$enable_libindicate" != "xno"; then
27
 
+   PKG_CHECK_MODULES(INDICATE,
28
 
+   [
29
 
+     indicate-0.5 >= $INDICATE_REQUIRED,
30
 
+     indicate-gtk-0.5 >= $INDICATE_GTK_REQUIRED
31
 
+   ], have_libindicate="yes", have_libindicate="no")
32
 
+
33
 
+   if test "x$have_libindicate" = "xyes"; then
34
 
+      AC_DEFINE(HAVE_LIBINDICATE, 1, [Define if you have libindicate])
35
 
+   fi
36
 
+else
37
 
+   have_libindicate=no
38
 
+fi
39
 
+
40
 
+if test "x$enable_libindicate" = "xyes" -a "x$have_libindicate" != "xyes"; then
41
 
+   AC_MSG_ERROR([Couldn't find libindicate.])
42
 
+fi
43
 
+
44
 
+AM_CONDITIONAL(HAVE_LIBINDICATE, test "x$have_libindicate" = "xyes")
45
 
+
46
 
+# -----------------------------------------------------------
47
 
 # nautilus-sendto
48
 
 # -----------------------------------------------------------
49
 
 AC_ARG_ENABLE(nautilus-sendto,
50
 
@@ -581,6 +611,7 @@
51
 
        CA Cert Path................:  ${GTLS_SYSTEM_CA_FILE}
52
 
 
53
 
     Features:
54
 
+       Message indicator support (libindicate):  ${have_libindicate}
55
 
        Spell checking (enchant)....:  ${have_enchant}
56
 
        Display maps (libchamplain).:  ${have_libchamplain}
57
 
        Location awareness (Geoclue):  ${have_geoclue}
58
 
Index: empathy-2.34.0/data/org.gnome.Empathy.gschema.xml.in
59
 
===================================================================
60
 
--- empathy-2.34.0.orig/data/org.gnome.Empathy.gschema.xml.in   2011-03-24 12:46:14.568547064 -0400
61
 
+++ empathy-2.34.0/data/org.gnome.Empathy.gschema.xml.in        2011-03-24 12:46:24.808547063 -0400
62
 
@@ -86,6 +86,11 @@
63
 
       <_summary>The position for the chat window side pane</_summary>
64
 
       <_description>The stored position (in pixels) of the chat window side pane.</_description>
65
 
     </key>
66
 
+    <key name="use-libindicate" type="b">
67
 
+      <default>true</default>
68
 
+      <summary>Use the messaging indicator</summary>
69
 
+      <description>Whether or not to use the messaging indicator, if false the icon in the notification area will be displayed.</description>
70
 
+    </key>
71
 
   </schema>
72
 
   <schema id="org.gnome.Empathy.contacts" path="/apps/empathy/contacts/">
73
 
     <key name="sort-criterium" type="s">
74
 
Index: empathy-2.34.0/libempathy-gtk/empathy-ui-utils.c
75
 
===================================================================
76
 
--- empathy-2.34.0.orig/libempathy-gtk/empathy-ui-utils.c       2011-03-24 11:15:16.000000000 -0400
77
 
+++ empathy-2.34.0/libempathy-gtk/empathy-ui-utils.c    2011-03-24 12:46:24.808547063 -0400
78
 
@@ -1567,25 +1567,36 @@
79
 
        Display      *dpy;
80
 
        GdkWindow    *gdk_window;
81
 
 
82
 
-       gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
83
 
-       gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
84
 
-       dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
85
 
+       // If the status icon isn't visible (because indicators are used) then
86
 
+       // attempting to change the properties of the status icon doesn't work.
87
 
+       if (gtk_status_icon_get_visible (status_icon)) {
88
 
+               gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
89
 
+               gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
90
 
+               dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
91
 
 
92
 
-       data[0] = icon_location.x;
93
 
-       data[1] = icon_location.y;
94
 
-       data[2] = icon_location.width;
95
 
-       data[3] = icon_location.height;
96
 
+               data[0] = icon_location.x;
97
 
+               data[1] = icon_location.y;
98
 
+               data[2] = icon_location.width;
99
 
+               data[3] = icon_location.height;
100
 
 
101
 
-       XChangeProperty (dpy,
102
 
-                        GDK_WINDOW_XID (gdk_window),
103
 
-                        gdk_x11_get_xatom_by_name_for_display (
104
 
-                               gdk_drawable_get_display (gdk_window),
105
 
-                        "_NET_WM_ICON_GEOMETRY"),
106
 
-                        XA_CARDINAL, 32, PropModeReplace,
107
 
-                        (guchar *)&data, 4);
108
 
+               XChangeProperty (dpy,
109
 
+                                GDK_WINDOW_XID (gdk_window),
110
 
+                                gdk_x11_get_xatom_by_name_for_display (
111
 
+                                       gdk_drawable_get_display (gdk_window),
112
 
+                                "_NET_WM_ICON_GEOMETRY"),
113
 
+                                XA_CARDINAL, 32, PropModeReplace,
114
 
+                                (guchar *)&data, 4);
115
 
+       }
116
 
 
117
 
        gtk_window_set_skip_taskbar_hint (window, TRUE);
118
 
-       gtk_window_iconify (window);
119
 
+       // If the status icon isn't present then the WM will probably choose to
120
 
+       // iconfy to the taskbar, which doesn't look as good as the taskbar
121
 
+       // entry has just been removed. Just hide instead.
122
 
+       if (gtk_status_icon_get_visible (status_icon)) {
123
 
+               gtk_window_iconify (window);
124
 
+       } else {
125
 
+               gtk_widget_hide (GTK_WIDGET(window));
126
 
+       }
127
 
 }
128
 
 
129
 
 /* Takes care of moving the window to the current workspace. */
130
 
Index: empathy-2.34.0/libempathy/empathy-gsettings.h
131
 
===================================================================
132
 
--- empathy-2.34.0.orig/libempathy/empathy-gsettings.h  2011-03-24 11:15:16.000000000 -0400
133
 
+++ empathy-2.34.0/libempathy/empathy-gsettings.h       2011-03-24 12:46:24.808547063 -0400
134
 
@@ -71,6 +71,7 @@
135
 
 #define EMPATHY_PREFS_UI_SHOW_AVATARS              "show-avatars"
136
 
 #define EMPATHY_PREFS_UI_SHOW_PROTOCOLS            "show-protocols"
137
 
 #define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST      "compact-contact-list"
138
 
+#define EMPATHY_PREFS_UI_USE_LIBINDICATE           "use-libindicate"
139
 
 #define EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS     "chat-window-paned-pos"
140
 
 #define EMPATHY_PREFS_UI_SHOW_OFFLINE              "show-offline"
141
 
 
142
 
Index: empathy-2.34.0/po/POTFILES.in
143
 
===================================================================
144
 
--- empathy-2.34.0.orig/po/POTFILES.in  2011-03-24 11:38:49.000000000 -0400
145
 
+++ empathy-2.34.0/po/POTFILES.in       2011-03-24 12:46:24.808547063 -0400
146
 
@@ -95,6 +95,8 @@
147
 
 [type: gettext/glade]src/empathy-ft-manager.ui
148
 
 src/empathy-import-dialog.c
149
 
 src/empathy-import-widget.c
150
 
+src/empathy-indicator.c
151
 
+src/empathy-indicator-manager.c
152
 
 [type: gettext/glade]src/empathy-import-dialog.ui
153
 
 src/empathy-import-widget.c
154
 
 src/empathy-main-window.c
155
 
Index: empathy-2.34.0/src/Makefile.am
156
 
===================================================================
157
 
--- empathy-2.34.0.orig/src/Makefile.am 2011-03-24 11:15:16.000000000 -0400
158
 
+++ empathy-2.34.0/src/Makefile.am      2011-03-24 12:46:24.808547063 -0400
159
 
@@ -8,6 +8,7 @@
160
 
        $(ERROR_CFLAGS)                                 \
161
 
        -I$(top_srcdir)                                 \
162
 
        -DG_LOG_DOMAIN=\"empathy\"                      \
163
 
+       -DDESKTOPDIR=\"$(datadir)/applications\"        \
164
 
        -DBIN_DIR=\"$(bindir)\"                         \
165
 
        $(DISABLE_DEPRECATED)                           \
166
 
        $(WARN_CFLAGS)                                  \
167
 
@@ -17,6 +18,7 @@
168
 
 AM_CPPFLAGS =                                          \
169
 
        $(CPPFLAGS_COMMON)                              \
170
 
        $(LIBNOTIFY_CFLAGS)                             \
171
 
+       $(INDICATE_CFLAGS)                              \
172
 
        $(UNIQUE_CFLAGS) \
173
 
        $(LIBCHAMPLAIN_CFLAGS)                          \
174
 
        $(WEBKIT_CFLAGS)                                \
175
 
@@ -27,6 +29,7 @@
176
 
        $(top_builddir)/libempathy/libempathy.la                \
177
 
        $(top_builddir)/extensions/libemp-extensions.la         \
178
 
        $(LIBNOTIFY_LIBS)                                       \
179
 
+       $(INDICATE_LIBS)                                        \
180
 
        $(UNIQUE_LIBS)                                          \
181
 
        $(EMPATHY_LIBS)                                         \
182
 
        $(GTK_LIBS)                                             \
183
 
@@ -200,6 +203,7 @@
184
 
         $(LIBNOTIFY_LIBS)                                              \
185
 
         $(UNIQUE_LIBS)                                         \
186
 
         $(EMPATHY_LIBS)                                                        \
187
 
+       $(INDICATE_LIBS)                                                \
188
 
         $(LIBCHAMPLAIN_LIBS)                                           \
189
 
         $(WEBKIT_LIBS)                                                 \
190
 
        $(NULL)
191
 
@@ -232,6 +236,18 @@
192
 
        $(autostart_DATA)       \
193
 
        $(ui_DATA)
194
 
 
195
 
+if HAVE_LIBINDICATE
196
 
+empathy_handwritten_source +=                          \
197
 
+       empathy-indicator-manager.c             \
198
 
+       empathy-indicator-manager.h             \
199
 
+       empathy-indicator.c empathy-indicator.h
200
 
+else
201
 
+EXTRA_DIST +=                                  \
202
 
+       empathy-indicator-manager.c             \
203
 
+       empathy-indicator-manager.h             \
204
 
+       empathy-indicator.c empathy-indicator.h
205
 
+endif
206
 
+
207
 
 if HAVE_LIBCHAMPLAIN
208
 
 empathy_handwritten_source +=                          \
209
 
        empathy-map-view.c                      \
210
 
Index: empathy-2.34.0/src/empathy-chat-window.c
211
 
===================================================================
212
 
--- empathy-2.34.0.orig/src/empathy-chat-window.c       2011-03-24 12:46:07.198547066 -0400
213
 
+++ empathy-2.34.0/src/empathy-chat-window.c    2011-03-24 12:46:24.808547063 -0400
214
 
@@ -63,6 +63,11 @@
215
 
 #include "empathy-about-dialog.h"
216
 
 #include "empathy-invite-participant-dialog.h"
217
 
 
218
 
+#ifdef HAVE_LIBINDICATE
219
 
+#include "empathy-indicator.h"
220
 
+#include "empathy-indicator-manager.h"
221
 
+#endif
222
 
+
223
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CHAT
224
 
 #include <libempathy/empathy-debug.h>
225
 
 
226
 
@@ -86,7 +91,11 @@
227
 
        GtkWidget   *dialog;
228
 
        GtkWidget   *notebook;
229
 
        NotifyNotification *notification;
230
 
-
231
 
+#ifdef HAVE_LIBINDICATE
232
 
+       EmpathyIndicatorManager *indicator_manager;
233
 
+       /* EmpathyChat -> EmpathyIndicator for that chat, if any */
234
 
+       GHashTable  *indicators;
235
 
+#endif
236
 
        GtkTargetList *contact_targets;
237
 
        GtkTargetList *file_targets;
238
 
 
239
 
@@ -1278,6 +1287,72 @@
240
 
        }
241
 
 }
242
 
 
243
 
+#ifdef HAVE_LIBINDICATE
244
 
+static void
245
 
+chat_window_indicator_activate_cb (EmpathyIndicator *indicator, guint timestamp,
246
 
+                                   EmpathyChat *chat)
247
 
+{
248
 
+       empathy_chat_window_present_chat (chat, timestamp);
249
 
+       empathy_indicator_hide (indicator);
250
 
+}
251
 
+
252
 
+static void
253
 
+chat_window_add_indicator (EmpathyChatWindow *window,
254
 
+                                        EmpathyMessage *message,
255
 
+                                        EmpathyChat    *chat)
256
 
+{
257
 
+       EmpathyChatWindowPriv *priv = GET_PRIV (window);
258
 
+       EmpathyContact *sender;
259
 
+       const char *body;
260
 
+       gboolean use_libindicate;
261
 
+       EmpathyIndicator *indicator = NULL;
262
 
+       GSettings *gsettings;
263
 
+
264
 
+       gsettings = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
265
 
+       use_libindicate = g_settings_get_boolean (gsettings, EMPATHY_PREFS_UI_USE_LIBINDICATE);
266
 
+       g_object_unref (gsettings);
267
 
+
268
 
+       if (!use_libindicate) {
269
 
+               return;
270
 
+       }
271
 
+
272
 
+       sender = empathy_message_get_sender (message);
273
 
+       body = empathy_message_get_body (message);
274
 
+
275
 
+       indicator = g_hash_table_lookup (priv->indicators, chat);
276
 
+       if (indicator != NULL) {
277
 
+               DEBUG ("indicator exists");
278
 
+               empathy_indicator_update (indicator, body);
279
 
+       } else {
280
 
+               DEBUG ("indicator doesn't exist yet, creating a new indicator");
281
 
+               indicator = empathy_indicator_manager_create_indicator (priv->indicator_manager,
282
 
+                       sender, body);
283
 
+               g_signal_connect (indicator, "activate",
284
 
+                                 G_CALLBACK (chat_window_indicator_activate_cb), chat);
285
 
+
286
 
+               g_hash_table_insert (priv->indicators, chat, indicator);
287
 
+       }
288
 
+       empathy_indicator_show (indicator);
289
 
+}
290
 
+
291
 
+static void
292
 
+chat_window_remove_indicator (EmpathyChatWindow *window, EmpathyChat *chat)
293
 
+{
294
 
+       EmpathyIndicator *indicator = NULL;
295
 
+       EmpathyChatWindowPriv *priv = GET_PRIV (window);
296
 
+
297
 
+       indicator = g_hash_table_lookup (priv->indicators, chat);
298
 
+
299
 
+       if ((indicator) && (indicator != NULL)) {
300
 
+               DEBUG ("indicator is %p", indicator);
301
 
+               empathy_indicator_hide (indicator);
302
 
+               g_hash_table_remove (priv->indicators, chat);
303
 
+       } else {
304
 
+               DEBUG ("indicator is NULL, nothing to remove");
305
 
+       }
306
 
+}
307
 
+#endif
308
 
+
309
 
 static void
310
 
 chat_window_show_or_update_notification (EmpathyChatWindow *window,
311
 
                                         EmpathyMessage *message,
312
 
@@ -1454,6 +1529,9 @@
313
 
 
314
 
                empathy_sound_play (GTK_WIDGET (priv->dialog),
315
 
                    EMPATHY_SOUND_MESSAGE_INCOMING);
316
 
+#ifdef HAVE_LIBINDICATE
317
 
+               chat_window_add_indicator (window, message, chat);
318
 
+#endif
319
 
 
320
 
                /* Pending messages have already been displayed in the approver, so we don't
321
 
                * display a notification for those. */
322
 
@@ -1526,6 +1604,10 @@
323
 
        empathy_chat_messages_read (chat);
324
 
 
325
 
        chat_window_update_chat_tab (chat);
326
 
+
327
 
+#ifdef HAVE_LIBINDICATE
328
 
+       chat_window_remove_indicator (window, chat);
329
 
+#endif
330
 
 }
331
 
 
332
 
 static void
333
 
@@ -1642,6 +1724,11 @@
334
 
        /* Update the title, since we now mark all unread messages as read. */
335
 
        chat_window_update_chat_tab_full (priv->current_chat, FALSE);
336
 
 
337
 
+#ifdef HAVE_LIBINDICATE
338
 
+       /* Remove the indicator for the active chat */
339
 
+       chat_window_remove_indicator (window, priv->current_chat);
340
 
+#endif
341
 
+
342
 
        return FALSE;
343
 
 }
344
 
 
345
 
@@ -1986,6 +2073,11 @@
346
 
        g_object_unref (gui);
347
 
 
348
 
        priv->chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
349
 
+#ifdef HAVE_LIBINDICATE
350
 
+       priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
351
 
+       priv->indicators = g_hash_table_new_full (g_direct_hash, g_direct_equal,
352
 
+                             NULL, g_object_unref);
353
 
+#endif
354
 
 
355
 
        priv->notebook = gtk_notebook_new ();
356
 
        gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow");
357
 
Index: empathy-2.34.0/src/empathy-indicator-manager.c
358
 
===================================================================
359
 
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
360
 
+++ empathy-2.34.0/src/empathy-indicator-manager.c      2011-03-24 12:46:24.808547063 -0400
361
 
@@ -0,0 +1,467 @@
362
 
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
363
 
+/*
364
 
+ * Copyright (C) 2009 Canonical Ltd.
365
 
+ *
366
 
+ * This program is free software; you can redistribute it and/or
367
 
+ * modify it under the terms of the GNU General Public License as
368
 
+ * published by the Free Software Foundation; either version 2 of the
369
 
+ * License, or (at your option) any later version.
370
 
+ *
371
 
+ * This program is distributed in the hope that it will be useful,
372
 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
373
 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
374
 
+ * General Public License for more details.
375
 
+ *
376
 
+ * You should have received a copy of the GNU General Public
377
 
+ * License along with this program; if not, write to the
378
 
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
379
 
+ * Boston, MA  02110-1301  USA
380
 
+ *
381
 
+ * Authors: James Westby <james.westby@ubuntu.com>
382
 
+ *
383
 
+ */
384
 
+
385
 
+#include <config.h>
386
 
+
387
 
+#include <gtk/gtk.h>
388
 
+
389
 
+#include <libempathy/empathy-contact.h>
390
 
+#include <libempathy/empathy-dispatcher.h>
391
 
+#include <libempathy/empathy-utils.h>
392
 
+
393
 
+#include <libempathy-gtk/empathy-ui-utils.h>
394
 
+#include <libempathy-gtk/empathy-notify-manager.h>
395
 
+
396
 
+#include <telepathy-glib/util.h>
397
 
+
398
 
+#include "empathy-event-manager.h"
399
 
+#include "empathy-indicator.h"
400
 
+#include "empathy-indicator-manager.h"
401
 
+
402
 
+#include <libindicate/server.h>
403
 
+#include <libindicate/indicator.h>
404
 
+
405
 
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
406
 
+#include <libempathy/empathy-debug.h>
407
 
+
408
 
+#define INDICATOR_LOGIN_TIMEOUT 15
409
 
+#define EMPATHY_DESKTOP_PATH DESKTOPDIR "/empathy.desktop"
410
 
+
411
 
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndicatorManager)
412
 
+
413
 
+enum {
414
 
+  SERVER_ACTIVATE,
415
 
+  LAST_SIGNAL
416
 
+};
417
 
+
418
 
+static guint signals[LAST_SIGNAL];
419
 
+
420
 
+typedef struct {
421
 
+  EmpathyEventManager *event_manager;
422
 
+  IndicateServer      *indicate_server;
423
 
+  GSList              *indicator_events;
424
 
+  GHashTable          *login_timeouts;
425
 
+} EmpathyIndicatorManagerPriv;
426
 
+
427
 
+typedef struct {
428
 
+  EmpathyIndicator    *indicator;
429
 
+  EmpathyEvent        *event;
430
 
+} IndicatorEvent;
431
 
+
432
 
+typedef struct {
433
 
+  EmpathyIndicatorManager *manager;
434
 
+  EmpathyIndicator        *indicator;
435
 
+} LoginData;
436
 
+
437
 
+G_DEFINE_TYPE (EmpathyIndicatorManager, empathy_indicator_manager, G_TYPE_OBJECT);
438
 
+
439
 
+static EmpathyIndicatorManager *manager_singleton = NULL;
440
 
+
441
 
+static EmpathyEvent *
442
 
+event_copy (EmpathyEvent *event)
443
 
+{
444
 
+       EmpathyEvent *ret = g_new0 (EmpathyEvent, 1);
445
 
+
446
 
+       ret->contact = g_object_ref (event->contact);
447
 
+       ret->icon_name = g_strdup (event->icon_name);
448
 
+       ret->header = g_strdup (event->header);
449
 
+       ret->message = g_strdup (event->message);
450
 
+       ret->must_ack = event->must_ack;
451
 
+
452
 
+       return ret;
453
 
+}
454
 
+
455
 
+static gboolean
456
 
+compare_events (EmpathyEvent *ev1, EmpathyEvent *ev2)
457
 
+{
458
 
+       return ((g_strcmp0 (ev1->icon_name, ev2->icon_name) == 0) &&
459
 
+               (g_strcmp0 (ev1->header, ev2->header) == 0) &&
460
 
+               (ev1->must_ack == ev2->must_ack) &&
461
 
+               (ev1->contact == ev2->contact));
462
 
+}
463
 
+
464
 
+static IndicatorEvent *
465
 
+indicator_event_new (EmpathyIndicator *indicator,
466
 
+                    EmpathyEvent *event)
467
 
+{
468
 
+  IndicatorEvent *indicator_event;
469
 
+
470
 
+  indicator_event = g_slice_new0 (IndicatorEvent);
471
 
+  indicator_event->indicator = g_object_ref (indicator);
472
 
+  indicator_event->event = event_copy (event);
473
 
+
474
 
+  return indicator_event;
475
 
+}
476
 
+
477
 
+
478
 
+static void
479
 
+indicator_event_free (IndicatorEvent *indicator_event)
480
 
+{
481
 
+  g_object_unref (indicator_event->indicator);
482
 
+  g_free (indicator_event);
483
 
+}
484
 
+
485
 
+
486
 
+static void
487
 
+indicate_server_activate (IndicateServer *server, guint timestamp,
488
 
+    EmpathyIndicatorManager *manager)
489
 
+{
490
 
+  g_signal_emit (manager, signals[SERVER_ACTIVATE], 0, timestamp);
491
 
+}
492
 
+
493
 
+
494
 
+static void
495
 
+indicate_show_cb (EmpathyIndicator *indicator, guint timestamp,
496
 
+    EmpathyEvent *event)
497
 
+{
498
 
+  empathy_event_activate (event);
499
 
+}
500
 
+
501
 
+
502
 
+static void
503
 
+indicator_manager_event_added_cb (EmpathyEventManager *event_manager,
504
 
+    EmpathyEvent *event,
505
 
+    EmpathyIndicatorManager *manager)
506
 
+{
507
 
+  EmpathyIndicator *indicator = NULL;
508
 
+  EmpathyIndicatorManagerPriv *priv;
509
 
+  IndicatorEvent *indicator_event;
510
 
+
511
 
+  priv = GET_PRIV (manager);
512
 
+
513
 
+  DEBUG ("Event added");
514
 
+
515
 
+  if (event->contact == NULL)
516
 
+    return;
517
 
+
518
 
+  indicator = empathy_indicator_new (event->contact, event->message, "im");
519
 
+  if (indicator == NULL) {
520
 
+    return;
521
 
+  }
522
 
+
523
 
+  empathy_indicator_show (indicator);
524
 
+  g_signal_connect (G_OBJECT(indicator), "activate",
525
 
+      G_CALLBACK (indicate_show_cb),
526
 
+      event);
527
 
+  indicator_event = indicator_event_new (indicator, event);
528
 
+  g_object_unref (indicator);
529
 
+  priv->indicator_events = g_slist_prepend (priv->indicator_events,
530
 
+      indicator_event);
531
 
+}
532
 
+
533
 
+static void
534
 
+indicator_manager_event_removed_cb (EmpathyEventManager *event_manager,
535
 
+    EmpathyEvent *event,
536
 
+    EmpathyIndicatorManager *manager)
537
 
+{
538
 
+  EmpathyIndicatorManagerPriv *priv;
539
 
+  GSList *l;
540
 
+
541
 
+  priv = GET_PRIV (manager);
542
 
+
543
 
+  DEBUG ("Event removed");
544
 
+
545
 
+  for (l = priv->indicator_events; l; l = l->next)
546
 
+  {
547
 
+    IndicatorEvent *indicator_event;
548
 
+    indicator_event = l->data;
549
 
+
550
 
+    if (compare_events (indicator_event->event, event)) {
551
 
+      priv->indicator_events = g_slist_remove (priv->indicator_events,
552
 
+          indicator_event);
553
 
+      empathy_indicator_hide (indicator_event->indicator);
554
 
+      return;
555
 
+    }
556
 
+  }
557
 
+}
558
 
+
559
 
+
560
 
+static void
561
 
+indicator_manager_event_updated_cb (EmpathyEventManager *event_manager,
562
 
+    EmpathyEvent *event,
563
 
+    EmpathyIndicatorManager *manager)
564
 
+{
565
 
+  EmpathyIndicatorManagerPriv *priv;
566
 
+  GSList *l;
567
 
+
568
 
+  priv = GET_PRIV (manager);
569
 
+
570
 
+  for (l = priv->indicator_events; l; l = l->next)
571
 
+  {
572
 
+    IndicatorEvent *indicator_event;
573
 
+    indicator_event = l->data;
574
 
+    if (compare_events (indicator_event->event, event)) {
575
 
+      empathy_indicator_update (indicator_event->indicator,
576
 
+          event->message);
577
 
+      return;
578
 
+    }
579
 
+  }
580
 
+}
581
 
+
582
 
+
583
 
+/* Remove the login indicator when it times out */
584
 
+static gboolean
585
 
+indicate_login_timeout (gpointer data)
586
 
+{
587
 
+  LoginData *login_data;
588
 
+  EmpathyIndicator *e_indicator;
589
 
+  EmpathyIndicatorManager *manager;
590
 
+  EmpathyIndicatorManagerPriv *priv;
591
 
+
592
 
+  login_data = (LoginData *) data;
593
 
+  e_indicator = login_data->indicator;
594
 
+  manager = login_data->manager;
595
 
+  priv = GET_PRIV (manager);
596
 
+
597
 
+  empathy_indicator_hide (e_indicator);
598
 
+  g_hash_table_remove (priv->login_timeouts, e_indicator);
599
 
+
600
 
+  return FALSE;
601
 
+}
602
 
+
603
 
+
604
 
+static void
605
 
+indicate_login_cb (EmpathyIndicator *e_indicator, guint timestamp,
606
 
+    EmpathyIndicatorManager *manager)
607
 
+{
608
 
+  EmpathyIndicatorManagerPriv *priv;
609
 
+  GSList *events, *l;
610
 
+  EmpathyContact *contact;
611
 
+
612
 
+  priv = GET_PRIV (manager);
613
 
+
614
 
+  empathy_indicator_hide (e_indicator);
615
 
+  g_hash_table_remove (priv->login_timeouts, e_indicator);
616
 
+
617
 
+  contact = empathy_indicator_get_contact (e_indicator);
618
 
+  /* If the contact has an event activate it, otherwise the
619
 
+   * default handler of row-activated will be called. */
620
 
+  events = empathy_event_manager_get_events (priv->event_manager);
621
 
+  for (l = events; l; l = l->next) {
622
 
+    EmpathyEvent *event;
623
 
+
624
 
+    event = l->data;
625
 
+    if (event->contact == contact) {
626
 
+      empathy_event_activate (event);
627
 
+      return;
628
 
+    }
629
 
+  }
630
 
+
631
 
+  /* Else start a new conversation */
632
 
+  empathy_dispatcher_chat_with_contact (contact, timestamp);
633
 
+}
634
 
+
635
 
+
636
 
+EmpathyIndicatorManager *
637
 
+empathy_indicator_manager_dup_singleton (void)
638
 
+{
639
 
+  return g_object_new (EMPATHY_TYPE_INDICATOR_MANAGER, NULL);
640
 
+}
641
 
+
642
 
+
643
 
+static void
644
 
+indicator_manager_dispose (GObject *object)
645
 
+{
646
 
+  EmpathyIndicatorManagerPriv *priv;
647
 
+
648
 
+  priv = GET_PRIV (object);
649
 
+
650
 
+  if (priv->indicator_events) {
651
 
+    g_slist_foreach (priv->indicator_events, (GFunc) indicator_event_free,
652
 
+        NULL);
653
 
+    g_slist_free (priv->indicator_events);
654
 
+    priv->indicator_events = NULL;
655
 
+  }
656
 
+  if (priv->event_manager) {
657
 
+    g_object_unref (priv->event_manager);
658
 
+    priv->event_manager = NULL;
659
 
+  }
660
 
+  if (priv->indicate_server) {
661
 
+    g_object_unref (priv->indicate_server);
662
 
+    priv->indicate_server = NULL;
663
 
+  }
664
 
+  if (priv->login_timeouts) {
665
 
+    g_hash_table_unref (priv->login_timeouts);
666
 
+    priv->login_timeouts = NULL;
667
 
+  }
668
 
+
669
 
+  G_OBJECT_CLASS (empathy_indicator_manager_parent_class)->dispose (object);
670
 
+}
671
 
+
672
 
+
673
 
+static GObject *
674
 
+indicator_manager_constructor (GType type,
675
 
+    guint n_props,
676
 
+    GObjectConstructParam *props)
677
 
+{
678
 
+  GObject *retval;
679
 
+
680
 
+  if (manager_singleton != NULL) {
681
 
+    retval = g_object_ref (manager_singleton);
682
 
+  } else {
683
 
+    retval = G_OBJECT_CLASS (empathy_indicator_manager_parent_class)->constructor
684
 
+      (type, n_props, props);
685
 
+
686
 
+    manager_singleton = EMPATHY_INDICATOR_MANAGER (retval);
687
 
+    g_object_add_weak_pointer (retval, (gpointer) &manager_singleton);
688
 
+  }
689
 
+
690
 
+  return retval;
691
 
+}
692
 
+
693
 
+
694
 
+static void
695
 
+empathy_indicator_manager_class_init (EmpathyIndicatorManagerClass *klass)
696
 
+{
697
 
+  GObjectClass *object_class;
698
 
+
699
 
+  object_class = G_OBJECT_CLASS (klass);
700
 
+  object_class->dispose = indicator_manager_dispose;
701
 
+  object_class->constructor = indicator_manager_constructor;
702
 
+
703
 
+  signals[SERVER_ACTIVATE] =
704
 
+      g_signal_new ("server-activate",
705
 
+          G_TYPE_FROM_CLASS (klass),
706
 
+          G_SIGNAL_RUN_LAST,
707
 
+          0,
708
 
+          NULL, NULL,
709
 
+          g_cclosure_marshal_VOID__UINT,
710
 
+          G_TYPE_NONE, 1, G_TYPE_UINT);
711
 
+
712
 
+  g_type_class_add_private (object_class, sizeof (EmpathyIndicatorManagerPriv));
713
 
+}
714
 
+
715
 
+
716
 
+static void
717
 
+empathy_indicator_manager_init (EmpathyIndicatorManager *manager)
718
 
+{
719
 
+  EmpathyIndicatorManagerPriv *priv;
720
 
+
721
 
+  priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
722
 
+       EMPATHY_TYPE_INDICATOR_MANAGER, EmpathyIndicatorManagerPriv);
723
 
+  manager->priv = priv;
724
 
+
725
 
+  priv->event_manager = empathy_event_manager_dup_singleton ();
726
 
+  priv->login_timeouts = g_hash_table_new_full (NULL, NULL,
727
 
+      (GDestroyNotify) g_object_unref, (GDestroyNotify) g_source_unref);
728
 
+  priv->indicate_server = indicate_server_ref_default ();
729
 
+  indicate_server_set_type (priv->indicate_server, "message.instant");
730
 
+  indicate_server_set_desktop_file (priv->indicate_server,
731
 
+      EMPATHY_DESKTOP_PATH);
732
 
+
733
 
+  g_signal_connect (priv->indicate_server,
734
 
+      INDICATE_SERVER_SIGNAL_SERVER_DISPLAY,
735
 
+      G_CALLBACK (indicate_server_activate),
736
 
+      manager);
737
 
+
738
 
+  g_signal_connect (priv->event_manager, "event-added",
739
 
+      G_CALLBACK (indicator_manager_event_added_cb),
740
 
+      manager);
741
 
+  g_signal_connect (priv->event_manager, "event-removed",
742
 
+      G_CALLBACK (indicator_manager_event_removed_cb),
743
 
+      manager);
744
 
+  g_signal_connect (priv->event_manager, "event-updated",
745
 
+      G_CALLBACK (indicator_manager_event_updated_cb),
746
 
+      manager);
747
 
+}
748
 
+
749
 
+void
750
 
+empathy_indicator_manager_set_server_visible (EmpathyIndicatorManager *manager,
751
 
+    gboolean visible)
752
 
+{
753
 
+  EmpathyIndicatorManagerPriv *priv;
754
 
+
755
 
+  priv = GET_PRIV (manager);
756
 
+  if (visible) {
757
 
+    DEBUG ("Show indicator");
758
 
+    indicate_server_show (priv->indicate_server);
759
 
+  } else {
760
 
+    DEBUG ("Hide indicator");
761
 
+    indicate_server_hide (priv->indicate_server);
762
 
+  }
763
 
+}
764
 
+
765
 
+
766
 
+EmpathyIndicator *
767
 
+empathy_indicator_manager_create_indicator (EmpathyIndicatorManager *manager,
768
 
+    EmpathyContact *sender,
769
 
+    const gchar *body)
770
 
+{
771
 
+  return empathy_indicator_new (sender, body, "im");
772
 
+}
773
 
+
774
 
+
775
 
+static LoginData *
776
 
+login_data_new (EmpathyIndicator *e_indicator,
777
 
+    EmpathyIndicatorManager *manager)
778
 
+{
779
 
+  LoginData *login_data;
780
 
+
781
 
+  login_data = g_slice_new0 (LoginData);
782
 
+  login_data->manager = g_object_ref (manager);
783
 
+  login_data->indicator = g_object_ref (e_indicator);
784
 
+
785
 
+  return login_data;
786
 
+}
787
 
+
788
 
+
789
 
+static void
790
 
+indicator_destroy_login_data (gpointer data)
791
 
+{
792
 
+  LoginData *login_data;
793
 
+
794
 
+  login_data = (LoginData *)data;
795
 
+
796
 
+  g_object_unref (login_data->manager);
797
 
+  g_object_unref (login_data->indicator);
798
 
+  g_slice_free (LoginData, login_data);
799
 
+}
800
 
+
801
 
+
802
 
+/* Add an indicator for someone logging in. This will be displayed for
803
 
+ * a short period only.
804
 
+ */
805
 
+void
806
 
+empathy_indicator_manager_add_login_indicator (EmpathyIndicatorManager *manager,
807
 
+    EmpathyContact *contact)
808
 
+{
809
 
+  EmpathyIndicatorManagerPriv *priv;
810
 
+  GSource *timeout;
811
 
+  EmpathyIndicator *e_indicator;
812
 
+  LoginData *login_data;
813
 
+
814
 
+  priv = GET_PRIV (manager);
815
 
+  e_indicator = empathy_indicator_new (contact, NULL, "login");
816
 
+  login_data = login_data_new (e_indicator, manager);
817
 
+
818
 
+  timeout = g_timeout_source_new_seconds (INDICATOR_LOGIN_TIMEOUT);
819
 
+  g_source_set_callback (timeout, indicate_login_timeout, login_data,
820
 
+      indicator_destroy_login_data);
821
 
+  g_source_attach (timeout, NULL);
822
 
+
823
 
+  g_hash_table_insert (priv->login_timeouts, e_indicator, timeout);
824
 
+
825
 
+  g_signal_connect (e_indicator, "activate",
826
 
+      G_CALLBACK (indicate_login_cb), manager);
827
 
+  empathy_indicator_show (e_indicator);
828
 
+}
829
 
Index: empathy-2.34.0/src/empathy-indicator-manager.h
830
 
===================================================================
831
 
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
832
 
+++ empathy-2.34.0/src/empathy-indicator-manager.h      2011-03-24 12:46:24.808547063 -0400
833
 
@@ -0,0 +1,77 @@
834
 
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
835
 
+/*
836
 
+ * Copyright (C) 2009 Canonical Ltd.
837
 
+ *
838
 
+ * This program is free software; you can redistribute it and/or
839
 
+ * modify it under the terms of the GNU General Public License as
840
 
+ * published by the Free Software Foundation; either version 2 of the
841
 
+ * License, or (at your option) any later version.
842
 
+ *
843
 
+ * This program is distributed in the hope that it will be useful,
844
 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
845
 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
846
 
+ * General Public License for more details.
847
 
+ *
848
 
+ * You should have received a copy of the GNU General Public
849
 
+ * License along with this program; if not, write to the
850
 
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
851
 
+ * Boston, MA  02110-1301  USA
852
 
+ *
853
 
+ * Authors: James Westby <james.westby@ubuntu.com>
854
 
+ *
855
 
+ */
856
 
+
857
 
+#ifndef __EMPATHY_INDICATOR_MANAGER_H__
858
 
+#define __EMPATHY_INDICATOR_MANAGER_H__
859
 
+
860
 
+#include <glib.h>
861
 
+
862
 
+#include <libempathy/empathy-contact.h>
863
 
+#include "empathy-indicator.h"
864
 
+
865
 
+G_BEGIN_DECLS
866
 
+
867
 
+#define EMPATHY_TYPE_INDICATOR_MANAGER \
868
 
+  (empathy_indicator_manager_get_type ())
869
 
+#define EMPATHY_INDICATOR_MANAGER(o) \
870
 
+  (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDICATOR_MANAGER, \
871
 
+                               EmpathyIndicatorManager))
872
 
+#define EMPATHY_INDICATOR_MANAGER_CLASS(k) \
873
 
+  (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_INDICATOR_MANAGER, \
874
 
+                           EmpathyIndicatorManagerClass))
875
 
+#define EMPATHY_IS_INDICATOR_MANAGER(o) \
876
 
+  (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_INDICATOR_MANAGER))
877
 
+#define EMPATHY_IS_INDICATOR_MANAGER_CLASS(k) \
878
 
+  (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDICATOR_MANAGER))
879
 
+#define EMPATHY_INDICATOR_MANAGER_GET_CLASS(o) \
880
 
+  (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDICATOR_MANAGER, \
881
 
+                              EmpathyIndicatorManagerClass))
882
 
+
883
 
+typedef struct _EmpathyIndicatorManager      EmpathyIndicatorManager;
884
 
+typedef struct _EmpathyIndicatorManagerClass EmpathyIndicatorManagerClass;
885
 
+
886
 
+struct _EmpathyIndicatorManager {
887
 
+  GObject parent;
888
 
+  gpointer priv;
889
 
+};
890
 
+
891
 
+struct _EmpathyIndicatorManagerClass {
892
 
+  GObjectClass parent_class;
893
 
+};
894
 
+
895
 
+GType empathy_indicator_manager_get_type (void) G_GNUC_CONST;
896
 
+EmpathyIndicatorManager *empathy_indicator_manager_dup_singleton (void);
897
 
+void empathy_indicator_manager_set_server_visible (
898
 
+    EmpathyIndicatorManager *manager,
899
 
+    gboolean visible);
900
 
+EmpathyIndicator *empathy_indicator_manager_create_indicator (
901
 
+    EmpathyIndicatorManager *manager,
902
 
+    EmpathyContact *sender,
903
 
+    const gchar *body);
904
 
+void empathy_indicator_manager_add_login_indicator (
905
 
+    EmpathyIndicatorManager *manager,
906
 
+    EmpathyContact *contact);
907
 
+
908
 
+G_END_DECLS
909
 
+
910
 
+#endif /* __EMPATHY_INDICATOR_MANAGER_H__ */
911
 
Index: empathy-2.34.0/src/empathy-indicator.c
912
 
===================================================================
913
 
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
914
 
+++ empathy-2.34.0/src/empathy-indicator.c      2011-03-24 12:46:24.808547063 -0400
915
 
@@ -0,0 +1,325 @@
916
 
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
917
 
+/*
918
 
+ * Copyright (C) 2009 Canonical Ltd.
919
 
+ *
920
 
+ * This program is free software; you can redistribute it and/or
921
 
+ * modify it under the terms of the GNU General Public License as
922
 
+ * published by the Free Software Foundation; either version 2 of the
923
 
+ * License, or (at your option) any later version.
924
 
+ *
925
 
+ * This program is distributed in the hope that it will be useful,
926
 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
927
 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
928
 
+ * General Public License for more details.
929
 
+ *
930
 
+ * You should have received a copy of the GNU General Public
931
 
+ * License along with this program; if not, write to the
932
 
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
933
 
+ * Boston, MA  02110-1301  USA
934
 
+ *
935
 
+ * Authors: James Westby <james.westby@ubuntu.com>
936
 
+ *
937
 
+ */
938
 
+
939
 
+#include <gtk/gtk.h>
940
 
+
941
 
+#include <libempathy/empathy-contact.h>
942
 
+#include <libempathy/empathy-utils.h>
943
 
+
944
 
+#include <libempathy-gtk/empathy-ui-utils.h>
945
 
+#include <libempathy-gtk/empathy-notify-manager.h>
946
 
+
947
 
+#include "empathy-indicator.h"
948
 
+
949
 
+#include <libindicate/indicator.h>
950
 
+#include <libindicate-gtk/indicator.h>
951
 
+
952
 
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
953
 
+#include <libempathy/empathy-debug.h>
954
 
+
955
 
+#define GET_PRIV(obj) EMPATHY_GET_PRIV ((obj), EmpathyIndicator)
956
 
+
957
 
+enum {
958
 
+  PROP_0,
959
 
+  PROP_CONTACT,
960
 
+  PROP_BODY,
961
 
+  PROP_SUBTYPE,
962
 
+  PROP_VISIBLE
963
 
+};
964
 
+
965
 
+enum {
966
 
+  ACTIVATE,
967
 
+  LAST_SIGNAL
968
 
+};
969
 
+
970
 
+static guint signals[LAST_SIGNAL];
971
 
+
972
 
+typedef struct {
973
 
+  IndicateIndicator *indicator;
974
 
+  EmpathyContact    *contact;
975
 
+  gchar             *body;
976
 
+  gchar             *subtype;
977
 
+} EmpathyIndicatorPriv;
978
 
+
979
 
+G_DEFINE_TYPE (EmpathyIndicator, empathy_indicator, G_TYPE_OBJECT)
980
 
+
981
 
+
982
 
+static void
983
 
+empathy_indicator_dispose (GObject *object)
984
 
+{
985
 
+  EmpathyIndicatorPriv *priv;
986
 
+
987
 
+  priv = GET_PRIV (object);
988
 
+
989
 
+  if (priv->indicator) {
990
 
+    g_object_unref (priv->indicator);
991
 
+    priv->indicator = NULL;
992
 
+  }
993
 
+  if (priv->contact) {
994
 
+    g_object_unref (priv->contact);
995
 
+    priv->contact = NULL;
996
 
+  }
997
 
+
998
 
+  G_OBJECT_CLASS (empathy_indicator_parent_class)->dispose (object);
999
 
+}
1000
 
+
1001
 
+
1002
 
+static void
1003
 
+empathy_indicator_finalize (GObject *object)
1004
 
+{
1005
 
+  EmpathyIndicatorPriv *priv;
1006
 
+
1007
 
+  priv = GET_PRIV (object);
1008
 
+
1009
 
+  g_free (priv->body);
1010
 
+  g_free (priv->subtype);
1011
 
+
1012
 
+  G_OBJECT_CLASS (empathy_indicator_parent_class)->finalize (object);
1013
 
+}
1014
 
+
1015
 
+static void
1016
 
+indicate_show_cb (IndicateIndicator *indicator, guint timestamp,
1017
 
+    EmpathyIndicator *e_indicator)
1018
 
+{
1019
 
+  g_signal_emit (e_indicator, signals[ACTIVATE], 0, timestamp);
1020
 
+}
1021
 
+
1022
 
+
1023
 
+static IndicateIndicator *
1024
 
+empathy_indicator_get_indicator (EmpathyIndicator *e_indicator)
1025
 
+{
1026
 
+  EmpathyIndicatorPriv *priv;
1027
 
+
1028
 
+  priv = GET_PRIV (e_indicator);
1029
 
+  if (priv->indicator)
1030
 
+    return priv->indicator;
1031
 
+
1032
 
+  priv->indicator = indicate_indicator_new ();
1033
 
+  g_assert (priv->indicator);
1034
 
+  g_signal_connect (G_OBJECT (priv->indicator),
1035
 
+      INDICATE_INDICATOR_SIGNAL_DISPLAY,
1036
 
+      G_CALLBACK (indicate_show_cb),
1037
 
+      e_indicator);
1038
 
+
1039
 
+  return priv->indicator;
1040
 
+}
1041
 
+
1042
 
+
1043
 
+static void
1044
 
+empathy_indicator_set_property (GObject *object,
1045
 
+    guint param_id,
1046
 
+    const GValue *value,
1047
 
+    GParamSpec *pspec)
1048
 
+{
1049
 
+  EmpathyIndicator *e_indicator;
1050
 
+  EmpathyIndicatorPriv *priv;
1051
 
+  IndicateIndicator *indicator;
1052
 
+  GTimeVal time;
1053
 
+  GdkPixbuf *pixbuf_avatar = NULL;
1054
 
+
1055
 
+  e_indicator = EMPATHY_INDICATOR (object);
1056
 
+  priv = GET_PRIV (e_indicator);
1057
 
+
1058
 
+  indicator = empathy_indicator_get_indicator (e_indicator);
1059
 
+
1060
 
+  switch (param_id) {
1061
 
+  case PROP_CONTACT:
1062
 
+    priv->contact = g_object_ref (g_value_get_object (value));
1063
 
+    g_assert (priv->contact);
1064
 
+    indicate_indicator_set_property (indicator, "sender",
1065
 
+        empathy_contact_get_alias (priv->contact));
1066
 
+    /* get the scaled avatar (22,22) until LP bug #433143 is fixed then switch to
1067
 
+       to letting indicate-messages handle the scaling by setting the size to 0, 0 */
1068
 
+    pixbuf_avatar = empathy_pixbuf_avatar_from_contact_scaled (priv->contact, 22, 22);
1069
 
+    if (pixbuf_avatar != NULL)
1070
 
+    {
1071
 
+      indicate_indicator_set_property_icon(indicator, "icon", pixbuf_avatar);
1072
 
+      g_object_unref(G_OBJECT(pixbuf_avatar));
1073
 
+    }
1074
 
+    break;
1075
 
+  case PROP_BODY:
1076
 
+    if (priv->body)
1077
 
+      g_free (priv->body);
1078
 
+    priv->body = g_strdup (g_value_get_string (value));
1079
 
+    indicate_indicator_set_property (indicator, "body", priv->body);
1080
 
+    if (priv->body != NULL) {
1081
 
+      g_get_current_time (&time);
1082
 
+      indicate_indicator_set_property_time (indicator, "time", &time);
1083
 
+    }
1084
 
+    break;
1085
 
+  case PROP_SUBTYPE:
1086
 
+    if (priv->subtype)
1087
 
+      g_free (priv->subtype);
1088
 
+    priv->subtype = g_strdup (g_value_get_string (value));
1089
 
+    indicate_indicator_set_property (indicator, "subtype", priv->subtype);
1090
 
+    if (g_strcmp0 (priv->subtype, "login") != 0 ) {
1091
 
+      indicate_indicator_set_property (indicator, "draw-attention", "true");
1092
 
+    }
1093
 
+    break;
1094
 
+  case PROP_VISIBLE:
1095
 
+    if (g_value_get_boolean (value))
1096
 
+      indicate_indicator_show (indicator);
1097
 
+    else
1098
 
+      indicate_indicator_hide (indicator);
1099
 
+    break;
1100
 
+  default:
1101
 
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1102
 
+    break;
1103
 
+  }
1104
 
+}
1105
 
+
1106
 
+
1107
 
+static void
1108
 
+empathy_indicator_get_property (GObject *object,
1109
 
+    guint param_id,
1110
 
+    GValue *value,
1111
 
+    GParamSpec *pspec)
1112
 
+{
1113
 
+  EmpathyIndicator *e_indicator;
1114
 
+  EmpathyIndicatorPriv *priv;
1115
 
+
1116
 
+  e_indicator = EMPATHY_INDICATOR (object);
1117
 
+  priv = GET_PRIV (e_indicator);
1118
 
+
1119
 
+  switch (param_id) {
1120
 
+  case PROP_CONTACT:
1121
 
+    g_value_set_object (value, priv->contact);
1122
 
+    break;
1123
 
+  case PROP_BODY:
1124
 
+    g_value_set_string (value, priv->body);
1125
 
+    break;
1126
 
+  case PROP_SUBTYPE:
1127
 
+    g_value_set_string (value, priv->subtype);
1128
 
+    break;
1129
 
+  case PROP_VISIBLE:
1130
 
+    g_value_set_boolean (value, indicate_indicator_is_visible (priv->indicator));
1131
 
+    break;
1132
 
+  default:
1133
 
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
1134
 
+    break;
1135
 
+  }
1136
 
+}
1137
 
+
1138
 
+
1139
 
+static void
1140
 
+empathy_indicator_class_init (EmpathyIndicatorClass *klass)
1141
 
+{
1142
 
+  GObjectClass *object_class;
1143
 
+
1144
 
+  object_class = G_OBJECT_CLASS (klass);
1145
 
+
1146
 
+  object_class->set_property = empathy_indicator_set_property;
1147
 
+  object_class->get_property = empathy_indicator_get_property;
1148
 
+  object_class->dispose = empathy_indicator_dispose;
1149
 
+  object_class->finalize = empathy_indicator_finalize;
1150
 
+
1151
 
+  g_object_class_install_property (object_class, PROP_CONTACT,
1152
 
+      g_param_spec_object ("contact",
1153
 
+          "Contact",
1154
 
+          "The contact being indicated",
1155
 
+          EMPATHY_TYPE_CONTACT,
1156
 
+          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
1157
 
+  g_object_class_install_property (object_class, PROP_BODY,
1158
 
+      g_param_spec_string ("body",
1159
 
+          "Body",
1160
 
+          "The text for this contact",
1161
 
+          NULL,
1162
 
+          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
1163
 
+  g_object_class_install_property (object_class, PROP_SUBTYPE,
1164
 
+      g_param_spec_string ("subtype",
1165
 
+          "Subtype",
1166
 
+          "The type of this indicator",
1167
 
+          NULL,
1168
 
+          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
1169
 
+  g_object_class_install_property (object_class, PROP_VISIBLE,
1170
 
+      g_param_spec_boolean ("visible",
1171
 
+          "Visible",
1172
 
+          "The visibility of this indicator",
1173
 
+          FALSE,
1174
 
+          G_PARAM_READWRITE));
1175
 
+
1176
 
+  signals[ACTIVATE] =
1177
 
+      g_signal_new ("activate",
1178
 
+          G_TYPE_FROM_CLASS (klass),
1179
 
+          G_SIGNAL_RUN_LAST,
1180
 
+          0,
1181
 
+          NULL, NULL,
1182
 
+          g_cclosure_marshal_VOID__UINT,
1183
 
+          G_TYPE_NONE, 1, G_TYPE_UINT);
1184
 
+
1185
 
+  g_type_class_add_private (object_class, sizeof (EmpathyIndicatorPriv));
1186
 
+}
1187
 
+
1188
 
+
1189
 
+static void
1190
 
+empathy_indicator_init (EmpathyIndicator *e_indicator)
1191
 
+{
1192
 
+  e_indicator->priv = G_TYPE_INSTANCE_GET_PRIVATE (e_indicator,
1193
 
+      EMPATHY_TYPE_INDICATOR,
1194
 
+      EmpathyIndicatorPriv);
1195
 
+}
1196
 
+
1197
 
+
1198
 
+EmpathyIndicator *
1199
 
+empathy_indicator_new (EmpathyContact *sender,
1200
 
+    const gchar *body,
1201
 
+    const gchar *subtype)
1202
 
+{
1203
 
+  DEBUG ("Creating a new indicator");
1204
 
+  return g_object_new (EMPATHY_TYPE_INDICATOR, "contact", sender, "body", body,
1205
 
+      "subtype", subtype, NULL);
1206
 
+}
1207
 
+
1208
 
+
1209
 
+void
1210
 
+empathy_indicator_show (EmpathyIndicator *e_indicator)
1211
 
+{
1212
 
+  DEBUG ("Showing indicator %p", e_indicator);
1213
 
+  g_object_set (e_indicator, "visible", TRUE, NULL);
1214
 
+}
1215
 
+
1216
 
+
1217
 
+void
1218
 
+empathy_indicator_hide (EmpathyIndicator *e_indicator)
1219
 
+{
1220
 
+  DEBUG ("Hiding indicator %p", e_indicator);
1221
 
+  g_object_set (e_indicator, "visible", FALSE, NULL);
1222
 
+}
1223
 
+
1224
 
+
1225
 
+void
1226
 
+empathy_indicator_update (EmpathyIndicator *e_indicator,
1227
 
+    const gchar *body)
1228
 
+{
1229
 
+  DEBUG ("Updating existing indicator %p", e_indicator);
1230
 
+  g_object_set (e_indicator, "body", body, NULL);
1231
 
+}
1232
 
+
1233
 
+
1234
 
+EmpathyContact *
1235
 
+empathy_indicator_get_contact (EmpathyIndicator *e_indicator)
1236
 
+{
1237
 
+  EmpathyContact *contact;
1238
 
+  g_object_get (e_indicator, "contact", &contact, NULL);
1239
 
+  return contact;
1240
 
+}
1241
 
Index: empathy-2.34.0/src/empathy-indicator.h
1242
 
===================================================================
1243
 
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1244
 
+++ empathy-2.34.0/src/empathy-indicator.h      2011-03-24 12:46:24.808547063 -0400
1245
 
@@ -0,0 +1,65 @@
1246
 
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
1247
 
+/*
1248
 
+ * Copyright (C) 2009 Canonical Ltd.
1249
 
+ *
1250
 
+ * This program is free software; you can redistribute it and/or
1251
 
+ * modify it under the terms of the GNU General Public License as
1252
 
+ * published by the Free Software Foundation; either version 2 of the
1253
 
+ * License, or (at your option) any later version.
1254
 
+ *
1255
 
+ * This program is distributed in the hope that it will be useful,
1256
 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1257
 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1258
 
+ * General Public License for more details.
1259
 
+ *
1260
 
+ * You should have received a copy of the GNU General Public
1261
 
+ * License along with this program; if not, write to the
1262
 
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
1263
 
+ * Boston, MA  02110-1301  USA
1264
 
+ *
1265
 
+ * Authors: James Westby <james.westby@ubuntu.com>
1266
 
+ *
1267
 
+ */
1268
 
+
1269
 
+#ifndef __EMPATHY_INDICATOR_H__
1270
 
+#define __EMPATHY_INDICATOR_H__
1271
 
+
1272
 
+#include <glib.h>
1273
 
+
1274
 
+#include <libempathy/empathy-contact.h>
1275
 
+
1276
 
+G_BEGIN_DECLS
1277
 
+
1278
 
+#define EMPATHY_TYPE_INDICATOR         (empathy_indicator_get_type ())
1279
 
+#define EMPATHY_INDICATOR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDICATOR, EmpathyIndicator))
1280
 
+#define EMPATHY_INDICATOR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_INDICATOR, EmpathyIndicatorClass))
1281
 
+#define EMPATHY_IS_INDICATOR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_INDICATOR))
1282
 
+#define EMPATHY_IS_INDICATOR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDICATOR))
1283
 
+#define EMPATHY_INDICATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDICATOR, EmpathyIndicatorClass))
1284
 
+
1285
 
+typedef struct _EmpathyIndicator      EmpathyIndicator;
1286
 
+typedef struct _EmpathyIndicatorClass EmpathyIndicatorClass;
1287
 
+
1288
 
+struct _EmpathyIndicator {
1289
 
+  GObject parent;
1290
 
+  gpointer priv;
1291
 
+};
1292
 
+
1293
 
+struct _EmpathyIndicatorClass {
1294
 
+  GObjectClass parent_class;
1295
 
+};
1296
 
+
1297
 
+GType empathy_indicator_get_type (void) G_GNUC_CONST;
1298
 
+EmpathyIndicator *empathy_indicator_new (EmpathyContact *sender,
1299
 
+    const gchar *body,
1300
 
+    const gchar *type);
1301
 
+void empathy_indicator_show (EmpathyIndicator *e_indicator);
1302
 
+void empathy_indicator_hide (EmpathyIndicator *e_indicator);
1303
 
+void empathy_indicator_update (EmpathyIndicator *e_indicator,
1304
 
+    const gchar *body);
1305
 
+EmpathyContact *empathy_indicator_get_contact (EmpathyIndicator *e_indicator);
1306
 
+
1307
 
+G_END_DECLS
1308
 
+
1309
 
+
1310
 
+#endif /* __EMPATHY-INDICATOR_H__ */
1311
 
Index: empathy-2.34.0/src/empathy-main-window.c
1312
 
===================================================================
1313
 
--- empathy-2.34.0.orig/src/empathy-main-window.c       2011-03-24 12:46:07.198547066 -0400
1314
 
+++ empathy-2.34.0/src/empathy-main-window.c    2011-03-24 12:46:24.808547063 -0400
1315
 
@@ -82,6 +82,10 @@
1316
 
 #include "empathy-ft-manager.h"
1317
 
 #include "empathy-migrate-butterfly-logs.h"
1318
 
 
1319
 
+#ifdef HAVE_LIBINDICATE
1320
 
+#include "empathy-indicator-manager.h"
1321
 
+#endif
1322
 
+
1323
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
1324
 
 #include <libempathy/empathy-debug.h>
1325
 
 
1326
 
@@ -161,6 +165,10 @@
1327
 
 
1328
 
        /* Actions that are enabled when there are connected accounts */
1329
 
        GList                  *actions_connected;
1330
 
+#ifdef HAVE_LIBINDICATE
1331
 
+       EmpathyIndicatorManager *indicator_manager;
1332
 
+       GHashTable              *indicator_timeouts;
1333
 
+#endif
1334
 
 
1335
 
        /* The idle event source to migrate butterfly's logs */
1336
 
        guint butterfly_log_migration_members_changed_id;
1337
 
@@ -433,11 +441,23 @@
1338
 
                            EmpathyEvent        *event,
1339
 
                            EmpathyMainWindow   *window)
1340
 
 {
1341
 
+        EmpathyMainWindowPriv *priv = GET_PRIV (window);
1342
 
+
1343
 
        if (event->contact) {
1344
 
                main_window_flash_start (window);
1345
 
        } else if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
1346
 
                main_window_auth_display (window, event);
1347
 
        }
1348
 
1349
 
+ #ifdef HAVE_LIBINDICATE
1350
 
+        if (event->type == EMPATHY_EVENT_TYPE_PRESENCE &&
1351
 
+            tp_connection_presence_type_cmp_availability (empathy_contact_get_presence (event->contact),
1352
 
+                                                          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0) {
1353
 
+                empathy_indicator_manager_add_login_indicator (priv->indicator_manager,
1354
 
+                 event->contact);
1355
 
+        }
1356
 
+ #endif
1357
 
+
1358
 
 }
1359
 
 
1360
 
 static void
1361
 
@@ -1004,6 +1024,10 @@
1362
 
        g_object_unref (priv->ui_manager);
1363
 
        g_object_unref (priv->chatroom_manager);
1364
 
 
1365
 
+#ifdef HAVE_LIBINDICATE
1366
 
+       g_object_unref (priv->indicator_manager);
1367
 
+#endif
1368
 
+
1369
 
        g_object_unref (priv->gsettings_ui);
1370
 
        g_object_unref (priv->gsettings_contacts);
1371
 
 
1372
 
@@ -2072,6 +2096,10 @@
1373
 
                l = l->next;
1374
 
        }
1375
 
 
1376
 
+#ifdef HAVE_LIBINDICATE
1377
 
+       priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
1378
 
+#endif
1379
 
+
1380
 
        /* Show offline ? */
1381
 
        show_offline = g_settings_get_boolean (priv->gsettings_ui,
1382
 
                                               EMPATHY_PREFS_UI_SHOW_OFFLINE);
1383
 
Index: empathy-2.34.0/src/empathy-preferences.c
1384
 
===================================================================
1385
 
--- empathy-2.34.0.orig/src/empathy-preferences.c       2011-03-24 11:15:16.000000000 -0400
1386
 
+++ empathy-2.34.0/src/empathy-preferences.c    2011-03-24 12:46:24.818547063 -0400
1387
 
@@ -56,6 +56,7 @@
1388
 
 
1389
 
        GtkWidget *checkbutton_show_smileys;
1390
 
        GtkWidget *checkbutton_show_contacts_in_rooms;
1391
 
+       GtkWidget *checkbutton_use_libindicate;
1392
 
        GtkWidget *combobox_chat_theme;
1393
 
        GtkWidget *checkbutton_separate_chat_windows;
1394
 
        GtkWidget *checkbutton_events_notif_area;
1395
 
@@ -235,6 +236,16 @@
1396
 
                         priv->checkbutton_show_smileys,
1397
 
                         "active",
1398
 
                         G_SETTINGS_BIND_DEFAULT);
1399
 
+#ifdef HAVE_LIBINDICATE
1400
 
+       g_settings_bind (priv->gsettings_ui,
1401
 
+                        EMPATHY_PREFS_UI_USE_LIBINDICATE,
1402
 
+                        priv->checkbutton_use_libindicate,
1403
 
+                        "active",
1404
 
+                        G_SETTINGS_BIND_DEFAULT);
1405
 
+#else
1406
 
+       gtk_widget_hide (GTK_WIDGET (priv->checkbutton_use_libindicate));
1407
 
+#endif
1408
 
+
1409
 
        g_settings_bind (priv->gsettings_chat,
1410
 
                         EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
1411
 
                         priv->checkbutton_show_contacts_in_rooms,
1412
 
@@ -890,6 +901,7 @@
1413
 
                "notebook", &priv->notebook,
1414
 
                "checkbutton_show_smileys", &priv->checkbutton_show_smileys,
1415
 
                "checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms,
1416
 
+               "checkbutton_use_libindicate", &priv->checkbutton_use_libindicate,
1417
 
                "combobox_chat_theme", &priv->combobox_chat_theme,
1418
 
                "checkbutton_separate_chat_windows", &priv->checkbutton_separate_chat_windows,
1419
 
                "checkbutton_events_notif_area", &priv->checkbutton_events_notif_area,
1420
 
Index: empathy-2.34.0/src/empathy-preferences.ui
1421
 
===================================================================
1422
 
--- empathy-2.34.0.orig/src/empathy-preferences.ui      2011-02-10 07:10:25.000000000 -0500
1423
 
+++ empathy-2.34.0/src/empathy-preferences.ui   2011-03-24 12:46:24.818547063 -0400
1424
 
@@ -266,6 +266,20 @@
1425
 
                     <property name="position">1</property>
1426
 
                   </packing>
1427
 
                 </child>
1428
 
+                <child>
1429
 
+                  <object class="GtkCheckButton" id="checkbutton_use_libindicate">
1430
 
+                    <property name="label" translatable="yes">Show incoming messages in the messaging menu</property>
1431
 
+                    <property name="visible">True</property>
1432
 
+                    <property name="can_focus">True</property>
1433
 
+                    <property name="receives_default">False</property>
1434
 
+                    <property name="draw_indicator">True</property>
1435
 
+                  </object>
1436
 
+                  <packing>
1437
 
+                    <property name="expand">False</property>
1438
 
+                    <property name="fill">False</property>
1439
 
+                    <property name="position">2</property>
1440
 
+                  </packing>
1441
 
+                </child>
1442
 
               </object>
1443
 
               <packing>
1444
 
                 <property name="position">1</property>
1445
 
Index: empathy-2.34.0/src/empathy-status-icon.c
1446
 
===================================================================
1447
 
--- empathy-2.34.0.orig/src/empathy-status-icon.c       2011-03-24 11:15:16.000000000 -0400
1448
 
+++ empathy-2.34.0/src/empathy-status-icon.c    2011-03-24 12:46:24.818547063 -0400
1449
 
@@ -29,6 +29,7 @@
1450
 
 #include <gdk/gdkkeysyms.h>
1451
 
 #include <glib/gi18n.h>
1452
 
 
1453
 
+#include <libnotify/notify.h>
1454
 
 #include <libnotify/notification.h>
1455
 
 #include <libnotify/notify.h>
1456
 
 
1457
 
@@ -52,6 +53,12 @@
1458
 
 #include "empathy-preferences.h"
1459
 
 #include "empathy-event-manager.h"
1460
 
 
1461
 
+#ifdef HAVE_LIBINDICATE
1462
 
+#include "empathy-indicator-manager.h"
1463
 
+#include <libindicate/server.h>
1464
 
+#include <libindicate/interests.h>
1465
 
+#endif
1466
 
+
1467
 
 #define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
1468
 
 #include <libempathy/empathy-debug.h>
1469
 
 
1470
 
@@ -76,6 +83,10 @@
1471
 
        GtkAction           *show_window_item;
1472
 
        GtkAction           *new_message_item;
1473
 
        GtkAction           *status_item;
1474
 
+#ifdef HAVE_LIBINDICATE
1475
 
+        EmpathyIndicatorManager *indicator_manager;
1476
 
+        IndicateServer      *indicate_server;
1477
 
+#endif
1478
 
 } EmpathyStatusIconPriv;
1479
 
 
1480
 
 G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
1481
 
@@ -457,6 +468,92 @@
1482
 
                empathy_window_present (GTK_WINDOW (priv->window));
1483
 
        }
1484
 
 }
1485
 
+#ifdef HAVE_LIBINDICATE
1486
 
+static void
1487
 
+empathy_status_icon_set_visible (gboolean show_icon, EmpathyStatusIcon *icon)
1488
 
+{
1489
 
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1490
 
+       gtk_status_icon_set_visible (priv->icon, show_icon);
1491
 
+}
1492
 
+
1493
 
+static void
1494
 
+empathy_indicator_interest_status_icon (gboolean icon_visibility,
1495
 
+       EmpathyStatusIcon *icon)
1496
 
+{
1497
 
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1498
 
+       EmpathyIndicatorManager *manager;
1499
 
+       gboolean use_libindicate;
1500
 
+
1501
 
+       manager = empathy_indicator_manager_dup_singleton();
1502
 
+       use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
1503
 
+                                                 EMPATHY_PREFS_UI_USE_LIBINDICATE);
1504
 
+
1505
 
+       if (use_libindicate && !icon_visibility) {
1506
 
+               empathy_indicator_manager_set_server_visible (manager, TRUE);
1507
 
+               /* Hide the status icon so there are not two ways to access
1508
 
+                * empathy.
1509
 
+                */
1510
 
+               DEBUG ("Hiding the icon, we are shown in the indicator");
1511
 
+               empathy_status_icon_set_visible (FALSE, icon);
1512
 
+       } else {
1513
 
+               empathy_indicator_manager_set_server_visible (manager,
1514
 
+                               FALSE);
1515
 
+               DEBUG ("Show the icon, we are not shown in the indicator");
1516
 
+               empathy_status_icon_set_visible (TRUE, icon);
1517
 
+       }
1518
 
+}
1519
 
+
1520
 
+static void
1521
 
+empathy_indicator_interest_added (IndicateServer * server,
1522
 
+       IndicateInterests interest, EmpathyStatusIcon *icon)
1523
 
+{
1524
 
+       if (interest != INDICATE_INTEREST_SERVER_SIGNAL) {
1525
 
+               return;
1526
 
+       }
1527
 
+       DEBUG ("Indicator received interest-added signal");
1528
 
+       empathy_indicator_interest_status_icon(FALSE, icon);
1529
 
+}
1530
 
+
1531
 
+static void
1532
 
+empathy_indicator_interest_removed (IndicateServer * server,
1533
 
+       IndicateInterests interest, EmpathyStatusIcon *icon)
1534
 
+{
1535
 
+       if (interest != INDICATE_INTEREST_SERVER_SIGNAL) {
1536
 
+               return;
1537
 
+       }
1538
 
+
1539
 
+       DEBUG ("Indicator received interest-removed signal");
1540
 
+       empathy_indicator_interest_status_icon(TRUE, icon);
1541
 
+}
1542
 
+
1543
 
+static void
1544
 
+status_icon_set_use_libindicate (EmpathyStatusIcon *icon,
1545
 
+                           gboolean use_libindicate)
1546
 
+{
1547
 
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1548
 
+
1549
 
+       if (use_libindicate) {
1550
 
+               empathy_indicator_manager_set_server_visible (priv->indicator_manager, TRUE);
1551
 
+       } else {
1552
 
+               empathy_indicator_manager_set_server_visible (priv->indicator_manager, FALSE);
1553
 
+               empathy_status_icon_set_visible(TRUE, icon);
1554
 
+       }
1555
 
+}
1556
 
+
1557
 
+static void
1558
 
+status_icon_notify_libindicate_cb (GSettings *gsettings,
1559
 
+                                 const gchar *key,
1560
 
+                                 gpointer     user_data)
1561
 
+{
1562
 
+       EmpathyStatusIcon *icon = user_data;
1563
 
+       EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1564
 
+       gboolean           use_libindicate;
1565
 
+
1566
 
+       use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
1567
 
+                                                 EMPATHY_PREFS_UI_USE_LIBINDICATE);
1568
 
+       status_icon_set_use_libindicate (icon, use_libindicate);
1569
 
+}
1570
 
+#endif
1571
 
 
1572
 
 static void
1573
 
 status_icon_notify_visibility_cb (GSettings   *gsettings,
1574
 
@@ -476,10 +573,36 @@
1575
 
        EmpathyStatusIconPriv *priv = GET_PRIV (icon);
1576
 
        gboolean               visible;
1577
 
 
1578
 
+
1579
 
        visible = gtk_window_is_active (priv->window);
1580
 
+#ifdef HAVE_LIBINDICATE
1581
 
+       gboolean               use_libindicate;
1582
 
+       use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
1583
 
+                                                 EMPATHY_PREFS_UI_USE_LIBINDICATE);
1584
 
+       if (use_libindicate) {
1585
 
+               /* If indicators are used then we may very well not be active
1586
 
+                * when toggled, as they are usually windows themselves. This
1587
 
+                * makes it damn hard to toggle, so we just look at whether
1588
 
+                * we are visible.
1589
 
+                */
1590
 
+               visible = GTK_WIDGET_VISIBLE (priv->window);
1591
 
+               status_icon_set_visibility (icon, TRUE, TRUE);
1592
 
+               return;
1593
 
+       }
1594
 
+#endif
1595
 
+
1596
 
        status_icon_set_visibility (icon, !visible, TRUE);
1597
 
 }
1598
 
 
1599
 
+#ifdef HAVE_LIBINDICATE
1600
 
+static void
1601
 
+indicate_server_activate_cb (EmpathyIndicatorManager *manager,
1602
 
+                               guint timestamp, EmpathyStatusIcon *icon)
1603
 
+{
1604
 
+       status_icon_toggle_visibility (icon);
1605
 
+}
1606
 
+#endif
1607
 
+
1608
 
 static void
1609
 
 status_icon_presence_changed_cb (EmpathyStatusIcon *icon)
1610
 
 {
1611
 
@@ -663,6 +786,9 @@
1612
 
        g_object_unref (priv->notify_mgr);
1613
 
        g_object_unref (priv->gsettings_ui);
1614
 
        g_object_unref (priv->window);
1615
 
+#ifdef HAVE_LIBINDICATE
1616
 
+       g_object_unref (priv->indicator_manager);
1617
 
+#endif
1618
 
 }
1619
 
 
1620
 
 static void
1621
 
@@ -723,6 +849,13 @@
1622
 
                          G_CALLBACK (status_icon_notify_visibility_cb),
1623
 
                          icon);
1624
 
 
1625
 
+#ifdef HAVE_LIBINDICATE
1626
 
+       g_signal_connect (priv->gsettings_ui,
1627
 
+                         "changed::" EMPATHY_PREFS_UI_USE_LIBINDICATE,
1628
 
+                         G_CALLBACK (status_icon_notify_libindicate_cb),
1629
 
+                         icon);
1630
 
+#endif
1631
 
+
1632
 
        status_icon_create_menu (icon);
1633
 
 
1634
 
        g_signal_connect_swapped (priv->account_manager,
1635
 
@@ -755,6 +888,9 @@
1636
 
        EmpathyStatusIconPriv *priv;
1637
 
        EmpathyStatusIcon     *icon;
1638
 
        gboolean               should_hide;
1639
 
+#ifdef HAVE_LIBINDICATE
1640
 
+       gboolean               use_libindicate;
1641
 
+#endif
1642
 
 
1643
 
        g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
1644
 
 
1645
 
@@ -762,6 +898,24 @@
1646
 
        priv = GET_PRIV (icon);
1647
 
 
1648
 
        priv->window = g_object_ref (window);
1649
 
+#ifdef HAVE_LIBINDICATE
1650
 
+       priv->indicator_manager = empathy_indicator_manager_dup_singleton ();
1651
 
+       priv->indicate_server = indicate_server_ref_default ();
1652
 
+
1653
 
+       g_signal_connect (priv->indicator_manager, "server-activate",
1654
 
+                         G_CALLBACK (indicate_server_activate_cb),
1655
 
+                         icon);
1656
 
+
1657
 
+       g_signal_connect (priv->indicate_server,
1658
 
+                         INDICATE_SERVER_SIGNAL_INTEREST_ADDED,
1659
 
+                         G_CALLBACK(empathy_indicator_interest_added),
1660
 
+                         icon);
1661
 
+
1662
 
+       g_signal_connect (priv->indicate_server,
1663
 
+                         INDICATE_SERVER_SIGNAL_INTEREST_REMOVED,
1664
 
+                         G_CALLBACK(empathy_indicator_interest_removed),
1665
 
+                         icon);
1666
 
+#endif
1667
 
 
1668
 
        g_signal_connect_after (priv->window, "key-press-event",
1669
 
                          G_CALLBACK (status_icon_key_press_event_cb),
1670
 
@@ -778,6 +932,12 @@
1671
 
                should_hide = TRUE;
1672
 
        }
1673
 
 
1674
 
+#ifdef HAVE_LIBINDICATE
1675
 
+       use_libindicate = g_settings_get_boolean (priv->gsettings_ui,
1676
 
+                                                 EMPATHY_PREFS_UI_USE_LIBINDICATE);
1677
 
+       status_icon_set_use_libindicate (icon, use_libindicate);
1678
 
+#endif
1679
 
+
1680
 
        status_icon_set_visibility (icon, !should_hide, FALSE);
1681
 
 
1682
 
        return icon;