Wed, 19 Jun 2013 19:56:19 +0530
Refactored pidgin to use the GObject-based PurpleAccount API
| 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" |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
43 | #include "sound-theme.h" |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
44 | #include "theme-manager.h" |
|
7465
17e1e9e996ad
[gaim-migrate @ 8078]
Mark Doliner <markdoliner@pidgin.im>
parents:
7464
diff
changeset
|
45 | #include "util.h" |
| 5684 | 46 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
47 | #include "gtkconv.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
48 | #include "gtksound.h" |
| 5684 | 49 | |
|
15880
d275b025481c
More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents:
15649
diff
changeset
|
50 | struct pidgin_sound_event { |
| 5684 | 51 | char *label; |
| 52 | char *pref; | |
| 53 | char *def; | |
| 54 | }; | |
| 55 | ||
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
56 | static guint mute_login_sounds_timeout = 0; |
| 5684 | 57 | static gboolean mute_login_sounds = FALSE; |
| 58 | ||
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
59 | #ifdef USE_GSTREAMER |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
60 | static gboolean gst_init_failed; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
61 | #endif /* USE_GSTREAMER */ |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
62 | |
|
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
|
63 | static const struct pidgin_sound_event sounds[PURPLE_NUM_SOUNDS] = { |
| 10158 | 64 | {N_("Buddy logs in"), "login", "login.wav"}, |
| 65 | {N_("Buddy logs out"), "logout", "logout.wav"}, | |
| 5684 | 66 | {N_("Message received"), "im_recv", "receive.wav"}, |
| 67 | {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
| 68 | {N_("Message sent"), "send_im", "send.wav"}, | |
| 10158 | 69 | {N_("Person enters chat"), "join_chat", "login.wav"}, |
| 70 | {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
| 5684 | 71 | {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
| 72 | {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
| 73 | /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
| 10158 | 74 | {NULL, "pounce_default", "alert.wav"}, |
|
24457
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
75 | {N_("Someone says your username in chat"), "nick_said", "alert.wav"}, |
|
29489
2322b6b9fcb7
Don't play the message received sound for NOTIFY messages (this will avoid
Marcus Lundblad <malu@pidgin.im>
parents:
28573
diff
changeset
|
76 | {N_("Attention received"), "got_attention", "alert.wav"} |
| 5684 | 77 | }; |
| 78 | ||
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
79 | static gboolean |
|
11463
d672317c99c1
[gaim-migrate @ 13703]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
80 | unmute_login_sounds_cb(gpointer data) |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
81 | { |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
82 | mute_login_sounds = FALSE; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
83 | mute_login_sounds_timeout = 0; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
84 | return FALSE; |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
85 | } |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
86 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
87 | static gboolean |
| 15884 | 88 | chat_nick_matches_name(PurpleConversation *conv, const char *aname) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
89 | { |
| 15884 | 90 | PurpleConvChat *chat = NULL; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
91 | char *nick = NULL; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
92 | char *name = NULL; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
93 | gboolean ret = FALSE; |
| 15884 | 94 | chat = purple_conversation_get_chat_data(conv); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
95 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
96 | if (chat==NULL) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
97 | return ret; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
98 | |
|
32620
a5c32f843d18
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32612
diff
changeset
|
99 | nick = g_strdup(purple_normalize(purple_conversation_get_account(conv), purple_conv_chat_get_nick(chat))); |
|
a5c32f843d18
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32612
diff
changeset
|
100 | name = g_strdup(purple_normalize(purple_conversation_get_account(conv), aname)); |
|
11552
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 | if (g_utf8_collate(nick, name) == 0) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
103 | ret = TRUE; |
|
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 | g_free(nick); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
106 | g_free(name); |
|
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 | return ret; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
109 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
110 | |
|
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 | * play a sound event for a conversation, honoring make_sound flag |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
113 | * 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
|
114 | */ |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
115 | static void |
| 15884 | 116 | play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
117 | { |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
118 | /* 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
|
119 | if (conv != NULL && PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
120 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
121 | PidginConversation *gtkconv; |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
122 | gboolean has_focus; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
123 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
124 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 15884 | 125 | has_focus = purple_conversation_has_focus(conv); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
126 | |
|
11642
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
127 | 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
|
128 | (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
|
129 | { |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
130 | return; |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
131 | } |
|
76b60f0bf467
[gaim-migrate @ 13919]
Casey Harkins <charkins@pidgin.im>
parents:
11581
diff
changeset
|
132 | } |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
133 | |
| 15884 | 134 | 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
|
135 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
136 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
137 | static void |
| 15884 | 138 | buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
139 | { |
| 15884 | 140 | purple_sound_play_event(event, purple_buddy_get_account(buddy)); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
141 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
142 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
143 | static void |
| 15884 | 144 | im_msg_received_cb(PurpleAccount *account, char *sender, |
| 145 | char *message, PurpleConversation *conv, | |
| 146 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
147 | { |
|
29489
2322b6b9fcb7
Don't play the message received sound for NOTIFY messages (this will avoid
Marcus Lundblad <malu@pidgin.im>
parents:
28573
diff
changeset
|
148 | if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY) |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
149 | return; |
|
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
150 | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
151 | if (conv==NULL) |
| 15884 | 152 | purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
153 | else |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
154 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
155 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
156 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
157 | static void |
| 15884 | 158 | im_msg_sent_cb(PurpleAccount *account, const char *receiver, |
| 159 | const char *message, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
160 | { |
| 15884 | 161 | PurpleConversation *conv = purple_find_conversation_with_account( |
|
27952
f0b5d4786136
Minor cleanup: this callback is only triggered for IMs.
Paul Aurich <darkrain42@pidgin.im>
parents:
26753
diff
changeset
|
162 | PURPLE_CONV_TYPE_IM, receiver, account); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
163 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
164 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
165 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
166 | static void |
| 15884 | 167 | chat_buddy_join_cb(PurpleConversation *conv, const char *name, |
| 168 | PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
| 169 | PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
170 | { |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
171 | if (new_arrival && !chat_nick_matches_name(conv, name)) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
172 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
173 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
174 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
175 | static void |
| 15884 | 176 | chat_buddy_left_cb(PurpleConversation *conv, const char *name, |
| 177 | const char *reason, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
178 | { |
| 11581 | 179 | if (!chat_nick_matches_name(conv, name)) |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
180 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
181 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
182 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
183 | static void |
| 15884 | 184 | chat_msg_sent_cb(PurpleAccount *account, const char *message, |
| 185 | int id, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
186 | { |
| 15884 | 187 | PurpleConnection *conn = purple_account_get_connection(account); |
| 188 | PurpleConversation *conv = NULL; | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
189 | |
| 11581 | 190 | if (conn!=NULL) |
| 15884 | 191 | conv = purple_find_chat(conn,id); |
|
11552
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 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
194 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
195 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
196 | static void |
| 15884 | 197 | chat_msg_received_cb(PurpleAccount *account, char *sender, |
| 198 | char *message, PurpleConversation *conv, | |
| 199 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
200 | { |
| 15884 | 201 | PurpleConvChat *chat; |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
202 | |
|
29489
2322b6b9fcb7
Don't play the message received sound for NOTIFY messages (this will avoid
Marcus Lundblad <malu@pidgin.im>
parents:
28573
diff
changeset
|
203 | if (flags & PURPLE_MESSAGE_DELAYED || flags & PURPLE_MESSAGE_NOTIFY) |
|
12850
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
204 | return; |
|
744542bdd53e
[gaim-migrate @ 15200]
Casey Harkins <charkins@pidgin.im>
parents:
12828
diff
changeset
|
205 | |
| 15884 | 206 | chat = purple_conversation_get_chat_data(conv); |
|
13413
8cdf761df65c
[gaim-migrate @ 15787]
Richard Laager <rlaager@pidgin.im>
parents:
13046
diff
changeset
|
207 | g_return_if_fail(chat != NULL); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
208 | |
| 15884 | 209 | if (purple_conv_chat_is_user_ignored(chat, sender)) |
|
11552
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 | |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
212 | if (chat_nick_matches_name(conv, sender)) |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
213 | return; |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
214 | |
|
32612
152caf3b6b63
Use purple_conv_chat_get_nick() rather than accessing chat->nick directly.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
215 | if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, purple_conv_chat_get_nick(chat))) |
|
28542
4868e1836159
Fix fallback to default sounds when the file isn't found.
Daniel Atallah <datallah@pidgin.im>
parents:
27952
diff
changeset
|
216 | /* This isn't quite right; if you have the PURPLE_SOUND_CHAT_NICK event disabled |
|
4868e1836159
Fix fallback to default sounds when the file isn't found.
Daniel Atallah <datallah@pidgin.im>
parents:
27952
diff
changeset
|
217 | * and the PURPLE_SOUND_CHAT_SAY event enabled, you won't get a sound at all */ |
| 15884 | 218 | play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
219 | else |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
220 | play_conv_event(conv, event); |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
221 | } |
|
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
222 | |
|
24457
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
223 | static void |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29653
diff
changeset
|
224 | got_attention_cb(PurpleAccount *account, const char *who, |
|
24457
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
225 | PurpleConversation *conv, guint type, PurpleSoundEventID event) |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
226 | { |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
227 | play_conv_event(conv, event); |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
228 | } |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
229 | |
|
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 | * 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
|
232 | * 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
|
233 | * your buddies logging in. |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
234 | */ |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
235 | static void |
| 15884 | 236 | account_signon_cb(PurpleConnection *gc, gpointer data) |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
237 | { |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
238 | if (mute_login_sounds_timeout != 0) |
|
26753
a8dca8faae69
A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
Arunan Balasubramaniam <foss@abala.me>
parents:
25888
diff
changeset
|
239 | purple_timeout_remove(mute_login_sounds_timeout); |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
240 | mute_login_sounds = TRUE; |
|
26753
a8dca8faae69
A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
Arunan Balasubramaniam <foss@abala.me>
parents:
25888
diff
changeset
|
241 | mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL); |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
242 | } |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
243 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
244 | const char * |
| 15884 | 245 | pidgin_sound_get_event_option(PurpleSoundEventID event) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
246 | { |
| 15884 | 247 | if(event >= PURPLE_NUM_SOUNDS) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
248 | return 0; |
|
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 | return sounds[event].pref; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
251 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
252 | |
|
15165
0ff631dfbbca
[gaim-migrate @ 17889]
Daniel Atallah <datallah@pidgin.im>
parents:
14972
diff
changeset
|
253 | const char * |
| 15884 | 254 | pidgin_sound_get_event_label(PurpleSoundEventID event) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
255 | { |
| 15884 | 256 | if(event >= PURPLE_NUM_SOUNDS) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
257 | return NULL; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
258 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
259 | return sounds[event].label; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
260 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
261 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
262 | void * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
263 | pidgin_sound_get_handle() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
264 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
265 | static int handle; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
266 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
267 | return &handle; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
268 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
269 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
270 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
271 | pidgin_sound_init(void) |
| 5684 | 272 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
273 | void *gtk_sound_handle = pidgin_sound_get_handle(); |
| 15884 | 274 | void *blist_handle = purple_blist_get_handle(); |
| 275 | void *conv_handle = purple_conversations_get_handle(); | |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
276 | #ifdef USE_GSTREAMER |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
277 | GError *error = NULL; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
278 | #endif |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
279 | |
| 15884 | 280 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 281 | gtk_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
|
10320
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
282 | NULL); |
|
f5b0f5cf8562
[gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents:
10297
diff
changeset
|
283 | |
|
16123
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_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
|
285 | 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
|
286 | 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
|
287 | 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
|
288 | 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
|
289 | 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
|
290 | 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
|
291 | 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
|
292 | 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
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | 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
|
305 | 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
|
306 | 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
|
307 | 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
|
308 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
309 | purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", ""); |
|
24457
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
310 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE); |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
311 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", ""); |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
312 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE); |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
313 | purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", ""); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
314 | 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
|
315 | 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
|
316 | 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
|
317 | 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
|
318 | purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50); |
| 5684 | 319 | |
| 13720 | 320 | #ifdef USE_GSTREAMER |
| 15884 | 321 | purple_debug_info("sound", "Initializing sound output drivers.\n"); |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
322 | if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { |
| 15884 | 323 | purple_notify_error(NULL, _("GStreamer Failure"), |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
324 | _("GStreamer failed to initialize."), |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
325 | error ? error->message : ""); |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
326 | if (error) { |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
327 | g_error_free(error); |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
328 | error = NULL; |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
329 | } |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
330 | } |
| 13720 | 331 | #endif /* USE_GSTREAMER */ |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
332 | |
| 15884 | 333 | purple_signal_connect(blist_handle, "buddy-signed-on", |
| 334 | gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 335 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
| 336 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 337 | gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 338 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
| 339 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 340 | gtk_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
| 341 | GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
| 342 | purple_signal_connect(conv_handle, "sent-im-msg", | |
| 343 | gtk_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
| 344 | GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
| 345 | purple_signal_connect(conv_handle, "chat-buddy-joined", | |
| 346 | gtk_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
| 347 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
| 348 | purple_signal_connect(conv_handle, "chat-buddy-left", | |
| 349 | gtk_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
| 350 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
| 351 | purple_signal_connect(conv_handle, "sent-chat-msg", | |
| 352 | gtk_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
| 353 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
| 354 | purple_signal_connect(conv_handle, "received-chat-msg", | |
| 355 | gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
| 356 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
|
24457
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
357 | purple_signal_connect(conv_handle, "got-attention", gtk_sound_handle, |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
358 | PURPLE_CALLBACK(got_attention_cb), |
|
adbbdb0532b0
Adds attention UI to Pidgin (can send attentions using a menu item)
Marcus Lundblad <malu@pidgin.im>
parents:
23314
diff
changeset
|
359 | GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION)); |
|
29489
2322b6b9fcb7
Don't play the message received sound for NOTIFY messages (this will avoid
Marcus Lundblad <malu@pidgin.im>
parents:
28573
diff
changeset
|
360 | /* for the time being, don't handle sent-attention here, since playing a |
|
2322b6b9fcb7
Don't play the message received sound for NOTIFY messages (this will avoid
Marcus Lundblad <malu@pidgin.im>
parents:
28573
diff
changeset
|
361 | sound would result induplicate sounds. And fixing that would require changing the |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29653
diff
changeset
|
362 | conversation signal for msg-recv */ |
| 5684 | 363 | } |
| 364 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
365 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
366 | pidgin_sound_uninit(void) |
| 5684 | 367 | { |
| 13720 | 368 | #ifdef USE_GSTREAMER |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
369 | if (!gst_init_failed) |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
370 | gst_deinit(); |
| 5684 | 371 | #endif |
|
11552
674a2a79943a
[gaim-migrate @ 13812]
Casey Harkins <charkins@pidgin.im>
parents:
11463
diff
changeset
|
372 | |
| 15884 | 373 | purple_signals_disconnect_by_handle(pidgin_sound_get_handle()); |
| 5684 | 374 | } |
| 375 | ||
| 13720 | 376 | #ifdef USE_GSTREAMER |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
377 | static gboolean |
| 13720 | 378 | bus_call (GstBus *bus, |
| 379 | GstMessage *msg, | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
380 | gpointer data) |
|
12815
5f73e8c06a9c
[gaim-migrate @ 15163]
Casey Harkins <charkins@pidgin.im>
parents:
12411
diff
changeset
|
381 | { |
| 13720 | 382 | GstElement *play = data; |
|
14941
0c27c799be04
[gaim-migrate @ 17648]
Mark Doliner <markdoliner@pidgin.im>
parents:
14762
diff
changeset
|
383 | GError *err = NULL; |
|
10074
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
384 | |
| 13720 | 385 | switch (GST_MESSAGE_TYPE (msg)) { |
| 386 | case GST_MESSAGE_ERROR: | |
| 387 | 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
|
388 | purple_debug_error("gstreamer", "%s\n", err->message); |
| 13720 | 389 | 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
|
390 | /* 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
|
391 | 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
|
392 | 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
|
393 | gst_object_unref(GST_OBJECT(play)); |
| 13720 | 394 | break; |
| 395 | case GST_MESSAGE_WARNING: | |
| 396 | 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
|
397 | purple_debug_warning("gstreamer", "%s\n", err->message); |
| 13720 | 398 | g_error_free(err); |
| 399 | break; | |
| 400 | default: | |
| 401 | break; | |
| 402 | } | |
| 403 | return TRUE; | |
| 404 | } | |
|
12930
2a65c7c86e86
[gaim-migrate @ 15283]
Richard Laager <rlaager@pidgin.im>
parents:
12850
diff
changeset
|
405 | #endif |
|
12815
5f73e8c06a9c
[gaim-migrate @ 15163]
Casey Harkins <charkins@pidgin.im>
parents:
12411
diff
changeset
|
406 | |
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
407 | #ifndef _WIN32 |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
408 | static gboolean |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
409 | expire_old_child(gpointer data) |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
410 | { |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
411 | pid_t pid = GPOINTER_TO_INT(data); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
412 | |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
413 | if (waitpid(pid, NULL, WNOHANG | WUNTRACED) < 0) { |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
414 | if (errno == ECHILD) |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
415 | return FALSE; |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
416 | else |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
417 | purple_debug_warning("gtksound", "Child is ill, pid: %d (%s)\n", pid, strerror(errno)); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
418 | } |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
419 | |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
420 | if (kill(pid, SIGKILL) < 0) |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
421 | purple_debug_error("gtksound", "Killing process %d failed (%s)\n", pid, strerror(errno)); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
422 | |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
423 | return FALSE; |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
424 | } |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
425 | #endif |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
426 | |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
427 | #ifdef _WIN32 |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
428 | static void |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
429 | pidgin_sound_play_file_win32(const char *filename) |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
430 | { |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
431 | wchar_t *wc_filename = g_utf8_to_utf16(filename, |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
432 | -1, NULL, NULL, NULL); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
433 | if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
434 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
435 | g_free(wc_filename); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
436 | } |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
437 | #endif /* _WIN32 */ |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
438 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
439 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
440 | pidgin_sound_play_file(const char *filename) |
| 5684 | 441 | { |
| 442 | const char *method; | |
| 13720 | 443 | #ifdef USE_GSTREAMER |
| 444 | float volume; | |
| 445 | char *uri; | |
| 446 | GstElement *sink = NULL; | |
| 447 | GstElement *play = NULL; | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
448 | GstBus *bus = NULL; |
| 5684 | 449 | #endif |
| 450 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
451 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute")) |
| 5684 | 452 | return; |
| 453 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
454 | method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"); |
| 5684 | 455 | |
|
10074
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
456 | if (!strcmp(method, "none")) { |
|
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
457 | return; |
|
4fab99572bf1
[gaim-migrate @ 11054]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9791
diff
changeset
|
458 | } else if (!strcmp(method, "beep")) { |
| 5684 | 459 | gdk_beep(); |
| 460 | return; | |
| 461 | } | |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
462 | #ifdef _WIN32 |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
463 | else if (!strcmp(method, "playsoundw")) { |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
464 | pidgin_sound_play_file_win32(filename); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
465 | return; |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
466 | } |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
467 | #endif /* _WIN32 */ |
| 5684 | 468 | |
| 13797 | 469 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
| 15884 | 470 | purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); |
| 5684 | 471 | return; |
| 13797 | 472 | } |
| 5684 | 473 | |
| 474 | #ifndef _WIN32 | |
| 475 | if (!strcmp(method, "custom")) { | |
| 476 | const char *sound_cmd; | |
| 477 | char *command; | |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
478 | char *esc_filename; |
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
479 | char **argv = NULL; |
| 5684 | 480 | GError *error = NULL; |
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
481 | GPid pid; |
| 5684 | 482 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
483 | sound_cmd = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/sound/command"); |
| 5684 | 484 | |
| 485 | if (!sound_cmd || *sound_cmd == '\0') { | |
| 15884 | 486 | purple_debug_error("gtksound", |
| 13797 | 487 | "'Command' sound method has been chosen, " |
|
24572
d2f6abb70f4e
Missing newline in debug message.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23314
diff
changeset
|
488 | "but no command has been set.\n"); |
| 5684 | 489 | return; |
| 490 | } | |
| 491 | ||
|
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
|
492 | 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
|
493 | |
| 7464 | 494 | 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
|
495 | command = purple_strreplace(sound_cmd, "%s", esc_filename); |
| 7464 | 496 | else |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
497 | command = g_strdup_printf("%s %s", sound_cmd, esc_filename); |
| 5684 | 498 | |
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
499 | if (!g_shell_parse_argv(command, NULL, &argv, &error)) { |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
500 | purple_debug_error("gtksound", "error parsing command %s (%s)\n", |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
501 | command, error->message); |
| 5684 | 502 | g_error_free(error); |
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
503 | g_free(esc_filename); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
504 | g_free(command); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
505 | return; |
| 5684 | 506 | } |
| 507 | ||
|
23027
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
508 | if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
509 | NULL, NULL, &pid, &error)) { |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
510 | purple_debug_error("gtksound", "sound command could not be launched: %s\n", |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
511 | error->message); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
512 | g_error_free(error); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
513 | } else { |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
514 | purple_timeout_add_seconds(15, expire_old_child, GINT_TO_POINTER(pid)); |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
515 | } |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
516 | |
|
5df4eac489e2
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22942
diff
changeset
|
517 | g_strfreev(argv); |
|
16951
d7d924e847d6
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16752
diff
changeset
|
518 | g_free(esc_filename); |
| 5684 | 519 | g_free(command); |
| 520 | return; | |
| 521 | } | |
|
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
|
522 | #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
|
523 | |
| 13720 | 524 | #ifdef USE_GSTREAMER |
|
14315
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
525 | if (gst_init_failed) /* Perhaps do gdk_beep instead? */ |
|
908ff155af2e
[gaim-migrate @ 16935]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14253
diff
changeset
|
526 | 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
|
527 | volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50; |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
528 | #ifdef _WIN32 |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
529 | if (!strcmp(method, "automatic")) { |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
530 | sink = gst_element_factory_make("directsoundsink", "sink"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
531 | if (sink == NULL) |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
532 | sink = gst_element_factory_make("waveformsink", "sink"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
533 | if (sink == NULL) |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
534 | sink = gst_element_factory_make("gconfaudiosink", "sink"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
535 | } else if (!strcmp(method, "directsound")) { |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
536 | sink = gst_element_factory_make("directsoundsink", "sink"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
537 | } else if (!strcmp(method, "waveform")) { |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
538 | sink = gst_element_factory_make("waveformsink", "sink"); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
539 | } |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
540 | #else |
| 13720 | 541 | if (!strcmp(method, "automatic")) { |
|
23314
f9ed181439a4
Try gconfaudiosink first always, not just under GNOME. This is what Debian
Richard Laager <rlaager@pidgin.im>
parents:
23239
diff
changeset
|
542 | sink = gst_element_factory_make("gconfaudiosink", "sink"); |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
543 | } else if (!strcmp(method, "esd")) { |
| 13720 | 544 | sink = gst_element_factory_make("esdsink", "sink"); |
|
17146
7d256e417ef6
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@pidgin.im>
parents:
16995
diff
changeset
|
545 | } 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
|
546 | sink = gst_element_factory_make("alsasink", "sink"); |
|
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
|
547 | } |
|
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
|
548 | #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
|
549 | else { |
| 15884 | 550 | purple_debug_error("sound", "Unknown sound method '%s'\n", method); |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
551 | return; |
| 13720 | 552 | } |
| 5684 | 553 | |
|
23239
1aec418902fd
A (modified) patch from Felipe to simplify our GStreamer sink selection
Felipe Contreras <felipe.contreras@gmail.com>
parents:
23069
diff
changeset
|
554 | if (strcmp(method, "automatic") != 0 && !sink) { |
|
1aec418902fd
A (modified) patch from Felipe to simplify our GStreamer sink selection
Felipe Contreras <felipe.contreras@gmail.com>
parents:
23069
diff
changeset
|
555 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
|
1aec418902fd
A (modified) patch from Felipe to simplify our GStreamer sink selection
Felipe Contreras <felipe.contreras@gmail.com>
parents:
23069
diff
changeset
|
556 | return; |
|
1aec418902fd
A (modified) patch from Felipe to simplify our GStreamer sink selection
Felipe Contreras <felipe.contreras@gmail.com>
parents:
23069
diff
changeset
|
557 | } |
|
1aec418902fd
A (modified) patch from Felipe to simplify our GStreamer sink selection
Felipe Contreras <felipe.contreras@gmail.com>
parents:
23069
diff
changeset
|
558 | |
|
33509
60647bc63acc
Bump GStreamer checks to 1.0.0 instead of 0.11.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33486
diff
changeset
|
559 | #if GST_CHECK_VERSION(1,0,0) |
|
33486
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33376
diff
changeset
|
560 | play = gst_element_factory_make("playbin", "play"); |
|
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33376
diff
changeset
|
561 | #else |
|
33372
0cd6239fcec9
Use GstPlayBin2 instead of GstPlayBin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32620
diff
changeset
|
562 | play = gst_element_factory_make("playbin2", "play"); |
|
33486
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33376
diff
changeset
|
563 | #endif |
|
21125
e7cd2426e511
Remove unused definition.
Daniel Atallah <datallah@pidgin.im>
parents:
21091
diff
changeset
|
564 | |
|
16161
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
565 | if (play == NULL) { |
|
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
566 | return; |
|
a6f32c913f9b
Fix a possible gstreamer crash
Sean Egan <seanegan@pidgin.im>
parents:
16123
diff
changeset
|
567 | } |
|
21125
e7cd2426e511
Remove unused definition.
Daniel Atallah <datallah@pidgin.im>
parents:
21091
diff
changeset
|
568 | |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
569 | #ifdef _WIN32 |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
570 | uri = g_strdup_printf("file:///%s", filename); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
571 | g_strdelimit(uri, "\\", '/'); |
|
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
572 | #else |
| 13720 | 573 | uri = g_strdup_printf("file://%s", filename); |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
574 | #endif |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
575 | |
| 13720 | 576 | g_object_set(G_OBJECT(play), "uri", uri, |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
577 | "volume", volume, |
| 13720 | 578 | "audio-sink", sink, NULL); |
| 5684 | 579 | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
580 | bus = gst_pipeline_get_bus(GST_PIPELINE(play)); |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
581 | gst_bus_add_watch(bus, bus_call, play); |
|
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
582 | |
| 13720 | 583 | gst_element_set_state(play, GST_STATE_PLAYING); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
584 | |
|
15285
505ff058278c
[gaim-migrate @ 18013]
Mark Doliner <markdoliner@pidgin.im>
parents:
15165
diff
changeset
|
585 | gst_object_unref(bus); |
| 13720 | 586 | g_free(uri); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
587 | |
|
23069
293830ac1149
Clarify #ifdef/#else/#endif matching; References #5770.
Ethan Blanton <elb@pidgin.im>
parents:
23027
diff
changeset
|
588 | #else /* #ifdef 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
|
589 | |
|
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
|
590 | #ifndef _WIN32 |
| 5684 | 591 | gdk_beep(); |
| 592 | #else /* _WIN32 */ | |
|
33948
b6c9e5dd95d1
VV: win32 support. No runtimes dependencies in dep-bundle yet. Refs #11075
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33509
diff
changeset
|
593 | pidgin_sound_play_file_win32(filename); |
| 5684 | 594 | #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
|
595 | |
|
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
|
596 | #endif /* USE_GSTREAMER */ |
| 5684 | 597 | } |
| 598 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
10320
diff
changeset
|
599 | static void |
| 15884 | 600 | pidgin_sound_play_event(PurpleSoundEventID event) |
| 5684 | 601 | { |
| 602 | char *enable_pref; | |
| 603 | char *file_pref; | |
|
23972
90e0da03c053
theme loader cleanup, and remove a few warnings
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23661
diff
changeset
|
604 | const char *theme_name; |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
605 | PurpleSoundTheme *theme; |
| 5684 | 606 | |
| 15884 | 607 | if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) |
| 5684 | 608 | return; |
| 609 | ||
| 15884 | 610 | if (event >= PURPLE_NUM_SOUNDS) { |
| 611 | purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
| 5684 | 612 | return; |
| 613 | } | |
| 614 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15931
diff
changeset
|
615 | enable_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s", |
| 5684 | 616 | 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
|
617 | file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref); |
| 5684 | 618 | |
| 619 | /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
| 15884 | 620 | if (purple_prefs_get_bool(enable_pref)) { |
| 621 | char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
|
23661
6cfcb043b068
fixed segfault when changing blist themes, changed prefs to not rely on static iter, fixed a few leaks
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23651
diff
changeset
|
622 | theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme"); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25884
diff
changeset
|
623 | |
|
25884
c00e14c20165
* Alphabetize files in a few Makefile.am files
Mark Doliner <markdoliner@pidgin.im>
parents:
24952
diff
changeset
|
624 | if (theme_name && *theme_name && (!filename || !*filename)) { |
|
c00e14c20165
* Alphabetize files in a few Makefile.am files
Mark Doliner <markdoliner@pidgin.im>
parents:
24952
diff
changeset
|
625 | /* Use theme */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13799
diff
changeset
|
626 | g_free(filename); |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
627 | |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
628 | theme = PURPLE_SOUND_THEME(purple_theme_manager_find_theme(theme_name, "sound")); |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
629 | filename = purple_sound_theme_get_file_full(theme, sounds[event].pref); |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
630 | |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
631 | if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)){ /* Use Default sound in this case */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25884
diff
changeset
|
632 | purple_debug_error("sound", "The file: (%s) %s\n from theme: %s, was not found or wasn't readable\n", |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
633 | sounds[event].pref, filename, theme_name); |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
634 | g_free(filename); |
|
28542
4868e1836159
Fix fallback to default sounds when the file isn't found.
Daniel Atallah <datallah@pidgin.im>
parents:
27952
diff
changeset
|
635 | filename = NULL; |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
636 | } |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
637 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25884
diff
changeset
|
638 | |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
639 | if (!filename || !strlen(filename)) { /* Use Default sounds */ |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
640 | g_free(filename); |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
641 | |
| 18292 | 642 | /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ |
| 643 | filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
| 5684 | 644 | } |
| 645 | ||
| 15884 | 646 | purple_sound_play_file(filename, NULL); |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
647 | |
| 5684 | 648 | g_free(filename); |
| 649 | } | |
| 650 | ||
| 651 | g_free(enable_pref); | |
| 652 | g_free(file_pref); | |
| 653 | } | |
| 654 | ||
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25884
diff
changeset
|
655 | gboolean |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
656 | pidgin_sound_is_customized(void) |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
657 | { |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25884
diff
changeset
|
658 | gint i; |
|
28545
06aa1af52d1c
Avoid an unnecessary alloc/free.
Daniel Atallah <datallah@pidgin.im>
parents:
28542
diff
changeset
|
659 | gchar *path; |
|
06aa1af52d1c
Avoid an unnecessary alloc/free.
Daniel Atallah <datallah@pidgin.im>
parents:
28542
diff
changeset
|
660 | const char *file; |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
661 | |
|
25884
c00e14c20165
* Alphabetize files in a few Makefile.am files
Mark Doliner <markdoliner@pidgin.im>
parents:
24952
diff
changeset
|
662 | for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
663 | path = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[i].pref); |
|
28545
06aa1af52d1c
Avoid an unnecessary alloc/free.
Daniel Atallah <datallah@pidgin.im>
parents:
28542
diff
changeset
|
664 | file = purple_prefs_get_path(path); |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
665 | g_free(path); |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
666 | |
|
28545
06aa1af52d1c
Avoid an unnecessary alloc/free.
Daniel Atallah <datallah@pidgin.im>
parents:
28542
diff
changeset
|
667 | if (file && file[0] != '\0') |
|
23649
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
668 | return TRUE; |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
669 | } |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
670 | |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
671 | return FALSE; |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
672 | |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
673 | } |
|
5da5fe967d10
Working sound themes (option 1) theme is saved in prefs and there is no seperate custom theme, everything
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23314
diff
changeset
|
674 | |
| 15884 | 675 | static PurpleSoundUiOps sound_ui_ops = |
| 5684 | 676 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
677 | pidgin_sound_init, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
678 | pidgin_sound_uninit, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
679 | 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
|
680 | 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
|
681 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
682 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
683 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
684 | NULL |
| 5684 | 685 | }; |
| 686 | ||
| 15884 | 687 | PurpleSoundUiOps * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
688 | pidgin_sound_get_ui_ops(void) |
| 5684 | 689 | { |
| 690 | return &sound_ui_ops; | |
| 691 | } |