[rhythmbox] daap: Add artist and album sort order codes



commit 23f9b9498ba3dbbb419f90c9eed8e1ec1782229b
Author: Philippe Gauthier <philippe gauthier deuxpi ca>
Date:   Thu May 6 22:37:15 2010 +1000

    daap: Add artist and album sort order codes

 plugins/daap/rb-daap-connection.c |   42 +++++++++++++++------
 plugins/daap/rb-daap-share.c      |   74 ++++++++++++++++++++----------------
 plugins/daap/rb-daap-structure.c  |    4 +-
 plugins/daap/rb-daap-structure.h  |    4 +-
 4 files changed, 77 insertions(+), 47 deletions(-)
---
diff --git a/plugins/daap/rb-daap-connection.c b/plugins/daap/rb-daap-connection.c
index 6cddec4..ac10e0e 100644
--- a/plugins/daap/rb-daap-connection.c
+++ b/plugins/daap/rb-daap-connection.c
@@ -690,13 +690,18 @@ static void
 entry_set_string_prop (RhythmDB        *db,
 		       RhythmDBEntry   *entry,
 		       RhythmDBPropType propid,
-		       const char      *str)
+		       const char      *str,
+		       gboolean         use_default)
 {
 	GValue value = {0,};
 	const gchar *tmp;
 
 	if (str == NULL || *str == '\0' || !g_utf8_validate (str, -1, NULL)) {
-		tmp = _("Unknown");
+		if (use_default) {
+			tmp = _("Unknown");
+		} else {
+			return;
+		}
 	} else {
 		tmp = str;
 	}
@@ -937,6 +942,8 @@ handle_song_listing (RBDAAPConnection *connection,
 		const gchar *format = NULL;
 		const gchar *genre = NULL;
 		const gchar *streamURI = NULL;
+		const gchar *sort_artist = NULL;
+		const gchar *sort_album = NULL;
 		gint length = 0;
 		gint track_number = 0;
 		gint disc_number = 0;
@@ -989,6 +996,12 @@ handle_song_listing (RBDAAPConnection *connection,
 				case RB_DAAP_CC_ASUL:
 					streamURI = g_value_get_string (&(meta_item->content));
 					break;
+				case RB_DAAP_CC_ASSA:
+					sort_artist = g_value_get_string (&(meta_item->content));
+					break;
+				case RB_DAAP_CC_ASSU:
+					sort_album = g_value_get_string (&(meta_item->content));
+					break;
 				default:
 					break;
 			}
@@ -1065,21 +1078,25 @@ handle_song_listing (RBDAAPConnection *connection,
 		g_value_unset (&value);
 
 		/* title */
-		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_TITLE, title);
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_TITLE, title, TRUE);
 
 		/* album */
-		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ALBUM, album);
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ALBUM, album, TRUE);
 
 		/* artist */
-		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ARTIST, artist);
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ARTIST, artist, TRUE);
 
 		/* genre */
-		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_GENRE, genre);
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_GENRE, genre, TRUE);
 
 		/* stream URI property is stored as a mountpoint for get_playback_uri */
-		if (streamURI && *streamURI != '\0') {
-			entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_MOUNTPOINT, streamURI);
-		}
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_MOUNTPOINT, streamURI, FALSE);
+
+		/* artist sort order */
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ARTIST_SORTNAME, sort_artist, FALSE);
+
+		/* album sort order */
+		entry_set_string_prop (priv->db, entry, RHYTHMDB_PROP_ALBUM_SORTNAME, sort_album, FALSE);
 
 		if (i % commit_batch == 0) {
 			connection->priv->progress = ((float)i / (float)returned_count);
@@ -1584,10 +1601,11 @@ rb_daap_connection_do_something (RBDAAPConnection *connection)
 		rb_debug ("Getting DAAP song listing");
 		path = g_strdup_printf ("/databases/%i/items?session-id=%u&revision-number=%i"
 				        "&meta=dmap.itemid,dmap.itemname,daap.songalbum,"
-					"daap.songartist,daap.daap.songgenre,daap.songsize,"
+					"daap.songartist,daap.songgenre,daap.songsize,"
 					"daap.songtime,daap.songtrackcount,daap.songtracknumber,"
-					"daap.songyear,daap.songformat,daap.songgenre,"
-					"daap.songbitrate,daap.songdiscnumber,daap.songdataurl",
+					"daap.songyear,daap.songformat,"
+					"daap.songbitrate,daap.songdiscnumber,daap.songdataurl,"
+					"daap.sortartist,daap.sortalbum",
 					priv->database_id,
 					priv->session_id,
 					priv->revision_number);
diff --git a/plugins/daap/rb-daap-share.c b/plugins/daap/rb-daap-share.c
index 810b0c2..30c8460 100644
--- a/plugins/daap/rb-daap-share.c
+++ b/plugins/daap/rb-daap-share.c
@@ -900,7 +900,9 @@ typedef enum {
 	SONG_TRACK_COUNT,
 	SONG_TRACK_NUMBER,
 	SONG_USER_RATING,
-	SONG_YEAR
+	SONG_YEAR,
+	SONG_SORT_ARTIST,
+	SONG_SORT_ALBUM
 } DAAPMetaData;
 
 struct DAAPMetaDataMap {
@@ -910,39 +912,41 @@ struct DAAPMetaDataMap {
 
 struct DAAPMetaDataMap meta_data_map[] = {
 	{"dmap.itemid",			ITEM_ID},
-    	{"dmap.itemname",		ITEM_NAME},
-    	{"dmap.itemkind",		ITEM_KIND},
-    	{"dmap.persistentid",		PERSISTENT_ID},
+	{"dmap.itemname",		ITEM_NAME},
+	{"dmap.itemkind",		ITEM_KIND},
+	{"dmap.persistentid",		PERSISTENT_ID},
 	{"dmap.containeritemid",	CONTAINER_ITEM_ID},
-    	{"daap.songalbum",		SONG_ALBUM},
-    	{"daap.songartist",		SONG_ARTIST},
-    	{"daap.songbitrate",		SONG_BITRATE},
-    	{"daap.songbeatsperminute",	SONG_BPM},
-    	{"daap.songcomment",		SONG_COMMENT},
-    	{"daap.songcompilation",	SONG_COMPILATION},
-    	{"daap.songcomposer",		SONG_COMPOSER},
-    	{"daap.songdatakind",		SONG_DATA_KIND},
-    	{"daap.songdataurl",		SONG_DATA_URL},
-    	{"daap.songdateadded",		SONG_DATE_ADDED},
-    	{"daap.songdatemodified",	SONG_DATE_MODIFIED},
-    	{"daap.songdescription",	SONG_DESCRIPTION},
-    	{"daap.songdisabled",		SONG_DISABLED},
-    	{"daap.songdisccount",		SONG_DISC_COUNT},
-    	{"daap.songdiscnumber",		SONG_DISC_NUMBER},
-    	{"daap.songeqpreset",		SONG_EQ_PRESET},
-    	{"daap.songformat",		SONG_FORMAT},
-    	{"daap.songgenre",		SONG_GENRE},
-    	{"daap.songgrouping",		SONG_GROUPING},
-    	{"daap.songrelativevolume",	SONG_RELATIVE_VOLUME},
-    	{"daap.songsamplerate",		SONG_SAMPLE_RATE},
-    	{"daap.songsize",		SONG_SIZE},
-    	{"daap.songstarttime",		SONG_START_TIME},
-    	{"daap.songstoptime",		SONG_STOP_TIME},
-   	{"daap.songtime",		SONG_TIME},
-    	{"daap.songtrackcount",		SONG_TRACK_COUNT},
-    	{"daap.songtracknumber",	SONG_TRACK_NUMBER},
-    	{"daap.songuserrating",		SONG_USER_RATING},
-    	{"daap.songyear",		SONG_YEAR}};
+	{"daap.songalbum",		SONG_ALBUM},
+	{"daap.songartist",		SONG_ARTIST},
+	{"daap.songbitrate",		SONG_BITRATE},
+	{"daap.songbeatsperminute",	SONG_BPM},
+	{"daap.songcomment",		SONG_COMMENT},
+	{"daap.songcompilation",	SONG_COMPILATION},
+	{"daap.songcomposer",		SONG_COMPOSER},
+	{"daap.songdatakind",		SONG_DATA_KIND},
+	{"daap.songdataurl",		SONG_DATA_URL},
+	{"daap.songdateadded",		SONG_DATE_ADDED},
+	{"daap.songdatemodified",	SONG_DATE_MODIFIED},
+	{"daap.songdescription",	SONG_DESCRIPTION},
+	{"daap.songdisabled",		SONG_DISABLED},
+	{"daap.songdisccount",		SONG_DISC_COUNT},
+	{"daap.songdiscnumber",		SONG_DISC_NUMBER},
+	{"daap.songeqpreset",		SONG_EQ_PRESET},
+	{"daap.songformat",		SONG_FORMAT},
+	{"daap.songgenre",		SONG_GENRE},
+	{"daap.songgrouping",		SONG_GROUPING},
+	{"daap.songrelativevolume",	SONG_RELATIVE_VOLUME},
+	{"daap.songsamplerate",		SONG_SAMPLE_RATE},
+	{"daap.songsize",		SONG_SIZE},
+	{"daap.songstarttime",		SONG_START_TIME},
+	{"daap.songstoptime",		SONG_STOP_TIME},
+	{"daap.songtime",		SONG_TIME},
+	{"daap.songtrackcount",		SONG_TRACK_COUNT},
+	{"daap.songtracknumber",	SONG_TRACK_NUMBER},
+	{"daap.songuserrating",		SONG_USER_RATING},
+	{"daap.songyear",		SONG_YEAR},
+	{"daap.sortartist",		SONG_SORT_ARTIST},
+	{"daap.sortalbum",		SONG_SORT_ALBUM}};
 
 typedef unsigned long long bitwise;
 
@@ -1059,6 +1063,10 @@ add_entry_to_mlcl (RhythmDBEntry *entry,
 		rb_daap_structure_add (mlit, RB_DAAP_CC_ASUR, 0); /* FIXME */
 	if (client_requested (mb->bits, SONG_YEAR))
 		rb_daap_structure_add (mlit, RB_DAAP_CC_ASYR, (gint32) rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_YEAR));
+	if (client_requested (mb->bits, SONG_SORT_ARTIST))
+		rb_daap_structure_add (mlit, RB_DAAP_CC_ASSA, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME));
+	if (client_requested (mb->bits, SONG_SORT_ALBUM))
+		rb_daap_structure_add (mlit, RB_DAAP_CC_ASSU, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM_SORTNAME));
 
 	return;
 }
diff --git a/plugins/daap/rb-daap-structure.c b/plugins/daap/rb-daap-structure.c
index d3f98db..02dc5cb 100644
--- a/plugins/daap/rb-daap-structure.c
+++ b/plugins/daap/rb-daap-structure.c
@@ -131,7 +131,9 @@ static const RBDAAPContentCodeDefinition cc_defs[] = {
 	{RB_DAAP_CC_MSAS, MAKE_CONTENT_CODE('m','s','a','s'), "daap.authentication.schemes", "msas", RB_DAAP_TYPE_BYTE},
 	{RB_DAAP_CC_AGRP, MAKE_CONTENT_CODE('a','g','r','p'), "daap.songgrouping", "agrp", RB_DAAP_TYPE_STRING},
 	{RB_DAAP_CC_ASCP, MAKE_CONTENT_CODE('a','s','c','p'), "daap.songcomposer", "ascp", RB_DAAP_TYPE_STRING},
-	{RB_DAAP_CC_AESP, MAKE_CONTENT_CODE('a','e','S','P'), "com.apple.itunes.smart-playlist", "aesp", RB_DAAP_TYPE_BYTE}
+	{RB_DAAP_CC_AESP, MAKE_CONTENT_CODE('a','e','S','P'), "com.apple.itunes.smart-playlist", "aesp", RB_DAAP_TYPE_BYTE},
+	{RB_DAAP_CC_ASSA, MAKE_CONTENT_CODE('a','s','s','a'), "daap.sortartist", "assa", RB_DAAP_TYPE_STRING},
+	{RB_DAAP_CC_ASSU, MAKE_CONTENT_CODE('a','s','s','u'), "daap.sortalbum", "assu", RB_DAAP_TYPE_STRING}
 	};
 
 const gchar *
diff --git a/plugins/daap/rb-daap-structure.h b/plugins/daap/rb-daap-structure.h
index 4b9ba39..1d7dfcc 100644
--- a/plugins/daap/rb-daap-structure.h
+++ b/plugins/daap/rb-daap-structure.h
@@ -122,7 +122,9 @@ typedef enum {
 	RB_DAAP_CC_MSAS,
 	RB_DAAP_CC_AGRP,
 	RB_DAAP_CC_ASCP,
-	RB_DAAP_CC_AESP
+	RB_DAAP_CC_AESP,
+	RB_DAAP_CC_ASSA,
+	RB_DAAP_CC_ASSU
 } RBDAAPContentCode;
 
 typedef struct _RBDAAPItem RBDAAPItem;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]