summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-05-10 13:30:51 (UTC)
committer mickeyl <mickeyl>2005-05-10 13:30:51 (UTC)
commite31f22952f47aeb54b206349f1e469704a6a6e8f (patch) (side-by-side diff)
tree2aa06bf1ebd9850b1e987d1dcc94794699a0c9fe /libopie2
parent9bcf6a5112d31ffdc196ebcd22a584c68f9f7b1e (diff)
downloadopie-e31f22952f47aeb54b206349f1e469704a6a6e8f.zip
opie-e31f22952f47aeb54b206349f1e469704a6a6e8f.tar.gz
opie-e31f22952f47aeb54b206349f1e469704a6a6e8f.tar.bz2
add foundation for a much more intuitive API for file notifications
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/ofilenotify.cpp58
-rw-r--r--libopie2/opiecore/ofilenotify.h37
2 files changed, 94 insertions, 1 deletions
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/ofilenotify.cpp
index 4264327..36ec6bf 100644
--- a/libopie2/opiecore/ofilenotify.cpp
+++ b/libopie2/opiecore/ofilenotify.cpp
@@ -54,16 +54,72 @@ QSocketNotifier* OFileNotification::_sn;
int OFileNotification::_fd = -1;
#define INOTIFY_DEVICE "/dev/inotify"
namespace Opie {
namespace Core {
//=================================================================================================
+// OFile
+//=================================================================================================
+
+OFile::OFile() : QObject( 0, 0 ), QFile()
+{
+ qDebug( "OFile()" );
+}
+
+OFile::OFile( const QString& name ) : QObject( 0, 0 ), QFile( name )
+{
+ qDebug( "OFile()" );
+}
+
+OFile::~OFile()
+{
+ qDebug( "~OFile()" );
+}
+
+void OFile::connectNotify( const char *signal )
+{
+ QString s = normalizeSignalSlot( signal+1 );
+ qDebug( "OFile::connectNotify() signal = '%s'", (const char*) s );
+
+ if ( s.startsWith( "accessed" ) )
+
+
+
+
+
+
+
+ QObject::connectNotify( signal );
+
+/*
+ void accessed( const QString& );
+ void modified( const QString& );
+ void attributed( const QString& );
+ void closed( const QString&, bool );
+ void opened( const QString& );
+ void deleted( const QString& );
+ void unmounted( const QString& );
+*/
+
+}
+
+void OFile::disconnectNotify( const char* signal )
+{
+ qDebug( "OFile::disconnectNotify() signal = '%s'", signal );
+ QObject::disconnectNotify( signal );
+}
+
+int OFile::startWatch( int mode )
+{
+}
+
+//=================================================================================================
// OFileNotificationEvent
//=================================================================================================
OFileNotificationEvent::OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name )
:_parent( parent ), _wd( wd ), _mask( mask ), _cookie( cookie ), _name( name )
{
qDebug( "OFileNotificationEvent()" );
}
@@ -214,17 +270,17 @@ bool OFileNotification::singleShot( const QString& path, QObject* receiver, cons
}
void OFileNotification::inotifyEventHandler()
{
qDebug( "OFileNotification::inotifyEventHandler(): reached." );
char buffer[16384];
- size_t buffer_i;
+ ssize_t buffer_i;
struct inotify_event *pevent, *event;
ssize_t r;
size_t event_size;
int count = 0;
r = ::read(_fd, buffer, 16384);
if ( r <= 0 )
diff --git a/libopie2/opiecore/ofilenotify.h b/libopie2/opiecore/ofilenotify.h
index 5bbf421..05343b9 100644
--- a/libopie2/opiecore/ofilenotify.h
+++ b/libopie2/opiecore/ofilenotify.h
@@ -33,20 +33,57 @@ _;:,     .>    :=|. This program is free software; you can
#endif
#include "linux_inotify.h"
/* QT */
#include <qsocketnotifier.h>
#include <qsignal.h>
#include <qstring.h>
+#include <qobject.h>
+#include <qfile.h>
namespace Opie {
namespace Core {
+class OFile : public QObject, public QFile
+{
+ Q_OBJECT
+
+ public:
+ OFile();
+ OFile( const QString & name );
+ virtual ~OFile();
+
+ protected:
+ virtual void connectNotify( const char* signal );
+ virtual void disconnectNotify( const char* signal );
+
+ private:
+ int startWatch( int mode );
+
+ signals:
+ void accessed( const QString& );
+ void modified( const QString& );
+ void attributed( const QString& );
+ void closed( const QString&, bool );
+ void opened( const QString& );
+ void deleted( const QString& );
+ void unmounted( 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& );
+*/
+
class OFileNotificationEvent;
/*======================================================================================
* OFileNotificationType
*======================================================================================*/
/**
* @brief An enumerate for the different types of file notifications