Mailinglist Archive: opensuse-commit (1028 mails)

< Previous Next >
commit fusepod
  • From: root@xxxxxxx (h_root)
  • Date: Wed, 14 Jun 2006 13:12:19 +0200 (CEST)
  • Message-id: <20060614111219.1789760EF8@xxxxxxxxxxxxxxx>

Hello community,

here is the log from the commit of package fusepod
checked in at Wed Jun 14 13:12:19 CEST 2006.

--------
--- fusepod/fusepod.changes 2006-04-24 10:31:29.000000000 +0200
+++ fusepod/fusepod.changes 2006-06-13 12:54:52.000000000 +0200
@@ -1,0 +2,12 @@
+Tue Jun 13 12:52:37 CEST 2006 - cthiel@xxxxxxx
+
+- update to version 0.4
+ * The filesystem can now create the iTunesDB for you, so you don't have to
+ run iTunes to set up the required files and directories.
+ * Playlist removal is now supported.
+ * A script for recursively adding files and directories to the iPod was
+ added.
+ * ./sync_ipod.sh now can show what it is doing with the -watch option.
+ * A statistics file was added.
+
+-------------------------------------------------------------------

Old:
----
fusepod-0.3.diff
fusepod-0.3.tar.bz2

New:
----
fusepod-0.4.diff
fusepod-0.4.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ fusepod.spec ++++++
--- /var/tmp/diff_new_pack.SjB9I5/_old 2006-06-14 13:12:00.000000000 +0200
+++ /var/tmp/diff_new_pack.SjB9I5/_new 2006-06-14 13:12:00.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package fusepod (Version 0.3)
+# spec file for package fusepod (Version 0.4)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -13,8 +13,8 @@
Name: fusepod
BuildRequires: fuse-devel gcc-c++ pkg-config
Summary: FUSEPod is a virtual user-space filesystem that mounts your iPod
-Version: 0.3
-Release: 2
+Version: 0.4
+Release: 1
License: GPL, LGPL
Group: System/Filesystems
Source: %{name}-%{version}.tar.bz2
@@ -57,5 +57,14 @@
%{_mandir}/man1/fusepod.1.gz

%changelog -n fusepod
+* Tue Jun 13 2006 - cthiel@xxxxxxx
+- update to version 0.4
+ * The filesystem can now create the iTunesDB for you, so you don't have to
+ run iTunes to set up the required files and directories.
+ * Playlist removal is now supported.
+ * A script for recursively adding files and directories to the iPod was
+ added.
+ * ./sync_ipod.sh now can show what it is doing with the -watch option.
+ * A statistics file was added.
* Mon Apr 24 2006 - cthiel@xxxxxxx
- initial package (version 0.3)

++++++ fusepod-0.3.diff -> fusepod-0.4.diff ++++++

++++++ fusepod-0.3.tar.bz2 -> fusepod-0.4.tar.bz2 ++++++
++++ 18228 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/AUTHORS new/fusepod-0.4/AUTHORS
--- old/fusepod-0.3/AUTHORS 2006-02-18 11:41:17.000000000 +0100
+++ new/fusepod-0.4/AUTHORS 2006-05-26 01:08:57.000000000 +0200
@@ -1 +1 @@
-Keegan Carrruthers-Smith <keegan.csmith@xxxxxxxxx>
+Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/ChangeLog new/fusepod-0.4/ChangeLog
--- old/fusepod-0.3/ChangeLog 2006-04-10 13:06:41.000000000 +0200
+++ new/fusepod-0.4/ChangeLog 2006-06-11 15:47:08.000000000 +0200
@@ -1,3 +1,32 @@
+2006-06-11 <keegan.csmith@xxxxxxxxx>
+
+ * man/fusepod.1, README: Updated documentation
+
+2006-06-08 <keegan.csmith@xxxxxxxxx>
+
+ * src/fusepod.cpp: Added add_files.sh, which enables you to add files and directories recursively.
+ Bug fixes.
+ Added -watch flag to sync_ipod.sh
+
+ * src/fusepod_ipod.cpp: Added method for iPod statistics
+
+2006-06-03 <keegan.csmith@xxxxxxxxx>
+
+ * src/fusepod_ipod.cpp: Does not show hidden playlists now.
+ Removal of playlists is now supported.
+ Checks if you have write access before deleting a song.
+ Can create iTunesDB directory structure.
+
+ * src/ipod/ipod_track_from_mp3.c (ipod_mp3_scan_frames): Stopped libipod
+ from dividing by 0 with bad mp3 tags
+
+ * src/fusepod.cpp (main): Made startup error more verbose.
+ Prompts user wether to create the iTunesDB directory structure if it doesn't exist.
+
+2006-04-14 Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>
+
+ * configure.ac: Bumped version upto 0.4
+
2006-04-10 Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>

* src/fusepod.cpp: Cleaned up some return errors.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/NEWS new/fusepod-0.4/NEWS
--- old/fusepod-0.3/NEWS 2006-04-10 18:48:45.000000000 +0200
+++ new/fusepod-0.4/NEWS 2006-06-11 14:54:46.000000000 +0200
@@ -1,5 +1,14 @@
See ChangeLog for more info

+What's new in 0.4:
+ * Can create the iTunesDB for you, so you don't have to run iTunes
+ to setup the required files/directories.
+ * Playlist removal
+ * A script for recursively adding files and directories to the iPod.
+ * ./sync_ipod.sh now can give status on what it is doing (-watch)
+ * A statistics file
+ * General fixes and polish
+
What's new in 0.3:
* Playlists
* You can remove tracks
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/README new/fusepod-0.4/README
--- old/fusepod-0.3/README 2006-04-10 18:49:54.000000000 +0200
+++ new/fusepod-0.4/README 2006-06-11 14:50:25.000000000 +0200
@@ -1,32 +1,32 @@
-FUSEPod v0.3
+FUSEPod v0.4
Copyright (C) 2006 Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>

http://fusepod.sourceforge.net

-This is the third release of FUSEPod, and such there may be some bugs and
-things working in a stupid way. I would really appreciate it if you could send
-bug reports, feature request, praise or dismissal my way at my email address
-above. I want to make the program better. Also any patches are welcome.
+This is the fourth release of FUSEPod.
+I would really appreciate it if you could send bug reports, feature request,
+praise or dismissal my way at my email address above. I want to make the
+program better. Also any patches are welcome.

Introduction
============

-FUSEPod is a userspace filesystem which mounts you iPod into a directory for
-easy browsing of you songs on your iPod.
+FUSEPod is a userspace filesystem which mounts your iPod into a directory
+for easy browsing of your songs on your iPod.

Features
========

* Read and Write support (Now including removal of files)
- * Viewing playlists
+ * Viewing/Removing playlists
* Configurable directory layout
* Discovers where your iPod is mounted

Installation
============

-This program has only been tested with Linux 2.6.11, but should work with any
-kernel version that FUSE supports. You require:
+This program has only been tested with Linux 2.6.11 and 2.6.16, but should
+work with any kernel version that FUSE supports. You require:
* FUSE 2.5 or higher (http://sourceforge.net/projects/fuse)

This program includes libipod 0.1 (http://libipod.sourceforge.net) which was
@@ -51,6 +51,10 @@
You would enter at the console:

IPOD_DIR="/media/IPOD" fusepod /home/keegan/ipod
+
+You can also create the necessary files and directories for your iPod to
+work. FUSEPod will prompt you if you specify IPOD_DIR which does not have
+the necessary structure.

To unmount FUSEPod type at the console:

@@ -60,19 +64,30 @@

[mounted_to]/add_songs

+You can also add files and recusrively add directories through
+
+ [mounted_to]/add_files.sh [ files/directories ] ...
+
And then to sync the database and copy the files run

- [mounted_to]/sync_ipod.sh
+ [mounted_to]/sync_ipod.sh [ -watch ]
+
+The switch -watch will give you status messages while syncing the iPod.

For example, say I was in the [mounted_to] directory. To add a CD to my iPod I
would type at the command line:

- find /home/keegan/Songs/Deftones\ -\ BSides\ and\ Rarities > add_songs
+ find /music/Deftones\ -\ BSides\ and\ Rarities > add_songs

Then if I also wanted to add another CD I would type at the command line:

find /home/keegan/Songs/Atreyu\ -\ The\ Curse >> add_songs

+or I could enter at the command line (this is should be in one line)
+
+ ./add_files.sh /music/Deftones\ -\ BSides\ and\ Rarities \
+ /music/Atreyu\ -\ The\ Curse
+
You can the view all the songs that will be added to the iPod by running the
command (Note songs that can't be added will be ignored):

@@ -108,8 +123,8 @@

/Testing/1/2/3/%a/%t.%e

-Note that the line has to start with a / character. View the default .fusepod
-and run the program to get a better understanding. (NB. The default .fusepod is
+Note that the line has to start with a / character. If you do not have a
+.fusepod in your home directory just run fusepod. (NB. The default .fusepod is
written on the first run)

License
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/TODO new/fusepod-0.4/TODO
--- old/fusepod-0.3/TODO 1970-01-01 01:00:00.000000000 +0100
+++ new/fusepod-0.4/TODO 2006-06-11 14:25:55.000000000 +0200
@@ -0,0 +1,19 @@
+TODO File for FUSEPod
+ * = TODO
+ + = DONE
+
+ * Unicode
+ * Better Playlists Support
+ * Creating
+ + Removing
+ * Configurable Layout
+ * Transparent copying of mp3s
+ * Take a look at libgpod.
+ * Have more actions to perform on ipod
+ + Recursive adding of files/directories
+ * kdialog/xdialog/zenity interface
+ + Option to display information while syncing
+ + Have a stat file for stats on the ipod
+ * Test on FreeBSD
+ + Stop crashing when trying to delete a readonly file
+ + If the specified IPOD_DIR has no iTunesDB, create one
\ No newline at end of file
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/configure.ac new/fusepod-0.4/configure.ac
--- old/fusepod-0.3/configure.ac 2006-03-12 00:06:38.000000000 +0100
+++ new/fusepod-0.4/configure.ac 2006-04-23 15:36:26.000000000 +0200
@@ -1,8 +1,8 @@
-AC_INIT([fusepod], [0.3],
+AC_INIT([fusepod], [0.4],
[Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>],
[fusepod])
AM_INIT_AUTOMAKE
-CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -O2"
+CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -O2"
AC_PROG_CXX
AC_PROG_LIBTOOL
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/fusepod.lsm new/fusepod-0.4/fusepod.lsm
--- old/fusepod-0.3/fusepod.lsm 2006-04-08 23:46:50.000000000 +0200
+++ new/fusepod-0.4/fusepod.lsm 2006-04-23 15:36:26.000000000 +0200
@@ -1,7 +1,7 @@
Begin3
Title: fusepod
-Version: 0.3
-Entered-date: 08 Apr 06
+Version: 0.4
+Entered-date: 14 Apr 06
Description: iPod virtual filesystem
Keywords: ipod fuse filesystem mp3
Author: Keegan Carruthers-Smith <keegan.csmith@xxxxxxxxx>
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/man/fusepod.1 new/fusepod-0.4/man/fusepod.1
--- old/fusepod-0.3/man/fusepod.1 2006-04-10 15:18:18.000000000 +0200
+++ new/fusepod-0.4/man/fusepod.1 2006-06-11 15:48:41.000000000 +0200
@@ -1,15 +1,15 @@
.\" Process this file with
.\" groff -man -Tascii fusepod.1
.\"
-.TH fusepod 1 "FUSEPod 1.0" "iPod virtual filesystem"
+.TH fusepod 1 "FUSEPod 0.4" "iPod virtual filesystem"
.SH NAME
fusepod \- iPod virtual filesystem
.SH SYNOPSIS
.B fusepod [ options ] mountpoint
.SH DESCRIPTION
.B FUSEPod
-is a userspace virtual filesystem which mounts you iPod into a directory for
-easy browsing of you songs on your iPod.
+is a userspace virtual filesystem which mounts your iPod into a directory for
+easy browsing of your songs on your iPod.
.SH USAGE

To mount your ipod type at the console:
@@ -37,7 +37,14 @@
.br
.B IPOD_DIR="/media/IPOD" fusepod /home/keegan/ipod
.RE
-
+
+You can also create the necessary files and directories for your iPod to
+work.
+.B FUSEPod
+will prompt you if you specify
+.B IPOD_DIR
+which does not have the necessary structure.
+
To unmount FUSEPod type at the console:
.RS
.br
@@ -50,10 +57,16 @@
.B [mounted_to]/add_songs
.RE

+You can also add files and recusrively add directories through
+.RS
+.br
+.B [mounted_to]/add_files.sh [ files/directories ] ...
+.RE
+
And then to sync the database and copy the files run
.RS
.br
-.B [mounted_to]/sync_ipod.sh
+.B [mounted_to]/sync_ipod.sh [ -watch ]
.RE

For example, say I was in the
@@ -70,6 +83,12 @@
.B find\ /home/keegan/Songs/Atreyu\\ -\\ The\\ Curse\ >>\ add_songs
.RE

+or I could enter at the command line (this is should be in one line)
+.RS
+.br
+.B ./add_files.sh\ /music/Deftones\ -\ BSides\ and\ Raritiess /music/Atreyu\ -\ The\ Curse
+.RE
+
You can the view all the songs that will be added to the iPod viewing the file
.B add_songs.

diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/fusepod.cpp new/fusepod-0.4/src/fusepod.cpp
--- old/fusepod-0.3/src/fusepod.cpp 2006-04-10 13:05:45.000000000 +0200
+++ new/fusepod-0.4/src/fusepod.cpp 2006-06-11 01:40:08.000000000 +0200
@@ -27,8 +27,6 @@
#include <fcntl.h>
}

-#include <ipod/ipod_cpp.h>
-#include <ipod/ipod_constants.h>
#include <iostream>
#include <fstream>
#include <vector>
@@ -43,11 +41,25 @@

using namespace std;

+/* I know globals are regarded as bad, but I'm lazy */
static FUSEPod * fusepod;
static string fuse_mount_point;
static string sync_script;
+static string add_files_script;
static char * add_songs;
static vector<uint32_t> songs_to_delete;
+static bool syncing;
+static string syncing_file;
+static string currently_syncing;
+
+/** Returns fusepod->get_statistics with syncing info */
+static string fusepod_get_stats () {
+ if (syncing) /* Add syncing stats */
+ return fusepod->get_statistics () +
+ "Currently Syncing: " + currently_syncing + "\n";
+ else
+ return fusepod->get_statistics ();
+}

static int fusepod_getattr (const char *path, struct stat *stbuf) {
Node * tn = fusepod->get_node (path);
@@ -60,6 +72,10 @@
return 0;
}

+ /* Update size for statistics file */
+ if (filename_stats == &(path[1]))
+ tn->value.size = fusepod_get_stats ().length ();
+
memset (stbuf, 0, sizeof (struct stat));
stbuf->st_uid = getuid ();
stbuf->st_gid = getgid ();
@@ -102,8 +118,9 @@
if (tn == 0)
return -ENOENT;

- /* Check if reading sync file */
- if (filename_sync == &(path[1]))
+ /* Check if reading sync file or stats file */
+ if (filename_sync == &(path[1]) ||
+ filename_stats == &(path[1]))
return 0;

const char * realpath;
@@ -111,7 +128,7 @@
if (filename_add == &(path[1])) //The special file containing songs to sync
realpath = add_songs;
else if (tn->value.mode == MODE_FILE) //A song
- realpath = fusepod->ipod->TrackByTrackID (tn->value.id).GetText (IPOD_FULL_PATH).c_str ();
+ realpath = fusepod->get_real_path (tn->value).c_str ();
else
return 0;

@@ -176,12 +193,34 @@
return bytes_read;
}

+ /* Check if reading add_files script */
+ if (filename_add_files == &(path[1])) {
+ if (offset >= add_files_script.length ())
+ return -EINVAL;
+
+ int bytes_read = min ((int) (add_files_script.length () - offset), (int) size);
+ memcpy (buf, &(add_files_script.c_str ()[offset]), bytes_read);
+ return bytes_read;
+ }
+
+ /* Check if reading statistics file */
+ if (filename_stats == &(path[1])) {
+ string stats = fusepod_get_stats ();
+
+ if (offset >= stats.length ())
+ return -EINVAL;
+
+ int bytes_read = min ((int) (stats.length () - offset), (int) size);
+ memcpy (buf, &(stats.c_str ()[offset]), bytes_read);
+ return bytes_read;
+ }
+
const char * realpath;
/* Check if reading songs to be added */
if (filename_add == &(path[1]))
realpath = add_songs;
else
- realpath = fusepod->ipod->TrackByTrackID (tn->value.id).GetText (IPOD_FULL_PATH).c_str ();
+ realpath = fusepod->get_real_path (tn->value).c_str ();

(void) fi;
fd = open(realpath, O_RDONLY);
@@ -197,8 +236,9 @@
}

static int fusepod_mknod (const char * path, mode_t mode, dev_t dev) {
- if (filename_sync_do == &(path [1])) {
+ if (filename_sync_do == &(path [1]) && !syncing) {
/* Synchronize iPod */
+ syncing = true;
ifstream in (add_songs);
string path;

@@ -211,6 +251,7 @@

if (S_ISREG(st.st_mode)) {
cout << "Adding track " << path << "... ";
+ currently_syncing = path;
fusepod->upload_song (path);
cout << "Successful" << endl;
}
@@ -222,14 +263,44 @@
remove (add_songs);
fclose (fopen (add_songs, "w"));

+ currently_syncing = "iTunesDB";
cout << "Syncing database... ";
fusepod->flush ();
cout << "Successful" << endl;
+
+ syncing = false;
+ currently_syncing = "";
return 0;
}
return -EACCES;
}

+/*static int fusepod_mkdir (const char * path, mode_t mode) {
+ Node * node = fusepod->get_node (path);
+
+ if (node != 0)
+ return -EEXIST;
+
+ if (!node->parent || dir_playlists != node->parent->value.text)
+ return -EACCES;
+
+ //TODO: Makes a playlist
+ }*/
+
+static int fusepod_rmdir (const char * path) {
+ Node * node = fusepod->get_node (path);
+
+ if (node == 0)
+ return -ENOENT;
+
+ if (!node->parent || dir_playlists != node->parent->value.text)
+ return -EACCES;
+
+ fusepod->remove_playlist (string (node->value.text));
+
+ return 0;
+}
+
static int fusepod_statfs (const char * path, struct statvfs * vfs) {
int ret = statvfs (fusepod->mount_point.c_str (), vfs);

@@ -247,7 +318,12 @@
if (S_ISDIR (node->value.mode))
return -EISDIR;

- fusepod->remove_song (node->value.id);
+ if (!(node->value.mode & S_IWUSR) ||
+ filename_add == &(path[1]))
+ return -EACCES;
+
+ if (!fusepod->remove_song (path))
+ return -EACCES;

return 0;
}
@@ -297,6 +373,9 @@
}

void * fusepod_init () {
+ syncing = false;
+ syncing_file = "";
+
vector<string> pd = get_string_desc ();

string mountpoint = FUSEPod::discover_ipod ();
@@ -321,12 +400,45 @@
sync_script = "#!/bin/sh\n";
sync_script += "#FUSEPod sync script\n";
sync_script += "echo Syncing iPod...\n";
- sync_script += "touch " + fuse_mount_point + "/" + filename_sync_do + " >& /dev/null\n";
+ sync_script += "if [ \"$1\" = '-watch' ]; then\n";
+ sync_script += " stats='" + fuse_mount_point + "/" + filename_stats + "'\n";
+ sync_script += " initial=$(grep 'Track Count' \"$stats\" | cut -b 14-)\n";
+ sync_script += " count=$(grep -c '^.*$' '" + fuse_mount_point + "/" + filename_add + "')\n";
+ sync_script += " touch " + fuse_mount_point + "/" + filename_sync_do + " >& /dev/null &\n";
+ sync_script += " sleep 0.2\n";
+ sync_script += " while [ 1 ]; do\n";
+ sync_script += " current=$(grep 'Track Count' \"$stats\" | cut -b 14-)\n";
+ sync_script += " file=$(grep 'Currently Syncing' \"$stats\")\n";
+ sync_script += " if [ $? != 0 ]; then break; fi\n";
+ sync_script += " clear && echo $file && echo Track $[$current-$initial] of \"$count\" && sleep 0.2\n";
+ sync_script += " done\n";
+ sync_script += "elif [ $# = 0 ]; then touch " + fuse_mount_point + "/" + filename_sync_do + " >& /dev/null\n";
+ sync_script += "else echo USAGE: $0 '[ -watch ]'\n";
+ sync_script += "fi\n";
sync_script += "echo Finished syncing iPod\n";

sync_ipod->size = sync_script.length ();
fusepod->root->addChild (*sync_ipod);

+ NodeValue * add_files = new NodeValue (fusepod_get_string (filename_add_files.c_str ()), S_IFREG | 0555);
+
+ /* Make Recursive Directory Add script */
+ add_files_script = "#!/bin/sh\n";
+ add_files_script += "#FUSEPod Recursive Directory Add\n";
+ add_files_script += "if [ $# = 0 ]; then echo \"USAGE: $0 [ file or directory ] ...\"; exit 1; fi\n";
+ add_files_script += "for file in \"$@\"; do\n";
+ add_files_script += " echo $file | grep ^/ &> /dev/null\n";
+ add_files_script += " if [ $? != 0 ]; then file=$PWD/$file; fi\n";
+ add_files_script += " find \"$file\" | egrep -i '(wav|mp3|m4a)$' >> '" + fuse_mount_point + "/" + filename_add + "'\n";
+ add_files_script += "done\n";
+
+ add_files->size = add_files_script.length ();
+ fusepod->root->addChild (*add_files);
+
+ /* Add statistics file */
+ NodeValue * stats = new NodeValue (fusepod_get_string (filename_stats.c_str ()), S_IFREG | 0444);
+ fusepod->root->addChild (*stats);
+
cout << "Starting FUSE layer" << endl;

return 0;
@@ -347,7 +459,7 @@
int main (int argc, char **argv) {

if (argc > 1) {
- /* This finds out were the mount point so that any app can use it.
+ /* This finds out were the mount point is so that any app can use it.
Note that it may contain ../ and ./ in it */
fuse_mount_point = argv [1];
if (fuse_mount_point [0] != '/')
@@ -357,30 +469,51 @@
Check for help option. If not found and ipod cannot be found, exit.*/
bool found = false;
for (int i = 1; i < argc && !found; i++)
- if (strcmp (argv [i], "--help") == 0)
+ if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0)
found = true;

if (!found && FUSEPod::discover_ipod () == "") {
cerr << "ERROR: Cannot find the iPod mount point.\n";
+ cerr << "This may happen because the iPod is not mounted or you have not created an itunes database yet\n";
cerr << "Please specifiy the mount point through the enviroment variable IPOD_DIR\n";
cerr << "Eg: IPOD_DIR=\"/media/ipod\" fusepod /home/keegan/myipod\n";
cerr << flush;
exit (1);
}
+
+ if (!found && getenv ("IPOD_DIR") && FUSEPod::discover_ipod () == getenv ("IPOD_DIR") &&
+ access ( (string (getenv ("IPOD_DIR")) + ITUNESDB_PATH).c_str (), F_OK ) != 0) { // Checks for itunesdb
+ cerr << "ERROR: Cannot find the iTunesDB in the directory specified by the IPOD_DIR environment variable.\n";
+ cerr << "Do you want to create the iTunesDB in the specified directory? (y/n): ";
+
+ char ans;
+ cin >> ans;
+ if (ans != 'y') {
+ cerr << "\nCannot run FUSEPod without iTunesDB.\nExiting...\n";
+ exit (1);
+ }
+
+ if (!FUSEPod::create_itunes_dirs (string (getenv ("IPOD_DIR")))) {
+ cerr << "\nERROR: Cannot create iTunesDB directory structure.\n";
+ cerr << "Exiting...\n";
+ exit (1);
+ }
+ }
}

- fusepod_oper.getattr = fusepod_getattr;
- fusepod_oper.access = fusepod_access;
- fusepod_oper.readdir = fusepod_readdir;
- fusepod_oper.open = fusepod_open;
- fusepod_oper.truncate= fusepod_truncate;
- fusepod_oper.write = fusepod_write;
- fusepod_oper.read = fusepod_read;
- fusepod_oper.unlink = fusepod_unlink;
- fusepod_oper.statfs = fusepod_statfs;
- fusepod_oper.mknod = fusepod_mknod;
- fusepod_oper.init = fusepod_init;
- fusepod_oper.destroy = fusepod_destroy;
+ fusepod_oper.getattr = fusepod_getattr;
+ fusepod_oper.access = fusepod_access;
+ fusepod_oper.readdir = fusepod_readdir;
+ fusepod_oper.open = fusepod_open;
+ fusepod_oper.truncate = fusepod_truncate;
+ fusepod_oper.write = fusepod_write;
+ fusepod_oper.read = fusepod_read;
+ fusepod_oper.unlink = fusepod_unlink;
+ fusepod_oper.statfs = fusepod_statfs;
+ fusepod_oper.mknod = fusepod_mknod;
+ fusepod_oper.rmdir = fusepod_rmdir;
+ fusepod_oper.init = fusepod_init;
+ fusepod_oper.destroy = fusepod_destroy;

return fuse_main(argc, argv, &fusepod_oper);
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/fusepod_constants.h new/fusepod-0.4/src/fusepod_constants.h
--- old/fusepod-0.3/src/fusepod_constants.h 2006-04-08 22:51:06.000000000 +0200
+++ new/fusepod-0.4/src/fusepod_constants.h 2006-06-11 00:51:05.000000000 +0200
@@ -21,11 +21,13 @@
#include <string>

const mode_t MODE_DIR = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH);
-const mode_t MODE_FILE = (S_IFREG | S_IRUSR | S_IRGRP | S_IROTH);
+const mode_t MODE_FILE = (S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH);

const std::string filename_add = "add_songs";
+const std::string filename_add_files = "add_files.sh";
const std::string filename_sync = "sync_ipod.sh";
const std::string filename_sync_do = "sync-ipod-now";
+const std::string filename_stats = "statistics";

const std::string dir_playlists = "Playlists";
const std::string playlist_track_format = "%a - %t.%e";
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/fusepod_ipod.cpp new/fusepod-0.4/src/fusepod_ipod.cpp
--- old/fusepod-0.3/src/fusepod_ipod.cpp 2006-04-10 02:14:55.000000000 +0200
+++ new/fusepod-0.4/src/fusepod_ipod.cpp 2006-06-10 00:21:21.000000000 +0200
@@ -19,6 +19,7 @@
#include <ipod/ipod_constants.h>
#include <iostream>
#include <fstream>
+#include <sstream>
#include <cstdlib>
#include <cstring>

@@ -54,6 +55,7 @@
FUSEPod::FUSEPod (const string & mount_point, vector<string> paths_descs) {
this->mount_point = mount_point;
this->paths_descs = paths_descs;
+ this->syncing = false;

char * text = new char [1];
text [0] = 0;
@@ -93,17 +95,60 @@
return "";
}

+bool FUSEPod::create_itunes_dirs (const string & dir) {
+ if (dir.length () < 1)
+ return false;
+
+ if (access (dir.c_str (), W_OK) != 0)
+ return false;
+
+ string base = dir;
+ if (dir[dir.length ()-1] != '/')
+ base += '/';
+
+ string control = base + "iPod_Control";
+ if (access (control.c_str (), F_OK) != 0 && mkdir (control.c_str (), 0777) != 0)
+ return false;
+
+ string itunes = control + "/iTunes";
+ if (access (itunes.c_str (), F_OK) != 0 && mkdir (itunes.c_str (), 0777) != 0)
+ return false;
+
+ string music = control + "/Music";
+ if (access (music.c_str (), F_OK) != 0 && mkdir (music.c_str (), 0777) != 0)
+ return false;
+
+ for (int i = 0; i < 20; i++) {
+ string music_dir = music + "/F";
+ if (i < 10) //I need sprintf
+ music_dir += string ("0") + (char)(i+'0');
+ else
+ music_dir += string ("1") + (char)((i%10) + '0');
+
+ if (access (music_dir.c_str (), F_OK) != 0 && mkdir (music_dir.c_str (), 0777) != 0)
+ return false;
+ }
+
+ return true;
+}
+
void FUSEPod::upload_song (const string & path) {
IPodTrack track (*ipod, path);
}

-void FUSEPod::remove_song (uint32_t song_id) {
+bool FUSEPod::remove_song (const string & path) {
+ string real_path = this->get_real_path (path);
+
+ if (real_path == "" or
+ access (real_path.c_str (), W_OK) != 0)
+ return false;
+
+ uint32_t song_id = this->get_node (path.c_str ())->value.id;
IPodTrack track = ipod->TrackByTrackID (song_id);

for (size_t i = 0; i < paths_descs.size (); i++)
remove_track (track, paths_descs [i]);

-
/* TODO There has to be a better way than this to remove the track
* from the playlists. */
Node * pnode = get_node (dir_playlists.c_str ());
@@ -117,12 +162,42 @@
}

track.Remove ();
+
+ return true;
}

-void FUSEPod::flush () {
+void FUSEPod::remove_playlist (const string & name) {
+ for (unsigned long i = 0; i < ipod->PlaylistCount (); i++) {
+ IPodPlaylist playlist = ipod->PlaylistByIndex (i);
+
+ if (playlist.GetAttribute (IPOD_PLAYLIST_HIDDEN))
+ continue;
+
+ const char * pname = fusepod_get_string (fusepod_check_string (playlist.GetText (IPOD_TITLE)).c_str ());
+
+ if (name != pname)
+ continue;
+
+ Node * node = this->get_node ((dir_playlists + "/" + name).c_str ());
+ node->parent->children.erase (node);
+ delete node;
+
+ playlist.Remove ();
+ break;
+ }
+}
+
+bool FUSEPod::flush () {
+ if (this->syncing)
+ return false;
+
+ this->syncing = true;
ipod->Flush ();
add_playlists ();
add_all_tracks ();
+ this->syncing = false;
+
+ return true;
}

Node * FUSEPod::get_node (const char * path) {
@@ -140,6 +215,29 @@
return cur;
}

+string FUSEPod::get_real_path (const NodeValue & nv) {
+ return this->ipod->TrackByTrackID (nv.id).GetText (IPOD_FULL_PATH);
+}
+
+string FUSEPod::get_real_path (const string & path) {
+ Node * node = this->get_node (path.c_str ());
+
+ if (node == 0 || !S_ISREG (node->value.mode))
+ return "";
+
+ return this->ipod->TrackByTrackID (node->value.id).GetText (IPOD_FULL_PATH);
+}
+
+string FUSEPod::get_statistics () {
+ using std::endl;
+ std::ostringstream stats;
+ stats << "FUSEPod Version: " << PACKAGE_VERSION << endl;
+ stats << "ITunesDB Version: " << this->ipod->Version () << endl;
+ stats << "Track Count: " << this->ipod->TrackCount () << endl;
+ stats << "Playlist Count: " << this->ipod->PlaylistCount () << endl;
+ return stats.str ();
+}
+
string FUSEPod::int_to_string (int i) {
char tmp [10];
i %= 1000000000;
@@ -254,6 +352,9 @@

for (unsigned long i = 0; i < ipod->PlaylistCount (); i++) {
IPodPlaylist playlist = ipod->PlaylistByIndex (i);
+
+ if (playlist.GetAttribute(IPOD_PLAYLIST_HIDDEN))
+ continue;

const char * pname = fusepod_get_string (fusepod_check_string (playlist.GetText (IPOD_TITLE)).c_str ());
NodeValue nv (pname, MODE_DIR);
@@ -263,7 +364,7 @@

size_t pos_len = 1;
int tmp = playlist.TrackItemCount ();
- while ((tmp /= 10) > 0)
+ while ((tmp /= 10) > 0) //For padding track number with 0's
pos_len++;

for (unsigned long a = 0; a < playlist.TrackItemCount (); a++) {
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/fusepod_ipod.h new/fusepod-0.4/src/fusepod_ipod.h
--- old/fusepod-0.3/src/fusepod_ipod.h 2006-04-10 01:32:32.000000000 +0200
+++ new/fusepod-0.4/src/fusepod_ipod.h 2006-06-10 00:21:10.000000000 +0200
@@ -15,7 +15,8 @@
#ifndef _FUSEPOD_IPOD_H_
#define _FUSEPOD_IPOD_H_

-#include <ipod/ipod_cpp.h>
+#include "ipod/ipod_cpp.h"
+#include "ipod/ipod_constants.h"
#include <string>
#include <cstring>
#include <set>
@@ -39,6 +40,11 @@
off_t size;
};

+/**
+ * The filesystem is kept in a tree. This is the node class, which is used for
+ * each file/directory in the filesystem. It stores the NodeValue, parent node
+ * and the child nodes (for directories).
+ */
class Node {
struct nodecomp {
bool operator () (const Node * a, const Node * b) {
@@ -54,7 +60,21 @@
typedef set<Node*, nodecomp>::iterator iterator;

/* Methods */
+
+ /**
+ * Searches the node's children.
+ * The is method will return the node with matching NodeValue.text
+ * If no node is found, the null pointer is returned.
+ */
Node * find (const NodeValue&);
+
+ /**
+ * Adds a new Node as a child.
+ * The new Node's value will be the value of the passed NodeValue.
+ * This method returns the added Node.
+ * If find (NodeValue) != 0; then this method will not add the child
+ * and will return the null pointer.
+ */
Node * addChild (const NodeValue&);
bool isLeaf () { return children.size () == 0; }
iterator begin () { return children.begin (); }
@@ -72,6 +92,9 @@
set<Node*, nodecomp> children;
};

+/**
+ * Abstracts iPod API and takes care of the virtual filesystem.
+ */
class FUSEPod {
public:
FUSEPod (const string & mount_point, vector<string> path_descs);
@@ -85,6 +108,13 @@
* @return A string pointing to an iPod directory.
*/
static string discover_ipod ();
+
+ /**
+ * This method will create the file layout necessary file libipod to create and sync the ITunesDB
+ * @param dir The directory to create the folders in.
+ * @return true on success
+ */
+ static bool create_itunes_dirs (const string & dir);

/**
* This function will upload a song to the iPod.
@@ -93,18 +123,44 @@

/**
* This function will remove a song from the FUSEPod filesystem.
- * This function will also call remove the song from the in
- * memory ITunesDB and remove the song from the iPod.
+ * This function will also remove the song from the inmemory
+ * ITunesDB and remove the song from the iPod.
+ * @return true if the operation was successful
+ */
+ bool remove_song (const string & path);
+
+ /**
+ * Removes a playlist from the FUSEPod filesystem aswell as the
+ * inmemory ITunesDB.
*/
- void remove_song (uint32_t song_id);
+ void remove_playlist (const string & name);

/**
* This will flush the iPod and update the FUSEPod filesystem layout.
+ * @return false if currently syncing
*/
- void flush ();
+ bool flush ();

+ /**
+ * Returns the node corresponding to the path, or the null pointer.
+ */
Node * get_node (const char * path);

+ /**
+ * Returns the real path of a song.
+ * This is the path to the song on the mounted iPod.
+ * @return An absolute path to the real file, or an empty string
+ */
+ string get_real_path (const NodeValue & nv);
+ string get_real_path (const string & path);
+
+ /**
+ * This method will returns a string with various statistics.
+ * This method is meant for use as a /proc like file.
+ * @return A multiline string with various statistics
+ */
+ string get_statistics ();
+
IPod * ipod;
Node * root;
string mount_point;
@@ -120,6 +176,8 @@
vector<string> paths_descs;
void add_playlists ();
void add_all_tracks ();
+ bool syncing;
+ string syncing_file;
};

#endif
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/ipod/ipod.c new/fusepod-0.4/src/ipod/ipod.c
--- old/fusepod-0.3/src/ipod/ipod.c 2006-02-27 22:15:31.000000000 +0100
+++ new/fusepod-0.4/src/ipod/ipod.c 2006-06-03 14:50:02.000000000 +0200
@@ -434,7 +434,7 @@
int i,dirNum;
char name[] = "XXXX";
char dirName[] = "F00";
-
+
dirNum = random() % dirCount;
for (i=0;i<4;i++)
name[i] = 'A'+(random() % 26);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/ipod/ipod_track_add.c new/fusepod-0.4/src/ipod/ipod_track_add.c
--- old/fusepod-0.3/src/ipod/ipod_track_add.c 2006-02-27 22:15:31.000000000 +0100
+++ new/fusepod-0.4/src/ipod/ipod_track_add.c 2006-05-27 15:39:39.000000000 +0200
@@ -94,6 +94,7 @@

ipod_track_t ipod_track_add_from(ipod_t ipod, const char *filePath)
{
+ printf ("123%s\n", filePath);fflush(stdout);
const char *extension = ipod_extension_of(filePath,".mp3");
if (!strcmp(extension,".mp3"))
return ipod_track_add_from_mp3(ipod,filePath);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/fusepod-0.3/src/ipod/ipod_track_from_mp3.c new/fusepod-0.4/src/ipod/ipod_track_from_mp3.c
--- old/fusepod-0.3/src/ipod/ipod_track_from_mp3.c 2006-02-27 22:15:31.000000000 +0100
+++ new/fusepod-0.4/src/ipod/ipod_track_from_mp3.c 2006-05-27 15:19:33.000000000 +0200
@@ -409,6 +409,8 @@
frame_types[bit_rate_index]++;
bit_rate = ipod_mp3_bit_rates[version][3-layer][bit_rate_index]*1000;
sample_rate = ipod_mp3_sample_rates[version][sample_rate_index];
+ if (sample_rate == 0) // Stupid fix. This happens with bad id3 tags.
+ break;
if (layer==IPOD_MPEG_LAYER_1)
frame_length = (12*bit_rate/sample_rate+padding)*4;
else
@@ -439,6 +441,8 @@
}
bit_rate = total_rate/frame_count;
//printf("bit_rate %d\n",bit_rate);
+ if (sample_rate == 0) // Stupid fix.
+ sample_rate = 1;
duration = duration/sample_rate*1000;
//printf("duration %d\n",duration);
ipod_track_set_attribute(track,IPOD_TRACK_SIZE,total_length);


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...


---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit-unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-commit-help@xxxxxxxxxxxx

< Previous Next >
This Thread