summaryrefslogtreecommitdiffstats
path: root/tests/test-ls.c
diff options
context:
space:
mode:
authorteuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2006-04-10 18:38:10 +0000
committerteuf <teuf@f01d2545-417e-4e96-918e-98f8d0dbbcb6>2006-04-10 18:38:10 +0000
commit47a44507874f28129346c10ee853a36d1b1653f6 (patch)
tree5f3629829d382928a834449f1e374d4132195b10 /tests/test-ls.c
parent230f33c88374b42db9cec635db2683ef46ac7eb2 (diff)
* tests/test-ls.c: new test program reading and displaying the iPod
content * tests/test-rebuild-db.cc: new test program which looks for mp3 files on the iPod in the Music dir and rebuild an iPod database from that (it uses taglib to parse the tags, so it's conditionnally built depending on taglib's availability) * configure.ac: * tests/Makefile.am: build system changes to accomodate the 2 new test programs git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1245 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'tests/test-ls.c')
-rw-r--r--tests/test-ls.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/test-ls.c b/tests/test-ls.c
new file mode 100644
index 0000000..b1376bd
--- /dev/null
+++ b/tests/test-ls.c
@@ -0,0 +1,122 @@
+/*
+| Copyright (C) 2002-2003 Jorg Schuler <jcsjcs at users.sourceforge.net>
+| Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
+|
+| This program is free software; you can redistribute it and/or modify
+| it under the terms of the GNU General Public License as published by
+| the Free Software Foundation; either version 2 of the License, or
+| (at your option) any later version.
+|
+| This program is distributed in the hope that it will be useful,
+| but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+| GNU General Public License for more details.
+|
+| You should have received a copy of the GNU General Public License
+| along with this program; if not, write to the Free Software
+| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <libintl.h>
+
+#include "itdb.h"
+
+static void
+display_track (Itdb_Track *track, const char *prefix)
+{
+ g_print ("%s%s - %s - %s\n", prefix,
+ track->artist, track->album, track->title);
+ g_print ("%s\t%s\n", prefix, track->ipod_path);
+}
+
+static void
+display_playlist (Itdb_Playlist *playlist, const char *prefix)
+{
+ char *track_prefix;
+ GList *it;
+
+ if (itdb_playlist_is_mpl (playlist)) {
+ g_print ("%s%s (Master Playlist)\n", prefix, playlist->name);
+ } else if (itdb_playlist_is_podcasts (playlist)) {
+ g_print ("%s%s (Podcasts Playlist)\n", prefix, playlist->name);
+ } else {
+ g_print ("%s%s\n", prefix, playlist->name);
+ }
+
+ printf ("%stracks: %d\n", prefix, g_list_length (playlist->members));
+ track_prefix = g_strdup_printf ("%s\t", prefix);
+ for (it = playlist->members; it != NULL; it = it->next) {
+ Itdb_Track *track;
+
+ track = (Itdb_Track *)it->data;
+ display_track (track, "\t");
+ }
+ g_print ("\n\n");
+ g_free (track_prefix);
+}
+
+int
+main (int argc, char *argv[])
+{
+ GError *error=NULL;
+ Itdb_iTunesDB *itdb;
+ gchar *mountpoint = NULL;
+
+ if (argc >= 2)
+ mountpoint = argv[1];
+
+ if (mountpoint == NULL)
+ {
+ g_print ("Usage: %s <mountpoint>\n", g_basename(argv[0]));
+ exit (0);
+ }
+
+ itdb = itdb_parse (mountpoint, &error);
+
+ if (error)
+ {
+ if (error->message) {
+ g_print("%s\n", error->message);
+ }
+ g_error_free (error);
+ error = NULL;
+ }
+
+ if (itdb)
+ {
+ GList *it;
+
+ printf ("playlists: %d\n", g_list_length (itdb->playlists));
+ for (it = itdb->playlists; it != NULL; it = it->next) {
+ Itdb_Playlist *playlist;
+
+ playlist = (Itdb_Playlist *)it->data;
+ display_playlist (playlist, "");
+ }
+
+ if (error)
+ {
+ if (error->message) {
+ g_print ("%s\n", error->message);
+ }
+ g_error_free (error);
+ error = NULL;
+ }
+ }
+
+ itdb_free (itdb);
+
+ return 0;
+}