From kde-core-devel Tue May 18 14:27:39 2004 From: Dirk Mueller Date: Tue, 18 May 2004 14:27:39 +0000 To: kde-core-devel Subject: Fwd: Little mountwatcher patch. Message-Id: <200405181627.39837.mueller () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=108489047005167 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_b1hqATXaayfTmDE" --Boundary-00=_b1hqATXaayfTmDE Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, any comments? Dirk --Boundary-00=_b1hqATXaayfTmDE Content-Type: message/rfc822; name="forwarded message" Content-Transfer-Encoding: 7bit Content-Description: Simone Gotti : Little mountwatcher patch. Content-Disposition: inline Return-Path: Delivered-To: dirk@mail.kde.org Received: (qmail 9372 invoked by uid 1055); 15 May 2004 12:22:55 -0000 Delivered-To: kde.org-mueller@kde.org Received: (qmail 9370 invoked from network); 15 May 2004 12:22:55 -0000 Received: from av1.mm.cineca.it (130.186.10.238) by ktown.kde.org with SMTP; 15 May 2004 12:22:52 -0000 Received: from unipr.mm.cineca.it (unipr.mm.cineca.it [130.186.10.204]) by av1.mm.cineca.it (Postfix) with ESMTP id 4CCD816D29D for ; Sat, 15 May 2004 14:22:51 +0200 (CEST) Received: from [10.224.151.1] (gmoboutz4.net.vodafone.it [194.185.97.58]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) as user simone.gotti@studenti.unipr.it by unipr.mm.cineca.it (Postfix) with ESMTP id 1077B21DD7B for ; Sat, 15 May 2004 14:22:44 +0200 (MEST) From: Simone Gotti To: mueller@kde.org Subject: Little mountwatcher patch. Date: Sat, 15 May 2004 14:12:42 +0200 User-Agent: KMail/1.6.52 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_YygpAVKLZyR7NKT" Message-Id: <200405151427.04145.simone.gotti@email.it> X-Virus-Scanned: Spin SafeMail X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on ktown.kde.org X-UIDL: Z2b!!R"a"!G`'"!_La"! --Boundary-00=_YygpAVKLZyR7NKT Content-Type: text/plain; charset="us-ascii"; boundary="" Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: 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 --Boundary-00=_YygpAVKLZyR7NKT Content-Type: text/x-diff; charset="us-ascii"; name="mountwatcher-patch-SimoneGotti-01.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mountwatcher-patch-SimoneGotti-01.patch" 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: "<deviceName()<count(); i++ ) @@ -239,5 +242,26 @@ } } +void DiskList::setAllOld() +{ + for( u_int i=0; icount(); i++ ) + { + DiskEntry *item = disks->at(i); + item->setOld(true); + } +} + +void DiskList::removeOldDisks() +{ + for( u_int i=0; icount(); 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:"<