Revision: 2271
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2271&view=rev
Author:   teuf
Date:     2009-03-14 17:59:36 +0000 (Sat, 14 Mar 2009)

Log Message:
-----------
Factorize some code in legacy artwork handling

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/src/itdb_device.c

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2009-03-14 17:57:24 UTC (rev 2270)
+++ libgpod/trunk/ChangeLog     2009-03-14 17:59:36 UTC (rev 2271)
@@ -1,5 +1,10 @@
 2009-03-14  Christophe Fergeau  <[email protected]>
 
+       * src/itdb_device.c: factorize some code in legacy artwork
+       handling
+
+2009-03-14  Christophe Fergeau  <[email protected]>
+
        * src/itdb.h:
        * src/itdb_device.c:
        * src/itdb_sysinfo_extended_parser.c:

Modified: libgpod/trunk/src/itdb_device.c
===================================================================
--- libgpod/trunk/src/itdb_device.c     2009-03-14 17:57:24 UTC (rev 2270)
+++ libgpod/trunk/src/itdb_device.c     2009-03-14 17:59:36 UTC (rev 2271)
@@ -1026,9 +1026,8 @@
 
 
 /* Return supported artwork formats supported by this iPod */
-static const Itdb_ArtworkFormat *
-itdb_device_get_artwork_formats (const Itdb_Device *device, 
-                                 enum ArtworkType type)
+static const ArtworkCapabilities *
+itdb_device_get_artwork_capabilities (const Itdb_Device *device)
 {
     const Itdb_IpodInfo *info;
     const ArtworkCapabilities *caps;
@@ -1045,35 +1044,47 @@
         }
         caps++;
     }
-    switch (type) {
-        case ARTWORK_TYPE_COVER_ART:
-            return caps->cover_art_formats;
-        case ARTWORK_TYPE_PHOTO:
-            return caps->photo_formats;
-        case ARTWORK_TYPE_CHAPTER_IMAGE:
-            return caps->chapter_image_formats;
-    }
 
-    g_return_val_if_reached (NULL);
+    if (caps->generation == ITDB_IPOD_GENERATION_UNKNOWN) {
+       return NULL;
+    }
+ 
+    return caps;
 }
 
 static GList *
-itdb_device_get_photo_formats_fallback (const Itdb_Device *device)
+itdb_device_get_artwork_formats_fallback (const Itdb_Device *device, 
+                                         enum ArtworkType type)
 {
-    const Itdb_ArtworkFormat *formats;
+    const ArtworkCapabilities *caps;
+    const Itdb_ArtworkFormat *formats = NULL;
     const Itdb_ArtworkFormat *it;
-    GList *photo_formats = NULL;
+    GList *artwork_formats = NULL;
 
-    formats = itdb_device_get_artwork_formats (device, ARTWORK_TYPE_PHOTO);
+    caps = itdb_device_get_artwork_capabilities (device);
+    if (caps == NULL) {
+       return NULL;
+    }
+    switch (type) {
+       case ARTWORK_TYPE_COVER_ART:
+           formats = caps->cover_art_formats;
+           break;
+       case ARTWORK_TYPE_PHOTO:
+           formats = caps->photo_formats;
+           break;
+       case ARTWORK_TYPE_CHAPTER_IMAGE:
+           formats = caps->chapter_image_formats;
+           break;
+    }
     if (formats == NULL) {
         return NULL;
     }
 
     for (it = formats; it->format_id != -1; it++) {
-        photo_formats = g_list_prepend (photo_formats, (gpointer)it);
+        artwork_formats = g_list_prepend (artwork_formats, (gpointer)it);
     }
 
-    return photo_formats;
+    return artwork_formats;
 }
 
 GList *itdb_device_get_photo_formats (const Itdb_Device *device)
@@ -1081,38 +1092,21 @@
     g_return_val_if_fail (device != NULL, NULL);
 
     if (device->sysinfo_extended == NULL) {
-        return itdb_device_get_photo_formats_fallback (device);
+        return itdb_device_get_artwork_formats_fallback (device,
+                                                        ARTWORK_TYPE_PHOTO);
     } else {
         return g_list_copy ((GList *)itdb_sysinfo_properties_get_photo_formats 
(device->sysinfo_extended));
     }
     g_return_val_if_reached (NULL);
 }
 
-static GList *
-itdb_device_get_cover_art_formats_fallback (const Itdb_Device *device)
-{
-    const Itdb_ArtworkFormat *formats;
-    const Itdb_ArtworkFormat *it;
-    GList *cover_art_formats = NULL;
-
-    formats = itdb_device_get_artwork_formats (device, ARTWORK_TYPE_COVER_ART);
-    if (formats == NULL) {
-        return NULL;
-    }
-
-    for (it = formats; it->format_id != -1; it++) {
-        cover_art_formats = g_list_prepend (cover_art_formats, (gpointer)it);
-    }
-
-    return cover_art_formats;
-}
-
 GList *itdb_device_get_cover_art_formats (const Itdb_Device *device)
 {
     g_return_val_if_fail (device != NULL, NULL);
 
     if (device->sysinfo_extended == NULL) {
-        return itdb_device_get_cover_art_formats_fallback (device);
+        return itdb_device_get_artwork_formats_fallback (device,
+                                                        
ARTWORK_TYPE_COVER_ART);
     } else {
         return g_list_copy ((GList 
*)itdb_sysinfo_properties_get_cover_art_formats (device->sysinfo_extended));
     }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to