annotate src/sound.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 a66ee70c614c
children 5bc3d67ceb24
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7035
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7035
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7035
diff changeset
6 * source distribution.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
23 #include "internal.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
24
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
25 #include "blist.h"
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
26 #include "prefs.h"
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
27 #include "sound.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
29 static GaimSoundUiOps *sound_ui_ops = NULL;
3319
3a05fcb133c4 [gaim-migrate @ 3337]
Sean Egan <seanegan@gmail.com>
parents: 3284
diff changeset
30
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
31 void
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
32 gaim_sound_play_file(const char *filename, const GaimAccount *account)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
33 {
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
34 GaimStatus *status;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
35
11652
a66ee70c614c [gaim-migrate @ 13936]
Mark Doliner <mark@kingant.net>
parents: 11642
diff changeset
36 if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away")))
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
37 {
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
38 status = gaim_account_get_active_status(account);
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
39 if (gaim_status_is_online(status) && !gaim_status_is_available(status))
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
40 return;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
41 }
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
42
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
43 if(sound_ui_ops && sound_ui_ops->play_file)
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
44 sound_ui_ops->play_file(filename);
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
45 }
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
46
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
47 void
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
48 gaim_sound_play_event(GaimSoundEventID event, const GaimAccount *account)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 {
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
50 GaimStatus *status;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
51
11652
a66ee70c614c [gaim-migrate @ 13936]
Mark Doliner <mark@kingant.net>
parents: 11642
diff changeset
52 if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away")))
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
53 {
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
54 status = gaim_account_get_active_status(account);
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
55 if (gaim_status_is_online(status) && !gaim_status_is_available(status))
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
56 return;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11563
diff changeset
57 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
58
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
59 if(sound_ui_ops && sound_ui_ops->play_event)
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5612
diff changeset
60 sound_ui_ops->play_event(event);
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
61 }
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
62
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
63 void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
64 gaim_sound_set_ui_ops(GaimSoundUiOps *ops)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
65 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
66 if(sound_ui_ops && sound_ui_ops->uninit)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
67 sound_ui_ops->uninit();
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
68
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
69 sound_ui_ops = ops;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
70
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
71 if(sound_ui_ops && sound_ui_ops->init)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
72 sound_ui_ops->init();
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
73 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
74
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
75 GaimSoundUiOps *
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
76 gaim_sound_get_ui_ops(void)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
77 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
78 return sound_ui_ops;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
79 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
80
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
81 void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
82 gaim_sound_init()
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
83 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
84 gaim_prefs_add_none("/core/sound");
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
85 gaim_prefs_add_bool("/core/sound/while_away", FALSE);
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
86
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
87 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
88
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
89 void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
90 gaim_sound_uninit()
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
91 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
92 if(sound_ui_ops && sound_ui_ops->uninit)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
93 sound_ui_ops->uninit();
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 9993
diff changeset
94 }