author | mickeyl <mickeyl> | 2005-05-10 13:30:51 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-10 13:30:51 (UTC) |
commit | e31f22952f47aeb54b206349f1e469704a6a6e8f (patch) (unidiff) | |
tree | 2aa06bf1ebd9850b1e987d1dcc94794699a0c9fe /libopie2 | |
parent | 9bcf6a5112d31ffdc196ebcd22a584c68f9f7b1e (diff) | |
download | opie-e31f22952f47aeb54b206349f1e469704a6a6e8f.zip opie-e31f22952f47aeb54b206349f1e469704a6a6e8f.tar.gz opie-e31f22952f47aeb54b206349f1e469704a6a6e8f.tar.bz2 |
add foundation for a much more intuitive API for file notifications
-rw-r--r-- | libopie2/opiecore/ofilenotify.cpp | 58 | ||||
-rw-r--r-- | libopie2/opiecore/ofilenotify.h | 37 |
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 | |||
@@ -58,8 +58,64 @@ int OFileNotification::_fd = -1; | |||
58 | namespace Opie { | 58 | namespace Opie { |
59 | namespace Core { | 59 | namespace Core { |
60 | 60 | ||
61 | //================================================================================================= | 61 | //================================================================================================= |
62 | // OFile | ||
63 | //================================================================================================= | ||
64 | |||
65 | OFile::OFile() : QObject( 0, 0 ), QFile() | ||
66 | { | ||
67 | qDebug( "OFile()" ); | ||
68 | } | ||
69 | |||
70 | OFile::OFile( const QString& name ) : QObject( 0, 0 ), QFile( name ) | ||
71 | { | ||
72 | qDebug( "OFile()" ); | ||
73 | } | ||
74 | |||
75 | OFile::~OFile() | ||
76 | { | ||
77 | qDebug( "~OFile()" ); | ||
78 | } | ||
79 | |||
80 | void OFile::connectNotify( const char *signal ) | ||
81 | { | ||
82 | QString s = normalizeSignalSlot( signal+1 ); | ||
83 | qDebug( "OFile::connectNotify() signal = '%s'", (const char*) s ); | ||
84 | |||
85 | if ( s.startsWith( "accessed" ) ) | ||
86 | |||
87 | |||
88 | |||
89 | |||
90 | |||
91 | |||
92 | |||
93 | QObject::connectNotify( signal ); | ||
94 | |||
95 | /* | ||
96 | void accessed( const QString& ); | ||
97 | void modified( const QString& ); | ||
98 | void attributed( const QString& ); | ||
99 | void closed( const QString&, bool ); | ||
100 | void opened( const QString& ); | ||
101 | void deleted( const QString& ); | ||
102 | void unmounted( const QString& ); | ||
103 | */ | ||
104 | |||
105 | } | ||
106 | |||
107 | void OFile::disconnectNotify( const char* signal ) | ||
108 | { | ||
109 | qDebug( "OFile::disconnectNotify() signal = '%s'", signal ); | ||
110 | QObject::disconnectNotify( signal ); | ||
111 | } | ||
112 | |||
113 | int OFile::startWatch( int mode ) | ||
114 | { | ||
115 | } | ||
116 | |||
117 | //================================================================================================= | ||
62 | // OFileNotificationEvent | 118 | // OFileNotificationEvent |
63 | //================================================================================================= | 119 | //================================================================================================= |
64 | OFileNotificationEvent::OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name ) | 120 | OFileNotificationEvent::OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name ) |
65 | :_parent( parent ), _wd( wd ), _mask( mask ), _cookie( cookie ), _name( name ) | 121 | :_parent( parent ), _wd( wd ), _mask( mask ), _cookie( cookie ), _name( name ) |
@@ -218,9 +274,9 @@ void OFileNotification::inotifyEventHandler() | |||
218 | { | 274 | { |
219 | qDebug( "OFileNotification::inotifyEventHandler(): reached." ); | 275 | qDebug( "OFileNotification::inotifyEventHandler(): reached." ); |
220 | 276 | ||
221 | char buffer[16384]; | 277 | char buffer[16384]; |
222 | size_t buffer_i; | 278 | ssize_t buffer_i; |
223 | struct inotify_event *pevent, *event; | 279 | struct inotify_event *pevent, *event; |
224 | ssize_t r; | 280 | ssize_t r; |
225 | size_t event_size; | 281 | size_t event_size; |
226 | int count = 0; | 282 | int count = 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 | |||
@@ -37,12 +37,49 @@ _;:, .> :=|. This program is free software; you can | |||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qsocketnotifier.h> | 38 | #include <qsocketnotifier.h> |
39 | #include <qsignal.h> | 39 | #include <qsignal.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qobject.h> | ||
42 | #include <qfile.h> | ||
41 | 43 | ||
42 | namespace Opie { | 44 | namespace Opie { |
43 | namespace Core { | 45 | namespace Core { |
44 | 46 | ||
47 | class OFile : public QObject, public QFile | ||
48 | { | ||
49 | Q_OBJECT | ||
50 | |||
51 | public: | ||
52 | OFile(); | ||
53 | OFile( const QString & name ); | ||
54 | virtual ~OFile(); | ||
55 | |||
56 | protected: | ||
57 | virtual void connectNotify( const char* signal ); | ||
58 | virtual void disconnectNotify( const char* signal ); | ||
59 | |||
60 | private: | ||
61 | int startWatch( int mode ); | ||
62 | |||
63 | signals: | ||
64 | void accessed( const QString& ); | ||
65 | void modified( const QString& ); | ||
66 | void attributed( const QString& ); | ||
67 | void closed( const QString&, bool ); | ||
68 | void opened( const QString& ); | ||
69 | void deleted( const QString& ); | ||
70 | void unmounted( const QString& ); | ||
71 | }; | ||
72 | |||
73 | /* | ||
74 | void movedTo( const QString&, const QString& ); | ||
75 | void movedFrom( const QString&, const QString& ); | ||
76 | void deletedSubdir( const QString&, const QString& ); | ||
77 | void deletedFile( const QString&, const QString& ); | ||
78 | void createdSubdir( const QString&, const QString& ); | ||
79 | void createdFile( const QString&, const QString& ); | ||
80 | */ | ||
81 | |||
45 | class OFileNotificationEvent; | 82 | class OFileNotificationEvent; |
46 | 83 | ||
47 | /*====================================================================================== | 84 | /*====================================================================================== |
48 | * OFileNotificationType | 85 | * OFileNotificationType |