summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2008-06-09 19:53:36 +0000
committerteuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2008-06-09 19:53:36 +0000
commit1d8f0569e5d779a14a590d33cc4aa45db5d8049b (patch)
tree1261fe601c0fdc543ca024404b6107245d3d4ead
parent55a3a23ffca6d6228e83ad69cbfbfca765023c41 (diff)
downloadlibgpod-1d8f0569e5d779a14a590d33cc4aa45db5d8049b.tar.gz
libgpod-1d8f0569e5d779a14a590d33cc4aa45db5d8049b.tar.xz
libgpod-1d8f0569e5d779a14a590d33cc4aa45db5d8049b.zip
* 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
-rw-r--r--ChangeLog21
-rw-r--r--src/db-artwork-parser.c85
-rw-r--r--src/db-artwork-parser.h2
-rw-r--r--src/db-artwork-writer.c28
-rw-r--r--src/db-image-parser.c42
-rw-r--r--src/itdb.h13
-rw-r--r--src/itdb_device.c241
-rw-r--r--src/itdb_device.h5
-rw-r--r--src/itdb_itunesdb.c4
-rw-r--r--src/itdb_photoalbum.c2
-rw-r--r--src/ithumb-writer.c39
11 files changed, 269 insertions, 213 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a87adc..7a8b3b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2008-06-09 Christophe Fergeau <christophe@anevia.com>
+ * 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
+
+2008-06-09 Christophe Fergeau <christophe@anevia.com>
+
* src/gchecksum.c: fix compilation (it's only compiled on system with
older glib versions)
diff --git a/src/db-artwork-parser.c b/src/db-artwork-parser.c
index 938dbef..1f4f84b 100644
--- a/src/db-artwork-parser.c
+++ b/src/db-artwork-parser.c
@@ -672,89 +672,6 @@ ipod_db_get_artwork_db_path (const char *mount_point)
return filename;
}
-G_GNUC_INTERNAL gboolean
-ipod_supports_cover_art (Itdb_Device *device)
-{
- const Itdb_ArtworkFormat *formats;
-
- if (device == NULL) {
- return FALSE;
- }
-
- formats = itdb_device_get_artwork_formats (device);
- if (formats == NULL) {
- return FALSE;
- }
-
- while (formats->type != -1)
- {
- switch (formats->type)
- {
- case ITDB_THUMB_COVER_SMALL:
- case ITDB_THUMB_COVER_LARGE:
- return TRUE;
- case ITDB_THUMB_PHOTO_SMALL:
- case ITDB_THUMB_PHOTO_LARGE:
- case ITDB_THUMB_PHOTO_FULL_SCREEN:
- case ITDB_THUMB_PHOTO_TV_SCREEN:
- break;
- case ITDB_THUMB_COVER_XLARGE:
- case ITDB_THUMB_COVER_MEDIUM:
- case ITDB_THUMB_COVER_SMEDIUM:
- case ITDB_THUMB_COVER_XSMALL:
- break;
- case ITDB_THUMB_CHAPTER_SMALL:
- case ITDB_THUMB_CHAPTER_LARGE:
- break;
- }
- formats++;
- }
-
- return FALSE;
-}
-
-G_GNUC_INTERNAL gboolean
-ipod_supports_photos (Itdb_Device *device)
-{
- const Itdb_ArtworkFormat *formats;
-
- if (device == NULL) {
- return FALSE;
- }
-
- formats = itdb_device_get_artwork_formats (device);
- if (formats == NULL) {
- return FALSE;
- }
-
- while (formats->type != -1)
- {
- switch (formats->type)
- {
- case ITDB_THUMB_COVER_SMALL:
- case ITDB_THUMB_COVER_LARGE:
- break;
- case ITDB_THUMB_PHOTO_SMALL:
- case ITDB_THUMB_PHOTO_LARGE:
- case ITDB_THUMB_PHOTO_FULL_SCREEN:
- case ITDB_THUMB_PHOTO_TV_SCREEN:
- return TRUE;
- case ITDB_THUMB_COVER_XLARGE:
- case ITDB_THUMB_COVER_MEDIUM:
- case ITDB_THUMB_COVER_SMEDIUM:
- case ITDB_THUMB_COVER_XSMALL:
- break;
- case ITDB_THUMB_CHAPTER_SMALL:
- case ITDB_THUMB_CHAPTER_LARGE:
- break;
- }
- formats++;
- }
-
- return FALSE;
-}
-
-
int
ipod_parse_artwork_db (Itdb_iTunesDB *itdb)
{
@@ -767,7 +684,7 @@ ipod_parse_artwork_db (Itdb_iTunesDB *itdb)
g_return_val_if_fail (itdb, -1);
- if (!ipod_supports_cover_art (itdb->device)) {
+ if (!itdb_device_supports_artwork (itdb->device)) {
return -1;
}
ctx = NULL;
diff --git a/src/db-artwork-parser.h b/src/db-artwork-parser.h
index 58c0fb2..dff1bd8 100644
--- a/src/db-artwork-parser.h
+++ b/src/db-artwork-parser.h
@@ -37,6 +37,4 @@ G_GNUC_INTERNAL char *ipod_db_get_artwork_db_path (const char *mount_point);
G_GNUC_INTERNAL char *ipod_db_get_photos_db_path (const char *mount_point);
G_GNUC_INTERNAL int ipod_parse_photo_db (Itdb_PhotoDB *photodb);
G_GNUC_INTERNAL int ipod_write_photo_db (Itdb_PhotoDB *db);
-G_GNUC_INTERNAL gboolean ipod_supports_cover_art (Itdb_Device *device);
-G_GNUC_INTERNAL gboolean ipod_supports_photos (Itdb_Device *device);
#endif
diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c
index 0794c16..24e1bbb 100644
--- a/src/db-artwork-writer.c
+++ b/src/db-artwork-writer.c
@@ -24,6 +24,7 @@
#include <config.h>
#include "itdb.h"
+#include "itdb_device.h"
#include "itdb_private.h"
#include "db-artwork-parser.h"
@@ -779,7 +780,8 @@ write_mhlf (Itdb_DB *db, iPodBuffer *buffer)
MhlfHeader *mhlf;
unsigned int total_bytes;
int bytes_written;
- const Itdb_ArtworkFormat *formats;
+ GList *formats;
+ GList *it;
unsigned int num_children;
mhlf = (MhlfHeader *)init_header (buffer, "mhlf", sizeof (MhlfHeader));
@@ -791,23 +793,31 @@ write_mhlf (Itdb_DB *db, iPodBuffer *buffer)
num_children = 0;
mhlf->num_files = get_gint32 (num_children, buffer->byte_order);
- formats = itdb_device_get_artwork_formats (db_get_device(db));
+ formats = NULL;
+ switch (buffer->db_type) {
+ case DB_TYPE_ITUNES:
+ formats = itdb_device_get_cover_art_formats(db_get_device(db));
+ break;
+ case DB_TYPE_PHOTO:
+ formats = itdb_device_get_photo_formats(db_get_device(db));
+ break;
+ }
if (formats == NULL) {
return total_bytes;
}
- while (formats->type != -1) {
+ for (it = formats; it != NULL; it = it->next) {
+ const Itdb_ArtworkFormat *format;
iPodBuffer *sub_buffer;
- if (!itdb_thumb_type_is_valid_for_db (formats, buffer->db_type)) {
- formats++;
- continue;
- }
+
+ format = (const Itdb_ArtworkFormat *)it->data;
sub_buffer = ipod_buffer_get_sub_buffer (buffer, total_bytes);
if (sub_buffer == NULL) {
+ g_list_free (formats);
return -1;
}
- bytes_written = write_mhif (db, sub_buffer, formats);
+ bytes_written = write_mhif (db, sub_buffer, format);
ipod_buffer_destroy (sub_buffer);
if (bytes_written == -1) {
@@ -821,9 +831,9 @@ write_mhlf (Itdb_DB *db, iPodBuffer *buffer)
* to get something somewhat consistent when there are errors
*/
mhlf->num_files = get_gint32 (num_children, buffer->byte_order);
- formats++;
}
dump_mhl ((MhlHeader *)mhlf, "mhlf");
+ g_list_free (formats);
return total_bytes;
}
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 <glib/gi18n-lib.h>
+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 *
diff --git a/src/itdb.h b/src/itdb.h
index 3ef593d..6ef33b5 100644
--- a/src/itdb.h
+++ b/src/itdb.h
@@ -97,9 +97,7 @@ typedef enum {
ITDB_IPOD_GENERATION_VIDEO_2,
ITDB_IPOD_GENERATION_CLASSIC_1,
ITDB_IPOD_GENERATION_TOUCH_1,
- /* The following 2 are no longer in use and should be removed */
- ITDB_IPOD_GENERATION_FIFTH,
- ITDB_IPOD_GENERATION_SIXTH,
+ ITDB_IPOD_GENERATION_IPHONE_1,
} Itdb_IpodGeneration;
typedef enum {
@@ -1084,13 +1082,14 @@ void itdb_device_free (Itdb_Device *device);
void itdb_device_set_mountpoint (Itdb_Device *device, const gchar *mp);
gboolean itdb_device_read_sysinfo (Itdb_Device *device);
gboolean itdb_device_write_sysinfo (Itdb_Device *device, GError **error);
-gchar *itdb_device_get_sysinfo (Itdb_Device *device, const gchar *field);
+gchar *itdb_device_get_sysinfo (const Itdb_Device *device, const gchar *field);
void itdb_device_set_sysinfo (Itdb_Device *device,
const gchar *field, const gchar *value);
-const Itdb_IpodInfo *itdb_device_get_ipod_info (Itdb_Device *device);
+const Itdb_IpodInfo *itdb_device_get_ipod_info (const Itdb_Device *device);
const Itdb_IpodInfo *itdb_info_get_ipod_info_table (void);
-gboolean itdb_device_supports_artwork (Itdb_Device *device);
-gboolean itdb_device_supports_photo (Itdb_Device *device);
+gboolean itdb_device_supports_artwork (const Itdb_Device *device);
+gboolean itdb_device_supports_video (const Itdb_Device *device);
+gboolean itdb_device_supports_photo (const Itdb_Device *device);
const gchar *itdb_info_get_ipod_model_name_string (Itdb_IpodModel model);
const gchar *itdb_info_get_ipod_generation_string (Itdb_IpodGeneration generation);
diff --git a/src/itdb_device.c b/src/itdb_device.c
index 9efd62f..5b7b2aa 100644
--- a/src/itdb_device.c
+++ b/src/itdb_device.c
@@ -195,7 +195,7 @@ static const Itdb_IpodInfo ipod_info_table [] = {
ModelNumStr: Mmobile1
*/
{"mobile1", -1, ITDB_IPOD_MODEL_MOBILE_1, ITDB_IPOD_GENERATION_MOBILE, 6},
- {"iPhone1", -1, ITDB_IPOD_MODEL_IPHONE_1, ITDB_IPOD_GENERATION_MOBILE, 14},
+ {"iPhone1", -1, ITDB_IPOD_MODEL_IPHONE_1, ITDB_IPOD_GENERATION_IPHONE_1, 14},
{NULL, 0, 0, 0, 0}
};
@@ -260,14 +260,20 @@ static const gchar *ipod_generation_name_table [] = {
N_("Video (2nd Gen.)"),
N_("Classic"),
N_("Touch"),
+ N_("iPhone"),
N_("Unused"),
N_("Unused"),
NULL
};
-static const Itdb_ArtworkFormat ipod_photo_artwork_info[] = {
+
+static const Itdb_ArtworkFormat ipod_photo_cover_art_info[] = {
{ITDB_THUMB_COVER_SMALL, 56, 56, 1017, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_COVER_LARGE, 140, 140, 1016, THUMB_FORMAT_RGB565_LE},
+ {-1, -1, -1, -1, -1}
+};
+
+static const Itdb_ArtworkFormat ipod_photo_photo_info[] = {
{ITDB_THUMB_PHOTO_SMALL, 42, 30, 1009, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_LARGE, 130, 88, 1015, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_FULL_SCREEN,220, 176, 1013, THUMB_FORMAT_RGB565_BE_90},
@@ -275,17 +281,25 @@ static const Itdb_ArtworkFormat ipod_photo_artwork_info[] = {
{-1, -1, -1, -1, -1}
};
-static const Itdb_ArtworkFormat ipod_nano_artwork_info[] = {
+static const Itdb_ArtworkFormat ipod_nano_cover_art_info[] = {
{ITDB_THUMB_COVER_SMALL, 42, 42, 1031, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_COVER_LARGE, 100, 100, 1027, THUMB_FORMAT_RGB565_LE},
+ {-1, -1, -1, -1, -1}
+};
+
+static const Itdb_ArtworkFormat ipod_nano_photo_info[] = {
{ITDB_THUMB_PHOTO_LARGE, 42, 37, 1032, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_FULL_SCREEN,176, 132, 1023, THUMB_FORMAT_RGB565_BE},
{-1, -1, -1, -1, -1}
};
-static const Itdb_ArtworkFormat ipod_video_artwork_info[] = {
+static const Itdb_ArtworkFormat ipod_video_cover_art_info[] = {
{ITDB_THUMB_COVER_SMALL, 100, 100, 1028, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_COVER_LARGE, 200, 200, 1029, THUMB_FORMAT_RGB565_LE},
+ {-1, -1, -1, -1, -1}
+};
+
+static const Itdb_ArtworkFormat ipod_video_photo_info[] = {
{ITDB_THUMB_PHOTO_SMALL, 50, 41, 1036, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_LARGE, 130, 88, 1015, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_FULL_SCREEN,320, 240, 1024, THUMB_FORMAT_RGB565_LE},
@@ -293,20 +307,23 @@ static const Itdb_ArtworkFormat ipod_video_artwork_info[] = {
{-1, -1, -1, -1, -1}
};
-static const Itdb_ArtworkFormat ipod_mobile_1_artwork_info[] = {
+static const Itdb_ArtworkFormat ipod_mobile_1_cover_art_info[] = {
{ITDB_THUMB_COVER_SMALL, 50, 50, 2002, THUMB_FORMAT_RGB565_BE},
{ITDB_THUMB_COVER_LARGE, 150, 150, 2003, THUMB_FORMAT_RGB565_BE},
{-1, -1, -1, -1, -1}
};
-static const Itdb_ArtworkFormat ipod_touch_1_artwork_info[] = {
+static const Itdb_ArtworkFormat ipod_touch_1_cover_art_info[] = {
{ITDB_THUMB_COVER_LARGE, 256, 256, 3001, THUMB_FORMAT_REC_RGB555_LE},
{ITDB_THUMB_COVER_MEDIUM, 128, 128, 3002, THUMB_FORMAT_REC_RGB555_LE},
{ITDB_THUMB_COVER_SMALL, 64, 64, 3003, THUMB_FORMAT_REC_RGB555_LE},
{ITDB_THUMB_COVER_XLARGE, 320, 320, 3005, THUMB_FORMAT_RGB555_LE},
{ITDB_THUMB_COVER_XSMALL, 56, 56, 3006, THUMB_FORMAT_RGB555_LE, 8192}, /*pad data to 8192 bytes */
{ITDB_THUMB_COVER_SMEDIUM, 88, 88, 3007, THUMB_FORMAT_RGB555_LE, 16364}, /*pad data to 16384 bytes */
+ {-1, -1, -1, -1, -1}
+};
+static const Itdb_ArtworkFormat ipod_touch_1_photo_info[] = {
/* In the album list, if a photo is being used to represent a whole album,
PHOTO_SMALL is used. We specify TRUE for the crop option so we fill
the square completely. */
@@ -324,25 +341,56 @@ static const Itdb_ArtworkFormat ipod_touch_1_artwork_info[] = {
{-1, -1, -1, -1, -1}
};
-static const Itdb_ArtworkFormat ipod_classic_1_artwork_info[] = {
+static const Itdb_ArtworkFormat ipod_classic_1_cover_art_info[] = {
/* officially 55x55 -- verify! */
{ITDB_THUMB_COVER_SMALL, 56, 56, 1061, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_COVER_MEDIUM, 128, 128, 1055, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_COVER_LARGE, 320, 320, 1060, THUMB_FORMAT_RGB565_LE},
+ {-1, -1, -1, -1, -1}
+};
+
+static const Itdb_ArtworkFormat ipod_classic_1_photo_info[] = {
{ITDB_THUMB_PHOTO_TV_SCREEN, 720, 480, 1067, THUMB_FORMAT_I420_LE},
{ITDB_THUMB_PHOTO_FULL_SCREEN,320, 240, 1024, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_PHOTO_SMALL, 64, 64, 1066, THUMB_FORMAT_RGB565_LE},
-/* These are the same as for the iPod video... -- labeled by the iPod as
- "chapter images" */
+ {-1, -1, -1, -1, -1}
+};
+
+static const Itdb_ArtworkFormat ipod_classic_1_chapter_image_info[] = {
+ /* These are the same as for the iPod video... -- labeled by the iPod as
+ "chapter images" */
{ITDB_THUMB_CHAPTER_SMALL, 100, 100, 1028, THUMB_FORMAT_RGB565_LE},
{ITDB_THUMB_CHAPTER_LARGE, 200, 200, 1029, THUMB_FORMAT_RGB565_LE},
{-1, -1, -1, -1, -1}
};
-/* these are identical... */
-#define ipod_nano3_artwork_info ipod_classic_1_artwork_info
-/* these might be identical... Please report if not*/
-#define ipod_iphone_1_artwork_info ipod_touch_1_artwork_info
+enum ArtworkType {
+ ARTWORK_TYPE_COVER_ART,
+ ARTWORK_TYPE_PHOTO,
+ ARTWORK_TYPE_CHAPTER_IMAGE
+};
+
+struct _ArtworkCapabilities {
+ Itdb_IpodGeneration generation;
+ const Itdb_ArtworkFormat *cover_art_formats;
+ const Itdb_ArtworkFormat *photo_formats;
+ const Itdb_ArtworkFormat *chapter_image_formats;
+};
+typedef struct _ArtworkCapabilities ArtworkCapabilities;
+
+static const ArtworkCapabilities ipod_artwork_capabilities[] = {
+ { ITDB_IPOD_GENERATION_PHOTO, ipod_photo_cover_art_info, ipod_photo_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_VIDEO_1, ipod_video_cover_art_info, ipod_video_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_VIDEO_2, ipod_video_cover_art_info, ipod_video_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_NANO_1, ipod_nano_cover_art_info, ipod_nano_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_NANO_2, ipod_nano_cover_art_info, ipod_nano_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_NANO_3, ipod_classic_1_cover_art_info, ipod_classic_1_photo_info, ipod_classic_1_chapter_image_info },
+ { ITDB_IPOD_GENERATION_CLASSIC_1, ipod_classic_1_cover_art_info, ipod_classic_1_photo_info, ipod_classic_1_chapter_image_info },
+ { ITDB_IPOD_GENERATION_TOUCH_1, ipod_touch_1_cover_art_info, ipod_touch_1_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_IPHONE_1, ipod_touch_1_cover_art_info, ipod_touch_1_photo_info, NULL },
+ { ITDB_IPOD_GENERATION_MOBILE, ipod_mobile_1_cover_art_info, NULL, NULL },
+ { ITDB_IPOD_GENERATION_UNKNOWN, NULL, NULL, NULL }
+};
static void itdb_device_set_timezone_info (Itdb_Device *device);
@@ -603,7 +651,7 @@ gboolean itdb_device_write_sysinfo (Itdb_Device *device, GError **error)
* Return value: the information associated with @field, or NULL if @field
* couldn't be found. g_free() after use
**/
-gchar *itdb_device_get_sysinfo (Itdb_Device *device, const gchar *field)
+gchar *itdb_device_get_sysinfo (const Itdb_Device *device, const gchar *field)
{
g_return_val_if_fail (device, NULL);
g_return_val_if_fail (device->sysinfo, NULL);
@@ -651,7 +699,7 @@ void itdb_device_set_sysinfo (Itdb_Device *device,
* Return value: the #Itdb_IpodInfo entry for this iPod
**/
const Itdb_IpodInfo *
-itdb_device_get_ipod_info (Itdb_Device *device)
+itdb_device_get_ipod_info (const Itdb_Device *device)
{
gint i;
gchar *model_num, *p;
@@ -682,63 +730,72 @@ itdb_device_get_ipod_info (Itdb_Device *device)
/* Return supported artwork formats supported by this iPod */
-G_GNUC_INTERNAL const Itdb_ArtworkFormat *
-itdb_device_get_artwork_formats (Itdb_Device *device)
+static const Itdb_ArtworkFormat *
+itdb_device_get_artwork_formats (const Itdb_Device *device,
+ enum ArtworkType type)
{
const Itdb_IpodInfo *info;
+ const ArtworkCapabilities *caps;
g_return_val_if_fail (device, NULL);
info = itdb_device_get_ipod_info (device);
g_return_val_if_fail (info, NULL);
-
- switch (info->ipod_generation)
- {
- case ITDB_IPOD_GENERATION_UNKNOWN:
- case ITDB_IPOD_GENERATION_FIRST:
- case ITDB_IPOD_GENERATION_SECOND:
- case ITDB_IPOD_GENERATION_THIRD:
- case ITDB_IPOD_GENERATION_FOURTH:
- return NULL;
- case ITDB_IPOD_GENERATION_PHOTO:
- return ipod_photo_artwork_info;
- case ITDB_IPOD_GENERATION_MOBILE:
- switch (info->ipod_model)
- {
- case ITDB_IPOD_MODEL_MOBILE_1:
- return ipod_mobile_1_artwork_info;
- case ITDB_IPOD_MODEL_IPHONE_1:
- return ipod_iphone_1_artwork_info;
- default:
- g_return_val_if_reached (NULL);
- }
- case ITDB_IPOD_GENERATION_MINI_1:
- case ITDB_IPOD_GENERATION_MINI_2:
- case ITDB_IPOD_GENERATION_SHUFFLE_1:
- case ITDB_IPOD_GENERATION_SHUFFLE_2:
- case ITDB_IPOD_GENERATION_SHUFFLE_3:
- return NULL;
- case ITDB_IPOD_GENERATION_NANO_1:
- case ITDB_IPOD_GENERATION_NANO_2:
- return ipod_nano_artwork_info;
- case ITDB_IPOD_GENERATION_NANO_3:
- return ipod_nano3_artwork_info;
- case ITDB_IPOD_GENERATION_VIDEO_1:
- case ITDB_IPOD_GENERATION_VIDEO_2:
- return ipod_video_artwork_info;
- case ITDB_IPOD_GENERATION_CLASSIC_1:
- return ipod_classic_1_artwork_info;
- case ITDB_IPOD_GENERATION_TOUCH_1:
- return ipod_touch_1_artwork_info;
- case ITDB_IPOD_GENERATION_FIFTH:
- case ITDB_IPOD_GENERATION_SIXTH:
- return NULL;
+ caps = ipod_artwork_capabilities;
+ while (caps->generation != ITDB_IPOD_GENERATION_UNKNOWN) {
+ if (caps->generation == info->ipod_generation) {
+ break;
+ }
+ 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);
}
+GList *itdb_device_get_photo_formats (const Itdb_Device *device)
+{
+ const Itdb_ArtworkFormat *formats;
+ const Itdb_ArtworkFormat *it;
+ GList *photo_formats = NULL;
+
+ formats = itdb_device_get_artwork_formats (device, ARTWORK_TYPE_PHOTO);
+ if (formats == NULL) {
+ return NULL;
+ }
+
+ for (it = formats; it->type != -1; it++) {
+ photo_formats = g_list_prepend (photo_formats, (gpointer)it);
+ }
+
+ return photo_formats;
+}
+
+GList *itdb_device_get_cover_art_formats (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->type != -1; it++) {
+ cover_art_formats = g_list_prepend (cover_art_formats, (gpointer)it);
+ }
+ return cover_art_formats;
+}
/* Determine the number of F.. directories in iPod_Control/Music.*/
G_GNUC_INTERNAL gint
@@ -974,13 +1031,58 @@ const gchar *itdb_info_get_ipod_generation_string (Itdb_IpodGeneration generatio
*
* Return value: true if @device can display artwork.
*/
-gboolean itdb_device_supports_artwork (Itdb_Device *device)
+gboolean itdb_device_supports_artwork (const Itdb_Device *device)
+{
+ if (device == NULL) {
+ return FALSE;
+ }
+
+ return (itdb_device_get_artwork_formats (device, ARTWORK_TYPE_COVER_ART) != NULL);
+}
+
+
+/**
+ * itdb_device_supports_video:
+ * @device: an #Itdb_Device
+ *
+ * Indicates whether @device can play videos or not.
+ *
+ * Return value: true if @device can play videos.
+ */
+
+gboolean itdb_device_supports_video (const Itdb_Device *device)
{
+ const Itdb_IpodInfo *info;
if (device == NULL) {
return FALSE;
}
- return (itdb_device_get_artwork_formats (device) != NULL);
+ info = itdb_device_get_ipod_info (device);
+ switch (info->ipod_generation) {
+ case ITDB_IPOD_GENERATION_UNKNOWN:
+ case ITDB_IPOD_GENERATION_FIRST:
+ case ITDB_IPOD_GENERATION_SECOND:
+ case ITDB_IPOD_GENERATION_THIRD:
+ case ITDB_IPOD_GENERATION_FOURTH:
+ case ITDB_IPOD_GENERATION_PHOTO:
+ case ITDB_IPOD_GENERATION_MOBILE:
+ case ITDB_IPOD_GENERATION_MINI_1:
+ case ITDB_IPOD_GENERATION_MINI_2:
+ case ITDB_IPOD_GENERATION_SHUFFLE_1:
+ case ITDB_IPOD_GENERATION_SHUFFLE_2:
+ case ITDB_IPOD_GENERATION_SHUFFLE_3:
+ case ITDB_IPOD_GENERATION_NANO_1:
+ case ITDB_IPOD_GENERATION_NANO_2:
+ return FALSE;
+ case ITDB_IPOD_GENERATION_NANO_3:
+ case ITDB_IPOD_GENERATION_VIDEO_1:
+ case ITDB_IPOD_GENERATION_VIDEO_2:
+ case ITDB_IPOD_GENERATION_CLASSIC_1:
+ case ITDB_IPOD_GENERATION_TOUCH_1:
+ case ITDB_IPOD_GENERATION_IPHONE_1:
+ return TRUE;
+ }
+ g_return_val_if_reached (FALSE);
}
@@ -993,26 +1095,20 @@ gboolean itdb_device_supports_artwork (Itdb_Device *device)
* Return value: true if @device can display photos.
*/
-gboolean itdb_device_supports_photo (Itdb_Device *device)
+gboolean itdb_device_supports_photo (const Itdb_Device *device)
{
const Itdb_ArtworkFormat *formats;
- const Itdb_ArtworkFormat *it;
if (device == NULL) {
return FALSE;
}
- formats = itdb_device_get_artwork_formats (device);
+ formats = itdb_device_get_artwork_formats (device, ARTWORK_TYPE_PHOTO);
if (formats == NULL) {
return FALSE;
}
- it = formats;
- while ((it->type != -1) && (it->type != ITDB_THUMB_PHOTO_FULL_SCREEN)) {
- it++;
- }
-
- return (it->type != -1);
+ return (formats->type != -1);
}
@@ -1094,7 +1190,7 @@ static void itdb_device_set_timezone_info (Itdb_Device *device)
*
* Return value: the guint64 firewire id, or 0 if we don't know it
**/
-guint64 itdb_device_get_firewire_id (Itdb_Device *device)
+guint64 itdb_device_get_firewire_id (const Itdb_Device *device)
{
gchar *fwid;
@@ -1123,6 +1219,7 @@ G_GNUC_INTERNAL gboolean itdb_device_requires_checksum (Itdb_Device *device)
case ITDB_IPOD_GENERATION_CLASSIC_1:
case ITDB_IPOD_GENERATION_NANO_3:
case ITDB_IPOD_GENERATION_TOUCH_1:
+ case ITDB_IPOD_GENERATION_IPHONE_1:
return TRUE;
case ITDB_IPOD_GENERATION_UNKNOWN:
@@ -1141,8 +1238,6 @@ G_GNUC_INTERNAL gboolean itdb_device_requires_checksum (Itdb_Device *device)
case ITDB_IPOD_GENERATION_NANO_2:
case ITDB_IPOD_GENERATION_VIDEO_1:
case ITDB_IPOD_GENERATION_VIDEO_2:
- case ITDB_IPOD_GENERATION_FIFTH:
- case ITDB_IPOD_GENERATION_SIXTH:
return FALSE;
}
diff --git a/src/itdb_device.h b/src/itdb_device.h
index f6aaf14..85956af 100644
--- a/src/itdb_device.h
+++ b/src/itdb_device.h
@@ -108,10 +108,11 @@ struct _Itdb_ArtworkFormat
gboolean crop;
};
-G_GNUC_INTERNAL const Itdb_ArtworkFormat *itdb_device_get_artwork_formats (Itdb_Device *device);
+G_GNUC_INTERNAL GList *itdb_device_get_photo_formats (const Itdb_Device *device);
+G_GNUC_INTERNAL GList *itdb_device_get_cover_art_formats (const Itdb_Device *device);
G_GNUC_INTERNAL gint itdb_device_musicdirs_number (Itdb_Device *device);
G_GNUC_INTERNAL void itdb_device_autodetect_endianess (Itdb_Device *device);
-G_GNUC_INTERNAL guint64 itdb_device_get_firewire_id (Itdb_Device *device);
+G_GNUC_INTERNAL guint64 itdb_device_get_firewire_id (const Itdb_Device *device);
G_END_DECLS
diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c
index 5e0eaca..5832917 100644
--- a/src/itdb_itunesdb.c
+++ b/src/itdb_itunesdb.c
@@ -6881,7 +6881,7 @@ static gboolean itdb_create_directories (Itdb_Device *device, GError **error)
/* Build Artwork directory only for devices requiring artwork
* (assume that 'unknown models' are new and will support
* artwork) */
- if (ipod_supports_cover_art(device) ||
+ if (itdb_device_supports_artwork(device) ||
(info->ipod_model == ITDB_IPOD_MODEL_UNKNOWN))
{
pbuf = g_build_filename (mp, podpath, "Artwork", NULL);
@@ -6895,7 +6895,7 @@ static gboolean itdb_create_directories (Itdb_Device *device, GError **error)
}
/* Build Photo directory only for devices requiring it */
- if (ipod_supports_photos(device) ||
+ if (itdb_device_supports_photo(device) ||
(info->ipod_model == ITDB_IPOD_MODEL_UNKNOWN))
{
pbuf = g_build_filename (mp, "Photos", "Thumbs", NULL);
diff --git a/src/itdb_photoalbum.c b/src/itdb_photoalbum.c
index 86c4917..a6b6d6d 100644
--- a/src/itdb_photoalbum.c
+++ b/src/itdb_photoalbum.c
@@ -368,7 +368,7 @@ static Itdb_Artwork *itdb_photodb_add_photo_internal (Itdb_PhotoDB *db,
g_return_val_if_fail (!(image_data && (image_data_len == 0)), NULL);
g_return_val_if_fail (!(pixbuf && (!GDK_IS_PIXBUF (pixbuf))), NULL);
- if (!ipod_supports_photos (db->device))
+ if (!itdb_device_supports_photo (db->device))
{
const Itdb_IpodInfo *ipodinfo = itdb_device_get_ipod_info (db->device);
const gchar *model, *generation;
diff --git a/src/ithumb-writer.c b/src/ithumb-writer.c
index a5629c3..83c9bff 100644
--- a/src/ithumb-writer.c
+++ b/src/ithumb-writer.c
@@ -1395,9 +1395,9 @@ itdb_write_ithumb_files (Itdb_DB *db)
{
#ifdef HAVE_GDKPIXBUF
GList *writers;
- GList *it;
Itdb_Device *device;
- const Itdb_ArtworkFormat *format;
+ GList *formats;
+ GList *it;
const gchar *mount_point;
g_return_val_if_fail (db, -1);
@@ -1410,26 +1410,27 @@ itdb_write_ithumb_files (Itdb_DB *db)
if (mount_point == NULL)
return -1;
- format = itdb_device_get_artwork_formats (device);
- if (format == NULL) {
- return -1;
- }
+ formats = NULL;
+ switch (db->db_type) {
+ case DB_TYPE_ITUNES:
+ formats = itdb_device_get_cover_art_formats(db_get_device(db));
+ break;
+ case DB_TYPE_PHOTO:
+ formats = itdb_device_get_photo_formats(db_get_device(db));
+ break;
+ }
writers = NULL;
- while (format->type != -1) {
+ for (it = formats; it != NULL; it = it->next) {
iThumbWriter *writer;
-
- if (itdb_thumb_type_is_valid_for_db (format, db->db_type))
- {
- ithmb_rearrange_existing_thumbnails (db, format );
- writer = ithumb_writer_new (mount_point,
- format,
- db->db_type,
- device->byte_order);
- if (writer != NULL) {
- writers = g_list_prepend (writers, writer);
- }
+ const Itdb_ArtworkFormat *format;
+
+ format = (const Itdb_ArtworkFormat *)it->data;
+ ithmb_rearrange_existing_thumbnails (db, format);
+ writer = ithumb_writer_new (mount_point, format,
+ db->db_type, device->byte_order);
+ if (writer != NULL) {
+ writers = g_list_prepend (writers, writer);
}
- format++;
}
if (writers == NULL) {
return -1;