kio Library API Documentation

kdirwatch_p.h

00001 /* Private Header for class of KDirWatchPrivate
00002  *
00003  * this separate header file is needed for MOC processing
00004  * because KDirWatchPrivate has signals and slots
00005  */
00006 
00007 #ifndef _KDIRWATCH_P_H
00008 #define _KDIRWATCH_P_H
00009 
00010 #ifdef HAVE_FAM
00011 #include <fam.h>
00012 #endif
00013 
00014 #include <ctime>
00015 
00016 #define invalid_ctime ((time_t)-1)
00017 
00018 /* KDirWatchPrivate is a singleton and does the watching
00019  * for every KDirWatch instance in the application.
00020  */
00021 class KDirWatchPrivate : public QObject
00022 {
00023   Q_OBJECT
00024 public:
00025 
00026   enum entryStatus { Normal = 0, NonExistent };
00027   enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode };
00028   enum { NoChange=0, Changed=1, Created=2, Deleted=4 };
00029 
00030   struct Client {
00031     KDirWatch* instance;
00032     int count;
00033     // did the instance stop watching
00034     bool watchingStopped;
00035     // events blocked when stopped
00036     int pending;
00037   };
00038 
00039   class Entry
00040   {
00041   public:
00042     // the last observed modification time
00043     time_t m_ctime;
00044     // the last observed link count
00045     int m_nlink; 
00046     entryStatus m_status;
00047     entryMode m_mode;
00048     bool isDir;
00049     // instances interested in events
00050     QPtrList<Client> m_clients;
00051     // nonexistent entries of this directory
00052     QPtrList<Entry> m_entries;
00053     QString path;
00054 
00055     int msecLeft, freq;
00056 
00057     void addClient(KDirWatch*);
00058     void removeClient(KDirWatch*);
00059     int clients();
00060     bool isValid() { return m_clients.count() || m_entries.count(); }
00061 
00062 #ifdef HAVE_FAM
00063     FAMRequest fr;
00064 #endif
00065 
00066 #ifdef HAVE_DNOTIFY
00067     int dn_fd;
00068     bool dn_dirty;
00069     void propagate_dirty();
00070 #endif
00071   };
00072 
00073   typedef QMap<QString,Entry> EntryMap;
00074 
00075   KDirWatchPrivate();
00076   ~KDirWatchPrivate();
00077 
00078   void resetList (KDirWatch*,bool);
00079   void useFreq(Entry* e, int newFreq);
00080   void addEntry(KDirWatch*,const QString&, Entry*, bool);
00081   void removeEntry(KDirWatch*,const QString&, Entry*);
00082   bool stopEntryScan(KDirWatch*, Entry*);
00083   bool restartEntryScan(KDirWatch*, Entry*, bool );
00084   void stopScan(KDirWatch*);
00085   void startScan(KDirWatch*, bool, bool);
00086 
00087   void removeEntries(KDirWatch*);
00088   void statistics();
00089 
00090   Entry* entry(const QString&);
00091   int scanEntry(Entry* e);
00092   void emitEvent(Entry* e, int event, const QString &fileName = QString::null);
00093 
00094   // Memory management - delete when last KDirWatch gets deleted
00095   void ref() { m_ref++; }
00096   bool deref() { return ( --m_ref == 0 ); }
00097 
00098 public slots:
00099   void slotRescan();
00100   void famEventReceived(); // for FAM
00101   void slotActivated(); // for DNOTIFY
00102   void slotRemoveDelayed();
00103 
00104 public:
00105   QTimer *timer;
00106   EntryMap m_mapEntries;
00107 
00108   int freq;
00109   int statEntries;
00110   int m_nfsPollInterval, m_PollInterval;
00111   int m_ref;
00112   bool useStat(Entry*);
00113 
00114   bool delayRemove;
00115   QPtrList<Entry> removeList;
00116 
00117 #ifdef HAVE_FAM
00118   QSocketNotifier *sn;
00119   FAMConnection fc;
00120   bool use_fam;
00121 
00122   void checkFAMEvent(FAMEvent*);
00123   bool useFAM(Entry*);
00124 #endif
00125 
00126 #ifdef HAVE_DNOTIFY
00127   bool supports_dnotify;
00128   bool rescan_all;
00129   int mPipe[2];
00130   QTimer mTimer;
00131   QSocketNotifier *mSn;
00132   QIntDict<Entry> fd_Entry;
00133 
00134   static void dnotify_handler(int, siginfo_t *si, void *);
00135   static void dnotify_sigio_handler(int, siginfo_t *si, void *);
00136   bool useDNotify(Entry*);
00137 #endif
00138 };
00139 
00140 #endif // KDIRWATCH_P_H
00141 
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Aug 4 05:25:32 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003