From 842693aa6371b1f41369c35a31da76375dbdf3f7 Mon Sep 17 00:00:00 2001 From: jcsjcs Date: Sun, 11 May 2008 07:17:29 +0000 Subject: * src/itdb_photoalbum.c src/itdb_private.h src/db-artwork-writer.c: renamed itdb_get_free_photo_id() to itdb_get_max_photo_id() and implemented Jacob Hoffman-Andrew's patch about the photo_ids and album_ids being shared. * tests/test-covers.c: print more info (marginally) git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1971 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- ChangeLog | 11 ++++++++++- src/db-artwork-writer.c | 4 ++-- src/itdb_photoalbum.c | 17 ++++++++++++----- src/itdb_private.h | 2 +- tests/test-covers.c | 2 +- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42fb9e2..8653df3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,17 @@ +2008-05-11 Jorg Schuler + + * src/itdb_photoalbum.c + src/itdb_private.h + src/db-artwork-writer.c: renamed itdb_get_free_photo_id() to + itdb_get_max_photo_id() and implemented Jacob Hoffman-Andrew's + patch about the photo_ids and album_ids being shared. + + * tests/test-covers.c: print more info (marginally) + 2008-05-10 Jorg Schuler * tests/test-covers.c: print more status messages. - 2008-05-01 Todd Zullinger * configure.ac: diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c index 21b6a91..50e65b3 100644 --- a/src/db-artwork-writer.c +++ b/src/db-artwork-writer.c @@ -1086,8 +1086,8 @@ ipod_write_photo_db (Itdb_PhotoDB *photodb) g_free (filename); return -1; } - id_max = itdb_get_free_photo_id( photodb ); - bytes_written = write_mhfd (&db, buf, id_max); + id_max = itdb_get_max_photo_id( photodb ); + bytes_written = write_mhfd (&db, buf, id_max+1); /* Refcount of the shared buffer should drop to 0 and this should * sync buffered data to disk diff --git a/src/itdb_photoalbum.c b/src/itdb_photoalbum.c index 994875e..b55c4d0 100644 --- a/src/itdb_photoalbum.c +++ b/src/itdb_photoalbum.c @@ -309,19 +309,26 @@ void itdb_photodb_free (Itdb_PhotoDB *photodb) -G_GNUC_INTERNAL gint itdb_get_free_photo_id ( Itdb_PhotoDB *db ) +G_GNUC_INTERNAL gint itdb_get_max_photo_id ( Itdb_PhotoDB *db ) { - gint photo_id = 0; + gint max_seen_id = 0; GList *it; for (it = db->photos; it != NULL; it = it->next) { Itdb_Artwork *artwork; artwork = (Itdb_Artwork *)it->data; - if( artwork->id > photo_id ) - photo_id = artwork->id; + if( artwork->id > max_seen_id ) + max_seen_id = artwork->id; } - return photo_id + 1; + for (it = db->photoalbums; it != NULL; it = it->next) { + Itdb_PhotoAlbum *album; + album = (Itdb_PhotoAlbum *)it->data; + if ( album->album_id > max_seen_id ) + max_seen_id = album->album_id; + + } + return max_seen_id; } static void itdb_photodb_photoalbum_free (Itdb_PhotoAlbum *album) diff --git a/src/itdb_private.h b/src/itdb_private.h index 7e9e410..2417423 100644 --- a/src/itdb_private.h +++ b/src/itdb_private.h @@ -146,7 +146,7 @@ G_GNUC_INTERNAL void itdb_splr_free (Itdb_SPLRule *splr); G_GNUC_INTERNAL const gchar *itdb_photodb_get_mountpoint (Itdb_PhotoDB *photodb); G_GNUC_INTERNAL gchar *db_get_mountpoint (Itdb_DB *db); G_GNUC_INTERNAL Itdb_Device *db_get_device(Itdb_DB *db); -G_GNUC_INTERNAL gint itdb_get_free_photo_id ( Itdb_PhotoDB *db ); +G_GNUC_INTERNAL gint itdb_get_max_photo_id ( Itdb_PhotoDB *db ); G_GNUC_INTERNAL Itdb_iTunesDB *db_get_itunesdb (Itdb_DB *db); G_GNUC_INTERNAL Itdb_PhotoDB *db_get_photodb (Itdb_DB *db); G_GNUC_INTERNAL gint itdb_thumb_get_byteorder (ItdbThumbFormat format); diff --git a/tests/test-covers.c b/tests/test-covers.c index ef353c1..02c5c78 100644 --- a/tests/test-covers.c +++ b/tests/test-covers.c @@ -80,7 +80,7 @@ save_thumbnails (Itdb_iTunesDB *db) Itdb_Track *song; song = (Itdb_Track *)it->data; - g_print ("Track %d\n", count++); + g_print ("Track %d (%016"G_GINT64_MODIFIER"x)\n", count++, song->dbid); save_song_thumbnails (song); } } -- cgit