From c6ada16b996189b1f80265bbfd001fcce14ce7de Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Mon, 9 Jun 2008 19:53:36 +0000 Subject: * src/db-artwork-parser.c: remove duplicated artwork/photo support testing functions * src/db-artwork-parser.h: ditto * src/itdb_itunesdb.c: s/ipod_supports_XXX/itdb_device_supports_XXX * src/itdb_photoalbum.c: ditto * src/itdb.h: use a const Itdb_Device argument for itdb_device_supports_*, add ITDB_IPOD_GENERATION_IPHONE_1 to Itdb_IpodGeneration, get rid of ITDB_IPOD_GENERATION_FIFTH and ITDB_IPOD_GENERATION_SIXTH * src/itdb_device.c: split functions to get artwork format from the ipod in 2 separate functions: instead of itdb_device_get_artwork_formats we now have itdb_device_get_photo_formats and itdb_device_get_cover_art_formats * src/itdb_device.h: * src/db-image-parser.c: use the separate get_cover_art_formats/get_photos_formats functions * src/db-artwork-writer.c: ditto * src/ithumb-writer.c: ditto git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@2009 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- src/db-image-parser.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'src/db-image-parser.c') diff --git a/src/db-image-parser.c b/src/db-image-parser.c index 8128e19..34995dc 100644 --- a/src/db-image-parser.c +++ b/src/db-image-parser.c @@ -35,29 +35,43 @@ #include "db-image-parser.h" #include +static const Itdb_ArtworkFormat * +find_format (GList *formats, gint16 format_id) +{ + GList *it; + + for (it = formats; it != NULL; it = it->next) { + const Itdb_ArtworkFormat *format; + format = (const Itdb_ArtworkFormat *)it->data; + if (format->format_id == format_id) { + return format; + } + } + + return NULL; +} + static const Itdb_ArtworkFormat * image_format_from_id (Itdb_Device *device, gint16 format_id) { - const Itdb_ArtworkFormat *formats; + GList *formats; + const Itdb_ArtworkFormat *format; if (device == NULL) { return NULL; } - formats = itdb_device_get_artwork_formats (device); - - if (formats == NULL) { - return NULL; - } - - while (formats->type != -1) { - if (formats->format_id == format_id) { - return formats; - } - formats++; - } + formats = itdb_device_get_cover_art_formats (device); + format = find_format (formats, format_id); + g_list_free (formats); + if (format != NULL) { + return format; + } - return NULL; + formats = itdb_device_get_photo_formats (device); + format = find_format (formats, format_id); + g_list_free (formats); + return format; } G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item * -- cgit