Mercurial > pidgin
annotate src/gtksound.c @ 11637:cedd48571c90
[gaim-migrate @ 13913]
Forgot to commit this, sorry
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 10 Oct 2005 12:29:30 +0000 |
parents | 9b3833da6840 |
children | 58bc500cf226 |
rev | line source |
---|---|
5684 | 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 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5684 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5684 | 28 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
29 #ifdef _WIN32 |
5684 | 30 #include <windows.h> |
31 #include <mmsystem.h> | |
32 #endif | |
33 | |
34 #ifdef USE_AO | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 # include <ao/ao.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
36 # include <audiofile.h> |
5684 | 37 #endif /* USE_AO */ |
38 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
39 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
40 #include "notify.h" |
5684 | 41 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
42 #include "sound.h" |
7465 | 43 #include "util.h" |
5684 | 44 |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
45 #include "gtkconv.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
46 #include "gtksound.h" |
5684 | 47 |
48 struct gaim_sound_event { | |
49 char *label; | |
50 char *pref; | |
51 char *def; | |
52 }; | |
53 | |
10074 | 54 #define PLAY_SOUND_TIMEOUT 15000 |
5684 | 55 |
10320 | 56 static guint mute_login_sounds_timeout = 0; |
5684 | 57 static gboolean mute_login_sounds = FALSE; |
6199 | 58 static gboolean sound_initialized = FALSE; |
5684 | 59 |
60 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { | |
10158 | 61 {N_("Buddy logs in"), "login", "login.wav"}, |
62 {N_("Buddy logs out"), "logout", "logout.wav"}, | |
5684 | 63 {N_("Message received"), "im_recv", "receive.wav"}, |
64 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
65 {N_("Message sent"), "send_im", "send.wav"}, | |
10158 | 66 {N_("Person enters chat"), "join_chat", "login.wav"}, |
67 {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
5684 | 68 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
69 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
70 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
10158 | 71 {NULL, "pounce_default", "alert.wav"}, |
72 {N_("Someone says your name in chat"), "nick_said", "alert.wav"} | |
5684 | 73 }; |
74 | |
75 #ifdef USE_AO | |
76 static int ao_driver = -1; | |
77 #endif /* USE_AO */ | |
78 | |
10320 | 79 static gboolean |
11463 | 80 unmute_login_sounds_cb(gpointer data) |
10320 | 81 { |
82 mute_login_sounds = FALSE; | |
83 mute_login_sounds_timeout = 0; | |
84 return FALSE; | |
85 } | |
86 | |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
87 static gboolean |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
88 chat_nick_matches_name(GaimConversation *conv, const char *aname) |
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 GaimConvChat *chat = NULL; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
91 char *nick = NULL; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
92 char *name = NULL; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
93 gboolean ret = FALSE; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
94 chat = gaim_conversation_get_chat_data(conv); |
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 (chat==NULL) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
97 return ret; |
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 nick = g_strdup(gaim_normalize(conv->account, chat->nick)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
100 name = g_strdup(gaim_normalize(conv->account, aname)); |
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 if (g_utf8_collate(nick, name) == 0) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
103 ret = TRUE; |
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 g_free(nick); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
106 g_free(name); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
107 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
108 return ret; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
109 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
110 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
111 /* |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
112 * play a sound event for a conversation, honoring make_sound flag |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
113 * 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
|
114 */ |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
115 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
116 play_conv_event(GaimConversation *conv, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
117 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
118 GaimGtkConversation *gtkconv; |
11581 | 119 GaimGtkWindow *win; |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
120 gboolean has_focus; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
121 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
122 if (conv==NULL) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
123 gaim_sound_play_event(event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
124 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
125 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 126 win = gtkconv->win; |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
127 |
11581 | 128 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
129 &has_focus, NULL); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
130 |
11581 | 131 if (gtkconv->make_sound && |
132 !((gaim_gtk_conv_window_get_active_conversation(win) == conv) && | |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
133 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
134 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
135 gaim_sound_play_event(event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
136 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
137 } |
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 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
140 buddy_state_cb(GaimBuddy *buddy, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
141 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
142 gaim_sound_play_event(event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
143 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
144 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
145 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
146 im_msg_received_cb(GaimAccount *account, char *sender, |
11581 | 147 char *message, GaimConversation *conv, |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
148 int flags, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
149 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
150 if (conv==NULL) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
151 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
152 else |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
153 play_conv_event(conv, event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
154 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
155 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
156 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
157 im_msg_sent_cb(GaimAccount *account, const char *receiver, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
158 const char *message, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
159 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
160 GaimConversation *conv = gaim_find_conversation_with_account( |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
161 GAIM_CONV_TYPE_ANY, receiver, account); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
162 play_conv_event(conv, event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
163 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
164 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
165 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
166 chat_buddy_join_cb(GaimConversation *conv, const char *name, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
167 GaimConvChatBuddyFlags flags, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
168 { |
11581 | 169 if (!chat_nick_matches_name(conv, name)) |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
170 play_conv_event(conv, event); |
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 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
173 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
174 chat_buddy_left_cb(GaimConversation *conv, const char *name, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
175 const char *reason, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
176 { |
11581 | 177 if (!chat_nick_matches_name(conv, name)) |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
178 play_conv_event(conv, event); |
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 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
181 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
182 chat_msg_sent_cb(GaimAccount *account, const char *message, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
183 int id, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
184 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
185 GaimConnection *conn = gaim_account_get_connection(account); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
186 GaimConversation *conv = NULL; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
187 |
11581 | 188 if (conn!=NULL) |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
189 conv = gaim_find_chat(conn,id); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
190 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
191 play_conv_event(conv, event); |
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 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
194 static void |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
195 chat_msg_received_cb(GaimAccount *account, char *sender, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
196 char *message, GaimConversation *conv, |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
197 int flags, GaimSoundEventID event) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
198 { |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
199 GaimConvChat *chat; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
200 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
201 chat = gaim_conversation_get_chat_data(conv); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
202 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
203 if (chat!=NULL && gaim_conv_chat_is_user_ignored(chat, sender)) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
204 return; |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
205 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
206 if (chat_nick_matches_name(conv, sender)) |
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 (flags & GAIM_CONV_CHAT_ALERT || gaim_utf8_has_word(message, chat->nick)) |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
210 play_conv_event(conv, GAIM_SOUND_CHAT_NICK); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
211 else |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
212 play_conv_event(conv, event); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
213 } |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
214 |
10320 | 215 /* |
216 * We mute sounds for the 10 seconds after you log in so that | |
217 * you don't get flooded with sounds when the blist shows all | |
218 * your buddies logging in. | |
219 */ | |
220 static void | |
221 account_signon_cb(GaimConnection *gc, gpointer data) | |
222 { | |
223 if (mute_login_sounds_timeout != 0) | |
224 g_source_remove(mute_login_sounds_timeout); | |
225 mute_login_sounds = TRUE; | |
11463 | 226 mute_login_sounds_timeout = gaim_timeout_add(10000, unmute_login_sounds_cb, NULL); |
10320 | 227 } |
228 | |
10322 | 229 static void |
230 _pref_sound_method_changed(const char *name, GaimPrefType type, | |
231 gpointer val, gpointer data) { | |
232 if(type != GAIM_PREF_STRING || strcmp(name, "/gaim/gtk/sound/method")) | |
233 return; | |
234 | |
235 sound_initialized = TRUE; | |
236 | |
237 #ifdef USE_AO | |
238 ao_driver = -1; | |
239 | |
240 if(!strcmp(val, "esd")) | |
241 ao_driver = ao_driver_id("esd"); | |
242 else if(!strcmp(val, "arts")) | |
243 ao_driver = ao_driver_id("arts"); | |
11082 | 244 else if(!strcmp(val, "nas")) |
245 ao_driver = ao_driver_id("nas"); | |
10322 | 246 else if(!strcmp(val, "automatic")) |
247 ao_driver = ao_default_driver_id(); | |
248 | |
249 if(ao_driver != -1) { | |
250 ao_info *info = ao_driver_info(ao_driver); | |
251 gaim_debug_info("sound", | |
252 "Sound output driver loaded: %s\n", info->name); | |
253 } | |
254 #endif /* USE_AO */ | |
255 } | |
256 | |
257 const char * | |
258 gaim_gtk_sound_get_event_option(GaimSoundEventID event) | |
259 { | |
260 if(event >= GAIM_NUM_SOUNDS) | |
261 return 0; | |
262 | |
263 return sounds[event].pref; | |
264 } | |
265 | |
266 char * | |
267 gaim_gtk_sound_get_event_label(GaimSoundEventID event) | |
268 { | |
269 if(event >= GAIM_NUM_SOUNDS) | |
270 return NULL; | |
271 | |
272 return sounds[event].label; | |
273 } | |
274 | |
275 void * | |
276 gaim_gtk_sound_get_handle() | |
277 { | |
278 static int handle; | |
279 | |
280 return &handle; | |
281 } | |
282 | |
283 static void | |
284 gaim_gtk_sound_init(void) | |
5684 | 285 { |
10320 | 286 void *gtk_sound_handle = gaim_gtk_sound_get_handle(); |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
287 void *blist_handle = gaim_blist_get_handle(); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
288 void *conv_handle = gaim_conversations_get_handle(); |
10320 | 289 |
290 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
291 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb), | |
292 NULL); | |
293 | |
5684 | 294 gaim_prefs_add_none("/gaim/gtk/sound"); |
295 gaim_prefs_add_none("/gaim/gtk/sound/enabled"); | |
296 gaim_prefs_add_none("/gaim/gtk/sound/file"); | |
297 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/login", TRUE); | |
298 gaim_prefs_add_string("/gaim/gtk/sound/file/login", ""); | |
299 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/logout", TRUE); | |
300 gaim_prefs_add_string("/gaim/gtk/sound/file/logout", ""); | |
301 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/im_recv", TRUE); | |
302 gaim_prefs_add_string("/gaim/gtk/sound/file/im_recv", ""); | |
303 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/first_im_recv", FALSE); | |
304 gaim_prefs_add_string("/gaim/gtk/sound/file/first_im_recv", ""); | |
305 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_im", TRUE); | |
306 gaim_prefs_add_string("/gaim/gtk/sound/file/send_im", ""); | |
307 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/join_chat", FALSE); | |
308 gaim_prefs_add_string("/gaim/gtk/sound/file/join_chat", ""); | |
309 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/left_chat", FALSE); | |
310 gaim_prefs_add_string("/gaim/gtk/sound/file/left_chat", ""); | |
311 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_chat_msg", FALSE); | |
312 gaim_prefs_add_string("/gaim/gtk/sound/file/send_chat_msg", ""); | |
313 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/chat_msg_recv", FALSE); | |
314 gaim_prefs_add_string("/gaim/gtk/sound/file/chat_msg_recv", ""); | |
315 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/nick_said", FALSE); | |
316 gaim_prefs_add_string("/gaim/gtk/sound/file/nick_said", ""); | |
7460
3973a09525b3
[gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
317 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE); |
3973a09525b3
[gaim-migrate @ 8073]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
318 gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", ""); |
8633 | 319 gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE); |
10074 | 320 gaim_prefs_add_bool("/gaim/gtk/sound/mute", FALSE); |
5684 | 321 gaim_prefs_add_string("/gaim/gtk/sound/command", ""); |
322 gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic"); | |
323 | |
324 #ifdef USE_AO | |
10322 | 325 gaim_debug_info("sound", "Initializing sound output drivers.\n"); |
5684 | 326 ao_initialize(); |
327 #endif /* USE_AO */ | |
328 | |
10087 | 329 gaim_prefs_connect_callback(gaim_gtk_sound_get_handle(), "/gaim/gtk/sound/method", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
330 _pref_sound_method_changed, NULL); |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
331 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
332 gaim_signal_connect(blist_handle, "buddy-signed-on", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
333 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
334 GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
335 gaim_signal_connect(blist_handle, "buddy-signed-off", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
336 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
337 GINT_TO_POINTER(GAIM_SOUND_BUDDY_LEAVE)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
338 gaim_signal_connect(conv_handle, "received-im-msg", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
339 gtk_sound_handle, GAIM_CALLBACK(im_msg_received_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
340 GINT_TO_POINTER(GAIM_SOUND_RECEIVE)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
341 gaim_signal_connect(conv_handle, "sent-im-msg", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
342 gtk_sound_handle, GAIM_CALLBACK(im_msg_sent_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
343 GINT_TO_POINTER(GAIM_SOUND_SEND)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
344 gaim_signal_connect(conv_handle, "chat-buddy-joined", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
345 gtk_sound_handle, GAIM_CALLBACK(chat_buddy_join_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
346 GINT_TO_POINTER(GAIM_SOUND_CHAT_JOIN)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
347 gaim_signal_connect(conv_handle, "chat-buddy-left", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
348 gtk_sound_handle, GAIM_CALLBACK(chat_buddy_left_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
349 GINT_TO_POINTER(GAIM_SOUND_CHAT_LEAVE)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
350 gaim_signal_connect(conv_handle, "sent-chat-msg", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
351 gtk_sound_handle, GAIM_CALLBACK(chat_msg_sent_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
352 GINT_TO_POINTER(GAIM_SOUND_CHAT_YOU_SAY)); |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
353 gaim_signal_connect(conv_handle, "received-chat-msg", |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
354 gtk_sound_handle, GAIM_CALLBACK(chat_msg_received_cb), |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
355 GINT_TO_POINTER(GAIM_SOUND_CHAT_SAY)); |
5684 | 356 } |
357 | |
10322 | 358 static void |
359 gaim_gtk_sound_uninit(void) | |
5684 | 360 { |
361 #ifdef USE_AO | |
362 ao_shutdown(); | |
363 #endif | |
6199 | 364 sound_initialized = FALSE; |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
365 |
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
366 gaim_signals_disconnect_by_handle(gaim_gtk_sound_get_handle()); |
5684 | 367 } |
368 | |
11463 | 369 #ifdef USE_AO |
10322 | 370 static gboolean |
371 expire_old_child(gpointer data) | |
10074 | 372 { |
373 int ret; | |
374 pid_t pid = GPOINTER_TO_INT(data); | |
375 | |
376 ret = waitpid(pid, NULL, WNOHANG | WUNTRACED); | |
377 | |
378 if(ret == 0) { | |
379 if(kill(pid, SIGKILL) < 0) | |
10322 | 380 gaim_debug_error("gtksound", "Killing process %d failed (%s)\n", |
381 pid, strerror(errno)); | |
10074 | 382 } |
383 | |
384 return FALSE; /* do not run again */ | |
385 } | |
386 #endif | |
387 | |
10322 | 388 static void |
389 gaim_gtk_sound_play_file(const char *filename) | |
5684 | 390 { |
391 const char *method; | |
11463 | 392 #ifdef USE_AO |
5684 | 393 pid_t pid; |
394 AFfilehandle file; | |
395 #endif | |
396 | |
6199 | 397 if (!sound_initialized) |
398 gaim_prefs_trigger_callback("/gaim/gtk/sound/method"); | |
399 | |
10074 | 400 if (gaim_prefs_get_bool("/gaim/gtk/sound/mute")) |
5684 | 401 return; |
402 | |
403 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); | |
404 | |
10074 | 405 if (!strcmp(method, "none")) { |
406 return; | |
407 } else if (!strcmp(method, "beep")) { | |
5684 | 408 gdk_beep(); |
409 return; | |
410 } | |
411 | |
412 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
413 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen file (%s) does not exist."), filename); | |
414 gaim_notify_error(NULL, NULL, tmp, NULL); | |
415 g_free(tmp); | |
416 return; | |
417 } | |
418 | |
419 #ifndef _WIN32 | |
420 if (!strcmp(method, "custom")) { | |
421 const char *sound_cmd; | |
422 char *command; | |
423 GError *error = NULL; | |
424 | |
425 sound_cmd = gaim_prefs_get_string("/gaim/gtk/sound/command"); | |
426 | |
427 if (!sound_cmd || *sound_cmd == '\0') { | |
428 gaim_notify_error(NULL, NULL, | |
429 _("Unable to play sound because the " | |
430 "'Command' sound method has been chosen, " | |
431 "but no command has been set."), NULL); | |
432 return; | |
433 } | |
434 | |
7464 | 435 if(strstr(sound_cmd, "%s")) |
436 command = gaim_strreplace(sound_cmd, "%s", filename); | |
437 else | |
438 command = g_strdup_printf("%s %s", sound_cmd, filename); | |
5684 | 439 |
440 if(!g_spawn_command_line_async(command, &error)) { | |
441 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message); | |
442 gaim_notify_error(NULL, NULL, tmp, NULL); | |
443 g_free(tmp); | |
444 g_error_free(error); | |
445 } | |
446 | |
447 g_free(command); | |
448 return; | |
449 } | |
11463 | 450 #ifdef USE_AO |
5684 | 451 pid = fork(); |
452 if (pid < 0) | |
453 return; | |
454 else if (pid == 0) { | |
11463 | 455 /* Child process */ |
5684 | 456 file = afOpenFile(filename, "rb", NULL); |
457 if(file) { | |
458 ao_device *device; | |
459 ao_sample_format format; | |
460 int in_fmt; | |
461 int bytes_per_frame; | |
462 | |
463 format.rate = afGetRate(file, AF_DEFAULT_TRACK); | |
464 format.channels = afGetChannels(file, AF_DEFAULT_TRACK); | |
465 afGetSampleFormat(file, AF_DEFAULT_TRACK, &in_fmt, | |
466 &format.bits); | |
467 | |
468 /* XXX: libao doesn't seem to like 8-bit sounds, so we'll | |
469 * let libaudiofile make them a bit better for us */ | |
470 if(format.bits == 8) | |
471 format.bits = 16; | |
472 | |
473 afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, | |
474 AF_SAMPFMT_TWOSCOMP, format.bits); | |
475 | |
476 #if __BYTE_ORDER == __BIG_ENDIAN | |
477 format.byte_format = AO_FMT_BIG; | |
478 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
479 AF_BYTEORDER_BIGENDIAN); | |
480 #elif __BYTE_ORDER == __LITTLE_ENDIAN | |
481 format.byte_format = AO_FMT_LITTLE; | |
482 afSetVirtualByteOrder(file, AF_DEFAULT_TRACK, | |
483 AF_BYTEORDER_LITTLEENDIAN); | |
484 #endif | |
485 | |
486 bytes_per_frame = format.bits * format.channels / 8; | |
487 | |
488 device = ao_open_live(ao_driver, &format, NULL); | |
489 | |
490 if(device) { | |
491 int frames_read; | |
492 char buf[4096]; | |
493 int buf_frames = sizeof(buf) / bytes_per_frame; | |
494 | |
495 while((frames_read = afReadFrames(file, AF_DEFAULT_TRACK, | |
496 buf, buf_frames))) { | |
497 if(!ao_play(device, buf, frames_read * bytes_per_frame)) | |
498 break; | |
499 } | |
500 ao_close(device); | |
501 } | |
502 afCloseFile(file); | |
503 } | |
504 ao_shutdown(); | |
505 _exit(0); | |
10074 | 506 } else { |
11463 | 507 /* Parent process */ |
10074 | 508 gaim_timeout_add(PLAY_SOUND_TIMEOUT, expire_old_child, GINT_TO_POINTER(pid)); |
5684 | 509 } |
11082 | 510 #else /* USE_AO */ |
5684 | 511 gdk_beep(); |
512 return; | |
11082 | 513 #endif /* USE_AO */ |
5684 | 514 #else /* _WIN32 */ |
10322 | 515 gaim_debug_info("sound", "Playing %s\n", filename); |
5684 | 516 |
10922
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
517 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
518 wchar_t *wc_filename = g_utf8_to_utf16(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
519 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
520 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
521 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
522 g_free(wc_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
523 } else { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
524 char *l_filename = g_locale_from_utf8(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
525 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
526 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
527 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
528 g_free(l_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
529 } |
5684 | 530 #endif /* _WIN32 */ |
531 } | |
532 | |
10322 | 533 static void |
534 gaim_gtk_sound_play_event(GaimSoundEventID event) | |
5684 | 535 { |
536 char *enable_pref; | |
537 char *file_pref; | |
538 | |
539 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
540 return; | |
541 | |
542 if (event >= GAIM_NUM_SOUNDS) { | |
10322 | 543 gaim_debug_error("sound", "got request for unknown sound: %d\n", event); |
5684 | 544 return; |
545 } | |
546 | |
547 enable_pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", | |
548 sounds[event].pref); | |
549 file_pref = g_strdup_printf("/gaim/gtk/sound/file/%s", sounds[event].pref); | |
550 | |
551 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
552 if (gaim_prefs_get_bool(enable_pref)) { | |
553 char *filename = g_strdup(gaim_prefs_get_string(file_pref)); | |
554 if(!filename || !strlen(filename)) { | |
555 if(filename) g_free(filename); | |
556 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); | |
557 } | |
558 | |
559 gaim_sound_play_file(filename); | |
560 g_free(filename); | |
561 } | |
562 | |
563 g_free(enable_pref); | |
564 g_free(file_pref); | |
565 } | |
566 | |
567 static GaimSoundUiOps sound_ui_ops = | |
568 { | |
569 gaim_gtk_sound_init, | |
10322 | 570 gaim_gtk_sound_uninit, |
5684 | 571 gaim_gtk_sound_play_file, |
572 gaim_gtk_sound_play_event | |
573 }; | |
574 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
575 GaimSoundUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
576 gaim_gtk_sound_get_ui_ops(void) |
5684 | 577 { |
578 return &sound_ui_ops; | |
579 } |