Mercurial > pidgin
annotate src/gtksound.c @ 13967:99b9b58b19dd
[gaim-migrate @ 16523]
Fix a crazy MSN crash. Basically it's possible to have more than one
slplink associated with a given switchboard, but our code did not
allow for that. I think it happens when you're in a multi-user
chat and you do stuff with multiple users that involves slplinks.
Like maybe file transfer and buddy icon related stuff.
Tracking this down took an ungodly amount of time, but thanks to
Meebo for letting me do it :-)
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 20 Jul 2006 07:31:15 +0000 |
parents | d0128f0efe96 |
children | 8bda65b88e49 |
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 | |
13718 | 34 #ifdef USE_GSTREAMER |
35 # include <gst/gst.h> | |
36 #endif /* USE_GSTREAMER */ | |
5684 | 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 | 40 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
41 #include "sound.h" |
7465 | 42 #include "util.h" |
5684 | 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 | 46 |
47 struct gaim_sound_event { | |
48 char *label; | |
49 char *pref; | |
50 char *def; | |
51 }; | |
52 | |
10074 | 53 #define PLAY_SOUND_TIMEOUT 15000 |
5684 | 54 |
10320 | 55 static guint mute_login_sounds_timeout = 0; |
5684 | 56 static gboolean mute_login_sounds = FALSE; |
57 | |
58 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { | |
10158 | 59 {N_("Buddy logs in"), "login", "login.wav"}, |
60 {N_("Buddy logs out"), "logout", "logout.wav"}, | |
5684 | 61 {N_("Message received"), "im_recv", "receive.wav"}, |
62 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
63 {N_("Message sent"), "send_im", "send.wav"}, | |
10158 | 64 {N_("Person enters chat"), "join_chat", "login.wav"}, |
65 {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
5684 | 66 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
67 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
68 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
10158 | 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 | 71 }; |
72 | |
10320 | 73 static gboolean |
11463 | 74 unmute_login_sounds_cb(gpointer data) |
10320 | 75 { |
76 mute_login_sounds = FALSE; | |
77 mute_login_sounds_timeout = 0; | |
78 return FALSE; | |
79 } | |
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 | 112 /* If we should not play the sound for some reason, then exit early */ |
113 if (conv != NULL) | |
114 { | |
115 GaimGtkConversation *gtkconv; | |
116 GaimGtkWindow *win; | |
117 gboolean has_focus; | |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
118 |
11642 | 119 gtkconv = GAIM_GTK_CONVERSATION(conv); |
120 win = gtkconv->win; | |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
121 |
11642 | 122 has_focus = gaim_conversation_has_focus(conv); |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
123 |
11642 | 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 | 126 { |
127 return; | |
128 } | |
129 } | |
11552
11d30825c1bb
[gaim-migrate @ 13812]
Gary Kramlich <grim@reaperworld.com>
parents:
11463
diff
changeset
|
130 |
11642 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 218 /* |
219 * We mute sounds for the 10 seconds after you log in so that | |
220 * you don't get flooded with sounds when the blist shows all | |
221 * your buddies logging in. | |
222 */ | |
223 static void | |
224 account_signon_cb(GaimConnection *gc, gpointer data) | |
225 { | |
226 if (mute_login_sounds_timeout != 0) | |
227 g_source_remove(mute_login_sounds_timeout); | |
228 mute_login_sounds = TRUE; | |
11463 | 229 mute_login_sounds_timeout = gaim_timeout_add(10000, unmute_login_sounds_cb, NULL); |
10320 | 230 } |
231 | |
10322 | 232 const char * |
233 gaim_gtk_sound_get_event_option(GaimSoundEventID event) | |
234 { | |
235 if(event >= GAIM_NUM_SOUNDS) | |
236 return 0; | |
237 | |
238 return sounds[event].pref; | |
239 } | |
240 | |
241 char * | |
242 gaim_gtk_sound_get_event_label(GaimSoundEventID event) | |
243 { | |
244 if(event >= GAIM_NUM_SOUNDS) | |
245 return NULL; | |
246 | |
247 return sounds[event].label; | |
248 } | |
249 | |
250 void * | |
251 gaim_gtk_sound_get_handle() | |
252 { | |
253 static int handle; | |
254 | |
255 return &handle; | |
256 } | |
257 | |
258 static void | |
259 gaim_gtk_sound_init(void) | |
5684 | 260 { |
10320 | 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 | 264 |
265 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
266 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb), | |
267 NULL); | |
268 | |
5684 | 269 gaim_prefs_add_none("/gaim/gtk/sound"); |
270 gaim_prefs_add_none("/gaim/gtk/sound/enabled"); | |
271 gaim_prefs_add_none("/gaim/gtk/sound/file"); | |
272 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/login", TRUE); | |
273 gaim_prefs_add_string("/gaim/gtk/sound/file/login", ""); | |
274 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/logout", TRUE); | |
275 gaim_prefs_add_string("/gaim/gtk/sound/file/logout", ""); | |
276 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/im_recv", TRUE); | |
277 gaim_prefs_add_string("/gaim/gtk/sound/file/im_recv", ""); | |
278 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/first_im_recv", FALSE); | |
279 gaim_prefs_add_string("/gaim/gtk/sound/file/first_im_recv", ""); | |
280 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_im", TRUE); | |
281 gaim_prefs_add_string("/gaim/gtk/sound/file/send_im", ""); | |
282 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/join_chat", FALSE); | |
283 gaim_prefs_add_string("/gaim/gtk/sound/file/join_chat", ""); | |
284 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/left_chat", FALSE); | |
285 gaim_prefs_add_string("/gaim/gtk/sound/file/left_chat", ""); | |
286 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/send_chat_msg", FALSE); | |
287 gaim_prefs_add_string("/gaim/gtk/sound/file/send_chat_msg", ""); | |
288 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/chat_msg_recv", FALSE); | |
289 gaim_prefs_add_string("/gaim/gtk/sound/file/chat_msg_recv", ""); | |
290 gaim_prefs_add_bool("/gaim/gtk/sound/enabled/nick_said", FALSE); | |
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 | 294 gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE); |
10074 | 295 gaim_prefs_add_bool("/gaim/gtk/sound/mute", FALSE); |
5684 | 296 gaim_prefs_add_string("/gaim/gtk/sound/command", ""); |
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 | 299 |
13718 | 300 #ifdef USE_GSTREAMER |
10322 | 301 gaim_debug_info("sound", "Initializing sound output drivers.\n"); |
13718 | 302 gst_init(NULL, NULL); |
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 | 329 } |
330 | |
10322 | 331 static void |
332 gaim_gtk_sound_uninit(void) | |
5684 | 333 { |
13718 | 334 #ifdef USE_GSTREAMER |
335 gst_deinit(); | |
5684 | 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 | 339 } |
340 | |
13718 | 341 #ifdef USE_GSTREAMER |
10322 | 342 static gboolean |
13718 | 343 bus_call (GstBus *bus, |
344 GstMessage *msg, | |
345 gpointer data) | |
12815
a8bffa7fb6ac
[gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents:
12411
diff
changeset
|
346 { |
13718 | 347 GstElement *play = data; |
348 GError *err; | |
10074 | 349 |
13718 | 350 switch (GST_MESSAGE_TYPE (msg)) { |
351 case GST_MESSAGE_EOS: | |
352 gst_element_set_state(play, GST_STATE_NULL); | |
353 gst_object_unref(GST_OBJECT(play)); | |
354 break; | |
355 case GST_MESSAGE_ERROR: | |
356 gst_message_parse_error(msg, &err, NULL); | |
357 gaim_debug_error("gstreamer", err->message); | |
358 g_error_free(err); | |
359 break; | |
360 case GST_MESSAGE_WARNING: | |
361 gst_message_parse_warning(msg, &err, NULL); | |
362 gaim_debug_warning("gstreamer", err->message); | |
363 g_error_free(err); | |
364 break; | |
365 default: | |
366 break; | |
367 } | |
368 return TRUE; | |
369 } | |
12930
33935a6320b8
[gaim-migrate @ 15283]
Richard Laager <rlaager@wiktel.com>
parents:
12850
diff
changeset
|
370 #endif |
12815
a8bffa7fb6ac
[gaim-migrate @ 15163]
Richard Laager <rlaager@wiktel.com>
parents:
12411
diff
changeset
|
371 |
10322 | 372 static void |
373 gaim_gtk_sound_play_file(const char *filename) | |
5684 | 374 { |
375 const char *method; | |
13718 | 376 #ifdef USE_GSTREAMER |
377 float volume; | |
378 char *uri; | |
379 GstElement *sink = NULL; | |
380 GstElement *play = NULL; | |
5684 | 381 #endif |
382 | |
10074 | 383 if (gaim_prefs_get_bool("/gaim/gtk/sound/mute")) |
5684 | 384 return; |
385 | |
386 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); | |
387 | |
10074 | 388 if (!strcmp(method, "none")) { |
389 return; | |
390 } else if (!strcmp(method, "beep")) { | |
5684 | 391 gdk_beep(); |
392 return; | |
393 } | |
394 | |
13795 | 395 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
13797
d0128f0efe96
[gaim-migrate @ 16209]
Richard Laager <rlaager@wiktel.com>
parents:
13795
diff
changeset
|
396 gaim_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); |
5684 | 397 return; |
13795 | 398 } |
5684 | 399 |
400 #ifndef _WIN32 | |
401 if (!strcmp(method, "custom")) { | |
402 const char *sound_cmd; | |
403 char *command; | |
404 GError *error = NULL; | |
405 | |
406 sound_cmd = gaim_prefs_get_string("/gaim/gtk/sound/command"); | |
407 | |
408 if (!sound_cmd || *sound_cmd == '\0') { | |
13795 | 409 gaim_debug_error("gtksound", |
410 "'Command' sound method has been chosen, " | |
411 "but no command has been set."); | |
5684 | 412 return; |
413 } | |
414 | |
7464 | 415 if(strstr(sound_cmd, "%s")) |
416 command = gaim_strreplace(sound_cmd, "%s", filename); | |
417 else | |
418 command = g_strdup_printf("%s %s", sound_cmd, filename); | |
5684 | 419 |
420 if(!g_spawn_command_line_async(command, &error)) { | |
13795 | 421 char *tmp = g_strdup_printf("sound command could not be launched: %s\n", error->message); |
422 gaim_debug_error("gtksound", tmp); | |
5684 | 423 g_free(tmp); |
424 g_error_free(error); | |
425 } | |
426 | |
427 g_free(command); | |
428 return; | |
429 } | |
13718 | 430 #ifdef USE_GSTREAMER |
431 volume = (float)(CLAMP(gaim_prefs_get_int("/gaim/gtk/sound/volume"),0,100)) / 50; | |
432 if (!strcmp(method, "automatic")) { | |
433 if (gaim_running_gnome()) { | |
434 sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
435 } | |
436 } else if (!strcmp(method, "esd")) { | |
437 sink = gst_element_factory_make("esdsink", "sink"); | |
438 } else if (!strcmp(method, "arts")) { | |
439 sink = gst_element_factory_make("artssink", "sink"); | |
440 } else if (!strcmp(method, "nas")) { | |
441 sink = gst_element_factory_make("nassink", "sink"); | |
442 } | |
5684 | 443 |
13718 | 444 uri = g_strdup_printf("file://%s", filename); |
445 play = gst_element_factory_make("playbin", "play"); | |
446 | |
447 g_object_set(G_OBJECT(play), "uri", uri, | |
448 "volume", volume, | |
449 "audio-sink", sink, NULL); | |
5684 | 450 |
13718 | 451 gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(play)), |
452 bus_call, play); | |
453 gst_element_set_state(play, GST_STATE_PLAYING); | |
454 | |
455 g_free(uri); | |
456 | |
457 #else /* USE_GSTREAMER */ | |
5684 | 458 gdk_beep(); |
459 return; | |
13718 | 460 #endif /* USE_GSTREAMER */ |
5684 | 461 #else /* _WIN32 */ |
10322 | 462 gaim_debug_info("sound", "Playing %s\n", filename); |
5684 | 463 |
10922
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
464 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
465 wchar_t *wc_filename = g_utf8_to_utf16(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
466 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
467 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
468 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
469 g_free(wc_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
470 } else { |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
471 char *l_filename = g_locale_from_utf8(filename, |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
472 -1, NULL, NULL, NULL); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
473 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
474 gaim_debug(GAIM_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
475 g_free(l_filename); |
68083504217c
[gaim-migrate @ 12691]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10322
diff
changeset
|
476 } |
5684 | 477 #endif /* _WIN32 */ |
478 } | |
479 | |
10322 | 480 static void |
481 gaim_gtk_sound_play_event(GaimSoundEventID event) | |
5684 | 482 { |
483 char *enable_pref; | |
484 char *file_pref; | |
485 | |
486 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
487 return; | |
488 | |
489 if (event >= GAIM_NUM_SOUNDS) { | |
10322 | 490 gaim_debug_error("sound", "got request for unknown sound: %d\n", event); |
5684 | 491 return; |
492 } | |
493 | |
494 enable_pref = g_strdup_printf("/gaim/gtk/sound/enabled/%s", | |
495 sounds[event].pref); | |
496 file_pref = g_strdup_printf("/gaim/gtk/sound/file/%s", sounds[event].pref); | |
497 | |
498 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
499 if (gaim_prefs_get_bool(enable_pref)) { | |
500 char *filename = g_strdup(gaim_prefs_get_string(file_pref)); | |
501 if(!filename || !strlen(filename)) { | |
502 if(filename) g_free(filename); | |
503 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); | |
504 } | |
505 | |
11642 | 506 gaim_sound_play_file(filename, NULL); |
5684 | 507 g_free(filename); |
508 } | |
509 | |
510 g_free(enable_pref); | |
511 g_free(file_pref); | |
512 } | |
513 | |
514 static GaimSoundUiOps sound_ui_ops = | |
515 { | |
516 gaim_gtk_sound_init, | |
10322 | 517 gaim_gtk_sound_uninit, |
5684 | 518 gaim_gtk_sound_play_file, |
519 gaim_gtk_sound_play_event | |
520 }; | |
521 | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
522 GaimSoundUiOps * |
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6778
diff
changeset
|
523 gaim_gtk_sound_get_ui_ops(void) |
5684 | 524 { |
525 return &sound_ui_ops; | |
526 } |