Bug 131487 - Support for iTunes mobile - REQUEST
Summary: Support for iTunes mobile - REQUEST
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Collections/iPod iPhone (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-28 21:06 UTC by Alphamerik
Modified: 2011-12-20 11:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alphamerik 2006-07-28 21:06:59 UTC
Version:           1.4-svn (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages
Compiler:          GNU 
OS:                Linux

In future releases of Amarok can we have support for iTunes Mobile?  (For those wondering, iTunes mobile is simply  iTunes on a mobile device, like a cell phone.)

This is generally a very easy request to implement (it is already implemented in gtkPod).  It requires the development version of libgpod.  Everything about iTunes mobile is identical to the iPod except for the directory structure (iTunes/iTunes_Control vs iPod_Control).  I have verified this is indeed a trivial request by creating my own "iTunes Mobile" MediaDevice.

Many thanks for this great product!
Comment 1 Martin Aumueller 2006-07-29 15:26:33 UTC
This sounds indeed like a reasonable wish. Will have a look at it some time soon.
Comment 2 Martin Aumueller 2006-08-03 09:04:06 UTC
Please test with the ipod plugin from svn - i can't as i don't have an itunes phone.
Comment 3 Martin Aumueller 2006-08-03 09:11:29 UTC
SVN commit 569229 by aumuell:

support for using the ipod plugin with itunes phones
- however initializing will not work because of the changed directory structure
BUG: 131487


 M  +1 -0      ChangeLog  
 M  +2 -1      README  
 M  +23 -10    src/mediadevice/ipod/ipodmediadevice.cpp  
 M  +1 -0      src/mediadevice/ipod/ipodmediadevice.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #569228:569229
@@ -7,6 +7,7 @@
 
 VERSION 1.4.2:
   FEATURES:
+    * iPod plugin usable with iTunes phones. (BR 131487)
     * Browse collection by composer. (BR 122452)
     * New DCOP call "playlist: filenames" returns the filenames of the songs
       currently in the playlist. Patch by Arash Abedinzadeh
--- trunk/extragear/multimedia/amarok/README #569228:569229
@@ -101,9 +101,10 @@
       (CD burning support)
       http://www.k3b.org
 
-    * libgpod 0.3.2
+    * libgpod 0.3.2 or newer
       (iPod support)
       http://www.gtkpod.org/libgpod.html
+      (libgpod from CVS is recommended because of many bug fixes)
 
     * libifp 1.0.0.2
       (iRiver iFP support)
--- trunk/extragear/multimedia/amarok/src/mediadevice/ipod/ipodmediadevice.cpp #569228:569229
@@ -764,7 +764,7 @@
 IpodMediaDevice::createLockFile( bool silent )
 {
     QString lockFilePath;
-    pathExists( ":iPod_Control:iTunes:iTunesLock", &lockFilePath );
+    pathExists( itunesDir( "iTunes:iTunesLock" ), &lockFilePath );
     m_lockFile = new QFile( lockFilePath );
     QString msg;
     bool ok = true;
@@ -839,7 +839,7 @@
     itdb_playlist_add(m_itdb, mpl, 0);
 
     QString realPath;
-    if(!pathExists(":iPod_Control", &realPath) )
+    if(!pathExists( itunesDir(), &realPath) )
     {
         dir.setPath(realPath);
         dir.mkdir(dir.absPath());
@@ -847,7 +847,7 @@
     if(!dir.exists())
         return false;
 
-    if(!pathExists(":iPod_Control:Music", &realPath) )
+    if(!pathExists( itunesDir( "Music" ), &realPath) )
     {
         dir.setPath(realPath);
         dir.mkdir(dir.absPath());
@@ -855,7 +855,7 @@
     if(!dir.exists())
         return false;
 
-    if(!pathExists(":iPod_Control:iTunes", &realPath) )
+    if(!pathExists( itunesDir( "iTunes" ), &realPath) )
     {
         dir.setPath(realPath);
         dir.mkdir(dir.absPath());
@@ -1045,7 +1045,7 @@
     {
         QString real;
         QString ipod;
-        ipod.sprintf( ":iPod_Control:Music:f%02d", i );
+        ipod.sprintf( itunesDir( "Music:f%02d" ).latin1(), i );
         if(!pathExists( ipod, &real ) )
         {
             QDir dir( real );
@@ -1142,7 +1142,8 @@
         cur = cur->next;
     }
 
-    QString musicpath = QString(itdb_get_mountpoint(m_itdb)) + "/iPod_Control/Music";
+    QString musicpath;
+    pathExists( itunesDir( "Music" ), &musicpath );
     QDir dir( musicpath, QString::null, QDir::Unsorted, QDir::Dirs );
     for(unsigned i=0; i<dir.count(); i++)
     {
@@ -1154,7 +1155,7 @@
         for(unsigned j=0; j<hashdir.count(); j++)
         {
             QString filename = hashpath + "/" + hashdir[j];
-            QString ipodPath = ":iPod_Control:Music:" + dir[i] + ":" + hashdir[j];
+            QString ipodPath = itunesDir( "Music:" ) + dir[i] + ":" + hashdir[j];
             Itdb_Track *track = m_files[ipodPath.lower()];
             if(!track)
             {
@@ -1425,6 +1426,18 @@
 }
 
 QString
+IpodMediaDevice::itunesDir(const QString &p) const
+{
+    QString base( ":iPod_Control" );
+    if( m_isMobile )
+        base = ":iTunes:iTunes_Control";
+
+    if( !p.startsWith( ":" ) )
+        base += ":";
+    return base + p;
+}
+
+QString
 IpodMediaDevice::realPath(const char *ipodPath)
 {
     QString path;
@@ -1726,7 +1739,7 @@
         int music_dirs = itdb_musicdirs_number(m_itdb) > 0 ? itdb_musicdirs_number(m_itdb) : 20;
         int dir = num % music_dirs;
         QString dirname;
-        dirname.sprintf( ":iPod_Control:Music:f%02d", dir );
+        dirname.sprintf( "%s:Music:f%02d", itunesDir().latin1(), dir );
         if( !pathExists( dirname ) )
         {
             QString realdir = realPath(dirname.latin1());
@@ -1788,8 +1801,8 @@
         return false;
 
 #ifdef HAVE_STATVFS
-    QString path = QFile::decodeName(itdb_get_mountpoint(m_itdb));
-    path.append("/iPod_Control");
+    QString path;
+    pathExists( itunesDir(), &path );
     struct statvfs buf;
     if(statvfs(QFile::encodeName(path), &buf) != 0)
     {
--- trunk/extragear/multimedia/amarok/src/mediadevice/ipod/ipodmediadevice.h #569228:569229
@@ -100,6 +100,7 @@
         void              addPlaylistToView( Itdb_Playlist *playlist );
         void              playlistFromItem( IpodMediaItem *item );
 
+        QString           itunesDir( const QString &path = QString::null ) const;
         QString           realPath( const char *ipodPath );
         QString           ipodPath( const QString &realPath );
         bool              pathExists( const QString &ipodPath, QString *realPath=0 );
Comment 4 Alphamerik 2006-08-05 06:24:03 UTC
Thank you very much!

There was a small problem getting this to work correctly, which I have detailed in Bug 131910.  (should have reopened the bug, apologies)