static gboolean load_uri_args (const char **args, GFunc handler, gpointer user_data) { gboolean handled; guint i; handled = FALSE; for (i = 0; args && args[i]; i++) { GFile *file; char *uri; rb_debug ("examining argument %s", args[i]); file = g_file_new_for_commandline_arg (args[i]); uri = g_file_get_uri (file); /* * rb_uri_exists won't work if the location isn't mounted. * however, things that are interesting to mount are generally * non-local, so we'll process them anyway. */ if (rb_uri_is_local (uri) == FALSE || rb_uri_exists (uri)) { handler (uri, user_data); } g_free (uri); g_object_unref (file); handled = TRUE; } return handled; }
static guint impl_want_uri (RBSource *source, const char *uri) { /* take anything local, on smb, or sftp */ if (rb_uri_is_local (uri) || g_str_has_prefix (uri, "smb://") || g_str_has_prefix (uri, "sftp://")) return 25; /* less than what the library returns */ return 0; }
static void rhythmdb_mount_added_cb (GVolumeMonitor *monitor, GMount *mount, RhythmDB *db) { GList *l; RhythmDBQueryResultList *list; char *mountpoint; GFile *root; root = g_mount_get_root (mount); mountpoint = g_file_get_uri (root); rb_debug ("volume %s mounted", mountpoint); g_object_unref (root); list = rhythmdb_query_result_list_new (); rhythmdb_do_full_query (db, RHYTHMDB_QUERY_RESULTS (list), RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_SONG, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_MOUNTPOINT, mountpoint, RHYTHMDB_QUERY_END); l = rhythmdb_query_result_list_get_results (list); rb_debug ("%d mounted entries to process", g_list_length (l)); for (; l != NULL; l = l->next) { RhythmDBEntry *entry = l->data; const char *location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); rhythmdb_entry_update_availability (entry, RHYTHMDB_ENTRY_AVAIL_MOUNTED); if (rb_uri_is_local (location)) { rhythmdb_add_uri_with_types (db, location, RHYTHMDB_ENTRY_TYPE_SONG, RHYTHMDB_ENTRY_TYPE_IGNORE, RHYTHMDB_ENTRY_TYPE_IMPORT_ERROR); } } g_object_unref (list); g_free (mountpoint); rhythmdb_commit (db); }
static void impl_add_uri (RBSource *source, const char *uri, const char *title, const char *genre, RBSourceAddCallback callback, gpointer data, GDestroyNotify destroy_data) { if (rb_uri_is_local (uri)) { rb_iradio_source_add_from_playlist (RB_IRADIO_SOURCE (source), uri); } else { rb_iradio_source_add_station (RB_IRADIO_SOURCE (source), uri, title, genre); } if (callback != NULL) { callback (source, uri, data); if (destroy_data != NULL) { destroy_data (data); } } }