commit 13172a776e5f3a821e07e278ea5ac85616e5efec
Author: phantomjinx <p.g.richard...@phantomjinx.co.uk>
Date:   Sun Jan 30 22:15:41 2011 +0000

    Fix some conversion issues
    
    * configure.ac
    * *m4a/Makefile.am
     * Check for faad dependency, warn if not installed
     * Only if faad installed is m4a file type plugin available
    
    * prefs
     * Fix the preferences path_conv_* in order to work more sanely.
     * mp3, m4a and mp4 paths are maintained and other checks made to determine
       whether files will be converted by them or not.
    
    * scripts/*
     * Improve logging so that a consistent log file is generated in the
       conversion cache
    
    * file_itunesdb.c
     * Ensure that extra status messages are still displayed while progress
       is ongoing.

 configure.ac                          |   20 ++++++++++
 libgtkpod/file_itunesdb.c             |   19 ++++-----
 libgtkpod/prefs.c                     |   67 ++++++++++----------------------
 libgtkpod/prefs.h                     |    4 ++
 plugins/core_preferences/core_prefs.c |   44 +++++++++++----------
 plugins/filetype_flac/plugin.c        |   13 ++++++
 plugins/filetype_m4a/Makefile.am      |    2 +
 plugins/filetype_m4a/m4afile.c        |   19 ++++++---
 plugins/filetype_m4a/plugin.c         |    8 ++-
 plugins/filetype_mp3/mp3file.c        |   11 +++++-
 plugins/filetype_ogg/plugin.c         |   12 ++++++
 plugins/filetype_video/videofile.c    |    2 +-
 plugins/filetype_wav/plugin.c         |   12 ++++++
 scripts/convert-2m4a.sh               |    5 --
 scripts/convert-2mp3.sh               |    3 -
 scripts/convert-2mp4.sh               |    5 +--
 scripts/gtkpod-convert-common.sh      |   11 +++--
 17 files changed, 153 insertions(+), 104 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1782f5d..002ceee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -269,6 +269,26 @@ if test "x$have_flac" = "xyes"; then
 fi
 AM_CONDITIONAL(HAVE_FLAC, test "x$have_flac" = "xyes")
 
+dnl Check for FAAD for use with m4a files
+AC_ARG_WITH(faad, AS_HELP_STRING([--without-faad],[Disable M4A -> MP3 
coversion support]))
+if test "x$with_faad" != "xno"; then
+       AC_CHECK_PROG(FAAD, faad, yes, no)
+       if test "x$FAAD" = "xyes"; then
+               have_faad="yes"
+       else
+        have_faad="no"
+        AC_MSG_WARN(["Cannot find faad. Conversion from m4a to mp3 not 
possible"])
+    fi
+    if test "xwith_faad" = "xyes" -a "x$have_faad" = "xno"; then
+        AC_MSG_ERROR([FAAD support explicitly requested but not available])
+    fi
+fi
+
+if test "x$have_faad" = "xyes"; then
+    AC_DEFINE(HAVE_FAAD, 1, [Define if you have the faad binary])
+fi
+AM_CONDITIONAL(HAVE_FAAD, test "x$have_faad" = "xyes")
+
 dnl Check for MP4 Headers
 AC_CHECK_HEADERS([mp4v2/platform.h], have_mp4=yes, have_mp4=no)
 AC_CHECK_HEADERS([mp4v2/itmf_tags.h], [], [],
diff --git a/libgtkpod/file_itunesdb.c b/libgtkpod/file_itunesdb.c
index 56e0d6e..29e7445 100644
--- a/libgtkpod/file_itunesdb.c
+++ b/libgtkpod/file_itunesdb.c
@@ -1196,7 +1196,7 @@ static gboolean ipod_dirs_present(const gchar 
*mountpoint) {
     return result;
 }
 
-static gdouble set_progress(time_t start, gint n, gint count, gint init_count, 
gdouble old_fraction) {
+static gdouble set_progress(time_t start, gint n, gint count, gint init_count, 
gdouble old_fraction, gchar *msg) {
     gchar *progtext;
     gdouble fraction;
 
@@ -1208,7 +1208,7 @@ static gdouble set_progress(time_t start, gint n, gint 
count, gint init_count, g
     }
 
     if (count - init_count == 0) {
-        progtext = g_strdup_printf(_("%d%%"), (gint) (fraction * 100));
+        progtext = g_strdup_printf(_("%d%%  %s"), (gint) (fraction * 100), 
msg);
     }
     else {
         time_t diff, fullsecs, hrs, mins, secs;
@@ -1219,7 +1219,7 @@ static gdouble set_progress(time_t start, gint n, gint 
count, gint init_count, g
         mins = (fullsecs % 3600) / 60;
         secs = ((fullsecs % 60) / 5) * 5;
         progtext
-                = g_strdup_printf(_("%d%% (%d/%d  %d:%02d:%02d left)"), (gint) 
(fraction * 100), count, n, (gint) hrs, (gint) mins, (gint) secs);
+                = g_strdup_printf(_("%d%% (%d/%d  %d:%02d:%02d left)  %s"), 
(gint) (fraction * 100), count, n, (gint) hrs, (gint) mins, (gint) secs, msg);
     }
 
 
@@ -1298,7 +1298,7 @@ static gboolean delete_files(iTunesDB *itdb, TransferData 
*td) {
             do {
                 GTimeVal gtime;
 
-                td->current_progress = set_progress(start, n, count, 0, 
td->current_progress);
+                td->current_progress = set_progress(start, n, count, 0, 
td->current_progress, "deletion completed");
 
                 g_mutex_unlock (td->mutex);
 
@@ -1333,7 +1333,7 @@ static gboolean delete_files(iTunesDB *itdb, TransferData 
*td) {
         eitdb->pending_deletion = g_list_delete_link(eitdb->pending_deletion, 
eitdb->pending_deletion);
     }
 
-    td->current_progress = set_progress(start, n, count, 0, 
td->current_progress);
+    td->current_progress = set_progress(start, n, count, 0, 
td->current_progress, "deletion completed");
 
     while (widgets_blocked && gtk_events_pending())
         gtk_main_iteration();
@@ -1477,20 +1477,19 @@ static gboolean transfer_tracks(iTunesDB *itdb, 
TransferData *td) {
                 = file_transfer_get_status(itdb, &to_convert_num, 
&converting_num, &to_transfer_num, &transferred_num, &failed_num);
 
         if (to_transfer_num > 0) {
-            buf = g_strdup_printf(_("Status: Copying track"));
+            buf = g_strdup_printf(_("Copying track"));
         }
         else {
             if ((to_convert_num + converting_num) > 0) {
-                buf = g_strdup_printf(_("Status: Waiting for conversion to 
complete"));
+                buf = g_strdup_printf(_("Waiting for conversion to complete"));
             }
             else {
-                buf = g_strdup_printf(_("Status: Finished transfer"));
+                buf = g_strdup_printf(_("Finished transfer"));
             }
         }
 
-        gtkpod_statusbar_message(buf);
         td->current_progress = set_progress(start, to_convert_num + 
to_transfer_num + failed_num + transferred_num, transferred_num
-                        + failed_num, transferred_init, td->current_progress);
+                        + 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 */
diff --git a/libgtkpod/prefs.c b/libgtkpod/prefs.c
index 6b48b21..72d6e49 100644
--- a/libgtkpod/prefs.c
+++ b/libgtkpod/prefs.c
@@ -173,23 +173,17 @@ static void set_default_preferences() {
     prefs_set_int("delete_database", TRUE);
     prefs_set_string("initial_mountpoint", "/media/ipod");
 
-    str = g_build_filename(get_script_dir(), "convert-2mp3.sh", NULL);
-    prefs_set_string("path_conv_ogg", str);
+    str = g_build_filename(get_script_dir(), CONVERT_TO_MP3_SCRIPT, NULL);
+    prefs_set_string("path_conv_mp3", str);
     g_free(str);
 
-    str = g_build_filename(get_script_dir(), "convert-2mp3.sh", NULL);
-    prefs_set_string("path_conv_flac", str);
+    str = g_build_filename(get_script_dir(), CONVERT_TO_M4A_SCRIPT, NULL);
+    prefs_set_string("path_conv_m4a", str);
     g_free(str);
 
-    str = g_build_filename(get_script_dir(), "convert-2mp3.sh", NULL);
-    prefs_set_string("path_conv_wav", str);
-    g_free(str);
-    prefs_set_int("convert_wav", FALSE);
-
-    str = g_build_filename(get_script_dir(), "convert-2mp4.sh", NULL);
+    str = g_build_filename(get_script_dir(), CONVERT_TO_MP4_SCRIPT, NULL);
     prefs_set_string("path_conv_mp4", str);
     g_free(str);
-    prefs_set_int("convert_mp4", TRUE);
 
     /* Set colum preferences */
     for (i = 0; i < TM_NUM_COLUMNS; i++) {
@@ -766,6 +760,20 @@ static void cleanup_keys() {
         prefs_set_string("md5", NULL);
     }
 
+    /* Conversion Paths */
+    gchar *str;
+    str = g_build_filename(get_script_dir(), CONVERT_TO_MP3_SCRIPT, NULL);
+    prefs_set_string("path_conv_mp3", str);
+    g_free(str);
+
+    str = g_build_filename(get_script_dir(), CONVERT_TO_M4A_SCRIPT, NULL);
+    prefs_set_string("path_conv_m4a", str);
+    g_free(str);
+
+    str = g_build_filename(get_script_dir(), CONVERT_TO_MP4_SCRIPT, NULL);
+    prefs_set_string("path_conv_mp4", str);
+    g_free(str);
+
     /* MP3 Gain */
     if (prefs_get_string_value_index("path", PATH_MP3GAIN, &buf)) {
         prefs_set_string("path_mp3gain", buf);
@@ -877,40 +885,6 @@ static void cleanup_keys() {
     if (version < 0.91)
         prefs_flush_subkey("itdb_");
 
-    /* rename convert scripts */
-    if (version <= 0.99001) {
-
-        const gchar **keyp;
-        const gchar *keys[] =
-            { "path_conv_m4a", "path_conv_wav", "path_conv_mp3", 
"path_conv_ogg", "path_conv_flac", "path_conv_mp4", NULL };
-
-        for (keyp = keys; *keyp; ++keyp) {
-            buf = prefs_get_string(*keyp);
-            if (buf) {
-                const gchar *needles[] =
-                    {
-                        "convert-flac2mp3.sh", "convert-m4a2mp3.sh", 
"convert-ogg2mp3.sh", "convert-wav2mp3.sh",
-                        "convert-flac2m4a.sh", "convert-m4a2m4a.sh", 
"convert-ogg2m4a.sh", "convert-wav2m4a.sh", NULL };
-                const gchar *replacements[] =
-                    {
-                        "convert-2mp3.sh    ", "convert-2mp3.sh   ", 
"convert-2mp3.sh   ", "convert-2mp3.sh   ",
-                        "convert-2m4a.sh    ", "convert-2m4a.sh   ", 
"convert-2m4a.sh   ", "convert-2m4a.sh   " };
-                const gchar **needlep;
-                const gchar **replp;
-                replp = replacements;
-                for (needlep = needles; *needlep; ++needlep, ++replp) {
-                    gchar *bufp = strstr(buf, *needlep);
-                    if (bufp) {
-                        g_memmove (bufp, *replp, strlen (*replp));
-                        prefs_set_string(*keyp, buf);
-                        break;
-                    }
-                }
-                g_free(buf);
-            }
-        }
-    }
-
     prefs_set_string("version", VERSION);
 }
 
@@ -1836,7 +1810,8 @@ GList *prefs_get_list(const gchar *key) {
             }
         }
         i++;
-    } while(item_string != NULL && item_hash != end_marker_hash);
+    }
+    while (item_string != NULL && item_hash != end_marker_hash);
 
     return list;
 }
diff --git a/libgtkpod/prefs.h b/libgtkpod/prefs.h
index beb7c6b..585f721 100644
--- a/libgtkpod/prefs.h
+++ b/libgtkpod/prefs.h
@@ -39,6 +39,10 @@
 /* End-of-list marker for variable-length lists */
 #define LIST_END_MARKER "----++++----"
 
+#define CONVERT_TO_MP3_SCRIPT "convert-2mp3.sh"
+#define CONVERT_TO_M4A_SCRIPT "convert-2m4a.sh"
+#define CONVERT_TO_MP4_SCRIPT "convert-2mp4.sh"
+
 /* Not sure where to put these (maybe prefkeys.h?): prefs keys used */
 /* repository.c */
 extern const gchar *KEY_CONCAL_AUTOSYNC;
diff --git a/plugins/core_preferences/core_prefs.c 
b/plugins/core_preferences/core_prefs.c
index cf8e2b8..530cfdd 100644
--- a/plugins/core_preferences/core_prefs.c
+++ b/plugins/core_preferences/core_prefs.c
@@ -93,7 +93,6 @@ const gchar *conv_checkbox_map[][3] =
         { "convert_mp3", "convert_mp3", NULL },
         { "convert_aac", "convert_m4a", NULL },
         { "convert_wav", "convert_wav", NULL },
-        { "convert_mp4", "convert_mp4", NULL },
         { "display_conversion_log", "", NULL }, };
 
 ind_string tag_checkbox_map[] =
@@ -104,17 +103,15 @@ ind_string tag_checkbox_map[] =
         { 3, "tag_genre" },
         { 4, "tag_composer" }, };
 
-const gchar *conv_scripts[] =
-    { "convert-2mp3.sh", "convert-2m4a.sh", };
+const gchar *conv_audio_scripts[] =
+    { CONVERT_TO_MP3_SCRIPT, CONVERT_TO_M4A_SCRIPT };
 
-ind_string conv_paths[] =
+gchar *modifiable_conv_paths[] =
     {
-        { -1, "path_conv_ogg" },
-        { -1, "path_conv_flac" },
-        { TARGET_FORMAT_AAC, "path_conv_m4a" },
-        { TARGET_FORMAT_MP3, "path_conv_mp3" },
-        { -1, "path_conv_wav" },
-        { -1, "path_conv_mp4" } };
+        "path_conv_ogg",
+        "path_conv_flac",
+        "path_conv_wav"
+    };
 
 static TempPrefs *temp_prefs = NULL;
 static GtkBuilder* builder = NULL;
@@ -528,6 +525,19 @@ G_MODULE_EXPORT void 
on_conversion_settings_clicked(GtkButton *sender, gpointer
         init_checkbox(GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, 
conv_checkbox_map[i][0])), conv_checkbox_map[i][1], conv_checkbox_map[i][2]);
     }
 
+    GtkWidget *mp3toggle = GTK_WIDGET (gtk_builder_get_object(builder, 
conv_checkbox_map[0][0]));
+    GtkWidget *m4atoggle = GTK_WIDGET (gtk_builder_get_object(builder, 
conv_checkbox_map[1][0]));
+
+    if (prefs_get_int("conversion_target_format") == TARGET_FORMAT_MP3) {
+        /* No point converting an mp3 to an mp3! */
+        gtk_widget_set_sensitive(mp3toggle, FALSE);
+        gtk_widget_set_sensitive(m4atoggle, TRUE);
+    } else if (prefs_get_int("conversion_target_format") == TARGET_FORMAT_AAC) 
{
+        /* No point converting an m4a to an m4a! */
+        gtk_widget_set_sensitive(mp3toggle, TRUE);
+        gtk_widget_set_sensitive(m4atoggle, FALSE);
+    }
+
     gtk_builder_connect_signals(builder, NULL);
     gtk_dialog_run(GTK_DIALOG (dlg));
     gtk_widget_hide(dlg);
@@ -560,19 +570,11 @@ G_MODULE_EXPORT void 
on_cache_size_value_changed(GtkSpinButton *sender, gpointer
  */
 G_MODULE_EXPORT void on_target_format_changed(GtkComboBox *sender, gpointer e) 
{
     gint index = gtk_combo_box_get_active(sender);
-    gchar *script = g_build_filename(get_script_dir(), conv_scripts[index], 
NULL);
+    gchar *script = g_build_filename(get_script_dir(), 
conv_audio_scripts[index], NULL);
     gint i;
 
-    for (i = 0; i < COUNTOF (conv_paths); i++) {
-        if (conv_paths[i].index == index) {
-            /*
-             The source format is the same as the target format -
-             we set "null conversion" without touching the boolean preference
-             */
-            prefs_set_string(conv_paths[i].string, "");
-        }
-        else
-            prefs_set_string(conv_paths[i].string, script);
+    for (i = 0; i < COUNTOF (modifiable_conv_paths); i++) {
+        prefs_set_string(modifiable_conv_paths[i], script);
     }
 
     prefs_set_int("conversion_target_format", index);
diff --git a/plugins/filetype_flac/plugin.c b/plugins/filetype_flac/plugin.c
index ebb9bd7..4daa299 100644
--- a/plugins/filetype_flac/plugin.c
+++ b/plugins/filetype_flac/plugin.c
@@ -33,12 +33,22 @@
 #include <glib.h>
 #include "libgtkpod/gtkpod_app_iface.h"
 #include "libgtkpod/filetype_iface.h"
+#include "libgtkpod/prefs.h"
+#include "libgtkpod/directories.h"
 #include "plugin.h"
 #include "flacfile.h"
 
 /* Parent class. Part of standard class definition */
 static gpointer parent_class;
 
+static void set_default_preferences() {
+    if (! prefs_get_string_value("path_conv_flac", NULL)) {
+        gchar *str = g_build_filename(get_script_dir(), CONVERT_TO_MP3_SCRIPT, 
NULL);
+        prefs_set_string("path_conv_flac", str);
+        g_free(str);
+    }
+}
+
 static gboolean activate_plugin(AnjutaPlugin *plugin) {
     FlacFileTypePlugin *flac_filetype_plugin;
 
@@ -47,6 +57,9 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
 
     gtkpod_register_filetype(FILE_TYPE(flac_filetype_plugin));
 
+    /* Set preferences */
+    set_default_preferences();
+
     return TRUE; /* FALSE if activation failed */
 }
 
diff --git a/plugins/filetype_m4a/Makefile.am b/plugins/filetype_m4a/Makefile.am
index 86fe828..249f81b 100644
--- a/plugins/filetype_m4a/Makefile.am
+++ b/plugins/filetype_m4a/Makefile.am
@@ -20,6 +20,7 @@ filetype_m4a_plugin_DATA =
 SUBDIRS =
 
 if HAVE_MP4
+if HAVE_FAAD
 
 include ../plugins.mk
 filetype_m4a.plugin: build-plugin-file
@@ -41,6 +42,7 @@ libfiletype_m4a_la_LIBADD = \
     $(LIBANJUTA_LIBS)
 
 endif
+endif
 
 EXTRA_DIST = \
        $(plugin_file).in \
diff --git a/plugins/filetype_m4a/m4afile.c b/plugins/filetype_m4a/m4afile.c
index 4e8eed2..6a5d958 100644
--- a/plugins/filetype_m4a/m4afile.c
+++ b/plugins/filetype_m4a/m4afile.c
@@ -39,7 +39,6 @@
 
 /* Info on how to implement new file formats: see mp3file.c for more info */
 
-
 Track *m4a_get_file_info(const gchar *m4aFileName) {
     gchar *path_utf8;
     gchar *suf;
@@ -57,23 +56,31 @@ Track *m4a_get_file_info(const gchar *m4aFileName) {
     return track;
 }
 
-gboolean m4a_write_file_info (const gchar *filename, Track *track) {
+gboolean m4a_write_file_info(const gchar *filename, Track *track) {
     return mp4_write_file_info(filename, track);
 }
 
-gboolean m4a_read_soundcheck (const gchar *filename, Track *track) {
+gboolean m4a_read_soundcheck(const gchar *filename, Track *track) {
     return mp4_read_soundcheck(filename, track);
 }
 
 gboolean m4a_can_convert() {
     gchar *cmd = m4a_get_conversion_cmd();
-    return cmd && cmd[0] && prefs_get_int("convert_m4a");
+    /*
+     * Return TRUE if
+     * Command exists and fully formed
+     * Target format is NOT set to AAC
+     * convert_m4a preference is set to TRUE
+     */
+    return cmd && cmd[0] && (prefs_get_int("conversion_target_format") != 
TARGET_FORMAT_AAC)
+            && prefs_get_int("convert_m4a");
 }
 
 gchar *m4a_get_conversion_cmd() {
-    return prefs_get_string("path_conv_m4a");
+    /* Convert an m4a to an mp3 */
+    return prefs_get_string("path_conv_mp3");
 }
 
 gchar *m4a_get_gain_cmd() {
-    return prefs_get_string ("path_aacgain");
+    return prefs_get_string("path_aacgain");
 }
diff --git a/plugins/filetype_m4a/plugin.c b/plugins/filetype_m4a/plugin.c
index 72011c9..ae4768a 100644
--- a/plugins/filetype_m4a/plugin.c
+++ b/plugins/filetype_m4a/plugin.c
@@ -33,6 +33,8 @@
 #include <glib.h>
 #include "libgtkpod/gtkpod_app_iface.h"
 #include "libgtkpod/filetype_iface.h"
+#include "libgtkpod/prefs.h"
+#include "libgtkpod/directories.h"
 #include "plugin.h"
 #include "m4afile.h"
 
@@ -61,7 +63,7 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) {
 }
 
 static void m4a_filetype_plugin_instance_init(GObject *obj) {
-//    M4AFileTypePlugin *plugin = (M4AFileTypePlugin*) obj;
+    //    M4AFileTypePlugin *plugin = (M4AFileTypePlugin*) obj;
 }
 
 static void m4a_filetype_plugin_class_init(GObjectClass *klass) {
@@ -93,8 +95,8 @@ static void m4a_filetype_iface_init(FileTypeInterface *iface) 
{
 }
 
 ANJUTA_PLUGIN_BEGIN (M4AFileTypePlugin, m4a_filetype_plugin);
-ANJUTA_PLUGIN_ADD_INTERFACE(m4a_filetype, FILE_TYPE_TYPE);
-ANJUTA_PLUGIN_END;
+        ANJUTA_PLUGIN_ADD_INTERFACE(m4a_filetype, 
FILE_TYPE_TYPE);ANJUTA_PLUGIN_END
+;
 
 ANJUTA_SIMPLE_PLUGIN (M4AFileTypePlugin, m4a_filetype_plugin)
 ;
diff --git a/plugins/filetype_mp3/mp3file.c b/plugins/filetype_mp3/mp3file.c
index c74c575..3b5ef9a 100644
--- a/plugins/filetype_mp3/mp3file.c
+++ b/plugins/filetype_mp3/mp3file.c
@@ -2905,11 +2905,20 @@ gboolean id3_lyrics_save(const gchar *filename, const 
gchar *lyrics) {
 
 gboolean mp3_can_convert() {
     gchar *cmd = mp3_get_conversion_cmd();
+    /*
+     * Return TRUE if
+     * Command exists and fully formed
+     * Target format is NOT set to MP3
+     * convert_mp3 preference is set to TRUE
+     */
+    return cmd && cmd[0] && (prefs_get_int("conversion_target_format") != 
TARGET_FORMAT_MP3)
+                && prefs_get_int("convert_mp3");
     return cmd && cmd[0] && prefs_get_int("convert_mp3");
 }
 
 gchar *mp3_get_conversion_cmd() {
-    return prefs_get_string("path_conv_mp3");
+    /* Convert an mp3 to an m4a */
+    return prefs_get_string("path_conv_m4a");
 }
 
 gchar *mp3_get_gain_cmd() {
diff --git a/plugins/filetype_ogg/plugin.c b/plugins/filetype_ogg/plugin.c
index 715a3d1..b6b69e6 100644
--- a/plugins/filetype_ogg/plugin.c
+++ b/plugins/filetype_ogg/plugin.c
@@ -33,12 +33,22 @@
 #include <glib.h>
 #include "libgtkpod/gtkpod_app_iface.h"
 #include "libgtkpod/filetype_iface.h"
+#include "libgtkpod/prefs.h"
+#include "libgtkpod/directories.h"
 #include "plugin.h"
 #include "oggfile.h"
 
 /* Parent class. Part of standard class definition */
 static gpointer parent_class;
 
+static void set_default_preferences() {
+    if (! prefs_get_string_value("path_conv_ogg", NULL)) {
+        gchar *str = g_build_filename(get_script_dir(), CONVERT_TO_MP3_SCRIPT, 
NULL);
+        prefs_set_string("path_conv_ogg", str);
+        g_free(str);
+    }
+}
+
 static gboolean activate_plugin(AnjutaPlugin *plugin) {
     OGGFileTypePlugin *ogg_filetype_plugin;
 
@@ -47,6 +57,8 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
 
     gtkpod_register_filetype(FILE_TYPE(ogg_filetype_plugin));
 
+    set_default_preferences();
+
     return TRUE; /* FALSE if activation failed */
 }
 
diff --git a/plugins/filetype_video/videofile.c 
b/plugins/filetype_video/videofile.c
index a3fcc65..db73a4f 100644
--- a/plugins/filetype_video/videofile.c
+++ b/plugins/filetype_video/videofile.c
@@ -51,7 +51,7 @@ Track *video_get_file_info(const gchar *filename) {
 
 gboolean video_can_convert() {
     gchar *cmd = video_get_conversion_cmd();
-    return cmd && cmd[0] && prefs_get_int("convert_mp4");
+    return cmd && cmd[0];
 }
 
 gchar *video_get_conversion_cmd() {
diff --git a/plugins/filetype_wav/plugin.c b/plugins/filetype_wav/plugin.c
index fae18c3..68f5ed2 100644
--- a/plugins/filetype_wav/plugin.c
+++ b/plugins/filetype_wav/plugin.c
@@ -33,12 +33,22 @@
 #include <glib.h>
 #include "libgtkpod/gtkpod_app_iface.h"
 #include "libgtkpod/filetype_iface.h"
+#include "libgtkpod/directories.h"
+#include "libgtkpod/prefs.h"
 #include "plugin.h"
 #include "wavfile.h"
 
 /* Parent class. Part of standard class definition */
 static gpointer parent_class;
 
+static void set_default_preferences() {
+    if (! prefs_get_string_value("path_conv_wav", NULL)) {
+        gchar *str = g_build_filename(get_script_dir(), CONVERT_TO_MP3_SCRIPT, 
NULL);
+        prefs_set_string("path_conv_wav", str);
+        g_free(str);
+    }
+}
+
 static gboolean activate_plugin(AnjutaPlugin *plugin) {
     WavFileTypePlugin *wav_filetype_plugin;
 
@@ -47,6 +57,8 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
 
     gtkpod_register_filetype(FILE_TYPE(wav_filetype_plugin));
 
+    set_default_preferences();
+
     return TRUE; /* FALSE if activation failed */
 }
 
diff --git a/scripts/convert-2m4a.sh b/scripts/convert-2m4a.sh
index 6b132b3..9f0394a 100755
--- a/scripts/convert-2m4a.sh
+++ b/scripts/convert-2m4a.sh
@@ -29,11 +29,6 @@ ENCODER="faac"
 
 . ${0%/*}/gtkpod-convert-common.sh
 
-LOG=`dirname "$outfile"`
-LOG=${LOG%.log}
-
-echo "Attempting to convert file" >> $LOG
-
 if [ $filetype = "wav" ]; then
     "$encoder" -o "$outfile" $ENCODER_OPTS -w --artist "$artist" --title 
"$title" --year "$year" --album "$album" --track "$track" --genre "$genre" 
--comment "$comment" "$infile" >> $LOG 2>&1
 else
diff --git a/scripts/convert-2mp3.sh b/scripts/convert-2mp3.sh
index 0bfc2c0..63b1250 100755
--- a/scripts/convert-2mp3.sh
+++ b/scripts/convert-2mp3.sh
@@ -26,9 +26,6 @@ ENCODER="lame"
 
 . ${0%/*}/gtkpod-convert-common.sh
 
-LOG=`dirname "$outfile"`
-LOG=${LOG%.log}
-
 # Check if the genre is one which lame supports
 if [ -n "$genre" ] && `"$encoder" --genre-list 2>&1 | cut -c 5- | grep -qi 
"^$genre$"`; then
     usegenre=$genre
diff --git a/scripts/convert-2mp4.sh b/scripts/convert-2mp4.sh
index 97c4b83..5ddd6d7 100755
--- a/scripts/convert-2mp4.sh
+++ b/scripts/convert-2mp4.sh
@@ -26,10 +26,7 @@ ENCODER="ffmpeg"
 
 . ${0%/*}/gtkpod-convert-common.sh
 
-LOG=`dirname "$outfile"`
-LOG=${LOG%.log}
-
-echo "Attempting to convert file" >> $LOG
+echo "Attempting to convert file $infile" >> $LOG
 
 "$encoder" -i "$infile" $ENCODER_OPTS -metadata author="$artist" -metadata 
title="$title" -metadata album="$album" -metadata year="$year" -metadata 
track="$track" -metadata genre="$genre" -metadata comment="$comment" "$outfile" 
>> $LOG 2>&1
 
diff --git a/scripts/gtkpod-convert-common.sh b/scripts/gtkpod-convert-common.sh
index 33b87e2..ca04c78 100755
--- a/scripts/gtkpod-convert-common.sh
+++ b/scripts/gtkpod-convert-common.sh
@@ -61,7 +61,10 @@ fi
 # Default values
 [ -z "$comment" ] && comment="Encoded for gtkpod with $ENCODER"
 
-# echo "Converting \"$infile\" into \"$outfile\""
+LOG=`dirname "$outfile"`
+LOG="$LOG/conversion.log"
+
+echo "Converting \"$infile\" into \"$outfile\"" >> $LOG
 
 # Checking input file
 if [ "$infile" = "" ]; then
@@ -72,13 +75,13 @@ if [ ! -f "$infile" ]; then
 fi
 
 # Checking output file
-touch "$outfile"
+touch "$outfile" >> $LOG 2>&1
 if [ "x$?" != "x0" ]; then
     exit 2
 fi
 
 # Check for the existence of encoder
-encoder=`which $ENCODER`
+encoder=`which $ENCODER` >> $LOG 2>&1
 if [ -z "$encoder" ]; then
     exit 5
 fi
@@ -101,7 +104,7 @@ esac
 
 # Check for the existence of decoder
 if [ $decoder ]; then
-    decoder=`which "$decoder"`
+    decoder=`which "$decoder"` >> $LOG 2>&1
     if [ -z "$decoder" ]; then
         exit 4
     fi

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
gtkpod-cvs2 mailing list
gtkpod-cvs2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to