static gboolean impl_track_added (RBTransferTarget *target, RhythmDBEntry *entry, const char *dest, guint64 filesize, const char *media_type) { LIBMTP_track_t *track = NULL; RBMtpSourcePrivate *priv = MTP_SOURCE_GET_PRIVATE (target); RhythmDB *db; 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); if (strcmp (track->album, _("Unknown")) != 0) { rb_mtp_thread_add_to_album (priv->device_thread, track, track->album); if (priv->album_art_supported) { RBExtDBKey *key; /* need to do this in an idle handler? */ key = rb_ext_db_key_create_lookup ("album", track->album); rb_ext_db_key_add_field (key, "artist", track->artist); rb_ext_db_request (priv->art_store, key, (RBExtDBRequestCallback) art_request_cb, g_object_ref (target), (GDestroyNotify) g_object_unref); rb_ext_db_key_free (key); } } db = get_db_for_source (RB_MTP_SOURCE (target)); add_mtp_track_to_db (RB_MTP_SOURCE (target), db, track); g_object_unref (db); queue_free_space_update (RB_MTP_SOURCE (target)); return FALSE; }
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; }