Wed, 13 May 2009 20:29:03 +0000
Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16860
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 1 | 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" |
|
24378
cb0bf512e61d
renamed sound-loader.[ch] to sound-theme-loader.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
23655
diff
changeset
|
28 | #include "sound-theme-loader.h" |
|
23655
704a67a69ce0
Changed the theme_manager_init function to do less, makes it cleaner and faster (won't have to build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
19859
diff
changeset
|
29 | #include "theme-manager.h" |
| 1 | 30 | |
| 15884 | 31 | static PurpleSoundUiOps *sound_ui_ops = NULL; |
| 3319 | 32 | |
| 14936 | 33 | #define STATUS_AVAILABLE 1 |
| 34 | #define STATUS_AWAY 2 | |
| 35 | ||
|
16860
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
36 | static time_t last_played[PURPLE_NUM_SOUNDS]; |
|
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
37 | |
| 14936 | 38 | static gboolean |
| 15884 | 39 | purple_sound_play_required(const PurpleAccount *account) |
| 14936 | 40 | { |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
41 | gint pref_status = purple_prefs_get_int("/purple/sound/while_status"); |
| 14936 | 42 | |
| 43 | if (pref_status == 3) | |
| 44 | { | |
| 45 | /* Play sounds: Always */ | |
| 46 | return TRUE; | |
| 47 | } | |
| 48 | ||
| 49 | if (account != NULL) | |
| 50 | { | |
| 15884 | 51 | PurpleStatus *status = purple_account_get_active_status(account); |
| 14936 | 52 | |
| 15884 | 53 | if (purple_status_is_online(status)) |
| 14936 | 54 | { |
| 15884 | 55 | gboolean available = purple_status_is_available(status); |
| 14936 | 56 | return (( available && pref_status == STATUS_AVAILABLE) || |
| 57 | (!available && pref_status == STATUS_AWAY)); | |
| 58 | } | |
| 59 | } | |
| 60 | ||
| 61 | /* We get here a couple of ways. Either the request has been OK'ed | |
| 15884 | 62 | * by purple_sound_play_event() and we're here because the UI has |
| 63 | * called purple_sound_play_file(), or we're here for something | |
| 14936 | 64 | * not related to an account (like testing a sound). */ |
| 65 | return TRUE; | |
| 66 | } | |
| 67 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
68 | void |
| 15884 | 69 | purple_sound_play_file(const char *filename, const PurpleAccount *account) |
| 5684 | 70 | { |
| 15884 | 71 | if (!purple_sound_play_required(account)) |
| 14936 | 72 | return; |
|
4430
95df701e8cdf
[gaim-migrate @ 4705]
Robert McQueen <robot101@debian.org>
parents:
4429
diff
changeset
|
73 | |
| 5684 | 74 | if(sound_ui_ops && sound_ui_ops->play_file) |
| 75 | sound_ui_ops->play_file(filename); | |
|
1006
fb2f2a403962
[gaim-migrate @ 1016]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
899
diff
changeset
|
76 | } |
|
fb2f2a403962
[gaim-migrate @ 1016]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
899
diff
changeset
|
77 | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
78 | void |
| 15884 | 79 | purple_sound_play_event(PurpleSoundEventID event, const PurpleAccount *account) |
| 1 | 80 | { |
| 15884 | 81 | if (!purple_sound_play_required(account)) |
| 14936 | 82 | return; |
| 4561 | 83 | |
|
16860
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
84 | if (time(NULL) - last_played[event] < 2) |
|
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
85 | return; |
|
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
86 | last_played[event] = time(NULL); |
|
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
87 | |
| 12291 | 88 | if(sound_ui_ops && sound_ui_ops->play_event) { |
| 89 | int plugin_return; | |
| 90 | ||
| 15884 | 91 | plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( |
| 92 | purple_sounds_get_handle(), "playing-sound-event", | |
| 12291 | 93 | event, account)); |
| 94 | ||
| 95 | if (plugin_return) | |
| 96 | return; | |
| 97 | else | |
| 98 | sound_ui_ops->play_event(event); | |
| 99 | } | |
| 4561 | 100 | } |
|
10322
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 | void |
| 15884 | 103 | purple_sound_set_ui_ops(PurpleSoundUiOps *ops) |
|
10322
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 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
106 | sound_ui_ops->uninit(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
107 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
108 | sound_ui_ops = ops; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
109 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
110 | if(sound_ui_ops && sound_ui_ops->init) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
111 | sound_ui_ops->init(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
112 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
113 | |
| 15884 | 114 | PurpleSoundUiOps * |
| 115 | purple_sound_get_ui_ops(void) | |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
116 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
117 | return sound_ui_ops; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
118 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
119 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
120 | void |
| 15884 | 121 | purple_sound_init() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
122 | { |
| 15884 | 123 | void *handle = purple_sounds_get_handle(); |
| 12291 | 124 | |
| 125 | /********************************************************************** | |
| 126 | * Register signals | |
| 127 | **********************************************************************/ | |
| 128 | ||
| 15884 | 129 | purple_signal_register(handle, "playing-sound-event", |
| 130 | purple_marshal_BOOLEAN__INT_POINTER, | |
| 131 | purple_value_new(PURPLE_TYPE_BOOLEAN), 2, | |
| 132 | purple_value_new(PURPLE_TYPE_INT), | |
| 133 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 134 | PURPLE_SUBTYPE_ACCOUNT)); | |
| 12291 | 135 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
136 | purple_prefs_add_none("/purple/sound"); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
137 | purple_prefs_add_int("/purple/sound/while_status", STATUS_AVAILABLE); |
|
16860
e4359f0477c8
Don't play the same sound twice within 2 seconds. Maybe this will fix Luke's gst problems. It fixes #140 in either case
Sean Egan <seanegan@pidgin.im>
parents:
16478
diff
changeset
|
138 | memset(last_played, 0, sizeof(last_played)); |
|
23655
704a67a69ce0
Changed the theme_manager_init function to do less, makes it cleaner and faster (won't have to build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
19859
diff
changeset
|
139 | |
|
704a67a69ce0
Changed the theme_manager_init function to do less, makes it cleaner and faster (won't have to build
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
19859
diff
changeset
|
140 | purple_theme_manager_register_type(g_object_new(PURPLE_TYPE_SOUND_THEME_LOADER, "type", "sound", NULL)); |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
141 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
142 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
143 | void |
| 15884 | 144 | purple_sound_uninit() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
145 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
146 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
147 | sound_ui_ops->uninit(); |
| 12291 | 148 | |
| 15884 | 149 | purple_signals_unregister_by_instance(purple_sounds_get_handle()); |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
150 | } |
| 12291 | 151 | |
| 152 | void * | |
| 15884 | 153 | purple_sounds_get_handle() |
| 12291 | 154 | { |
| 155 | static int handle; | |
| 156 | ||
| 157 | return &handle; | |
| 158 | } |