summaryrefslogtreecommitdiffstats
path: root/src/db-image-parser.c
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2008-05-30 12:00:21 +0000
committerChristophe Fergeau <teuf@gnome.org>2008-05-30 12:00:21 +0000
commit37e1533b203557602942eea32cc9f2397004023c (patch)
tree15322f7006e27473d2c0c69b2d891f26c66cde67 /src/db-image-parser.c
parent747eda0937e4bf51a586183d99a326b75ebf6a78 (diff)
downloadlibgpod-37e1533b203557602942eea32cc9f2397004023c.tar.gz
libgpod-37e1533b203557602942eea32cc9f2397004023c.tar.xz
libgpod-37e1533b203557602942eea32cc9f2397004023c.zip
* src/Makefile.am:
* src/db-artwork-parser.c: * src/db-artwork-writer.c: * src/db-image-parser.c: * src/db-image-parser.h: * src/itdb.h: * src/itdb_artwork.c: * src/itdb_device.h: * src/itdb_photoalbum.c: * src/itdb_track.c: * src/ithumb-writer.c: * tests/test-covers.c: * tests/test-photos.c: rework Itdb_Thumb type. Now it's split into different subtypes depending on what it represents (GdkPixbuf, thumbnail read from the ipod, ...). Itdb_Artwork now contains only a pointer to a single Itdb_Thumb (it used to contain a GList * of Itdb_Thumb) since the only time when the list is useful is for thumbs read from the ipod. Using a list for the other types of thumbnails created some complications when trying to set art on an Itdb_Track that wasn't attached to an Itdb_iTunesDB. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1991 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'src/db-image-parser.c')
-rw-r--r--src/db-image-parser.c72
1 files changed, 21 insertions, 51 deletions
diff --git a/src/db-image-parser.c b/src/db-image-parser.c
index dfc7d5d..8128e19 100644
--- a/src/db-image-parser.c
+++ b/src/db-image-parser.c
@@ -35,66 +35,51 @@
#include "db-image-parser.h"
#include <glib/gi18n-lib.h>
-static int
-image_type_from_format_id (Itdb_Device *device, gint16 format_id)
+static const Itdb_ArtworkFormat *
+image_format_from_id (Itdb_Device *device, gint16 format_id)
{
const Itdb_ArtworkFormat *formats;
if (device == NULL) {
- return -1;
+ return NULL;
}
formats = itdb_device_get_artwork_formats (device);
if (formats == NULL) {
- return -1;
+ return NULL;
}
while (formats->type != -1) {
if (formats->format_id == format_id) {
- return formats->type;
+ return formats;
}
formats++;
}
- return -1;
-}
-
-
-G_GNUC_INTERNAL const Itdb_ArtworkFormat *
-itdb_get_artwork_info_from_type (Itdb_Device *device,
- ItdbThumbType image_type)
-{
- const Itdb_ArtworkFormat *formats;
-
- if (device == NULL) {
- return NULL;
- }
-
- formats = itdb_device_get_artwork_formats (device);
- if (formats == NULL) {
- return NULL;
- }
-
- while ((formats->type != -1) && (formats->type != image_type)) {
- formats++;
- }
-
- if (formats->type == -1) {
- return NULL;
- }
-
- return formats;
+ return NULL;
}
-G_GNUC_INTERNAL Itdb_Thumb *
+G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item *
ipod_image_new_from_mhni (MhniHeader *mhni, Itdb_DB *db)
{
- Itdb_Thumb *img;
+ Itdb_Thumb_Ipod_Item *img;
+ const Itdb_ArtworkFormat *format;
gint16 format_id;
Itdb_Device *device = NULL;
- img = g_new0 (Itdb_Thumb, 1);
+ device = db_get_device (db);
+ g_return_val_if_fail (device, NULL);
+
+ format_id = get_gint32_db (db, mhni->format_id);
+ format = image_format_from_id (device, format_id);
+ if (format == NULL) {
+ g_warning (_("Unexpected image type in mhni: %d, offset: %d\n"),
+ format_id, get_guint32_db (db, mhni->ithmb_offset));
+ return NULL;
+ }
+
+ img = itdb_thumb_new_item_from_ipod (format);
if (img == NULL) {
return NULL;
}
@@ -107,25 +92,10 @@ ipod_image_new_from_mhni (MhniHeader *mhni, Itdb_DB *db)
img->vertical_padding =
get_gint16_db (db, mhni->vertical_padding);
- device = db_get_device (db);
- g_return_val_if_fail (device, NULL);
-
- format_id = get_gint32_db (db, mhni->format_id);
- img->type = image_type_from_format_id (device, format_id);
-
#if DEBUG_ARTWORK
printf ("format_id: %d, of: %6d sz: %6d, x: %3d, y: %3d, xpad: %3d, ypad: %3d\n",
format_id, img->offset, img->size, img->width, img->height, img->horizontal_padding, img->vertical_padding);
#endif
- if (img->type == -1)
- {
- g_warning (_("Unexpected image type in mhni: size: %ux%u (%d), offset: %d\n"),
- img->width, img->height,
- format_id, img->offset);
- g_free (img);
- return NULL;
- }
-
return img;
}