Sat, 12 Oct 2019 04:38:00 -0400
Rewrite fb_http_urlcmp using SoupURI.
| 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 | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
24378
diff
changeset
|
25 | #include "buddylist.h" |
|
10322
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; |
|
38584
9cde452b1bc6
Use monotonic time for UI-related timestamping.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37398
diff
changeset
|
32 | static gint64 last_played[PURPLE_NUM_SOUNDS]; |
|
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
|
33 | |
| 14936 | 34 | static gboolean |
|
39514
9c7715998bbc
Cleanup account.[ch] and status.[ch] to remove g_type_class_add_private and other cleans including remove const from accessors
Gary Kramlich <grim@reaperworld.com>
parents:
38584
diff
changeset
|
35 | purple_sound_play_required(PurpleAccount *account) |
| 14936 | 36 | { |
|
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
|
37 | gint pref_status = purple_prefs_get_int("/purple/sound/while_status"); |
| 14936 | 38 | |
|
37398
a9aa2aa0b1b6
Replace magic numbers on the sound API
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36083
diff
changeset
|
39 | if (pref_status == PURPLE_SOUND_STATUS_ALWAYS) |
| 14936 | 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); |
|
37398
a9aa2aa0b1b6
Replace magic numbers on the sound API
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36083
diff
changeset
|
52 | return (( available && pref_status == PURPLE_SOUND_STATUS_AVAILABLE) || |
|
a9aa2aa0b1b6
Replace magic numbers on the sound API
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36083
diff
changeset
|
53 | (!available && pref_status == PURPLE_SOUND_STATUS_AWAY)); |
| 14936 | 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 |
|
39514
9c7715998bbc
Cleanup account.[ch] and status.[ch] to remove g_type_class_add_private and other cleans including remove const from accessors
Gary Kramlich <grim@reaperworld.com>
parents:
38584
diff
changeset
|
65 | purple_sound_play_file(const char *filename, 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 |
|
39514
9c7715998bbc
Cleanup account.[ch] and status.[ch] to remove g_type_class_add_private and other cleans including remove const from accessors
Gary Kramlich <grim@reaperworld.com>
parents:
38584
diff
changeset
|
75 | purple_sound_play_event(PurpleSoundEventID event, PurpleAccount *account) |
| 1 | 76 | { |
| 15884 | 77 | if (!purple_sound_play_required(account)) |
| 14936 | 78 | return; |
| 4561 | 79 | |
| 36083 | 80 | g_return_if_fail(event < PURPLE_NUM_SOUNDS); |
| 81 | ||
|
38584
9cde452b1bc6
Use monotonic time for UI-related timestamping.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37398
diff
changeset
|
82 | if (g_get_monotonic_time() - last_played[event] < 2 * G_USEC_PER_SEC) |
|
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
|
83 | return; |
|
38584
9cde452b1bc6
Use monotonic time for UI-related timestamping.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37398
diff
changeset
|
84 | last_played[event] = g_get_monotonic_time(); |
|
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
|
85 | |
| 12291 | 86 | if(sound_ui_ops && sound_ui_ops->play_event) { |
| 87 | int plugin_return; | |
| 88 | ||
| 15884 | 89 | plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( |
| 90 | purple_sounds_get_handle(), "playing-sound-event", | |
| 12291 | 91 | event, account)); |
| 92 | ||
| 93 | if (plugin_return) | |
| 94 | return; | |
| 95 | else | |
| 96 | sound_ui_ops->play_event(event); | |
| 97 | } | |
| 4561 | 98 | } |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
99 | |
| 35572 | 100 | static PurpleSoundUiOps * |
| 101 | purple_sound_ui_ops_copy(PurpleSoundUiOps *ops) | |
| 102 | { | |
| 103 | PurpleSoundUiOps *ops_new; | |
| 104 | ||
| 105 | g_return_val_if_fail(ops != NULL, NULL); | |
| 106 | ||
| 107 | ops_new = g_new(PurpleSoundUiOps, 1); | |
| 108 | *ops_new = *ops; | |
| 109 | ||
| 110 | return ops_new; | |
| 111 | } | |
| 112 | ||
| 113 | GType | |
| 114 | purple_sound_ui_ops_get_type(void) | |
| 115 | { | |
| 116 | static GType type = 0; | |
| 117 | ||
| 118 | if (type == 0) { | |
| 119 | type = g_boxed_type_register_static("PurpleSoundUiOps", | |
| 120 | (GBoxedCopyFunc)purple_sound_ui_ops_copy, | |
|
35597
7fcfcf147b99
Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents:
35572
diff
changeset
|
121 | (GBoxedFreeFunc)g_free); |
| 35572 | 122 | } |
| 123 | ||
| 124 | return type; | |
| 125 | } | |
| 126 | ||
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
127 | void |
| 15884 | 128 | purple_sound_set_ui_ops(PurpleSoundUiOps *ops) |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
129 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
130 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
131 | sound_ui_ops->uninit(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
132 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
133 | sound_ui_ops = ops; |
|
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->init) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
136 | sound_ui_ops->init(); |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
137 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
138 | |
| 15884 | 139 | PurpleSoundUiOps * |
| 140 | purple_sound_get_ui_ops(void) | |
|
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 | return sound_ui_ops; |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
143 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
144 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
145 | void |
| 15884 | 146 | purple_sound_init() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
147 | { |
| 15884 | 148 | void *handle = purple_sounds_get_handle(); |
| 12291 | 149 | |
| 150 | /********************************************************************** | |
| 151 | * Register signals | |
| 152 | **********************************************************************/ | |
| 153 | ||
| 15884 | 154 | purple_signal_register(handle, "playing-sound-event", |
| 155 | purple_marshal_BOOLEAN__INT_POINTER, | |
|
34824
6868ad1739a3
Refactored dbus-server, signals, sound, status to use GType and GValue instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
156 | G_TYPE_BOOLEAN, 2, G_TYPE_INT, PURPLE_TYPE_ACCOUNT); |
| 12291 | 157 | |
|
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
|
158 | purple_prefs_add_none("/purple/sound"); |
|
37398
a9aa2aa0b1b6
Replace magic numbers on the sound API
Jorge Villaseñor <salinasv@pidgin.im>
parents:
36083
diff
changeset
|
159 | purple_prefs_add_int("/purple/sound/while_status", PURPLE_SOUND_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
|
160 | 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
|
161 | |
|
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
|
162 | 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
|
163 | } |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
164 | |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
165 | void |
| 15884 | 166 | purple_sound_uninit() |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
167 | { |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
168 | if(sound_ui_ops && sound_ui_ops->uninit) |
|
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
169 | sound_ui_ops->uninit(); |
| 12291 | 170 | |
| 15884 | 171 | purple_signals_unregister_by_instance(purple_sounds_get_handle()); |
|
10322
06e23196da4b
[gaim-migrate @ 11529]
Mark Doliner <markdoliner@pidgin.im>
parents:
9993
diff
changeset
|
172 | } |
| 12291 | 173 | |
| 174 | void * | |
| 15884 | 175 | purple_sounds_get_handle() |
| 12291 | 176 | { |
| 177 | static int handle; | |
| 178 | ||
| 179 | return &handle; | |
| 180 | } |