Index: kdecore/kmountpoint.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kmountpoint.cpp,v
retrieving revision 1.8
diff -u -3 -p -r1.8 kmountpoint.cpp
--- kdecore/kmountpoint.cpp	13 Sep 2003 11:18:31 -0000	1.8
+++ kdecore/kmountpoint.cpp	13 May 2004 12:00:55 -0000
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 
 #include <qfile.h>
+#include <qmap.h>
 
 #include "kstandarddirs.h"
 
@@ -95,13 +96,29 @@ extern "C" void endvfsent( );
 #endif
 
 
+class KMountPoint::KMountPointPrivate
+{
+public:
+   KMountPointPrivate()
+   {
+      hotplug = false;
+   }
+   bool hotplug;
+};
 
 KMountPoint::KMountPoint()
 {
+   d = new KMountPointPrivate;
 }
 
 KMountPoint::~KMountPoint()
 {
+   delete d;
+}
+
+bool KMountPoint::hotplug() const
+{
+   return d->hotplug;
 }
 
 #ifdef HAVE_SETMNTENT
@@ -125,12 +142,13 @@ KMountPoint::~KMountPoint()
 #define MOUNTOPTIONS(var) var.mnt_mntopts
 #define FSNAME(var) var.mnt_special
 #endif
+#include <iostream>
 
 KMountPoint::List KMountPoint::possibleMountPoints(int infoNeeded)
 {
   KMountPoint::List result;
   
-#ifdef HAVE_SETMNTENT
+#if 0
    STRUCT_SETMNTENT fstab;
    if ((fstab = SETMNTENT(FSTAB, "r")) == 0)
       return result;
@@ -184,7 +202,7 @@ KMountPoint::List KMountPoint::possibleM
 #endif
 
       KMountPoint *mp = new KMountPoint();
-
+      
       int i = 0;
       mp->m_mountedFrom = item[i++];
 #ifdef _OS_SOLARIS_
@@ -204,6 +222,16 @@ KMountPoint::List KMountPoint::possibleM
          if (mp->m_mountedFrom.startsWith("/"))
             mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom);
       }
+
+#ifdef __linux__
+      // does any other OS do it this way?
+      if (s.find("HOTPLUG") != -1)
+      {
+         mp->d->hotplug = true;
+         std::cerr << "sW#$%BWRTSE$5w-er-ea-45 " << s.latin1() << std::endl;
+      }
+#endif
+
       // TODO: Strip trailing '/' ?
       result.append(mp);
    } //while
@@ -215,19 +243,35 @@ KMountPoint::List KMountPoint::possibleM
 
 KMountPoint::List KMountPoint::currentMountPoints(int infoNeeded)
 {
-  KMountPoint::List result;
+   KMountPoint::List result;
+   
+   KMountPoint::List possibleInfo = possibleMountPoints();
+   QMap<QString, Ptr> mountPointToInfo;
+   
+   for (KMountPoint::List::Iterator i(possibleInfo.begin()); i != possibleInfo.end(); ++i)
+   {
+      QString str = (*i)->mountPoint().stripWhiteSpace();
+      mountPointToInfo[str] = *i;
+   }
+
 
 #ifdef HAVE_GETMNTINFO
 
-    struct statfs *mounted;
+   struct statfs *mounted;
 
-    int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
+   int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
 
-    for (int i=0;i<num_fs;i++) 
-    {
+   for (int i=0;i<num_fs;i++) 
+   {
       KMountPoint *mp = new KMountPoint();
       mp->m_mountedFrom = QFile::decodeName(mounted[i].f_mntfromname);
       mp->m_mountPoint = QFile::decodeName(mounted[i].f_mntonname);
+      
+      {
+         Ptr info = mountPointToInfo[mp->m_mountPoint.stripWhiteSpace()];
+         if (info)
+            mp->d->hotplug = info->hotplug();
+      }
 
 #ifdef __osf__
       mp->m_mountType = QFile::decodeName(mnt_names[mounted[i].f_type]);
@@ -253,75 +297,80 @@ KMountPoint::List KMountPoint::currentMo
 
 #elif defined(_AIX)
 
-    struct vmount *mntctl_buffer;
-    struct vmount *vm;
-    char *mountedfrom;
-    char *mountedto;
-    int fsname_len, num;
-    int buf_sz = 4096;
-
-    mntctl_buffer = (struct vmount*)malloc(buf_sz);
-    num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
-    if (num == 0)
-    {
-	buf_sz = *(int*)mntctl_buffer;
-	free(mntctl_buffer);
-	mntctl_buffer = (struct vmount*)malloc(buf_sz);
-	num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
-    }
-
-    if (num > 0)
-    {
-        /* iterate through items in the vmount structure: */
-        vm = (struct vmount *)mntctl_buffer;
-        for ( ; num > 0; num-- )
-        {
-            /* get the name of the mounted file systems: */
-            fsname_len = vmt2datasize(vm, VMT_STUB);
-            mountedto     = (char*)malloc(fsname_len + 1);
-	    mountedto[fsname_len] = '\0';
-            strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
-
-            fsname_len = vmt2datasize(vm, VMT_OBJECT);
-            mountedfrom     = (char*)malloc(fsname_len + 1);
-	    mountedfrom[fsname_len] = '\0';
-            strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
-
-	    /* Look up the string for the file system type,
-             * as listed in /etc/vfs.
-             * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs
-             */
-            struct vfs_ent* ent = getvfsbytype(vm->vmt_gfstype);
-
-            KMountPoint *mp = new KMountPoint();
-            mp->m_mountedFrom = QFile::decodeName(mountedfrom);
-            mp->m_mountPoint = QFile::decodeName(mountedto);
-            mp->m_mountType = QFile::decodeName(ent->vfsent_name);
-
-            free(mountedfrom);
-            free(mountedto);
-
-            if (infoNeeded & NeedMountOptions)
-            {
-              // TODO
-            }
-
-            if (infoNeeded & NeedRealDeviceName)
-            {
-               if (mp->m_mountedFrom.startsWith("/"))
-                  mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom);
-            }
+   struct vmount *mntctl_buffer;
+   struct vmount *vm;
+   char *mountedfrom;
+   char *mountedto;
+   int fsname_len, num;
+   int buf_sz = 4096;
+
+   mntctl_buffer = (struct vmount*)malloc(buf_sz);
+   num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
+   if (num == 0)
+   {
+      buf_sz = *(int*)mntctl_buffer;
+      free(mntctl_buffer);
+      mntctl_buffer = (struct vmount*)malloc(buf_sz);
+      num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
+   }
+
+   if (num > 0)
+   {
+      /* iterate through items in the vmount structure: */
+      vm = (struct vmount *)mntctl_buffer;
+      for ( ; num > 0; num-- )
+      {
+         /* get the name of the mounted file systems: */
+         fsname_len = vmt2datasize(vm, VMT_STUB);
+         mountedto     = (char*)malloc(fsname_len + 1);
+         mountedto[fsname_len] = '\0';
+         strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
+
+         fsname_len = vmt2datasize(vm, VMT_OBJECT);
+         mountedfrom     = (char*)malloc(fsname_len + 1);
+         mountedfrom[fsname_len] = '\0';
+         strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
+
+         /* Look up the string for the file system type,
+          * as listed in /etc/vfs.
+          * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs
+          */
+         struct vfs_ent* ent = getvfsbytype(vm->vmt_gfstype);
+
+         KMountPoint *mp = new KMountPoint();
+         mp->m_mountedFrom = QFile::decodeName(mountedfrom);
+         mp->m_mountPoint = QFile::decodeName(mountedto);
+         mp->m_mountType = QFile::decodeName(ent->vfsent_name);
+         {
+             Ptr info = mountPointToInfo[mp->m_mountPoint.stripWhiteSpace()];
+             if (info)
+               mp->d->hotplug = info->hotplug();
+         }
+
+         free(mountedfrom);
+         free(mountedto);
+
+         if (infoNeeded & NeedMountOptions)
+         {
+            // TODO
+         }
+
+         if (infoNeeded & NeedRealDeviceName)
+         {
+            if (mp->m_mountedFrom.startsWith("/"))
+               mp->m_device = KStandardDirs::realPath(mp->m_mountedFrom);
+         }
             
-            result.append(mp);
+         result.append(mp);
 
-            /* goto the next vmount structure: */
-            vm = (struct vmount *)((char *)vm + vm->vmt_length);
-        }
+         /* goto the next vmount structure: */
+         vm = (struct vmount *)((char *)vm + vm->vmt_length);
+      }
 
-	endvfsent( );
-    }
+      endvfsent( );
+   }
 
-    free( mntctl_buffer );
+   free( mntctl_buffer );
 #else
    STRUCT_SETMNTENT mnttab;
    if ((mnttab = SETMNTENT(MNTTAB, "r")) == 0)
@@ -335,6 +384,11 @@ KMountPoint::List KMountPoint::currentMo
          
       mp->m_mountPoint = QFile::decodeName(MOUNTPOINT(fe));
       mp->m_mountType = QFile::decodeName(MOUNTTYPE(fe));
+      {
+         Ptr info = mountPointToInfo[mp->m_mountPoint.stripWhiteSpace()];
+         if (info)
+            mp->d->hotplug = info->hotplug();
+      }
       if (infoNeeded & NeedMountOptions)
       {
          QString options = QFile::decodeName(MOUNTOPTIONS(fe));
@@ -354,4 +408,4 @@ KMountPoint::List KMountPoint::currentMo
    return result;
 }
 
-
+// vim: et ts=3
Index: kdecore/kmountpoint.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kmountpoint.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 kmountpoint.h
--- kdecore/kmountpoint.h	7 Oct 2003 22:09:16 -0000	1.5
+++ kdecore/kmountpoint.h	13 May 2004 12:00:55 -0000
@@ -89,6 +89,12 @@ public:
     */
    ~KMountPoint();
 
+   /**
+    * returns if this device is a hot-pluggable device
+    **/
+   bool hotplug() const;
+   
+
 private:
    /**
     * Constructor
@@ -106,3 +112,5 @@ private:
 };
 
 #endif
+
+// vim: et ts=3
