Mon, 17 Mar 2008 13:38:34 +0000
Revert the dependency on gstreamer-0.10 >= 0.10.10, falling back to the SIGALRM
hack on gstreamers which can't disable forking. This should keep both Alver
and Stu happy in their respective stone-ages.
| 5684 | 1 | /* |
|
14547
389330a9e9b5
[gaim-migrate @ 17204]
Mark Doliner <markdoliner@pidgin.im>
parents:
14316
diff
changeset
|
2 | * @file gtksound.c GTK+ Sound |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16161
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 5684 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15923
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 5684 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19849
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5684 | 25 | * |
| 26 | */ | |
| 9791 | 27 | #include "internal.h" |
| 15577 | 28 | #include "pidgin.h" |
| 5684 | 29 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
30 | #ifdef _WIN32 |
| 5684 | 31 | #include <windows.h> |
| 32 | #include <mmsystem.h> | |
| 33 | #endif | |
| 34 | ||
| 13720 | 35 | #ifdef USE_GSTREAMER |
| 36 | # include <gst/gst.h> | |
| 37 | #endif /* USE_GSTREAMER */ | |
| 5684 | 38 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
39 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
40 | #include "notify.h" |
| 5684 | 41 | #include "prefs.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
42 | #include "sound.h" |
|
7465
17e1e9e996ad
[gaim-migrate @ 8078]
Mark Doliner <markdoliner@pidgin.im>
parents:
7464
diff
changeset
|
43 | #include "util.h" |
| 5684 | 44 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
45 | #include "gtkconv.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
46 | #include "gtksound.h" |
| 5684 | 47 | |
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15649
diff
changeset
|
48 | struct pidgin_sound_event { |
| 5684 | 49 | char *label; |
| 50 | char *pref; | |
| 51 | char *def; | |
| 52 | }; | |
| 53 | ||
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
54 | static guint mute_login_sounds_timeout = 0; |
| 5684 | 55 | static gboolean mute_login_sounds = FALSE; |
| 56 | ||
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
57 | #ifdef USE_GSTREAMER |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
58 | static gboolean gst_init_failed; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
59 | #endif /* USE_GSTREAMER */ |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
60 | |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
20234
diff
changeset
|
61 | static const struct pidgin_sound_event sounds[PURPLE_NUM_SOUNDS] = { |
| 10158 | 62 | {N_("Buddy logs in"), "login", "login.wav"}, |
| 63 | {N_("Buddy logs out"), "logout", "logout.wav"}, | |
| 5684 | 64 | {N_("Message received"), "im_recv", "receive.wav"}, |
| 65 | {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
| 66 | {N_("Message sent"), "send_im", "send.wav"}, | |
| 10158 | 67 | {N_("Person enters chat"), "join_chat", "login.wav"}, |
| 68 | {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
| 5684 | 69 | {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
| 70 | {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
| 71 | /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
| 10158 | 72 | {NULL, "pounce_default", "alert.wav"}, |
|
13551
d21effc814bc
[gaim-migrate @ 15927]
Richard Laager <rlaager@pidgin.im>
parents:
13544
diff
changeset
|
73 | {N_("Someone says your screen name in chat"), "nick_said", "alert.wav"} |
| 5684 | 74 | }; |
| 75 | ||
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
76 | static gboolean |
|
11463
d672317c99c1
[gaim-migrate @ 13703]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
77 | unmute_login_sounds_cb(gpointer data) |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
78 | { |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
79 | mute_login_sounds = FALSE; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
80 | mute_login_sounds_timeout = 0; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
81 | return FALSE; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
82 | } |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
83 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
84 | static gboolean |
| 15884 | 85 | chat_nick_matches_name(PurpleConversation *conv, const char *aname) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
86 | { |
| 15884 | 87 | PurpleConvChat *chat = NULL; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
88 | char *nick = NULL; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
89 | char *name = NULL; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
90 | gboolean ret = FALSE; |
| 15884 | 91 | chat = purple_conversation_get_chat_data(conv); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
92 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
93 | if (chat==NULL) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
94 | return ret; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
95 | |
| 15884 | 96 | nick = g_strdup(purple_normalize(conv->account, chat->nick)); |
| 97 | name = g_strdup(purple_normalize(conv->account, aname)); | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
98 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
99 | if (g_utf8_collate(nick, name) == 0) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
100 | ret = TRUE; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
101 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
102 | g_free(nick); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
103 | g_free(name); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
104 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
105 | return ret; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
106 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
107 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
108 | /* |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
109 | * play a sound event for a conversation, honoring make_sound flag |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
110 | * of conversation and checking for focus if conv_focus pref is set |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
111 | */ |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
112 | static void |
| 15884 | 113 | play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
114 | { |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
115 | /* If we should not play the sound for some reason, then exit early */ |
|
19591
a943e8e69c5f
Make sure a conversation is a pidgin-conversation to avoid a crash.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19564
diff
changeset
|
116 | if (conv != NULL && PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
117 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
118 | PidginConversation *gtkconv; |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
119 | gboolean has_focus; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
120 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
121 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 15884 | 122 | has_focus = purple_conversation_has_focus(conv); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
123 | |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
124 | if (!gtkconv->make_sound || |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
125 | (has_focus && !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus"))) |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
126 | { |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
127 | return; |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
128 | } |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
129 | } |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
130 | |
| 15884 | 131 | purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
132 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
133 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
134 | static void |
| 15884 | 135 | buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
136 | { |
| 15884 | 137 | purple_sound_play_event(event, purple_buddy_get_account(buddy)); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
138 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
139 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
140 | static void |
| 15884 | 141 | im_msg_received_cb(PurpleAccount *account, char *sender, |
| 142 | char *message, PurpleConversation *conv, | |
| 143 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
144 | { |
| 15884 | 145 | if (flags & PURPLE_MESSAGE_DELAYED) |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
146 | return; |
|
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
147 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
148 | if (conv==NULL) |
| 15884 | 149 | purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
150 | else |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
151 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
152 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
153 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
154 | static void |
| 15884 | 155 | im_msg_sent_cb(PurpleAccount *account, const char *receiver, |
| 156 | const char *message, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
157 | { |
| 15884 | 158 | PurpleConversation *conv = purple_find_conversation_with_account( |
| 159 | PURPLE_CONV_TYPE_ANY, receiver, account); | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
160 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
161 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
162 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
163 | static void |
| 15884 | 164 | chat_buddy_join_cb(PurpleConversation *conv, const char *name, |
| 165 | PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
| 166 | PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
167 | { |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
168 | if (new_arrival && !chat_nick_matches_name(conv, name)) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
169 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
170 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
171 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
172 | static void |
| 15884 | 173 | chat_buddy_left_cb(PurpleConversation *conv, const char *name, |
| 174 | const char *reason, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
175 | { |
| 11581 | 176 | if (!chat_nick_matches_name(conv, name)) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
177 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
178 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
179 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
180 | static void |
| 15884 | 181 | chat_msg_sent_cb(PurpleAccount *account, const char *message, |
| 182 | int id, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
183 | { |
| 15884 | 184 | PurpleConnection *conn = purple_account_get_connection(account); |
| 185 | PurpleConversation *conv = NULL; | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
186 | |
| 11581 | 187 | if (conn!=NULL) |
| 15884 | 188 | conv = purple_find_chat(conn,id); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
189 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
190 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
191 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
192 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
193 | static void |
| 15884 | 194 | chat_msg_received_cb(PurpleAccount *account, char *sender, |
| 195 | char *message, PurpleConversation *conv, | |
| 196 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
197 | { |
| 15884 | 198 | PurpleConvChat *chat; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
199 | |
| 15884 | 200 | if (flags & PURPLE_MESSAGE_DELAYED) |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
201 | return; |
|
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
202 | |
| 15884 | 203 | chat = purple_conversation_get_chat_data(conv); |
|
13413
8cdf761df65c
[gaim-migrate @ 15787]
Richard Laager <rlaager@pidgin.im>
parents:
13046
diff
changeset
|
204 | g_return_if_fail(chat != NULL); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
205 | |
| 15884 | 206 | if (purple_conv_chat_is_user_ignored(chat, sender)) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
207 | return; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
208 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
209 | if (chat_nick_matches_name(conv, sender)) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
210 | return; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
211 | |
| 15884 | 212 | if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) |
| 213 | play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
214 | else |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
215 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
216 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
217 | |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
218 | /* |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
219 | * We mute sounds for the 10 seconds after you log in so that |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
220 | * you don't get flooded with sounds when the blist shows all |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
221 | * your buddies logging in. |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
222 | */ |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
223 | static void |
| 15884 | 224 | account_signon_cb(PurpleConnection *gc, gpointer data) |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
225 | { |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
226 | if (mute_login_sounds_timeout != 0) |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
227 | g_source_remove(mute_login_sounds_timeout); |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
228 | mute_login_sounds = TRUE; |
| 15884 | 229 | mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
230 | } |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
231 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
232 | const char * |
| 15884 | 233 | pidgin_sound_get_event_option(PurpleSoundEventID event) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
234 | { |
| 15884 | 235 | if(event >= PURPLE_NUM_SOUNDS) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
236 | return 0; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
237 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
238 | return sounds[event].pref; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
239 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
240 | |
|
15165
0ff631dfbbca
[gaim-migrate @ 17889]
Daniel Atallah <datallah@pidgin.im>
parents:
14972
diff
changeset
|
241 | const char * |
| 15884 | 242 | pidgin_sound_get_event_label(PurpleSoundEventID event) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
243 | { |
| 15884 | 244 | if(event >= PURPLE_NUM_SOUNDS) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
245 | return NULL; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
246 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
247 | return sounds[event].label; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
248 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
249 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
250 | void * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
251 | pidgin_sound_get_handle() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
252 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
253 | static int handle; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
254 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
255 | return &handle; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
256 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
257 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
258 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
259 | pidgin_sound_init(void) |
| 5684 | 260 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
261 | void *gtk_sound_handle = pidgin_sound_get_handle(); |
| 15884 | 262 | void *blist_handle = purple_blist_get_handle(); |
| 263 | void *conv_handle = purple_conversations_get_handle(); | |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
264 | #ifdef USE_GSTREAMER |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
265 | GError *error = NULL; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
266 | #endif |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
267 | |
| 15884 | 268 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 269 | gtk_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
270 | NULL); |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
271 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
272 | purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
273 | purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/enabled"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
274 | purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/file"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
275 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/login", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
276 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/login", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
277 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/logout", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
278 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/logout", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
279 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/im_recv", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
280 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/im_recv", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
281 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
282 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/first_im_recv", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
283 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_im", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
284 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_im", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
285 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/join_chat", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
286 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/join_chat", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
287 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/left_chat", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
288 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/left_chat", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
289 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
290 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_chat_msg", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
291 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
292 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
293 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
294 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
295 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
296 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
297 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
298 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
299 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", ""); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
300 | purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
301 | purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50); |
| 5684 | 302 | |
| 13720 | 303 | #ifdef USE_GSTREAMER |
| 15884 | 304 | purple_debug_info("sound", "Initializing sound output drivers.\n"); |
|
22631
ba53b0eadb20
Revert the dependency on gstreamer-0.10 >= 0.10.10, falling back to the SIGALRM
Will Thompson <resiak@pidgin.im>
parents:
22565
diff
changeset
|
305 | #ifdef GST_CAN_DISABLE_FORKING |
|
22565
d1943619d6f9
Tell gstreamer not to fork; remove the SIGCHLD -> SIGALRM hack, which made
Will Thompson <resiak@pidgin.im>
parents:
21125
diff
changeset
|
306 | gst_registry_fork_set_enabled (FALSE); |
|
22631
ba53b0eadb20
Revert the dependency on gstreamer-0.10 >= 0.10.10, falling back to the SIGALRM
Will Thompson <resiak@pidgin.im>
parents:
22565
diff
changeset
|
307 | #endif |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
308 | if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { |
| 15884 | 309 | purple_notify_error(NULL, _("GStreamer Failure"), |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
310 | _("GStreamer failed to initialize."), |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
311 | error ? error->message : ""); |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
312 | if (error) { |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
313 | g_error_free(error); |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
314 | error = NULL; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
315 | } |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
316 | } |
| 13720 | 317 | #endif /* USE_GSTREAMER */ |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
318 | |
| 15884 | 319 | purple_signal_connect(blist_handle, "buddy-signed-on", |
| 320 | gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 321 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
| 322 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 323 | gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 324 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
| 325 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 326 | gtk_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
| 327 | GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
| 328 | purple_signal_connect(conv_handle, "sent-im-msg", | |
| 329 | gtk_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
| 330 | GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
| 331 | purple_signal_connect(conv_handle, "chat-buddy-joined", | |
| 332 | gtk_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
| 333 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
| 334 | purple_signal_connect(conv_handle, "chat-buddy-left", | |
| 335 | gtk_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
| 336 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
| 337 | purple_signal_connect(conv_handle, "sent-chat-msg", | |
| 338 | gtk_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
| 339 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
| 340 | purple_signal_connect(conv_handle, "received-chat-msg", | |
| 341 | gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
| 342 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
| 5684 | 343 | } |
| 344 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
345 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
346 | pidgin_sound_uninit(void) |
| 5684 | 347 | { |
| 13720 | 348 | #ifdef USE_GSTREAMER |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
349 | if (!gst_init_failed) |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
350 | gst_deinit(); |
| 5684 | 351 | #endif |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
352 | |
| 15884 | 353 | purple_signals_disconnect_by_handle(pidgin_sound_get_handle()); |
| 5684 | 354 | } |
| 355 | ||
| 13720 | 356 | #ifdef USE_GSTREAMER |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
357 | static gboolean |
| 13720 | 358 | bus_call (GstBus *bus, |
| 359 | GstMessage *msg, | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
360 | gpointer data) |
|
12815
5f73e8c06a9c
[gaim-migrate @ 15163]
Casey Harkins <charkins@pidgin.im>
parents:
12411
diff
changeset
|
361 | { |
| 13720 | 362 | GstElement *play = data; |
|
14941
0c27c799be04
[gaim-migrate @ 17648]
Mark Doliner <markdoliner@pidgin.im>
parents:
14762
diff
changeset
|
363 | GError *err = NULL; |
|
10074
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
364 | |
| 13720 | 365 | switch (GST_MESSAGE_TYPE (msg)) { |
| 366 | case GST_MESSAGE_ERROR: | |
| 367 | gst_message_parse_error(msg, &err, NULL); | |
|
17731
6486f382fb08
Improve the formatting of some gstreamer error messages. Someone
Mark Doliner <markdoliner@pidgin.im>
parents:
17146
diff
changeset
|
368 | purple_debug_error("gstreamer", "%s\n", err->message); |
| 13720 | 369 | g_error_free(err); |
|
19564
6f04c6ab2897
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@pidgin.im>
parents:
18292
diff
changeset
|
370 | /* fall-through and clean up */ |
|
6f04c6ab2897
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@pidgin.im>
parents:
18292
diff
changeset
|
371 | case GST_MESSAGE_EOS: |
|
6f04c6ab2897
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@pidgin.im>
parents:
18292
diff
changeset
|
372 | gst_element_set_state(play, GST_STATE_NULL); |
|
6f04c6ab2897
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@pidgin.im>
parents:
18292
diff
changeset
|
373 | gst_object_unref(GST_OBJECT(play)); |
| 13720 | 374 | break; |
| 375 | case GST_MESSAGE_WARNING: | |
| 376 | gst_message_parse_warning(msg, &err, NULL); | |
|
17732
b6325601b1ff
I left off a comma. My bad!
Mark Doliner <markdoliner@pidgin.im>
parents:
17731
diff
changeset
|
377 | purple_debug_warning("gstreamer", "%s\n", err->message); |
| 13720 | 378 | g_error_free(err); |
| 379 | break; | |
| 380 | default: | |
| 381 | break; | |
| 382 | } | |
| 383 | return TRUE; | |
| 384 | } | |
|
12930
2a65c7c86e86
[gaim-migrate @ 15283]
Richard Laager <rlaager@pidgin.im>
parents:
12850
diff
changeset
|
385 | #endif |
|
12815
5f73e8c06a9c
[gaim-migrate @ 15163]
Casey Harkins <charkins@pidgin.im>
parents:
12411
diff
changeset
|
386 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
387 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
388 | pidgin_sound_play_file(const char *filename) |
| 5684 | 389 | { |
| 390 | const char *method; | |
| 13720 | 391 | #ifdef USE_GSTREAMER |
| 392 | float volume; | |
| 393 | char *uri; | |
| 394 | GstElement *sink = NULL; | |
| 395 | GstElement *play = NULL; | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
396 | GstBus *bus = NULL; |
| 5684 | 397 | #endif |
| 398 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
399 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute")) |
| 5684 | 400 | return; |
| 401 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
402 | method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"); |
| 5684 | 403 | |
|
10074
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
404 | if (!strcmp(method, "none")) { |
|
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
405 | return; |
|
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
406 | } else if (!strcmp(method, "beep")) { |
| 5684 | 407 | gdk_beep(); |
| 408 | return; | |
| 409 | } | |
| 410 | ||
| 13797 | 411 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
| 15884 | 412 | purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); |
| 5684 | 413 | return; |
| 13797 | 414 | } |
| 5684 | 415 | |
| 416 | #ifndef _WIN32 | |
| 417 | if (!strcmp(method, "custom")) { | |
| 418 | const char *sound_cmd; | |
| 419 | char *command; | |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
420 | char *esc_filename; |
| 5684 | 421 | GError *error = NULL; |
| 422 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
423 | sound_cmd = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/sound/command"); |
| 5684 | 424 | |
| 425 | if (!sound_cmd || *sound_cmd == '\0') { | |
| 15884 | 426 | purple_debug_error("gtksound", |
| 13797 | 427 | "'Command' sound method has been chosen, " |
| 428 | "but no command has been set."); | |
| 5684 | 429 | return; |
| 430 | } | |
| 431 | ||
|
16959
5ae554ed8299
Let glib handle quoting filenames for shell, it'll escape other quotes as needed.
Casey Harkins <charkins@pidgin.im>
parents:
16951
diff
changeset
|
432 | esc_filename = g_shell_quote(filename); |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
433 | |
| 7464 | 434 | if(strstr(sound_cmd, "%s")) |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
435 | command = purple_strreplace(sound_cmd, "%s", esc_filename); |
| 7464 | 436 | else |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
437 | command = g_strdup_printf("%s %s", sound_cmd, esc_filename); |
| 5684 | 438 | |
| 439 | if(!g_spawn_command_line_async(command, &error)) { | |
| 15884 | 440 | purple_debug_error("gtksound", "sound command could not be launched: %s\n", error->message); |
| 5684 | 441 | g_error_free(error); |
| 442 | } | |
| 443 | ||
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
444 | g_free(esc_filename); |
| 5684 | 445 | g_free(command); |
| 446 | return; | |
| 447 | } | |
|
19849
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
448 | #endif /* _WIN32 */ |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
449 | |
| 13720 | 450 | #ifdef USE_GSTREAMER |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
451 | if (gst_init_failed) /* Perhaps do gdk_beep instead? */ |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
452 | return; |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
453 | volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50; |
| 13720 | 454 | if (!strcmp(method, "automatic")) { |
| 15884 | 455 | if (purple_running_gnome()) { |
| 13720 | 456 | sink = gst_element_factory_make("gconfaudiosink", "sink"); |
| 457 | } | |
| 14972 | 458 | if (!sink) |
| 459 | sink = gst_element_factory_make("autoaudiosink", "sink"); | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
460 | if (!sink) { |
| 15884 | 461 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
462 | return; |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
463 | } |
|
19849
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
464 | } |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
465 | #ifndef _WIN32 |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
466 | else if (!strcmp(method, "esd")) { |
| 13720 | 467 | sink = gst_element_factory_make("esdsink", "sink"); |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
468 | if (!sink) { |
| 15884 | 469 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
470 | return; |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
471 | } |
|
17146
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
472 | } else if (!strcmp(method, "alsa")) { |
|
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
473 | sink = gst_element_factory_make("alsasink", "sink"); |
|
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
474 | if (!sink) { |
|
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
475 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
|
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
476 | return; |
|
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
477 | } |
|
19849
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
478 | } |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
479 | #endif |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
480 | else { |
| 15884 | 481 | purple_debug_error("sound", "Unknown sound method '%s'\n", method); |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
482 | return; |
| 13720 | 483 | } |
| 5684 | 484 | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
485 | play = gst_element_factory_make("playbin", "play"); |
|
21125
e7cd2426e511
Remove unused definition.
Daniel Atallah <datallah@pidgin.im>
parents:
21091
diff
changeset
|
486 | |
|
16161
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
487 | if (play == NULL) { |
|
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
488 | return; |
|
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
489 | } |
|
21125
e7cd2426e511
Remove unused definition.
Daniel Atallah <datallah@pidgin.im>
parents:
21091
diff
changeset
|
490 | |
| 13720 | 491 | uri = g_strdup_printf("file://%s", filename); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
492 | |
| 13720 | 493 | g_object_set(G_OBJECT(play), "uri", uri, |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
494 | "volume", volume, |
| 13720 | 495 | "audio-sink", sink, NULL); |
| 5684 | 496 | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
497 | bus = gst_pipeline_get_bus(GST_PIPELINE(play)); |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
498 | gst_bus_add_watch(bus, bus_call, play); |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
499 | |
| 13720 | 500 | gst_element_set_state(play, GST_STATE_PLAYING); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
501 | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
502 | gst_object_unref(bus); |
| 13720 | 503 | g_free(uri); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
504 | |
| 13720 | 505 | #else /* USE_GSTREAMER */ |
|
19849
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
506 | |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
507 | #ifndef _WIN32 |
| 5684 | 508 | gdk_beep(); |
| 509 | #else /* _WIN32 */ | |
| 15884 | 510 | purple_debug_info("sound", "Playing %s\n", filename); |
| 5684 | 511 | |
|
10922
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
512 | if (G_WIN32_HAVE_WIDECHAR_API ()) { |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
513 | wchar_t *wc_filename = g_utf8_to_utf16(filename, |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
514 | -1, NULL, NULL, NULL); |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
515 | if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
| 15884 | 516 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
|
10922
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
517 | g_free(wc_filename); |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
518 | } else { |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
519 | char *l_filename = g_locale_from_utf8(filename, |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
520 | -1, NULL, NULL, NULL); |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
521 | if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) |
| 15884 | 522 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
|
10922
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
523 | g_free(l_filename); |
|
a27fde43df3b
[gaim-migrate @ 12691]
Daniel Atallah <datallah@pidgin.im>
parents:
10322
diff
changeset
|
524 | } |
| 5684 | 525 | #endif /* _WIN32 */ |
|
19849
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
526 | |
|
e8a23f4721f0
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <datallah@pidgin.im>
parents:
19591
diff
changeset
|
527 | #endif /* USE_GSTREAMER */ |
| 5684 | 528 | } |
| 529 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
530 | static void |
| 15884 | 531 | pidgin_sound_play_event(PurpleSoundEventID event) |
| 5684 | 532 | { |
| 533 | char *enable_pref; | |
| 534 | char *file_pref; | |
| 535 | ||
| 15884 | 536 | if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) |
| 5684 | 537 | return; |
| 538 | ||
| 15884 | 539 | if (event >= PURPLE_NUM_SOUNDS) { |
| 540 | purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
| 5684 | 541 | return; |
| 542 | } | |
| 543 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
544 | enable_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s", |
| 5684 | 545 | sounds[event].pref); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
546 | file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref); |
| 5684 | 547 | |
| 548 | /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
| 15884 | 549 | if (purple_prefs_get_bool(enable_pref)) { |
| 550 | char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
| 5684 | 551 | if(!filename || !strlen(filename)) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
552 | g_free(filename); |
| 18292 | 553 | /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ |
| 554 | filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
| 5684 | 555 | } |
| 556 | ||
| 15884 | 557 | purple_sound_play_file(filename, NULL); |
| 5684 | 558 | g_free(filename); |
| 559 | } | |
| 560 | ||
| 561 | g_free(enable_pref); | |
| 562 | g_free(file_pref); | |
| 563 | } | |
| 564 | ||
| 15884 | 565 | static PurpleSoundUiOps sound_ui_ops = |
| 5684 | 566 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
567 | pidgin_sound_init, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
568 | pidgin_sound_uninit, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
569 | pidgin_sound_play_file, |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
570 | pidgin_sound_play_event, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
571 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
572 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
573 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
574 | NULL |
| 5684 | 575 | }; |
| 576 | ||
| 15884 | 577 | PurpleSoundUiOps * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
578 | pidgin_sound_get_ui_ops(void) |
| 5684 | 579 | { |
| 580 | return &sound_ui_ops; | |
| 581 | } |