annotate src/gtksound.c @ 13753:c066473fff04

[gaim-migrate @ 16164] SF Patch #1482906 from Sadrul "The timestamp plugin was not working. This makes it work again. Looks like I didn't update this one when the displaying- signals were moved to gtkconv from conv. Also, I think having this timestamp work for chat windows can't hurt. So I have added support for that too." If you object to the change in functionality, that's easy to remove. I wasn't sure, since I don't use this plugin, but I kept it because I can't think of a reason you wouldn't want the timestamps in chats as well. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 09 May 2006 01:42:39 +0000
parents 988186eb1688
children 164932c4d050
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10158
diff changeset
2 * @file gtksound.h GTK+ Sound
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10158
diff changeset
3 * @ingroup gtkui
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10158
diff changeset
4 *
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 * gaim
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7465
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7465
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7465
diff changeset
9 * source distribution.
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 *
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 *
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 8947
diff changeset
26 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 8947
diff changeset
27 #include "gtkgaim.h"
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
29 #ifdef _WIN32
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include <windows.h>
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include <mmsystem.h>
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #endif
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
34 #ifdef USE_GSTREAMER
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
35 # include <gst/gst.h>
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
36 #endif /* USE_GSTREAMER */
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
38 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
39 #include "notify.h"
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 #include "prefs.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
41 #include "sound.h"
7465
dedbfdc7ce65 [gaim-migrate @ 8078]
Mark Doliner <mark@kingant.net>
parents: 7464
diff changeset
42 #include "util.h"
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
44 #include "gtkconv.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
45 #include "gtksound.h"
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 struct gaim_sound_event {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 char *label;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 char *pref;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 char *def;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 };
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
53 #define PLAY_SOUND_TIMEOUT 15000
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
55 static guint mute_login_sounds_timeout = 0;
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 static gboolean mute_login_sounds = FALSE;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = {
10158
5dd9c1df6459 [gaim-migrate @ 11239]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
59 {N_("Buddy logs in"), "login", "login.wav"},
5dd9c1df6459 [gaim-migrate @ 11239]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
60 {N_("Buddy logs out"), "logout", "logout.wav"},
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 {N_("Message received"), "im_recv", "receive.wav"},
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"},
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 {N_("Message sent"), "send_im", "send.wav"},
10158
5dd9c1df6459 [gaim-migrate @ 11239]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
64 {N_("Person enters chat"), "join_chat", "login.wav"},
5dd9c1df6459 [gaim-migrate @ 11239]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
65 {N_("Person leaves chat"), "left_chat", "logout.wav"},
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 {N_("You talk in chat"), "send_chat_msg", "send.wav"},
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"},
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
10158
5dd9c1df6459 [gaim-migrate @ 11239]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
69 {NULL, "pounce_default", "alert.wav"},
13550
47c12348cfd1 [gaim-migrate @ 15927]
Richard Laager <rlaager@wiktel.com>
parents: 13543
diff changeset
70 {N_("Someone says your screen name in chat"), "nick_said", "alert.wav"}
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 };
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
73 static gboolean
11463
448ebda0f7ec [gaim-migrate @ 13703]
Mark Doliner <mark@kingant.net>
parents: 11256
diff changeset
74 unmute_login_sounds_cb(gpointer data)
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
75 {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
76 mute_login_sounds = FALSE;
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
77 mute_login_sounds_timeout = 0;
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
78 return FALSE;
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
79 }
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
80
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
81 static gboolean
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
82 chat_nick_matches_name(GaimConversation *conv, const char *aname)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
83 {
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
84 GaimConvChat *chat = NULL;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
85 char *nick = NULL;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
86 char *name = NULL;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
87 gboolean ret = FALSE;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
88 chat = gaim_conversation_get_chat_data(conv);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
89
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
90 if (chat==NULL)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
91 return ret;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
92
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
93 nick = g_strdup(gaim_normalize(conv->account, chat->nick));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
94 name = g_strdup(gaim_normalize(conv->account, aname));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
95
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
96 if (g_utf8_collate(nick, name) == 0)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
97 ret = TRUE;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
98
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
99 g_free(nick);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
100 g_free(name);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
101
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
102 return ret;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
103 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
104
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
105 /*
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
106 * play a sound event for a conversation, honoring make_sound flag
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
107 * of conversation and checking for focus if conv_focus pref is set
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
108 */
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
109 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
110 play_conv_event(GaimConversation *conv, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
111 {
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
112 /* If we should not play the sound for some reason, then exit early */
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
113 if (conv != NULL)
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
114 {
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
115 GaimGtkConversation *gtkconv;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
116 GaimGtkWindow *win;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
117 gboolean has_focus;
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
118
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
119 gtkconv = GAIM_GTK_CONVERSATION(conv);
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
120 win = gtkconv->win;
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
121
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
122 has_focus = gaim_conversation_has_focus(conv);
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
123
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
124 if (!gtkconv->make_sound ||
11687
941aa045f9f6 [gaim-migrate @ 13973]
Richard Laager <rlaager@wiktel.com>
parents: 11642
diff changeset
125 (has_focus && !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus")))
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
126 {
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
127 return;
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
128 }
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
129 }
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
130
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
131 gaim_sound_play_event(event, conv ? gaim_conversation_get_account(conv) : NULL);
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
132 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
133
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
134 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
135 buddy_state_cb(GaimBuddy *buddy, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
136 {
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
137 gaim_sound_play_event(event, gaim_buddy_get_account(buddy));
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
138 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
139
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
140 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
141 im_msg_received_cb(GaimAccount *account, char *sender,
11581
9b3833da6840 [gaim-migrate @ 13851]
Tim Ringenbach <marv@pidgin.im>
parents: 11552
diff changeset
142 char *message, GaimConversation *conv,
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
143 int flags, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
144 {
12850
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
145 if (flags & GAIM_MESSAGE_DELAYED)
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
146 return;
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
147
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
148 if (conv==NULL)
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
149 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE, account);
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
150 else
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
151 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
152 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
153
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
154 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
155 im_msg_sent_cb(GaimAccount *account, const char *receiver,
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
156 const char *message, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
157 {
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
158 GaimConversation *conv = gaim_find_conversation_with_account(
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
159 GAIM_CONV_TYPE_ANY, receiver, account);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
160 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
161 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
162
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
163 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
164 chat_buddy_join_cb(GaimConversation *conv, const char *name,
12850
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
165 GaimConvChatBuddyFlags flags, gboolean new_arrival,
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
166 GaimSoundEventID event)
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
167 {
12850
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
168 if (new_arrival && !chat_nick_matches_name(conv, name))
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
169 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
170 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
171
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
172 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
173 chat_buddy_left_cb(GaimConversation *conv, const char *name,
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
174 const char *reason, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
175 {
11581
9b3833da6840 [gaim-migrate @ 13851]
Tim Ringenbach <marv@pidgin.im>
parents: 11552
diff changeset
176 if (!chat_nick_matches_name(conv, name))
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
177 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
178 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
179
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
180 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
181 chat_msg_sent_cb(GaimAccount *account, const char *message,
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
182 int id, GaimSoundEventID event)
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
183 {
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
184 GaimConnection *conn = gaim_account_get_connection(account);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
185 GaimConversation *conv = NULL;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
186
11581
9b3833da6840 [gaim-migrate @ 13851]
Tim Ringenbach <marv@pidgin.im>
parents: 11552
diff changeset
187 if (conn!=NULL)
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
188 conv = gaim_find_chat(conn,id);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
189
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
190 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
191 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
192
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
193 static void
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
194 chat_msg_received_cb(GaimAccount *account, char *sender,
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
195 char *message, GaimConversation *conv,
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11687
diff changeset
196 GaimMessageFlags flags, GaimSoundEventID event)
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
197 {
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
198 GaimConvChat *chat;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
199
12850
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
200 if (flags & GAIM_MESSAGE_DELAYED)
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
201 return;
49b2347863b2 [gaim-migrate @ 15200]
Richard Laager <rlaager@wiktel.com>
parents: 12828
diff changeset
202
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
203 chat = gaim_conversation_get_chat_data(conv);
13412
d93194613696 [gaim-migrate @ 15787]
Richard Laager <rlaager@wiktel.com>
parents: 13046
diff changeset
204 g_return_if_fail(chat != NULL);
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
205
13412
d93194613696 [gaim-migrate @ 15787]
Richard Laager <rlaager@wiktel.com>
parents: 13046
diff changeset
206 if (gaim_conv_chat_is_user_ignored(chat, sender))
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
207 return;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
208
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
209 if (chat_nick_matches_name(conv, sender))
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
210 return;
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
211
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11687
diff changeset
212 if (flags & GAIM_MESSAGE_NICK || gaim_utf8_has_word(message, chat->nick))
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
213 play_conv_event(conv, GAIM_SOUND_CHAT_NICK);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
214 else
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
215 play_conv_event(conv, event);
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
216 }
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
217
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
218 /*
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
219 * We mute sounds for the 10 seconds after you log in so that
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
220 * you don't get flooded with sounds when the blist shows all
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
221 * your buddies logging in.
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
222 */
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
223 static void
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
224 account_signon_cb(GaimConnection *gc, gpointer data)
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
225 {
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
226 if (mute_login_sounds_timeout != 0)
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
227 g_source_remove(mute_login_sounds_timeout);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
228 mute_login_sounds = TRUE;
11463
448ebda0f7ec [gaim-migrate @ 13703]
Mark Doliner <mark@kingant.net>
parents: 11256
diff changeset
229 mute_login_sounds_timeout = gaim_timeout_add(10000, unmute_login_sounds_cb, NULL);
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
230 }
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
231
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
232 const char *
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
233 gaim_gtk_sound_get_event_option(GaimSoundEventID event)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
234 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
235 if(event >= GAIM_NUM_SOUNDS)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
236 return 0;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
237
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
238 return sounds[event].pref;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
239 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
240
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
241 char *
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
242 gaim_gtk_sound_get_event_label(GaimSoundEventID event)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
243 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
244 if(event >= GAIM_NUM_SOUNDS)
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
245 return NULL;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
246
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
247 return sounds[event].label;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
248 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
249
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
250 void *
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
251 gaim_gtk_sound_get_handle()
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
252 {
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
253 static int handle;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
254
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
255 return &handle;
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
256 }
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
257
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
258 static void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
259 gaim_gtk_sound_init(void)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 {
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
261 void *gtk_sound_handle = gaim_gtk_sound_get_handle();
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
262 void *blist_handle = gaim_blist_get_handle();
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
263 void *conv_handle = gaim_conversations_get_handle();
10320
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
264
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
265 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
266 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb),
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
267 NULL);
61852117568f [gaim-migrate @ 11527]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
268
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 gaim_prefs_add_none("/gaim/gtk/sound");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 gaim_prefs_add_none("/gaim/gtk/sound/enabled");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 gaim_prefs_add_none("/gaim/gtk/sound/file");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/login", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273 gaim_prefs_add_string("/gaim/gtk/sound/file/login", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/logout", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 gaim_prefs_add_string("/gaim/gtk/sound/file/logout", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/im_recv", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 gaim_prefs_add_string("/gaim/gtk/sound/file/im_recv", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/first_im_recv", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 gaim_prefs_add_string("/gaim/gtk/sound/file/first_im_recv", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_im", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 gaim_prefs_add_string("/gaim/gtk/sound/file/send_im", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/join_chat", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 gaim_prefs_add_string("/gaim/gtk/sound/file/join_chat", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/left_chat", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 gaim_prefs_add_string("/gaim/gtk/sound/file/left_chat", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_chat_msg", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 gaim_prefs_add_string("/gaim/gtk/sound/file/send_chat_msg", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/chat_msg_recv", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 gaim_prefs_add_string("/gaim/gtk/sound/file/chat_msg_recv", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/nick_said", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 gaim_prefs_add_string("/gaim/gtk/sound/file/nick_said", "");
7460
3973a09525b3 [gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
292 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE);
3973a09525b3 [gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
293 gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", "");
8633
f8292be3b45c [gaim-migrate @ 9385]
Mark Doliner <mark@kingant.net>
parents: 8632
diff changeset
294 gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE);
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
295 gaim_prefs_add_bool("/gaim/gtk/sound/mute", FALSE);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296 gaim_prefs_add_string("/gaim/gtk/sound/command", "");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic");
12815
a8bffa7fb6ac [gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents: 12411
diff changeset
298 gaim_prefs_add_int("/gaim/gtk/sound/volume", 50);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
300 #ifdef USE_GSTREAMER
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
301 gaim_debug_info("sound", "Initializing sound output drivers.\n");
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
302 gst_init(NULL, NULL);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
303 #endif /* USE_GSTREAMER */
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
304
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
305 gaim_signal_connect(blist_handle, "buddy-signed-on",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
306 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
307 GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
308 gaim_signal_connect(blist_handle, "buddy-signed-off",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
309 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
310 GINT_TO_POINTER(GAIM_SOUND_BUDDY_LEAVE));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
311 gaim_signal_connect(conv_handle, "received-im-msg",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
312 gtk_sound_handle, GAIM_CALLBACK(im_msg_received_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
313 GINT_TO_POINTER(GAIM_SOUND_RECEIVE));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
314 gaim_signal_connect(conv_handle, "sent-im-msg",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
315 gtk_sound_handle, GAIM_CALLBACK(im_msg_sent_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
316 GINT_TO_POINTER(GAIM_SOUND_SEND));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
317 gaim_signal_connect(conv_handle, "chat-buddy-joined",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
318 gtk_sound_handle, GAIM_CALLBACK(chat_buddy_join_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
319 GINT_TO_POINTER(GAIM_SOUND_CHAT_JOIN));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
320 gaim_signal_connect(conv_handle, "chat-buddy-left",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
321 gtk_sound_handle, GAIM_CALLBACK(chat_buddy_left_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
322 GINT_TO_POINTER(GAIM_SOUND_CHAT_LEAVE));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
323 gaim_signal_connect(conv_handle, "sent-chat-msg",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
324 gtk_sound_handle, GAIM_CALLBACK(chat_msg_sent_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
325 GINT_TO_POINTER(GAIM_SOUND_CHAT_YOU_SAY));
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
326 gaim_signal_connect(conv_handle, "received-chat-msg",
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
327 gtk_sound_handle, GAIM_CALLBACK(chat_msg_received_cb),
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
328 GINT_TO_POINTER(GAIM_SOUND_CHAT_SAY));
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
331 static void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
332 gaim_gtk_sound_uninit(void)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 {
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
334 #ifdef USE_GSTREAMER
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
335 gst_deinit();
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 #endif
11552
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
337
11d30825c1bb [gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents: 11463
diff changeset
338 gaim_signals_disconnect_by_handle(gaim_gtk_sound_get_handle());
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
341 #ifdef USE_GSTREAMER
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
342 static gboolean
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
343 expire_old_child(gpointer data)
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
344 {
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
345 int ret;
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
346 pid_t pid = GPOINTER_TO_INT(data);
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
347
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
348 ret = waitpid(pid, NULL, WNOHANG | WUNTRACED);
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
349
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
350 if(ret == 0) {
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
351 if(kill(pid, SIGKILL) < 0)
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
352 gaim_debug_error("gtksound", "Killing process %d failed (%s)\n",
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
353 pid, strerror(errno));
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
354 }
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
355
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
356 return FALSE; /* do not run again */
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
357 }
12815
a8bffa7fb6ac [gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents: 12411
diff changeset
358
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
359 static gboolean
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
360 bus_call (GstBus *bus,
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
361 GstMessage *msg,
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
362 gpointer data)
12815
a8bffa7fb6ac [gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents: 12411
diff changeset
363 {
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
364 GstElement *play = data;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
365 GError *err;
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
366
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
367 switch (GST_MESSAGE_TYPE (msg)) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
368 case GST_MESSAGE_EOS:
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
369 gst_element_set_state(play, GST_STATE_NULL);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
370 gst_object_unref(GST_OBJECT(play));
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
371 break;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
372 case GST_MESSAGE_ERROR:
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
373 gst_message_parse_error(msg, &err, NULL);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
374 gaim_debug_error("gstreamer", err->message);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
375 g_error_free(err);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
376 break;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
377 case GST_MESSAGE_WARNING:
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
378 gst_message_parse_warning(msg, &err, NULL);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
379 gaim_debug_warning("gstreamer", err->message);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
380 g_error_free(err);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
381 break;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
382 default:
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
383 break;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
384 }
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
385 return TRUE;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
386 }
12930
33935a6320b8 [gaim-migrate @ 15283]
Richard Laager <rlaager@wiktel.com>
parents: 12850
diff changeset
387 #endif
12815
a8bffa7fb6ac [gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents: 12411
diff changeset
388
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
389 static void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
390 gaim_gtk_sound_play_file(const char *filename)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 const char *method;
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
393 #ifdef USE_GSTREAMER
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
394 float volume;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
395 char *uri;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
396 GstElement *sink = NULL;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
397 GstElement *play = NULL;
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 #endif
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
400 if (gaim_prefs_get_bool("/gaim/gtk/sound/mute"))
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
402
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403 method = gaim_prefs_get_string("/gaim/gtk/sound/method");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
404
10074
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
405 if (!strcmp(method, "none")) {
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
406 return;
2e225cd35615 [gaim-migrate @ 11054]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
407 } else if (!strcmp(method, "beep")) {
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408 gdk_beep();
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
409 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen file (%s) does not exist."), filename);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
414 gaim_notify_error(NULL, NULL, tmp, NULL);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 g_free(tmp);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
418
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419 #ifndef _WIN32
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
420 if (!strcmp(method, "custom")) {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421 const char *sound_cmd;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
422 char *command;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
423 GError *error = NULL;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
424
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
425 sound_cmd = gaim_prefs_get_string("/gaim/gtk/sound/command");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
426
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
427 if (!sound_cmd || *sound_cmd == '\0') {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
428 gaim_notify_error(NULL, NULL,
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
429 _("Unable to play sound because the "
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
430 "'Command' sound method has been chosen, "
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
431 "but no command has been set."), NULL);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
432 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434
7464
a259e244e44f [gaim-migrate @ 8077]
Nathan Walp <nwalp@pidgin.im>
parents: 7460
diff changeset
435 if(strstr(sound_cmd, "%s"))
a259e244e44f [gaim-migrate @ 8077]
Nathan Walp <nwalp@pidgin.im>
parents: 7460
diff changeset
436 command = gaim_strreplace(sound_cmd, "%s", filename);
a259e244e44f [gaim-migrate @ 8077]
Nathan Walp <nwalp@pidgin.im>
parents: 7460
diff changeset
437 else
a259e244e44f [gaim-migrate @ 8077]
Nathan Walp <nwalp@pidgin.im>
parents: 7460
diff changeset
438 command = g_strdup_printf("%s %s", sound_cmd, filename);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
439
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
440 if(!g_spawn_command_line_async(command, &error)) {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
441 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
442 gaim_notify_error(NULL, NULL, tmp, NULL);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
443 g_free(tmp);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
444 g_error_free(error);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
445 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
446
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
447 g_free(command);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
448 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
449 }
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
450 #ifdef USE_GSTREAMER
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
451 volume = (float)(CLAMP(gaim_prefs_get_int("/gaim/gtk/sound/volume"),0,100)) / 50;
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
452 if (!strcmp(method, "automatic")) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
453 if (gaim_running_gnome()) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
454 sink = gst_element_factory_make("gconfaudiosink", "sink");
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
455 }
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
456 } else if (!strcmp(method, "esd")) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
457 sink = gst_element_factory_make("esdsink", "sink");
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
458 } else if (!strcmp(method, "arts")) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
459 sink = gst_element_factory_make("artssink", "sink");
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
460 } else if (!strcmp(method, "nas")) {
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
461 sink = gst_element_factory_make("nassink", "sink");
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
462 }
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
464 uri = g_strdup_printf("file://%s", filename);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
465 play = gst_element_factory_make("playbin", "play");
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
466
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
467 g_object_set(G_OBJECT(play), "uri", uri,
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
468 "volume", volume,
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
469 "audio-sink", sink, NULL);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
470
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
471 gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(play)),
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
472 bus_call, play);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
473 gst_element_set_state(play, GST_STATE_PLAYING);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
474
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
475 g_free(uri);
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
476
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
477 #else /* USE_GSTREAMER */
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
478 gdk_beep();
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
479 return;
13718
988186eb1688 [gaim-migrate @ 16127]
Sean Egan <seanegan@gmail.com>
parents: 13550
diff changeset
480 #endif /* USE_GSTREAMER */
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
481 #else /* _WIN32 */
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
482 gaim_debug_info("sound", "Playing %s\n", filename);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
483
10922
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
484 if (G_WIN32_HAVE_WIDECHAR_API ()) {
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
485 wchar_t *wc_filename = g_utf8_to_utf16(filename,
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
486 -1, NULL, NULL, NULL);
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
487 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
488 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n");
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
489 g_free(wc_filename);
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
490 } else {
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
491 char *l_filename = g_locale_from_utf8(filename,
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
492 -1, NULL, NULL, NULL);
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
493 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME))
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
494 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n");
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
495 g_free(l_filename);
68083504217c [gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10322
diff changeset
496 }
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
497 #endif /* _WIN32 */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
498 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
499
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
500 static void
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
501 gaim_gtk_sound_play_event(GaimSoundEventID event)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502 {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503 char *enable_pref;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504 char *file_pref;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
505
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
506 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
507 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
508
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
509 if (event >= GAIM_NUM_SOUNDS) {
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
510 gaim_debug_error("sound", "got request for unknown sound: %d\n", event);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
511 return;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
512 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
513
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
514 enable_pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s",
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
515 sounds[event].pref);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
516 file_pref = g_strdup_printf("/gaim/gtk/sound/file/%s", sounds[event].pref);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
517
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
518 /* check NULL for sounds that don't have an option, ie buddy pounce */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
519 if (gaim_prefs_get_bool(enable_pref)) {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
520 char *filename = g_strdup(gaim_prefs_get_string(file_pref));
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
521 if(!filename || !strlen(filename)) {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
522 if(filename) g_free(filename);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
523 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
525
11642
58bc500cf226 [gaim-migrate @ 13919]
Mark Doliner <mark@kingant.net>
parents: 11581
diff changeset
526 gaim_sound_play_file(filename, NULL);
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
527 g_free(filename);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
528 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
529
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
530 g_free(enable_pref);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
531 g_free(file_pref);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
532 }
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
534 static GaimSoundUiOps sound_ui_ops =
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
535 {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
536 gaim_gtk_sound_init,
10322
2a132b73a6e6 [gaim-migrate @ 11529]
Mark Doliner <mark@kingant.net>
parents: 10320
diff changeset
537 gaim_gtk_sound_uninit,
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 gaim_gtk_sound_play_file,
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539 gaim_gtk_sound_play_event
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 };
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6778
diff changeset
542 GaimSoundUiOps *
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6778
diff changeset
543 gaim_gtk_sound_get_ui_ops(void)
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
544 {
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
545 return &sound_ui_ops;
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
546 }