static void request_cover_art (MxFrame *frame, RhythmDBEntry *entry) { RBExtDBKey *key; RBExtDB *art_store; art_store = rb_ext_db_new ("album-art"); key = rhythmdb_entry_create_ext_db_key (entry, RHYTHMDB_PROP_ALBUM); rb_ext_db_request (art_store, key, (RBExtDBRequestCallback) art_cb, g_object_ref (frame), g_object_unref); rb_ext_db_key_free (key); g_object_unref (art_store); }
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 void update_current_playing_data (RBNotificationPlugin *plugin, RhythmDBEntry *entry) { GValue *value; const char *stream_title = NULL; char *artist = NULL; char *album = NULL; char *title = NULL; GString *secondary; RBExtDBKey *key; const char *artist_template = NULL; const char *album_template = NULL; g_free (plugin->current_title); g_free (plugin->current_album_and_artist); plugin->current_title = NULL; plugin->current_album_and_artist = NULL; if (entry == NULL) { plugin->current_title = g_strdup (_("Not Playing")); plugin->current_album_and_artist = g_strdup (""); g_free (plugin->notify_art_path); plugin->notify_art_path = NULL; return; } secondary = g_string_sized_new (100); if (plugin->notify_art_key == NULL || (rhythmdb_entry_matches_ext_db_key (plugin->db, entry, plugin->notify_art_key) == FALSE)) { if (plugin->notify_art_key) rb_ext_db_key_free (plugin->notify_art_key); plugin->notify_art_key = NULL; g_free (plugin->notify_art_path); plugin->notify_art_path = NULL; /* request album art */ key = rhythmdb_entry_create_ext_db_key (entry, RHYTHMDB_PROP_ALBUM); rb_ext_db_request (plugin->art_store, key, (RBExtDBRequestCallback) art_cb, g_object_ref (plugin), g_object_unref); rb_ext_db_key_free (key); } /* get artist, preferring streaming song details */ value = rhythmdb_entry_request_extra_metadata (plugin->db, entry, RHYTHMDB_PROP_STREAM_SONG_ARTIST); if (value != NULL) { artist = markup_escape (g_value_get_string (value)); g_value_unset (value); g_free (value); } else { artist = markup_escape (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST)); } /* get album, preferring streaming song details */ value = rhythmdb_entry_request_extra_metadata (plugin->db, entry, RHYTHMDB_PROP_STREAM_SONG_ALBUM); if (value != NULL) { album = markup_escape (g_value_get_string (value)); g_value_unset (value); g_free (value); } else { album = markup_escape (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM)); } get_artist_album_templates (artist, album, &artist_template, &album_template); if (artist != NULL && artist[0] != '\0') { g_string_append_printf (secondary, artist_template, artist); } g_free (artist); if (album != NULL && album[0] != '\0') { if (secondary->len != 0) g_string_append_c (secondary, ' '); g_string_append_printf (secondary, album_template, album); } g_free (album); /* get title and possibly stream name. * if we have a streaming song title, the entry's title * property is the stream name. */ value = rhythmdb_entry_request_extra_metadata (plugin->db, entry, RHYTHMDB_PROP_STREAM_SONG_TITLE); if (value != NULL) { title = g_value_dup_string (value); g_value_unset (value); g_free (value); stream_title = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE); } else { title = g_strdup (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE)); } if (stream_title != NULL && stream_title[0] != '\0') { char *escaped; escaped = markup_escape (stream_title); if (secondary->len == 0) g_string_append (secondary, escaped); else g_string_append_printf (secondary, " (%s)", escaped); g_free (escaped); } if (title == NULL) { /* Translators: unknown track title */ title = g_strdup (_("Unknown")); } plugin->current_title = title; plugin->current_album_and_artist = g_string_free (secondary, FALSE); }