Mercurial > pidgin.yaz
annotate src/sound.c @ 13770:9df4a46b0bb3
[gaim-migrate @ 16182]
SF Patch #1460287 from Jrme Poulin (ticpu), with a bug fix by Sadrul
Currently, with a string like "vnc://ticpu.myftp.org:1/", the "ftp.org:1/"
portion will be linkified as an FTP URL. This patch corrects that.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 12 May 2006 21:50:19 +0000 |
parents | 5bc3d67ceb24 |
children |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
1 | 7 * |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
23 #include "internal.h" |
3630 | 24 |
10322 | 25 #include "blist.h" |
26 #include "prefs.h" | |
4561 | 27 #include "sound.h" |
1 | 28 |
5684 | 29 static GaimSoundUiOps *sound_ui_ops = NULL; |
3319 | 30 |
10322 | 31 void |
11642 | 32 gaim_sound_play_file(const char *filename, const GaimAccount *account) |
5684 | 33 { |
11642 | 34 GaimStatus *status; |
35 | |
11652 | 36 if ((account != NULL) && (!gaim_prefs_get_bool("/core/sound/while_away"))) |
11642 | 37 { |
38 status = gaim_account_get_active_status(account); | |
39 if (gaim_status_is_online(status) && !gaim_status_is_available(status)) | |
40 return; | |
41 } | |
4430 | 42 |
5684 | 43 if(sound_ui_ops && sound_ui_ops->play_file) |
44 sound_ui_ops->play_file(filename); | |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
45 } |
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
899
diff
changeset
|
46 |
10322 | 47 void |
11642 | 48 gaim_sound_play_event(GaimSoundEventID event, const GaimAccount *account) |
1 | 49 { |
11642 | 50 GaimStatus *status; |
51 | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
52 if ((account != NULL) && |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
53 (!gaim_prefs_get_bool("/core/sound/while_away"))) |
11642 | 54 { |
55 status = gaim_account_get_active_status(account); | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
56 if (gaim_status_is_online(status) && |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
57 !gaim_status_is_available(status)) |
11642 | 58 return; |
59 } | |
4561 | 60 |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
61 if(sound_ui_ops && sound_ui_ops->play_event) { |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
62 int plugin_return; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
63 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
64 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
65 gaim_sounds_get_handle(), "playing-sound-event", |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
66 event, account)); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
67 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
68 if (plugin_return) |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
69 return; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
70 else |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
71 sound_ui_ops->play_event(event); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
72 } |
4561 | 73 } |
10322 | 74 |
75 void | |
76 gaim_sound_set_ui_ops(GaimSoundUiOps *ops) | |
77 { | |
78 if(sound_ui_ops && sound_ui_ops->uninit) | |
79 sound_ui_ops->uninit(); | |
80 | |
81 sound_ui_ops = ops; | |
82 | |
83 if(sound_ui_ops && sound_ui_ops->init) | |
84 sound_ui_ops->init(); | |
85 } | |
86 | |
87 GaimSoundUiOps * | |
88 gaim_sound_get_ui_ops(void) | |
89 { | |
90 return sound_ui_ops; | |
91 } | |
92 | |
93 void | |
94 gaim_sound_init() | |
95 { | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
96 void *handle = gaim_sounds_get_handle(); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
97 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
98 /********************************************************************** |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
99 * Register signals |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
100 **********************************************************************/ |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
101 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
102 gaim_signal_register(handle, "playing-sound-event", |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
103 gaim_marshal_BOOLEAN__INT_POINTER, |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
104 gaim_value_new(GAIM_TYPE_BOOLEAN), 2, |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
105 gaim_value_new(GAIM_TYPE_INT), |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
106 gaim_value_new(GAIM_TYPE_POINTER)); |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
107 |
10322 | 108 gaim_prefs_add_none("/core/sound"); |
109 gaim_prefs_add_bool("/core/sound/while_away", FALSE); | |
110 | |
111 } | |
112 | |
113 void | |
114 gaim_sound_uninit() | |
115 { | |
116 if(sound_ui_ops && sound_ui_ops->uninit) | |
117 sound_ui_ops->uninit(); | |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
118 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
119 gaim_signals_unregister_by_instance(gaim_sounds_get_handle()); |
10322 | 120 } |
12291
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
121 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
122 void * |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
123 gaim_sounds_get_handle() |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
124 { |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
125 static int handle; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
126 |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
127 return &handle; |
5bc3d67ceb24
[gaim-migrate @ 14595]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11652
diff
changeset
|
128 } |