~ubuntu-branches/ubuntu/oneiric/rhythmbox/oneiric

« back to all changes in this revision

Viewing changes to plugins/daap/rb-daap-plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Rico Tzschichholz
  • Date: 2011-07-29 16:41:38 UTC
  • mto: This revision was merged to the branch mainline in revision 191.
  • Revision ID: james.westby@ubuntu.com-20110729164138-wwicy8nqalm18ck7
Tags: upstream-2.90.1~20110802
ImportĀ upstreamĀ versionĀ 2.90.1~20110802

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
#include <libsoup/soup.h>
42
42
 
 
43
#include <libpeas-gtk/peas-gtk.h>
 
44
 
 
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"
 
54
 
 
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"
56
66
 
57
67
#include <libdmapsharing/dmap.h>
58
68
 
59
 
/* preferences */
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"
63
 
 
64
69
#define DAAP_DBUS_PATH  "/org/gnome/Rhythmbox/DAAP"
65
70
#define DAAP_DBUS_IFACE "org.gnome.Rhythmbox.DAAP"
66
71
 
78
83
"  </interface>"
79
84
"</node>";
80
85
 
81
 
 
82
 
struct RBDaapPluginPrivate
 
86
struct _RBDaapPlugin
83
87
{
84
 
        RBShell *shell;
 
88
        PeasExtensionBase parent;
85
89
 
86
90
        GtkBuilder *builder;
87
91
        GtkWidget *preferences;
97
101
 
98
102
        GHashTable *source_lookup;
99
103
 
100
 
        guint enable_browsing_notify_id;
101
 
        guint enable_remote_notify_id;
 
104
        GSettings *settings;
 
105
        GSettings *dacp_settings;
102
106
 
103
107
        GdkPixbuf *daap_share_pixbuf;
104
108
        GdkPixbuf *daap_share_locked_pixbuf;
107
111
        guint dbus_intf_id;
108
112
};
109
113
 
110
 
enum
 
114
struct _RBDaapPluginClass
111
115
{
112
 
        PROP_0,
113
 
        PROP_SHUTDOWN,
114
 
        PROP_SHELL
 
116
        PeasExtensionBaseClass parent;
115
117
};
116
118
 
117
 
G_MODULE_EXPORT GType register_rb_plugin (GTypeModule *module);
118
119
 
119
 
static void rb_daap_plugin_get_property (GObject *object,
120
 
                                         guint prop_id,
121
 
                                         GValue *value,
122
 
                                         GParamSpec *pspec);
 
120
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
123
121
 
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);
128
123
 
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);
132
126
 
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,
137
 
                                        guint cnxn_id,
138
 
                                        GConfEntry *entry,
139
 
                                        RBDaapPlugin *plugin);
140
 
static void enable_remote_changed_cb (GConfClient *client,
141
 
                                        guint cnxn_id,
142
 
                                        GConfEntry *entry,
143
 
                                        RBDaapPlugin *plugin);
 
130
static void settings_changed_cb (GSettings *settings,
 
131
                                 const char *key,
 
132
                                 RBDaapPlugin *plugin);
 
133
static void dacp_settings_changed_cb (GSettings *settings,
 
134
                                      const char *key,
 
135
                                      RBDaapPlugin *plugin);
144
136
static void libdmapsharing_debug (const char *domain,
145
137
                                  GLogLevelFlags level,
146
138
                                  const char *message,
149
141
static void register_daap_dbus_iface (RBDaapPlugin *plugin);
150
142
static void unregister_daap_dbus_iface (RBDaapPlugin *plugin);
151
143
 
152
 
RB_PLUGIN_REGISTER(RBDaapPlugin, rb_daap_plugin)
 
144
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
 
145
 
 
146
RB_DEFINE_PLUGIN(RB_TYPE_DAAP_PLUGIN,
 
147
                 RBDaapPlugin,
 
148
                 rb_daap_plugin,
 
149
                 (G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
 
150
                                                peas_gtk_configurable_iface_init)))
153
151
 
154
152
static GtkActionEntry rb_daap_plugin_actions [] =
155
153
{
166
164
};
167
165
 
168
166
static void
169
 
rb_daap_plugin_class_init (RBDaapPluginClass *klass)
170
 
{
171
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
172
 
        RBPluginClass *plugin_class = RB_PLUGIN_CLASS (klass);
173
 
 
174
 
        object_class->dispose = rb_daap_plugin_dispose;
175
 
        object_class->get_property = rb_daap_plugin_get_property;
176
 
 
177
 
        plugin_class->activate = impl_activate;
178
 
        plugin_class->deactivate = impl_deactivate;
179
 
        plugin_class->create_configure_dialog = impl_create_configure_dialog;
180
 
 
181
 
        g_object_class_install_property (object_class,
182
 
                                         PROP_SHUTDOWN,
183
 
                                         g_param_spec_boolean ("shutdown",
184
 
                                                               "shutdown",
185
 
                                                               "Whether the DAAP plugin has been shut down",
186
 
                                                               FALSE,
187
 
                                                               G_PARAM_READABLE));
188
 
 
189
 
        g_object_class_install_property (object_class,
190
 
                                         PROP_SHELL,
191
 
                                         g_param_spec_object ("shell",
192
 
                                                              "Shell",
193
 
                                                              "The Rhythmbox Shell",
194
 
                                                              RB_TYPE_SHELL,
195
 
                                                              G_PARAM_READABLE));
196
 
 
197
 
        g_type_class_add_private (object_class, sizeof (RBDaapPluginPrivate));
198
 
}
199
 
 
200
 
static void
201
167
rb_daap_plugin_init (RBDaapPlugin *plugin)
202
168
{
 
169
        GSettings *daap_settings;
 
170
 
203
171
        rb_debug ("RBDaapPlugin initialising");
204
 
        plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, RB_TYPE_DAAP_PLUGIN, RBDaapPluginPrivate);
205
 
 
206
 
        rb_daap_src_set_plugin (RB_PLUGIN (plugin));
207
 
}
208
 
 
209
 
static void
210
 
rb_daap_plugin_dispose (GObject *object)
211
 
{
212
 
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (object);
213
 
 
214
 
        rb_debug ("RBDaapPlugin dispose");
215
 
 
216
 
        if (plugin->priv->preferences) {
217
 
                gtk_widget_destroy (plugin->priv->preferences);
218
 
                plugin->priv->preferences = NULL;
219
 
        }
220
 
 
221
 
        if (plugin->priv->builder) {
222
 
                g_object_unref (plugin->priv->builder);
223
 
                plugin->priv->builder = NULL;
224
 
        }
225
 
 
226
 
        if (plugin->priv->bus) {
227
 
                g_object_unref (plugin->priv->bus);
228
 
                plugin->priv->bus = NULL;
229
 
        }
230
 
 
231
 
        G_OBJECT_CLASS (rb_daap_plugin_parent_class)->dispose (object);
232
 
}
233
 
 
234
 
 
235
 
static void
236
 
rb_daap_plugin_get_property (GObject *object,
237
 
                             guint prop_id,
238
 
                             GValue *value,
239
 
                             GParamSpec *pspec)
240
 
{
241
 
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (object);
242
 
 
243
 
        switch (prop_id) {
244
 
        case PROP_SHUTDOWN:
245
 
                g_value_set_boolean (value, plugin->priv->shutdown);
246
 
                break;
247
 
        case PROP_SHELL:
248
 
                g_value_take_object (value, plugin->priv->shell);
249
 
                break;
250
 
        default:
251
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
252
 
                break;
253
 
        }
254
 
}
255
 
 
256
 
static void
257
 
impl_activate (RBPlugin *bplugin,
258
 
               RBShell *shell)
 
172
        rb_daap_src_set_plugin (G_OBJECT (plugin));
 
173
 
 
174
        plugin->settings = g_settings_new ("org.gnome.rhythmbox.sharing");
 
175
 
 
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);
 
179
}
 
180
 
 
181
static void
 
182
impl_activate (PeasActivatable *bplugin)
259
183
{
260
184
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
261
185
        gboolean no_registration;
262
 
        gboolean enabled = TRUE;
263
 
        gboolean remote_enabled = TRUE;
264
 
        GConfValue *value;
265
 
        GConfClient *client = eel_gconf_client_get_global ();
266
186
        GtkUIManager *uimanager = NULL;
267
187
        char *uifile;
 
188
        RBShell *shell;
268
189
 
269
 
        plugin->priv->shutdown = FALSE;
270
 
        plugin->priv->shell = g_object_ref (shell);
 
190
        plugin->shutdown = FALSE;
271
191
 
272
192
        g_log_set_handler ("libdmapsharing",
273
193
                            G_LOG_LEVEL_MASK,
274
194
                            libdmapsharing_debug,
275
195
                            NULL);
276
196
 
277
 
        value = gconf_client_get_without_default (client,
278
 
                                                  CONF_ENABLE_BROWSING, NULL);
279
 
        if (value != NULL) {
280
 
                enabled = gconf_value_get_bool (value);
281
 
                gconf_value_free (value);
282
 
        }
283
 
 
284
 
        if (enabled) {
 
197
        g_object_get (plugin, "object", &shell, NULL);
 
198
 
 
199
        g_signal_connect_object (plugin->settings, "changed", G_CALLBACK (settings_changed_cb), plugin, 0);
 
200
 
 
201
        g_signal_connect_object (plugin->dacp_settings, "changed", G_CALLBACK (dacp_settings_changed_cb), plugin, 0);
 
202
 
 
203
        if (g_settings_get_boolean (plugin->settings, "enable-browsing")) {
285
204
                start_browsing (plugin);
286
205
        }
287
206
 
288
 
        plugin->priv->enable_browsing_notify_id =
289
 
                eel_gconf_notification_add (CONF_ENABLE_BROWSING,
290
 
                                            (GConfClientNotifyFunc) enable_browsing_changed_cb,
291
 
                                            plugin);
292
 
 
293
 
        /* Check if Remote (DACP) lookup is enabled */
294
 
        value = gconf_client_get_without_default (client,
295
 
                                                  CONF_ENABLE_REMOTE, NULL);
296
 
        if (value != NULL) {
297
 
                remote_enabled = gconf_value_get_bool (value);
298
 
                gconf_value_free (value);
299
 
        }
300
 
 
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);
304
 
        }
305
 
 
306
 
        plugin->priv->enable_remote_notify_id =
307
 
                eel_gconf_notification_add (CONF_ENABLE_REMOTE,
308
 
                                            (GConfClientNotifyFunc) enable_remote_changed_cb,
309
 
                                            plugin);
310
 
 
311
207
        create_pixbufs (plugin);
312
208
 
313
 
        g_object_get (shell,
314
 
                      "ui-manager", &uimanager,
315
 
                      NULL);
 
209
        g_object_get (shell, "ui-manager", &uimanager, NULL);
316
210
 
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),
323
217
                                      plugin);
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);
329
223
 
330
224
        /* add UI */
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);
334
228
                g_free (uifile);
335
229
        }
336
230
 
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
343
237
         */
344
 
        g_object_get (G_OBJECT (shell),
345
 
                      "no-registration", &no_registration,
346
 
                      NULL);
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;
 
240
        if (plugin->sharing)
349
241
                rb_daap_sharing_init (shell);
350
242
 
 
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);
 
246
        }
 
247
 
351
248
        register_daap_dbus_iface (plugin);
 
249
 
 
250
        g_object_unref (shell);
352
251
}
353
252
 
354
253
static void
355
 
impl_deactivate (RBPlugin *bplugin,
356
 
                 RBShell *shell)
 
254
impl_deactivate (PeasActivatable *bplugin)
357
255
{
358
256
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
359
257
        GtkUIManager *uimanager = NULL;
 
258
        RBShell *shell;
360
259
 
361
260
        rb_debug ("Shutting down DAAP plugin");
362
261
 
 
262
        g_object_get (plugin, "object", &shell, NULL);
 
263
 
363
264
        unregister_daap_dbus_iface (plugin);
364
 
        plugin->priv->shutdown = TRUE;
 
265
        plugin->shutdown = TRUE;
365
266
 
366
 
        if (plugin->priv->sharing)
 
267
        if (plugin->sharing)
367
268
                rb_daap_sharing_shutdown (shell);
368
269
 
369
 
        if (plugin->priv->mdns_browser) {
 
270
        if (plugin->mdns_browser) {
370
271
                stop_browsing (plugin);
371
272
        }
372
273
 
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;
376
 
        }
377
 
 
378
 
        g_object_unref (plugin->priv->dacp_share);
379
 
 
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;
383
 
        }
384
 
 
385
 
        g_object_get (shell,
386
 
                      "ui-manager", &uimanager,
387
 
                      NULL);
388
 
 
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;
 
277
        }
 
278
 
 
279
        g_object_unref (plugin->dacp_share);
 
280
 
 
281
        g_object_get (shell, "ui-manager", &uimanager, NULL);
 
282
 
 
283
        gtk_ui_manager_remove_ui (uimanager, plugin->daap_ui_merge_id);
 
284
        gtk_ui_manager_remove_action_group (uimanager, plugin->daap_action_group);
391
285
 
392
286
        g_object_unref (uimanager);
393
287
 
394
 
        if (plugin->priv->daap_share_pixbuf != NULL) {
395
 
                g_object_unref (plugin->priv->daap_share_pixbuf);
396
 
                plugin->priv->daap_share_pixbuf = NULL;
397
 
        }
398
 
 
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;
402
 
        }
403
 
 
404
 
        if (plugin->priv->shell) {
405
 
                g_object_unref (plugin->priv->shell);
406
 
                plugin->priv->shell = NULL;
407
 
        }
 
288
        if (plugin->daap_share_pixbuf != NULL) {
 
289
                g_object_unref (plugin->daap_share_pixbuf);
 
290
                plugin->daap_share_pixbuf = NULL;
 
291
        }
 
292
 
 
293
        if (plugin->daap_share_locked_pixbuf != NULL) {
 
294
                g_object_unref (plugin->daap_share_locked_pixbuf);
 
295
                plugin->daap_share_locked_pixbuf = NULL;
 
296
        }
 
297
 
 
298
        if (plugin->preferences) {
 
299
                gtk_widget_destroy (plugin->preferences);
 
300
                plugin->preferences = NULL;
 
301
        }
 
302
 
 
303
        if (plugin->builder) {
 
304
                g_object_unref (plugin->builder);
 
305
                plugin->builder = NULL;
 
306
        }
 
307
 
 
308
        if (plugin->bus) {
 
309
                g_object_unref (plugin->bus);
 
310
                plugin->bus = NULL;
 
311
        }
 
312
 
 
313
        g_object_unref (shell);
408
314
}
409
315
 
410
316
/* DAAP share icons */
473
379
        theme = gtk_icon_theme_get_default ();
474
380
 
475
381
        gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL);
476
 
        plugin->priv->daap_share_pixbuf =
 
382
        plugin->daap_share_pixbuf =
477
383
                gtk_icon_theme_load_icon (theme, "gnome-fs-network", size, 0, NULL);
478
384
 
479
385
        gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &size, NULL);
480
386
        emblem = gtk_icon_theme_load_icon (theme, "stock_lock", size, 0, NULL);
481
387
 
482
 
        plugin->priv->daap_share_locked_pixbuf = composite_icons (plugin->priv->daap_share_pixbuf, emblem);
 
388
        plugin->daap_share_locked_pixbuf = composite_icons (plugin->daap_share_pixbuf, emblem);
483
389
 
484
390
        if (emblem != NULL) {
485
391
                g_object_unref (emblem);
493
399
{
494
400
        GdkPixbuf *icon;
495
401
 
496
 
        g_return_val_if_fail (plugin->priv->daap_share_pixbuf != NULL, NULL);
497
 
        g_return_val_if_fail (plugin->priv->daap_share_locked_pixbuf != NULL, NULL);
 
402
        g_return_val_if_fail (plugin->daap_share_pixbuf != NULL, NULL);
 
403
        g_return_val_if_fail (plugin->daap_share_locked_pixbuf != NULL, NULL);
498
404
 
499
405
        if (password_protected == FALSE) {
500
 
                icon = g_object_ref (plugin->priv->daap_share_pixbuf);
 
406
                icon = g_object_ref (plugin->daap_share_pixbuf);
501
407
        } else if (connected) {
502
 
                icon = g_object_ref (plugin->priv->daap_share_pixbuf);
 
408
                icon = g_object_ref (plugin->daap_share_pixbuf);
503
409
        } else {
504
 
                icon = g_object_ref (plugin->priv->daap_share_locked_pixbuf);
 
410
                icon = g_object_ref (plugin->daap_share_locked_pixbuf);
505
411
        }
506
412
 
507
413
        return icon;
515
421
{
516
422
        RBSource *source;
517
423
 
518
 
        source = g_hash_table_lookup (plugin->priv->source_lookup, service_name);
 
424
        source = g_hash_table_lookup (plugin->source_lookup, service_name);
519
425
 
520
426
        return source;
521
427
}
523
429
static void
524
430
mdns_service_added (DMAPMdnsBrowser *browser,
525
431
                    DMAPMdnsBrowserService *service,
526
 
                    RBDaapPlugin        *plugin)
 
432
                    RBDaapPlugin *plugin)
527
433
{
528
434
        RBSource *source;
 
435
        RBShell *shell;
529
436
 
530
437
        rb_debug ("New service: %s name=%s host=%s port=%u password=%d",
531
438
                   service->service_name,
539
446
        source = find_source_by_service_name (plugin, service->service_name);
540
447
 
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);
 
450
 
 
451
                source = rb_daap_source_new (shell,
 
452
                                             G_OBJECT (plugin),
 
453
                                             service->service_name,
 
454
                                             service->name,
 
455
                                             service->host,
 
456
                                             service->port,
 
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);
 
462
 
 
463
                g_object_unref (shell);
545
464
        } else {
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,
567
486
 
568
487
        rb_debug ("DAAP source '%s' went away", service_name);
569
488
        if (source != NULL) {
570
 
                g_hash_table_remove (plugin->priv->source_lookup, service_name);
 
489
                g_hash_table_remove (plugin->source_lookup, service_name);
571
490
        }
572
491
 
573
492
        GDK_THREADS_LEAVE ();
592
511
{
593
512
        GError *error;
594
513
 
595
 
        if (plugin->priv->mdns_browser != NULL) {
 
514
        if (plugin->mdns_browser != NULL) {
596
515
                return;
597
516
        }
598
517
 
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");
602
521
                return;
603
522
        }
604
523
 
605
 
        g_signal_connect_object (plugin->priv->mdns_browser,
 
524
        g_signal_connect_object (plugin->mdns_browser,
606
525
                                 "service-added",
607
526
                                 G_CALLBACK (mdns_service_added),
608
527
                                 plugin,
609
528
                                 0);
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),
613
532
                                 plugin,
614
533
                                 0);
615
534
 
616
535
        error = NULL;
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);
621
540
        }
622
541
 
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);
631
550
{
632
551
        GError *error;
633
552
 
634
 
        if (plugin->priv->mdns_browser == NULL) {
 
553
        if (plugin->mdns_browser == NULL) {
635
554
                return;
636
555
        }
637
556
 
638
557
        rb_debug ("Destroying DAAP source lookup");
639
558
 
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;
642
561
 
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);
645
564
 
646
565
        error = NULL;
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);
651
570
        }
652
571
 
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;
655
574
}
656
575
 
657
576
static void
658
 
enable_browsing_changed_cb (GConfClient *client,
659
 
                            guint cnxn_id,
660
 
                            GConfEntry *entry,
661
 
                            RBDaapPlugin *plugin)
 
577
dacp_settings_changed_cb (GSettings *settings, const char *key, RBDaapPlugin *plugin)
662
578
{
663
 
        gboolean enabled = eel_gconf_get_boolean (CONF_ENABLE_BROWSING);
664
 
 
665
 
        if (enabled) {
666
 
                start_browsing (plugin);
667
 
        } else {
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);
 
582
                } else {
 
583
                        dacp_share_stop_lookup (plugin->dacp_share);
 
584
                }
669
585
        }
670
586
}
671
587
 
672
588
static void
673
 
enable_remote_changed_cb (GConfClient *client,
674
 
                            guint cnxn_id,
675
 
                            GConfEntry *entry,
676
 
                            RBDaapPlugin *plugin)
 
589
settings_changed_cb (GSettings *settings, const char *key, RBDaapPlugin *plugin)
677
590
{
678
 
        gboolean enabled = eel_gconf_get_boolean (CONF_ENABLE_REMOTE);
679
 
 
680
 
        if (enabled) {
681
 
                dacp_share_start_lookup (plugin->priv->dacp_share);
682
 
        } else {
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);
 
594
                } else {
 
595
                        stop_browsing (plugin);
 
596
                }
 
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);
 
601
 
 
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"));
 
604
 
 
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);
684
607
        }
685
608
}
686
609
 
729
652
 
730
653
        rb_debug ("adding manually specified DAAP share at %s", location);
731
654
        service.name = (char *) location;
732
 
        service.host = (char *) location;
 
655
        service.host = (char *) host;
733
656
        service.service_name = service.name;
734
657
        service.port = port;
735
658
        service.password_protected = FALSE;
793
716
        s = strchr (ip, ':');
794
717
        *s = '\0';
795
718
 
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);
797
720
 
798
721
        g_free (ip);
799
722
 
800
723
        return source;
801
724
}
802
725
 
 
726
gboolean
 
727
rb_daap_plugin_shutdown (RBDaapPlugin *plugin)
 
728
{
 
729
        return plugin->shutdown;
 
730
}
 
731
 
803
732
/* preferences dialog */
804
733
 
805
 
static void
806
 
preferences_response_cb (GtkWidget *dialog, gint response, RBPlugin *plugin)
807
 
{
808
 
        gtk_widget_hide (dialog);
809
 
}
810
 
 
811
 
static void
812
 
share_check_button_toggled_cb (GtkToggleButton *button,
813
 
                               GtkBuilder *builder)
814
 
{
815
 
        gboolean b;
816
 
        GtkToggleButton *password_check;
817
 
        GtkWidget *password_entry;
818
 
 
819
 
        b = gtk_toggle_button_get_active (button);
820
 
 
821
 
        eel_gconf_set_boolean (CONF_DAAP_ENABLE_SHARING, b);
822
 
 
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"));
825
 
 
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);
828
 
}
829
 
 
830
 
static void
831
 
remote_check_button_toggled_cb (GtkToggleButton *button,
832
 
                               gpointer data)
833
 
{
834
 
        gboolean b;
835
 
 
836
 
        b = gtk_toggle_button_get_active (button);
837
 
 
838
 
        eel_gconf_set_boolean (CONF_ENABLE_REMOTE, b);
839
 
}
840
 
 
841
 
static void
842
 
password_check_button_toggled_cb (GtkToggleButton *button,
843
 
                                  GtkWidget *widget)
844
 
{
845
 
        gboolean b;
846
 
 
847
 
        b = gtk_toggle_button_get_active (button);
848
 
 
849
 
        eel_gconf_set_boolean (CONF_DAAP_REQUIRE_PASSWORD, b);
850
 
 
851
 
        gtk_widget_set_sensitive (widget, b);
852
 
}
 
734
/* should move this to a separate class really */
853
735
 
854
736
static void
855
737
forget_remotes_button_toggled_cb (GtkToggleButton *button,
856
 
                                  gpointer data)
 
738
                                  RBDaapPlugin *plugin)
857
739
{
858
 
        eel_gconf_unset (CONF_KNOWN_REMOTES);
 
740
        g_settings_reset (plugin->dacp_settings, "known-remotes");
859
741
}
860
742
 
861
743
static gboolean
862
744
share_name_entry_focus_out_event_cb (GtkEntry *entry,
863
745
                                     GdkEventFocus *event,
864
 
                                     gpointer data)
 
746
                                     RBDaapPlugin *plugin)
865
747
{
866
748
        gboolean    changed;
867
749
        const char *name;
868
750
        char       *old_name;
869
751
 
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");
872
754
 
873
755
        if (name == NULL && old_name == NULL) {
874
756
                changed = FALSE;
880
762
                changed = FALSE;
881
763
        }
882
764
 
883
 
        if (changed)
884
 
                eel_gconf_set_string (CONF_DAAP_SHARE_NAME, name);
 
765
        if (changed) {
 
766
                g_settings_set_string (plugin->settings, "share-name", name);
 
767
        }
885
768
 
886
769
        g_free (old_name);
887
770
 
891
774
static gboolean
892
775
share_password_entry_focus_out_event_cb (GtkEntry *entry,
893
776
                                         GdkEventFocus *event,
894
 
                                         gpointer data)
 
777
                                         RBDaapPlugin *plugin)
895
778
{
896
779
        gboolean    changed;
897
780
        const char *pw;
898
781
        char       *old_pw;
899
782
 
900
783
        pw = gtk_entry_get_text (entry);
901
 
        old_pw = eel_gconf_get_string (CONF_DAAP_SHARE_PASSWORD);
 
784
        old_pw = g_settings_get_string (plugin->settings, "share-password");
902
785
 
903
786
        if (pw == NULL && old_pw == NULL) {
904
787
                changed = FALSE;
910
793
                changed = FALSE;
911
794
        }
912
795
 
913
 
        if (changed)
914
 
                eel_gconf_set_string (CONF_DAAP_SHARE_PASSWORD, pw);
 
796
        if (changed) {
 
797
                g_settings_set_string (plugin->settings, "share-password", pw);
 
798
        }
915
799
 
916
800
        g_free (old_pw);
917
801
 
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;
933
814
        char *name;
934
815
        char *password;
935
816
 
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"));
942
 
 
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);
946
 
 
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);
950
 
 
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);
954
 
 
955
 
        g_signal_connect (forget_remotes_button, "clicked", G_CALLBACK (forget_remotes_button_toggled_cb), NULL);
956
 
 
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"));
 
823
 
 
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);
 
826
 
 
827
        /*g_signal_connect (check, "toggled", G_CALLBACK (share_check_button_toggled_cb), plugin->builder);*/
 
828
 
 
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);
 
832
 
 
833
        g_signal_connect_object (forget_remotes_button, "clicked", G_CALLBACK (forget_remotes_button_toggled_cb), plugin, 0);
 
834
 
 
835
        name = g_settings_get_string (plugin->settings, "share-name");
 
836
        if (name == NULL || name[0] == '\0') {
 
837
                g_free (name);
959
838
                name = rb_daap_sharing_default_share_name ();
960
 
        if (name != NULL)
 
839
        }
 
840
        if (name != NULL) {
961
841
                gtk_entry_set_text (GTK_ENTRY (name_entry), name);
962
 
        g_free (name);
963
 
        g_signal_connect (name_entry, "focus-out-event",
964
 
                          G_CALLBACK (share_name_entry_focus_out_event_cb), NULL);
 
842
                g_free (name);
 
843
        }
 
844
        g_signal_connect_object (name_entry,
 
845
                                 "focus-out-event",
 
846
                                 G_CALLBACK (share_name_entry_focus_out_event_cb),
 
847
                                 plugin,
 
848
                                 0);
965
849
 
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);
969
 
        g_free (password);
970
 
        g_signal_connect (password_entry, "focus-out-event",
971
 
                          G_CALLBACK (share_password_entry_focus_out_event_cb), NULL);
 
853
                g_free (password);
 
854
        }
 
855
        g_signal_connect_object (password_entry,
 
856
                                 "focus-out-event",
 
857
                                 G_CALLBACK (share_password_entry_focus_out_event_cb),
 
858
                                 plugin,
 
859
                                 0);
972
860
 
973
 
        gtk_widget_set_sensitive (password_entry, require_password);
 
861
        /*gtk_widget_set_sensitive (password_entry, require_password);*/
974
862
}
975
863
 
976
864
static GtkWidget *
977
 
make_config_widget (RBDaapPlugin *plugin)
 
865
impl_create_configure_widget (PeasGtkConfigurable *bplugin)
978
866
{
979
867
        char *builder_file;
 
868
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
980
869
 
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) {
983
872
                return NULL;
984
873
        }
985
874
 
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);
988
877
 
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"));
991
880
}
992
881
 
993
 
 
994
 
static GtkWidget*
995
 
impl_create_configure_dialog (RBPlugin *bplugin)
 
882
static void
 
883
peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
996
884
{
997
 
        RBDaapPlugin *plugin = RB_DAAP_PLUGIN (bplugin);
998
 
 
999
 
        if (plugin->priv->preferences == NULL) {
1000
 
                GtkWidget *widget;
1001
 
 
1002
 
                widget = make_config_widget (plugin);
1003
 
 
1004
 
                plugin->priv->preferences = gtk_dialog_new_with_buttons (_("DAAP Music Sharing Preferences"),
1005
 
                                                                   NULL,
1006
 
                                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
1007
 
                                                                   GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
1008
 
                                                                   NULL);
1009
 
                g_signal_connect (G_OBJECT (plugin->priv->preferences),
1010
 
                                  "response",
1011
 
                                  G_CALLBACK (preferences_response_cb),
1012
 
                                  plugin);
1013
 
                gtk_widget_hide_on_delete (plugin->priv->preferences);
1014
 
 
1015
 
                gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (plugin->priv->preferences))),
1016
 
                                   widget);
1017
 
        } else {
1018
 
                update_config_widget (plugin);
1019
 
        }
1020
 
 
1021
 
        gtk_widget_show_all (plugin->priv->preferences);
1022
 
        return plugin->priv->preferences;
 
885
        iface->create_configure_widget = impl_create_configure_widget;
1023
886
}
1024
887
 
1025
888
/* DAAP DBus interface */
1034
897
                       GDBusMethodInvocation *invocation,
1035
898
                       RBDaapPlugin *plugin)
1036
899
{
1037
 
        if (plugin->priv->shutdown) {
 
900
        if (plugin->shutdown) {
1038
901
                rb_debug ("ignoring %s call", method_name);
1039
902
                return;
1040
903
        }
1055
918
 
1056
919
                g_variant_get (parameters, "(&s)", &service_name);
1057
920
                rb_debug ("removing DAAP source %s", service_name);
1058
 
                mdns_service_removed (plugin->priv->mdns_browser, service_name, plugin);
 
921
                mdns_service_removed (plugin->mdns_browser, service_name, plugin);
1059
922
 
1060
923
                g_dbus_method_invocation_return_value (invocation, NULL);
1061
924
        }
1074
937
        GDBusNodeInfo *node_info;
1075
938
        GDBusInterfaceInfo *iface_info;
1076
939
 
1077
 
        if (plugin->priv->dbus_intf_id != 0) {
 
940
        if (plugin->dbus_intf_id != 0) {
1078
941
                rb_debug ("DAAP DBus interface already registered");
1079
942
                return;
1080
943
        }
1081
944
 
1082
 
        if (plugin->priv->bus == NULL) {
1083
 
                plugin->priv->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
1084
 
                if (plugin->priv->bus == NULL) {
 
945
        if (plugin->bus == NULL) {
 
946
                plugin->bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
 
947
                if (plugin->bus == NULL) {
1085
948
                        rb_debug ("Unable to register DAAP DBus interface: %s", error->message);
1086
949
                        g_clear_error (&error);
1087
950
                        return;
1096
959
        }
1097
960
 
1098
961
        iface_info = g_dbus_node_info_lookup_interface (node_info, DAAP_DBUS_IFACE);
1099
 
        plugin->priv->dbus_intf_id =
1100
 
                g_dbus_connection_register_object (plugin->priv->bus,
 
962
        plugin->dbus_intf_id =
 
963
                g_dbus_connection_register_object (plugin->bus,
1101
964
                                                   DAAP_DBUS_PATH,
1102
965
                                                   iface_info,
1103
966
                                                   &daap_dbus_vtable,
1115
978
static void
1116
979
unregister_daap_dbus_iface (RBDaapPlugin *plugin)
1117
980
{
1118
 
        if (plugin->priv->dbus_intf_id == 0) {
 
981
        if (plugin->dbus_intf_id == 0) {
1119
982
                rb_debug ("DAAP DBus interface not registered");
1120
983
                return;
1121
984
        }
1122
985
 
1123
 
        if (plugin->priv->bus == NULL) {
 
986
        if (plugin->bus == NULL) {
1124
987
                rb_debug ("no bus connection");
1125
988
                return;
1126
989
        }
1127
990
 
1128
 
        g_dbus_connection_unregister_object (plugin->priv->bus, plugin->priv->dbus_intf_id);
1129
 
        plugin->priv->dbus_intf_id = 0;
1130
 
}
1131
 
 
 
991
        g_dbus_connection_unregister_object (plugin->bus, plugin->dbus_intf_id);
 
992
        plugin->dbus_intf_id = 0;
 
993
}
 
994
 
 
995
G_MODULE_EXPORT void
 
996
peas_register_types (PeasObjectModule *module)
 
997
{
 
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));
 
1008
 
 
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);
 
1015
}