diff options
author | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2006-10-29 10:37:47 +0000 |
---|---|---|
committer | Jorg Schuler <jcsjcs@users.sourceforge.net> | 2006-10-29 10:37:47 +0000 |
commit | 539186ab49e478b784c919761533d6e8b3fce983 (patch) | |
tree | 2ae5e3895a3664053972b55ff71f5fbf06f12a35 | |
parent | cb0393e876d66ae4f16efbd84844246f96f12bd9 (diff) | |
download | libgpod-tmz-539186ab49e478b784c919761533d6e8b3fce983.tar.gz libgpod-tmz-539186ab49e478b784c919761533d6e8b3fce983.tar.xz libgpod-tmz-539186ab49e478b784c919761533d6e8b3fce983.zip |
Added additional functionality for photo albums
* src/db-artwork-parser.c
src/db-artwork-writer.c
src/db-itunes-parser.c:
src/itdb.h: added additional fields to MhbaHeader and
Itdb_PhotoAlbum (playmusic, repeat, random, show_titles,
transition_direction, slide duration, transition_duration,
unk024, unk028, unk044, unk048, song_id. These fields are read
and written from the PhotoDB now. Also corrected error for
"album type" which was read and written as int32 even though it
was a int8. Removed num_images from Itdb_PhotoAlbum -- instead
count images at time of writing.
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1330 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | src/db-artwork-parser.c | 32 | ||||
-rw-r--r-- | src/db-artwork-writer.c | 35 | ||||
-rw-r--r-- | src/db-itunes-parser.h | 21 | ||||
-rw-r--r-- | src/itdb.h | 32 | ||||
-rw-r--r-- | src/itdb_photoalbum.c | 5 | ||||
-rw-r--r-- | tests/test-photos.c | 4 |
7 files changed, 103 insertions, 40 deletions
@@ -61,6 +61,20 @@ * src/db-itunes-parser.h: added comments to _MhbaHeader definition. + Added additional functionality for photo albums + + * src/db-artwork-parser.c + src/db-artwork-writer.c + src/db-itunes-parser.c: + src/itdb.h: added additional fields to MhbaHeader and + Itdb_PhotoAlbum (playmusic, repeat, random, show_titles, + transition_direction, slide duration, transition_duration, + unk024, unk028, unk044, unk048, song_id. These fields are read + and written from the PhotoDB now. Also corrected error for + "album type" which was read and written as int32 even though it + was a int8. Removed num_images from Itdb_PhotoAlbum -- instead + count images at time of writing. + 2006-10-02 Jorg Schuler <jcsjcs at users.sourceforge.net> * tests/Makefile.am diff --git a/src/db-artwork-parser.c b/src/db-artwork-parser.c index 51d81fa..88de265 100644 --- a/src/db-artwork-parser.c +++ b/src/db-artwork-parser.c @@ -386,7 +386,7 @@ parse_mhba (DBParseContext *ctx, GError *error) ArtworkDB_MhodHeader *mhod; DBParseContext *mhod_ctx; DBParseContext *mhia_ctx; - Itdb_PhotoAlbum *photo_album; + Itdb_PhotoAlbum *album; Itdb_PhotoDB *photodb; int num_children; off_t cur_offset; @@ -399,11 +399,25 @@ parse_mhba (DBParseContext *ctx, GError *error) dump_mhba (mhba); - photo_album = g_new0 (Itdb_PhotoAlbum, 1); - photo_album->num_images = get_gint32( mhba->num_mhias, ctx->byte_order); - photo_album->album_id = get_gint32( mhba->playlist_id, ctx->byte_order); - photo_album->album_type = get_gint32( mhba->album_type, ctx->byte_order); - photo_album->prev_album_id = get_gint32( mhba->prev_playlist_id, ctx->byte_order); + album = g_new0 (Itdb_PhotoAlbum, 1); + album->album_id = get_gint32(mhba->album_id, ctx->byte_order); + album->unk024 = get_gint32(mhba->unk024, ctx->byte_order); + album->unk028 = get_gint16(mhba->unk028, ctx->byte_order); + album->album_type = mhba->album_type; + album->playmusic = mhba->playmusic; + album->repeat = mhba->repeat; + album->random = mhba->random; + album->show_titles = mhba->show_titles; + album->transition_direction = mhba->transition_direction; + album->slide_duration = get_gint32(mhba->slide_duration, + ctx->byte_order); + album->transition_duration = get_gint32(mhba->transition_duration, + ctx->byte_order); + album->unk044 = get_gint32(mhba->unk044, ctx->byte_order); + album->unk048 = get_gint32(mhba->unk048, ctx->byte_order); + album->song_id = get_gint64(mhba->song_id, ctx->byte_order); + album->prev_album_id = get_gint32(mhba->prev_album_id, + ctx->byte_order); cur_offset = ctx->header_len; mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset); @@ -415,7 +429,7 @@ parse_mhba (DBParseContext *ctx, GError *error) return -1; } db_parse_context_set_total_len (mhod_ctx, get_gint32(mhod->total_len, ctx->byte_order)); - photo_album->name = g_strdup( (char *)((MhodHeaderArtworkType1*)mhod)->string ); + album->name = g_strdup( (char *)((MhodHeaderArtworkType1*)mhod)->string ); cur_offset += mhod_ctx->total_len; dump_mhod_type_1 ((MhodHeaderArtworkType1*)mhod); g_free (mhod_ctx); @@ -425,7 +439,7 @@ parse_mhba (DBParseContext *ctx, GError *error) mhia_ctx = db_parse_context_get_sub_context (ctx, cur_offset); num_children = get_gint32 (mhba->num_mhias, ctx->byte_order); while ((num_children > 0) && (mhia_ctx != NULL)) { - parse_mhia (mhia_ctx, photo_album, NULL); + parse_mhia (mhia_ctx, album, NULL); num_children--; cur_offset += mhia_ctx->total_len; g_free (mhia_ctx); @@ -434,7 +448,7 @@ parse_mhba (DBParseContext *ctx, GError *error) photodb = db_get_photodb (ctx->db); g_return_val_if_fail (photodb, -1); photodb->photoalbums = g_list_append (photodb->photoalbums, - photo_album); + album); return 0; } diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c index 80ab33f..e80657a 100644 --- a/src/db-artwork-writer.c +++ b/src/db-artwork-writer.c @@ -671,7 +671,7 @@ write_mhia (gint image_id, iPodBuffer *buffer) } static int -write_mhba (Itdb_PhotoAlbum *photo_album, iPodBuffer *buffer) +write_mhba (Itdb_PhotoAlbum *album, iPodBuffer *buffer) { GList *it; MhbaHeader *mhba; @@ -684,10 +684,27 @@ write_mhba (Itdb_PhotoAlbum *photo_album, iPodBuffer *buffer) return -1; } mhba->num_mhods = get_gint32(1, buffer->byte_order); - mhba->playlist_id = get_gint32(photo_album->album_id, buffer->byte_order); - mhba->album_type = get_gint32(photo_album->album_type, buffer->byte_order); - mhba->prev_playlist_id = get_gint32(photo_album->prev_album_id, buffer->byte_order); - mhba->num_mhias = get_gint32(photo_album->num_images, buffer->byte_order); + mhba->num_mhias = get_gint32(g_list_length (album->members), + buffer->byte_order); + mhba->album_id = get_gint32(album->album_id, buffer->byte_order); + mhba->unk024 = get_gint32(album->unk024, buffer->byte_order); + mhba->unk028 = get_gint16(album->unk028, buffer->byte_order); + mhba->album_type = album->album_type; + mhba->playmusic = album->playmusic; + mhba->repeat = album->repeat; + mhba->random = album->random; + mhba->show_titles = album->show_titles; + mhba->transition_direction = album->transition_direction; + mhba->slide_duration = get_gint32(album->slide_duration, + buffer->byte_order); + mhba->transition_duration = get_gint32(album->transition_duration, + buffer->byte_order); + mhba->unk044 = get_gint32(album->unk044, buffer->byte_order); + mhba->unk048 = get_gint32(album->unk048, buffer->byte_order); + mhba->song_id = get_gint64(album->song_id, buffer->byte_order); + mhba->prev_album_id = get_gint32(album->prev_album_id, + buffer->byte_order); + total_bytes = get_gint32 (mhba->header_len, buffer->byte_order); /* FIXME: Write other mhods */ @@ -696,14 +713,14 @@ write_mhba (Itdb_PhotoAlbum *photo_album, iPodBuffer *buffer) if (sub_buffer == NULL) { return -1; } - bytes_written = write_mhod_type_1 (photo_album->name, sub_buffer); + bytes_written = write_mhod_type_1 (album->name, sub_buffer); ipod_buffer_destroy (sub_buffer); if (bytes_written == -1) { return -1; } total_bytes += bytes_written; - for (it = photo_album->members; it != NULL; it = it->next) { + for (it = album->members; it != NULL; it = it->next) { Itdb_Artwork *photo = it->data; g_return_val_if_fail (photo, -1); @@ -740,13 +757,13 @@ write_mhla (Itdb_DB *db, iPodBuffer *buffer) unsigned int bytes_written; for (it = db_get_photodb(db)->photoalbums; it != NULL; it = it->next) { - Itdb_PhotoAlbum *photo_album = (Itdb_PhotoAlbum *)it->data; + Itdb_PhotoAlbum *album = (Itdb_PhotoAlbum *)it->data; sub_buffer = ipod_buffer_get_sub_buffer (buffer, total_bytes); if (sub_buffer == NULL) { return -1; } - bytes_written = write_mhba (photo_album, sub_buffer); + bytes_written = write_mhba (album, sub_buffer); ipod_buffer_destroy (sub_buffer); if (bytes_written == -1) { return -1; diff --git a/src/db-itunes-parser.h b/src/db-itunes-parser.h index 1b2cfff..423485c 100644 --- a/src/db-itunes-parser.h +++ b/src/db-itunes-parser.h @@ -1,4 +1,5 @@ -/* +/* Time-stamp: <2006-10-29 19:18:28 jcs> + * * Copyright (C) 2005 Christophe Fergeau * * @@ -20,6 +21,7 @@ * * This product is not supported/written/published by Apple! * + * $Id$ */ @@ -615,10 +617,10 @@ struct _MhbaHeader { gint32 num_mhods; /* number of Data Objects in the List, probably always 1 */ gint32 num_mhias; /* number of pictures in the album */ - gint32 playlist_id;/* starts out at $64 and increments by 1 */ - gint32 unknown2; /* unknown, seems to be always 0 */ - gint16 unknown3; /* unknown, seems to be always 0 */ - gchar album_type; /* 1 = master photo list ("Photo Library"), + gint32 album_id; /* starts out at $64 and increments by 1 */ + gint32 unk024; /* unknown, seems to be always 0 */ + gint16 unk028; /* unknown, seems to be always 0 */ + guint8 album_type; /* 1 = master photo list ("Photo Library"), 2 = normal album, sometimes 4 and 5 */ guint8 playmusic; /* play music during slideshow (from iPhoto setting) */ guint8 repeat; /* repeat the slideshow (from iPhoto setting) */ @@ -630,10 +632,11 @@ struct _MhbaHeader { 4=bottom-to-top (from iPhoto setting) */ gint32 slide_duration; /* in seconds (from iPhoto setting) */ gint32 transition_duration; /* in milliseconds (from iPhoto setting) */ - gint32 unk044; - gint32 unk048; - gint64 song_id; - gint32 prev_playlist_id; /* the id of the previous playlist */ + gint32 unk044; /* unknown, seems to always be 0 */ + gint32 unk048; /* unknown, seems to always be 0 */ + gint64 song_id; /* dbid2 of track in iTunesDB to play during + slideshow (from iPhoto setting) */ + gint32 prev_album_id; /* the id of the previous photoalbum */ unsigned char padding[]; }; @@ -1,6 +1,6 @@ -/* Time-stamp: <2006-10-29 15:03:21 jcs> +/* Time-stamp: <2006-10-29 19:18:27 jcs> | -| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net> +| Copyright (C) 2002-2006 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. | | URL: http://www.gtkpod.org/ @@ -490,11 +490,29 @@ struct _Itdb_iTunesDB struct _Itdb_PhotoAlbum { - gchar *name; /* name of photoalbum in UTF8 */ - GList *members; /* photos in album (Itdb_Artwork *) */ - gint num_images; /* number of photos in album */ - gint album_type; /* 0x01 for master (Photo Library), - 0x02 otherwise */ + gchar *name; /* name of photoalbum in UTF8 */ + GList *members; /* photos in album (Itdb_Artwork *) */ + guint8 album_type; /* 0x01 for master (Photo Library), + 0x02 otherwise (sometimes 4 and 5) */ + guint8 playmusic; /* play music during slideshow (from + iPhoto setting) */ + guint8 repeat; /* repeat the slideshow (from iPhoto + setting) */ + guint8 random; /* show the slides in random order + (from iPhoto setting) */ + guint8 show_titles; /* show slide captions (from iPhoto + setting) */ + guint8 transition_direction; /* 0=none, 1=left-to-right, + 2=right-to-left, 3=top-to-bottom, + 4=bottom-to-top (from iPhoto setting) */ + gint32 slide_duration; /* in seconds (from iPhoto setting) */ + gint32 transition_duration; /* in milliseconds (from iPhoto setting) */ + gint64 song_id; /* dbid2 of track in iTunesDB to play + during slideshow (from iPhoto setting)*/ + gint32 unk024; /* unknown, seems to be always 0 */ + gint16 unk028; /* unknown, seems to be always 0 */ + gint32 unk044; /* unknown, seems to always be 0 */ + gint32 unk048; /* unknown, seems to always be 0 */ /* set automatically at time of writing the PhotoDB */ gint32 album_id; gint32 prev_album_id; diff --git a/src/itdb_photoalbum.c b/src/itdb_photoalbum.c index 4a06a28..34d811c 100644 --- a/src/itdb_photoalbum.c +++ b/src/itdb_photoalbum.c @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-10-22 20:19:45 jcs> +/* Time-stamp: <2006-10-29 19:15:33 jcs> | | Copyright (C) 2002-2006 Jorg Schuler <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -528,7 +528,6 @@ void itdb_photodb_remove_photo (Itdb_PhotoDB *db, while (g_list_find (_album->members, photo)) { _album->members = g_list_remove (_album->members, photo); - --_album->num_images; } } /* Remove the photo from the image list */ @@ -540,7 +539,6 @@ void itdb_photodb_remove_photo (Itdb_PhotoDB *db, else { album->members = g_list_remove (album->members, photo); - --album->num_images; } } @@ -630,7 +628,6 @@ void itdb_photodb_photoalbum_add_photo (Itdb_PhotoDB *db, g_return_if_fail (photo); album->members = g_list_append (album->members, photo); - ++album->num_images; } diff --git a/tests/test-photos.c b/tests/test-photos.c index 36c3bf5..18d364e 100644 --- a/tests/test-photos.c +++ b/tests/test-photos.c @@ -405,9 +405,9 @@ main (int argc, char **argv) { return do_remove (argc, argv); } + g_print (_("Unknown command '%s'\n"), argv[1]); usage (argc, argv); - - return 0; + return 1; } |