Mon, 19 Mar 2007 07:01:17 +0000
sed -ie 's/gaim/purple/g'
| 1 | 1 | /* |
| 15884 | 2 | * purple |
| 1 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
23 | #include "internal.h" |
| 3630 | 24 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
25 | #include "blist.h" |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
26 | #include "prefs.h" |
| 4561 | 27 | #include "sound.h" |
| 1 | 28 | |
| 15884 | 29 | static PurpleSoundUiOps *sound_ui_ops = NULL; |
| 3319 | 30 | |
| 14936 | 31 | #define STATUS_AVAILABLE 1 |
| 32 | #define STATUS_AWAY 2 | |
| 33 | ||
| 34 | static gboolean | |
| 15884 | 35 | purple_sound_play_required(const PurpleAccount *account) |
| 14936 | 36 | { |
| 15884 | 37 | gint pref_status = purple_prefs_get_int("/core/sound/while_status"); |
| 14936 | 38 | |
| 39 | if (pref_status == 3) | |
| 40 | { | |
| 41 | /* Play sounds: Always */ | |
| 42 | return TRUE; | |
| 43 | } | |
| 44 | ||
| 45 | if (account != NULL) | |
| 46 | { | |
| 15884 | 47 | PurpleStatus *status = purple_account_get_active_status(account); |
| 14936 | 48 | |
| 15884 | 49 | if (purple_status_is_online(status)) |
| 14936 | 50 | { |
| 15884 | 51 | gboolean available = purple_status_is_available(status); |
| 14936 | 52 | return (( available && pref_status == STATUS_AVAILABLE) || |
| 53 | (!available && pref_status == STATUS_AWAY)); | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 57 | /* We get here a couple of ways. Either the request has been OK'ed | |
| 15884 | 58 | * by purple_sound_play_event() and we're here because the UI has |
| 59 | * called purple_sound_play_file(), or we're here for something | |
| 14936 | 60 | * not related to an account (like testing a sound). */ |
| 61 | return TRUE; | |
| 62 | } | |
| 63 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
64 | void |
| 15884 | 65 | purple_sound_play_file(const char *filename, const PurpleAccount *account) |
| 5684 | 66 | { |
| 15884 | 67 | if (!purple_sound_play_required(account)) |
| 14936 | 68 | return; |
|
4430
95df701e8cdf
[gaim-migrate @ 4705]
Robert McQueen <robot101@debian.org>
parents:
4429
diff
changeset
|
69 | |
| 5684 | 70 | if(sound_ui_ops && sound_ui_ops->play_file) |
| 71 | sound_ui_ops->play_file(filename); | |
|
1006
fb2f2a403962
[gaim-migrate @ 1016]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
899
diff
changeset
|
72 | } |
|
fb2f2a403962
[gaim-migrate @ 1016]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
899
diff
changeset
|
73 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
74 | void |
| 15884 | 75 | purple_sound_play_event(PurpleSoundEventID event, const PurpleAccount *account) |
| 1 | 76 | { |
| 15884 | 77 | if (!purple_sound_play_required(account)) |
| 14936 | 78 | return; |
| 4561 | 79 | |
| 12291 | 80 | if(sound_ui_ops && sound_ui_ops->play_event) { |
| 81 | int plugin_return; | |
| 82 | ||
| 15884 | 83 | plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( |
| 84 | purple_sounds_get_handle(), "playing-sound-event", | |
| 12291 | 85 | event, account)); |
| 86 | ||
| 87 | if (plugin_return) | |
| 88 | return; | |
| 89 | else | |
| 90 | sound_ui_ops->play_event(event); | |
| 91 | } | |
| 4561 | 92 | } |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
93 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
94 | void |
| 15884 | 95 | purple_sound_set_ui_ops(PurpleSoundUiOps *ops) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
96 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
97 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
98 | sound_ui_ops->uninit(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
99 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
100 | sound_ui_ops = ops; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
101 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
102 | if(sound_ui_ops && sound_ui_ops->init) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
103 | sound_ui_ops->init(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
104 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
105 | |
| 15884 | 106 | PurpleSoundUiOps * |
| 107 | purple_sound_get_ui_ops(void) | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
108 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
109 | return sound_ui_ops; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
110 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
111 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
112 | void |
| 15884 | 113 | purple_sound_init() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
114 | { |
| 15884 | 115 | void *handle = purple_sounds_get_handle(); |
| 12291 | 116 | |
| 117 | /********************************************************************** | |
| 118 | * Register signals | |
| 119 | **********************************************************************/ | |
| 120 | ||
| 15884 | 121 | purple_signal_register(handle, "playing-sound-event", |
| 122 | purple_marshal_BOOLEAN__INT_POINTER, | |
| 123 | purple_value_new(PURPLE_TYPE_BOOLEAN), 2, | |
| 124 | purple_value_new(PURPLE_TYPE_INT), | |
| 125 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 126 | PURPLE_SUBTYPE_ACCOUNT)); | |
| 12291 | 127 | |
| 15884 | 128 | purple_prefs_add_none("/core/sound"); |
| 129 | purple_prefs_add_int("/core/sound/while_status", STATUS_AVAILABLE); | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
130 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
131 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
132 | void |
| 15884 | 133 | purple_sound_uninit() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
134 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
135 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
136 | sound_ui_ops->uninit(); |
| 12291 | 137 | |
| 15884 | 138 | purple_signals_unregister_by_instance(purple_sounds_get_handle()); |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
139 | } |
| 12291 | 140 | |
| 141 | void * | |
| 15884 | 142 | purple_sounds_get_handle() |
| 12291 | 143 | { |
| 144 | static int handle; | |
| 145 | ||
| 146 | return &handle; | |
| 147 | } |