Mercurial > pidgin
annotate pidgin/gtksound.c @ 23119:2498242c7af7
Make pidgin_set_custom_buddy_icon use the
purple_buddy_icons_node_set_custom_icon_from_file convenience function.
Also, I noticed that the custom buddy icons (which are set on contacts) were
being converted according to the prpl icon specifications of whichever buddy
in the contact was used in the pidgin_set_custom_buddy_icon call, since I have
no earthly idea why we would want to do that I'm dropping it.
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Thu, 15 May 2008 03:26:46 +0000 |
parents | 5b27a807abf9 |
children | fb87b6d77543 |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file gtksound.c GTK+ Sound |
16193
247e421c4fa6
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@wiktel.com>
parents:
16101
diff
changeset
|
3 * @ingroup pidgin |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* pidgin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15862
diff
changeset
|
8 * Pidgin is the legal property of its developers, whose names are too numerous |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19672
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "internal.h" |
15513 | 28 #include "pidgin.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include <windows.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include <mmsystem.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 # include <gst/gst.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #endif /* USE_GSTREAMER */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 #include "sound.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 #include "gtkconv.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 #include "gtksound.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
15819
c02a897a67c7
More Gaim to Pidgin changes
Sean Egan <seanegan@gmail.com>
parents:
15587
diff
changeset
|
48 struct pidgin_sound_event { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 char *label; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 char *pref; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 char *def; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 static guint mute_login_sounds_timeout = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 static gboolean mute_login_sounds = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 static gboolean gst_init_failed; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 #endif /* USE_GSTREAMER */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
20342
diff
changeset
|
61 static const struct pidgin_sound_event sounds[PURPLE_NUM_SOUNDS] = { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 {N_("Buddy logs in"), "login", "login.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 {N_("Buddy logs out"), "logout", "logout.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 {N_("Message received"), "im_recv", "receive.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 {N_("Message sent"), "send_im", "send.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 {N_("Person enters chat"), "join_chat", "login.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 {N_("Person leaves chat"), "left_chat", "logout.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 {N_("You talk in chat"), "send_chat_msg", "send.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 {NULL, "pounce_default", "alert.wav"}, |
22794
cc8903c59d6b
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <mark@kingant.net>
parents:
22495
diff
changeset
|
73 {N_("Someone says your username in chat"), "nick_said", "alert.wav"} |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 unmute_login_sounds_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 mute_login_sounds = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 mute_login_sounds_timeout = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 static gboolean |
15822 | 85 chat_nick_matches_name(PurpleConversation *conv, const char *aname) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 { |
15822 | 87 PurpleConvChat *chat = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 char *nick = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 char *name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 gboolean ret = FALSE; |
15822 | 91 chat = purple_conversation_get_chat_data(conv); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 if (chat==NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 |
15822 | 96 nick = g_strdup(purple_normalize(conv->account, chat->nick)); |
97 name = g_strdup(purple_normalize(conv->account, aname)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 if (g_utf8_collate(nick, name) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 ret = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 g_free(nick); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 g_free(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 * play a sound event for a conversation, honoring make_sound flag |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 * of conversation and checking for focus if conv_focus pref is set |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 static void |
15822 | 113 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 /* If we should not play the sound for some reason, then exit early */ |
19414
3d42c005fc17
Make sure a conversation is a pidgin-conversation to avoid a crash.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19384
diff
changeset
|
116 if (conv != NULL && PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 { |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
118 PidginConversation *gtkconv; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 gboolean has_focus; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
121 gtkconv = PIDGIN_CONVERSATION(conv); |
15822 | 122 has_focus = purple_conversation_has_focus(conv); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 if (!gtkconv->make_sound || |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
125 (has_focus && !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus"))) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 |
15822 | 131 purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 static void |
15822 | 135 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 { |
15822 | 137 purple_sound_play_event(event, purple_buddy_get_account(buddy)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 static void |
15822 | 141 im_msg_received_cb(PurpleAccount *account, char *sender, |
142 char *message, PurpleConversation *conv, | |
143 PurpleMessageFlags flags, PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 { |
15822 | 145 if (flags & PURPLE_MESSAGE_DELAYED) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 if (conv==NULL) |
15822 | 149 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 static void |
15822 | 155 im_msg_sent_cb(PurpleAccount *account, const char *receiver, |
156 const char *message, PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 { |
15822 | 158 PurpleConversation *conv = purple_find_conversation_with_account( |
159 PURPLE_CONV_TYPE_ANY, receiver, account); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 static void |
15822 | 164 chat_buddy_join_cb(PurpleConversation *conv, const char *name, |
165 PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
166 PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 if (new_arrival && !chat_nick_matches_name(conv, name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 static void |
15822 | 173 chat_buddy_left_cb(PurpleConversation *conv, const char *name, |
174 const char *reason, PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 if (!chat_nick_matches_name(conv, name)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 static void |
15822 | 181 chat_msg_sent_cb(PurpleAccount *account, const char *message, |
182 int id, PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 { |
15822 | 184 PurpleConnection *conn = purple_account_get_connection(account); |
185 PurpleConversation *conv = NULL; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 if (conn!=NULL) |
15822 | 188 conv = purple_find_chat(conn,id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 static void |
15822 | 194 chat_msg_received_cb(PurpleAccount *account, char *sender, |
195 char *message, PurpleConversation *conv, | |
196 PurpleMessageFlags flags, PurpleSoundEventID event) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 { |
15822 | 198 PurpleConvChat *chat; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 |
15822 | 200 if (flags & PURPLE_MESSAGE_DELAYED) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 |
15822 | 203 chat = purple_conversation_get_chat_data(conv); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 g_return_if_fail(chat != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 |
15822 | 206 if (purple_conv_chat_is_user_ignored(chat, sender)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 if (chat_nick_matches_name(conv, sender)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 |
15822 | 212 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) |
213 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 play_conv_event(conv, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 * We mute sounds for the 10 seconds after you log in so that |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 * you don't get flooded with sounds when the blist shows all |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 * your buddies logging in. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 static void |
15822 | 224 account_signon_cb(PurpleConnection *gc, gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 if (mute_login_sounds_timeout != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 g_source_remove(mute_login_sounds_timeout); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 mute_login_sounds = TRUE; |
15822 | 229 mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 const char * |
15822 | 233 pidgin_sound_get_event_option(PurpleSoundEventID event) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 { |
15822 | 235 if(event >= PURPLE_NUM_SOUNDS) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 return sounds[event].pref; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 const char * |
15822 | 242 pidgin_sound_get_event_label(PurpleSoundEventID event) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 { |
15822 | 244 if(event >= PURPLE_NUM_SOUNDS) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 return sounds[event].label; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 void * |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
251 pidgin_sound_get_handle() |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 static int handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 static void |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
259 pidgin_sound_init(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 { |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
261 void *gtk_sound_handle = pidgin_sound_get_handle(); |
15822 | 262 void *blist_handle = purple_blist_get_handle(); |
263 void *conv_handle = purple_conversations_get_handle(); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
15822 | 268 purple_signal_connect(purple_connections_get_handle(), "signed-on", |
269 gtk_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
272 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound"); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
273 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/enabled"); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
274 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/file"); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
275 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/login", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
276 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/login", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
277 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/logout", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
278 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/logout", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
279 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/im_recv", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
280 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/im_recv", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
281 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
282 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/first_im_recv", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
283 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_im", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
284 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_im", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
285 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/join_chat", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
286 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/join_chat", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
287 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/left_chat", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
288 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/left_chat", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
289 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
290 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_chat_msg", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
291 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
292 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
293 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
294 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
295 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
296 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
297 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
298 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
299 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", ""); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
300 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic"); |
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
301 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 #ifdef USE_GSTREAMER |
15822 | 304 purple_debug_info("sound", "Initializing sound output drivers.\n"); |
22495
5c216e2c5405
Revert the dependency on gstreamer-0.10 >= 0.10.10, falling back to the SIGALRM
Will Thompson <will.thompson@collabora.co.uk>
parents:
22427
diff
changeset
|
305 #ifdef GST_CAN_DISABLE_FORKING |
22427
eab5bc54e163
Tell gstreamer not to fork; remove the SIGCHLD -> SIGALRM hack, which made
Will Thompson <will.thompson@collabora.co.uk>
parents:
21054
diff
changeset
|
306 gst_registry_fork_set_enabled (FALSE); |
22495
5c216e2c5405
Revert the dependency on gstreamer-0.10 >= 0.10.10, falling back to the SIGALRM
Will Thompson <will.thompson@collabora.co.uk>
parents:
22427
diff
changeset
|
307 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { |
15822 | 309 purple_notify_error(NULL, _("GStreamer Failure"), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 _("GStreamer failed to initialize."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 error ? error->message : ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 if (error) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 #endif /* USE_GSTREAMER */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
15822 | 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)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 static void |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
346 pidgin_sound_uninit(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 if (!gst_init_failed) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 gst_deinit(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 |
15822 | 353 purple_signals_disconnect_by_handle(pidgin_sound_get_handle()); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 bus_call (GstBus *bus, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 GstMessage *msg, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 GstElement *play = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 GError *err = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 switch (GST_MESSAGE_TYPE (msg)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 case GST_MESSAGE_ERROR: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 gst_message_parse_error(msg, &err, NULL); |
17623
177ff4b22285
Improve the formatting of some gstreamer error messages. Someone
Mark Doliner <mark@kingant.net>
parents:
17038
diff
changeset
|
368 purple_debug_error("gstreamer", "%s\n", err->message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 g_error_free(err); |
19384
630938110521
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@gmail.com>
parents:
19115
diff
changeset
|
370 /* fall-through and clean up */ |
630938110521
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@gmail.com>
parents:
19115
diff
changeset
|
371 case GST_MESSAGE_EOS: |
630938110521
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@gmail.com>
parents:
19115
diff
changeset
|
372 gst_element_set_state(play, GST_STATE_NULL); |
630938110521
Cleanup playbin on error. Thanks, Elliott Sales de Andrade. Fixes #2663
Sean Egan <seanegan@gmail.com>
parents:
19115
diff
changeset
|
373 gst_object_unref(GST_OBJECT(play)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 case GST_MESSAGE_WARNING: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 gst_message_parse_warning(msg, &err, NULL); |
17624
b6145c9b6483
I left off a comma. My bad!
Mark Doliner <mark@kingant.net>
parents:
17623
diff
changeset
|
377 purple_debug_warning("gstreamer", "%s\n", err->message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 g_error_free(err); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
387 #ifndef _WIN32 |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
388 static gboolean |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
389 expire_old_child(gpointer data) |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
390 { |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
391 pid_t pid = GPOINTER_TO_INT(data); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
392 |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
393 if (waitpid(pid, NULL, WNOHANG | WUNTRACED) < 0) { |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
394 if (errno == ECHILD) |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
395 return FALSE; |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
396 else |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
397 purple_debug_warning("gtksound", "Child is ill, pid: %d (%s)\n", pid, strerror(errno)); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
398 } |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
399 |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
400 if (kill(pid, SIGKILL) < 0) |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
401 purple_debug_error("gtksound", "Killing process %d failed (%s)\n", pid, strerror(errno)); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
402 |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
403 return FALSE; |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
404 } |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
405 #endif |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
406 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 static void |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
408 pidgin_sound_play_file(const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 const char *method; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 float volume; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 char *uri; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 GstElement *sink = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 GstElement *play = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 GstBus *bus = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
419 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
422 method = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 if (!strcmp(method, "none")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 } else if (!strcmp(method, "beep")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 gdk_beep(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
15822 | 432 purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 if (!strcmp(method, "custom")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 const char *sound_cmd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 char *command; |
16895
64b7d4ebd2b2
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16673
diff
changeset
|
440 char *esc_filename; |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
441 char **argv = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 GError *error = NULL; |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
443 GPid pid; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
445 sound_cmd = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/sound/command"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 if (!sound_cmd || *sound_cmd == '\0') { |
15822 | 448 purple_debug_error("gtksound", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 "'Command' sound method has been chosen, " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 "but no command has been set."); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 |
16910
ba47cfaa013b
Let glib handle quoting filenames for shell, it'll escape other quotes as needed.
Casey Harkins <charkins@pidgin.im>
parents:
16895
diff
changeset
|
454 esc_filename = g_shell_quote(filename); |
16895
64b7d4ebd2b2
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16673
diff
changeset
|
455 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 if(strstr(sound_cmd, "%s")) |
16895
64b7d4ebd2b2
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16673
diff
changeset
|
457 command = purple_strreplace(sound_cmd, "%s", esc_filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 else |
16895
64b7d4ebd2b2
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16673
diff
changeset
|
459 command = g_strdup_printf("%s %s", sound_cmd, esc_filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
461 if (!g_shell_parse_argv(command, NULL, &argv, &error)) { |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
462 purple_debug_error("gtksound", "error parsing command %s (%s)\n", |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
463 command, error->message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 g_error_free(error); |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
465 g_free(esc_filename); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
466 g_free(command); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
467 return; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 |
22863
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
470 if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
471 NULL, NULL, &pid, &error)) { |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
472 purple_debug_error("gtksound", "sound command could not be launched: %s\n", |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
473 error->message); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
474 g_error_free(error); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
475 } else { |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
476 purple_timeout_add_seconds(15, expire_old_child, GINT_TO_POINTER(pid)); |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
477 } |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
478 |
56a38b60576e
Kill off sound playing child processes if they are still around after 15
Stu Tomlinson <stu@nosnilmot.com>
parents:
22794
diff
changeset
|
479 g_strfreev(argv); |
16895
64b7d4ebd2b2
Escape filename when using the command sound method. Fixes ticket #607.
Casey Harkins <charkins@pidgin.im>
parents:
16673
diff
changeset
|
480 g_free(esc_filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 g_free(command); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 } |
19672
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
484 #endif /* _WIN32 */ |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
485 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 #ifdef USE_GSTREAMER |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 if (gst_init_failed) /* Perhaps do gdk_beep instead? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 return; |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
489 volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 if (!strcmp(method, "automatic")) { |
15822 | 491 if (purple_running_gnome()) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 sink = gst_element_factory_make("gconfaudiosink", "sink"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 if (!sink) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 sink = gst_element_factory_make("autoaudiosink", "sink"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 if (!sink) { |
15822 | 497 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 } |
19672
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
500 } |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
501 #ifndef _WIN32 |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
502 else if (!strcmp(method, "esd")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 sink = gst_element_factory_make("esdsink", "sink"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 if (!sink) { |
15822 | 505 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 } |
17038
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
508 } else if (!strcmp(method, "alsa")) { |
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
509 sink = gst_element_factory_make("alsasink", "sink"); |
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
510 if (!sink) { |
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
511 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); |
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
512 return; |
5a308f09c871
ALSA Gstreamer sink. Mostly to see if this still crashes Luke.
Sean Egan <seanegan@gmail.com>
parents:
16947
diff
changeset
|
513 } |
19672
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
514 } |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
515 #endif |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
516 else { |
15822 | 517 purple_debug_error("sound", "Unknown sound method '%s'\n", method); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 play = gst_element_factory_make("playbin", "play"); |
21054
901b3e13c633
Remove unused definition.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21015
diff
changeset
|
522 |
16101
cbb2ee5464b4
Fix a possible gstreamer crash
Sean Egan <seanegan@gmail.com>
parents:
16062
diff
changeset
|
523 if (play == NULL) { |
cbb2ee5464b4
Fix a possible gstreamer crash
Sean Egan <seanegan@gmail.com>
parents:
16062
diff
changeset
|
524 return; |
cbb2ee5464b4
Fix a possible gstreamer crash
Sean Egan <seanegan@gmail.com>
parents:
16062
diff
changeset
|
525 } |
21054
901b3e13c633
Remove unused definition.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21015
diff
changeset
|
526 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 uri = g_strdup_printf("file://%s", filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 g_object_set(G_OBJECT(play), "uri", uri, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 "volume", volume, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 "audio-sink", sink, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 bus = gst_pipeline_get_bus(GST_PIPELINE(play)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 gst_bus_add_watch(bus, bus_call, play); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 gst_element_set_state(play, GST_STATE_PLAYING); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 gst_object_unref(bus); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 g_free(uri); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 |
22904
5b27a807abf9
Clarify #ifdef/#else/#endif matching; References #5770.
Ethan Blanton <elb@pidgin.im>
parents:
22863
diff
changeset
|
541 #else /* #ifdef USE_GSTREAMER */ |
19672
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
542 |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
543 #ifndef _WIN32 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 gdk_beep(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 #else /* _WIN32 */ |
15822 | 546 purple_debug_info("sound", "Playing %s\n", filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 wchar_t *wc_filename = g_utf8_to_utf16(filename, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 -1, NULL, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) |
15822 | 552 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 g_free(wc_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 char *l_filename = g_locale_from_utf8(filename, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 -1, NULL, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) |
15822 | 558 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 g_free(l_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 #endif /* _WIN32 */ |
19672
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
562 |
0914ce0f3e0e
Don't assume that the Gstreamer stuff isn't used on win32. There really isn't anything to see here.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19414
diff
changeset
|
563 #endif /* USE_GSTREAMER */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 static void |
15822 | 567 pidgin_sound_play_event(PurpleSoundEventID event) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 char *enable_pref; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 char *file_pref; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 |
15822 | 572 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 |
15822 | 575 if (event >= PURPLE_NUM_SOUNDS) { |
576 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
580 enable_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/enabled/%s", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 sounds[event].pref); |
16062
07554cc5d090
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents:
15870
diff
changeset
|
582 file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 /* check NULL for sounds that don't have an option, ie buddy pounce */ |
15822 | 585 if (purple_prefs_get_bool(enable_pref)) { |
586 char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 if(!filename || !strlen(filename)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 g_free(filename); |
19115 | 589 /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ |
590 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 |
15822 | 593 purple_sound_play_file(filename, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 g_free(enable_pref); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 g_free(file_pref); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 |
15822 | 601 static PurpleSoundUiOps sound_ui_ops = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 { |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
603 pidgin_sound_init, |
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
604 pidgin_sound_uninit, |
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
605 pidgin_sound_play_file, |
16673
fbf111436896
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16193
diff
changeset
|
606 pidgin_sound_play_event, |
fbf111436896
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16193
diff
changeset
|
607 NULL, |
fbf111436896
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16193
diff
changeset
|
608 NULL, |
fbf111436896
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16193
diff
changeset
|
609 NULL, |
fbf111436896
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16193
diff
changeset
|
610 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 |
15822 | 613 PurpleSoundUiOps * |
15500
d75099d2567e
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents:
15373
diff
changeset
|
614 pidgin_sound_get_ui_ops(void) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 return &sound_ui_ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 } |