41
41
#include <libsoup/soup.h>
43
#include <libpeas-gtk/peas-gtk.h>
45
#include "rb-plugin-macros.h"
43
46
#include "rb-daap-plugin.h"
44
47
#include "rb-debug.h"
45
48
#include "rb-shell.h"
46
49
#include "rb-dialog.h"
47
50
#include "rb-file-helpers.h"
48
51
#include "rb-builder-helpers.h"
49
#include "eel-gconf-extensions.h"
52
#include "rb-uri-dialog.h"
53
#include "rb-display-page-group.h"
55
#include "rb-daap-container-record.h"
56
#include "rb-daap-record-factory.h"
57
#include "rb-daap-record.h"
50
58
#include "rb-daap-source.h"
51
59
#include "rb-daap-sharing.h"
52
60
#include "rb-daap-src.h"
53
61
#include "rb-dacp-pairing-page.h"
54
#include "rb-uri-dialog.h"
55
#include "rb-display-page-group.h"
62
#include "rb-dacp-player.h"
63
#include "rb-dmap-container-db-adapter.h"
64
#include "rb-rhythmdb-dmap-db-adapter.h"
65
#include "rb-rhythmdb-query-model-dmap-db-adapter.h"
57
67
#include <libdmapsharing/dmap.h>
60
#define CONF_DAAP_PREFIX CONF_PREFIX "/plugins/daap"
61
#define CONF_ENABLE_BROWSING CONF_DAAP_PREFIX "/enable_browsing"
62
#define CONF_ENABLE_REMOTE CONF_DAAP_PREFIX "/enable_remote"
64
69
#define DAAP_DBUS_PATH "/org/gnome/Rhythmbox/DAAP"
65
70
#define DAAP_DBUS_IFACE "org.gnome.Rhythmbox.DAAP"
107
111
guint dbus_intf_id;
114
struct _RBDaapPluginClass
116
PeasExtensionBaseClass parent;
117
G_MODULE_EXPORT GType register_rb_plugin (GTypeModule *module);
119
static void rb_daap_plugin_get_property (GObject *object,
120
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
124
122
static void rb_daap_plugin_init (RBDaapPlugin *plugin);
125
static void rb_daap_plugin_dispose (GObject *object);
126
static void impl_activate (RBPlugin *plugin, RBShell *shell);
127
static void impl_deactivate (RBPlugin *plugin, RBShell *shell);
129
static GtkWidget* impl_create_configure_dialog (RBPlugin *plugin);
130
124
static void rb_daap_plugin_cmd_disconnect (GtkAction *action, RBSource *source);
131
125
static void rb_daap_plugin_cmd_connect (GtkAction *action, RBDaapPlugin *plugin);
133
127
static void create_pixbufs (RBDaapPlugin *plugin);
134
128
static void start_browsing (RBDaapPlugin *plugin);
135
129
static void stop_browsing (RBDaapPlugin *plugin);
136
static void enable_browsing_changed_cb (GConfClient *client,
139
RBDaapPlugin *plugin);
140
static void enable_remote_changed_cb (GConfClient *client,
143
RBDaapPlugin *plugin);
130
static void settings_changed_cb (GSettings *settings,
132
RBDaapPlugin *plugin);
133
static void dacp_settings_changed_cb (GSettings *settings,
135
RBDaapPlugin *plugin);
144
136
static void libdmapsharing_debug (const char *domain,
145
137
GLogLevelFlags level,
146
138
const char *message,
169
rb_daap_plugin_class_init (RBDaapPluginClass *klass)
171
GObjectClass *object_class = G_OBJECT_CLASS (klass);
172
RBPluginClass *plugin_class = RB_PLUGIN_CLASS (klass);
174
object_class->dispose = rb_daap_plugin_dispose;
175
object_class->get_property = rb_daap_plugin_get_property;
177
plugin_class->activate = impl_activate;
178
plugin_class->deactivate = impl_deactivate;
179
plugin_class->create_configure_dialog = impl_create_configure_dialog;
181
g_object_class_install_property (object_class,
183
g_param_spec_boolean ("shutdown",
185
"Whether the DAAP plugin has been shut down",
189
g_object_class_install_property (object_class,
191
g_param_spec_object ("shell",
193
"The Rhythmbox Shell",
197
g_type_class_add_private (object_class, sizeof (RBDaapPluginPrivate));
201
167
rb_daap_plugin_init (RBDaapPlugin *plugin)
169
GSettings *daap_settings;
203
171
rb_debug ("RBDaapPlugin initialising");
204
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, RB_TYPE_DAAP_PLUGIN, RBDaapPluginPrivate);
206
rb_daap_src_set_plugin (RB_PLUGIN (plugin));
210
rb_daap_plugin_dispose (GObject *object)
212
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (object);
214
rb_debug ("RBDaapPlugin dispose");
216
if (plugin->priv->preferences) {
217
gtk_widget_destroy (plugin->priv->preferences);
218
plugin->priv->preferences = NULL;
221
if (plugin->priv->builder) {
222
g_object_unref (plugin->priv->builder);
223
plugin->priv->builder = NULL;
226
if (plugin->priv->bus) {
227
g_object_unref (plugin->priv->bus);
228
plugin->priv->bus = NULL;
231
G_OBJECT_CLASS (rb_daap_plugin_parent_class)->dispose (object);
236
rb_daap_plugin_get_property (GObject *object,
241
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (object);
245
g_value_set_boolean (value, plugin->priv->shutdown);
248
g_value_take_object (value, plugin->priv->shell);
251
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
257
impl_activate (RBPlugin *bplugin,
172
rb_daap_src_set_plugin (G_OBJECT (plugin));
174
plugin->settings = g_settings_new ("org.gnome.rhythmbox.sharing");
176
daap_settings = g_settings_new ("org.gnome.rhythmbox.plugins.daap");
177
plugin->dacp_settings = g_settings_get_child (daap_settings, "dacp");
178
g_object_unref (daap_settings);
182
impl_activate (PeasActivatable *bplugin)
260
184
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
261
185
gboolean no_registration;
262
gboolean enabled = TRUE;
263
gboolean remote_enabled = TRUE;
265
GConfClient *client = eel_gconf_client_get_global ();
266
186
GtkUIManager *uimanager = NULL;
269
plugin->priv->shutdown = FALSE;
270
plugin->priv->shell = g_object_ref (shell);
190
plugin->shutdown = FALSE;
272
192
g_log_set_handler ("libdmapsharing",
273
193
G_LOG_LEVEL_MASK,
274
194
libdmapsharing_debug,
277
value = gconf_client_get_without_default (client,
278
CONF_ENABLE_BROWSING, NULL);
280
enabled = gconf_value_get_bool (value);
281
gconf_value_free (value);
197
g_object_get (plugin, "object", &shell, NULL);
199
g_signal_connect_object (plugin->settings, "changed", G_CALLBACK (settings_changed_cb), plugin, 0);
201
g_signal_connect_object (plugin->dacp_settings, "changed", G_CALLBACK (dacp_settings_changed_cb), plugin, 0);
203
if (g_settings_get_boolean (plugin->settings, "enable-browsing")) {
285
204
start_browsing (plugin);
288
plugin->priv->enable_browsing_notify_id =
289
eel_gconf_notification_add (CONF_ENABLE_BROWSING,
290
(GConfClientNotifyFunc) enable_browsing_changed_cb,
293
/* Check if Remote (DACP) lookup is enabled */
294
value = gconf_client_get_without_default (client,
295
CONF_ENABLE_REMOTE, NULL);
297
remote_enabled = gconf_value_get_bool (value);
298
gconf_value_free (value);
301
plugin->priv->dacp_share = rb_daap_create_dacp_share (RB_PLUGIN (plugin));
302
if (remote_enabled) {
303
dacp_share_start_lookup (plugin->priv->dacp_share);
306
plugin->priv->enable_remote_notify_id =
307
eel_gconf_notification_add (CONF_ENABLE_REMOTE,
308
(GConfClientNotifyFunc) enable_remote_changed_cb,
311
207
create_pixbufs (plugin);
314
"ui-manager", &uimanager,
209
g_object_get (shell, "ui-manager", &uimanager, NULL);
317
211
/* add actions */
318
plugin->priv->daap_action_group = gtk_action_group_new ("DaapActions");
319
gtk_action_group_set_translation_domain (plugin->priv->daap_action_group,
212
plugin->daap_action_group = gtk_action_group_new ("DaapActions");
213
gtk_action_group_set_translation_domain (plugin->daap_action_group,
320
214
GETTEXT_PACKAGE);
321
gtk_action_group_add_actions (plugin->priv->daap_action_group,
215
gtk_action_group_add_actions (plugin->daap_action_group,
322
216
rb_daap_plugin_actions, G_N_ELEMENTS (rb_daap_plugin_actions),
324
_rb_action_group_add_display_page_actions (plugin->priv->daap_action_group,
218
_rb_action_group_add_display_page_actions (plugin->daap_action_group,
325
219
G_OBJECT (shell),
326
220
rb_daap_source_actions,
327
221
G_N_ELEMENTS (rb_daap_source_actions));
328
gtk_ui_manager_insert_action_group (uimanager, plugin->priv->daap_action_group, 0);
222
gtk_ui_manager_insert_action_group (uimanager, plugin->daap_action_group, 0);
331
uifile = rb_plugin_find_file (bplugin, "daap-ui.xml");
225
uifile = rb_find_plugin_data_file (G_OBJECT (plugin), "daap-ui.xml");
332
226
if (uifile != NULL) {
333
plugin->priv->daap_ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, uifile, NULL);
227
plugin->daap_ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, uifile, NULL);
341
235
* This flag is only used to run multiple instances at the same time, and
342
236
* sharing from two instances would be silly
344
g_object_get (G_OBJECT (shell),
345
"no-registration", &no_registration,
347
plugin->priv->sharing = !no_registration;
348
if (plugin->priv->sharing)
238
g_object_get (shell, "no-registration", &no_registration, NULL);
239
plugin->sharing = !no_registration;
349
241
rb_daap_sharing_init (shell);
243
plugin->dacp_share = rb_daap_create_dacp_share (G_OBJECT (plugin));
244
if (g_settings_get_boolean (plugin->dacp_settings, "enable-remote")) {
245
dacp_share_start_lookup (plugin->dacp_share);
351
248
register_daap_dbus_iface (plugin);
250
g_object_unref (shell);
355
impl_deactivate (RBPlugin *bplugin,
254
impl_deactivate (PeasActivatable *bplugin)
358
256
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
359
257
GtkUIManager *uimanager = NULL;
361
260
rb_debug ("Shutting down DAAP plugin");
262
g_object_get (plugin, "object", &shell, NULL);
363
264
unregister_daap_dbus_iface (plugin);
364
plugin->priv->shutdown = TRUE;
265
plugin->shutdown = TRUE;
366
if (plugin->priv->sharing)
367
268
rb_daap_sharing_shutdown (shell);
369
if (plugin->priv->mdns_browser) {
270
if (plugin->mdns_browser) {
370
271
stop_browsing (plugin);
373
if (plugin->priv->enable_browsing_notify_id != EEL_GCONF_UNDEFINED_CONNECTION) {
374
eel_gconf_notification_remove (plugin->priv->enable_browsing_notify_id);
375
plugin->priv->enable_browsing_notify_id = EEL_GCONF_UNDEFINED_CONNECTION;
378
g_object_unref (plugin->priv->dacp_share);
380
if (plugin->priv->enable_remote_notify_id != EEL_GCONF_UNDEFINED_CONNECTION) {
381
eel_gconf_notification_remove (plugin->priv->enable_remote_notify_id);
382
plugin->priv->enable_remote_notify_id = EEL_GCONF_UNDEFINED_CONNECTION;
386
"ui-manager", &uimanager,
389
gtk_ui_manager_remove_ui (uimanager, plugin->priv->daap_ui_merge_id);
390
gtk_ui_manager_remove_action_group (uimanager, plugin->priv->daap_action_group);
274
if (plugin->settings) {
275
g_object_unref (plugin->settings);
276
plugin->settings = NULL;
279
g_object_unref (plugin->dacp_share);
281
g_object_get (shell, "ui-manager", &uimanager, NULL);
283
gtk_ui_manager_remove_ui (uimanager, plugin->daap_ui_merge_id);
284
gtk_ui_manager_remove_action_group (uimanager, plugin->daap_action_group);
392
286
g_object_unref (uimanager);
394
if (plugin->priv->daap_share_pixbuf != NULL) {
395
g_object_unref (plugin->priv->daap_share_pixbuf);
396
plugin->priv->daap_share_pixbuf = NULL;
399
if (plugin->priv->daap_share_locked_pixbuf != NULL) {
400
g_object_unref (plugin->priv->daap_share_locked_pixbuf);
401
plugin->priv->daap_share_locked_pixbuf = NULL;
404
if (plugin->priv->shell) {
405
g_object_unref (plugin->priv->shell);
406
plugin->priv->shell = NULL;
288
if (plugin->daap_share_pixbuf != NULL) {
289
g_object_unref (plugin->daap_share_pixbuf);
290
plugin->daap_share_pixbuf = NULL;
293
if (plugin->daap_share_locked_pixbuf != NULL) {
294
g_object_unref (plugin->daap_share_locked_pixbuf);
295
plugin->daap_share_locked_pixbuf = NULL;
298
if (plugin->preferences) {
299
gtk_widget_destroy (plugin->preferences);
300
plugin->preferences = NULL;
303
if (plugin->builder) {
304
g_object_unref (plugin->builder);
305
plugin->builder = NULL;
309
g_object_unref (plugin->bus);
313
g_object_unref (shell);
410
316
/* DAAP share icons */
539
446
source = find_source_by_service_name (plugin, service->service_name);
541
448
if (source == NULL) {
542
source = rb_daap_source_new (plugin->priv->shell, RB_PLUGIN (plugin), service->service_name, service->name, service->host, service->port, service->password_protected);
543
g_hash_table_insert (plugin->priv->source_lookup, g_strdup (service->service_name), source);
544
rb_shell_append_display_page (plugin->priv->shell, RB_DISPLAY_PAGE (source), RB_DISPLAY_PAGE_GROUP_SHARED);
449
g_object_get (plugin, "object", &shell, NULL);
451
source = rb_daap_source_new (shell,
453
service->service_name,
457
service->password_protected);
458
g_hash_table_insert (plugin->source_lookup, g_strdup (service->service_name), source);
459
rb_shell_append_display_page (shell,
460
RB_DISPLAY_PAGE (source),
461
RB_DISPLAY_PAGE_GROUP_SHARED);
463
g_object_unref (shell);
546
g_object_set (G_OBJECT (source),
465
g_object_set (source,
547
466
"name", service->name,
548
467
"host", service->host,
549
468
"port", service->port,
595
if (plugin->priv->mdns_browser != NULL) {
514
if (plugin->mdns_browser != NULL) {
599
plugin->priv->mdns_browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP);
600
if (plugin->priv->mdns_browser == NULL) {
518
plugin->mdns_browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP);
519
if (plugin->mdns_browser == NULL) {
601
520
g_warning ("Unable to start mDNS browsing");
605
g_signal_connect_object (plugin->priv->mdns_browser,
524
g_signal_connect_object (plugin->mdns_browser,
607
526
G_CALLBACK (mdns_service_added),
610
g_signal_connect_object (plugin->priv->mdns_browser,
529
g_signal_connect_object (plugin->mdns_browser,
611
530
"service-removed",
612
531
G_CALLBACK (mdns_service_removed),
617
dmap_mdns_browser_start (plugin->priv->mdns_browser, &error);
536
dmap_mdns_browser_start (plugin->mdns_browser, &error);
618
537
if (error != NULL) {
619
538
g_warning ("Unable to start mDNS browsing: %s", error->message);
620
539
g_error_free (error);
623
plugin->priv->source_lookup = g_hash_table_new_full ((GHashFunc)g_str_hash,
542
plugin->source_lookup = g_hash_table_new_full ((GHashFunc)g_str_hash,
624
543
(GEqualFunc)g_str_equal,
625
544
(GDestroyNotify)g_free,
626
545
(GDestroyNotify)remove_source);
634
if (plugin->priv->mdns_browser == NULL) {
553
if (plugin->mdns_browser == NULL) {
638
557
rb_debug ("Destroying DAAP source lookup");
640
g_hash_table_destroy (plugin->priv->source_lookup);
641
plugin->priv->source_lookup = NULL;
559
g_hash_table_destroy (plugin->source_lookup);
560
plugin->source_lookup = NULL;
643
g_signal_handlers_disconnect_by_func (plugin->priv->mdns_browser, mdns_service_added, plugin);
644
g_signal_handlers_disconnect_by_func (plugin->priv->mdns_browser, mdns_service_removed, plugin);
562
g_signal_handlers_disconnect_by_func (plugin->mdns_browser, mdns_service_added, plugin);
563
g_signal_handlers_disconnect_by_func (plugin->mdns_browser, mdns_service_removed, plugin);
647
dmap_mdns_browser_stop (plugin->priv->mdns_browser, &error);
566
dmap_mdns_browser_stop (plugin->mdns_browser, &error);
648
567
if (error != NULL) {
649
568
g_warning ("Unable to stop mDNS browsing: %s", error->message);
650
569
g_error_free (error);
653
g_object_unref (plugin->priv->mdns_browser);
654
plugin->priv->mdns_browser = NULL;
572
g_object_unref (plugin->mdns_browser);
573
plugin->mdns_browser = NULL;
658
enable_browsing_changed_cb (GConfClient *client,
661
RBDaapPlugin *plugin)
577
dacp_settings_changed_cb (GSettings *settings, const char *key, RBDaapPlugin *plugin)
663
gboolean enabled = eel_gconf_get_boolean (CONF_ENABLE_BROWSING);
666
start_browsing (plugin);
668
stop_browsing (plugin);
579
if (g_strcmp0 (key, "enable-remote") == 0) {
580
if (g_settings_get_boolean (settings, key)) {
581
dacp_share_start_lookup (plugin->dacp_share);
583
dacp_share_stop_lookup (plugin->dacp_share);
673
enable_remote_changed_cb (GConfClient *client,
676
RBDaapPlugin *plugin)
589
settings_changed_cb (GSettings *settings, const char *key, RBDaapPlugin *plugin)
678
gboolean enabled = eel_gconf_get_boolean (CONF_ENABLE_REMOTE);
681
dacp_share_start_lookup (plugin->priv->dacp_share);
683
dacp_share_stop_lookup (plugin->priv->dacp_share);
591
if (g_strcmp0 (key, "enable-browsing") == 0) {
592
if (g_settings_get_boolean (settings, key)) {
593
start_browsing (plugin);
595
stop_browsing (plugin);
597
} else if (g_strcmp0 (key, "enable-sharing") == 0) {
598
GtkToggleButton *password_check;
599
GtkWidget *password_entry;
600
gboolean enabled = g_settings_get_boolean (settings, key);
602
password_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (plugin->builder, "daap_password_check"));
603
password_entry = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_password_entry"));
605
gtk_widget_set_sensitive (password_entry, enabled && gtk_toggle_button_get_active (password_check));
606
gtk_widget_set_sensitive (GTK_WIDGET (password_check), enabled);
793
716
s = strchr (ip, ':');
796
source = (RBDAAPSource *)g_hash_table_find (plugin->priv->source_lookup, (GHRFunc)source_host_find, ip);
719
source = (RBDAAPSource *)g_hash_table_find (plugin->source_lookup, (GHRFunc)source_host_find, ip);
727
rb_daap_plugin_shutdown (RBDaapPlugin *plugin)
729
return plugin->shutdown;
803
732
/* preferences dialog */
806
preferences_response_cb (GtkWidget *dialog, gint response, RBPlugin *plugin)
808
gtk_widget_hide (dialog);
812
share_check_button_toggled_cb (GtkToggleButton *button,
816
GtkToggleButton *password_check;
817
GtkWidget *password_entry;
819
b = gtk_toggle_button_get_active (button);
821
eel_gconf_set_boolean (CONF_DAAP_ENABLE_SHARING, b);
823
password_check = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "daap_password_check"));
824
password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "daap_password_entry"));
826
gtk_widget_set_sensitive (password_entry, b && gtk_toggle_button_get_active (password_check));
827
gtk_widget_set_sensitive (GTK_WIDGET (password_check), b);
831
remote_check_button_toggled_cb (GtkToggleButton *button,
836
b = gtk_toggle_button_get_active (button);
838
eel_gconf_set_boolean (CONF_ENABLE_REMOTE, b);
842
password_check_button_toggled_cb (GtkToggleButton *button,
847
b = gtk_toggle_button_get_active (button);
849
eel_gconf_set_boolean (CONF_DAAP_REQUIRE_PASSWORD, b);
851
gtk_widget_set_sensitive (widget, b);
734
/* should move this to a separate class really */
855
737
forget_remotes_button_toggled_cb (GtkToggleButton *button,
738
RBDaapPlugin *plugin)
858
eel_gconf_unset (CONF_KNOWN_REMOTES);
740
g_settings_reset (plugin->dacp_settings, "known-remotes");
862
744
share_name_entry_focus_out_event_cb (GtkEntry *entry,
863
745
GdkEventFocus *event,
746
RBDaapPlugin *plugin)
866
748
gboolean changed;
867
749
const char *name;
870
752
name = gtk_entry_get_text (entry);
871
old_name = eel_gconf_get_string (CONF_DAAP_SHARE_NAME);
753
old_name = g_settings_get_string (plugin->settings, "share-name");
873
755
if (name == NULL && old_name == NULL) {
927
811
GtkWidget *password_entry;
928
812
GtkWidget *password_check;
929
813
GtkWidget *forget_remotes_button;
930
gboolean sharing_enabled;
931
gboolean remote_enabled;
932
gboolean require_password;
936
check = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "daap_enable_check"));
937
remote_check = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "dacp_enable_check"));
938
password_check = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "daap_password_check"));
939
name_entry = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "daap_name_entry"));
940
password_entry = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "daap_password_entry"));
941
forget_remotes_button = GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "forget_remotes_button"));
943
sharing_enabled = eel_gconf_get_boolean (CONF_DAAP_ENABLE_SHARING);
944
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), sharing_enabled);
945
g_signal_connect (check, "toggled", G_CALLBACK (share_check_button_toggled_cb), plugin->priv->builder);
947
remote_enabled = eel_gconf_get_boolean (CONF_ENABLE_REMOTE);
948
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (remote_check), remote_enabled);
949
g_signal_connect (remote_check, "toggled", G_CALLBACK (remote_check_button_toggled_cb), plugin->priv->builder);
951
require_password = eel_gconf_get_boolean (CONF_DAAP_REQUIRE_PASSWORD);
952
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (password_check), require_password);
953
g_signal_connect (password_check, "toggled", G_CALLBACK (password_check_button_toggled_cb), password_entry);
955
g_signal_connect (forget_remotes_button, "clicked", G_CALLBACK (forget_remotes_button_toggled_cb), NULL);
957
name = eel_gconf_get_string (CONF_DAAP_SHARE_NAME);
958
if (name == NULL || name[0] == '\0')
817
check = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_enable_check"));
818
remote_check = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "dacp_enable_check"));
819
password_check = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_password_check"));
820
name_entry = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_name_entry"));
821
password_entry = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_password_entry"));
822
forget_remotes_button = GTK_WIDGET (gtk_builder_get_object (plugin->builder, "forget_remotes_button"));
824
g_settings_bind (plugin->settings, "enable-sharing", check, "active", G_SETTINGS_BIND_DEFAULT);
825
g_settings_bind (plugin->dacp_settings, "enable-remote", remote_check, "active", G_SETTINGS_BIND_DEFAULT);
827
/*g_signal_connect (check, "toggled", G_CALLBACK (share_check_button_toggled_cb), plugin->builder);*/
829
/* probably needs rethinking to deal with remotes.. */
830
g_settings_bind (plugin->settings, "require-password", password_check, "active", G_SETTINGS_BIND_DEFAULT);
831
g_settings_bind (plugin->settings, "require-password", password_entry, "sensitive", G_SETTINGS_BIND_NO_SENSITIVITY);
833
g_signal_connect_object (forget_remotes_button, "clicked", G_CALLBACK (forget_remotes_button_toggled_cb), plugin, 0);
835
name = g_settings_get_string (plugin->settings, "share-name");
836
if (name == NULL || name[0] == '\0') {
959
838
name = rb_daap_sharing_default_share_name ();
961
841
gtk_entry_set_text (GTK_ENTRY (name_entry), name);
963
g_signal_connect (name_entry, "focus-out-event",
964
G_CALLBACK (share_name_entry_focus_out_event_cb), NULL);
844
g_signal_connect_object (name_entry,
846
G_CALLBACK (share_name_entry_focus_out_event_cb),
966
password = eel_gconf_get_string (CONF_DAAP_SHARE_PASSWORD);
967
if (password != NULL)
850
password = g_settings_get_string (plugin->settings, "share-password");
851
if (password != NULL) {
968
852
gtk_entry_set_text (GTK_ENTRY (password_entry), password);
970
g_signal_connect (password_entry, "focus-out-event",
971
G_CALLBACK (share_password_entry_focus_out_event_cb), NULL);
855
g_signal_connect_object (password_entry,
857
G_CALLBACK (share_password_entry_focus_out_event_cb),
973
gtk_widget_set_sensitive (password_entry, require_password);
861
/*gtk_widget_set_sensitive (password_entry, require_password);*/
976
864
static GtkWidget *
977
make_config_widget (RBDaapPlugin *plugin)
865
impl_create_configure_widget (PeasGtkConfigurable *bplugin)
979
867
char *builder_file;
868
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
981
builder_file = rb_plugin_find_file (RB_PLUGIN (plugin), "daap-prefs.ui");
870
builder_file = rb_find_plugin_data_file (G_OBJECT (plugin), "daap-prefs.ui");
982
871
if (builder_file == NULL) {
986
plugin->priv->builder = rb_builder_load (builder_file, NULL);
875
plugin->builder = rb_builder_load (builder_file, NULL);
987
876
g_free (builder_file);
989
878
update_config_widget (plugin);
990
return GTK_WIDGET (gtk_builder_get_object (plugin->priv->builder, "daap_vbox"));
879
return GTK_WIDGET (gtk_builder_get_object (plugin->builder, "daap_vbox"));
995
impl_create_configure_dialog (RBPlugin *bplugin)
883
peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
997
RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
999
if (plugin->priv->preferences == NULL) {
1002
widget = make_config_widget (plugin);
1004
plugin->priv->preferences = gtk_dialog_new_with_buttons (_("DAAP Music Sharing Preferences"),
1006
GTK_DIALOG_DESTROY_WITH_PARENT,
1007
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1009
g_signal_connect (G_OBJECT (plugin->priv->preferences),
1011
G_CALLBACK (preferences_response_cb),
1013
gtk_widget_hide_on_delete (plugin->priv->preferences);
1015
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (plugin->priv->preferences))),
1018
update_config_widget (plugin);
1021
gtk_widget_show_all (plugin->priv->preferences);
1022
return plugin->priv->preferences;
885
iface->create_configure_widget = impl_create_configure_widget;
1025
888
/* DAAP DBus interface */
1116
979
unregister_daap_dbus_iface (RBDaapPlugin *plugin)
1118
if (plugin->priv->dbus_intf_id == 0) {
981
if (plugin->dbus_intf_id == 0) {
1119
982
rb_debug ("DAAP DBus interface not registered");
1123
if (plugin->priv->bus == NULL) {
986
if (plugin->bus == NULL) {
1124
987
rb_debug ("no bus connection");
1128
g_dbus_connection_unregister_object (plugin->priv->bus, plugin->priv->dbus_intf_id);
1129
plugin->priv->dbus_intf_id = 0;
991
g_dbus_connection_unregister_object (plugin->bus, plugin->dbus_intf_id);
992
plugin->dbus_intf_id = 0;
996
peas_register_types (PeasObjectModule *module)
998
rb_daap_plugin_register_type (G_TYPE_MODULE (module));
999
_rb_daap_container_record_register_type (G_TYPE_MODULE (module));
1000
_rb_daap_record_factory_register_type (G_TYPE_MODULE (module));
1001
_rb_daap_record_register_type (G_TYPE_MODULE (module));
1002
_rb_daap_source_register_type (G_TYPE_MODULE (module));
1003
_rb_dacp_pairing_page_register_type (G_TYPE_MODULE (module));
1004
_rb_dacp_player_register_type (G_TYPE_MODULE (module));
1005
_rb_dmap_container_db_adapter_register_type (G_TYPE_MODULE (module));
1006
_rb_rhythmdb_dmap_db_adapter_register_type (G_TYPE_MODULE (module));
1007
_rb_rhythmdb_query_model_dmap_db_adapter_register_type (G_TYPE_MODULE (module));
1009
peas_object_module_register_extension_type (module,
1010
PEAS_TYPE_ACTIVATABLE,
1011
RB_TYPE_DAAP_PLUGIN);
1012
peas_object_module_register_extension_type (module,
1013
PEAS_GTK_TYPE_CONFIGURABLE,
1014
RB_TYPE_DAAP_PLUGIN);