-rw-r--r-- | examples/opiecore/onotifytest/.cvsignore | 6 | ||||
-rw-r--r-- | examples/opiecore/onotifytest/main.cpp | 59 | ||||
-rw-r--r-- | examples/opiecore/onotifytest/onotifytest.pro | 16 | ||||
-rw-r--r-- | examples/opiecore/opiecore.pro | 2 | ||||
-rw-r--r-- | libopie2/opiecore/ofilenotify.cpp | 58 | ||||
-rw-r--r-- | libopie2/opiecore/ofilenotify.h | 37 |
6 files changed, 176 insertions, 2 deletions
diff --git a/examples/opiecore/onotifytest/.cvsignore b/examples/opiecore/onotifytest/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/examples/opiecore/onotifytest/.cvsignore @@ -0,0 +1,6 @@ +Makefile* +moc* +*moc +*.o +~* + diff --git a/examples/opiecore/onotifytest/main.cpp b/examples/opiecore/onotifytest/main.cpp new file mode 100644 index 0000000..467ebc9 --- a/dev/null +++ b/examples/opiecore/onotifytest/main.cpp @@ -0,0 +1,59 @@ +// (C) Michael 'Mickey' Lauer <mickey@Vanille.de> +// LICENSE = "GPLv2" + +/* OPIE */ +#include <opie2/odebug.h> +#include <opie2/oapplication.h> +#include <opie2/ofilenotify.h> +using namespace Opie::Core; + +/* QT */ +#include <qpushbutton.h> +#include <qtextstream.h> + +class App : public OApplication +{ + +public: +OFile* tmpfoo; + +App( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify test" ) +{ + odebug << "App()" << oendl; + + tmpfoo = new OFile( "/tmp/foo" ); + if ( tmpfoo->open( IO_ReadWrite ) ) + { + QTextStream stream( tmpfoo ); + stream << "This is my content"; + } + + QObject::connect( tmpfoo, SIGNAL(accessed(const QString&)), this, SLOT(quit()) ); + QObject::connect( tmpfoo, SIGNAL(closed(const QString&,bool)), this, SLOT(quit()) ); +} + +~App() +{ + odebug << "~App()" << oendl; + + delete tmpfoo; +} + +}; + +int main( int argc, char** argv ) +{ + App* app = new App( argc, argv ); + QPushButton* b = new QPushButton( "Click me to close", 0 ); + QObject::connect( b, SIGNAL(clicked()), app, SLOT(quit()) ); + b->resize( 200, 200 ); + b->move( 150, 150 ); + b->show(); + app->setMainWidget( b ); + app->exec(); + delete app; + + return 0; + +} + diff --git a/examples/opiecore/onotifytest/onotifytest.pro b/examples/opiecore/onotifytest/onotifytest.pro new file mode 100644 index 0000000..4e0faec --- a/dev/null +++ b/examples/opiecore/onotifytest/onotifytest.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +CONFIG = qt warn_on +SOURCES = main.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lopiecore2 +TARGET = onotifytest + +!contains( platform, x11 ) { + include( $(OPIEDIR)/include.pro ) +} + +contains( platform, x11 ) { + LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib +} + diff --git a/examples/opiecore/opiecore.pro b/examples/opiecore/opiecore.pro index 1f86a40..3550055 100644 --- a/examples/opiecore/opiecore.pro +++ b/examples/opiecore/opiecore.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo onotifydemo oprocessdemo oplugins oinputsystemdemo +unix:SUBDIRS = odebugdemo oconfigdemo oglobalsettingsdemo onotifydemo onotifytest oprocessdemo oplugins oinputsystemdemo 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 @@ -61,2 +61,58 @@ 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 @@ -221,3 +277,3 @@ void OFileNotification::inotifyEventHandler() char buffer[16384]; - size_t buffer_i; + ssize_t buffer_i; struct inotify_event *pevent, *event; 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 @@ -40,2 +40,4 @@ _;:, .> :=|. This program is free software; you can #include <qstring.h> +#include <qobject.h> +#include <qfile.h> @@ -44,2 +46,37 @@ 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; |