summaryrefslogtreecommitdiffabout
path: root/microkde/kio
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kio
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kio') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kio/kfile/kurlrequester.cpp10
-rw-r--r--microkde/kio/kfile/kurlrequester.h4
-rw-r--r--microkde/kio/kio/kdirwatch.cpp12
-rw-r--r--microkde/kio/kio/kdirwatch_p.h10
4 files changed, 20 insertions, 16 deletions
diff --git a/microkde/kio/kfile/kurlrequester.cpp b/microkde/kio/kfile/kurlrequester.cpp
index ca94570..ce62da7 100644
--- a/microkde/kio/kfile/kurlrequester.cpp
+++ b/microkde/kio/kfile/kurlrequester.cpp
@@ -6,48 +6,50 @@
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#include <sys/stat.h> 20#include <sys/stat.h>
21#ifdef _WIN32_ 21#ifdef _WIN32_
22 22
23#else 23#else
24#include <unistd.h> 24#include <unistd.h>
25#endif 25#endif
26#include <qstring.h> 26#include <qstring.h>
27//US #include <qtooltip.h> 27//US #include <qtooltip.h>
28 28
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30//Added by qt3to4:
31#include <QPixmap>
30 32
31//US #include <kaccel.h> 33//US #include <kaccel.h>
32//US #include <kcombobox.h> 34//US #include <kcombobox.h>
33#include <kdebug.h> 35#include <kdebug.h>
34#include <kdialog.h> 36#include <kdialog.h>
35#include <kfiledialog.h> 37#include <kfiledialog.h>
36#include <kglobal.h> 38#include <kglobal.h>
37#include <kiconloader.h> 39#include <kiconloader.h>
38#include <klineedit.h> 40#include <klineedit.h>
39#include <klocale.h> 41#include <klocale.h>
40//US #include <kurlcompletion.h> 42//US #include <kurlcompletion.h>
41//US #include <kurldrag.h> 43//US #include <kurldrag.h>
42//US #include <kprotocolinfo.h> 44//US #include <kprotocolinfo.h>
43 45
44 46
45#include "kurlrequester.h" 47#include "kurlrequester.h"
46 48
47 49
48class KURLDragPushButton : public QPushButton 50class KURLDragPushButton : public QPushButton
49{ 51{
50public: 52public:
51 KURLDragPushButton( QWidget *parent, const char *name=0 ) 53 KURLDragPushButton( QWidget *parent, const char *name=0 )
52 : QPushButton( parent, name ) { 54 : QPushButton( parent, name ) {
53 //US setDragEnabled( true ); 55 //US setDragEnabled( true );
@@ -161,84 +163,84 @@ public:
161//US KComboBox *combo; 163//US KComboBox *combo;
162 int fileDialogMode; 164 int fileDialogMode;
163 QString fileDialogFilter; 165 QString fileDialogFilter;
164}; 166};
165 167
166 168
167/*US 169/*US
168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent, 170KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent,
169 const char *name ) 171 const char *name )
170 : QHBox( parent, name ) 172 : QHBox( parent, name )
171{ 173{
172 d = new KURLRequesterPrivate; 174 d = new KURLRequesterPrivate;
173 175
174 // must have this as parent 176 // must have this as parent
175 editWidget->reparent( this, 0, QPoint(0,0) ); 177 editWidget->reparent( this, 0, QPoint(0,0) );
176//US d->edit = dynamic_cast<KLineEdit*>( editWidget ); 178//US d->edit = dynamic_cast<KLineEdit*>( editWidget );
177 d->edit = (KLineEdit*)( editWidget ); 179 d->edit = (KLineEdit*)( editWidget );
178//US d->combo = dynamic_cast<KComboBox*>( editWidget ); 180//US d->combo = dynamic_cast<KComboBox*>( editWidget );
179 181
180 init(); 182 init();
181} 183}
182*/ 184*/
183 185
184KURLRequester::KURLRequester( QWidget *parent, const char *name ) 186KURLRequester::KURLRequester( QWidget *parent, const char *name )
185 : QHBox( parent, name ) 187 : Q3HBox( parent, name )
186{ 188{
187 d = new KURLRequesterPrivate; 189 d = new KURLRequesterPrivate;
188 init(); 190 init();
189} 191}
190 192
191 193
192KURLRequester::KURLRequester( const QString& url, QWidget *parent, 194KURLRequester::KURLRequester( const QString& url, QWidget *parent,
193 const char *name ) 195 const char *name )
194 : QHBox( parent, name ) 196 : Q3HBox( parent, name )
195{ 197{
196 d = new KURLRequesterPrivate; 198 d = new KURLRequesterPrivate;
197 init(); 199 init();
198 setURL( url ); 200 setURL( url );
199} 201}
200 202
201 203
202KURLRequester::~KURLRequester() 204KURLRequester::~KURLRequester()
203{ 205{
204//US delete myCompletion; 206//US delete myCompletion;
205 delete myFileDialog; 207 delete myFileDialog;
206 delete d; 208 delete d;
207} 209}
208 210
209 211
210void KURLRequester::init() 212void KURLRequester::init()
211{ 213{
212 myFileDialog = 0L; 214 myFileDialog = 0L;
213 myShowLocalProt = false; 215 myShowLocalProt = false;
214 mPathIsDir = false; 216 mPathIsDir = false;
215 if (/*US !d->combo && */ !d->edit ) 217 if (/*US !d->combo && */ !d->edit )
216 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); 218 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" );
217 219
218 myButton = new KURLDragPushButton( this, "kfile button"); 220 myButton = new KURLDragPushButton( this, "kfile button");
219 QIconSet iconSet = SmallIconSet("fileopen"); 221 QIcon iconSet = SmallIconSet("fileopen");
220 QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); 222 QPixmap pixMap = iconSet.pixmap( QIcon::Small, QIcon::Normal );
221 myButton->setIconSet( iconSet ); 223 myButton->setIconSet( iconSet );
222 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); 224 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
223//US QToolTip::add(myButton, i18n("Open file dialog")); 225//US QToolTip::add(myButton, i18n("Open file dialog"));
224 226
225 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() )); 227 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() ));
226 228
227 setSpacing( KDialog::spacingHint() ); 229 setSpacing( KDialog::spacingHint() );
228 230
229 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit; 231 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit;
230 setFocusProxy( widget ); 232 setFocusProxy( widget );
231 233
232 d->connectSignals( this ); 234 d->connectSignals( this );
233 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() )); 235 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() ));
234/*US 236/*US
235 myCompletion = new KURLCompletion(); 237 myCompletion = new KURLCompletion();
236 d->setCompletionObject( myCompletion ); 238 d->setCompletionObject( myCompletion );
237 239
238 KAccel *accel = new KAccel( this ); 240 KAccel *accel = new KAccel( this );
239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() )); 241 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() ));
240 accel->readSettings(); 242 accel->readSettings();
241*/ 243*/
242} 244}
243 245
244 246
diff --git a/microkde/kio/kfile/kurlrequester.h b/microkde/kio/kfile/kurlrequester.h
index faa3326..5d4fa11 100644
--- a/microkde/kio/kfile/kurlrequester.h
+++ b/microkde/kio/kfile/kurlrequester.h
@@ -1,80 +1,80 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#ifndef KURLREQUESTER_H 20#ifndef KURLREQUESTER_H
21#define KURLREQUESTER_H 21#define KURLREQUESTER_H
22 22
23#include <qhbox.h> 23#include <q3hbox.h>
24 24
25#include <keditlistbox.h> 25#include <keditlistbox.h>
26//US #include <kfile.h> 26//US #include <kfile.h>
27//US #include <kpushbutton.h> 27//US #include <kpushbutton.h>
28#include <kurl.h> 28#include <kurl.h>
29 29
30//US class KComboBox; 30//US class KComboBox;
31 31
32class KFileDialog; 32class KFileDialog;
33class KLineEdit; 33class KLineEdit;
34//US class KURLCompletion; 34//US class KURLCompletion;
35class KURLDragPushButton; 35class KURLDragPushButton;
36 36
37class QPushButton; 37class QPushButton;
38class QString; 38class QString;
39class QTimer; 39class QTimer;
40 40
41/** 41/**
42 * This class is a widget showing a lineedit and a button, which invokes a 42 * This class is a widget showing a lineedit and a button, which invokes a
43 * filedialog. File name completion is available in the lineedit. 43 * filedialog. File name completion is available in the lineedit.
44 * 44 *
45 * The defaults for the filedialog are to ask for one existing local file, i.e. 45 * The defaults for the filedialog are to ask for one existing local file, i.e.
46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ) 46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly )
47 * The default filter is "*", i.e. show all files, and the start directory is 47 * The default filter is "*", i.e. show all files, and the start directory is
48 * the current working directory, or the last directory where a file has been 48 * the current working directory, or the last directory where a file has been
49 * selected. 49 * selected.
50 * 50 *
51 * You can change this behavior by using @ref setMode() or @ref setFilter(). 51 * You can change this behavior by using @ref setMode() or @ref setFilter().
52 * 52 *
53 * @short A widget to request a filename/url from the user 53 * @short A widget to request a filename/url from the user
54 * @author Carsten Pfeiffer <pfeiffer@kde.org> 54 * @author Carsten Pfeiffer <pfeiffer@kde.org>
55 */ 55 */
56class KURLRequester : public QHBox 56class KURLRequester : public Q3HBox
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 Q_PROPERTY( QString url READ url WRITE setURL ) 59 Q_PROPERTY( QString url READ url WRITE setURL )
60 60
61public: 61public:
62 /** 62 /**
63 * Constructs a KURLRequester widget. 63 * Constructs a KURLRequester widget.
64 */ 64 */
65 KURLRequester( QWidget *parent=0, const char *name=0 ); 65 KURLRequester( QWidget *parent=0, const char *name=0 );
66 66
67 /** 67 /**
68 * Constructs a KURLRequester widget with the initial URL @p url. 68 * Constructs a KURLRequester widget with the initial URL @p url.
69 */ 69 */
70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 ); 70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 );
71 71
72 /** 72 /**
73 * Special constructor, which creates a KURLRequester widget with a custom 73 * Special constructor, which creates a KURLRequester widget with a custom
74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit 74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit
75 * (or inherited thereof). Note: for geometry management reasons, the 75 * (or inherited thereof). Note: for geometry management reasons, the
76 * edit-widget is reparented to have the KURLRequester as parent. 76 * edit-widget is reparented to have the KURLRequester as parent.
77 * @param modal specifies whether the filedialog should be opened as modal 77 * @param modal specifies whether the filedialog should be opened as modal
78 * or not. 78 * or not.
79 */ 79 */
80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 ); 80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 );
diff --git a/microkde/kio/kio/kdirwatch.cpp b/microkde/kio/kio/kdirwatch.cpp
index 1596d1f..5f07c54 100644
--- a/microkde/kio/kio/kdirwatch.cpp
+++ b/microkde/kio/kio/kdirwatch.cpp
@@ -31,53 +31,55 @@ $Id$
31// Jan 28, 2000 - Usage of FAM service on IRIX (Josef.Weidendorfer@in.tum.de) 31// Jan 28, 2000 - Usage of FAM service on IRIX (Josef.Weidendorfer@in.tum.de)
32// May 24. 1998 - List of times introduced, and some bugs are fixed. (sven) 32// May 24. 1998 - List of times introduced, and some bugs are fixed. (sven)
33// May 23. 1998 - Removed static pointer - you can have more instances. 33// May 23. 1998 - Removed static pointer - you can have more instances.
34// It was Needed for KRegistry. KDirWatch now emits signals and doesn't 34// It was Needed for KRegistry. KDirWatch now emits signals and doesn't
35// call (or need) KFM. No more URL's - just plain paths. (sven) 35// call (or need) KFM. No more URL's - just plain paths. (sven)
36// Mar 29. 1998 - added docs, stop/restart for particular Dirs and 36// Mar 29. 1998 - added docs, stop/restart for particular Dirs and
37// deep copies for list of dirs. (sven) 37// deep copies for list of dirs. (sven)
38// Mar 28. 1998 - Created. (sven) 38// Mar 28. 1998 - Created. (sven)
39 39
40 40
41//US #include <config.h> 41//US #include <config.h>
42 42
43#ifdef HAVE_DNOTIFY 43#ifdef HAVE_DNOTIFY
44#include <unistd.h> 44#include <unistd.h>
45#include <time.h> 45#include <time.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <signal.h> 47#include <signal.h>
48#include <errno.h> 48#include <errno.h>
49#endif 49#endif
50 50
51#include <sys/stat.h> 51#include <sys/stat.h>
52#include <assert.h> 52#include <assert.h>
53#include <qdir.h> 53#include <qdir.h>
54#include <qfile.h> 54#include <qfile.h>
55#include <qintdict.h> 55#include <q3intdict.h>
56#include <qptrlist.h> 56#include <q3ptrlist.h>
57#include <qsocketnotifier.h> 57#include <qsocketnotifier.h>
58#include <qstringlist.h> 58#include <qstringlist.h>
59#include <qtimer.h> 59#include <qtimer.h>
60//Added by qt3to4:
61#include <Q3CString>
60 62
61#include <kapplication.h> 63#include <kapplication.h>
62#include <kdebug.h> 64#include <kdebug.h>
63#include <kconfig.h> 65#include <kconfig.h>
64#include <kconfigbase.h> 66#include <kconfigbase.h>
65#include <kglobal.h> 67#include <kglobal.h>
66#include <kstaticdeleter.h> 68#include <kstaticdeleter.h>
67 69
68#include "kdirwatch.h" 70#include "kdirwatch.h"
69#include "kdirwatch_p.h" 71#include "kdirwatch_p.h"
70//US #include "global.h" // KIO::probably_slow_mounted 72//US #include "global.h" // KIO::probably_slow_mounted
71 73
72#define NO_NOTIFY (time_t) 0 74#define NO_NOTIFY (time_t) 0
73 75
74static KDirWatchPrivate* dwp_self = 0; 76static KDirWatchPrivate* dwp_self = 0;
75 77
76#ifdef HAVE_DNOTIFY 78#ifdef HAVE_DNOTIFY
77 79
78#include <sys/utsname.h> 80#include <sys/utsname.h>
79 81
80static int dnotify_signal = 0; 82static int dnotify_signal = 0;
81 83
82/* DNOTIFY signal handler 84/* DNOTIFY signal handler
83 * 85 *
@@ -163,49 +165,49 @@ void KDirWatchPrivate::dnotify_sigio_handler(int sig, siginfo_t *si, void *p)
163 * (IMON, sending change events to /dev/imon) and a user 165 * (IMON, sending change events to /dev/imon) and a user
164 * level damon (fam), to which applications connect for 166 * level damon (fam), to which applications connect for
165 * notification of file changes. For NFS, the fam damon 167 * notification of file changes. For NFS, the fam damon
166 * on the NFS server machine is used; if IMON is not built 168 * on the NFS server machine is used; if IMON is not built
167 * into the kernel, fam uses polling for local files. 169 * into the kernel, fam uses polling for local files.
168 * - DNOTIFY: In late LINUX 2.3.x, directory notification was 170 * - DNOTIFY: In late LINUX 2.3.x, directory notification was
169 * introduced. By opening a directory, you can request for 171 * introduced. By opening a directory, you can request for
170 * UNIX signals to be sent to the process when a directory 172 * UNIX signals to be sent to the process when a directory
171 * is changed. 173 * is changed.
172 */ 174 */
173 175
174KDirWatchPrivate::KDirWatchPrivate() 176KDirWatchPrivate::KDirWatchPrivate()
175{ 177{
176 timer = new QTimer(this); 178 timer = new QTimer(this);
177 connect (timer, SIGNAL(timeout()), this, SLOT(slotRescan())); 179 connect (timer, SIGNAL(timeout()), this, SLOT(slotRescan()));
178 freq = 3600000; // 1 hour as upper bound 180 freq = 3600000; // 1 hour as upper bound
179 statEntries = 0; 181 statEntries = 0;
180 delayRemove = false; 182 delayRemove = false;
181 m_ref = 0; 183 m_ref = 0;
182 184
183//US KConfigGroup config(KGlobal::config(), QCString("DirWatch")); 185//US KConfigGroup config(KGlobal::config(), QCString("DirWatch"));
184//US m_nfsPollInterval = config.readNumEntry("NFSPollInterval", 5000); 186//US m_nfsPollInterval = config.readNumEntry("NFSPollInterval", 5000);
185//US m_PollInterval = config.readNumEntry("PollInterval", 500); 187//US m_PollInterval = config.readNumEntry("PollInterval", 500);
186 KConfig *config = KGlobal::config(); 188 KConfig *config = KGlobal::config();
187 KConfigGroupSaver saver( config, QCString("DirWatch") ); 189 KConfigGroupSaver saver( config, Q3CString("DirWatch") );
188 190
189 m_nfsPollInterval = config->readNumEntry("NFSPollInterval", 5000); 191 m_nfsPollInterval = config->readNumEntry("NFSPollInterval", 5000);
190 m_PollInterval = config->readNumEntry("PollInterval", 500); 192 m_PollInterval = config->readNumEntry("PollInterval", 500);
191 193
192 194
193 QString available("Stat"); 195 QString available("Stat");
194 196
195#ifdef HAVE_FAM 197#ifdef HAVE_FAM
196 // It's possible that FAM server can't be started 198 // It's possible that FAM server can't be started
197 if (FAMOpen(&fc) ==0) { 199 if (FAMOpen(&fc) ==0) {
198 available += ", FAM"; 200 available += ", FAM";
199 use_fam=true; 201 use_fam=true;
200 sn = new QSocketNotifier( FAMCONNECTION_GETFD(&fc), 202 sn = new QSocketNotifier( FAMCONNECTION_GETFD(&fc),
201 QSocketNotifier::Read, this); 203 QSocketNotifier::Read, this);
202 connect( sn, SIGNAL(activated(int)), 204 connect( sn, SIGNAL(activated(int)),
203 this, SLOT(famEventReceived()) ); 205 this, SLOT(famEventReceived()) );
204 } 206 }
205 else { 207 else {
206 kdDebug(7001) << "Can't use FAM (fam daemon not running?)" << endl; 208 kdDebug(7001) << "Can't use FAM (fam daemon not running?)" << endl;
207 use_fam=false; 209 use_fam=false;
208 } 210 }
209#endif 211#endif
210 212
211#ifdef HAVE_DNOTIFY 213#ifdef HAVE_DNOTIFY
@@ -710,49 +712,49 @@ void KDirWatchPrivate::removeEntry( KDirWatch* instance,
710 } 712 }
711#endif 713#endif
712 714
713 if (e->m_mode == StatMode) { 715 if (e->m_mode == StatMode) {
714 statEntries--; 716 statEntries--;
715 if ( statEntries == 0 ) { 717 if ( statEntries == 0 ) {
716 timer->stop(); // stop timer if lists are empty 718 timer->stop(); // stop timer if lists are empty
717 kdDebug(7001) << " Stopped Polling Timer" << endl; 719 kdDebug(7001) << " Stopped Polling Timer" << endl;
718 } 720 }
719 } 721 }
720 722
721 kdDebug(7001) << "Removed " << (e->isDir ? "Dir ":"File ") << e->path 723 kdDebug(7001) << "Removed " << (e->isDir ? "Dir ":"File ") << e->path
722 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString("")) 724 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString(""))
723 << (instance ? QString(" [%1]").arg(instance->name()) : QString("")) 725 << (instance ? QString(" [%1]").arg(instance->name()) : QString(""))
724 << endl; 726 << endl;
725 m_mapEntries.remove( e->path ); // <e> not valid any more 727 m_mapEntries.remove( e->path ); // <e> not valid any more
726} 728}
727 729
728 730
729/* Called from KDirWatch destructor: 731/* Called from KDirWatch destructor:
730 * remove <instance> as client from all entries 732 * remove <instance> as client from all entries
731 */ 733 */
732void KDirWatchPrivate::removeEntries( KDirWatch* instance ) 734void KDirWatchPrivate::removeEntries( KDirWatch* instance )
733{ 735{
734 QPtrList<Entry> list; 736 Q3PtrList<Entry> list;
735 int minfreq = 3600000; 737 int minfreq = 3600000;
736 738
737 // put all entries where instance is a client in list 739 // put all entries where instance is a client in list
738 EntryMap::Iterator it = m_mapEntries.begin(); 740 EntryMap::Iterator it = m_mapEntries.begin();
739 for( ; it != m_mapEntries.end(); ++it ) { 741 for( ; it != m_mapEntries.end(); ++it ) {
740 Client* c = (*it).m_clients.first(); 742 Client* c = (*it).m_clients.first();
741 for(;c;c=(*it).m_clients.next()) 743 for(;c;c=(*it).m_clients.next())
742 if (c->instance == instance) break; 744 if (c->instance == instance) break;
743 if (c) { 745 if (c) {
744 c->count = 1; // forces deletion of instance as client 746 c->count = 1; // forces deletion of instance as client
745 list.append(&(*it)); 747 list.append(&(*it));
746 } 748 }
747 else if ( (*it).m_mode == StatMode && (*it).freq < minfreq ) 749 else if ( (*it).m_mode == StatMode && (*it).freq < minfreq )
748 minfreq = (*it).freq; 750 minfreq = (*it).freq;
749 } 751 }
750 752
751 for(Entry* e=list.first();e;e=list.next()) 753 for(Entry* e=list.first();e;e=list.next())
752 removeEntry(instance, e->path, 0); 754 removeEntry(instance, e->path, 0);
753 755
754 if (minfreq > freq) { 756 if (minfreq > freq) {
755 // we can decrease the global polling frequency 757 // we can decrease the global polling frequency
756 freq = minfreq; 758 freq = minfreq;
757 if (timer->isActive()) timer->changeInterval(freq); 759 if (timer->isActive()) timer->changeInterval(freq);
758 kdDebug(7001) << "Poll Freq now " << freq << " msec" << endl; 760 kdDebug(7001) << "Poll Freq now " << freq << " msec" << endl;
@@ -986,49 +988,49 @@ void KDirWatchPrivate::slotRemoveDelayed()
986 for(e=removeList.first();e;e=removeList.next()) 988 for(e=removeList.first();e;e=removeList.next())
987 removeEntry(0, e->path, 0); 989 removeEntry(0, e->path, 0);
988 removeList.clear(); 990 removeList.clear();
989} 991}
990 992
991/* Scan all entries to be watched for changes. This is done regularly 993/* Scan all entries to be watched for changes. This is done regularly
992 * when polling and once after a DNOTIFY signal. This is NOT used by FAM. 994 * when polling and once after a DNOTIFY signal. This is NOT used by FAM.
993 */ 995 */
994void KDirWatchPrivate::slotRescan() 996void KDirWatchPrivate::slotRescan()
995{ 997{
996 EntryMap::Iterator it; 998 EntryMap::Iterator it;
997 999
998 // People can do very long things in the slot connected to dirty(), 1000 // People can do very long things in the slot connected to dirty(),
999 // like showing a message box. We don't want to keep polling during 1001 // like showing a message box. We don't want to keep polling during
1000 // that time, otherwise the value of 'delayRemove' will be reset. 1002 // that time, otherwise the value of 'delayRemove' will be reset.
1001 bool timerRunning = timer->isActive(); 1003 bool timerRunning = timer->isActive();
1002 if ( timerRunning ) 1004 if ( timerRunning )
1003 timer->stop(); 1005 timer->stop();
1004 1006
1005 // We delay deletions of entries this way. 1007 // We delay deletions of entries this way.
1006 // removeDir(), when called in slotDirty(), can cause a crash otherwise 1008 // removeDir(), when called in slotDirty(), can cause a crash otherwise
1007 delayRemove = true; 1009 delayRemove = true;
1008 1010
1009#ifdef HAVE_DNOTIFY 1011#ifdef HAVE_DNOTIFY
1010 QPtrList<Entry> dList, cList; 1012 Q3PtrList<Entry> dList, cList;
1011 1013
1012 // for DNotify method, 1014 // for DNotify method,
1013 if (rescan_all) 1015 if (rescan_all)
1014 { 1016 {
1015 // mark all as dirty 1017 // mark all as dirty
1016 it = m_mapEntries.begin(); 1018 it = m_mapEntries.begin();
1017 for( ; it != m_mapEntries.end(); ++it ) 1019 for( ; it != m_mapEntries.end(); ++it )
1018 (*it).dn_dirty = true; 1020 (*it).dn_dirty = true;
1019 rescan_all = false; 1021 rescan_all = false;
1020 } 1022 }
1021 else 1023 else
1022 { 1024 {
1023 // progate dirty flag to dependant entries (e.g. file watches) 1025 // progate dirty flag to dependant entries (e.g. file watches)
1024 it = m_mapEntries.begin(); 1026 it = m_mapEntries.begin();
1025 for( ; it != m_mapEntries.end(); ++it ) 1027 for( ; it != m_mapEntries.end(); ++it )
1026 if ( ((*it).m_mode == DNotifyMode) && (*it).dn_dirty ) 1028 if ( ((*it).m_mode == DNotifyMode) && (*it).dn_dirty )
1027 (*it).propagate_dirty(); 1029 (*it).propagate_dirty();
1028 } 1030 }
1029 1031
1030#endif 1032#endif
1031 1033
1032 it = m_mapEntries.begin(); 1034 it = m_mapEntries.begin();
1033 for( ; it != m_mapEntries.end(); ++it ) { 1035 for( ; it != m_mapEntries.end(); ++it ) {
1034 // we don't check invalid entries (i.e. remove delayed) 1036 // we don't check invalid entries (i.e. remove delayed)
diff --git a/microkde/kio/kio/kdirwatch_p.h b/microkde/kio/kio/kdirwatch_p.h
index 0ab482f..be74f2a 100644
--- a/microkde/kio/kio/kdirwatch_p.h
+++ b/microkde/kio/kio/kdirwatch_p.h
@@ -1,87 +1,87 @@
1/* Private Header for class of KDirWatchPrivate 1/* Private Header for class of KDirWatchPrivate
2 * 2 *
3 * this separate header file is needed for MOC processing 3 * this separate header file is needed for MOC processing
4 * because KDirWatchPrivate has signals and slots 4 * because KDirWatchPrivate has signals and slots
5 */ 5 */
6 6
7/* 7/*
8Enhanced Version of the file for platform independent KDE tools. 8Enhanced Version of the file for platform independent KDE tools.
9Copyright (c) 2004 Ulf Schenk 9Copyright (c) 2004 Ulf Schenk
10 10
11$Id$ 11$Id$
12*/ 12*/
13 13
14#ifndef _KDIRWATCH_P_H 14#ifndef _KDIRWATCH_P_H
15#define _KDIRWATCH_P_H 15#define _KDIRWATCH_P_H
16 16
17#ifdef HAVE_FAM 17#ifdef HAVE_FAM
18#include <fam.h> 18#include <fam.h>
19#endif 19#endif
20 20
21#include <qptrlist.h> 21#include <q3ptrlist.h>
22 22
23#include <kdirwatch.h> 23#include <kdirwatch.h>
24 24
25#include <ctime> 25#include <ctime>
26 26
27#define invalid_ctime ((time_t)-1) 27#define invalid_ctime ((time_t)-1)
28 28
29/* KDirWatchPrivate is a singleton and does the watching 29/* KDirWatchPrivate is a singleton and does the watching
30 * for every KDirWatch instance in the application. 30 * for every KDirWatch instance in the application.
31 */ 31 */
32class KDirWatchPrivate : public QObject 32class KDirWatchPrivate : public QObject
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 36
37 enum entryStatus { Normal = 0, NonExistent }; 37 enum entryStatus { Normal = 0, NonExistent };
38 enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode }; 38 enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode };
39 enum { NoChange=0, Changed=1, Created=2, Deleted=4 }; 39 enum { NoChange=0, Changed=1, Created=2, Deleted=4 };
40 40
41 struct Client { 41 struct Client {
42 KDirWatch* instance; 42 KDirWatch* instance;
43 int count; 43 int count;
44 // did the instance stop watching 44 // did the instance stop watching
45 bool watchingStopped; 45 bool watchingStopped;
46 // events blocked when stopped 46 // events blocked when stopped
47 int pending; 47 int pending;
48 }; 48 };
49 49
50 class Entry 50 class Entry
51 { 51 {
52 public: 52 public:
53 // the last observed modification time 53 // the last observed modification time
54 time_t m_ctime; 54 time_t m_ctime;
55 // the last observed link count 55 // the last observed link count
56 int m_nlink; 56 int m_nlink;
57 entryStatus m_status; 57 entryStatus m_status;
58 entryMode m_mode; 58 entryMode m_mode;
59 bool isDir; 59 bool isDir;
60 // instances interested in events 60 // instances interested in events
61 QPtrList<Client> m_clients; 61 Q3PtrList<Client> m_clients;
62 // nonexistent entries of this directory 62 // nonexistent entries of this directory
63 QPtrList<Entry> m_entries; 63 Q3PtrList<Entry> m_entries;
64 QString path; 64 QString path;
65 65
66 int msecLeft, freq; 66 int msecLeft, freq;
67 67
68 void addClient(KDirWatch*); 68 void addClient(KDirWatch*);
69 void removeClient(KDirWatch*); 69 void removeClient(KDirWatch*);
70 int clients(); 70 int clients();
71 bool isValid() { return m_clients.count() || m_entries.count(); } 71 bool isValid() { return m_clients.count() || m_entries.count(); }
72 72
73#ifdef HAVE_FAM 73#ifdef HAVE_FAM
74 FAMRequest fr; 74 FAMRequest fr;
75#endif 75#endif
76 76
77#ifdef HAVE_DNOTIFY 77#ifdef HAVE_DNOTIFY
78 int dn_fd; 78 int dn_fd;
79 bool dn_dirty; 79 bool dn_dirty;
80 void propagate_dirty(); 80 void propagate_dirty();
81#endif 81#endif
82 }; 82 };
83 83
84 typedef QMap<QString,Entry> EntryMap; 84 typedef QMap<QString,Entry> EntryMap;
85 85
86 KDirWatchPrivate(); 86 KDirWatchPrivate();
87 ~KDirWatchPrivate(); 87 ~KDirWatchPrivate();
@@ -103,51 +103,51 @@ public:
103 void emitEvent(Entry* e, int event, const QString &fileName = QString::null); 103 void emitEvent(Entry* e, int event, const QString &fileName = QString::null);
104 104
105 // Memory management - delete when last KDirWatch gets deleted 105 // Memory management - delete when last KDirWatch gets deleted
106 void ref() { m_ref++; } 106 void ref() { m_ref++; }
107 bool deref() { return ( --m_ref == 0 ); } 107 bool deref() { return ( --m_ref == 0 ); }
108 108
109public slots: 109public slots:
110 void slotRescan(); 110 void slotRescan();
111 void famEventReceived(); // for FAM 111 void famEventReceived(); // for FAM
112 void slotActivated(); // for DNOTIFY 112 void slotActivated(); // for DNOTIFY
113 void slotRemoveDelayed(); 113 void slotRemoveDelayed();
114 114
115public: 115public:
116 QTimer *timer; 116 QTimer *timer;
117 EntryMap m_mapEntries; 117 EntryMap m_mapEntries;
118 118
119private: 119private:
120 int freq; 120 int freq;
121 int statEntries; 121 int statEntries;
122 int m_nfsPollInterval, m_PollInterval; 122 int m_nfsPollInterval, m_PollInterval;
123 int m_ref; 123 int m_ref;
124 bool useStat(Entry*); 124 bool useStat(Entry*);
125 125
126 bool delayRemove; 126 bool delayRemove;
127 QPtrList<Entry> removeList; 127 Q3PtrList<Entry> removeList;
128 128
129#ifdef HAVE_FAM 129#ifdef HAVE_FAM
130 QSocketNotifier *sn; 130 QSocketNotifier *sn;
131 FAMConnection fc; 131 FAMConnection fc;
132 bool use_fam; 132 bool use_fam;
133 133
134 void checkFAMEvent(FAMEvent*); 134 void checkFAMEvent(FAMEvent*);
135 bool useFAM(Entry*); 135 bool useFAM(Entry*);
136#endif 136#endif
137 137
138#ifdef HAVE_DNOTIFY 138#ifdef HAVE_DNOTIFY
139 bool supports_dnotify; 139 bool supports_dnotify;
140 bool rescan_all; 140 bool rescan_all;
141 int mPipe[2]; 141 int mPipe[2];
142 QTimer mTimer; 142 QTimer mTimer;
143 QSocketNotifier *mSn; 143 QSocketNotifier *mSn;
144 QIntDict<Entry> fd_Entry; 144 Q3IntDict<Entry> fd_Entry;
145 145
146 static void dnotify_handler(int, siginfo_t *si, void *); 146 static void dnotify_handler(int, siginfo_t *si, void *);
147 static void dnotify_sigio_handler(int, siginfo_t *si, void *); 147 static void dnotify_sigio_handler(int, siginfo_t *si, void *);
148 bool useDNotify(Entry*); 148 bool useDNotify(Entry*);
149#endif 149#endif
150}; 150};
151 151
152#endif // KDIRWATCH_P_H 152#endif // KDIRWATCH_P_H
153 153