Revision: 1692
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1692&view=rev
Author:   jcsjcs
Date:     2007-09-14 23:37:22 -0700 (Fri, 14 Sep 2007)

Log Message:
-----------
        * src/file_itunesdb.c (gp_load_ipod): make sure the ipod model
          number is known and written to the iPod before loading the
          iTunesDB. If the model number is not known at the time of
          loading the iTunesDB, libgpod will not read the ArtworkDB,
          thereby losing all artwork.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog_detailed
    gtkpod/trunk/src/file_itunesdb.c

Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed     2007-09-08 15:15:57 UTC (rev 1691)
+++ gtkpod/trunk/ChangeLog_detailed     2007-09-15 06:37:22 UTC (rev 1692)
@@ -1,19 +1,27 @@
+2007-09-15 Jorg Schuler <jcsjcs at users.sourceforge.net>
+
+       * src/file_itunesdb.c (gp_load_ipod): make sure the ipod model
+         number is known and written to the iPod before loading the
+         iTunesDB. If the model number is not known at the time of
+         loading the iTunesDB, libgpod will not read the ArtworkDB,
+         thereby losing all artwork.
+
 2007-09-02  Todd Zullinger  <tmzullinger at users.sourceforge.net>
 
        * scripts/convert-m4a2mp3.sh: fixed a typo, spotted by Peter
-       van der Does.
+         van der Does.
 
 2007-08-26 P.G. Richardson <phantom_sf at users.sourceforge.net>
 
-  * src/fetchcover.c
-  * src/fetchcover.h
-  * src/display_coverart.c
-  * src/details.c
-  * src/context_menus.c
-  * gtkpod.glade
+       * src/fetchcover.c
+       * src/fetchcover.h
+       * src/display_coverart.c
+       * src/details.c
+       * src/context_menus.c
+       * gtkpod.glade
   
-  Commented out fetchcover due to licensing problems. Wiil re-enable
-  once a new approach has been fully considered.
+       Commented out fetchcover due to licensing problems. Wiil re-enable
+       once a new approach has been fully considered.
 
 2007-08-25 Jorg Schuler <jcsjcs at users.sourceforge.net>
 

Modified: gtkpod/trunk/src/file_itunesdb.c
===================================================================
--- gtkpod/trunk/src/file_itunesdb.c    2007-09-08 15:15:57 UTC (rev 1691)
+++ gtkpod/trunk/src/file_itunesdb.c    2007-09-15 06:37:22 UTC (rev 1692)
@@ -30,6 +30,7 @@
 #  include <config.h>
 #endif
 
+#include <ctype.h>
 #include <string.h>
 #include <glib/gstdio.h>
 #include "charset.h"
@@ -774,7 +775,7 @@
  *
  * Return value: pointer to the new repository
  */
-iTunesDB *gp_merge_itdb (iTunesDB *old_itdb)
+static iTunesDB *gp_merge_itdb (iTunesDB *old_itdb)
 {
     ExtraiTunesDBData *old_eitdb;
     iTunesDB *new_itdb;
@@ -885,41 +886,72 @@
 
     if (ok_to_load)
     {
+       gchar *prefs_model = get_itdb_prefs_string (itdb, KEY_IPOD_MODEL);
+       gchar *ipod_model = itdb_device_get_sysinfo (itdb->device, 
"ModelNumStr");
+       if (!prefs_model && ipod_model)
+       {   /* let's believe what the iPod says */
+           set_itdb_prefs_string (itdb, KEY_IPOD_MODEL, ipod_model);
+       }
+       else if (prefs_model && !ipod_model)
+       {   /* verify with the user if the model is correct --
+            * incorrect mdoel information can result in loss of
+            * Artwork */
+           gp_ipod_init_set_model (itdb, prefs_model);
+           /* write out new SysInfo file -- otherwise libpod won't
+              use it. Ignore error for now. */
+           itdb_device_write_sysinfo (itdb->device, NULL);
+       }
+       else if (!prefs_model && !ipod_model)
+       {
+           /* ask the user to set the model information */
+           gp_ipod_init_set_model (itdb, NULL);
+           /* write out new SysInfo file -- otherwise libpod won't
+              use it. Ignore error for now. */
+           itdb_device_write_sysinfo (itdb->device, NULL);
+       }
+       else
+       {   /* prefs_model && ipod_model are set */
+           const gchar *prefs_ptr = prefs_model;
+           const gchar *ipod_ptr = ipod_model;
+           /* Normalize model number */
+           if (isalpha (prefs_model[0]))  ++prefs_ptr;
+           if (isalpha (ipod_model[0]))   ++ipod_ptr;
+           if (strcmp (prefs_ptr, ipod_ptr) != 0)
+           {   /* Model number is different -- confirm */
+               gp_ipod_init_set_model (itdb, ipod_model);
+               /* write out new SysInfo file -- otherwise libpod won't
+                  use it. Ignore error for now. */
+               itdb_device_write_sysinfo (itdb->device, NULL);
+           }
+       }
+       g_free (prefs_model);
+       g_free (ipod_model);
+
        new_itdb = gp_merge_itdb (itdb);
+
        if (new_itdb)
        {
            GList *gl;
-           gchar *old_model = get_itdb_prefs_string (new_itdb,
-                                                     KEY_IPOD_MODEL);
            gchar *new_model = itdb_device_get_sysinfo (new_itdb->device,
                                                        "ModelNumStr");
 
-           if (!old_model && new_model)
-           {
-               set_itdb_prefs_string (new_itdb, KEY_IPOD_MODEL, new_model);
+           if (!new_model)
+           {   /* Something went wrong with setting the ipod model
+                * above */
+               prefs_model = get_itdb_prefs_string (new_itdb, KEY_IPOD_MODEL);
+               if (prefs_model)
+               {
+                   itdb_device_set_sysinfo (new_itdb->device, "ModelNumStr",
+                                            prefs_model);
+               }
+               else
+               {   /* ask again... */
+                   gp_ipod_init_set_model (new_itdb, NULL);
+               }
+               g_free (prefs_model);
            }
-           else if (old_model && !new_model)
-           {
-               gp_ipod_init_set_model (new_itdb, old_model);
-           }
-           else if (!old_model && !new_model)
-           {
-               gp_ipod_init_set_model (new_itdb, NULL);
-           }
-           else
-           {   /* old_model && new_model are set */
-#if 0
-               const gchar *old_ptr = old_model;
-               const gchar *new_ptr = new_model;
-               /* Normalize model number */
-               if (isalpha (old_model[0]))   ++old_ptr;
-               if (isalpha (new_model[0]))   ++new_ptr;
-               if (strcmp (old_ptr, new_ptr) != 0)
-               {   /* Model number has changed -- confirm */
-                }
-#endif         
-               set_itdb_prefs_string (new_itdb, KEY_IPOD_MODEL, new_model);
-           }
+           g_free (new_model);
+
            /* adjust rating and playcount in local databases */
            for (gl=new_itdb->tracks; gl; gl=gl->next)
            {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to