summaryrefslogtreecommitdiffabout
path: root/microkde/kio
Unidiff
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
@@ -1,77 +1,79 @@
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#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 );
54 } 56 }
55 ~KURLDragPushButton() {} 57 ~KURLDragPushButton() {}
56 58
57 void setURL( const KURL& url ) { 59 void setURL( const KURL& url ) {
58 m_urls.clear(); 60 m_urls.clear();
59 m_urls.append( url ); 61 m_urls.append( url );
60 } 62 }
61 63
62 /* not needed so far 64 /* not needed so far
63 void setURLs( const KURL::List& urls ) { 65 void setURLs( const KURL::List& urls ) {
64 m_urls = urls; 66 m_urls = urls;
65 } 67 }
66 const KURL::List& urls() const { return m_urls; } 68 const KURL::List& urls() const { return m_urls; }
67 */ 69 */
68 70
69protected: 71protected:
70/*US 72/*US
71 virtual QDragObject *dragObject() { 73 virtual QDragObject *dragObject() {
72 if ( m_urls.isEmpty() ) 74 if ( m_urls.isEmpty() )
73 return 0L; 75 return 0L;
74 76
75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" ); 77 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" );
76 return drag; 78 return drag;
77 } 79 }
@@ -137,132 +139,132 @@ public:
137 combo->setCompletionObject( comp ); 139 combo->setCompletionObject( comp );
138 else 140 else
139 edit->setCompletionObject( comp ); 141 edit->setCompletionObject( comp );
140 } 142 }
141 */ 143 */
142 /** 144 /**
143 * replaces ~user or $FOO, if necessary 145 * replaces ~user or $FOO, if necessary
144 */ 146 */
145 QString url() { 147 QString url() {
146 QString txt = /*US combo ? combo->currentText() : */ edit->text(); 148 QString txt = /*US combo ? combo->currentText() : */ edit->text();
147/*US KURLCompletion *comp; 149/*US KURLCompletion *comp;
148 if ( combo ) 150 if ( combo )
149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject()); 151 comp = dynamic_cast<KURLCompletion*>(combo->completionObject());
150 else 152 else
151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject()); 153 comp = dynamic_cast<KURLCompletion*>(edit->completionObject());
152 154
153 if ( comp ) 155 if ( comp )
154 return comp->replacedPath( txt ); 156 return comp->replacedPath( txt );
155 else 157 else
156*/ 158*/
157 return txt; 159 return txt;
158 } 160 }
159 161
160 KLineEdit *edit; 162 KLineEdit *edit;
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
245void KURLRequester::setURL( const QString& url ) 247void KURLRequester::setURL( const QString& url )
246{ 248{
247 bool hasLocalPrefix = (url.startsWith("file:")); 249 bool hasLocalPrefix = (url.startsWith("file:"));
248 250
249 if ( !myShowLocalProt && hasLocalPrefix ) 251 if ( !myShowLocalProt && hasLocalPrefix )
250 d->setText( url.mid( 5, url.length()-5 )); 252 d->setText( url.mid( 5, url.length()-5 ));
251 else 253 else
252 d->setText( url ); 254 d->setText( url );
253} 255}
254 256
255void KURLRequester::setCaption( const QString& caption ) 257void KURLRequester::setCaption( const QString& caption )
256{ 258{
257 //USfileDialog()->setCaption( caption ); 259 //USfileDialog()->setCaption( caption );
258 //USQWidget::setCaption( caption ); 260 //USQWidget::setCaption( caption );
259} 261}
260 262
261QString KURLRequester::url() const 263QString KURLRequester::url() const
262{ 264{
263 return d->url(); 265 return d->url();
264} 266}
265 267
266 268
267void KURLRequester::slotOpenDialog() 269void KURLRequester::slotOpenDialog()
268{ 270{
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,104 +1,104 @@
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 );
81 /** 81 /**
82 * Destructs the KURLRequester. 82 * Destructs the KURLRequester.
83 */ 83 */
84 ~KURLRequester(); 84 ~KURLRequester();
85 85
86 /** 86 /**
87 * @returns the current url in the lineedit. May be malformed, if the user 87 * @returns the current url in the lineedit. May be malformed, if the user
88 * entered something weird. ~user or environment variables are substituted 88 * entered something weird. ~user or environment variables are substituted
89 * for local files. 89 * for local files.
90 */ 90 */
91 QString url() const; 91 QString url() const;
92 92
93 /** 93 /**
94 * Enables/disables showing file:/ in the lineedit, when a local file has 94 * Enables/disables showing file:/ in the lineedit, when a local file has
95 * been selected in the filedialog or was set via @ref setURL(). 95 * been selected in the filedialog or was set via @ref setURL().
96 * Default is false, not showing file:/ 96 * Default is false, not showing file:/
97 * @see #showLocalProtocol 97 * @see #showLocalProtocol
98 */ 98 */
99 void setShowLocalProtocol( bool b ); 99 void setShowLocalProtocol( bool b );
100 100
101 /** 101 /**
102 * Sets the mode of the file dialog. 102 * Sets the mode of the file dialog.
103 * Note: you can only select one file with the filedialog, 103 * Note: you can only select one file with the filedialog,
104 * so KFile::Files doesn't make much sense. 104 * so KFile::Files doesn't make much sense.
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
@@ -7,101 +7,103 @@
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* 20/*
21Enhanced Version of the file for platform independent KDE tools. 21Enhanced Version of the file for platform independent KDE tools.
22Copyright (c) 2004 Ulf Schenk 22Copyright (c) 2004 Ulf Schenk
23 23
24$Id$ 24$Id$
25*/ 25*/
26 26
27 27
28// CHANGES: 28// CHANGES:
29// Februar 2002 - Add file watching and remote mount check for STAT 29// Februar 2002 - Add file watching and remote mount check for STAT
30// Mar 30, 2001 - Native support for Linux dir change notification. 30// Mar 30, 2001 - Native support for Linux dir change notification.
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 *
84 * As this is called asynchronously, only a flag is set and 86 * As this is called asynchronously, only a flag is set and
85 * a rescan is requested. 87 * a rescan is requested.
86 * This is done by writing into a pipe to trigger a QSocketNotifier 88 * This is done by writing into a pipe to trigger a QSocketNotifier
87 * watching on this pipe: a timer is started and after a timeout, 89 * watching on this pipe: a timer is started and after a timeout,
88 * the rescan is done. 90 * the rescan is done.
89 */ 91 */
90void KDirWatchPrivate::dnotify_handler(int, siginfo_t *si, void *) 92void KDirWatchPrivate::dnotify_handler(int, siginfo_t *si, void *)
91{ 93{
92 // write might change errno, we have to save it and restore it 94 // write might change errno, we have to save it and restore it
93 // (Richard Stevens, Advanced programming in the Unix Environment) 95 // (Richard Stevens, Advanced programming in the Unix Environment)
94 int saved_errno = errno; 96 int saved_errno = errno;
95 97
96 Entry* e = (dwp_self) ? dwp_self->fd_Entry.find(si->si_fd) :0; 98 Entry* e = (dwp_self) ? dwp_self->fd_Entry.find(si->si_fd) :0;
97 99
98// kdDebug(7001) << "DNOTIFY Handler: fd " << si->si_fd << " path " 100// kdDebug(7001) << "DNOTIFY Handler: fd " << si->si_fd << " path "
99 // << QString(e ? e->path:"unknown") << endl; 101 // << QString(e ? e->path:"unknown") << endl;
100 102
101 if(!e || e->dn_fd != si->si_fd) { 103 if(!e || e->dn_fd != si->si_fd) {
102 qDebug("fatal error in KDirWatch"); 104 qDebug("fatal error in KDirWatch");
103 } else 105 } else
104 e->dn_dirty = true; 106 e->dn_dirty = true;
105 107
106 char c = 0; 108 char c = 0;
107 write(dwp_self->mPipe[1], &c, 1); 109 write(dwp_self->mPipe[1], &c, 1);
@@ -139,97 +141,97 @@ void KDirWatchPrivate::dnotify_sigio_handler(int sig, siginfo_t *si, void *p)
139 (old_sigio_act.sa_handler != SIG_IGN)) 141 (old_sigio_act.sa_handler != SIG_IGN))
140 (*old_sigio_act.sa_handler)(sig); 142 (*old_sigio_act.sa_handler)(sig);
141 } 143 }
142} 144}
143#endif 145#endif
144 146
145 147
146// 148//
147// Class KDirWatchPrivate (singleton) 149// Class KDirWatchPrivate (singleton)
148// 150//
149 151
150/* All entries (files/directories) to be watched in the 152/* All entries (files/directories) to be watched in the
151 * application (coming from multiple KDirWatch instances) 153 * application (coming from multiple KDirWatch instances)
152 * are registered in a single KDirWatchPrivate instance. 154 * are registered in a single KDirWatchPrivate instance.
153 * 155 *
154 * At the moment, the following methods for file watching 156 * At the moment, the following methods for file watching
155 * are supported: 157 * are supported:
156 * - Polling: All files to be watched are polled regularly 158 * - Polling: All files to be watched are polled regularly
157 * using stat (more precise: QFileInfo.lastModified()). 159 * using stat (more precise: QFileInfo.lastModified()).
158 * The polling frequency is determined from global kconfig 160 * The polling frequency is determined from global kconfig
159 * settings, defaulting to 500 ms for local directories 161 * settings, defaulting to 500 ms for local directories
160 * and 5000 ms for remote mounts 162 * and 5000 ms for remote mounts
161 * - FAM (File Alternation Monitor): first used on IRIX, SGI 163 * - FAM (File Alternation Monitor): first used on IRIX, SGI
162 * has ported this method to LINUX. It uses a kernel part 164 * has ported this method to LINUX. It uses a kernel part
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
212 supports_dnotify = true; // not guilty until proven guilty 214 supports_dnotify = true; // not guilty until proven guilty
213 rescan_all = false; 215 rescan_all = false;
214 struct utsname uts; 216 struct utsname uts;
215 int major, minor, patch; 217 int major, minor, patch;
216 if (uname(&uts) < 0) 218 if (uname(&uts) < 0)
217 supports_dnotify = false; // *shrug* 219 supports_dnotify = false; // *shrug*
218 else if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3) 220 else if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3)
219 supports_dnotify = false; // *shrug* 221 supports_dnotify = false; // *shrug*
220 else if( major * 1000000 + minor * 1000 + patch < 2004019 ) { // <2.4.19 222 else if( major * 1000000 + minor * 1000 + patch < 2004019 ) { // <2.4.19
221 kdDebug(7001) << "Can't use DNotify, Linux kernel too old" << endl; 223 kdDebug(7001) << "Can't use DNotify, Linux kernel too old" << endl;
222 supports_dnotify = false; 224 supports_dnotify = false;
223 } 225 }
224 226
225 if( supports_dnotify ) { 227 if( supports_dnotify ) {
226 available += ", DNotify"; 228 available += ", DNotify";
227 229
228 pipe(mPipe); 230 pipe(mPipe);
229 fcntl(mPipe[0], F_SETFD, FD_CLOEXEC); 231 fcntl(mPipe[0], F_SETFD, FD_CLOEXEC);
230 fcntl(mPipe[1], F_SETFD, FD_CLOEXEC); 232 fcntl(mPipe[1], F_SETFD, FD_CLOEXEC);
231 mSn = new QSocketNotifier( mPipe[0], QSocketNotifier::Read, this); 233 mSn = new QSocketNotifier( mPipe[0], QSocketNotifier::Read, this);
232 connect(mSn, SIGNAL(activated(int)), this, SLOT(slotActivated())); 234 connect(mSn, SIGNAL(activated(int)), this, SLOT(slotActivated()));
233 connect(&mTimer, SIGNAL(timeout()), this, SLOT(slotRescan())); 235 connect(&mTimer, SIGNAL(timeout()), this, SLOT(slotRescan()));
234 struct sigaction act; 236 struct sigaction act;
235 act.sa_sigaction = KDirWatchPrivate::dnotify_handler; 237 act.sa_sigaction = KDirWatchPrivate::dnotify_handler;
@@ -686,97 +688,97 @@ void KDirWatchPrivate::removeEntry( KDirWatch* instance,
686#endif 688#endif
687 689
688#ifdef HAVE_DNOTIFY 690#ifdef HAVE_DNOTIFY
689 if (e->m_mode == DNotifyMode) { 691 if (e->m_mode == DNotifyMode) {
690 if (!e->isDir) { 692 if (!e->isDir) {
691 removeEntry(0, QFileInfo(e->path).dirPath(true), e); 693 removeEntry(0, QFileInfo(e->path).dirPath(true), e);
692 } 694 }
693 else { // isDir 695 else { // isDir
694 // must close the FD. 696 // must close the FD.
695 if ( e->m_status == Normal) { 697 if ( e->m_status == Normal) {
696 if (e->dn_fd) { 698 if (e->dn_fd) {
697 ::close(e->dn_fd); 699 ::close(e->dn_fd);
698 fd_Entry.remove(e->dn_fd); 700 fd_Entry.remove(e->dn_fd);
699 701
700 kdDebug(7001) << "Cancelled DNotify (fd " << e->dn_fd 702 kdDebug(7001) << "Cancelled DNotify (fd " << e->dn_fd
701 << ") for " << e->path << endl; 703 << ") for " << e->path << endl;
702 e->dn_fd = 0; 704 e->dn_fd = 0;
703 705
704 } 706 }
705 } 707 }
706 else { 708 else {
707 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e); 709 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e);
708 } 710 }
709 } 711 }
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;
759 } 761 }
760} 762}
761 763
762// instance ==0: stop scanning for all instances 764// instance ==0: stop scanning for all instances
763bool KDirWatchPrivate::stopEntryScan( KDirWatch* instance, Entry* e) 765bool KDirWatchPrivate::stopEntryScan( KDirWatch* instance, Entry* e)
764{ 766{
765 int stillWatching = 0; 767 int stillWatching = 0;
766 Client* c = e->m_clients.first(); 768 Client* c = e->m_clients.first();
767 for(;c;c=e->m_clients.next()) { 769 for(;c;c=e->m_clients.next()) {
768 if (!instance || instance == c->instance) 770 if (!instance || instance == c->instance)
769 c->watchingStopped = true; 771 c->watchingStopped = true;
770 else if (!c->watchingStopped) 772 else if (!c->watchingStopped)
771 stillWatching += c->count; 773 stillWatching += c->count;
772 } 774 }
773 775
774 kdDebug(7001) << instance->name() << " stopped scanning " << e->path 776 kdDebug(7001) << instance->name() << " stopped scanning " << e->path
775 << " (now " << stillWatching << " watchers)" << endl; 777 << " (now " << stillWatching << " watchers)" << endl;
776 778
777 if (stillWatching == 0) { 779 if (stillWatching == 0) {
778 // if nobody is interested, we don't watch 780 // if nobody is interested, we don't watch
779 e->m_ctime = invalid_ctime; // invalid 781 e->m_ctime = invalid_ctime; // invalid
780 // e->m_status = Normal; 782 // e->m_status = Normal;
781 } 783 }
782 return true; 784 return true;
@@ -962,97 +964,97 @@ void KDirWatchPrivate::emitEvent(Entry* e, int event, const QString &fileName)
962 c->pending = NoChange; 964 c->pending = NoChange;
963 if (event == NoChange) continue; 965 if (event == NoChange) continue;
964 966
965 if (event & Deleted) { 967 if (event & Deleted) {
966 c->instance->setDeleted(path); 968 c->instance->setDeleted(path);
967 // emit only Deleted event... 969 // emit only Deleted event...
968 continue; 970 continue;
969 } 971 }
970 972
971 if (event & Created) { 973 if (event & Created) {
972 c->instance->setCreated(path); 974 c->instance->setCreated(path);
973 // possible emit Change event after creation 975 // possible emit Change event after creation
974 } 976 }
975 977
976 if (event & Changed) 978 if (event & Changed)
977 c->instance->setDirty(path); 979 c->instance->setDirty(path);
978 } 980 }
979} 981}
980 982
981// Remove entries which were marked to be removed 983// Remove entries which were marked to be removed
982void KDirWatchPrivate::slotRemoveDelayed() 984void KDirWatchPrivate::slotRemoveDelayed()
983{ 985{
984 Entry* e; 986 Entry* e;
985 delayRemove = false; 987 delayRemove = false;
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)
1035 if (!(*it).isValid()) continue; 1037 if (!(*it).isValid()) continue;
1036 1038
1037 int ev = scanEntry( &(*it) ); 1039 int ev = scanEntry( &(*it) );
1038 1040
1039#ifdef HAVE_DNOTIFY 1041#ifdef HAVE_DNOTIFY
1040 if ((*it).m_mode == DNotifyMode) { 1042 if ((*it).m_mode == DNotifyMode) {
1041 if ((*it).isDir && (ev == Deleted)) { 1043 if ((*it).isDir && (ev == Deleted)) {
1042 dList.append( &(*it) ); 1044 dList.append( &(*it) );
1043 1045
1044 // must close the FD. 1046 // must close the FD.
1045 if ((*it).dn_fd) { 1047 if ((*it).dn_fd) {
1046 ::close((*it).dn_fd); 1048 ::close((*it).dn_fd);
1047 fd_Entry.remove((*it).dn_fd); 1049 fd_Entry.remove((*it).dn_fd);
1048 (*it).dn_fd = 0; 1050 (*it).dn_fd = 0;
1049 } 1051 }
1050 } 1052 }
1051 1053
1052 else if ((*it).isDir && (ev == Created)) { 1054 else if ((*it).isDir && (ev == Created)) {
1053 // For created, but yet without DNOTIFYing ... 1055 // For created, but yet without DNOTIFYing ...
1054 if ( (*it).dn_fd == 0) { 1056 if ( (*it).dn_fd == 0) {
1055 cList.append( &(*it) ); 1057 cList.append( &(*it) );
1056 if (! useDNotify( &(*it) )) { 1058 if (! useDNotify( &(*it) )) {
1057 // if DNotify setup fails... 1059 // if DNotify setup fails...
1058 useStat( &(*it) ); 1060 useStat( &(*it) );
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,153 +1,153 @@
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();
88 88
89 void resetList (KDirWatch*,bool); 89 void resetList (KDirWatch*,bool);
90 void useFreq(Entry* e, int newFreq); 90 void useFreq(Entry* e, int newFreq);
91 void addEntry(KDirWatch*,const QString&, Entry*, bool); 91 void addEntry(KDirWatch*,const QString&, Entry*, bool);
92 void removeEntry(KDirWatch*,const QString&, Entry*); 92 void removeEntry(KDirWatch*,const QString&, Entry*);
93 bool stopEntryScan(KDirWatch*, Entry*); 93 bool stopEntryScan(KDirWatch*, Entry*);
94 bool restartEntryScan(KDirWatch*, Entry*, bool ); 94 bool restartEntryScan(KDirWatch*, Entry*, bool );
95 void stopScan(KDirWatch*); 95 void stopScan(KDirWatch*);
96 void startScan(KDirWatch*, bool, bool); 96 void startScan(KDirWatch*, bool, bool);
97 97
98 void removeEntries(KDirWatch*); 98 void removeEntries(KDirWatch*);
99 void statistics(); 99 void statistics();
100 100
101 Entry* entry(const QString&); 101 Entry* entry(const QString&);
102 int scanEntry(Entry* e); 102 int scanEntry(Entry* e);
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