commit 5631699a4104a9ad9e0f07d230186e432298334e
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Sun Mar 13 19:53:10 2011 +0000

    Revert "trial attempt at converting itdb"
    
    Not yet ready to push.
    
    This reverts commit 1968080128bbc4ded4fe8f31ae420b3b42a5e578.

 libgtkpod/autodetection.c                   |   30 +++---
 libgtkpod/file.h                            |    3 +-
 libgtkpod/file_itunesdb.c                   |  149 +++++++++++++++---------
 libgtkpod/gp_itdb.c                         |  168 ++++-----------------------
 libgtkpod/gp_itdb.h                         |    1 -
 libgtkpod/prefs.c                           |    2 -
 libgtkpod/prefs.h                           |    2 -
 plugins/repository_editor/repository_init.c |    2 +-
 8 files changed, 134 insertions(+), 223 deletions(-)
---
diff --git a/libgtkpod/autodetection.c b/libgtkpod/autodetection.c
index 75c1371..e0bc5b0 100644
--- a/libgtkpod/autodetection.c
+++ b/libgtkpod/autodetection.c
@@ -73,23 +73,25 @@ static iTunesDB *ad_find_repository_with_mountpoint(const 
gchar *mountpoint) {
         iTunesDB *itdb = gl->data;
         g_return_val_if_fail (itdb, NULL);
 
-        gchar *imp = get_itdb_prefs_string(itdb, KEY_MOUNTPOINT);
-        if (imp) {
-            gint comp;
-            gint lenimp = strlen(imp);
-
-            /* eliminate trailing dir separators ('/') */
-            if ((lenimp > 0) && (imp[lenimp - 1] == G_DIR_SEPARATOR)) {
-                imp[lenmp - 1] = 0;
-            }
+        if (itdb->usertype & GP_ITDB_TYPE_IPOD) {
+            gchar *imp = get_itdb_prefs_string(itdb, KEY_MOUNTPOINT);
+            if (imp) {
+                gint comp;
+                gint lenimp = strlen(imp);
+
+                /* eliminate trailing dir separators ('/') */
+                if ((lenimp > 0) && (imp[lenimp - 1] == G_DIR_SEPARATOR)) {
+                    imp[lenmp - 1] = 0;
+                }
 
-            comp = strcmp(mp, imp);
+                comp = strcmp(mp, imp);
 
-            g_free(imp);
+                g_free(imp);
 
-            if (comp == 0) {
-                result = itdb;
-                break;
+                if (comp == 0) {
+                    result = itdb;
+                    break;
+                }
             }
         }
     }
diff --git a/libgtkpod/file.h b/libgtkpod/file.h
index 55440e4..9c99785 100644
--- a/libgtkpod/file.h
+++ b/libgtkpod/file.h
@@ -77,7 +77,8 @@ void update_tracks (GList *selected_tracks);
 void display_non_updated (Track *track, gchar *txt);
 void display_updated (Track *track, gchar *txt);
 iTunesDB *gp_import_itdb (iTunesDB *old_itdb, const gint type,
-                         const gchar *mp, const gchar *name_off);
+                         const gchar *mp, const gchar *name_off,
+                         const gchar *name_loc);
 void gp_load_ipods (void);
 iTunesDB *gp_load_ipod (iTunesDB *itdb);
 gboolean gp_eject_ipod(iTunesDB *itdb);
diff --git a/libgtkpod/file_itunesdb.c b/libgtkpod/file_itunesdb.c
index 5d0ff08..d947106 100644
--- a/libgtkpod/file_itunesdb.c
+++ b/libgtkpod/file_itunesdb.c
@@ -412,9 +412,9 @@ static void load_photodb(iTunesDB *itdb, GString *errors) {
  * @type: GP_ITDB_TYPE_LOCAL/IPOD (bitwise flags!)
  * @mp: mount point of iPod (if reading an iPod iTunesDB)
  * @name_off: name of the iTunesDB in offline mode
- * Return value: a new iTunesDB structure or NULL in case of an error
- */
-iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint type, const gchar *mp, 
const gchar *name_off) {
+ * @name_loc: name of iTunesDB (if reading a local file browser) */
+/* Return value: a new iTunesDB structure or NULL in case of an error */
+iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint type, const gchar *mp, 
const gchar *name_off, const gchar *name_loc) {
     gchar *cfgdir;
     GList *gl;
     Playlist *pod_pl;
@@ -425,7 +425,9 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
     gint32 total, num;
     gboolean offline;
 
-    g_return_val_if_fail (mp && name_off, NULL);
+    g_return_val_if_fail (!(type & GP_ITDB_TYPE_LOCAL) || name_loc, NULL);
+    g_return_val_if_fail (!(type & GP_ITDB_TYPE_IPOD) ||
+            (mp && name_off), NULL);
 
     cfgdir = prefs_get_cfgdir();
     g_return_val_if_fail (cfgdir, NULL);
@@ -436,11 +438,18 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
         offline = FALSE;
 
     block_widgets();
-    if (offline) { /* offline - requires extended info */
+    if (offline || (type & GP_ITDB_TYPE_LOCAL)) { /* offline or local database 
- requires extended info */
         gchar *name_ext;
         gchar *name_db;
-        name_ext = g_strdup_printf("%s.ext", name_off);
-        name_db = g_strdup(name_off);
+
+        if (type & GP_ITDB_TYPE_LOCAL) {
+            name_ext = g_strdup_printf("%s.ext", name_loc);
+            name_db = g_strdup(name_loc);
+        }
+        else {
+            name_ext = g_strdup_printf("%s.ext", name_off);
+            name_db = g_strdup(name_off);
+        }
 
         if (g_file_test(name_db, G_FILE_TEST_EXISTS)) {
             if (WRITE_EXTENDED_INFO) {
@@ -451,20 +460,29 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
                     msg
                             = g_strconcat(msg, _("This database identifies the 
track on disk with the track data in the repository database. "), _("Any tracks 
already in the database cannot be transferred between repositories without the 
extended database. "), _("A new extended database will be created upon saving 
but existing tracks will need to be reimported to be linked to the file on 
disk.\n\n"), NULL);
                     g_string_append(errors, msg);
-                    g_free(msg);
                 }
             }
             itdb = itdb_parse_file(name_db, &error);
             if (itdb && !error) {
-                gtkpod_statusbar_message(_("Offline iPod database successfully 
imported"));
+                if (type & GP_ITDB_TYPE_IPOD)
+                    gtkpod_statusbar_message(_("Offline iPod database 
successfully imported"));
+                else
+                    gtkpod_statusbar_message(_("Local database successfully 
imported"));
             }
             else {
                 if (error) {
-                    g_string_append_printf(errors, _("Offline iPod database 
import failed: '%s'\n\n"), error->message);
+                    if (type & GP_ITDB_TYPE_IPOD)
+                        g_string_append_printf(errors, _("Offline iPod 
database import failed: '%s'\n\n"), error->message);
+                    else
+                        g_string_append_printf(errors, _("Local database 
import failed: '%s'\n\n"), error->message);
+
                     g_error_free(error);
                 }
                 else {
-                    g_string_append(errors, _("Offline iPod database import 
failed: \n\n"));
+                    if (type & GP_ITDB_TYPE_IPOD)
+                        g_string_append(errors, _("Offline iPod database 
import failed: \n\n"));
+                    else
+                        g_string_append(errors, _("Local database import 
failed: \n\n"));
                 }
             }
         }
@@ -474,7 +492,7 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
         g_free(name_ext);
         g_free(name_db);
     }
-    else { /* iPod is connected */
+    else { /* GP_ITDB_TYPE_IPOD _and_ iPod is connected */
         gchar *name_ext = NULL, *name_db = NULL;
 
         name_db = itdb_get_itunesdb_path(mp);
@@ -525,12 +543,14 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
 
     /* fill in additional info */
     itdb->usertype = type;
-    if (offline) {
-        itdb_set_mountpoint(itdb, mp);
-        g_free(itdb->filename);
-        itdb->filename = NULL;
+    if (type & GP_ITDB_TYPE_IPOD) {
+        if (offline) {
+            itdb_set_mountpoint(itdb, mp);
+            g_free(itdb->filename);
+            itdb->filename = NULL;
+        }
+        eitdb->offline_filename = g_strdup(name_off);
     }
-    eitdb->offline_filename = g_strdup(name_off);
 
     total = g_list_length(itdb->tracks);
     num = 1;
@@ -672,19 +692,19 @@ iTunesDB *gp_import_itdb(iTunesDB *old_itdb, const gint 
type, const gchar *mp, c
 
     if (errors && errors->len > 0) {
         gtkpod_confirmation(-1, /* gint id, */
-        TRUE, /* gboolean modal, */
-        _("Import Repository Errors"), /* title */
-        _("Errors created during repository import"), /* label */
-        errors->str, /* scrolled text */
-        NULL, 0, NULL, /* option 1 */
-        NULL, 0, NULL, /* option 2 */
-        TRUE, /* gboolean confirm_again, */
-        "show_itdb_import_errors",/* confirm_again_key,*/
-        CONF_NULL_HANDLER, /* ConfHandler ok_handler,*/
-        NULL, /* don't show "Apply" button */
-        NULL, /* cancel_handler,*/
-        NULL, /* gpointer user_data1,*/
-        NULL); /* gpointer user_data2,*/
+                TRUE, /* gboolean modal, */
+                _("Import Repository Errors"), /* title */
+                _("Errors created during repository import"), /* label */
+                errors->str, /* scrolled text */
+                NULL, 0, NULL, /* option 1 */
+                NULL, 0, NULL, /* option 2 */
+                TRUE, /* gboolean confirm_again, */
+                "show_itdb_import_errors",/* confirm_again_key,*/
+                CONF_NULL_HANDLER, /* ConfHandler ok_handler,*/
+                NULL, /* don't show "Apply" button */
+                NULL, /* cancel_handler,*/
+                NULL, /* gpointer user_data1,*/
+                NULL); /* gpointer user_data2,*/
 
         g_string_free(errors, TRUE);
     }
@@ -730,11 +750,22 @@ static iTunesDB *gp_merge_itdb(iTunesDB *old_itdb) {
     old_eitdb = old_itdb->userdata;
     g_return_val_if_fail (old_eitdb, NULL);
 
-    const gchar *mountpoint = itdb_get_mountpoint(old_itdb);
-    g_return_val_if_fail (mountpoint, NULL);
-    g_return_val_if_fail (old_eitdb->offline_filename, NULL);
+    if (old_itdb->usertype & GP_ITDB_TYPE_LOCAL) {
+        g_return_val_if_fail (old_itdb->filename, NULL);
+
+        new_itdb = gp_import_itdb(old_itdb, old_itdb->usertype, NULL, NULL, 
old_itdb->filename);
+    }
+    else if (old_itdb->usertype & GP_ITDB_TYPE_IPOD) {
+        const gchar *mountpoint = itdb_get_mountpoint(old_itdb);
+        g_return_val_if_fail (mountpoint, NULL);
+        g_return_val_if_fail (old_eitdb->offline_filename, NULL);
+
+        new_itdb = gp_import_itdb(old_itdb, old_itdb->usertype, mountpoint, 
old_eitdb->offline_filename, NULL);
+    }
+    else {
+        g_return_val_if_reached (NULL);
+    }
 
-    new_itdb = gp_import_itdb(old_itdb, old_itdb->usertype, mountpoint, 
old_eitdb->offline_filename);
     if (new_itdb) {
         gp_replace_itdb(old_itdb, new_itdb);
         /* take care of autosync... */
@@ -1213,6 +1244,7 @@ static gdouble set_progress(time_t start, gint n, gint 
count, gint init_count, g
                 = g_strdup_printf(_("%d%% (%d/%d  %d:%02d:%02d left)  %s"), 
(gint) (fraction * 100), count, n, (gint) hrs, (gint) mins, (gint) secs, msg);
     }
 
+
     gdouble ticks = fraction - old_fraction;
     gtkpod_statusbar_increment_progress_ticks(ticks * 100, progtext);
 
@@ -1478,8 +1510,8 @@ static gboolean transfer_tracks(iTunesDB *itdb, 
TransferData *td) {
             }
         }
 
-        td->current_progress = set_progress(start, to_convert_num + 
converting_num + to_transfer_num + failed_num
-                + transferred_num, transferred_num + failed_num, 
transferred_init, td->current_progress, buf);
+        td->current_progress = set_progress(start, to_convert_num + 
converting_num + to_transfer_num + failed_num + transferred_num, transferred_num
+                        + failed_num, transferred_init, td->current_progress, 
buf);
 
         if ((to_convert_num != 0) && (converting_num == 0)) { /* Force the 
conversion to continue. Not sure if this scenario
          * is likely to happen, but better be safe then sorry */
@@ -1633,17 +1665,7 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
         gp_track_cleanup_empty_strings((Itdb_Track *) it->data);
     }
 
-    const Itdb_IpodInfo *info;
-    if (success && !get_offline(itdb) && gp_itdb_has_mountpoint(itdb)) { /* 
write to the iPod */
-        g_warning("Supposed modelnum %s", itdb_device_get_sysinfo 
(itdb->device, "ModelNumStr"));
-        info = itdb_device_get_ipod_info (itdb->device);
-        g_warning("device info: %d %d", info->ipod_generation, 
info->ipod_model);
-
-        if (itdb_device_supports_artwork(itdb->device))
-            g_warning("Does support artwork");
-        else
-            g_warning("Does not support artwork");
-
+    if (success && !get_offline(itdb) && (itdb->usertype & GP_ITDB_TYPE_IPOD)) 
{ /* write to the iPod */
         GError *error = NULL;
         if (!itdb_write(itdb, &error)) { /* an error occurred */
             success = FALSE;
@@ -1655,11 +1677,7 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
             error = NULL;
         }
 
-        /*
-         * write shuffle data but only if an ipod since the local
-         * and podcast dbs definitely are not shuffles
-         */
-        if (success && (itdb->usertype & GP_ITDB_TYPE_IPOD)) {
+        if (success) { /* write shuffle data */
             if (!itdb_shuffle_write(itdb, &error)) { /* an error occurred */
                 success = FALSE;
                 if (error && error->message) {
@@ -1732,7 +1750,7 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
         }
     }
 
-    if (success && get_offline(itdb) && gp_itdb_has_mountpoint(itdb)) { /* 
write to cfgdir */
+    if (success && get_offline(itdb) && (itdb->usertype & GP_ITDB_TYPE_IPOD)) 
{ /* write to cfgdir */
         GError *error = NULL;
         if (!itdb_write_file(itdb, eitdb->offline_filename, &error)) { /* an 
error occurred */
             success = FALSE;
@@ -1748,6 +1766,22 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
         }
     }
 
+    if (success && (itdb->usertype & GP_ITDB_TYPE_LOCAL)) { /* write to cfgdir 
*/
+        GError *error = NULL;
+        if (!itdb_write_file(itdb, NULL, &error)) { /* an error occurred */
+            success = FALSE;
+            if (error && error->message)
+                gtkpod_warning("%s\n\n", error->message);
+                else
+                g_warning ("error->message == NULL!\n");
+            g_error_free(error);
+            error = NULL;
+        }
+        if (success) { /* write extended information */
+            success = write_extended_info(itdb);
+        }
+    }
+
     for (it = itdb->tracks; it != NULL; it = it->next) {
         gp_track_validate_entries((Itdb_Track *) it->data);
     }
@@ -1755,7 +1789,7 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
     /* If the ipod supports photos and the photo_data_changed
      * flag has been set to true then wrtie the photo database
      */
-    if (success && gp_itdb_has_mountpoint(itdb) && 
itdb_device_supports_photo(itdb->device) && eitdb->photodb
+    if (success && (itdb->usertype & GP_ITDB_TYPE_IPOD) && 
itdb_device_supports_photo(itdb->device) && eitdb->photodb
             != NULL && eitdb->photo_data_changed == TRUE) {
         GError *error = NULL;
         if (!itdb_photodb_write(eitdb->photodb, &error)) {
@@ -1773,7 +1807,12 @@ static gboolean gp_write_itdb(iTunesDB *itdb) {
     /* indicate that files and/or database is saved */
     if (success) {
         data_unchanged(itdb);
-        gtkpod_statusbar_message(_("%s: Changes saved"), mpl->name);
+        if (itdb->usertype & GP_ITDB_TYPE_IPOD) {
+            gtkpod_statusbar_message(_("%s: Database saved"), mpl->name);
+        }
+        else {
+            gtkpod_statusbar_message(_("%s: Changes saved"), mpl->name);
+        }
     }
 
     g_free(cfgdir);
diff --git a/libgtkpod/gp_itdb.c b/libgtkpod/gp_itdb.c
index 63ce111..b95847e 100644
--- a/libgtkpod/gp_itdb.c
+++ b/libgtkpod/gp_itdb.c
@@ -48,129 +48,10 @@
 #include "clientserver.h"
 #include "gtkpod_app_iface.h"
 
-#define CONVERT_ERR_MESSAGE "Failed to convert local itunes db from file to a 
directory."
-
 /* A struct containing a list with available iTunesDBs. A pointer to
  this struct is stored in gtkpod_app as itdbs_head */
 static struct itdbs_head *itdbs_head = NULL;
 
-static gchar *gp_convert_itdb_file_to_directory (gint index, gint itdb_type, 
gchar *filename) {
-
-    g_return_val_if_fail((itdb_type & GP_ITDB_TYPE_PODCASTS) || (itdb_type & 
GP_ITDB_TYPE_LOCAL), NULL);
-
-    GError *error = NULL;
-    gboolean result;
-
-    if (!filename) {
-        gchar *local = g_strdup_printf("local%d.itdb", index);
-        filename = g_build_filename(prefs_get_cfgdir(), local, NULL);
-        g_free(local);
-    }
-
-    g_message("Filename: %s", filename);
-
-    gchar *db_name_key = get_itdb_prefs_key(index, KEY_NAME);
-    gchar *db_name = prefs_get_string(db_name_key);
-    g_free(db_name_key);
-
-    if (! db_name) {
-        if (itdb_type & GP_ITDB_TYPE_PODCASTS)
-            db_name = g_strdup(_("Podcasts"));
-        else
-            db_name = g_strdup(_("Local"));
-    }
-
-    /* Determine the new mountpoint */
-    gchar *mountpoint = g_build_filename(prefs_get_cfgdir(), 
g_strdup_printf("%s_%d", g_utf8_strdown(db_name, -1), index), NULL);
-    while (g_file_test(mountpoint, G_FILE_TEST_EXISTS)) {
-        gchar *mp = g_strdup_printf("%s1", mountpoint);
-        g_free(mountpoint);
-        mountpoint = mp;
-    }
-
-    g_message("Chosen mountpoint: %s", mountpoint);
-
-    /* initialise a blank itdb in the mountpoint */
-    const Itdb_IpodInfo *info = itdb_info_get_ipod_info_table();
-    while(info->model_number) {
-        if (info->ipod_generation == ITDB_IPOD_GENERATION_CLASSIC_3) {
-            break;
-        }
-        ++info;
-    }
-
-    result = itdb_init_ipod(mountpoint, info->model_number, db_name, &error);
-    g_free(db_name);
-
-    if (!result) {
-        if (error) {
-            gtkpod_warning(_("%s : %s\n"), CONVERT_ERR_MESSAGE, 
error->message);
-            g_error_free(error);
-            error = NULL;
-        }
-        else {
-            gtkpod_warning(_("%s, unknown error initialising directory 
structure\n"), CONVERT_ERR_MESSAGE);
-        }
-        g_free(mountpoint);
-        return NULL;
-    }
-
-    /* Copy in the itdb file to replace the blank itdb */
-    gchar *itunesdb = itdb_get_itunesdb_path(mountpoint);
-    GFile *oldfile = g_file_new_for_path(filename);
-    GFile *newfile = g_file_new_for_path(itunesdb);
-    g_free(itunesdb);
-
-    result = g_file_copy(oldfile, newfile, G_FILE_COPY_OVERWRITE, NULL, NULL, 
NULL, &error);
-    g_object_unref(oldfile);
-    g_object_unref(newfile);
-
-    if (!result) {
-        if (error) {
-            gtkpod_warning(_("%s : %s\n"), CONVERT_ERR_MESSAGE, 
error->message);
-            g_error_free(error);
-            error = NULL;
-        }
-        else {
-            gtkpod_warning(_("%s, unknown error copying in existing itdb.\n"), 
CONVERT_ERR_MESSAGE);
-        }
-        g_free(mountpoint);
-        return NULL;
-    }
-
-    /* Copy in the itdb ext */
-    gchar *oldextfilename = g_strdup_printf("%s.ext", filename);
-    gchar *newextfilename = g_strdup_printf("%s.ext", 
itdb_get_itunesdb_path(mountpoint));
-    oldfile = g_file_new_for_path(oldextfilename);
-    newfile = g_file_new_for_path(newextfilename);
-    g_free(oldextfilename);
-    g_free(newextfilename);
-
-    result = g_file_copy(oldfile, newfile, G_FILE_COPY_OVERWRITE, NULL, NULL, 
NULL, &error);
-    g_object_unref(oldfile);
-    g_object_unref(newfile);
-
-    if (!result) {
-        if (error) {
-            gtkpod_warning(_("%s : %s\n"), CONVERT_ERR_MESSAGE, 
error->message);
-            g_error_free(error);
-            error = NULL;
-        }
-        else {
-            gtkpod_warning(_("%s, unknown error copying in existing itdb ext 
file.\n"), CONVERT_ERR_MESSAGE);
-        }
-        g_free(mountpoint);
-        return NULL;
-    }
-
-    /* Successfully created new itdb */
-
-    /* Update preferences of this itdb */
-    set_itdb_index_prefs_string(index, KEY_MOUNTPOINT, mountpoint);
-
-    return mountpoint;
-}
-
 /* for convenience */
 struct itdbs_head *gp_get_itdbs_head() {
     g_return_val_if_fail(gtkpod_app, NULL);
@@ -305,10 +186,6 @@ void gp_itdb_add_extra_full(iTunesDB *itdb) {
     }
 }
 
-gboolean gp_itdb_has_mountpoint(iTunesDB *itdb) {
-    return itdb_get_mountpoint(itdb) != NULL;
-}
-
 Playlist *gp_playlist_new(const gchar *title, gboolean spl) {
     Playlist *pl = itdb_playlist_new(title, spl);
     pl->userdata = g_new0 (ExtraPlaylistData, 1);
@@ -982,7 +859,7 @@ void gp_init_itdbs() {
  system. */
 iTunesDB *setup_itdb_n(gint i) {
     iTunesDB *itdb = NULL;
-    gchar *property = get_itdb_prefs_key(i, KEY_TYPE);
+    gchar *property = get_itdb_prefs_key(i, "type");
     gint type;
     gboolean valid = prefs_get_int_value(property, &type);
     g_free(property);
@@ -991,36 +868,33 @@ iTunesDB *setup_itdb_n(gint i) {
         Playlist *pl = NULL;
         ExtraiTunesDBData *eitdb;
         gchar *filename = NULL;
-        gchar *offline_filename = NULL;
         gchar *mountpoint = NULL;
+        gchar *offline_filename = NULL;
 
-        /* Read filename from preferences */
-        gchar *filename_key = get_itdb_prefs_key(i, KEY_FILENAME);
-        if (filename_key) {
-            filename = prefs_get_string(filename_key);
-        }
-        g_free(filename_key);
+        if (type & GP_ITDB_TYPE_LOCAL) {
+            gchar *fn = get_itdb_prefs_key(i, "filename");
 
-        /* Read mountpoint from preferences */
-        gchar *mountpoint_key = get_itdb_prefs_key(i, KEY_MOUNTPOINT);
-        if (mountpoint_key) {
-            mountpoint = prefs_get_string(mountpoint_key);
-        }
-        g_free(mountpoint_key);
+            filename = prefs_get_string(fn);
 
-        if (type & GP_ITDB_TYPE_LOCAL) {
-            if (!mountpoint) {
-                /* This is the old style itdb file */
-                g_warning("Deprecated file structure ... Converting local 
itdb");
-                mountpoint = gp_convert_itdb_file_to_directory(i, type, 
filename);
+            if (!filename) {
+                gchar *local = g_strdup_printf("local%d.itdb", i);
+                filename = g_build_filename(cfgdir, local, NULL);
+                g_free(local);
             }
-
-            if (g_file_test(mountpoint, G_FILE_TEST_EXISTS))
-                itdb = gp_import_itdb(NULL, type, mountpoint, filename);
+            g_free(fn);
+            if (g_file_test(filename, G_FILE_TEST_EXISTS))
+                itdb = gp_import_itdb(NULL, type, NULL, NULL, filename);
         }
         else if (type & GP_ITDB_TYPE_IPOD) {
-            offline_filename = filename;
-            filename = NULL;
+            gchar *key;
+
+            key = get_itdb_prefs_key(i, KEY_MOUNTPOINT);
+            mountpoint = prefs_get_string(key);
+            g_free(key);
+
+            key = get_itdb_prefs_key(i, "filename");
+            offline_filename = prefs_get_string(key);
+            g_free(key);
 
             if (!offline_filename) {
                 gchar *local = g_strdup_printf("gtkpod_%d.itdb", i);
diff --git a/libgtkpod/gp_itdb.h b/libgtkpod/gp_itdb.h
index a56e9cc..74e6b71 100644
--- a/libgtkpod/gp_itdb.h
+++ b/libgtkpod/gp_itdb.h
@@ -134,7 +134,6 @@ void gp_itdb_free (iTunesDB *itdb);
 void gp_replace_itdb (iTunesDB *old_itdb, iTunesDB *new_itdb);
 void gp_itdb_add_extra (iTunesDB *itdb);
 void gp_itdb_add_extra_full (iTunesDB *itdb);
-gboolean gp_itdb_has_mountpoint(iTunesDB *itdb);
 
 Track *gp_track_new (void);
 #define gp_track_free itdb_track_free
diff --git a/libgtkpod/prefs.c b/libgtkpod/prefs.c
index 15c8abc..249d71d 100644
--- a/libgtkpod/prefs.c
+++ b/libgtkpod/prefs.c
@@ -73,8 +73,6 @@ const gchar *KEY_MOUNTPOINT = "mountpoint";
 const gchar *KEY_BACKUP = "filename";
 const gchar *KEY_IPOD_MODEL = "ipod_model";
 const gchar *KEY_FILENAME = "filename";
-const gchar *KEY_TYPE = "type";
-const gchar *KEY_NAME = "name";
 const gchar *KEY_PATH_SYNC_CONTACTS = "path_sync_contacts";
 const gchar *KEY_PATH_SYNC_CALENDAR = "path_sync_calendar";
 const gchar *KEY_PATH_SYNC_NOTES = "path_sync_notes";
diff --git a/libgtkpod/prefs.h b/libgtkpod/prefs.h
index 212d46a..585f721 100644
--- a/libgtkpod/prefs.h
+++ b/libgtkpod/prefs.h
@@ -53,8 +53,6 @@ extern const gchar *KEY_SYNC_SHOW_SUMMARY;
 extern const gchar *KEY_MOUNTPOINT;
 extern const gchar *KEY_IPOD_MODEL;
 extern const gchar *KEY_FILENAME;
-extern const gchar *KEY_TYPE;
-extern const gchar *KEY_NAME;
 extern const gchar *KEY_PATH_SYNC_CONTACTS;
 extern const gchar *KEY_PATH_SYNC_CALENDAR;
 extern const gchar *KEY_PATH_SYNC_NOTES;
diff --git a/plugins/repository_editor/repository_init.c 
b/plugins/repository_editor/repository_init.c
index 901d458..ed69c89 100644
--- a/plugins/repository_editor/repository_init.c
+++ b/plugins/repository_editor/repository_init.c
@@ -177,7 +177,7 @@ gboolean repository_ipod_init(iTunesDB *itdb) {
         model = gtk_combo_box_get_active_text(GTK_COMBO_BOX (GET_WIDGET 
(ii->builder, IID_MODEL_COMBO)));
         if ((strcmp(model, gettext(SELECT_OR_ENTER_YOUR_MODEL)) == 0) || 
(strlen(model) == 0)) { /* User didn't choose a model */
             g_free(model);
-            model = "Unknown";
+            model = NULL;
         }
 
         /* Set model in the prefs system */

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to