Update of /cvsroot/gtkpod/libgpod/src
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv15213/src

Modified Files:
        db-artwork-parser.c db-artwork-writer.c db-itunes-parser.h 
        itdb.h itdb_photoalbum.c 
Log Message:
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.



Index: db-artwork-parser.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-artwork-parser.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- db-artwork-parser.c 29 Oct 2006 08:43:28 -0000      1.23
+++ db-artwork-parser.c 29 Oct 2006 10:37:46 -0000      1.24
@@ -386,7 +386,7 @@
        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 @@
 
        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 @@
                        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 @@
        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 @@
        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;
 }
 

Index: db-artwork-writer.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-artwork-writer.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- db-artwork-writer.c 29 Oct 2006 08:43:28 -0000      1.23
+++ db-artwork-writer.c 29 Oct 2006 10:37:47 -0000      1.24
@@ -671,7 +671,7 @@
 }
 
 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 @@
                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 @@
        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 @@
            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;

Index: db-itunes-parser.h
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-itunes-parser.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- db-itunes-parser.h  29 Oct 2006 08:43:28 -0000      1.7
+++ db-itunes-parser.h  29 Oct 2006 10:37:47 -0000      1.8
@@ -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 @@
        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 @@
                              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[];
 };
 

Index: itdb.h
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- itdb.h      29 Oct 2006 08:43:28 -0000      1.46
+++ itdb.h      29 Oct 2006 10:37:47 -0000      1.47
@@ -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_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;

Index: itdb_photoalbum.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb_photoalbum.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- itdb_photoalbum.c   29 Oct 2006 08:43:28 -0000      1.8
+++ itdb_photoalbum.c   29 Oct 2006 10:37:47 -0000      1.9
@@ -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 @@
            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 @@
     else
     {
         album->members = g_list_remove (album->members, photo);
-        --album->num_images;
     }
 }
 
@@ -630,7 +628,6 @@
     g_return_if_fail (photo);
 
     album->members = g_list_append (album->members, photo);
-    ++album->num_images;
 }
 
 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to