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

Modified Files:
        db-artwork-debug.c db-artwork-parser.c db-artwork-writer.c 
        db-itunes-parser.h itdb.h 
Log Message:
        * itdb.h: Itdb_Artwork:
          - added unk028, unk036 and rating
          - added digitized_data timestamp
          - changed creation_date from gint32 to guint32

        * db-itunes-parser.h:
          db-artwork-debug.c: MhiiHeader:
          - renamed unknown5 to rating
          - renamed digitised_date to digitized_date for conformity

        * db-artwork-writer.c (write_mhli): sanity check to avoid access
          of NULL pointer.
          (write_mhii): write unk028, rating, unk036, digitized_data

        * db-artwork_parser.c (parse_mhii):
          - parse unk028, rating, unk036, digitized data.
          - unified reading of DB_TYPE_PHOTO and DB_TYPE_ITUNES, got rid
            of parse_mhod() and parse_mhni().



Index: db-artwork-debug.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-artwork-debug.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- db-artwork-debug.c  30 May 2006 14:09:42 -0000      1.5
+++ db-artwork-debug.c  11 Nov 2006 13:44:29 -0000      1.6
@@ -148,10 +148,10 @@
        g_print ("\tImage ID: %08x\n", GINT_FROM_LE (mhii->image_id));
        g_print ("\tSong ID: %016llx\n", GINT64_FROM_LE (mhii->song_id));
        g_print ("\tUnknown4: %08x\n", GINT_FROM_LE (mhii->unknown4));
-       g_print ("\tUnknown5: %08x\n", GINT_FROM_LE (mhii->unknown5));
+       g_print ("\tRating: %08x\n", GINT_FROM_LE (mhii->rating));
        g_print ("\tUnknown6: %08x\n", GINT_FROM_LE (mhii->unknown6));
        g_print ("\tOrig Date: %08x\n", GINT_FROM_LE (mhii->orig_date));
-       g_print ("\tDigitised Date: %08x\n", GINT_FROM_LE 
(mhii->digitised_date));
+       g_print ("\tDigitised Date: %08x\n", GINT_FROM_LE 
(mhii->digitized_date));
        g_print ("\tImage size: %d bytes\n", GINT_FROM_LE 
(mhii->orig_img_size));
 }
 

Index: db-artwork-parser.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-artwork-parser.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- db-artwork-parser.c 29 Oct 2006 10:37:46 -0000      1.24
+++ db-artwork-parser.c 11 Nov 2006 13:44:29 -0000      1.25
@@ -42,7 +42,6 @@
 
 typedef int (*ParseListItem)(DBParseContext *ctx, GError *error);
 
-#ifndef NOT_DEFINED_DEBUG_ARTWORKDB
 static Itdb_Track *
 get_song_by_dbid (Itdb_iTunesDB *db, guint64 id)
 {
@@ -58,7 +57,6 @@
        }
        return NULL;
 }
-#endif
 
 
 static int
@@ -195,42 +193,11 @@
 }
 
 static int
-parse_mhni (DBParseContext *ctx, iPodSong *song, GError *error)
-{
-       MhniHeader *mhni;
-       DBParseContext *mhod_ctx; 
-       Itdb_Thumb *thumb;
-
-       mhni = db_parse_context_get_m_header (ctx, MhniHeader, "mhni");
-       if (mhni == NULL) {
-               return -1;
-       }
-       db_parse_context_set_total_len (ctx, get_gint32 (mhni->total_len, 
ctx->byte_order));
-       dump_mhni (mhni);
-       thumb = ipod_image_new_from_mhni (mhni, ctx->db);
-       if (thumb == NULL) {
-               return 0;
-       }
-
-       song->artwork->thumbnails =
-               g_list_append (song->artwork->thumbnails, thumb);
-
-       mhod_ctx = db_parse_context_get_sub_context (ctx, ctx->header_len);
-       if (mhod_ctx == NULL) {
-         return -1;
-       }
-       parse_mhod_3 (mhod_ctx, thumb, error);
-       g_free (mhod_ctx);
-
-       return 0;
-}
-
-static int
 parse_photo_mhod (DBParseContext *ctx, Itdb_Artwork *artwork, GError *error)
 {
        ArtworkDB_MhodHeader *mhod;
        DBParseContext *mhni_ctx;
-       int type;
+       gint32 type;
 
        mhod = db_parse_context_get_m_header (ctx, ArtworkDB_MhodHeader, 
"mhod");
        if (mhod == NULL) {
@@ -238,47 +205,6 @@
        }
        db_parse_context_set_total_len (ctx, get_gint32 (mhod->total_len, 
ctx->byte_order));
 
-       /* The MHODs found in the ArtworkDB and Photo Database files are
-        * significantly different than those found in the iTunesDB.
-        * For example, the "type" is split like this:
-        * - low 3 bytes are actual type;
-        * - high byte is padding length of string (0-3).
-        */
-       type = get_gint16 (mhod->type, ctx->byte_order) & 0x00FFFFFF;
-
-       if ( type == MHOD_ARTWORK_TYPE_ALBUM_NAME) {
-               dump_mhod_type_1 ((MhodHeaderArtworkType1 *)mhod);
-       } else {
-               dump_mhod (mhod);
-       }
-
-       /* if this is a container... */
-       if (type == MHOD_ARTWORK_TYPE_THUMBNAIL) {
-               mhni_ctx = db_parse_context_get_sub_context (ctx, 
ctx->header_len);
-               if (mhni_ctx == NULL) {
-                       return -1;
-               }
-               parse_photo_mhni (mhni_ctx, artwork, NULL);
-               g_free (mhni_ctx);
-       }
-
-       return 0;
-}
-static int
-parse_mhod (DBParseContext *ctx, iPodSong *song, GError *error)
-{
-       ArtworkDB_MhodHeader *mhod;
-       DBParseContext *mhni_ctx;
-       int type;
-       gint32 total_len;
-
-       mhod = db_parse_context_get_m_header (ctx, ArtworkDB_MhodHeader, 
"mhod");
-       if (mhod == NULL) {
-               return -1;
-       }
-       total_len = get_gint32 (mhod->total_len, ctx->byte_order);
-       db_parse_context_set_total_len (ctx, total_len);
-
        type = get_gint16 (mhod->type, ctx->byte_order);
 
        if ( type == MHOD_ARTWORK_TYPE_ALBUM_NAME) {
@@ -293,14 +219,12 @@
                if (mhni_ctx == NULL) {
                        return -1;
                }
-               parse_mhni (mhni_ctx, song, NULL);
+               parse_photo_mhni (mhni_ctx, artwork, NULL);
                g_free (mhni_ctx);
        }
 
        return 0;
 }
-
-
 static int
 parse_mhii (DBParseContext *ctx, GError *error)
 {
@@ -308,73 +232,79 @@
        DBParseContext *mhod_ctx;
        int num_children;
        off_t cur_offset;
-       iPodSong *song;
+       iPodSong *song = NULL;
        Itdb_Artwork *artwork;
        Itdb_PhotoDB *photodb;
        Itdb_iTunesDB *itunesdb;
+       guint64 dbid;
 
        mhii = db_parse_context_get_m_header (ctx, MhiiHeader, "mhii");
-       if (mhii == NULL) {
-               return -1;
+       if (mhii == NULL)
+       {
+           return -1;
        }
        db_parse_context_set_total_len (ctx, get_gint32 (mhii->total_len, 
ctx->byte_order));
        dump_mhii (mhii);
 
-       switch (ctx->db->db_type) {
+       switch (ctx->db->db_type)
+       {
        case DB_TYPE_PHOTO:
-               artwork = g_new0( Itdb_Artwork, 1 );
-               artwork->artwork_size = get_gint32 (mhii->orig_img_size, 
ctx->byte_order);
-               artwork->id = get_gint32 (mhii->image_id, ctx->byte_order);
-               artwork->creation_date = itdb_time_mac_to_host( get_gint32 
(mhii->digitised_date, ctx->byte_order) );
-
-               cur_offset = ctx->header_len;
-               mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset);
-               num_children = get_gint32 (mhii->num_children, ctx->byte_order);
-               while ((num_children > 0) && (mhod_ctx != NULL)) {
-                       parse_photo_mhod (mhod_ctx, artwork, NULL);
-                       num_children--;
-                       cur_offset += mhod_ctx->total_len;
-                       g_free (mhod_ctx);
-                       mhod_ctx = db_parse_context_get_sub_context (ctx, 
cur_offset);
-               }
-               photodb = db_get_photodb (ctx->db);
-               g_return_val_if_fail (photodb, -1);
-               photodb->photos = g_list_append (photodb->photos,
-                                                artwork);
-               break;
+           photodb = db_get_photodb (ctx->db);
+           g_return_val_if_fail (photodb, -1);
+           artwork = g_new0 (Itdb_Artwork, 1);
+           photodb->photos = g_list_append (photodb->photos, artwork);
+           break;
        case DB_TYPE_ITUNES:
-#ifdef NOT_DEFINED_DEBUG_ARTWORKDB
-               song = NULL;
-#else
-               itunesdb = db_get_itunesdb (ctx->db);
-               g_return_val_if_fail (itunesdb, -1);
-               song = get_song_by_dbid (itunesdb,
-                                        get_gint64 (mhii->song_id,
-                                                    ctx->byte_order));
-               if (song == NULL) {
-                       return -1;
-               }
-               song->artwork->artwork_size = get_gint32 (mhii->orig_img_size, 
ctx->byte_order);
-               if ((song->artwork_size+song->artwork_count) !=
-                               song->artwork->artwork_size) {
-                       g_warning (_("iTunesDB and ArtworkDB artwork sizes 
inconsistent (%d+%d != %d)"), song->artwork_size, song->artwork_count, 
song->artwork->artwork_size);
-               }
-               song->artwork->id = get_gint32 (mhii->image_id, 
ctx->byte_order);
-#endif
-
-               cur_offset = ctx->header_len;
-               mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset);
-               num_children = get_gint32 (mhii->num_children, ctx->byte_order);
-               while ((num_children > 0) && (mhod_ctx != NULL)) {
-                       parse_mhod (mhod_ctx, song, NULL);
-                       num_children--;
-                       cur_offset += mhod_ctx->total_len;
-                       g_free (mhod_ctx);
-                       mhod_ctx = db_parse_context_get_sub_context (ctx, 
cur_offset);
-               }
-               break;
+           itunesdb = db_get_itunesdb (ctx->db);
+           g_return_val_if_fail (itunesdb, -1);
+           dbid = get_gint64 (mhii->song_id, ctx->byte_order);
+           song = get_song_by_dbid (itunesdb, dbid);
+           if (song == NULL)
+           {
+               gchar *strval = g_strdup_printf("%" G_GINT64_FORMAT, dbid);
+               g_print (_("Could not find corresponding track (dbid: %s) for 
artwork entry.\n"), strval);
+               g_free (strval);
+               return -1;
+           }
+           artwork = song->artwork;
+           g_return_val_if_fail (artwork, -1);
+           break;
        default:
-              g_return_val_if_reached (-1);
+           g_return_val_if_reached (-1);
+       }
+
+       artwork->id = get_gint32 (mhii->image_id, ctx->byte_order);
+       artwork->unk028 = get_gint32 (mhii->unknown4, ctx->byte_order);
+       artwork->rating = get_gint32 (mhii->rating, ctx->byte_order);
+       artwork->unk036 = get_gint32 (mhii->unknown6, ctx->byte_order);
+       artwork->creation_date = get_gint32 (mhii->orig_date, ctx->byte_order);
+       artwork->digitized_date = get_gint32 (mhii->digitized_date,
+                                             ctx->byte_order);
+       artwork->artwork_size = get_gint32 (mhii->orig_img_size,
+                                           ctx->byte_order);
+
+       if (song)
+       {
+           if ((song->artwork_size+song->artwork_count) !=
+               artwork->artwork_size)
+           {
+               g_warning (_("iTunesDB and ArtworkDB artwork sizes inconsistent 
(%d+%d != %d)\n"),
+                          song->artwork_size,
+                          song->artwork_count,
+                          song->artwork->artwork_size);
+           }
+       }
+
+       cur_offset = ctx->header_len;
+       mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset);
+       num_children = get_gint32 (mhii->num_children, ctx->byte_order);
+       while ((num_children > 0) && (mhod_ctx != NULL))
+       {
+           parse_photo_mhod (mhod_ctx, artwork, NULL);
+           num_children--;
+           cur_offset += mhod_ctx->total_len;
+           g_free (mhod_ctx);
+           mhod_ctx = db_parse_context_get_sub_context (ctx, cur_offset);
        }
        return 0;
 }

Index: db-artwork-writer.c
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-artwork-writer.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- db-artwork-writer.c 29 Oct 2006 10:37:47 -0000      1.24
+++ db-artwork-writer.c 11 Nov 2006 13:44:29 -0000      1.25
@@ -541,23 +541,26 @@
        switch( buffer->db_type) {
        case DB_TYPE_ITUNES:
                song = (Itdb_Track *)data;
+               artwork = song->artwork;
                mhii->song_id = get_gint64 (song->dbid, buffer->byte_order);
-               mhii->image_id = get_guint32 (song->artwork->id, 
buffer->byte_order);
-               mhii->orig_img_size = get_gint32 (song->artwork->artwork_size, 
-                               buffer->byte_order);
-               it = song->artwork->thumbnails;
                break;
        case DB_TYPE_PHOTO:
                artwork = (Itdb_Artwork *)data;
                mhii->song_id = get_gint64 (artwork->id + 2, 
buffer->byte_order);
-               mhii->image_id = get_guint32 (artwork->id, buffer->byte_order);
-               mhii->orig_date = get_guint32 (itdb_time_host_to_mac( 
artwork->creation_date )
-                               , buffer->byte_order);
-               mhii->digitised_date = get_guint32 (itdb_time_host_to_mac( 
artwork->creation_date )
-                               , buffer->byte_order);
-               it = artwork->thumbnails;
                break;
+       default:
+               g_return_val_if_reached (-1);
        }
+       mhii->image_id = get_guint32 (artwork->id, buffer->byte_order);
+       mhii->unknown4 = get_gint32 (artwork->unk028, buffer->byte_order);
+       mhii->rating = get_gint32 (artwork->rating, buffer->byte_order);
+       mhii->unknown6 = get_gint32 (artwork->unk036, buffer->byte_order);
+       mhii->orig_date = get_guint32 (artwork->creation_date, 
buffer->byte_order);
+       mhii->digitized_date = get_guint32 (artwork->digitized_date,
+                                           buffer->byte_order);
+       mhii->orig_img_size = get_gint32 (artwork->artwork_size, 
+                                         buffer->byte_order);
+       it = artwork->thumbnails;
        num_children = 0;
        while (it != NULL) {
                iPodBuffer *sub_buffer;
@@ -628,7 +631,7 @@
 
                if (buffer->db_type == DB_TYPE_ITUNES) {
                        song = (Itdb_Track*)it->data;
-                       if (song->artwork->id == 0) {
+                       if (!song->artwork || (song->artwork->id == 0)) {
                                it = it->next;
                                continue;
                        }

Index: db-itunes-parser.h
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/db-itunes-parser.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- db-itunes-parser.h  29 Oct 2006 10:37:47 -0000      1.8
+++ db-itunes-parser.h  11 Nov 2006 13:44:29 -0000      1.9
@@ -1,4 +1,4 @@
-/*  Time-stamp: <2006-10-29 19:18:28 jcs>
+/*  Time-stamp: <2006-11-11 20:38:32 jcs>
  *
  *  Copyright (C) 2005 Christophe Fergeau
  *
@@ -333,7 +333,7 @@
         * phones with iPod support).
         */
        gint16 type;
-    gint16 unknown014;
+        gint16 unknown014;
        gint32 unknown1;
        gint32 unknown2;
 };
@@ -575,10 +575,10 @@
        gint32 image_id;
        gint64 song_id;
        gint32 unknown4;
-       gint32 unknown5;
+       gint32 rating;
        gint32 unknown6;
        gint32 orig_date;
-       gint32 digitised_date;
+       gint32 digitized_date;
        gint32 orig_img_size;
        unsigned char padding[];
 } __attribute__((__packed__));

Index: itdb.h
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/src/itdb.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- itdb.h      7 Nov 2006 12:08:18 -0000       1.48
+++ itdb.h      11 Nov 2006 13:44:29 -0000      1.49
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-11-07 20:51:08 jcs>
+/* Time-stamp: <2006-11-11 16:29:02 jcs>
 |
 |  Copyright (C) 2002-2006 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -445,11 +445,20 @@
 };
 
 struct _Itdb_Artwork {
-    GList *thumbnails;    /* list of Itdb_Thumbs */
-    guint32 artwork_size; /* Size in bytes of the original source image */
-    guint32 id;           /* Artwork id used by photoalbums, starts at
-                          * 0x40... libgpod will set this on sync. */
-    gint32 creation_date; /* Date the image was created */
+    GList *thumbnails;     /* list of Itdb_Thumbs */
+    guint32 id;            /* Artwork id used by photoalbums, starts at
+                           * 0x40... libgpod will set this on sync. */
+    gint32  unk028;
+    guint32 rating;        /* Rating from iPhoto * 20 (PhotoDB only) */
+    gint32  unk036;
+    guint32 creation_date; /* Date the image file was created
+                             (creation date of image file (Mac type,
+                             PhotoDB only) */
+    guint32 digitized_date;/* Date the image was taken (EXIF
+                             information, Mac type, PhotoDB only) */
+    guint32 artwork_size;  /* Size in bytes of the original source
+                             image (PhotoDB only -- don't touch in
+                             case of ArtworkDB!) */
     /* below is for use by application */
     guint64 usertype;
     gpointer userdata;


-------------------------------------------------------------------------
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