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 = rhythmdb_entry_register_type (db, name); entry_type->save_to_disk = FALSE; entry_type->category = RHYTHMDB_ENTRY_NORMAL; 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_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; }