Revision: 2009
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2009&view=rev
Author: teuf
Date: 2008-06-09 12:53:36 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
* 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
Modified Paths:
--------------
libgpod/trunk/ChangeLog
libgpod/trunk/src/db-artwork-parser.c
libgpod/trunk/src/db-artwork-parser.h
libgpod/trunk/src/db-artwork-writer.c
libgpod/trunk/src/db-image-parser.c
libgpod/trunk/src/itdb.h
libgpod/trunk/src/itdb_device.c
libgpod/trunk/src/itdb_device.h
libgpod/trunk/src/itdb_itunesdb.c
libgpod/trunk/src/itdb_photoalbum.c
libgpod/trunk/src/ithumb-writer.c
Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/ChangeLog 2008-06-09 19:53:36 UTC (rev 2009)
@@ -1,5 +1,26 @@
2008-06-09 Christophe Fergeau <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* src/gchecksum.c: fix compilation (it's only compiled on system with
older glib versions)
Modified: libgpod/trunk/src/db-artwork-parser.c
===================================================================
--- libgpod/trunk/src/db-artwork-parser.c 2008-06-09 07:52:22 UTC (rev
2008)
+++ libgpod/trunk/src/db-artwork-parser.c 2008-06-09 19:53:36 UTC (rev
2009)
@@ -672,89 +672,6 @@
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 @@
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;
Modified: libgpod/trunk/src/db-artwork-parser.h
===================================================================
--- libgpod/trunk/src/db-artwork-parser.h 2008-06-09 07:52:22 UTC (rev
2008)
+++ libgpod/trunk/src/db-artwork-parser.h 2008-06-09 19:53:36 UTC (rev
2009)
@@ -37,6 +37,4 @@
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
Modified: libgpod/trunk/src/db-artwork-writer.c
===================================================================
--- libgpod/trunk/src/db-artwork-writer.c 2008-06-09 07:52:22 UTC (rev
2008)
+++ libgpod/trunk/src/db-artwork-writer.c 2008-06-09 19:53:36 UTC (rev
2009)
@@ -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 @@
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 @@
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 @@
* 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;
}
Modified: libgpod/trunk/src/db-image-parser.c
===================================================================
--- libgpod/trunk/src/db-image-parser.c 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/db-image-parser.c 2008-06-09 19:53:36 UTC (rev 2009)
@@ -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);
+ formats = itdb_device_get_cover_art_formats (device);
+ format = find_format (formats, format_id);
+ g_list_free (formats);
+ if (format != NULL) {
+ return format;
+ }
- if (formats == NULL) {
- return NULL;
- }
-
- while (formats->type != -1) {
- if (formats->format_id == format_id) {
- return formats;
- }
- formats++;
- }
-
- 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 *
Modified: libgpod/trunk/src/itdb.h
===================================================================
--- libgpod/trunk/src/itdb.h 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/itdb.h 2008-06-09 19:53:36 UTC (rev 2009)
@@ -97,9 +97,7 @@
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_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);
Modified: libgpod/trunk/src/itdb_device.c
===================================================================
--- libgpod/trunk/src/itdb_device.c 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/itdb_device.c 2008-06-09 19:53:36 UTC (rev 2009)
@@ -195,7 +195,7 @@
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 @@
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 @@
{-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 @@
{-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,26 +341,57 @@
{-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);
/* Reset or create the SysInfo hash table */
@@ -603,7 +651,7 @@
* 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 @@
* 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,64 +730,73 @@
/* 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);
+ 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;
+ }
- 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;
- }
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
itdb_musicdirs_number_by_mountpoint (const gchar *mountpoint)
@@ -974,17 +1031,62 @@
*
* 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) != NULL);
+ 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;
+ }
+
+ 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);
+}
+
+
+/**
* itdb_device_supports_photo:
* @device: an #Itdb_Device
*
@@ -993,26 +1095,20 @@
* 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 @@
*
* 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 @@
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 @@
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;
}
Modified: libgpod/trunk/src/itdb_device.h
===================================================================
--- libgpod/trunk/src/itdb_device.h 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/itdb_device.h 2008-06-09 19:53:36 UTC (rev 2009)
@@ -108,10 +108,11 @@
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
Modified: libgpod/trunk/src/itdb_itunesdb.c
===================================================================
--- libgpod/trunk/src/itdb_itunesdb.c 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/itdb_itunesdb.c 2008-06-09 19:53:36 UTC (rev 2009)
@@ -6881,7 +6881,7 @@
/* 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 @@
}
/* 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);
Modified: libgpod/trunk/src/itdb_photoalbum.c
===================================================================
--- libgpod/trunk/src/itdb_photoalbum.c 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/itdb_photoalbum.c 2008-06-09 19:53:36 UTC (rev 2009)
@@ -368,7 +368,7 @@
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;
Modified: libgpod/trunk/src/ithumb-writer.c
===================================================================
--- libgpod/trunk/src/ithumb-writer.c 2008-06-09 07:52:22 UTC (rev 2008)
+++ libgpod/trunk/src/ithumb-writer.c 2008-06-09 19:53:36 UTC (rev 2009)
@@ -1395,9 +1395,9 @@
{
#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 @@
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;
+ const Itdb_ArtworkFormat *format;
- 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);
- }
+ 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;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2