RBSource * rb_podcast_main_source_new (RBShell *shell, RBPodcastManager *podcast_manager) { RBSource *source; RhythmDBQuery *base_query; RhythmDB *db; g_object_get (shell, "db", &db, NULL); base_query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_PODCAST_POST, RHYTHMDB_QUERY_END); g_object_unref (db); source = RB_SOURCE (g_object_new (RB_TYPE_PODCAST_MAIN_SOURCE, "name", _("Podcasts"), "shell", shell, "entry-type", RHYTHMDB_ENTRY_TYPE_PODCAST_POST, "source-group", RB_SOURCE_GROUP_LIBRARY, "search-type", RB_SOURCE_SEARCH_INCREMENTAL, "podcast-manager", podcast_manager, "base-query", base_query, NULL)); rhythmdb_query_free (base_query); rb_shell_register_entry_type_for_source (shell, source, RHYTHMDB_ENTRY_TYPE_PODCAST_FEED); rb_shell_register_entry_type_for_source (shell, source, RHYTHMDB_ENTRY_TYPE_PODCAST_POST); return source; }
RBSource * rb_iradio_source_new (RBShell *shell, GObject *plugin) { RBSource *source; RhythmDBEntryType *entry_type; RhythmDB *db; GSettings *settings; g_object_get (shell, "db", &db, NULL); entry_type = rhythmdb_entry_type_get_by_name (db, "iradio"); if (entry_type == NULL) { entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", "iradio", "save-to-disk", TRUE, "category", RHYTHMDB_ENTRY_STREAM, NULL); rhythmdb_register_entry_type (db, entry_type); } g_object_unref (db); settings = g_settings_new ("org.gnome.rhythmbox.plugins.iradio"); source = RB_SOURCE (g_object_new (RB_TYPE_IRADIO_SOURCE, "name", _("Radio"), "shell", shell, "entry-type", entry_type, "plugin", plugin, "settings", g_settings_get_child (settings, "source"), "toolbar-path", "/IRadioSourceToolBar", NULL)); g_object_unref (settings); rb_shell_register_entry_type_for_source (shell, source, entry_type); return source; }
RBSource * rb_mtp_source_new (RBShell *shell, GObject *plugin, #if defined(HAVE_GUDEV) GUdevDevice *udev_device, #else const char *udi, #endif LIBMTP_raw_device_t *device) { RBMtpSource *source = NULL; RhythmDBEntryType *entry_type; RhythmDB *db = NULL; GSettings *settings; GtkBuilder *builder; GMenu *toolbar; char *name = NULL; g_object_get (shell, "db", &db, NULL); name = g_strdup_printf ("MTP-%u-%d", device->bus_location, device->devnum); entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, NULL); g_free (name); g_object_unref (db); builder = rb_builder_load_plugin_file (plugin, "mtp-toolbar.ui", NULL); toolbar = G_MENU (gtk_builder_get_object (builder, "mtp-toolbar")); rb_application_link_shared_menus (RB_APPLICATION (g_application_get_default ()), toolbar); settings = g_settings_new ("org.gnome.rhythmbox.plugins.mtpdevice"); source = RB_MTP_SOURCE (g_object_new (RB_TYPE_MTP_SOURCE, "plugin", plugin, "entry-type", entry_type, "shell", shell, "visibility", TRUE, "raw-device", device, #if defined(HAVE_GUDEV) "udev-device", udev_device, #else "udi", udi, #endif "load-status", RB_SOURCE_LOAD_STATUS_LOADING, "settings", g_settings_get_child (settings, "source"), "encoding-settings", g_settings_get_child (settings, "encoding"), "toolbar-menu", toolbar, "name", _("Media Player"), NULL)); g_object_unref (settings); g_object_unref (builder); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_SOURCE (source); }
RBSource * rb_podcast_main_source_new (RBShell *shell, RBPodcastManager *podcast_manager) { RBSource *source; RhythmDBQuery *base_query; RhythmDB *db; GSettings *settings; g_object_get (shell, "db", &db, NULL); base_query = rhythmdb_query_parse (db, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_PODCAST_POST, RHYTHMDB_QUERY_END); g_object_unref (db); settings = g_settings_new (PODCAST_SETTINGS_SCHEMA); source = RB_SOURCE (g_object_new (RB_TYPE_PODCAST_MAIN_SOURCE, "name", _("Podcasts"), "shell", shell, "entry-type", RHYTHMDB_ENTRY_TYPE_PODCAST_POST, "podcast-manager", podcast_manager, "base-query", base_query, "settings", g_settings_get_child (settings, "source"), "toolbar-path", "/PodcastSourceToolBar", "show-all-feeds", TRUE, NULL)); g_object_unref (settings); rhythmdb_query_free (base_query); rb_shell_register_entry_type_for_source (shell, source, RHYTHMDB_ENTRY_TYPE_PODCAST_FEED); rb_shell_register_entry_type_for_source (shell, source, RHYTHMDB_ENTRY_TYPE_PODCAST_POST); return source; }
RBRemovableMediaSource * rb_generic_player_source_new (RBShell *shell, GMount *mount) { RBGenericPlayerSource *source; RhythmDBEntryType entry_type; RhythmDBEntryType error_type; RhythmDBEntryType ignore_type; RhythmDB *db; GVolume *volume; char *name; char *path; g_assert (rb_generic_player_is_mount_player (mount)); volume = g_mount_get_volume (mount); g_object_get (G_OBJECT (shell), "db", &db, NULL); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); name = g_strdup_printf ("generic audio player: %s", path); entry_type = rhythmdb_entry_register_type (db, name); g_free (name); name = g_strdup_printf ("generic audio player (ignore): %s", path); ignore_type = rhythmdb_entry_register_type (db, name); g_free (name); name = g_strdup_printf ("generic audio player (errors): %s", path); error_type = rhythmdb_entry_register_type (db, name); g_free (name); g_object_unref (db); g_object_unref (volume); g_free (path); source = RB_GENERIC_PLAYER_SOURCE (g_object_new (RB_TYPE_GENERIC_PLAYER_SOURCE, "entry-type", entry_type, "ignore-entry-type", ignore_type, "error-entry-type", error_type, "mount", mount, "shell", shell, "source-group", RB_SOURCE_GROUP_DEVICES, NULL)); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_REMOVABLE_MEDIA_SOURCE (source); }
RBSource * rb_mtp_source_new (RBShell *shell, RBPlugin *plugin, #if defined(HAVE_GUDEV) GUdevDevice *udev_device, #else const char *udi, #endif LIBMTP_raw_device_t *device) { RBMtpSource *source = NULL; RhythmDBEntryType *entry_type; RhythmDB *db = NULL; char *name = NULL; g_object_get (shell, "db", &db, NULL); name = g_strdup_printf ("MTP-%u-%d", device->bus_location, device->devnum); entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, NULL); g_free (name); g_object_unref (db); source = RB_MTP_SOURCE (g_object_new (RB_TYPE_MTP_SOURCE, "plugin", plugin, "entry-type", entry_type, "shell", shell, "visibility", TRUE, "volume", NULL, "source-group", RB_SOURCE_GROUP_DEVICES, "raw-device", device, #if defined(HAVE_GUDEV) "udev-device", udev_device, #else "udi", udi, #endif NULL)); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_SOURCE (source); }
RBSource * rb_grilo_source_new (GObject *plugin, GrlSource *grilo_source) { GObject *source; RBShell *shell; GSettings *settings; RhythmDBEntryType *entry_type; RhythmDB *db; char *name; name = g_strdup_printf ("grilo:%s", grl_source_get_id (grilo_source)); g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "db", &db, NULL); entry_type = g_object_new (rb_grilo_entry_type_get_type (), "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, "type-data-size", sizeof(RBGriloEntryData), NULL); rhythmdb_register_entry_type (db, entry_type); g_object_unref (db); g_free (name); settings = g_settings_new ("org.gnome.rhythmbox.plugins.grilo"); source = g_object_new (RB_TYPE_GRILO_SOURCE, "name", grl_source_get_name (grilo_source), "entry-type", entry_type, "shell", shell, "plugin", plugin, "show-browser", FALSE, "settings", g_settings_get_child (settings, "source"), "grilo-source", grilo_source, NULL); g_object_unref (settings); rb_display_page_set_icon_name (RB_DISPLAY_PAGE (source), "network-server-symbolic"); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); g_object_unref (shell); return RB_SOURCE (source); }
RBSource * rb_psp_source_new (GObject *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info) { RBPspSource *source; RhythmDBEntryType *entry_type; RhythmDB *db; char *name; char *path; GVolume *volume; g_assert (rb_psp_is_mount_player (mount, device_info)); volume = g_mount_get_volume (mount); g_object_get (G_OBJECT (shell), "db", &db, NULL); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); name = g_strdup_printf ("psp: %s", path); entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, NULL); rhythmdb_register_entry_type (db, entry_type); g_object_unref (db); g_free (name); g_free (path); g_object_unref (volume); source = RB_PSP_SOURCE (g_object_new (RB_TYPE_PSP_SOURCE, "plugin", plugin, "entry-type", entry_type, "mount", mount, "shell", shell, "device-info", device_info, NULL)); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_SOURCE (source); }
RBSource * rb_audiocd_source_new (RBPlugin *plugin, RBShell *shell, GVolume *volume) { GObject *source; RhythmDBEntryType entry_type; RhythmDB *db; char *name; char *path; g_object_get (shell, "db", &db, NULL); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); name = g_strdup_printf ("audiocd: %s", path); entry_type = rhythmdb_entry_register_type (db, name); g_free (name); g_free (path); g_object_unref (db); entry_type->category = RHYTHMDB_ENTRY_NORMAL; entry_type->can_sync_metadata = (RhythmDBEntryCanSyncFunc)rb_true_function; /* TODO save the metadata somewhere */ entry_type->sync_metadata = (RhythmDBEntrySyncFunc)rb_null_function; entry_type->entry_type_data_size = sizeof(RBAudioCDEntryData); source = g_object_new (RB_TYPE_AUDIOCD_SOURCE, "entry-type", entry_type, "volume", volume, "shell", shell, "sorting-key", NULL, "source-group", RB_SOURCE_GROUP_DEVICES, "plugin", plugin, NULL); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_SOURCE (source); }
RBRemovableMediaSource * rb_nokia770_source_new (RBPlugin *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info) { RBNokia770Source *source; RhythmDBEntryType entry_type; RhythmDB *db; GVolume *volume; char *name; char *path; g_assert (rb_nokia770_is_mount_player (mount, device_info)); volume = g_mount_get_volume (mount); g_object_get (G_OBJECT (shell), "db", &db, NULL); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); name = g_strdup_printf ("nokia770: %s", path); entry_type = rhythmdb_entry_register_type (db, name); g_object_unref (db); g_free (name); g_free (path); g_object_unref (volume); source = RB_NOKIA770_SOURCE (g_object_new (RB_TYPE_NOKIA770_SOURCE, "plugin", plugin, "entry-type", entry_type, "ignore-entry-type", RHYTHMDB_ENTRY_TYPE_INVALID, "error-entry-type", RHYTHMDB_ENTRY_TYPE_INVALID, "mount", mount, "shell", shell, "source-group", RB_SOURCE_GROUP_DEVICES, "device-info", device_info, NULL)); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_REMOVABLE_MEDIA_SOURCE (source); }
RBBrowserSource * rb_mtp_source_new (RBShell *shell, LIBMTP_mtpdevice_t *device, const char *udi) { RBMtpSource *source = NULL; RhythmDBEntryType entry_type; RhythmDB *db = NULL; char *name = NULL; g_object_get (shell, "db", &db, NULL); name = g_strdup_printf ("MTP-%s", LIBMTP_Get_Serialnumber (device)); entry_type = rhythmdb_entry_register_type (db, name); entry_type->save_to_disk = FALSE; entry_type->category = RHYTHMDB_ENTRY_NORMAL; entry_type->get_playback_uri = (RhythmDBEntryStringFunc)rb_mtp_source_get_playback_uri; g_free (name); g_object_unref (db); source = RB_MTP_SOURCE (g_object_new (RB_TYPE_MTP_SOURCE, "entry-type", entry_type, "shell", shell, "visibility", TRUE, "volume", NULL, "source-group", RB_SOURCE_GROUP_DEVICES, "libmtp-device", device, "udi", udi, NULL)); entry_type->get_playback_uri_data = source; rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_BROWSER_SOURCE (source); }
static void impl_activate (RBPlugin *plugin, RBShell *shell) { // rb_error_dialog (NULL, _("Spotify Plugin"), "Spotify plugin activated, with shell %p", shell); RBSpotifySource *source; RhythmDBEntryType type; RhythmDB *db; char *entry_type_name, *username, *password; int err; RBSpotifyPluginPrivate *pprivate = RB_SPOTIFY_PLUGIN_GET_PRIVATE(plugin); pthread_mutex_init(&g_notify_mutex, NULL); pthread_cond_init(&g_notify_cond, NULL); audio_fifo_init(&g_audio_fifo); spconfig.application_key_size = g_appkey_size; err = sp_session_init(&spconfig, &pprivate->sess); if (err != SP_ERROR_OK) { rb_error_dialog (NULL, _("Spotify Plugin"), "Error initialising spotify session"); pprivate->sess = NULL; return; } fprintf(stderr, "err: %x", err); err = pthread_create(&pprivate->notify_thread, 0, notification_routine, pprivate->sess); fprintf(stderr, "Thread created"); if (err != 0) { fprintf(stderr, "Error creating notification thread %x\n", err); return; } username = eel_gconf_get_string (CONF_SPOTIFY_USERNAME); password = eel_gconf_get_string (CONF_SPOTIFY_PASSWORD); if (username == NULL || password == NULL) { rb_error_dialog (NULL, _("Spotify Plugin"), "Username and password not set."); return; } err = sp_session_login(pprivate->sess, username, password); fprintf(stderr, "err: %x", err); rbspotifysrc_set_plugin(plugin); g_object_get (shell, "db", &db, NULL); entry_type_name = g_strdup_printf ("spotify"); type = rhythmdb_entry_register_type (db, entry_type_name); g_free (entry_type_name); type->save_to_disk = FALSE; type->category = RHYTHMDB_ENTRY_NORMAL; // type->get_playback_uri = (RhythmDBEntryStringFunc) rb_daap_source_get_playback_uri; g_object_unref (db); // icon = rb_daap_plugin_get_icon (RB_DAAP_PLUGIN (plugin), password_protected, FALSE); source = (RBSpotifySource*)RB_SOURCE (g_object_new (RBSPOTIFYSOURCE_TYPE, "name", "spotify", "entry-type", type, "shell", shell, "visibility", TRUE, // "sorting-key", CONF_STATE_SORTING, "source-group", RB_SOURCE_GROUP_SHARED, "plugin", RB_PLUGIN (plugin), NULL)); source->priv->sess = pprivate->sess; source->priv->db = db; source->priv->type = type; rb_shell_register_entry_type_for_source (shell, (RBSource*)source, type); rb_shell_append_source (shell, (RBSource*)source, NULL); // return source; }
RBSource * rb_generic_player_source_new (GObject *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info) { RBGenericPlayerSource *source; RhythmDBEntryType *entry_type; RhythmDBEntryType *error_type; RhythmDBEntryType *ignore_type; RhythmDB *db; GVolume *volume; GSettings *settings; char *name; char *path; volume = g_mount_get_volume (mount); g_object_get (shell, "db", &db, NULL); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); name = g_strdup_printf ("generic audio player: %s", path); entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, NULL); rhythmdb_register_entry_type (db, entry_type); g_free (name); name = g_strdup_printf ("generic audio player (ignore): %s", path); ignore_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_VIRTUAL, NULL); rhythmdb_register_entry_type (db, ignore_type); g_free (name); name = g_strdup_printf ("generic audio player (errors): %s", path); error_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_VIRTUAL, NULL); rhythmdb_register_entry_type (db, error_type); g_free (name); g_object_unref (db); g_object_unref (volume); g_free (path); settings = g_settings_new ("org.gnome.rhythmbox.plugins.generic-player"); source = RB_GENERIC_PLAYER_SOURCE (g_object_new (RB_TYPE_GENERIC_PLAYER_SOURCE, "plugin", plugin, "entry-type", entry_type, "ignore-entry-type", ignore_type, "error-entry-type", error_type, "mount", mount, "shell", shell, "device-info", device_info, "load-status", RB_SOURCE_LOAD_STATUS_LOADING, "settings", g_settings_get_child (settings, "source"), "toolbar-path", "/GenericPlayerSourceToolBar", NULL)); g_object_unref (settings); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); return RB_SOURCE (source); }
static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBGenericPlayerPlugin *plugin) { RBSource *source = NULL; GType source_type = G_TYPE_NONE; RBShell *shell; RhythmDB *db; RhythmDBEntryType *entry_type; RhythmDBEntryType *error_type; RhythmDBEntryType *ignore_type; GtkBuilder *builder; GMenu *toolbar; GVolume *volume; GSettings *settings; const char *name_prefix; char *name; char *path; if (rb_psp_is_mount_player (mount, device_info)) { source_type = RB_TYPE_PSP_SOURCE; name_prefix = "psp"; } else if (rb_nokia770_is_mount_player (mount, device_info)) { source_type = RB_TYPE_NOKIA770_SOURCE; name_prefix = "nokia770"; } else if (rb_generic_player_is_mount_player (mount, device_info)) { source_type = RB_TYPE_GENERIC_PLAYER_SOURCE; name_prefix = "generic-player"; } else { return NULL; } volume = g_mount_get_volume (mount); path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); g_object_get (plugin, "object", &shell, NULL); g_object_get (shell, "db", &db, NULL); name = g_strdup_printf ("%s: %s", name_prefix, path); entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_NORMAL, NULL); rhythmdb_register_entry_type (db, entry_type); g_free (name); name = g_strdup_printf ("%s (ignore): %s", name_prefix, path); ignore_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_VIRTUAL, NULL); rhythmdb_register_entry_type (db, ignore_type); g_free (name); name = g_strdup_printf ("%s (errors): %s", name_prefix, path); error_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE, "db", db, "name", name, "save-to-disk", FALSE, "category", RHYTHMDB_ENTRY_VIRTUAL, NULL); rhythmdb_register_entry_type (db, error_type); g_free (name); g_object_unref (db); builder = rb_builder_load_plugin_file (G_OBJECT (plugin), "generic-player-toolbar.ui", NULL); toolbar = G_MENU (gtk_builder_get_object (builder, "generic-player-toolbar")); rb_application_link_shared_menus (RB_APPLICATION (g_application_get_default ()), toolbar); settings = g_settings_new ("org.gnome.rhythmbox.plugins.generic-player"); source = RB_SOURCE (g_object_new (source_type, "plugin", plugin, "entry-type", entry_type, "ignore-entry-type", ignore_type, "error-entry-type", error_type, "mount", mount, "shell", shell, "device-info", device_info, "load-status", RB_SOURCE_LOAD_STATUS_LOADING, "settings", g_settings_get_child (settings, "source"), "encoding-settings", g_settings_get_child (settings, "encoding"), "toolbar-menu", toolbar, NULL)); g_object_unref (settings); g_object_unref (builder); rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type); plugin->player_sources = g_list_prepend (plugin->player_sources, source); g_signal_connect_object (G_OBJECT (source), "deleted", G_CALLBACK (rb_generic_player_plugin_source_deleted), plugin, 0); g_object_unref (shell); return source; }