Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Opie::Core::OFileNotification Class Reference

Represents a file notification. More...

#include </home/clem/local/src/opie/libopie2/opiecore/linux/ofilenotify.h>

Collaboration diagram for Opie::Core::OFileNotification:

Collaboration graph
[legend]
List of all members.

Signals

void triggered (const QString &, unsigned int, const QString &)
void accessed (const QString &)
void modified (const QString &)
void attributed (const QString &)
void closed (const QString &, bool)
void opened (const QString &)
void movedTo (const QString &, const QString &)
void movedFrom (const QString &, const QString &)
void deletedSubdir (const QString &, const QString &)
void deletedFile (const QString &, const QString &)
void createdSubdir (const QString &, const QString &)
void createdFile (const QString &, const QString &)
void deleted (const QString &)
void unmounted (const QString &)

Public Member Functions

 OFileNotification (QObject *parent=0, const char *name=0)
 ~OFileNotification ()
int watch (const QString &path, bool sshot=false, OFileNotificationType type=Modify)
void stop ()
OFileNotificationType type () const
QString path () const
bool isSingleShot () const
bool isActive () const
int startWatching (const QString &path, bool sshot=false, OFileNotificationType type=Modify)

Static Public Member Functions

static bool singleShot (const QString &path, QObject *receiver, const char *member, OFileNotificationType type=Modify)

Protected Member Functions

bool activate (const OFileNotificationEvent *e)

Private Slots

void inotifyEventHandler ()

Private Member Functions

bool registerEventHandler ()
void unregisterEventHandler ()

Private Attributes

QString _path
OFileNotificationType _type
QSignal _signal
bool _active
bool _multi
int _wd

Static Private Attributes

static QSocketNotifier * _sn
static int _fd = -1

Friends

class OFileNotificationEvent

Detailed Description

Represents a file notification.

This class allows to watch for events happening to files. It uses the inotify linux (2.6.x) kernel interface.

See also:
http://www.kernel.org/pub/linux/kernel/people/rml/inotify/
Author:
Michael 'Mickey' Lauer <mickey@vanille.de>

Definition at line 149 of file ofilenotify.h.


Constructor & Destructor Documentation

Opie::Core::OFileNotification::OFileNotification QObject *  parent = 0,
const char *  name = 0
 

Definition at line 135 of file ofilenotify.cpp.

References qDebug().

Referenced by singleShot().

Opie::Core::OFileNotification::~OFileNotification  ) 
 

Definition at line 142 of file ofilenotify.cpp.

References qDebug(), and stop().


Member Function Documentation

void Opie::Core::OFileNotification::accessed const QString  )  [signal]
 

Referenced by activate().

bool Opie::Core::OFileNotification::activate const OFileNotificationEvent e  )  [protected]
 

Definition at line 235 of file ofilenotify.cpp.

References Opie::Core::_Ignored, _multi, _path, Opie::Core::_QueueOverflow, _signal, Opie::Core::Access, accessed(), assert, Opie::Core::Attrib, attributed(), closed(), Opie::Core::CloseNoWrite, Opie::Core::CloseWrite, Opie::Core::OFileNotificationEvent::cookie(), createdFile(), createdSubdir(), Opie::Core::CreateFile, Opie::Core::CreateSubdir, deleted(), deletedFile(), deletedSubdir(), Opie::Core::DeleteFile, Opie::Core::DeleteSelf, Opie::Core::DeleteSubdir, Opie::Core::OFileNotificationEvent::descriptor(), Opie::Core::OFileNotificationEvent::mask(), modified(), Opie::Core::Modify, movedFrom(), Opie::Core::MovedFrom, movedTo(), Opie::Core::MovedTo, Opie::Core::OFileNotificationEvent::name(), Opie::Core::Open, opened(), qDebug(), qFatal(), qWarning(), stop(), triggered(), Opie::Core::Unmount, and unmounted().

Referenced by Opie::Core::OFileNotificationEvent::activate().

void Opie::Core::OFileNotification::attributed const QString  )  [signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::closed const QString ,
bool 
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::createdFile const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::createdSubdir const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::deleted const QString  )  [signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::deletedFile const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::deletedSubdir const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::inotifyEventHandler  )  [private, slot]
 

Definition at line 285 of file ofilenotify.cpp.

References _fd, inotify_event::cookie, inotify_event::len, inotify_event::mask, inotify_event::name, OFileNotificationEvent, qDebug(), and inotify_event::wd.

Referenced by registerEventHandler().

bool Opie::Core::OFileNotification::isActive  )  const
 

Returns:
if a file is currently being watched.

Definition at line 149 of file ofilenotify.cpp.

References _active.

bool Opie::Core::OFileNotification::isSingleShot  )  const
 

Returns:
if the notification is single-shot

Definition at line 229 of file ofilenotify.cpp.

References _multi.

Referenced by Opie::Core::ODirNotification::subdirCreated().

void Opie::Core::OFileNotification::modified const QString  )  [signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::movedFrom const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::movedTo const QString ,
const QString
[signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::opened const QString  )  [signal]
 

Referenced by activate().

QString Opie::Core::OFileNotification::path  )  const
 

Returns:
the path to the file being watched by this instance.

Definition at line 223 of file ofilenotify.cpp.

References _path.

Referenced by Opie::Core::ODirNotification::subdirCreated().

bool Opie::Core::OFileNotification::registerEventHandler  )  [private]
 

Definition at line 317 of file ofilenotify.cpp.

References _fd, _sn, INOTIFY_DEVICE, inotifyEventHandler(), qDebug(), and qWarning().

Referenced by startWatching().

bool Opie::Core::OFileNotification::singleShot const QString path,
QObject *  receiver,
const char *  member,
OFileNotificationType  type = Modify
[static]
 

This static function calls a slot when an event with type happens to file path.

It is very convenient to use this function because you do not need to bother with a timerEvent or to create a local QTimer object.

Example:

     #include <opie2/oapplication.h>
     #include <opie2/ofilenotify.h>
     using namespace Opie::Core;

     int main( int argc, char **argv )
     {
         OApplication a( argc, argv, "File Notification Example" );
         OFileNotification::singleShot( "/tmp/quit", &a, SLOT(quit()), Access );
         ... // create and show your widgets
         return a.exec();
     }
  

This sample program automatically terminates when the file "/tmp/quit" has been accessed.

The receiver is the receiving object and the member is the slot.

Definition at line 277 of file ofilenotify.cpp.

References _signal, OFileNotification(), and watch().

int Opie::Core::OFileNotification::startWatching const QString path,
bool  sshot = false,
OFileNotificationType  type = Modify
 

For internal use only.

Definition at line 174 of file ofilenotify.cpp.

References _active, _fd, _multi, _path, _type, _wd, INOTIFY_WATCH, QIntDict< type >::insert(), QIntDict< type >::isEmpty(), inotify_watch_request::name, qDebug(), qWarning(), and registerEventHandler().

Referenced by Opie::Core::ODirNotification::watch(), and watch().

void Opie::Core::OFileNotification::stop  ) 
 

Stop watching for file events.

Definition at line 204 of file ofilenotify.cpp.

References _active, _path, _wd, QIntDict< type >::isEmpty(), QString::null, QIntDict< type >::remove(), and unregisterEventHandler().

Referenced by activate(), and ~OFileNotification().

void Opie::Core::OFileNotification::triggered const QString ,
unsigned  int,
const QString
[signal]
 

Referenced by activate().

OFileNotificationType Opie::Core::OFileNotification::type  )  const
 

Returns:
the notification type as set by start().

Definition at line 217 of file ofilenotify.cpp.

References _type.

Referenced by Opie::Core::ODirNotification::subdirCreated().

void Opie::Core::OFileNotification::unmounted const QString  )  [signal]
 

Referenced by activate().

void Opie::Core::OFileNotification::unregisterEventHandler  )  [private]
 

Definition at line 334 of file ofilenotify.cpp.

References _fd, _sn, and qDebug().

Referenced by stop().

int Opie::Core::OFileNotification::watch const QString path,
bool  sshot = false,
OFileNotificationType  type = Modify
 

Starts to watch for type changes to path. Set sshot to True if you want to be notified only once. Note that in that case it may be more convenient to use OFileNotification::singleShot() then.

Definition at line 155 of file ofilenotify.cpp.

References qWarning(), and startWatching().

Referenced by DemoApp::addTrigger(), and singleShot().


Friends And Related Function Documentation

friend class OFileNotificationEvent [friend]
 

Definition at line 249 of file ofilenotify.h.

Referenced by inotifyEventHandler().


Member Data Documentation

bool Opie::Core::OFileNotification::_active [private]
 

Definition at line 243 of file ofilenotify.h.

Referenced by isActive(), startWatching(), and stop().

int OFileNotification::_fd = -1 [static, private]
 

Definition at line 54 of file ofilenotify.cpp.

Referenced by inotifyEventHandler(), registerEventHandler(), startWatching(), and unregisterEventHandler().

bool Opie::Core::OFileNotification::_multi [private]
 

Definition at line 244 of file ofilenotify.h.

Referenced by activate(), isSingleShot(), and startWatching().

QString Opie::Core::OFileNotification::_path [private]
 

Definition at line 240 of file ofilenotify.h.

Referenced by activate(), path(), startWatching(), and stop().

QSignal Opie::Core::OFileNotification::_signal [private]
 

Definition at line 242 of file ofilenotify.h.

Referenced by activate(), and singleShot().

QSocketNotifier * OFileNotification::_sn [static, private]
 

Definition at line 53 of file ofilenotify.cpp.

Referenced by registerEventHandler(), and unregisterEventHandler().

OFileNotificationType Opie::Core::OFileNotification::_type [private]
 

Definition at line 241 of file ofilenotify.h.

Referenced by startWatching(), and type().

int Opie::Core::OFileNotification::_wd [private]
 

Definition at line 246 of file ofilenotify.h.

Referenced by startWatching(), and stop().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 18:00:29 2005 for OPIE by  doxygen 1.4.2