[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Fwd: Little mountwatcher patch.
From:       Dirk Mueller <mueller () kde ! org>
Date:       2004-05-18 14:27:39
Message-ID: 200405181627.39837.mueller () kde ! org
[Download RAW message or body]

Hi, 

any comments?


Dirk

["forwarded message" (message/rfc822)]



Hi,

Sorry if I'm boring you but I can't contact jowenn@kde.org bacause his mail i 
full, and you are the last that changed the mountwatcher program.

Using an hotplug scripts that automounts my usb key, I've noticed that the 
mountwatcher doesn't remove from his "disks" list the unmounted devices. So 
removing the usb-key doesn't remove the entry on the desktop (or in the 
devices bar of konqueror). And this caused the creation of another desktop 
entry every time the usb-key was replugged to the system.

So I've did a little patch that remove the DiskEntry if it doesn't exists 
anymore in mtab or fstab. It applies to the current CVS HEAD.

I've did it in 20 minutes so I don't know if you can like it, but it works 
well for me.

I've already got an account for the kde CVS (kdebluetooth) but I don't like 
to commit things without asking to the mantainer of the program. :-)

Please let me know your suggestions.

Bye!
-- 
Simone Gotti
<simone.gotti@email.it>

["mountwatcher-patch-SimoneGotti-01.patch" (text/x-diff)]

Only in kdebase-patch01/kioslave/devices/kdedmodule/: Makefile.in
diff -U 3 -H -d -r -- kdebase/kioslave/devices/kdedmodule/disklist.cpp \
                kdebase-patch01/kioslave/devices/kdedmodule/disklist.cpp
--- kdebase/kioslave/devices/kdedmodule/disklist.cpp	2004-02-24 12:30:11.000000000 \
                +0100
+++ kdebase-patch01/kioslave/devices/kdedmodule/disklist.cpp	2004-05-15 \
13:38:47.000000000 +0200 @@ -108,6 +108,7 @@
 			(disk->inode()==item->inode()))) &&
 			(item->mountPoint()==disk->mountPoint()) ) {
 			item->setMounted(TRUE);
+			item->setOld(false);
 			pos=i;
 			break;
 		}
@@ -136,6 +137,8 @@
   //
   //int pos=disks->find(disk);
 
+  disk->setOld(false);
+  
   kdDebug()<<"Trying to find an item referencing: "<<disk->deviceName()<<endl;
   int pos = -1;
   for( u_int i=0; i<disks->count(); i++ )
@@ -239,5 +242,26 @@
    }
 }
 
+void DiskList::setAllOld()
+{
+   for( u_int i=0; i<disks->count(); i++ )
+   {
+      DiskEntry *item = disks->at(i);
+      item->setOld(true);
+   }
+}
+
+void DiskList::removeOldDisks()
+{
+   for( u_int i=0; i<disks->count(); i++ )
+   {
+      DiskEntry *item = disks->at(i);
+      if(item->old())
+	  	 disks->remove(i);
+   }
+}
+
+
+
 #include "disklist.moc"
 
diff -U 3 -H -d -r -- kdebase/kioslave/devices/kdedmodule/disklist.h \
                kdebase-patch01/kioslave/devices/kdedmodule/disklist.h
--- kdebase/kioslave/devices/kdedmodule/disklist.h	2003-05-13 13:27:48.000000000 \
                +0200
+++ kdebase-patch01/kioslave/devices/kdedmodule/disklist.h	2004-05-15 \
13:38:30.000000000 +0200 @@ -64,6 +64,8 @@
  ~DiskList();
    void readFSTAB();
    void readMNTTAB();
+   void setAllOld();
+   void removeOldDisks();
    int find(const DiskEntry* disk) {return disks->find(disk);};
    DiskEntry*  at(uint index) {return disks->at(index);};
    DiskEntry* first() {return disks->first();};
diff -U 3 -H -d -r -- kdebase/kioslave/devices/kdedmodule/disks.cpp \
                kdebase-patch01/kioslave/devices/kdedmodule/disks.cpp
--- kdebase/kioslave/devices/kdedmodule/disks.cpp	2003-07-26 12:41:22.000000000 +0200
+++ kdebase-patch01/kioslave/devices/kdedmodule/disks.cpp	2004-05-15 \
13:36:55.000000000 +0200 @@ -49,6 +49,7 @@
   type="";
   mountedOn="";
   isMounted=FALSE;
+  isOld=false;
 }
 
 QString DiskEntry::niceDescription()
@@ -182,4 +183,16 @@
   isMounted=nowMounted;
 }
 
+void DiskEntry::setOld(bool old)
+{
+  isOld=old;
+}
+
+bool DiskEntry::old()
+{
+  return isOld;
+}
+
+
+
 #include "disks.moc"
diff -U 3 -H -d -r -- kdebase/kioslave/devices/kdedmodule/disks.h \
                kdebase-patch01/kioslave/devices/kdedmodule/disks.h
--- kdebase/kioslave/devices/kdedmodule/disks.h	2003-05-13 13:27:48.000000000 +0200
+++ kdebase-patch01/kioslave/devices/kdedmodule/disks.h	2004-05-15 13:37:02.000000000 \
+0200 @@ -50,6 +50,7 @@
   ino_t inode() const {return m_inode; };
   bool inodeType() const {return m_inodeType;};
   QString fsType() const { return type; };
+  bool old();
 
   QString discType();
   QString niceDescription();
@@ -59,6 +60,7 @@
   void setMountPoint(const QString & mountPoint);
   void setFsType(const QString & fsType);
   void setMounted(bool nowMounted);
+  void setOld(bool);
 
 private:
   void init();
@@ -73,6 +75,8 @@
   bool        m_inodeType;
 
   ino_t	      m_inode;
+  
+  bool        isOld;
 };
 
 #endif
diff -U 3 -H -d -r -- kdebase/kioslave/devices/kdedmodule/mountwatcher.cpp \
                kdebase-patch01/kioslave/devices/kdedmodule/mountwatcher.cpp
--- kdebase/kioslave/devices/kdedmodule/mountwatcher.cpp	2004-03-13 \
                14:05:34.000000000 +0100
+++ kdebase-patch01/kioslave/devices/kdedmodule/mountwatcher.cpp	2004-05-15 \
13:40:15.000000000 +0200 @@ -65,6 +65,7 @@
 
 	mDiskList.readFSTAB();
 	mDiskList.readMNTTAB();
+	mDiskList.removeOldDisks();
 	reReadSpecialConfig();
 	readDFDone();
 }
@@ -175,8 +176,10 @@
 void MountWatcherModule::reloadExclusionLists()
 {
 	mDiskList.loadExclusionLists();
+	mDiskList.setAllOld();
 	mDiskList.readFSTAB();
 	mDiskList.readMNTTAB();
+	mDiskList.removeOldDisks();
 	readDFDone();
 }
 
@@ -192,8 +195,10 @@
 		if (newsize!=mtabsize) {
 			mtabsize=newsize;
 			kdDebug()<<"MTAB FILESIZE:"<<f.size()<<endl;
+			mDiskList.setAllOld();
 			mDiskList.readFSTAB();
 			mDiskList.readMNTTAB();
+			mDiskList.removeOldDisks();
 			readDFDone();
 			return;
 		}
@@ -202,8 +207,10 @@
 #ifdef FSTAB
 	if (str==FSTAB)
 	{
+		mDiskList.setAllOld(); 
 		mDiskList.readFSTAB();
 		mDiskList.readMNTTAB();
+		mDiskList.removeOldDisks();
 		readDFDone();
 		return;
 	}



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic