Index: amarok/amarok.kdevelop
===================================================================
--- amarok/amarok.kdevelop	(revision 554563)
+++ amarok/amarok.kdevelop	(working copy)
@@ -11,8 +11,8 @@
     </keywords>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <version/>
-    <description/>
+    <version></version>
+    <description></description>
     <ignoreparts/>
     <secondaryLanguages/>
     <versioncontrol/>
@@ -87,7 +87,7 @@
       <hidenonlocation>false</hidenonlocation>
     </groups>
     <tree>
-      <hidenonprojectfiles>false</hidenonprojectfiles>
+      <hidenonprojectfiles>true</hidenonprojectfiles>
       <hidepatterns>*.o,*.lo,CVS</hidepatterns>
       <showvcsfields>true</showvcsfields>
     </tree>
@@ -112,15 +112,15 @@
   <kdevdebugger>
     <general>
       <dbgshell>/usr/bin/libtool</dbgshell>
-      <programargs/>
-      <gdbpath/>
+      <programargs></programargs>
+      <gdbpath></gdbpath>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
       <runappinappdirectory>true</runappinappdirectory>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
     </general>
     <display>
       <staticmembers>false</staticmembers>
@@ -130,7 +130,11 @@
   </kdevdebugger>
   <kdevfilecreate>
     <filetypes/>
-    <useglobaltypes/>
+    <useglobaltypes>
+      <type ext="ui" />
+      <type ext="cpp" />
+      <type ext="h" />
+    </useglobaltypes>
   </kdevfilecreate>
   <cppsupportpart>
     <filetemplates>
@@ -147,7 +151,7 @@
       <includeGlobalFunctions>true</includeGlobalFunctions>
       <includeTypes>true</includeTypes>
       <includeEnums>true</includeEnums>
-      <includeTypedefs>false</includeTypedefs>
+      <includeTypedefs>true</includeTypedefs>
       <automaticCodeCompletion>true</automaticCodeCompletion>
       <automaticArgumentsHint>true</automaticArgumentsHint>
       <codeCompletionDelay>250</codeCompletionDelay>
@@ -157,7 +161,7 @@
     </codecompletion>
     <references/>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
@@ -169,6 +173,9 @@
       <version>3</version>
       <root>/home/kde-dev/kde-svn/branches/qt/3.3/qt-copy</root>
     </qt>
+    <designerintegration>
+      <qtdesigner/>
+    </designerintegration>
   </kdevcppsupport>
   <kdevclassview>
     <folderhierarchy>true</folderhierarchy>
Index: amarok/src/mediadevice/generic/genericmediadevice.h
===================================================================
--- amarok/src/mediadevice/generic/genericmediadevice.h	(revision 554563)
+++ amarok/src/mediadevice/generic/genericmediadevice.h	(working copy)
@@ -29,7 +29,10 @@
 
 class GenericMediaItem;
 class GenericMediaFile;
+class GenericMediaDeviceConfigDialog;
 
+class QStringList;
+
 typedef QMap<QString, GenericMediaFile*> MediaFileMap;
 typedef QMap<GenericMediaItem*, GenericMediaFile*> MediaItemMap;
 
@@ -37,6 +40,8 @@
 {
     Q_OBJECT
 
+    friend  class GenericMediaDeviceConfigDialog;
+
     public:
                           GenericMediaDevice();
         void              init( MediaBrowser* parent );
@@ -46,11 +51,15 @@
 
         void              rmbPressed( QListViewItem* qitem, const QPoint& point, int );
 
-        bool              hasTransferDialog() { return true; }
-        void              runTransferDialog();
-        TransferDialog   *getTransferDialog() { return m_td; }
+        QStringList       supportedFiletypes() { return m_supportedFileTypes; }
+        bool              isPlayable( const MetaBundle& bundle );
+        bool              isPreferredFormat( const MetaBundle &bundle );
 
         bool              needsManualConfig() { return false; }
+        void              addConfigElements( QWidget * parent );
+        void              removeConfigElements( QWidget * /* parent */);
+
+        void              applyConfig();
         void              loadConfig();
 
         MediaFileMap     &getFileMap() { return m_mfm; }
@@ -99,6 +108,9 @@
 
         MediaItem        *trackExists( const MetaBundle& );
 
+        QString           buildDestination( const QString &format, const MetaBundle &mb );
+        void              checkAndBuildLocation( const QString& location );
+
         KURL::List        getSelectedItems();
         void              downloadSelectedItems();
         void              copyTrackSortHelper( const MetaBundle& bundle, QString& sort, QString& base );
@@ -115,14 +127,20 @@
 
         KDirLister        *m_dirLister;
 
-        TransferDialog    *m_td;
         bool              m_actuallyVfat;
         bool              m_dirListerComplete;
         bool              m_connected;
         KURL::List        m_downloadList;
         MediaFileMap      m_mfm;
         MediaItemMap      m_mim;
+
+        QStringList       m_supportedFileTypes;
+        QString           m_songLocation;
+        QString           m_podcastLocation;
+        bool              m_asciiTextOnly;
+        bool              m_ignoreThePrefix;
+
+        GenericMediaDeviceConfigDialog *m_configDialog;
 };
 
 #endif /*AMAROK_GENERICMEDIADEVICE_H*/
-
Index: amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui.h
===================================================================
--- amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui.h	(revision 0)
+++ amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui.h	(revision 0)
@@ -0,0 +1,295 @@
+/// Configuration Dialog Extension slots
+
+void
+GenericMediaDeviceConfigDialog::addSupportedButtonClicked( int id )
+{
+    QPopupMenu *unsupported = m_addSupportedButton->popup();
+    QComboBox *convert     = m_convertComboBox;
+    QListBox  *supported   = m_supportedListBox;
+
+    supported->insertItem( unsupported->text( id ) );
+
+    QString temp = convert->currentText();
+    convert->insertItem( unsupported->text( id ) );
+
+    unsupported->removeItem( id );
+
+    supported->sort();
+    convert->listBox()->sort();
+
+    convert->setCurrentText( temp );
+}
+
+
+void
+GenericMediaDeviceConfigDialog::removeSupportedButtonClicked()
+{
+    QStringList unsupported;
+
+    QComboBox *convert     = m_convertComboBox;
+    QListBox  *supported   = m_supportedListBox;
+
+    for( int i = 0; i < m_addSupportedButton->popup()->count(); i++ )
+    {
+        int id = m_addSupportedButton->popup()->idAt( i );
+        unsupported.append( m_addSupportedButton->popup()->text( id ) );
+    }
+
+    for( uint i = 0; i < supported->count() ; /* nothing */)
+    {
+        QListBoxItem *item = supported->item( i );
+
+        if( item->isSelected() )
+        {
+            QString temp;
+
+            unsupported.append( item->text() );
+
+            temp = convert->currentText();
+
+            convert->setCurrentText( item->text() );
+            convert->removeItem( convert->currentItem() );
+
+            if( temp == item->text() )
+                convert->setCurrentItem( 0 );
+            else
+                convert->setCurrentText( temp );
+
+            item = 0;
+            supported->removeItem( i );
+
+            continue;
+        }
+
+        i++;
+    }
+
+    // at least support mp3 format.
+    if( supported->count() <= 0 )
+    {
+        supported->insertItem( "mp3" );
+        convert->insertItem( "mp3" );
+        convert->setCurrentItem( 0 );
+        unsupported.remove( "mp3" );
+    }
+
+    unsupported.sort();
+    m_addSupportedButton->popup()->clear();
+    for( QStringList::Iterator it = unsupported.begin(); it != unsupported.end(); it++ )
+    {
+        m_addSupportedButton->popup()->insertItem( *it );
+    }
+}
+
+
+void
+GenericMediaDeviceConfigDialog::supportedListBoxDoubleClicked( QListBoxItem* item )
+{
+    m_convertComboBox->setCurrentText( item->text() );
+}
+
+
+
+
+void
+GenericMediaDeviceConfigDialog::updateConfigDialogLists( const QStringList & supportedFileTypes )
+{
+    QStringList allTypes;
+    allTypes << "mp3" << "ogg" << "wma" << "mp4" << "aac" << "m4a" << "ac3";
+    allTypes << "wav" << "flac" << "asf" << "asx" << "mpg" << "mp4v" << "mpeg";
+    allTypes << "aa" << "3gp" << "mp2";
+
+    QStringList unsupported;
+    QComboBox *convert      = m_convertComboBox;
+    QListBox  *supported    = m_supportedListBox;
+
+    for( QStringList::Iterator it = allTypes.begin(); it != allTypes.end(); it++ )
+    {
+        if( supportedFileTypes.contains( *it ) )
+        {
+            supported->insertItem( *it );
+            convert->insertItem( *it );
+        }
+        else
+        {
+            unsupported.append( *it );
+        }
+    }
+
+    supported->sort();
+    unsupported.sort();
+
+    m_addSupportedButton->popup()->clear();
+
+    for( QStringList::Iterator it = unsupported.begin(); it != unsupported.end(); it++ )
+    {
+        m_addSupportedButton->popup()->insertItem( *it );
+    }
+    convert->listBox()->sort();
+    convert->setCurrentText( supportedFileTypes.first() );
+}
+
+QString
+GenericMediaDeviceConfigDialog::buildDestination( const QString &format, const MetaBundle &mb ) const
+{
+    bool isCompilation = mb.compilation() > 0;
+    QMap<QString, QString> args;
+    QString artist = mb.artist();
+    QString albumartist = artist;
+    if( isCompilation )
+        albumartist = i18n( "Various Artists" );
+    args["theartist"] = cleanPath( artist );
+    args["thealbumartist"] = cleanPath( albumartist );
+    if( m_ignoreTheCheck->isChecked() && artist.startsWith( "The " ) )
+        CollectionView::instance()->manipulateThe( artist, true );
+    artist = cleanPath( artist );
+    if( m_ignoreTheCheck->isChecked() && albumartist.startsWith( "The " ) )
+        CollectionView::instance()->manipulateThe( albumartist, true );
+
+    albumartist = cleanPath( albumartist );
+    for( int i = 0; i < MetaBundle::NUM_COLUMNS; i++ )
+    {
+        if( i == MetaBundle::Score || i == MetaBundle::PlayCount || i == MetaBundle::LastPlayed )
+            continue;
+        args[mb.exactColumnName( i ).lower()] = cleanPath( mb.prettyText( i ) );
+    }
+    args["artist"] = artist;
+    args["albumartist"] = albumartist;
+    args["initial"] = albumartist.mid( 0, 1 ).upper();
+    args["filetype"] = mb.url().path().section( ".", -1 ).lower();
+    QString track;
+    if ( mb.track() )
+        track.sprintf( "%02d", mb.track() );
+    args["track"] = track;
+
+    amaroK::QStringx formatx( format );
+    QString result = m_device->mountPoint().append( formatx.namedOptArgs( args ) );
+    QString tail = result.mid( m_device->mountPoint().length() );
+    if( !tail.startsWith( "/" ) )
+        tail.prepend( "/" );
+ 
+   return m_device->mountPoint() + tail.replace( QRegExp( "/\\.*" ), "/" );
+}
+
+QString GenericMediaDeviceConfigDialog::cleanPath( const QString &component ) const
+{
+    QString result = component;
+
+    if( m_asciiCheck->isChecked() )
+    {
+        result = amaroK::cleanPath(result, true /* replaces weird stuff by '_' */);
+    }
+
+    result.simplifyWhiteSpace();
+    if( m_spaceCheck->isChecked() )
+        result.replace( QRegExp( "\\s" ), "_" );
+    if( m_device->m_actuallyVfat )
+        result = amaroK::vfatPath( result );
+
+    result.replace( "/", "-" );
+
+    return result;
+}
+
+
+void
+GenericMediaDeviceConfigDialog::updatePreviewLabel()
+{
+    m_previewLabel->setText( buildDestination( m_songLocationBox->text(), *m_previewBundle ) );
+}
+
+void
+GenericMediaDeviceConfigDialog::updatePreviewLabel( const QString& format)
+{
+    m_previewLabel->setText( buildDestination( format , *m_previewBundle ) );
+}
+
+void
+GenericMediaDeviceConfigDialog::setDevice( GenericMediaDevice* device )
+{
+    m_device = device;
+    m_songLocationBox->setText( m_device->m_songLocation );
+    m_podcastLocationBox->setText( m_device->m_podcastLocation );
+
+    updatePreviewLabel( m_device->m_songLocation );
+
+    updateConfigDialogLists( m_device->m_supportedFileTypes );
+    m_asciiCheck->setChecked( m_device->m_asciiTextOnly );
+    m_spaceCheck->setChecked( m_device->m_spacesToUnderscores );
+    m_ignoreTheCheck->setChecked( m_device->m_ignoreThePrefix );
+}
+
+QString
+GenericMediaDeviceConfigDialog::buildFormatTip() const
+{
+    QMap<QString, QString> args;
+    for( int i = 0; i < MetaBundle::NUM_COLUMNS; i++ )
+    {
+        if( i == MetaBundle::Score || i == MetaBundle::PlayCount || i == MetaBundle::LastPlayed )
+            continue;
+        args[MetaBundle::exactColumnName( i ).lower()] = MetaBundle::prettyColumnName( i );
+    }
+    args["albumartist"] = i18n( "%1 or %2" ).arg( "Album Artist, The" , "The Album Artist" );
+    args["thealbumartist"] = "The Album Artist";
+    args["theartist"] = "The Artist";
+    args["artist"] = i18n( "%1 or %2" ).arg( "Artist, The" , "The Artist" );
+    args["initial"] = i18n( "Artist's Initial" );
+    args["filetype"] = i18n( "File Extension of Source" );
+    args["track"] = i18n( "Track Number" );
+
+    QString tooltip = i18n( "<h3>Custom Format String</h3>" );
+    tooltip += i18n( "You can use the following tokens:" );
+    tooltip += "<ul>";
+    for( QMap<QString, QString>::iterator it = args.begin();
+            it != args.end();
+            ++it )
+    {
+        tooltip += QString( "<li>%1 - %2" ).arg( it.data(), "%" + it.key() );
+    }
+    tooltip += "</ul>";
+
+    tooltip += i18n( "If you surround sections of text that contain a token with curly-braces, "
+            "that section will be hidden if the token is empty." );
+
+    return tooltip;
+}
+
+void
+GenericMediaDeviceConfigDialog::init()
+{
+    m_previewBundle = new MetaBundle();
+    m_previewBundle->setAlbum( AtomicString( "Some Album" ) );
+    m_previewBundle->setArtist( AtomicString( "The One Artist" ) );
+    m_previewBundle->setBitrate( 128 );
+    m_previewBundle->setComment( AtomicString( "Some Comment" ) );
+    m_previewBundle->setCompilation( 0 );
+    m_previewBundle->setComposer( AtomicString( "The One Composer" ) );
+    m_previewBundle->setDiscNumber( 1 );
+    m_previewBundle->setFileType( 2 );
+    m_previewBundle->setFilesize( 1003264 );
+    m_previewBundle->setGenre( AtomicString( "Some Genre" ) );
+    m_previewBundle->setLength( 193 );
+    m_previewBundle->setPlayCount( 2 );
+    m_previewBundle->setRating( 3 );
+    m_previewBundle->setSampleRate( 44100 );
+    m_previewBundle->setScore( 3 );
+    m_previewBundle->setTitle( AtomicString( "Some Title" ) );
+    m_previewBundle->setTrack( 7 );
+    m_previewBundle->setUrl( "/some%20directory/some%20file.mp3" );
+    m_previewBundle->setYear( 2006 );
+
+    m_formatHelp->setText( QString( "<a href='whatsthis:%1'>%2</a>" ).
+            arg( amaroK::escapeHTMLAttr( buildFormatTip() ), i18n( "(Help)" ) ) );
+
+    m_unsupportedMenu = new QPopupMenu( m_addSupportedButton, "unsupported" );
+
+    m_addSupportedButton->setPopup( m_unsupportedMenu );
+
+    connect( m_unsupportedMenu, SIGNAL( activated( int ) ), this, SLOT( addSupportedButtonClicked( int ) ) );
+}
+
+
+void GenericMediaDeviceConfigDialog::GenericMediaDeviceConfigDialog_destroyed( QObject * )
+{
+
+}
Index: amarok/src/mediadevice/generic/Makefile.am
===================================================================
--- amarok/src/mediadevice/generic/Makefile.am	(revision 554563)
+++ amarok/src/mediadevice/generic/Makefile.am	(working copy)
@@ -23,8 +23,10 @@
     $(all_libraries)
 
 libamarok_generic_mediadevice_la_SOURCES = \
+    genericmediadeviceconfigdialog.ui\
     genericmediadevice.cpp
 
 noinst_HEADERS = \
+    genericmediadeviceconfigdialog.ui.h\
     genericmediadevice.h
 
Index: amarok/src/mediadevice/generic/genericmediadevice.cpp
===================================================================
--- amarok/src/mediadevice/generic/genericmediadevice.cpp	(revision 554563)
+++ amarok/src/mediadevice/generic/genericmediadevice.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "playlist.h"
 #include "statusbar/statusbar.h"
 #include "transferdialog.h"
+#include "genericmediadeviceconfigdialog.h"
 
 #include <kapplication.h>
 #include <kconfig.h>           //download saveLocation
@@ -51,7 +52,12 @@
 #include <qcstring.h>
 #include <qfile.h>
 #include <qstringx.h>
+#include <qstringlist.h>
 
+#include <qcombobox.h>
+#include <qlistbox.h>
+#include <qlineedit.h>
+
 typedef QPtrList<GenericMediaFile> MediaFileList;
 typedef QPtrListIterator<GenericMediaFile> MediaFileListIterator;
 
@@ -304,14 +310,22 @@
 {
     DEBUG_BLOCK
     m_name = "Generic Audio Player";
-    m_td = 0;
     m_dirLister = new KDirLister();
-    m_dirLister->setNameFilter( "*.mp3 *.wav *.asf *.flac *.wma *.ogg *.aac *.m4a" );
+    m_dirLister->setNameFilter( "*.mp3 *.wav *.asf *.flac *.wma *.ogg *.aac *.m4a *.mp4 *.mp2 *.ac3" );
     m_dirLister->setAutoUpdate( false );
+
     m_spacesToUnderscores = false;
-    m_firstSort = "None";
-    m_secondSort = "None";
-    m_thirdSort = "None";
+    m_ignoreThePrefix = false;
+    m_asciiTextOnly = false;
+
+    m_songLocation = "";
+    m_podcastLocation = "";
+
+    m_supportedFileTypes.empty();
+
+    m_configDialog = 0;
+
+
     connect( m_dirLister, SIGNAL( newItems(const KFileItemList &) ), this, SLOT( newItems(const KFileItemList &) ) );
     connect( m_dirLister, SIGNAL( completed() ), this, SLOT( dirListerCompleted() ) );
     connect( m_dirLister, SIGNAL( clear() ), this, SLOT( dirListerClear() ) );
@@ -327,23 +341,58 @@
 
 GenericMediaDevice::~GenericMediaDevice()
 {
-    setConfigString( "firstGrouping"    , m_firstSort );
-    setConfigString( "secondGrouping"   , m_secondSort );
-    setConfigString( "thirdGrouping"    , m_thirdSort );
-    setConfigBool( "spacesToUnderscores", m_spacesToUnderscores );
+    applyConfig();
 
     closeDevice();
 }
 
 void
+GenericMediaDevice::applyConfig()
+{
+    if( m_configDialog != 0)
+    {
+        m_supportedFileTypes.clear();
+        for( uint i = 0; i < m_configDialog->m_supportedListBox->count(); i++ )
+        {
+            QString currentText = m_configDialog->m_supportedListBox->item( i )->text();
+
+            if( currentText == m_configDialog->m_convertComboBox->currentText() )
+                m_supportedFileTypes.prepend( currentText );
+            else
+                m_supportedFileTypes.append( currentText );
+        }
+
+        m_spacesToUnderscores = m_configDialog->m_spaceCheck->isChecked();
+        m_asciiTextOnly = m_configDialog->m_asciiCheck->isChecked();
+        m_ignoreThePrefix = m_configDialog->m_ignoreTheCheck->isChecked();
+
+        m_songLocation = m_configDialog->m_songLocationBox->text();
+        m_podcastLocation = m_configDialog->m_podcastLocationBox->text();
+    }
+
+
+    setConfigString( "songLocation"       , m_songLocation );
+    setConfigString( "podcastLocation"    , m_podcastLocation );
+    setConfigBool(   "spacesToUnderscores", m_spacesToUnderscores );
+    setConfigBool(   "ignoreThePrefix"    , m_ignoreThePrefix );
+    setConfigBool(   "asciiTextOnly"      , m_asciiTextOnly );
+    setConfigString( "supportedFiletypes" , m_supportedFileTypes.join( ", " ) );
+}
+
+
+void
 GenericMediaDevice::loadConfig()
 {
     MediaDevice::loadConfig();
 
-    m_spacesToUnderscores = configBool("spacesToUnderscores");
-    m_firstSort           = configString( "firstGrouping", "None" );
-    m_secondSort          = configString( "secondGrouping", "None" );
-    m_thirdSort           = configString( "thirdGrouping", "None" );
+    m_spacesToUnderscores = configBool( "spacesToUnderscores", false );
+    m_ignoreThePrefix = configBool( "ignoreThePrefix", false);
+    m_asciiTextOnly = configBool( "asciiTextOnly", false );
+
+    m_songLocation = configString( "songLocation", "/%artist/%album/%title.%filetype" );
+    m_podcastLocation = configString( "podcastLocation", "/podcasts/" );
+
+    m_supportedFileTypes = QStringList::split( ", ", configString( "supportedFiletypes", "mp3"), true);
 }
 
 bool
@@ -382,13 +431,6 @@
     return true;
 }
 
-void
-GenericMediaDevice::runTransferDialog()
-{
-    m_td = new TransferDialog( this );
-    m_td->exec();
-}
-
 /// Renaming
 
 void
@@ -491,44 +533,79 @@
 
 /// Uploading
 
+QString
+GenericMediaDevice::buildDestination( const QString &format, const MetaBundle &mb )
+{
+    bool isCompilation = mb.compilation() > 0;
+    QMap<QString, QString> args;
+    QString artist = mb.artist();
+    QString albumartist = artist;
+    if( isCompilation )
+        albumartist = i18n( "Various Artists" );
+    args["theartist"] = cleanPath( artist );
+    args["thealbumartist"] = cleanPath( albumartist );
+    if( m_ignoreThePrefix && artist.startsWith( "The " ) )
+        CollectionView::instance()->manipulateThe( artist, true );
+    artist = cleanPath( artist );
+    if( m_ignoreThePrefix && albumartist.startsWith( "The " ) )
+        CollectionView::instance()->manipulateThe( albumartist, true );
+
+    albumartist = cleanPath( albumartist );
+    for( int i = 0; i < MetaBundle::NUM_COLUMNS; i++ )
+    {
+        if( i == MetaBundle::Score || i == MetaBundle::PlayCount || i == MetaBundle::LastPlayed )
+            continue;
+        args[mb.exactColumnName( i ).lower()] = cleanPath( mb.prettyText( i ) );
+    }
+    args["artist"] = artist;
+    args["albumartist"] = albumartist;
+    args["initial"] = albumartist.mid( 0, 1 ).upper();
+    args["filetype"] = mb.url().path().section( ".", -1 ).lower();
+    QString track;
+    if ( mb.track() )
+        track.sprintf( "%02d", mb.track() );
+    args["track"] = track;
+
+    amaroK::QStringx formatx( format );
+    QString result = formatx.namedOptArgs( args );
+    if( !result.startsWith( "/" ) )
+        result.prepend( "/" );
+ 
+   return result.replace( QRegExp( "/\\.*" ), "/" );
+}
+
 void
-GenericMediaDevice::copyTrackSortHelper( const MetaBundle& bundle, QString& sort, QString& base )
+GenericMediaDevice::checkAndBuildLocation( const QString& location )
 {
-    if( sort != "None" )
+    for( int i = m_medium.mountPoint().contains( '/', false );
+         i < location.contains( '/', false );
+         i++ )
     {
-        QString temp = bundle.prettyText( bundle.columnIndex(sort) );
-        temp = ( temp == QString::null ? "Unknown" : cleanPath(temp) );
-        QString newBase = base + '/' + temp;
+        QString path = location.section( '/', 0, i );
+        KURL url( path );
 
-        if( !KIO::NetAccess::exists( KURL( newBase ), false, m_parent ) )
+        if( !KIO::NetAccess::exists( url, false, m_parent ) )
         {
             debug() << "directory does not exist, creating..." << endl;
-            if( !KIO::NetAccess::mkdir( KURL( QFile::encodeName( newBase ) ), m_view ) ) //failed
+            if( !KIO::NetAccess::mkdir(url, m_view ) ) //failed
             {
-                debug() << "Failed to create directory " << temp << endl;
+                debug() << "Failed to create directory " << url << endl;
                 return;
             }
         }
-        base = newBase;
     }
 }
 
-
 MediaItem *
 GenericMediaDevice::copyTrackToDevice( const MetaBundle& bundle )
 {
     if( !m_connected ) return 0;
 
-    QString  newFilenameSansBaseDir = fileName( bundle );
-    QString  base = m_transferDir;
+    QString  path = m_transferDir + buildDestination( m_songLocation, bundle);
 
-    copyTrackSortHelper( bundle, m_firstSort, base);
-    copyTrackSortHelper( bundle, m_secondSort, base);
-    copyTrackSortHelper( bundle, m_thirdSort, base);
+    checkAndBuildLocation( path );
 
-    QString  newFilename = base + '/' + newFilenameSansBaseDir;
-
-    const QCString dest = QFile::encodeName( newFilename );
+    const QCString dest = QFile::encodeName( path );
     const KURL desturl = KURL::fromPathOrURL( dest );
 
     //kapp->processEvents( 100 );
@@ -552,49 +629,28 @@
 GenericMediaDevice::trackExists( const MetaBundle& bundle )
 {
     QString key;
+    QString path = buildDestination( m_songLocation, bundle);
+    KURL url( path );
+    QStringList directories = QStringList::split( "/", url.directory(1,1), false );
+
     QListViewItem *it = view()->firstChild();
-    if( m_firstSort != "None")
+    for( QStringList::Iterator directory = directories.begin();
+         directory != directories.end();
+         directory++ )
     {
-        key = bundle.prettyText( bundle.columnIndex( m_firstSort ) );
-        key = cleanPath( ( key.isEmpty() ? "Unknown" : key ) );
+        key = *directory;
         while( it && it->text( 0 ) != key )
             it = it->nextSibling();
         if( !it )
             return 0;
         if( !it->childCount() )
-           expandItem( it );
+            expandItem( it );
         it = it->firstChild();
     }
 
-    if( m_secondSort != "None")
-    {
-        key = bundle.prettyText( bundle.columnIndex( m_secondSort ) );
-        key = cleanPath( ( key.isEmpty() ? "Unknown" : key ) );
-        while( it && it->text( 0 ) != key )
-        {
-            it = it->nextSibling();
-        }
-        if( !it )
-            return 0;
-        if( !it->childCount() )
-           expandItem( it );
-        it = it->firstChild();
-    }
+    key = url.fileName( true );
+    key = key.isEmpty() ? fileName( bundle ) : key;
 
-    if( m_thirdSort != "None")
-    {
-        key = bundle.prettyText( bundle.columnIndex( m_thirdSort ) );
-        key = cleanPath( ( key.isEmpty() ? "Unknown" : key ) );
-        while( it && it->text( 0 ) != key )
-            it = it->nextSibling();
-        if( !it )
-            return 0;
-        if( !it->childCount() )
-           expandItem( it );
-        it = it->firstChild();
-    }
-
-    key = fileName( bundle );
     while( it && it->text( 0 ) != key )
         it = it->nextSibling();
 
@@ -947,4 +1003,43 @@
     return result;
 }
 
+/// File Information functions
+
+bool GenericMediaDevice::isPlayable( const MetaBundle& bundle )
+{
+    for( QStringList::Iterator it = m_supportedFileTypes.begin(); it != m_supportedFileTypes.end() ; it++ )
+    {
+        if( bundle.type() == *it )
+            return true;
+    }
+
+    return false;
+}
+
+
+bool GenericMediaDevice::isPreferredFormat( const MetaBundle &bundle )
+{
+    return m_supportedFileTypes.first() == bundle.type();
+}
+
+/// Configuration Dialog Extension
+
+void GenericMediaDevice::addConfigElements( QWidget * parent )
+{
+    m_configDialog = new GenericMediaDeviceConfigDialog( parent );
+
+    m_configDialog->setDevice( this );
+}
+
+
+void GenericMediaDevice::removeConfigElements( QWidget * /* parent */ )
+{
+    if( m_configDialog != 0 )
+        delete m_configDialog;
+
+    m_configDialog = 0;
+
+}
+
+
 #include "genericmediadevice.moc"
Index: amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui
===================================================================
--- amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui	(revision 0)
+++ amarok/src/mediadevice/generic/genericmediadeviceconfigdialog.ui	(revision 0)
@@ -0,0 +1,470 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>GenericMediaDeviceConfigDialog</class>
+<widget class="QWidget">
+    <property name="name">
+        <cstring>GenericMediaDeviceConfigDialog</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>486</width>
+            <height>577</height>
+        </rect>
+    </property>
+    <property name="sizePolicy">
+        <sizepolicy>
+            <hsizetype>7</hsizetype>
+            <vsizetype>7</vsizetype>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+        </sizepolicy>
+    </property>
+    <property name="caption">
+        <string>GenericMediaDeviceConfigDialog1</string>
+    </property>
+    <grid>
+        <property name="name">
+            <cstring>unnamed</cstring>
+        </property>
+        <property name="margin">
+            <number>0</number>
+        </property>
+        <property name="spacing">
+            <number>0</number>
+        </property>
+        <widget class="QLayoutWidget" row="0" column="0">
+            <property name="name">
+                <cstring>layout88</cstring>
+            </property>
+            <vbox>
+                <property name="name">
+                    <cstring>unnamed</cstring>
+                </property>
+                <property name="margin">
+                    <number>0</number>
+                </property>
+                <widget class="QGroupBox">
+                    <property name="name">
+                        <cstring>groupBox1</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>7</hsizetype>
+                            <vsizetype>3</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="frameShape">
+                        <enum>GroupBoxPanel</enum>
+                    </property>
+                    <property name="frameShadow">
+                        <enum>Sunken</enum>
+                    </property>
+                    <property name="title">
+                        <string>Transferring files to media device</string>
+                    </property>
+                    <property name="flat">
+                        <bool>false</bool>
+                    </property>
+                    <grid>
+                        <property name="name">
+                            <cstring>unnamed</cstring>
+                        </property>
+                        <widget class="QLabel" row="0" column="0">
+                            <property name="name">
+                                <cstring>textLabel2</cstring>
+                            </property>
+                            <property name="frameShape">
+                                <enum>NoFrame</enum>
+                            </property>
+                            <property name="frameShadow">
+                                <enum>Plain</enum>
+                            </property>
+                            <property name="text">
+                                <string>The following formats will be transferred directly:</string>
+                            </property>
+                        </widget>
+                        <widget class="QLayoutWidget" row="1" column="0">
+                            <property name="name">
+                                <cstring>layout24</cstring>
+                            </property>
+                            <hbox>
+                                <property name="name">
+                                    <cstring>unnamed</cstring>
+                                </property>
+                                <widget class="QLayoutWidget">
+                                    <property name="name">
+                                        <cstring>layout23</cstring>
+                                    </property>
+                                    <vbox>
+                                        <property name="name">
+                                            <cstring>unnamed</cstring>
+                                        </property>
+                                        <widget class="QListBox">
+                                            <property name="name">
+                                                <cstring>m_supportedListBox</cstring>
+                                            </property>
+                                            <property name="selectionMode">
+                                                <enum>Multi</enum>
+                                            </property>
+                                            <property name="toolTip" stdset="0">
+                                                <string>The formats supported by the generic media device.</string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QLabel">
+                                            <property name="name">
+                                                <cstring>textLabel1</cstring>
+                                            </property>
+                                            <property name="sizePolicy">
+                                                <sizepolicy>
+                                                    <hsizetype>7</hsizetype>
+                                                    <vsizetype>0</vsizetype>
+                                                    <horstretch>0</horstretch>
+                                                    <verstretch>0</verstretch>
+                                                </sizepolicy>
+                                            </property>
+                                            <property name="text">
+                                                <string>Other formats will be converted to:</string>
+                                            </property>
+                                        </widget>
+                                    </vbox>
+                                </widget>
+                                <widget class="QLayoutWidget">
+                                    <property name="name">
+                                        <cstring>layout19</cstring>
+                                    </property>
+                                    <vbox>
+                                        <property name="name">
+                                            <cstring>unnamed</cstring>
+                                        </property>
+                                        <widget class="QPushButton">
+                                            <property name="name">
+                                                <cstring>m_addSupportedButton</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>&amp;Add format...</string>
+                                            </property>
+                                            <property name="accel">
+                                                <string>Alt+A</string>
+                                            </property>
+                                            <property name="toolTip" stdset="0">
+                                                <string>Add the above format to the list.</string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QPushButton">
+                                            <property name="name">
+                                                <cstring>m_removeSupportedButton</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Remove selected</string>
+                                            </property>
+                                            <property name="toolTip" stdset="0">
+                                                <string>Remove the selected formats from the list.</string>
+                                            </property>
+                                        </widget>
+                                        <spacer>
+                                            <property name="name">
+                                                <cstring>spacer1</cstring>
+                                            </property>
+                                            <property name="orientation">
+                                                <enum>Vertical</enum>
+                                            </property>
+                                            <property name="sizeType">
+                                                <enum>Expanding</enum>
+                                            </property>
+                                            <property name="sizeHint">
+                                                <size>
+                                                    <width>20</width>
+                                                    <height>93</height>
+                                                </size>
+                                            </property>
+                                        </spacer>
+                                        <widget class="QComboBox">
+                                            <property name="name">
+                                                <cstring>m_convertComboBox</cstring>
+                                            </property>
+                                            <property name="sizePolicy">
+                                                <sizepolicy>
+                                                    <hsizetype>1</hsizetype>
+                                                    <vsizetype>0</vsizetype>
+                                                    <horstretch>0</horstretch>
+                                                    <verstretch>0</verstretch>
+                                                </sizepolicy>
+                                            </property>
+                                            <property name="toolTip" stdset="0">
+                                                <string>The preferred format for transcoding files.</string>
+                                            </property>
+                                        </widget>
+                                    </vbox>
+                                </widget>
+                            </hbox>
+                        </widget>
+                    </grid>
+                </widget>
+                <widget class="QGroupBox">
+                    <property name="name">
+                        <cstring>groupBox2</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>7</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="title">
+                        <string>Transfered files locations</string>
+                    </property>
+                    <grid>
+                        <property name="name">
+                            <cstring>unnamed</cstring>
+                        </property>
+                        <widget class="QLayoutWidget" row="0" column="0">
+                            <property name="name">
+                                <cstring>layout120</cstring>
+                            </property>
+                            <vbox>
+                                <property name="name">
+                                    <cstring>unnamed</cstring>
+                                </property>
+                                <widget class="QLayoutWidget">
+                                    <property name="name">
+                                        <cstring>layout119</cstring>
+                                    </property>
+                                    <grid>
+                                        <property name="name">
+                                            <cstring>unnamed</cstring>
+                                        </property>
+                                        <widget class="QCheckBox" row="0" column="2">
+                                            <property name="name">
+                                                <cstring>m_ignoreTheCheck</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Ignore "The"</string>
+                                            </property>
+                                            <property name="accel">
+                                                <string></string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QCheckBox" row="0" column="1">
+                                            <property name="name">
+                                                <cstring>m_spaceCheck</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Convert spaces</string>
+                                            </property>
+                                            <property name="accel">
+                                                <string></string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QCheckBox" row="0" column="0">
+                                            <property name="name">
+                                                <cstring>m_asciiCheck</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>ASCII te&amp;xt</string>
+                                            </property>
+                                            <property name="accel">
+                                                <string>Alt+X</string>
+                                            </property>
+                                        </widget>
+                                    </grid>
+                                </widget>
+                                <widget class="QLayoutWidget">
+                                    <property name="name">
+                                        <cstring>layout96</cstring>
+                                    </property>
+                                    <vbox>
+                                        <property name="name">
+                                            <cstring>unnamed</cstring>
+                                        </property>
+                                        <widget class="QLabel">
+                                            <property name="name">
+                                                <cstring>textLabel1_2_2</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Song location:</string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QLayoutWidget">
+                                            <property name="name">
+                                                <cstring>layout86</cstring>
+                                            </property>
+                                            <hbox>
+                                                <property name="name">
+                                                    <cstring>unnamed</cstring>
+                                                </property>
+                                                <widget class="QLineEdit">
+                                                    <property name="name">
+                                                        <cstring>m_songLocationBox</cstring>
+                                                    </property>
+                                                    <property name="text">
+                                                        <string></string>
+                                                    </property>
+                                                    <property name="toolTip" stdset="0">
+                                                        <string>The location of the transfered songs relative to the device mount point.</string>
+                                                    </property>
+                                                </widget>
+                                                <widget class="KActiveLabel">
+                                                    <property name="name">
+                                                        <cstring>m_formatHelp</cstring>
+                                                    </property>
+                                                    <property name="sizePolicy">
+                                                        <sizepolicy>
+                                                            <hsizetype>1</hsizetype>
+                                                            <vsizetype>7</vsizetype>
+                                                            <horstretch>0</horstretch>
+                                                            <verstretch>0</verstretch>
+                                                        </sizepolicy>
+                                                    </property>
+                                                    <property name="text">
+                                                        <string>&lt;p align="center"&gt;(help)&lt;/p&gt;</string>
+                                                    </property>
+                                                    <property name="autoFormatting">
+                                                        <set>AutoAll</set>
+                                                    </property>
+                                                </widget>
+                                            </hbox>
+                                        </widget>
+                                        <widget class="QLabel">
+                                            <property name="name">
+                                                <cstring>textLabel2_2</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Example song location:</string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QLabel">
+                                            <property name="name">
+                                                <cstring>m_previewLabel</cstring>
+                                            </property>
+                                            <property name="sizePolicy">
+                                                <sizepolicy>
+                                                    <hsizetype>7</hsizetype>
+                                                    <vsizetype>5</vsizetype>
+                                                    <horstretch>0</horstretch>
+                                                    <verstretch>0</verstretch>
+                                                </sizepolicy>
+                                            </property>
+                                            <property name="frameShape">
+                                                <enum>StyledPanel</enum>
+                                            </property>
+                                            <property name="frameShadow">
+                                                <enum>Plain</enum>
+                                            </property>
+                                            <property name="margin">
+                                                <number>2</number>
+                                            </property>
+                                            <property name="text">
+                                                <string></string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QLabel">
+                                            <property name="name">
+                                                <cstring>textLabel2_2_2</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string>Podcast location:</string>
+                                            </property>
+                                        </widget>
+                                        <widget class="QLineEdit">
+                                            <property name="name">
+                                                <cstring>m_podcastLocationBox</cstring>
+                                            </property>
+                                            <property name="text">
+                                                <string></string>
+                                            </property>
+                                            <property name="toolTip" stdset="0">
+                                                <string>The location of the transfered podcasts relative to the device mount point.</string>
+                                            </property>
+                                        </widget>
+                                    </vbox>
+                                </widget>
+                            </vbox>
+                        </widget>
+                    </grid>
+                </widget>
+            </vbox>
+        </widget>
+    </grid>
+</widget>
+<connections>
+    <connection>
+        <sender>m_removeSupportedButton</sender>
+        <signal>clicked()</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>removeSupportedButtonClicked()</slot>
+    </connection>
+    <connection>
+        <sender>m_supportedListBox</sender>
+        <signal>doubleClicked(QListBoxItem*)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>supportedListBoxDoubleClicked(QListBoxItem*)</slot>
+    </connection>
+    <connection>
+        <sender>m_songLocationBox</sender>
+        <signal>textChanged(const QString&amp;)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>updatePreviewLabel(const QString&amp;)</slot>
+    </connection>
+    <connection>
+        <sender>m_asciiCheck</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>updatePreviewLabel()</slot>
+    </connection>
+    <connection>
+        <sender>m_spaceCheck</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>updatePreviewLabel()</slot>
+    </connection>
+    <connection>
+        <sender>m_ignoreTheCheck</sender>
+        <signal>toggled(bool)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>updatePreviewLabel()</slot>
+    </connection>
+    <connection>
+        <sender>GenericMediaDeviceConfigDialog</sender>
+        <signal>destroyed(QObject*)</signal>
+        <receiver>GenericMediaDeviceConfigDialog</receiver>
+        <slot>GenericMediaDeviceConfigDialog_destroyed(QObject*)</slot>
+    </connection>
+</connections>
+<includes>
+    <include location="global" impldecl="in implementation">metabundle.h</include>
+    <include location="global" impldecl="in implementation">qstringx.h</include>
+    <include location="global" impldecl="in implementation">collectionbrowser.h</include>
+    <include location="local" impldecl="in declaration">genericmediadevice.h</include>
+    <include location="global" impldecl="in declaration">qpopupmenu.h</include>
+</includes>
+<variables>
+    <variable access="private">QPopupMenu *m_unsupportedMenu;</variable>
+    <variable access="private">MetaBundle *m_previewBundle;</variable>
+    <variable access="private">GenericMediaDevice *m_device;</variable>
+</variables>
+<slots>
+    <slot>addSupportedButtonClicked( int id )</slot>
+    <slot specifier="non virtual">removeSupportedButtonClicked()</slot>
+    <slot specifier="non virtual">supportedListBoxDoubleClicked( QListBoxItem * item )</slot>
+    <slot>updatePreviewLabel()</slot>
+    <slot>updatePreviewLabel( const QString &amp; format )</slot>
+    <slot>GenericMediaDeviceConfigDialog_destroyed(QObject*)</slot>
+</slots>
+<functions>
+    <function access="private" specifier="non virtual">updateConfigDialogLists( const QStringList &amp; supportedFileTypes )</function>
+    <function access="private" specifier="non virtual" returnType="QString">buildDestination( const QString &amp; format, const MetaBundle &amp; mb ) const</function>
+    <function access="private" specifier="non virtual" returnType="QString">cleanPath( const QString &amp; component ) const</function>
+    <function specifier="non virtual">setDevice( GenericMediaDevice * device )</function>
+    <function access="private" specifier="non virtual" returnType="QString">buildFormatTip() const</function>
+    <function access="private" specifier="non virtual">init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+    <includehint>kactivelabel.h</includehint>
+</includehints>
+</UI>
