summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/ofilenotify.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/ofilenotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/ofilenotify.cpp58
1 files changed, 57 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
@@ -50,24 +50,80 @@ using namespace Opie::Core;
50 50
51static QIntDict<OFileNotification> notification_list; 51static QIntDict<OFileNotification> notification_list;
52 52
53QSocketNotifier* OFileNotification::_sn; 53QSocketNotifier* OFileNotification::_sn;
54int OFileNotification::_fd = -1; 54int OFileNotification::_fd = -1;
55 55
56#define INOTIFY_DEVICE "/dev/inotify" 56#define INOTIFY_DEVICE "/dev/inotify"
57 57
58namespace Opie { 58namespace Opie {
59namespace Core { 59namespace Core {
60 60
61//================================================================================================= 61//=================================================================================================
62// OFile
63//=================================================================================================
64
65OFile::OFile() : QObject( 0, 0 ), QFile()
66{
67 qDebug( "OFile()" );
68}
69
70OFile::OFile( const QString& name ) : QObject( 0, 0 ), QFile( name )
71{
72 qDebug( "OFile()" );
73}
74
75OFile::~OFile()
76{
77 qDebug( "~OFile()" );
78}
79
80void 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
107void OFile::disconnectNotify( const char* signal )
108{
109 qDebug( "OFile::disconnectNotify() signal = '%s'", signal );
110 QObject::disconnectNotify( signal );
111}
112
113int OFile::startWatch( int mode )
114{
115}
116
117//=================================================================================================
62// OFileNotificationEvent 118// OFileNotificationEvent
63//================================================================================================= 119//=================================================================================================
64OFileNotificationEvent::OFileNotificationEvent( OFileNotification* parent, int wd, unsigned int mask, unsigned int cookie, const QString& name ) 120OFileNotificationEvent::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 )
66{ 122{
67 qDebug( "OFileNotificationEvent()" ); 123 qDebug( "OFileNotificationEvent()" );
68} 124}
69 125
70 126
71OFileNotificationEvent::~OFileNotificationEvent() 127OFileNotificationEvent::~OFileNotificationEvent()
72{ 128{
73 qDebug( "~OFileNotificationEvent()" ); 129 qDebug( "~OFileNotificationEvent()" );
@@ -210,25 +266,25 @@ bool OFileNotification::singleShot( const QString& path, QObject* receiver, cons
210{ 266{
211 OFileNotification* ofn = new OFileNotification(); 267 OFileNotification* ofn = new OFileNotification();
212 ofn->_signal.connect( receiver, member ); 268 ofn->_signal.connect( receiver, member );
213 return ofn->watch( path, true, type ) != -1; 269 return ofn->watch( path, true, type ) != -1;
214} 270}
215 271
216 272
217void OFileNotification::inotifyEventHandler() 273void 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;
227 283
228 r = ::read(_fd, buffer, 16384); 284 r = ::read(_fd, buffer, 16384);
229 285
230 if ( r <= 0 ) 286 if ( r <= 0 )
231 return; 287 return;
232 288
233 buffer_i = 0; 289 buffer_i = 0;
234 while ( buffer_i < r ) 290 while ( buffer_i < r )