--- kdebase-3.5.6_orig/kdesktop/Makefile.am	2006-05-22 20:12:51.000000000 +0200
+++ kdebase-3.5.6/kdesktop/Makefile.am	2007-02-08 00:14:37.000000000 +0100
@@ -1,8 +1,8 @@
 ## Makefile.am of kdebase/kdesktop
 
-INCLUDES = -I$(top_srcdir)/kcontrol/background -I$(top_srcdir)/libkonq -I$(top_srcdir)/kdmlib $(all_includes)
+INCLUDES = -I$(top_srcdir)/kcontrol/background -I$(top_srcdir)/libkonq -I$(top_srcdir)/kdmlib -I$(top_srcdir)/kioslave/media/libmediacommon $(all_includes)
 kdesktop_la_LDFLAGS  = $(all_libraries) -module $(KDE_PLUGIN)
-kdesktop_la_LIBADD   = libkdesktopsettings.la $(top_builddir)/libkonq/libkonq.la $(top_builddir)/kcontrol/background/libbgnd.la $(top_builddir)/kdmlib/libdmctl.la $(LIB_XSS) $(LIB_KUTILS) $(LIB_XCURSOR)
+kdesktop_la_LIBADD   = $(top_builddir)/kioslave/media/libmediacommon/libmediacommon.la libkdesktopsettings.la $(top_builddir)/libkonq/libkonq.la $(top_builddir)/kcontrol/background/libbgnd.la $(top_builddir)/kdmlib/libdmctl.la $(LIB_XSS) $(LIB_KUTILS) $(LIB_XCURSOR)
 
 SUBDIRS = . lock pics patterns programs init kwebdesktop
 
@@ -18,7 +18,7 @@
 libkdesktopsettings_la_SOURCES = kdesktopsettings.kcfgc klaunchsettings.kcfgc 
 
 kdesktop_la_SOURCES = main.cc krootwm.cc xautolock.cc kdiconview.cc desktop.cc \
-	lockeng.cc KDesktopIface.skel \
+	lockeng.cc KDesktopIface.skel kdiconview.skel \
 	bgmanager.cc init.cc KScreensaverIface.skel \
 	minicli.cpp KBackgroundIface.skel pixmapserver.cc kcustommenu.cc \
 	startupid.cpp minicli_ui.ui xautolock_diy.c xautolock_engine.c \
--- kdebase-3.5.6_orig/kdesktop/kdiconview.h	2007-01-15 12:32:10.000000000 +0100
+++ kdebase-3.5.6/kdesktop/kdiconview.h	2007-02-14 08:35:17.000000000 +0100
@@ -20,10 +20,13 @@
 #ifndef kdiconview_h
 #define kdiconview_h
 
+#include <qmap.h>
 #include <konq_iconviewwidget.h>
 #include <kaction.h>
 #include <kfileitem.h>
 #include <kdirnotify.h>
+#include <dcopobject.h>
+#include "medium.h"
 
 class KDirLister;
 class KonqSettings;
@@ -43,6 +46,7 @@
 class KDIconView : public KonqIconViewWidget, public KDirNotify
 {
     Q_OBJECT
+	K_DCOP
 
 public:
     KDIconView( QWidget *parent, const char* name = 0L );
@@ -103,6 +107,10 @@
 
     void startDirLister();
 
+k_dcop:
+	void onMediumAdded( const QString &name, bool allowNotification);
+	void onMediumRemoved( const QString &name, bool allowNotification);
+
 protected slots:
 
     // slots connected to the icon view
@@ -135,6 +143,8 @@
 
     void slotNewMenuActivated();
 
+	void slotMediumStatResult( KIO::Job *job );
+
     // For communication with KDesktop
 signals:
     void colorDropEvent( QDropEvent *e );
@@ -153,6 +163,7 @@
     void refreshIcons();
 
 
+
 protected:
     void createActions();
     void setupSortKeys();
@@ -184,6 +195,12 @@
     static void saveIconPosition(KSimpleConfig *config, int x, int y);
     static void readIconPosition(KSimpleConfig *config, int &x, int &y);
 
+	
+//	KURL resolveDevNode(const QString &devNodeName);
+	Medium resolveDevNode(const QString &devNodeName);
+	KURL extractUrlFromMedium(const Medium &thisMedium);
+	void handleFileEntry( const KFileItem &newEntry, const QString &devNodeName );
+
     /** Our action collection, parent of all our actions */
     KActionCollection m_actionCollection;
 
@@ -251,6 +268,12 @@
     // did we already get the correct desktopIconsArea (from kicker)
     // needed when we want to line up icons on a grid
     bool m_gotIconsArea;
+
+    bool m_mediaInit;
+
+    QMap<KIO::Job*,QString> mJobDevNodeMap;
+    QMap<QString,KFileItem *> mDevNodeFileItemMap;
+    QMap<KIO::Job*,QString> mJobDevLabelMap;
 };
 
 #endif
--- kdebase-3.5.6_orig/kdesktop/kdiconview.cc	2007-01-15 12:32:10.000000000 +0100
+++ kdebase-3.5.6/kdesktop/kdiconview.cc	2007-02-16 22:36:08.000000000 +0100
@@ -58,6 +58,7 @@
 #include "kshadowengine.h"
 #include "kdesktopshadowsettings.h"
 #include "kfileividesktop.h"
+#include "medium.h"
 
 // for multihead
 extern int kdesktop_screen_number;
@@ -147,7 +148,8 @@
       m_eSortCriterion( NameCaseInsensitive ),
       m_bSortDirectoriesFirst( true ),
       m_itemsAlwaysFirst(),
-      m_gotIconsArea(false)
+      m_gotIconsArea(false),
+      m_mediaInit(false)
 {
     setResizeMode( Fixed );
     setIconArea( desktopRect() );  // the default is the whole desktop
@@ -199,6 +201,16 @@
     delete m_dotDirectory;
     delete m_dirLister;
     delete m_shadowEngine;
+
+    // Clean up our media KFileItem
+    QMap<QString,KFileItem *>::Iterator it;
+    it = mDevNodeFileItemMap.begin();
+    while(it != mDevNodeFileItemMap.end() )
+    {
+        delete it.data();
+        it = mDevNodeFileItemMap.begin();
+    }
+
 }
 
 void KDIconView::initDotDirectories()
@@ -268,7 +280,6 @@
 void KDIconView::initConfig( bool init )
 {
     //kdDebug() << "initConfig " << init << endl;
-
     if ( !init ) {
         KonqFMSettings::reparseConfiguration();
         KDesktopSettings::self()->readConfig();
@@ -378,36 +389,195 @@
 void KDIconView::configureMedia()
 {
     kdDebug(1204) << "***********KDIconView::configureMedia() " <<endl;
-    m_dirLister->setMimeExcludeFilter(m_excludedMedia);
-    m_dirLister->emitChanges();
     updateContents();
-    if (m_enableMedia)
+
+    // Connect up the DCOP signals.
+    if(!m_mediaInit)
     {
-    	for (KURL::List::Iterator it1=m_mergeDirs.begin();it1!=m_mergeDirs.end();++it1)
-	    {
-	    	if ((*it1).url()=="media:/") return;
-	    }
-    	m_mergeDirs.append(KURL("media:/"));
-    	m_dirLister->openURL(KURL("media:/"),true);
+        // Load in the current list of media
+
+        DCOPRef mediamanager("kded", "mediamanager");
+        DCOPReply reply = mediamanager.call( "fullList" );
+        if ( reply.isValid() )
+        {
+            Medium::List mediumList = Medium::createList(reply);
+            Medium::List::iterator it = mediumList.begin();
+            Medium::List::iterator end = mediumList.end();
+
+            Medium thisMedium(QString::null,QString::null);
+
+            for(; it!=end; ++it)
+            {
+                onMediumAdded( (*it).name(), false);
+            }
+        }
+
+        // Hook up the signals from the mediamanager.
+        connectDCOPSignal( "kded", "mediamanager", "mediumAdded(QString, bool)",
+            "onMediumAdded(QString, bool)", true );
+
+        connectDCOPSignal( "kded", "mediamanager", "mediumChanged(QString, bool)",
+            "onMediumAdded(QString, bool)", true );
+
+        connectDCOPSignal( "kded", "mediamanager", "mediumRemoved(QString, bool)",
+            "onMediumRemoved(QString, bool)", true );
+
+        m_mediaInit = true;
+    }
+
+}
+
+void KDIconView::onMediumAdded( const QString &name, bool /* allowNotification */)
+{
+    // This method handles medium added and medium changed signals.
+	Medium thisMedium = resolveDevNode(name);
+	KURL realUrl = extractUrlFromMedium(thisMedium); 
+    if ( !realUrl.isValid() )
+    {
+        onMediumRemoved(name,false);
+        return;
+    }
+
+    if ( realUrl.protocol()=="audiocd" || realUrl.protocol()=="camera")
+    {
+        KFileItem newEntry( realUrl, thisMedium.mimeType(), S_IRUSR|S_IRGRP|S_IROTH );
+        newEntry.setName(thisMedium.label());
+        handleFileEntry(newEntry, name);
     }
     else
     {
-            for (KURL::List::Iterator it2=m_mergeDirs.begin();it2!=m_mergeDirs.end();++it2)
-	    {
-		if ((*it2).url()=="media:/")
+        KIO::SimpleJob *job = KIO::stat( realUrl, false );
+        job->setInteractive( false );
+
+        mJobDevNodeMap[job] = name;
+        mJobDevLabelMap[job] = thisMedium.label();
+
+        connect( job, SIGNAL( result( KIO::Job * ) ),
+                 this, SLOT( slotMediumStatResult( KIO::Job * ) ) );
+    }
+}
+
+Medium KDIconView::resolveDevNode(const QString &devNodeName)
+{
+	Medium thisMedium(QString::null,QString::null);
+
+	// We get the mount/media information from the KDE mediamanager, the
+	// same way as what the media:/ ioslave does.
+	DCOPRef mediamanager("kded", "mediamanager");
+	DCOPReply reply = mediamanager.call( "fullList" );
+	if ( !reply.isValid() )
+	{
+		return thisMedium;
+	}
+
+	Medium::List mediumList = Medium::createList(reply);
+	Medium::List::iterator it = mediumList.begin();
+	Medium::List::iterator end = mediumList.end();
+
+	for(; it!=end; ++it)
+	{
+		if( (*it).name()==devNodeName)
 		{
-			  delete m_dirLister;
-			  m_dirLister=0;
-			  start();
-//			m_mergeDirs.remove(it2);
-//			m_dirLister->stop("media");
-			return;
+//fprintf(stderr,"kdiconview.resolveDevNode(%s) found\n",devNodeName.latin1());
+//fflush(stderr);
+			return *it;
 		}
+	}
 
-	    }
-	    return;
+//fprintf(stderr,"kdiconview.resolveDevNode(%s) failed\n",devNodeName.latin1());
+//fflush(stderr);
+		// Couldn't find the medium entry. Sorry.
+	return thisMedium;
+}
+
+KURL KDIconView::extractUrlFromMedium(const Medium &thisMedium) {
+	KURL thisUrl;
+	if(thisMedium.baseURL().startsWith("audiocd:"))
+	{
+		thisUrl = KURL("audiocd:/");
+	}
+	else
+	{
+		if(thisMedium.mountPoint()!=QString::null && !thisMedium.baseURL().startsWith("camera:"))
+		{
+			thisUrl = KURL(thisMedium.mountPoint());
+		}
+		else
+		{
+			thisUrl = KURL(thisMedium.baseURL());
+		}
+	}
+	return thisUrl;
+}
+
+void KDIconView::slotMediumStatResult( KIO::Job *job )
+{
+    if ( job->error() != 0 ) return;
+
+    KIO::StatJob *stat_job = static_cast<KIO::StatJob *>( job );
+
+    KIO::UDSEntry entry = stat_job->statResult();
+    KURL url = stat_job->url();
+    KFileItem newEntry( entry, url );
+
+    QString devNodeName = mJobDevNodeMap[job];
+    mJobDevNodeMap.remove( job );
+    QString devNodeLabel = mJobDevLabelMap[job];
+    mJobDevLabelMap.remove( job );
+
+    newEntry.setName(QString("%1 (%2)").arg(devNodeLabel).arg(newEntry.name()));
+
+    handleFileEntry(newEntry, devNodeName);
+}
+
+void KDIconView::handleFileEntry( const KFileItem &newEntry, const QString &devNodeName) {
+    if ( mDevNodeFileItemMap.contains(devNodeName) )
+    {
+        // We already have this medium item. Just update it and send it on to the normal update code.
+        *(mDevNodeFileItemMap[devNodeName]) = newEntry; 
+        KFileItemList itemList;
+        itemList.append( mDevNodeFileItemMap[devNodeName] );
+        slotRefreshItems(itemList);
     }
+    else
+    {
+        // New medium
+        KFileItem *newHeapEntry = new KFileItem( newEntry );
+        QString mimetype = newHeapEntry->mimetype();
 
+        if( !(m_excludedMedia.contains(mimetype) 
+                || mimetype=="media/cdrom_unmounted"
+                || mimetype=="media/removable_unmounted"
+                || mimetype=="media/camera_unmounted"
+                || mimetype=="media/dvd_unmounted"
+                || mimetype=="media/cdwriter_unmounted"
+                || mimetype=="media/zip_unmounted") )
+        {
+            // Not banned. Show it.
+            KFileItemList itemList;
+            itemList.append(newHeapEntry);
+            mDevNodeFileItemMap[devNodeName] = newHeapEntry;		
+            slotNewItems(itemList);
+        }
+        else
+        {
+            // Forget this medium.
+            delete newHeapEntry;
+        }
+    }
+    viewport()->repaint( FALSE );
+    repaint( FALSE );
+}
+
+void KDIconView::onMediumRemoved( const QString &name, bool /*allowNotification*/ )
+{
+    if ( mDevNodeFileItemMap.contains(name) )
+    {
+        KFileItem *item = mDevNodeFileItemMap[name];
+        slotDeleteItem(item);
+        mDevNodeFileItemMap.remove(name);
+        delete item;
+    }
 }
 
 void KDIconView::createActions()
@@ -431,9 +601,6 @@
         KAction *pasteTo = KStdAction::paste( this, SLOT( slotPopupPasteTo() ), &m_actionCollection, "pasteto" );
         pasteTo->setEnabled( false ); // only enabled during popupMenu()
 
-        KShortcut reloadShortcut = KStdAccel::shortcut(KStdAccel::Reload);
-        new KAction( i18n( "&Reload" ), "reload", reloadShortcut, this, SLOT( refreshIcons() ), &m_actionCollection, "reload" );
-
         (void) new KAction( i18n( "&Rename" ), /*"editrename",*/ Key_F2, this, SLOT( renameSelectedItem() ), &m_actionCollection, "rename" );
         (void) new KAction( i18n( "&Properties" ), ALT+Key_Return, this, SLOT( slotProperties() ), &m_actionCollection, "properties" );
         KAction* trash = new KAction( i18n( "&Move to Trash" ), "edittrash", Key_Delete, &m_actionCollection, "trash" );
@@ -886,6 +1053,11 @@
     QString desktopFile;
     if ( item->isDir() && item->isLocalFile() )
     {
+        if ( item->url().url()=="file:///" )	// The root volume.
+        {
+            fileIVI->setText( "/" );
+            return true;
+        } 
         KURL u( item->url() );
         u.addPath( ".directory" );
         // using KStandardDirs as this one checks for path being
@@ -963,12 +1135,15 @@
     if (!desktopPath.isEmpty() && url.isLocalFile() && !url.path().startsWith(desktopPath))
     {
       QString fileName = url.fileName();
-      if (QFile::exists(desktopPath + fileName))
+      if (!fileName.isNull() && QFile::exists(desktopPath + fileName))
+      {
          continue; // Don't duplicate entry
-
+      }
       QString mostLocal = locate("appdata", "Desktop/"+fileName);
       if (!mostLocal.isEmpty() && (mostLocal != url.path()))
-         continue; // Don't duplicate entry
+      {
+          continue; // Don't duplicate entry
+      }
     }
 
     // No delayed mimetype determination on the desktop
--- kdebase-3.5.6_orig/kcontrol/konq/desktopbehavior_impl.cpp	2006-10-01 19:31:48.000000000 +0200
+++ kdebase-3.5.6/kcontrol/konq/desktopbehavior_impl.cpp	2007-02-08 00:14:37.000000000 +0100
@@ -236,9 +236,16 @@
     QValueListIterator<KMimeType::Ptr> it2(mimetypes.begin());
     g_pConfig->setGroup( "Media" );
     enableMediaBox->setChecked(g_pConfig->readBoolEntry("enabled",false));
-    QString excludedMedia=g_pConfig->readEntry("exclude","media/hdd_mounted,media/hdd_unmounted,media/floppy_unmounted,media/cdrom_unmounted,media/floppy5_unmounted");
+    QString excludedMedia=g_pConfig->readEntry("exclude","media/hdd_mounted");
     for (; it2 != mimetypes.end(); ++it2) {
-       if ( ((*it2)->name().startsWith("media/")) )
+       QString name = (*it2)->name();
+       if ( name.startsWith("media/")
+            && name!="media/cdrom_unmounted"
+            && name!="media/removable_unmounted"
+            && name!="media/camera_unmounted"
+            && name!="media/dvd_unmounted"
+            && name!="media/cdwriter_unmounted"
+            && name!="media/zip_unmounted" )
 	{
     	    bool ok=excludedMedia.contains((*it2)->name())==0;
 		new DesktopBehaviorMediaItem (this, mediaListView, (*it2)->comment(), (*it2)->name(),ok);
