annotate src/sound.c @ 4562:2c8372d4fb2a

[gaim-migrate @ 4843] a few minor tweaks. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 09 Feb 2003 04:52:00 +0000
parents 9df99116840a
children 0ea6a4c53f38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4562
2c8372d4fb2a [gaim-migrate @ 4843]
Nathan Walp <nwalp@pidgin.im>
parents: 4561
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
5 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
23 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
24 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 338
diff changeset
25 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <stdio.h>
1057
d50d3abb9eb7 [gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1006
diff changeset
27 #include <stdlib.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <string.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
29
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
30 #ifndef _WIN32
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <sys/time.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <unistd.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <sys/wait.h>
63
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
34 #include <unistd.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
35 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
36 #include <windows.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
37 #include <mmsystem.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
38 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
39
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
40 #include <fcntl.h>
63
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
41 #include <sys/types.h>
12894b62d206 [gaim-migrate @ 73]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1
diff changeset
42 #include <sys/stat.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
44 #ifdef USE_AO
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
45 #include <ao/ao.h>
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
46 #include <audiofile.h>
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
47 #endif /* USE_AO */
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
48
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #include "gaim.h"
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
50 #include "sound.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51
4019
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
52 #ifdef _WIN32
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
53 #include "win32dep.h"
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
54 #endif
e53d9f9969d0 [gaim-migrate @ 4219]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4014
diff changeset
55
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
56 struct gaim_sound_event {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
57 char *label;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
58 guint opt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
59 char *def;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
60 };
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
61
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
62 #ifdef USE_AO
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
63 static int ao_driver;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
64 #endif /* USE_AO */
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
65
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
66
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
67 static gboolean mute_login_sounds = FALSE;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
68 static gboolean mute_sounds = FALSE;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
69 static char *sound_cmd = NULL;
3319
3a05fcb133c4 [gaim-migrate @ 3337]
Sean Egan <seanegan@gmail.com>
parents: 3284
diff changeset
70
4082
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
71 /* description, option bit, default sound file *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
72 * set the option bit to 0 to have it not display in prefs *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
73 * the order here has to match the defines in gaim.h. *
4b04ecb3eb97 [gaim-migrate @ 4297]
Luke Schierer <lschiere@pidgin.im>
parents: 4019
diff changeset
74 * -Robot101 */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
75 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = {
4013
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
76 {N_("Buddy logs in"), OPT_SOUND_LOGIN, "arrive.wav"},
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
77 {N_("Buddy logs out"), OPT_SOUND_LOGOUT, "leave.wav"},
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
78 {N_("Message received"), OPT_SOUND_RECV, "receive.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
79 {N_("Message received begins conversation"), OPT_SOUND_FIRST_RCV, "receive.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
80 {N_("Message sent"), OPT_SOUND_SEND, "send.wav"},
4013
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
81 {N_("Person enters chat"), OPT_SOUND_CHAT_JOIN, "arrive.wav"},
73853a0a1a77 [gaim-migrate @ 4213]
Sean Egan <seanegan@gmail.com>
parents: 4012
diff changeset
82 {N_("Person leaves chat"), OPT_SOUND_CHAT_PART, "leave.wav"},
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
83 {N_("You talk in chat"), OPT_SOUND_CHAT_YOU_SAY, "send.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
84 {N_("Others talk in chat"), OPT_SOUND_CHAT_SAY, "receive.wav"},
3326
03daf01a8000 [gaim-migrate @ 3344]
Jim Seymour <jseymour>
parents: 3319
diff changeset
85 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
4012
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
86 {NULL, 0, "redalert.wav"},
ab6c48a07fd6 [gaim-migrate @ 4212]
Sean Egan <seanegan@gmail.com>
parents: 4010
diff changeset
87 {N_("Someone says your name in chat"), OPT_SOUND_CHAT_NICK, "redalert.wav"}
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
88 };
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
89
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
90 static char *sound_file[GAIM_NUM_SOUNDS];
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
91
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
92 void gaim_sound_init()
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
93 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
94 #ifdef USE_AO
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
95
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
96 ao_initialize();
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
97 ao_driver = ao_default_driver_id();
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
98
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
99 if(ao_driver == -1) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
100 do_error_dialog(_("Sound Driver Not Found"),
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
101 _("Gaim was unable to load a sound driver. Sound files will "
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
102 "not be played."), GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
103 } else {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
104 ao_info *info = ao_driver_info(ao_driver);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
105 debug_printf("Sound output driver loaded: %s\n", info->name);
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
106 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
107
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
108 #endif
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
109 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
110
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
111 void gaim_sound_quit()
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
112 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
113 #ifdef USE_AO
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
114
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
115 ao_shutdown();
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
116
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
117 #endif
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
118 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
119
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
120 void gaim_sound_play_file(char *filename)
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
121 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
122 #ifdef USE_AO
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
123 pid_t pid;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
124 #endif /* USE_AO */
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
125
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
126 if (mute_sounds)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
127 return;
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
128
3901
7740c891537e [gaim-migrate @ 4054]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
129 if (awaymessage && !(sound_options & OPT_SOUND_WHEN_AWAY))
7740c891537e [gaim-migrate @ 4054]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
130 return; /* check here in case a buddy pounce plays a file while away */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
131
3004
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
132 if (sound_options & OPT_SOUND_BEEP) {
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
133 gdk_beep();
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
134 return;
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
135 }
bfd2b1ef907c [gaim-migrate @ 3017]
Sean Egan <seanegan@gmail.com>
parents: 2995
diff changeset
136
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
137 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
138 char *tmp = g_strdup_printf(_("Unable to play sound because the chosen filename (%s) does not exist."), filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
139 do_error_dialog(tmp, NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
140 g_free(tmp);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
141 return;
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
142 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
143
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
144 #ifndef _WIN32
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
145 if ((sound_options & OPT_SOUND_CMD)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
146 char *command;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
147 GError *error = NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
148
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
149 if(!sound_cmd) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
150 do_error_dialog(_("Unable to play sound because the 'Command' sound method has been chosen, but no command has been set."), NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
151 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
152 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
153
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
154 command = g_strdup_printf(sound_cmd, filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
155
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
156 if(!g_spawn_command_line_async(command, &error)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
157 char *tmp = g_strdup_printf(_("Unable to play sound because the configured sound command could not be launched: %s"), error->message);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
158 do_error_dialog(tmp, NULL, GAIM_ERROR);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
159 g_free(tmp);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
160 g_error_free(error);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
161 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
162
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
163 g_free(command);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
164 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
165 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
166 #ifdef USE_AO
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
167
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
168 if(ao_driver == -1) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
169 /* do _something_ audible ;-) */
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
170 gdk_beep();
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
171 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
172 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
173
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
174
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
175 pid = fork();
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
176
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
177 if (pid < 0)
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
178 return;
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
179 else if (pid == 0) {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
180 AFfilehandle file = afOpenFile(filename, "rb", NULL);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
181 if(file) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
182 ao_device *device;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
183 ao_sample_format format;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
184 int in_fmt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
185 int bytes_per_frame;
4429
bf770f11132b [gaim-migrate @ 4704]
Luke Schierer <lschiere@pidgin.im>
parents: 4082
diff changeset
186
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
187 format.rate = afGetRate(file, AF_DEFAULT_TRACK);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
188 format.channels = afGetChannels(file, AF_DEFAULT_TRACK);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
189 afGetSampleFormat(file, AF_DEFAULT_TRACK, &in_fmt,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
190 &format.bits);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
191
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
192 afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
193 AF_SAMPFMT_TWOSCOMP, format.bits);
4429
bf770f11132b [gaim-migrate @ 4704]
Luke Schierer <lschiere@pidgin.im>
parents: 4082
diff changeset
194
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
195 if(afGetByteOrder(file, AF_DEFAULT_TRACK) == AF_BYTEORDER_BIGENDIAN)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
196 format.byte_format = AO_FMT_BIG;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
197 else
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
198 format.byte_format = AO_FMT_LITTLE;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
199
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
200 bytes_per_frame = format.bits * format.channels / 8;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
201
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
202 device = ao_open_live(ao_driver, &format, NULL);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
203
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
204 if(device) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
205 int frames_read;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
206 char buf[4096];
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
207 int buf_frames = sizeof(buf) / bytes_per_frame;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
208
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
209 while((frames_read = afReadFrames(file, AF_DEFAULT_TRACK,
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
210 buf, buf_frames))) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
211 if(!ao_play(device, buf, frames_read * bytes_per_frame))
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
212 break;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
213 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
214 ao_close(device);
4562
2c8372d4fb2a [gaim-migrate @ 4843]
Nathan Walp <nwalp@pidgin.im>
parents: 4561
diff changeset
215 } else {
2c8372d4fb2a [gaim-migrate @ 4843]
Nathan Walp <nwalp@pidgin.im>
parents: 4561
diff changeset
216 debug_printf("error opening audio device!\n");
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
217 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
218 afCloseFile(file);
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
219 }
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
220 _exit(0);
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
221 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
222 #else /* USE_AO */
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
223 gdk_beep();
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
224 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
225 #endif /* USE_AO */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
226 #else /* _WIN32 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
227 debug_printf("Playing %s\n", filename);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
228 if (!PlaySound(filename, 0, SND_ASYNC | SND_FILENAME))
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3367
diff changeset
229 debug_printf("Error playing sound.");
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
230 #endif /* _WIN32 */
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
231 }
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
232
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
233 void gaim_sound_play_event(GaimSoundEventID event)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 {
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
235 if ((event == GAIM_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
236 return;
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
237
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
238 if (event >= GAIM_NUM_SOUNDS) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
239 debug_printf("got request for unknown sound: %d\n", event);
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
240 return;
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
241 }
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
242
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
243 /* check NULL for sounds that don't have an option, ie buddy pounce */
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
244 if ((sound_options & sounds[event].opt) || (sounds[event].opt == 0)) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
245 if (sound_file[event]) {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
246 gaim_sound_play_file(sound_file[event]);
3060
4f2f12bf4408 [gaim-migrate @ 3074]
Sean Egan <seanegan@gmail.com>
parents: 3025
diff changeset
247 } else {
4004
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
248 gchar *filename = NULL;
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
249
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
250 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
251 gaim_sound_play_file(filename);
4004
b2520034b62f [gaim-migrate @ 4204]
Sean Egan <seanegan@gmail.com>
parents: 3901
diff changeset
252 g_free(filename);
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 899
diff changeset
253 }
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1235
diff changeset
254 }
64
b1d7336cba85 [gaim-migrate @ 74]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 63
diff changeset
255 }
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
256
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
257 void gaim_sound_set_mute(gboolean mute)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
258 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
259 mute_sounds = mute;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
260 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
261
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
262 gboolean gaim_sound_get_mute()
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
263 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
264 return mute_sounds;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
265 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
266
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
267 void gaim_sound_set_login_mute(gboolean mute)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
268 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
269 mute_login_sounds = mute;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
270 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
271
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
272 void gaim_sound_set_event_file(GaimSoundEventID event, const char *filename)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
273 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
274 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
275 return;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
276
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
277 if(sound_file[event])
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
278 g_free(sound_file[event]);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
279
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
280 sound_file[event] = g_strdup(filename);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
281 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
282
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
283
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
284 char *gaim_sound_get_event_file(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
285 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
286 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
287 return NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
288
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
289 return sound_file[event];
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
290 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
291
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
292 guint gaim_sound_get_event_option(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
293 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
294 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
295 return 0;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
296
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
297 return sounds[event].opt;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
298 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
299
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
300 char *gaim_sound_get_event_label(GaimSoundEventID event)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
301 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
302 if(event >= GAIM_NUM_SOUNDS)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
303 return NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
304
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
305 return sounds[event].label;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
306 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
307
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
308
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
309 void gaim_sound_set_command(const char *cmd)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
310 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
311 if(sound_cmd)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
312 g_free(sound_cmd);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
313 if(strlen(cmd) > 0)
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
314 sound_cmd = g_strdup(cmd);
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
315 else
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
316 sound_cmd = NULL;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
317 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
318
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
319 char *gaim_sound_get_command()
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
320 {
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
321 return sound_cmd;
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
322 }
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
323