commit c0b8817a3378046c4cbe45cb5c214c18df9fc1ea
Merge: ae4cb23 7ab31fe
Author: Paul Richardson aka phantomjinx <[email protected]>
Date: Sun Apr 18 20:11:00 2010 +0100
Merge branch 'master' into plugin-framework
Conflicts:
configure.in
src/Makefile.am
src/autodetection.c
src/display_itdb.c
src/file.c
src/file_itunesdb.c
src/mp4file.c
CMakeLists.txt | 27 ++----
ChangeLog | 124 ++++++++++++++++++++++++
NEWS | 22 ++++
cmake/FindGIO.cmake | 3 +
cmake/FindGnomeVFS.cmake | 3 -
cmake/FindHAL.cmake | 3 -
configure.in | 73 +++++++-------
src/autodetection.c | 236 +++++++++++----------------------------------
src/details.c | 33 +++++++
src/display_itdb.c | 31 +++---
src/file.c | 241 ++++++++++++++++++++++++++--------------------
src/file_itunesdb.c | 1 -
src/mp4file.c | 205 +++++++++++++++++++++++++++++++++++++--
src/oggfile.c | 1 +
14 files changed, 634 insertions(+), 369 deletions(-)
---
diff --cc configure.in
index b8f4dc9,82df9d8..818af39
--- a/configure.in
+++ b/configure.in
@@@ -235,6 -175,6 +224,17 @@@ els
have_flac="*no -- will build without FLAC support"
fi
++dnl Check for MP4 Headers
++AC_CHECK_HEADERS([mp4v2/platform.h])
++AC_CHECK_HEADERS([mp4v2/itmf_tags.h], [], [],
++ [#ifdef HAVE_MP4V2_PLATFORM_H
++ # include <mp4v2/platform.h>
++ #endif
++ typedef void* MP4FileHandle;
++ ])
++
++AC_CHECK_HEADERS([endian.h])
++
dnl Additional libs maybe needed when compiling under solaris
AC_SEARCH_LIBS(bind, ["socket" "nsl" "socket -lnsl"])
diff --cc src/autodetection.c
index 5f23645,39b1171..94ac6a2
--- a/src/autodetection.c
+++ b/src/autodetection.c
@@@ -25,26 -25,17 +25,22 @@@
|
| $Id$
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
-
+#include <stdio.h>
+#include <string.h>
+#include <glib/gi18n-lib.h>
#include "autodetection.h"
-#include "config.h"
+#include "gp_itdb.h"
+#include "gtkpod_app_iface.h"
#include "misc.h"
#include "prefs.h"
-#include <stdio.h>
-#include <string.h>
+
- #ifdef HAVE_GNOME_VFS
- #include <libgnomevfs/gnome-vfs.h>
- #endif
- #ifdef HAVE_HAL
- #include <libhal.h>
- #include <dbus/dbus.h>
+ #ifdef HAVE_GIO
+ #include <gio/gio.h>
#endif
#undef DEBUG_AUTO
@@@ -369,13 -240,17 +245,17 @@@ static gboolean ad_timeout_cb (gpointe
g_return_val_if_fail (mount_uri, (gdk_threads_leave(),
release_widgets(), TRUE));
- mountpoint = g_filename_from_uri (mount_uri, NULL, NULL);
+ GFile *muri = g_file_parse_name (mount_uri);
+ mountpoint = g_file_get_path (muri);
+ g_object_unref (muri);
g_free (mount_uri);
- debug ("Mounted iPod at '%s'\n", mountpoint);
- itdb = ad_find_repository_with_mountpoint (mountpoint);
+ if (mountpoint) {
+ debug ("Mounted iPod at '%s'\n", mountpoint);
+ itdb = ad_find_repository_with_mountpoint (mountpoint);
+ }
- itdbs = gp_get_itdbs_head (gtkpod_window);
+ itdbs = gp_get_itdbs_head ();
g_return_val_if_fail (itdbs, (gdk_threads_leave(),
release_widgets(), TRUE));
block_widgets ();
diff --cc src/display_itdb.c
index f0526c7,2a9af53..ffd42e1
--- a/src/display_itdb.c
+++ b/src/display_itdb.c
@@@ -763,40 -854,42 +763,41 @@@ void gp_init(GtkPodApp *single_app, in
itdbs_head = g_new0 (struct itdbs_head, 1);
- g_object_set_data (G_OBJECT (window), "itdbs_head", itdbs_head);
+ g_object_set_data(G_OBJECT (gtkpod_app), "itdbs_head", itdbs_head);
- if (!prefs_get_int_value("itdb_0_type", NULL)) {
- /* databases have not been set up previously -- take care of
- this */
- #ifndef HAVE_GNOME_VFS
- gchar *mountpoint;
+ if (!prefs_get_int_value ("itdb_0_type", NULL))
+ {
+ /* databases have not been set up previously -- take care of
+ this */
+ #ifndef HAVE_GIO
+ gchar *mountpoint;
#endif
- gchar *filename;
-
- /* Local database */
- filename = g_build_filename (cfgdir, "local_0.itdb", NULL);
- prefs_set_int ("itdb_0_type", GP_ITDB_TYPE_LOCAL);
- prefs_set_string ("itdb_0_name", _("Music Library"));
- prefs_set_string ("itdb_0_filename", filename);
- g_free (filename);
-
- /* Podcasts database */
- filename = g_build_filename (cfgdir, "podcasts.itdb", NULL);
- prefs_set_int ("itdb_1_type",
- GP_ITDB_TYPE_PODCASTS|GP_ITDB_TYPE_LOCAL);
- prefs_set_string ("itdb_1_name", _("Podcasts"));
- prefs_set_string ("itdb_1_filename", filename);
- g_free (filename);
+ gchar *filename;
+
+ /* Local database */
+ filename = g_build_filename(cfgdir, "local_0.itdb", NULL);
+ prefs_set_int("itdb_0_type", GP_ITDB_TYPE_LOCAL);
+ prefs_set_string("itdb_0_name", _("Music Library"));
+ prefs_set_string("itdb_0_filename", filename);
+ g_free(filename);
+
+ /* Podcasts database */
+ filename = g_build_filename(cfgdir, "podcasts.itdb", NULL);
+ prefs_set_int("itdb_1_type", GP_ITDB_TYPE_PODCASTS |
GP_ITDB_TYPE_LOCAL);
+ prefs_set_string("itdb_1_name", _("Podcasts"));
+ prefs_set_string("itdb_1_filename", filename);
+ g_free(filename);
- #ifndef HAVE_GNOME_VFS
- /* iPod database -- only set up if autodetection is not active */
- mountpoint = prefs_get_string ("initial_mountpoint");
- filename = g_build_filename (cfgdir, "iTunesDB", NULL);
- prefs_set_int ("itdb_2_type", GP_ITDB_TYPE_IPOD);
- prefs_set_string ("itdb_2_name", _("iPod"));
- prefs_set_string ("itdb_2_filename", filename);
- prefs_set_string ("itdb_2_mountpoint", mountpoint);
- g_free (mountpoint);
- g_free (filename);
+ #ifndef HAVE_GIO
+ /* iPod database -- only set up if autodetection is not active */
+ mountpoint = prefs_get_string ("initial_mountpoint");
+ filename = g_build_filename (cfgdir, "iTunesDB", NULL);
+ prefs_set_int ("itdb_2_type", GP_ITDB_TYPE_IPOD);
+ prefs_set_string ("itdb_2_name", _("iPod"));
+ prefs_set_string ("itdb_2_filename", filename);
+ prefs_set_string ("itdb_2_mountpoint", mountpoint);
+ g_free (mountpoint);
+ g_free (filename);
#endif
}
diff --cc src/file.c
index b7157b3,940543e..6c964af
--- a/src/file.c
+++ b/src/file.c
@@@ -1173,47 -1297,55 +1173,52 @@@ static Track *get_track_info_from_file(
}
/* reset the auto detection charset (see explanation in charset.c) */
- charset_reset_auto ();
+ charset_reset_auto();
/* check for filetype */
- len = strlen (name);
- if (len < 4) return NULL;
+ len = strlen(name);
+ if (len < 4)
+ return NULL;
filetype = determine_file_type(name);
- switch (filetype)
- {
+ switch (filetype) {
case FILE_TYPE_MP3:
- nti = mp3_get_file_info(name);
- /* Set mediatype to audio */
- if (nti)
- nti->mediatype = ITDB_MEDIATYPE_AUDIO;
- break;
+ nti = mp3_get_file_info (name);
+ /* Set mediatype to audio */
+ if (nti)
+ {
+ if (g_strcasecmp (nti->genre, "audiobook") == 0) nti->mediatype =
ITDB_MEDIATYPE_AUDIOBOOK;
+ else if (g_strcasecmp (nti->genre, "podcast") == 0) nti->mediatype
= ITDB_MEDIATYPE_PODCAST;
+ else nti->mediatype = ITDB_MEDIATYPE_AUDIO;
+ }
+ break;
case FILE_TYPE_M4A:
case FILE_TYPE_M4P:
- nti = mp4_get_file_info(name);
- /* Set mediatype to audio */
- if (nti) {
- nti->mediatype = ITDB_MEDIATYPE_AUDIO;
- }
- break;
+ nti = mp4_get_file_info (name);
+ /* Set mediatype to audio */
+ if (nti && !nti->mediatype)
+ {
+ nti->mediatype = ITDB_MEDIATYPE_AUDIO;
+ }
+ break;
case FILE_TYPE_M4B:
- nti = mp4_get_file_info (name);
- /* Set mediatype to audiobook */
- if (nti)
- {
- nti->mediatype = ITDB_MEDIATYPE_AUDIOBOOK;
- }
- break;
+ nti = mp4_get_file_info(name);
+ /* Set mediatype to audiobook */
+ if (nti) {
+ nti->mediatype = ITDB_MEDIATYPE_AUDIOBOOK;
+ }
+ break;
case FILE_TYPE_WAV:
- nti = wav_get_file_info (name);
- /* Set mediatype to audio */
- if (nti)
- {
- nti->mediatype = ITDB_MEDIATYPE_AUDIO;
- }
- break;
+ nti = wav_get_file_info(name);
+ /* Set mediatype to audio */
+ if (nti) {
+ nti->mediatype = ITDB_MEDIATYPE_AUDIO;
+ }
+ break;
case FILE_TYPE_OGG:
- nti = ogg_get_file_info (name);
+ nti = ogg_get_file_info(name);
/* Set mediatype to audio */
- if (nti)
- {
+ if (nti) {
nti->mediatype = ITDB_MEDIATYPE_AUDIO;
}
break;
@@@ -1226,31 -1359,33 +1231,32 @@@
break;
case FILE_TYPE_M4V:
case FILE_TYPE_MP4:
- /* I don't know if .m4v and .mp4 can simply be handled like
- this. Let's see if someone complains. */
- nti = mp4_get_file_info(name);
- if (!nti)
- video_get_file_info(name);
- /* Set mediatype to video */
- if (nti) {
+ /* I don't know if .m4v and .mp4 can simply be handled like
+ this. Let's see if someone complains. */
+ nti = mp4_get_file_info (name);
+ if (!nti) video_get_file_info (name);
+ /* Set mediatype to video */
+ if (nti)
+ {
+ if (!nti->mediatype)
nti->mediatype = ITDB_MEDIATYPE_MOVIE;
- nti->movie_flag = 0x01;
- }
- break;
+ nti->movie_flag = 0x01;
+ }
+ break;
case FILE_TYPE_MOV:
case FILE_TYPE_MPG:
- /* for now treat all the same */
- nti = video_get_file_info (name);
- /* Set mediatype to video */
- if (nti)
- {
- nti->mediatype = ITDB_MEDIATYPE_MOVIE;
- nti->movie_flag = 0x01;
- }
- break;
+ /* for now treat all the same */
+ nti = video_get_file_info(name);
+ /* Set mediatype to video */
+ if (nti) {
+ nti->mediatype = ITDB_MEDIATYPE_MOVIE;
+ nti->movie_flag = 0x01;
+ }
+ break;
case FILE_TYPE_UNKNOWN:
- gtkpod_warning (_("The following track could not be processed (filetype
unknown): '%s'\n"), name_utf8);
- g_free (name_utf8);
- return NULL;
+ gtkpod_warning(_("The following track could not be processed
(filetype unknown): '%s'\n"), name_utf8);
+ g_free(name_utf8);
+ return NULL;
case FILE_TYPE_IMAGE:
case FILE_TYPE_DIRECTORY:
case FILE_TYPE_M3U:
diff --cc src/file_itunesdb.c
index 54797ca,d33c948..bc04ff0
--- a/src/file_itunesdb.c
+++ b/src/file_itunesdb.c
@@@ -1575,258 -1819,313 +1575,257 @@@ static gboolean transfer_tracks(iTunesD
return result;
}
+static gboolean gp_write_itdb(iTunesDB *itdb) {
+ gchar *cfgdir;
+ gboolean success = TRUE;
+ ExtraiTunesDBData *eitdb;
+ GtkWidget *dialog;
+ Playlist *mpl;
+ TransferData *transferdata;
+ g_return_val_if_fail (itdb, FALSE);
+ eitdb = itdb->userdata;
+ g_return_val_if_fail (eitdb, FALSE);
-static gboolean gp_write_itdb (iTunesDB *itdb)
-{
- gchar *cfgdir;
- gboolean success = TRUE;
- ExtraiTunesDBData *eitdb;
- GtkWidget *dialog;
- Playlist *mpl;
- TransferData *transferdata;
-
- g_return_val_if_fail (itdb, FALSE);
- eitdb = itdb->userdata;
- g_return_val_if_fail (eitdb, FALSE);
-
- cfgdir = prefs_get_cfgdir ();
- g_return_val_if_fail (cfgdir, FALSE);
-
- mpl = itdb_playlist_mpl (itdb);
- g_return_val_if_fail (mpl, FALSE);
-
- if (!eitdb->itdb_imported)
- { /* No iTunesDB was read but user wants to export current
- data. If an iTunesDB is present on the iPod or in cfgdir,
- this is most likely an error. We should tell the user */
- gchar *tunes = NULL;
- /* First check if we can find an existing iTunesDB. */
- if (itdb->usertype & GP_ITDB_TYPE_LOCAL)
- {
- tunes = g_strdup (itdb->filename);
- }
- else if (itdb->usertype & GP_ITDB_TYPE_IPOD)
- {
- if (get_offline (itdb))
- {
- tunes = g_strdup (eitdb->offline_filename);
- }
- else
- {
- const gchar *mountpoint = itdb_get_mountpoint (itdb);
- g_return_val_if_fail (mountpoint, FALSE);
- tunes = itdb_get_itunesdb_path (mountpoint);
- }
- }
- else
- {
- g_free (cfgdir);
- g_return_val_if_reached (FALSE);
- }
- if (g_file_test (tunes, G_FILE_TEST_EXISTS))
- {
- gchar *str = g_strdup_printf (_("You did not import the
existing iTunesDB ('%s'). This is most likely incorrect and will result in the
loss of the existing database.\n\nIf you skip storing, you can import the
existing database before calling this function again.\n"), tunes);
-
- gint result = gtkpod_confirmation_hig (GTK_WINDOW
(gtkpod_window),
-
GTK_MESSAGE_WARNING,
-
_("Existing iTunes database not imported"),
-
str,
-
_("Proceed anyway"),
-
_("Skip storing"),
-
NULL,
-
NULL);
-
- g_free (str);
-
- if (result == GTK_RESPONSE_CANCEL)
- {
- g_free (cfgdir);
- return FALSE;
- }
- }
- }
-
- block_widgets ();
-
- transferdata = transfer_data_new ();
- dialog = create_transfer_information_dialog (transferdata);
- gtk_widget_show (dialog);
-
- if((itdb->usertype & GP_ITDB_TYPE_IPOD) && !get_offline (itdb))
- {
- const gchar *mountpoint = itdb_get_mountpoint (itdb);
- g_return_val_if_fail (mountpoint, FALSE);
- /* check if iPod directories are present */
- if (!ipod_dirs_present (mountpoint))
- { /* no -- create them */
- gp_ipod_init (itdb);
- /* if still not present abort */
- if (!ipod_dirs_present (mountpoint))
- {
- gtkpod_warning (_("iPod directory structure must be present
before synching to the iPod can be performed.\n"));
- success = FALSE;
- }
- }
- if (success)
- { /* remove deleted files */
- success = delete_files (itdb, transferdata);
- if (!success)
- {
- gtkpod_warning (_("Some tracks could not be deleted from the
iPod. Export aborted!"));
- }
- }
- if (success)
- {
- /* write tracks to iPod */
- success = transfer_tracks (itdb, transferdata);
- }
- }
-
- if (itdb->usertype & GP_ITDB_TYPE_LOCAL)
- {
- success = delete_files (itdb, transferdata);
- }
-
- if (success)
- {
- gchar *buf;
- buf = g_strdup_printf (_("Now writing database '%s'. Please wait..."),
mpl->name);
- gtk_label_set_text (GTK_LABEL (transferdata->textlabel), buf);
- g_free (buf);
-
- while (widgets_blocked && gtk_events_pending ())
- gtk_main_iteration ();
- }
-
- 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;
- 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 shuffle data */
- if (!itdb_shuffle_write (itdb, &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)
- {
- if (WRITE_EXTENDED_INFO)
- { /* write extended information */
- success = write_extended_info (itdb);
- }
- else
- { /* delete extended information if present */
- gchar *ext = g_strdup_printf ("%s.ext", itdb->filename);
- if (g_file_test (ext, G_FILE_TEST_EXISTS))
- {
- if (remove (ext) != 0)
- {
- gtkpod_statusbar_message (_("Extended information file
not deleted: '%s\'"), ext);
- }
- }
- g_free (ext);
- }
- }
- if (success)
- { /* copy to cfgdir */
- GError *error = NULL;
- if (! g_file_test (eitdb->offline_filename, G_FILE_TEST_EXISTS))
- {
- /* Possible that plugging an ipod into a different pc can lead to
an offline filename
- * that does not exist. This results in the save process failing
as it cannot write a
- * backup. Attempt to mitigate this situation with a reserve
backup path.
- */
- gchar *ipod_model = get_itdb_prefs_string (itdb, KEY_IPOD_MODEL);
- gchar *backup_name = g_strconcat ("backupDB_", ipod_model, NULL);
- g_free (ipod_model);
- g_free (eitdb->offline_filename);
- eitdb->offline_filename = g_build_filename(cfgdir, backup_name,
NULL);
- g_free (backup_name);
- gtkpod_warning ("Backup database could not be found so backing up
database to %s\n", eitdb->offline_filename);
- }
-
- if (!itdb_cp (itdb->filename, eitdb->offline_filename, &error))
- {
- 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 (WRITE_EXTENDED_INFO)
- {
- gchar *from, *to;
- from = g_strdup_printf ("%s.ext", itdb->filename);
- to = g_strdup_printf ("%s.ext", eitdb->offline_filename);
- if (!itdb_cp (from, to, &error))
- {
- success = FALSE;
- if (error && error->message)
- gtkpod_warning ("%s\n\n", error->message);
- else
- g_warning ("error->message == NULL!\n");
- g_error_free (error);
- }
- g_free (from);
- g_free (to);
- }
- }
- }
-
- 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;
- 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_INFO)
- { /* write extended information */
- success = write_extended_info (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);
- }
- }
-
- /* If the ipod supports photos and the photo_data_changed
- * flag has been set to true then wrtie the photo database
- */
- 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))
- {
- 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;
- }
- }
-
- /* indicate that files and/or database is saved */
- if (success)
- {
- data_unchanged (itdb);
- 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);
-
- gtk_widget_destroy (dialog);
- transfer_data_free (transferdata);
-
- release_widgets ();
-
- return success;
-}
+ cfgdir = prefs_get_cfgdir();
+ g_return_val_if_fail (cfgdir, FALSE);
+
+ mpl = itdb_playlist_mpl(itdb);
+ g_return_val_if_fail (mpl, FALSE);
+
+ if (!eitdb->itdb_imported) { /* No iTunesDB was read but user wants to
export current
+ data. If an iTunesDB is present on the iPod or in cfgdir,
+ this is most likely an error. We should tell the user */
+ gchar *tunes = NULL;
+ /* First check if we can find an existing iTunesDB. */
+ if (itdb->usertype & GP_ITDB_TYPE_LOCAL) {
+ tunes = g_strdup(itdb->filename);
+ }
+ else if (itdb->usertype & GP_ITDB_TYPE_IPOD) {
+ if (get_offline(itdb)) {
+ tunes = g_strdup(eitdb->offline_filename);
+ }
+ else {
+ const gchar *mountpoint = itdb_get_mountpoint(itdb);
+ g_return_val_if_fail (mountpoint, FALSE);
+ tunes = itdb_get_itunesdb_path(mountpoint);
+ }
+ }
+ else {
+ g_free(cfgdir);
+ g_return_val_if_reached (FALSE);
+ }
+ if (g_file_test(tunes, G_FILE_TEST_EXISTS)) {
+ gchar
+ *str =
+ g_strdup_printf(_("You did not import the
existing iTunesDB ('%s'). This is most likely incorrect and will result in the
loss of the existing database.\n\nIf you skip storing, you can import the
existing database before calling this function again.\n"), tunes);
+
+ gint
+ result =
+ gtkpod_confirmation_hig(GTK_MESSAGE_WARNING,
_("Existing iTunes database not imported"), str, _("Proceed anyway"), _("Skip
storing"), NULL, NULL);
+
+ g_free(str);
+
+ if (result == GTK_RESPONSE_CANCEL) {
+ g_free(cfgdir);
+ return FALSE;
+ }
+ }
+ }
+ block_widgets();
+
+ transferdata = transfer_data_new();
+ dialog = create_transfer_information_dialog(transferdata);
+ gtk_widget_show(dialog);
+
+ if ((itdb->usertype & GP_ITDB_TYPE_IPOD) && !get_offline(itdb)) {
+ const gchar *mountpoint = itdb_get_mountpoint(itdb);
+ g_return_val_if_fail (mountpoint, FALSE);
+ /* check if iPod directories are present */
+ if (!ipod_dirs_present(mountpoint)) { /* no -- create them */
+ gtkpod_init_repository(itdb);
+ /* if still not present abort */
+ if (!ipod_dirs_present(mountpoint)) {
+ gtkpod_warning(_("iPod directory structure must be present
before synching to the iPod can be performed.\n"));
+ success = FALSE;
+ }
+ }
+ if (success) { /* remove deleted files */
+ success = delete_files(itdb, transferdata);
+ if (!success) {
+ gtkpod_warning(_("Some tracks could not be deleted from the
iPod. Export aborted!"));
+ }
+ }
+ if (success) {
+ /* write tracks to iPod */
+ success = transfer_tracks(itdb, transferdata);
+ }
+ }
+ if (itdb->usertype & GP_ITDB_TYPE_LOCAL) {
+ success = delete_files(itdb, transferdata);
+ }
+
+ if (success) {
+ gchar *buf;
+ buf = g_strdup_printf(_("Now writing database '%s'. Please wait..."),
mpl->name);
+ gtk_label_set_text(GTK_LABEL (transferdata->textlabel), buf);
+ g_free(buf);
+
+ while (widgets_blocked && gtk_events_pending())
+ gtk_main_iteration();
+ }
+
+ 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;
+ 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 shuffle data */
+ if (!itdb_shuffle_write(itdb, &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) {
+ if (WRITE_EXTENDED_INFO) { /* write extended information */
+ success = write_extended_info(itdb);
+ }
+ else { /* delete extended information if present */
+ gchar *ext = g_strdup_printf("%s.ext", itdb->filename);
+ if (g_file_test(ext, G_FILE_TEST_EXISTS)) {
+ if (remove(ext) != 0) {
+ gtkpod_statusbar_message(_("Extended information file
not deleted: '%s\'"), ext);
+ }
+ }
+ g_free(ext);
+ }
+ }
+ if (success) { /* copy to cfgdir */
+ GError *error = NULL;
+ if (!g_file_test(eitdb->offline_filename, G_FILE_TEST_EXISTS)) {
+ /* Possible that plugging an ipod into a different pc can
lead to an offline filename
+ * that does not exist. This results in the save process
failing as it cannot write a
+ * backup. Attempt to mitigate this situation with a reserve
backup path.
+ */
+ gchar *ipod_model = get_itdb_prefs_string(itdb,
KEY_IPOD_MODEL);
+ gchar *backup_name = g_strconcat("backupDB_", ipod_model,
NULL);
+ g_free(ipod_model);
+ eitdb->offline_filename = g_build_filename(cfgdir,
backup_name, NULL);
+ g_free(backup_name);
+ gtkpod_warning("Backup database could not be found so backing
up database to %s\n", eitdb->offline_filename);
+ }
+
+ if (!itdb_cp(itdb->filename, eitdb->offline_filename, &error)) {
+ 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 (WRITE_EXTENDED_INFO) {
+ gchar *from, *to;
+ from = g_strdup_printf("%s.ext", itdb->filename);
+ to = g_strdup_printf("%s.ext", eitdb->offline_filename);
+ if (!itdb_cp(from, to, &error)) {
+ success = FALSE;
+ if (error && error->message)
+ gtkpod_warning("%s\n\n", error->message);
+ else
+ g_warning ("error->message == NULL!\n");
+ g_error_free(error);
+ }
+ g_free(from);
+ g_free(to);
+ }
+ }
+ }
+
+ 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;
+ 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_INFO) { /* write extended information */
+ success = write_extended_info(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);
+ }
+ }
+
+ /* If the ipod supports photos and the photo_data_changed
+ * flag has been set to true then wrtie the photo database
+ */
+ 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)) {
+ 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;
+ }
+ }
+
+ /* indicate that files and/or database is saved */
- g_message("TODO indicate that database has been saved\n");
+ if (success) {
+ data_unchanged(itdb);
+ 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);
+
+ gtk_widget_destroy(dialog);
+ transfer_data_free(transferdata);
+
+ release_widgets();
+
+ return success;
+}
/* used to handle export of database */
/* ATTENTION: directly used as callback in gtkpod.glade -- if you
diff --cc src/mp4file.c
index 08fbbc3,0817085..8f74c3d
--- a/src/mp4file.c
+++ b/src/mp4file.c
@@@ -31,7 -31,10 +31,10 @@@
# include <config.h>
#endif
+#include <glib/gi18n-lib.h>
+ #ifdef HAVE_ENDIAN_H
+ # include <endian.h> /* for be32toh () */
+ #endif
-
#include "charset.h"
#include "itdb.h"
#include "misc.h"
@@@ -256,9 -267,18 +267,18 @@@ typedef bool (*MP4GetMetadataTool_t)(MP
typedef bool (*MP4GetMetadataFreeForm_t)(MP4FileHandle hFile, const char
*name,
u_int8_t** pValue, u_int32_t* valueSize, const char
*owner DEFAULT(NULL));
-typedef bool (*MP4HaveAtom_t)(MP4FileHandle hFile,
+typedef bool (*MP4HaveAtom_t)(MP4FileHandle hFile,
const char *atomName);
+ typedef bool (*MP4GetIntegerProperty_t)(MP4FileHandle hFile,
+ const char* propName, u_int64_t *retval);
+ typedef bool (*MP4GetStringProperty_t)(MP4FileHandle hFile,
+ const char* propName, const char **retvalue);
+ typedef bool (*MP4GetBytesProperty_t)(MP4FileHandle hFile,
+ const char* propName, u_int8_t** ppValue, u_int32_t*
pValueSize);
+ typedef bool (*MP4SetVerbosity_t)(MP4FileHandle hFile,
+ u_int32_t verbosity);
+
typedef bool (*MP4SetMetadataName_t)(MP4FileHandle hFile, const char* value);
typedef bool (*MP4SetMetadataArtist_t)(MP4FileHandle hFile, const char*
value);
typedef bool (*MP4SetMetadataAlbumArtist_t)(MP4FileHandle hFile, const char*
value);
@@@ -337,10 -368,10 +368,10 @@@ static MP4TagsFree_t MP4TagsFreeFunc =
/* end mp4v2 dynamic load declarations */
/* mp4v2 initialization code */
-
+
void mp4_init()
{
- mp4v2_handle = dlopen("libmp4v2.so.0", RTLD_LAZY);
+ mp4v2_handle = dlopen("libmp4v2.so.1", RTLD_LAZY);
if (!mp4v2_handle)
{
@@@ -400,9 -435,12 +435,12 @@@
MP4SetMetadataCoverArt = (MP4SetMetadataCoverArt_t) dlsym(mp4v2_handle,
"MP4SetMetadataCoverArt");
MP4Modify = (MP4Modify_t) dlsym(mp4v2_handle, "MP4Modify");
MP4MetadataDelete = (MP4MetadataDelete_t) dlsym(mp4v2_handle,
"MP4MetadataDelete");
+ MP4TagsAllocFunc = (MP4TagsAlloc_t) dlsym(mp4v2_handle, "MP4TagsAlloc");
+ MP4TagsFetchFunc = (MP4TagsFetch_t) dlsym(mp4v2_handle, "MP4TagsFetch");
+ MP4TagsFreeFunc = (MP4TagsFree_t) dlsym(mp4v2_handle, "MP4TagsFree");
/* alternate names for HAVE_LIBMP4V2_2 */
-
+
if(!MP4GetMetadataWriter)
{
MP4GetMetadataWriter = (MP4GetMetadataWriter_t) dlsym(mp4v2_handle,
"MP4GetMetadataComposer");
@@@ -641,8 -782,13 +782,13 @@@ Track *mp4_get_file_info (gchar *mp4Fil
{
gchar *value;
guint16 numvalue, numvalue2;
+ u_int8_t numvalue3;
+ gboolean possibly_tv_show = FALSE;
+ #if HAVE_MP4V2_ITMF_TAGS_H
+ const MP4Tags* mp4tags = NULL;
+ #endif
MP4Duration trackDuration = MP4GetTrackDuration(mp4File,
trackId);
- double msDuration =
+ double msDuration =
(double)MP4ConvertFromTrackDuration(mp4File, trackId,
trackDuration,
MP4_MSECS_TIME_SCALE);
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2