[sound-juicer] mb4: move SjMb4ArtistDetails to generic code



commit 2f57965c48f4bb60a080d0a27af6aa79ebdbd12f
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Sun Jan 8 20:38:11 2012 +0400

    mb4: move SjMb4ArtistDetails to generic code
    
    Artist details will only be set by the musicbrainz4 backend, but
    since it's easy to make it optional, it doesn't hurt to expose it
    to the library users.

 libjuicer/sj-metadata-musicbrainz4.c |   41 +++++-----------------------------
 libjuicer/sj-structures.c            |   15 ++++++++++++
 libjuicer/sj-structures.h            |   16 +++++++++++++
 3 files changed, 37 insertions(+), 35 deletions(-)
---
diff --git a/libjuicer/sj-metadata-musicbrainz4.c b/libjuicer/sj-metadata-musicbrainz4.c
index a610f54..21baa16 100644
--- a/libjuicer/sj-metadata-musicbrainz4.c
+++ b/libjuicer/sj-metadata-musicbrainz4.c
@@ -87,22 +87,6 @@ G_DEFINE_TYPE_WITH_CODE (SjMetadataMusicbrainz4,
 /*
  * Private methods
  */
-
-
-struct _SjMb4ArtistDetails {
-  char *id;
-  char *name;
-  char *sortname;
-  char *disambiguation;
-  char *gender;
-  char *country;
-
-  /* doesn't belong in here, prevent sharing the artist structure between
-   * distinct ReleaseGroups - more convenient for now */
-  char *joinphrase;
-};
-typedef struct _SjMb4ArtistDetails SjMb4ArtistDetails;
-
 struct _SjMb4AlbumDetails {
     AlbumDetails parent;
     GList *artists;
@@ -125,22 +109,9 @@ struct _SjMb4TrackDetails {
 typedef struct _SjMb4TrackDetails SjMb4TrackDetails;
 
 static void
-sj_mb4_artist_details_free (SjMb4ArtistDetails *details)
-{
-  g_free (details->id);
-  g_free (details->name);
-  g_free (details->sortname);
-  g_free (details->disambiguation);
-  g_free (details->gender);
-  g_free (details->country);
-  g_free (details->joinphrase);
-  g_free (details);
-}
-
-static void
 sj_mb4_track_details_free (SjMb4TrackDetails *details)
 {
-  g_list_foreach (details->artists, (GFunc)sj_mb4_artist_details_free, NULL);
+  g_list_foreach (details->artists, (GFunc)artist_details_free, NULL);
   g_list_free (details->artists);
   track_details_free ((TrackDetails *)details);
 }
@@ -148,7 +119,7 @@ sj_mb4_track_details_free (SjMb4TrackDetails *details)
 static void
 sj_mb4_album_details_free (SjMb4AlbumDetails *details)
 {
-  g_list_foreach (details->artists, (GFunc)sj_mb4_artist_details_free, NULL);
+  g_list_foreach (details->artists, (GFunc)artist_details_free, NULL);
   g_list_free (details->artists);
   g_free (details->status);
   g_free (details->quality);
@@ -213,10 +184,10 @@ get_artist_list (Mb4ArtistCredit credit)
   for (i = 0; i < mb4_namecredit_list_size (name_list); i++) {
     Mb4NameCredit name_credit;
     Mb4Artist artist;
-    SjMb4ArtistDetails *details;
+    ArtistDetails *details;
 
     name_credit = mb4_namecredit_list_item (name_list, i);
-    details = g_new0 (SjMb4ArtistDetails, 1);
+    details = g_new0 (ArtistDetails, 1);
     GET (details->joinphrase, mb4_namecredit_get_joinphrase, name_credit);
     artists = g_list_prepend (artists, details);
     artist = mb4_namecredit_get_artist (name_credit);
@@ -247,7 +218,7 @@ get_artist_info (GList *artists, char **name, char **sortname, char **id)
   artist_name = g_string_new (NULL);
   artist_count = 0;
   for (it = artists; it != NULL; it = it->next) {
-    SjMb4ArtistDetails *details = (SjMb4ArtistDetails *)it->data;
+    ArtistDetails *details = (ArtistDetails *)it->data;
     artist_count++;
     g_string_append (artist_name, details->name);
     if (details->joinphrase != NULL)
@@ -261,7 +232,7 @@ get_artist_info (GList *artists, char **name, char **sortname, char **id)
       if (id != NULL)
         *id = NULL;
   } else {
-      SjMb4ArtistDetails *details = (SjMb4ArtistDetails *)artists->data;
+      ArtistDetails *details = (ArtistDetails *)artists->data;
       if (sortname != NULL)
         *sortname = g_strdup (details->sortname);
       if (id != NULL)
diff --git a/libjuicer/sj-structures.c b/libjuicer/sj-structures.c
index 3d23ce6..a638ae3 100644
--- a/libjuicer/sj-structures.c
+++ b/libjuicer/sj-structures.c
@@ -57,3 +57,18 @@ void album_details_free(AlbumDetails *album)
   g_free (album->wikipedia);
   g_free (album);
 }
+
+/*
+ * Free a ArtistDetails*
+ */
+void artist_details_free (ArtistDetails *artist)
+{
+  g_free (artist->id);
+  g_free (artist->name);
+  g_free (artist->sortname);
+  g_free (artist->disambiguation);
+  g_free (artist->gender);
+  g_free (artist->country);
+  g_free (artist->joinphrase);
+  g_free (artist);
+}
diff --git a/libjuicer/sj-structures.h b/libjuicer/sj-structures.h
index 07ccc60..be1d35e 100644
--- a/libjuicer/sj-structures.h
+++ b/libjuicer/sj-structures.h
@@ -29,6 +29,7 @@
 typedef enum _MetadataSource MetadataSource;
 
 typedef struct _AlbumDetails AlbumDetails;
+typedef struct _ArtistDetails ArtistDetails;
 typedef struct _TrackDetails TrackDetails;
 
 enum _MetadataSource {
@@ -68,7 +69,22 @@ struct _AlbumDetails {
   gboolean is_spoken_word;
 };
 
+struct _ArtistDetails {
+  char *id;
+  char *name;
+  char *sortname;
+  char *disambiguation;
+  char *gender;
+  char *country;
+
+  /* doesn't belong in here, prevent sharing the artist structure between
+   * distinct ReleaseGroups - more convenient for now */
+  char *joinphrase;
+};
+
+
 void album_details_free(AlbumDetails *album);
+void artist_details_free(ArtistDetails *artist);
 void track_details_free(TrackDetails *track);
 
 #endif



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