static void process_unmounted_entries (RhythmDB *db, RhythmDBEntryType *entry_type, const char *mountpoint) { RhythmDBQueryResultList *list; GList *l; list = rhythmdb_query_result_list_new (); rhythmdb_do_full_query (db, RHYTHMDB_QUERY_RESULTS (list), RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, entry_type, RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_MOUNTPOINT, mountpoint, RHYTHMDB_QUERY_END); l = rhythmdb_query_result_list_get_results (list); rb_debug ("%d unmounted entries to process", g_list_length (l)); for (; l != NULL; l = l->next) { RhythmDBEntry *entry = l->data; rhythmdb_entry_update_availability (entry, RHYTHMDB_ENTRY_AVAIL_UNMOUNTED); } g_object_unref (list); rhythmdb_commit (db); }
/** * rb_source_update_play_statistics: * @source: a #RBSource * @db: the #RhythmDB instance * @entry: the #RhythmDBEntry to update * * Updates play count and play time statistics for a database entry. * Sources containing entries that do not normally reach EOS should * call this for an entry when it is no longer being played. */ void rb_source_update_play_statistics (RBSource *source, RhythmDB *db, RhythmDBEntry *entry) { time_t now; gulong current_count; GValue value = { 0, }; g_value_init (&value, G_TYPE_ULONG); current_count = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_PLAY_COUNT); g_value_set_ulong (&value, current_count + 1); /* Increment current play count */ rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_PLAY_COUNT, &value); g_value_unset (&value); /* Reset the last played time */ time (&now); g_value_init (&value, G_TYPE_ULONG); g_value_set_ulong (&value, now); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_LAST_PLAYED, &value); g_value_unset (&value); rhythmdb_commit (db); }
static gboolean add_entries (RBImportDialog *dialog) { int i; GValue new_type = {0,}; g_value_init (&new_type, G_TYPE_OBJECT); g_value_set_object (&new_type, RHYTHMDB_ENTRY_TYPE_SONG); for (i = 0; i < 1000; i++) { RhythmDBEntry *entry; entry = dialog->priv->add_entry_list->data; dialog->priv->add_entry_list = g_list_delete_link (dialog->priv->add_entry_list, dialog->priv->add_entry_list); rhythmdb_entry_set (dialog->priv->db, entry, RHYTHMDB_PROP_TYPE, &new_type); rhythmdb_entry_unref (entry); if (dialog->priv->add_entry_list == NULL) break; } rhythmdb_commit (dialog->priv->db); if (dialog->priv->add_entry_list == NULL) { dialog->priv->add_entries_id = 0; dialog->priv->added_entries_id = g_idle_add ((GSourceFunc) add_entries_done, dialog); return FALSE; } else { return TRUE; } }
static void feed_selection_changed_cb (GtkTreeSelection *selection, RBPodcastAddDialog *dialog) { GtkTreeModel *model; if (dialog->priv->clearing) return; dialog->priv->have_selection = gtk_tree_selection_get_selected (selection, &model, &dialog->priv->selected_feed); gtk_widget_set_sensitive (dialog->priv->subscribe_button, dialog->priv->have_selection); rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH); rhythmdb_commit (dialog->priv->db); if (dialog->priv->have_selection) { RBPodcastChannel *channel = NULL; gtk_tree_model_get (model, &dialog->priv->selected_feed, FEED_COLUMN_PARSED_FEED, &channel, -1); if (channel->posts == NULL) { rb_debug ("parsing feed %s to get posts", channel->url); parse_in_thread (dialog, channel->url, TRUE, FALSE); } else { add_posts_for_feed (dialog, channel); } } }
static void default_move_to_trash (RBSource *source) { GList *sel, *tem; RBEntryView *entry_view; RhythmDB *db; RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source); g_object_get (priv->shell, "db", &db, NULL); sel = NULL; entry_view = rb_source_get_entry_view (source); if (entry_view != NULL) { sel = rb_entry_view_get_selected_entries (entry_view); } for (tem = sel; tem != NULL; tem = tem->next) { rhythmdb_entry_move_to_trash (db, (RhythmDBEntry *)tem->data); rhythmdb_commit (db); } g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL); g_list_free (sel); g_object_unref (db); }
END_TEST START_TEST (test_rhythmdb_mirroring) { GValue val = {0,}; RhythmDBEntry *entry; const char *str; entry = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///foo.mp3"); fail_unless (entry != NULL, "failed to create entry"); /* check the last-played date is mirrored */ g_value_init (&val, G_TYPE_ULONG); g_value_set_ulong (&val, 1354285); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_LAST_PLAYED, &val); g_value_unset (&val); rhythmdb_commit (db); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LAST_PLAYED_STR); fail_unless (str && (strlen (str) > 0), "date not converted to string"); /* check folded and sort-key varients */ g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "FOO"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_TITLE, &val); g_value_unset (&val); rhythmdb_commit (db); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_SORT_KEY); fail_unless (str && (strlen (str) > 0), "sort-key not generated"); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_FOLDED); fail_unless (str && (strcmp (str, "foo") == 0), "folded variant not generated"); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "BAR"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_TITLE, &val); g_value_unset (&val); rhythmdb_commit (db); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_SORT_KEY); fail_unless (str && (strlen (str) > 0), "sort-key not generated"); str = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_FOLDED); fail_unless (str && (strcmp (str, "bar") == 0), "folded variant not generated"); }
void rb_generic_player_source_trash_or_delete_entries (RBGenericPlayerSource *source, GList *entries, gboolean _delete) { RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); GList *tem; if (priv->read_only != FALSE) return; for (tem = entries; tem != NULL; tem = tem->next) { RhythmDBEntry *entry; const char *uri; GFile *file; GFile *dir; entry = tem->data; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); file = g_file_new_for_uri (uri); if (_delete) g_file_delete (file, NULL, NULL); else g_file_trash (file, NULL, NULL); /* now walk up the directory structure and delete empty dirs * until we reach the root or one of the device's audio folders. */ dir = g_file_get_parent (file); while (can_delete_directory (source, dir)) { GFile *parent; char *path; path = g_file_get_path (dir); rb_debug ("trying to delete %s", path); g_free (path); if (g_file_delete (dir, NULL, NULL) == FALSE) { break; } parent = g_file_get_parent (dir); if (parent == NULL) { break; } g_object_unref (dir); dir = parent; } g_object_unref (dir); g_object_unref (file); rhythmdb_entry_delete (priv->db, entry); } rhythmdb_commit (priv->db); }
END_TEST START_TEST (test_rhythmdb_modify_after_delete) { RhythmDBEntry *entry; GValue val = {0,}; entry = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///whee.ogg"); fail_unless (entry != NULL, "failed to create entry"); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "Anything"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_GENRE, &val); g_value_unset (&val); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "Nothing"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ARTIST, &val); g_value_unset (&val); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "Something"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ALBUM, &val); g_value_unset (&val); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "Thing"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_TITLE, &val); g_value_unset (&val); rhythmdb_commit (db); rhythmdb_entry_ref (entry); rhythmdb_entry_delete (db, entry); rhythmdb_commit (db); g_value_init (&val, G_TYPE_STRING); g_value_set_static_string (&val, "Something Else"); rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_ALBUM, &val); g_value_unset (&val); rhythmdb_commit (db); rhythmdb_entry_unref (entry); }
END_TEST START_TEST (test_rhythmdb_multiple) { RhythmDBEntry *entry1, *entry2, *entry3; /* add multiple entries */ entry1 = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///foo.mp3"); rhythmdb_commit (db); fail_unless (entry1 != NULL, "failed to create entry"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///foo.mp3") == entry1, "entry missing"); entry2 = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///bar.mp3"); rhythmdb_commit (db); fail_unless (entry2 != NULL, "failed to create entry"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///bar.mp3") == entry2, "entry missing"); entry3 = rhythmdb_entry_new (db, RHYTHMDB_ENTRY_TYPE_IGNORE, "file:///baz.mp3"); rhythmdb_commit (db); fail_unless (entry3 != NULL, "failed to create entry"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///baz.mp3") == entry3, "entry missing"); /* check they're still there */ fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///foo.mp3") == entry1, "entry missing"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///bar.mp3") == entry2, "entry missing"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///baz.mp3") == entry3, "entry missing"); /* remove the middle one and check again */ rhythmdb_entry_delete (db, entry2); rhythmdb_commit (db); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///foo.mp3") == entry1, "entry missing"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///bar.mp3") == NULL, "entry not deleted"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///baz.mp3") == entry3, "entry missing"); /* and the others */ rhythmdb_entry_delete (db, entry1); rhythmdb_entry_delete (db, entry3); rhythmdb_commit (db); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///foo.mp3") == NULL, "entry not deleted"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///bar.mp3") == NULL, "entry not deleted"); fail_unless (rhythmdb_entry_lookup_by_location (db, "file:///baz.mp3") == NULL, "entry not deleted"); }
static void impl_delete_entries (RBMediaPlayerSource *source, GList *entries, RBMediaPlayerSourceDeleteCallback callback, gpointer user_data, GDestroyNotify destroy_data) { RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); RhythmDB *db; GList *i; TracksDeletedCallbackData *cb_data; cb_data = g_new0 (TracksDeletedCallbackData, 1); cb_data->source = g_object_ref (source); cb_data->callback_data = user_data; cb_data->callback = callback; cb_data->destroy_data = destroy_data; cb_data->check_folders = g_hash_table_new (g_direct_hash, g_direct_equal); db = get_db_for_source (RB_MTP_SOURCE (source)); for (i = entries; i != NULL; i = i->next) { LIBMTP_track_t *track; const char *uri; const char *album_name; RhythmDBEntry *entry; entry = i->data; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); track = g_hash_table_lookup (priv->entry_map, entry); if (track == NULL) { rb_debug ("Couldn't find track on mtp-device! (%s)", uri); continue; } album_name = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM); if (g_strcmp0 (album_name, _("Unknown")) != 0) { rb_mtp_thread_remove_from_album (priv->device_thread, track, album_name); } rb_mtp_thread_delete_track (priv->device_thread, track); g_hash_table_insert (cb_data->check_folders, GUINT_TO_POINTER (track->parent_id), GINT_TO_POINTER (1)); g_hash_table_remove (priv->entry_map, entry); rhythmdb_entry_delete (db, entry); } /* callback when all tracks have been deleted */ rb_mtp_thread_queue_callback (priv->device_thread, (RBMtpThreadCallback) delete_done_cb, cb_data, (GDestroyNotify) free_delete_data); rhythmdb_commit (db); }
static void copy_track_done_cb (RBTrackTransferBatch *batch, RhythmDBEntry *entry, const char *dest, guint64 dest_size, const char *mediatype, GError *error, RBImportDialog *dialog) { rhythmdb_entry_delete (dialog->priv->db, entry); rhythmdb_commit (dialog->priv->db); }
static void impl_delete_selected (RBSource *asource) { RBMissingFilesSource *source = RB_MISSING_FILES_SOURCE (asource); GList *sel, *tem; sel = rb_entry_view_get_selected_entries (source->priv->view); for (tem = sel; tem != NULL; tem = tem->next) { rhythmdb_entry_delete (source->priv->db, tem->data); rhythmdb_commit (source->priv->db); } g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL); g_list_free (sel); }
static void impl_delete (RBSource *asource) { RBImportErrorsSource *source = RB_IMPORT_ERRORS_SOURCE (asource); GList *sel, *tem; sel = rb_entry_view_get_selected_entries (source->priv->view); for (tem = sel; tem != NULL; tem = tem->next) { rhythmdb_entry_delete (source->priv->db, tem->data); rhythmdb_commit (source->priv->db); } g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL); g_list_free (sel); }
static void impl_delete (RBSource *source) { RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); GList *sel; GList *tem; RBEntryView *tracks; RhythmDB *db; int ret; db = get_db_for_source (RB_MTP_SOURCE (source)); tracks = rb_source_get_entry_view (source); sel = rb_entry_view_get_selected_entries (tracks); for (tem = sel; tem != NULL; tem = tem->next) { LIBMTP_track_t *track; RhythmDBEntry *entry; const char *uri; const char *album_name; entry = (RhythmDBEntry *)tem->data; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); track = g_hash_table_lookup (priv->entry_map, entry); if (track == NULL) { rb_debug ("Couldn't find track on mtp-device! (%s)", uri); continue; } ret = LIBMTP_Delete_Object (priv->device, track->item_id); if (ret != 0) { rb_debug ("Delete track %d failed", track->item_id); report_libmtp_errors (priv->device, TRUE); continue; } album_name = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM); if (strcmp (album_name, _("Unknown")) != 0) { remove_track_from_album (RB_MTP_SOURCE (source), album_name, track); } g_hash_table_remove (priv->entry_map, entry); rhythmdb_entry_delete (db, entry); } rhythmdb_commit (db); g_list_free (sel); g_list_free (tem); }
static void update_tracks (RBAudioCdSource *source, RhythmDBPropType property, GValue *value) { RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source); RhythmDB *db; GList *i; db = get_db_for_source (source); for (i = priv->tracks; i != NULL; i = i->next) { rhythmdb_entry_set (db, i->data, property, value); } rhythmdb_commit (db); g_object_unref (db); }
static void impl_delete (RBSource *asource) { RBIRadioSource *source = RB_IRADIO_SOURCE (asource); GList *sel; GList *l; sel = rb_entry_view_get_selected_entries (source->priv->stations); for (l = sel; l != NULL; l = g_list_next (l)) { rhythmdb_entry_delete (source->priv->db, l->data); rhythmdb_commit (source->priv->db); } g_list_foreach (sel, (GFunc)rhythmdb_entry_unref, NULL); g_list_free (sel); }
void rb_podcast_add_dialog_reset (RBPodcastAddDialog *dialog, const char *text, gboolean load) { dialog->priv->reset_count++; remove_all_feeds (dialog); rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH); rhythmdb_commit (dialog->priv->db); rb_search_entry_set_text (dialog->priv->search_entry, text); if (load) { search_cb (dialog->priv->search_entry, text, dialog); } else { rb_search_entry_grab_focus (dialog->priv->search_entry); } }
static void missing_plugins_retry_cb (gpointer instance, gboolean installed, RhythmDBImportJob *job) { GSList *retry = NULL; GSList *i; g_mutex_lock (&job->priv->lock); g_assert (job->priv->retried == FALSE); if (installed == FALSE) { rb_debug ("plugin installation was not successful; job complete"); g_signal_emit (job, signals[COMPLETE], 0, job->priv->total); } else { job->priv->retried = TRUE; /* reset the job state to just show the retry information */ job->priv->total = g_slist_length (job->priv->retry_entries); rb_debug ("plugin installation was successful, retrying %d entries", job->priv->total); job->priv->imported = 0; /* remove the import error entries and build the list of URIs to retry */ for (i = job->priv->retry_entries; i != NULL; i = i->next) { RhythmDBEntry *entry = (RhythmDBEntry *)i->data; char *uri; uri = rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_LOCATION); rhythmdb_entry_delete (job->priv->db, entry); g_hash_table_insert (job->priv->outstanding, g_strdup (uri), GINT_TO_POINTER (1)); retry = g_slist_prepend (retry, uri); } rhythmdb_commit (job->priv->db); retry = g_slist_reverse (retry); } g_mutex_unlock (&job->priv->lock); for (i = retry; i != NULL; i = i->next) { char *uri = (char *)i->data; rhythmdb_add_uri_with_types (job->priv->db, uri, job->priv->entry_type, job->priv->ignore_type, job->priv->error_type); } rb_slist_deep_free (retry); }
static void delete_entries (RBAndroidSource *source, GList *entries) { RBAndroidSourcePrivate *priv = GET_PRIVATE (source); GList *tem; for (tem = entries; tem != NULL; tem = tem->next) { RhythmDBEntry *entry; const char *uri; GFile *file; GFile *dir; entry = tem->data; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); file = g_file_new_for_uri (uri); g_file_delete (file, NULL, NULL); /* now walk up the directory structure and delete empty dirs * until we reach the root or one of the device's audio folders. */ dir = g_file_get_parent (file); while (can_delete_directory (source, dir)) { GFile *parent; if (g_file_delete (dir, NULL, NULL) == FALSE) { break; } parent = g_file_get_parent (dir); if (parent == NULL) { break; } g_object_unref (dir); dir = parent; } g_object_unref (dir); g_object_unref (file); rhythmdb_entry_delete (priv->db, entry); } rhythmdb_commit (priv->db); }
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 search_cb (RBSearchEntry *entry, const char *text, RBPodcastAddDialog *dialog) { GList *searches; GList *s; int i; /* remove previous feeds */ remove_all_feeds (dialog); rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH); rhythmdb_commit (dialog->priv->db); gtk_widget_hide (dialog->priv->info_bar); if (text == NULL || text[0] == '\0') { return; } /* if the entered text looks like a feed URL, parse it directly */ for (i = 0; i < G_N_ELEMENTS (podcast_uri_prefixes); i++) { if (g_str_has_prefix (text, podcast_uri_prefixes[i])) { parse_in_thread (dialog, text, FALSE, TRUE); return; } } /* not really sure about this one */ if (g_path_is_absolute (text)) { parse_in_thread (dialog, text, FALSE, TRUE); return; } /* otherwise, try podcast searches */ dialog->priv->search_successful = FALSE; searches = rb_podcast_manager_get_searches (dialog->priv->podcast_mgr); for (s = searches; s != NULL; s = s->next) { RBPodcastSearch *search = s->data; g_signal_connect_object (search, "result", G_CALLBACK (podcast_search_result_cb), dialog, 0); g_signal_connect_object (search, "finished", G_CALLBACK (podcast_search_finished_cb), dialog, 0); rb_podcast_search_start (search, text, PODCAST_SEARCH_LIMIT); dialog->priv->running_searches++; } }
static void impl_delete_thyself (RBDisplayPage *page) { RhythmDB *db; RBShell *shell; RhythmDBEntryType *entry_type; g_object_get (page, "shell", &shell, NULL); g_object_get (shell, "db", &db, NULL); g_object_unref (shell); g_object_get (page, "entry-type", &entry_type, NULL); rb_debug ("deleting all entries of type '%s'", rhythmdb_entry_type_get_name (entry_type)); rhythmdb_entry_delete_by_type (db, entry_type); g_object_unref (entry_type); rhythmdb_commit (db); g_object_unref (db); }
static void rb_mtp_source_dispose (GObject *object) { RBMtpSource *source = RB_MTP_SOURCE (object); RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); RhythmDBEntryType *entry_type; RhythmDB *db; if (priv->device_thread != NULL) { g_object_unref (priv->device_thread); priv->device_thread = NULL; } #if defined(HAVE_GUDEV) if (priv->remount_volume != NULL) { rb_debug ("remounting gvfs volume for mtp device"); /* the callback will unref remount_volume */ g_volume_mount (priv->remount_volume, G_MOUNT_MOUNT_NONE, NULL, NULL, remount_done_cb, NULL); priv->remount_volume = NULL; } #endif if (priv->art_store != NULL) { g_object_unref (priv->art_store); priv->art_store = NULL; } db = get_db_for_source (source); g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL); rhythmdb_entry_delete_by_type (db, entry_type); g_object_unref (entry_type); rhythmdb_commit (db); g_object_unref (db); G_OBJECT_CLASS (rb_mtp_source_parent_class)->dispose (object); }
static void impl_delete_thyself (RBSource *source) { RhythmDB *db; RhythmDBEntryType entry_type; rb_debug ("audio cd ejected"); /* cancel the loading of metadata */ rb_audiocd_load_metadata_cancel (RB_AUDIOCD_SOURCE (source)); db = get_db_for_source (RB_AUDIOCD_SOURCE (source)); g_object_get (source, "entry-type", &entry_type, NULL); rhythmdb_entry_delete_by_type (db, entry_type); g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type); rhythmdb_commit (db); g_object_unref (db); }
static void subscribe_selected_feed (RBPodcastAddDialog *dialog) { RBPodcastChannel *channel; g_assert (dialog->priv->have_selection); rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH); rhythmdb_commit (dialog->priv->db); /* subscribe selected feed */ gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->feed_model), &dialog->priv->selected_feed, FEED_COLUMN_PARSED_FEED, &channel, -1); if (channel->posts != NULL) { rb_podcast_manager_add_parsed_feed (dialog->priv->podcast_mgr, channel); } else { rb_podcast_manager_subscribe_feed (dialog->priv->podcast_mgr, channel->url, TRUE); } }
static void impl_delete_thyself (RBDisplayPage *page) { RBGriloSource *source = RB_GRILO_SOURCE (page); RhythmDBEntryType *entry_type; if (source->priv->browse_op != 0) { grl_operation_cancel (source->priv->browse_op); source->priv->browse_op = 0; } if (source->priv->media_browse_op != 0) { grl_operation_cancel (source->priv->media_browse_op); source->priv->media_browse_op = 0; } g_object_get (source, "entry-type", &entry_type, NULL); rhythmdb_entry_delete_by_type (source->priv->db, entry_type); g_object_unref (entry_type); rhythmdb_commit (source->priv->db); }
static void start_scanning (RBImportDialog *dialog) { RBTaskList *tasklist; rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->entry_type); rhythmdb_entry_delete_by_type (dialog->priv->db, dialog->priv->ignore_type); rhythmdb_commit (dialog->priv->db); rb_debug ("starting %s", dialog->priv->current_uri); dialog->priv->import_job = rhythmdb_import_job_new (dialog->priv->db, dialog->priv->entry_type, dialog->priv->ignore_type, dialog->priv->ignore_type); g_object_set (dialog->priv->import_job, "task-label", _("Importing tracks"), NULL); g_signal_connect (dialog->priv->import_job, "complete", G_CALLBACK (import_complete_cb), dialog); rhythmdb_import_job_add_uri (dialog->priv->import_job, dialog->priv->current_uri); rhythmdb_import_job_start (dialog->priv->import_job); g_object_get (dialog->priv->shell, "task-list", &tasklist, NULL); rb_task_list_add_task (tasklist, RB_TASK_PROGRESS (dialog->priv->import_job)); g_object_unref (tasklist); }
static void add_posts_for_feed (RBPodcastAddDialog *dialog, RBPodcastChannel *channel) { GList *l; for (l = channel->posts; l != NULL; l = l->next) { RBPodcastItem *item = (RBPodcastItem *) l->data; rb_podcast_manager_add_post (dialog->priv->db, TRUE, channel->title ? channel->title : channel->url, item->title, channel->url, (item->author ? item->author : channel->author), item->url, item->description, (item->pub_date > 0 ? item->pub_date : channel->pub_date), item->duration, item->filesize); } rhythmdb_commit (dialog->priv->db); }
static void missing_plugins_retry_cb (gpointer instance, gboolean installed, RhythmDBImportJob *job) { GSList *i; g_mutex_lock (&job->priv->lock); g_assert (job->priv->retried == FALSE); if (installed == FALSE) { rb_debug ("plugin installation was not successful; job complete"); job->priv->complete = TRUE; g_signal_emit (job, signals[COMPLETE], 0, job->priv->total); g_object_notify (G_OBJECT (job), "task-outcome"); } else { job->priv->retried = TRUE; /* reset the job state to just show the retry information */ job->priv->total = g_slist_length (job->priv->retry_entries); rb_debug ("plugin installation was successful, retrying %d entries", job->priv->total); job->priv->processed = 0; /* remove the import error entries and build the list of URIs to retry */ for (i = job->priv->retry_entries; i != NULL; i = i->next) { RhythmDBEntry *entry = (RhythmDBEntry *)i->data; char *uri; uri = rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_LOCATION); rhythmdb_entry_delete (job->priv->db, entry); g_queue_push_tail (job->priv->outstanding, g_strdup (uri)); } rhythmdb_commit (job->priv->db); } maybe_start_more (job); g_mutex_unlock (&job->priv->lock); }
static void rb_mtp_source_dispose (GObject *object) { RBMtpSource *source = RB_MTP_SOURCE (object); RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); RhythmDBEntryType entry_type; RhythmDB *db; db = get_db_for_source (source); g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL); rhythmdb_entry_delete_by_type (db, entry_type); g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type); rhythmdb_commit (db); g_object_unref (db); if (priv->load_songs_idle_id != 0) { g_source_remove (priv->load_songs_idle_id); priv->load_songs_idle_id = 0; } G_OBJECT_CLASS (rb_mtp_source_parent_class)->dispose (object); }