annotate src/gaim-client.c @ 12116:e75ef7aa913e

[gaim-migrate @ 14416] " This patch implements a replacement for the queuing system from 1.x. It also obsoletes a previous patch [#1338873] I submitted to prioritize the unseen states in gtk conversations. The attached envelope.png is ripped from the msgunread.png already included in gaim. It should be dropped in the pixmaps directory (Makefile.am is updated accordingly in this patch). The two separate queuing preferences from 1.x, queuing messages while away and queuing all new messages (from docklet), are replaced with a single 3-way preference for conversations. The new preference is "Hide new IM conversations". This preference can be set to never, away and always. When a gtk conversation is created, it may be placed in a hidden conversation window instead of being placed normally. This decision is based upon the preference and possibly the away state of the account the conversation is being created for. This *will* effect conversations the user explicitly requests to be created, so in these cases the caller must be sure to present the conversation to the user, using gaim_gtkconv_present_conversation(). This is done already in gtkdialogs.c which handles creating conversations requested by the user from gaim proper (menus, double-clicking on budy in blist, etc.). The main advantage to not queuing messages is that the conversations exist, the message is written to the conversation (and logged if appropriate) and the unseen state is set on the conversation. This means no additional features are needed to track whether there are queued messages or not, just use the unseen state on conversations. Since conversations may not be visible (messages "queued"), gaim proper needs some notification that there are messages waiting. I opted for a menutray icon that shows up when an im conversation has an unseen message. Clicking this icon will focus (and show if hidden) the first conversation with an unseen message. This is essentially the same behavior of the docklet in cvs right now, except that the icon is only visible when there is a conversation with an unread message. The api that is added is flexible enough to allow either the docklet or the new blist menutray icon to be visible for conversations of any/all types and for unseen messages >= any state. Currently they are set to only IM conversations and only unseen states >= TEXT (system messages and no log messages will not trigger blinking the docklet or showing the blist tray icon), but these could be made preferences relatively easily in the future. Other plugins could probably benefit as well: gaim_gtk_conversations_get_first_unseen(). There is probably some limit to comment size, so I'll stop rambling now. If anyone has more questions/comments, catch me in #gaim, here or on gaim-devel." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 16 Nov 2005 18:17:01 +0000
parents 421a8523ad04
children 8bda65b88e49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 #define DBUS_API_SUBJECT_TO_CHANGE
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
2
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 #include <dbus/dbus-glib.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
4 #include <stdio.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
5 #include <stdlib.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
6
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
7 #include "dbus-gaim.h"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
8 #include "gaim-client-bindings.h"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
9
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
10 static DBusGConnection *bus;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
11 static DBusGProxy *gaim_proxy;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
12
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
13 static GList *garray_int_to_glist(GArray *array) {
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
14 GList *list = NULL;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
15 int i;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
16
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
17 for(i = 0; i < array->len; i++)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
18 list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
19
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
20 g_array_free(array, TRUE);
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
21 return list;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
22 }
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
23
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
24 static GSList *garray_int_to_gslist(GArray *array) {
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
25 GSList *list = NULL;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
26 int i;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
27
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
28 for(i = 0; i < array->len; i++)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
29 list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
30
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
31 g_array_free(array, TRUE);
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
32 return list;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
33 }
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
34
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
35 #include "gaim-client-bindings.c"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
36
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
37 static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
38 static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
39
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
40 static void
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
41 lose (const char *str, ...)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
42 {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
43 va_list args;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
44
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
45 va_start (args, str);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
46
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
47 vfprintf (stderr, str, args);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
48 fputc ('\n', stderr);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
49
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
50 va_end (args);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
51
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
52 exit (1);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
53 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
54
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
55 static void
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
56 lose_gerror (const char *prefix, GError *error)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
57 {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
58 lose ("%s: %s", prefix, error->message);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
59 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
60
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
61 void gaim_init(void) {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
62 GError *error = NULL;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
63
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
64 g_type_init ();
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
65
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
66 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
67 if (!bus)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
68 lose_gerror ("Couldn't connect to session bus", error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
69
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
70 gaim_proxy = dbus_g_proxy_new_for_name (bus,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
71 DBUS_SERVICE_GAIM,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
72 DBUS_PATH_GAIM,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
73 DBUS_INTERFACE_GAIM);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
74
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
75 if (!gaim_proxy)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
76 lose_gerror ("Couldn't connect to the Gaim Service", error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
77 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
78