static void entry_added_cb (RhythmDB *db, RhythmDBEntry *entry, RhythmDBImportJob *job) { const char *uri; gboolean ours; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); g_mutex_lock (&job->priv->lock); ours = g_hash_table_remove (job->priv->outstanding, uri); if (ours) { const char *details; job->priv->imported++; rb_debug ("got entry %s; %d now imported", uri, job->priv->imported); g_signal_emit (job, signals[ENTRY_ADDED], 0, entry); /* if it's an import error with missing plugins, add it to the retry list */ details = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_COMMENT); if (rhythmdb_entry_get_entry_type (entry) == job->priv->error_type && (details != NULL && details[0] != '\0')) { rb_debug ("entry %s is an import error with missing plugin details: %s", uri, details); job->priv->retry_entries = g_slist_prepend (job->priv->retry_entries, rhythmdb_entry_ref (entry)); } if (job->priv->status_changed_id == 0) { job->priv->status_changed_id = g_idle_add ((GSourceFunc) emit_status_changed, job); } } g_mutex_unlock (&job->priv->lock); }
static void rb_static_playlist_source_add_location_internal (RBStaticPlaylistSource *source, const char *location, gint index) { RhythmDB *db; RhythmDBEntry *entry; RBPlaylistSource *psource = RB_PLAYLIST_SOURCE (source); if (rb_playlist_source_location_in_map (psource, location)) return; db = rb_playlist_source_get_db (psource); entry = rhythmdb_entry_lookup_by_location (db, location); if (entry) { RBStaticPlaylistSourcePrivate *priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source); if (_rb_source_check_entry_type (RB_SOURCE (source), entry)) { rhythmdb_entry_ref (entry); rhythmdb_query_model_add_entry (priv->base_model, entry, index); rhythmdb_entry_unref (entry); } } rb_playlist_source_add_to_map (psource, location); rb_playlist_source_mark_dirty (psource); }
void _rb_media_player_source_add_to_map (GHashTable *map, RhythmDBEntry *entry) { g_hash_table_insert (map, rb_sync_state_make_track_uuid (entry), rhythmdb_entry_ref (entry)); }
static gboolean collect_entries (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GList **list) { RhythmDBEntry *entry; entry = rhythmdb_query_model_iter_to_entry (RHYTHMDB_QUERY_MODEL (model), iter); *list = g_list_prepend (*list, rhythmdb_entry_ref (entry)); return FALSE; }
static void entry_added_cb (RhythmDB *db, RhythmDBEntry *entry, RhythmDBImportJob *job) { const char *uri; GList *link; uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION); g_mutex_lock (&job->priv->lock); link = g_queue_find_custom (job->priv->processing, uri, (GCompareFunc) g_strcmp0); if (link != NULL) { const char *details; RhythmDBEntryType *entry_type; entry_type = rhythmdb_entry_get_entry_type (entry); job->priv->processed++; if (entry_type == job->priv->entry_type) { job->priv->imported++; g_signal_emit (job, signals[ENTRY_ADDED], 0, entry); } rb_debug ("got entry %s; %d imported, %d processed", uri, job->priv->imported, job->priv->processed); /* if it's an import error with missing plugins, add it to the retry list */ details = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_COMMENT); if (entry_type == job->priv->error_type && (details != NULL && details[0] != '\0')) { rb_debug ("entry %s is an import error with missing plugin details: %s", uri, details); job->priv->retry_entries = g_slist_prepend (job->priv->retry_entries, rhythmdb_entry_ref (entry)); } if (job->priv->status_changed_id == 0) { job->priv->status_changed_id = g_idle_add ((GSourceFunc) emit_status_changed, job); } g_queue_delete_link (job->priv->processing, link); maybe_start_more (job); } g_mutex_unlock (&job->priv->lock); }
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); }
static gboolean impl_track_added (RBRemovableMediaSource *source, RhythmDBEntry *entry, const char *dest, guint64 filesize, const char *mimetype) { LIBMTP_track_t *track = NULL; RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (source); RhythmDB *db; RhythmDBEntry *mtp_entry; track = g_hash_table_lookup (priv->track_transfer_map, dest); if (track == NULL) { rb_debug ("track-added called, but can't find a track for dest URI %s", dest); return FALSE; } g_hash_table_remove (priv->track_transfer_map, dest); db = get_db_for_source (RB_MTP_SOURCE (source)); /* entry_map takes ownership of the track here */ mtp_entry = add_mtp_track_to_db (RB_MTP_SOURCE (source), db, track); g_object_unref (db); if (strcmp (track->album, _("Unknown")) != 0) { rb_mtp_thread_add_to_album (priv->device_thread, track, track->album); } if (priv->album_art_supported) { RequestAlbumArtData *artdata; artdata = g_new0 (RequestAlbumArtData, 1); artdata->source = g_object_ref (source); artdata->entry = rhythmdb_entry_ref (mtp_entry); g_idle_add ((GSourceFunc) request_album_art_idle, artdata); } queue_free_space_update (RB_MTP_SOURCE (source)); /* chain up to parent class for sync */ RB_REMOVABLE_MEDIA_SOURCE_CLASS (rb_mtp_source_parent_class)->impl_track_added (source, entry, dest, filesize, mimetype); return FALSE; }
/** * rb_track_transfer_batch_add: * @batch: a #RBTrackTransferBatch * @entry: the source #RhythmDBEntry to transfer * * Adds an entry to be transferred. */ void rb_track_transfer_batch_add (RBTrackTransferBatch *batch, RhythmDBEntry *entry) { batch->priv->entries = g_list_append (batch->priv->entries, rhythmdb_entry_ref (entry)); }