summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-09-27 16:08:07 (GMT)
committermread <qt-info@nokia.com>2011-09-28 10:41:33 (GMT)
commit827ba304d068eed1c0bd1dacbfbbe82115f43bd2 (patch)
treee6e318a994ede429e818e146dc3a448981c76511
parenteef7c0674d667e1a932a58944a80a0046d08445a (diff)
downloadQt-827ba304d068eed1c0bd1dacbfbbe82115f43bd2.zip
Qt-827ba304d068eed1c0bd1dacbfbbe82115f43bd2.tar.gz
Qt-827ba304d068eed1c0bd1dacbfbbe82115f43bd2.tar.bz2
Making QNotifyChangeEvent, Symbian file watcher, more widely usable
QNotifyChangeEvent was being used by QSymbianFileSystemWatcherEngine, but it also helps in the implementation of new plugin watching for QTBUG-20098. So it has been generalised to work with an interface and any class that implements that interface. The Qt file system watchers could not be used in QTBUG-20098, as they will not watch for currently non-existing directories. Task-number: QTBUG-20098 Reviewed-by: Shane Kearns
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp10
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian_p.h18
2 files changed, 17 insertions, 11 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index 63cc4f1..fa857c6 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -52,7 +52,7 @@
QT_BEGIN_NAMESPACE
QNotifyChangeEvent::QNotifyChangeEvent(RFs &fs, const TDesC &file,
- QSymbianFileSystemWatcherEngine *e, bool aIsDir,
+ QSymbianFileSystemWatcherInterface *e, bool aIsDir,
TInt aPriority) :
CActive(aPriority),
isDir(aIsDir),
@@ -96,9 +96,9 @@ void QNotifyChangeEvent::RunL()
if (!failureCount) {
int err;
- QT_TRYCATCH_ERROR(err, engine->emitPathChanged(this));
+ QT_TRYCATCH_ERROR(err, engine->handlePathChanged(this));
if (err != KErrNone)
- qWarning("QNotifyChangeEvent::RunL() - emitPathChanged threw exception (Converted error code: %d)", err);
+ qWarning("QNotifyChangeEvent::RunL() - handlePathChanged threw exception (Converted error code: %d)", err);
}
}
}
@@ -203,7 +203,7 @@ QStringList QSymbianFileSystemWatcherEngine::removePaths(const QStringList &path
return p;
}
-void QSymbianFileSystemWatcherEngine::emitPathChanged(QNotifyChangeEvent *e)
+void QSymbianFileSystemWatcherEngine::handlePathChanged(QNotifyChangeEvent *e)
{
QMutexLocker locker(&mutex);
@@ -255,7 +255,7 @@ void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directory
QMutexLocker locker(&mutex);
QString nativeDir(QDir::toNativeSeparators(directoryPath));
TPtrC ptr(qt_QString2TPtrC(nativeDir));
- currentAddEvent = new QNotifyChangeEvent(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
+ currentAddEvent = q_check_ptr(new QNotifyChangeEvent(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'))));
syncCondition.wakeOne();
}
diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h
index 0b317a0..842df80 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian_p.h
+++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h
@@ -66,29 +66,35 @@
QT_BEGIN_NAMESPACE
-class QSymbianFileSystemWatcherEngine;
+class QSymbianFileSystemWatcherInterface;
class QNotifyChangeEvent : public CActive
{
public:
- QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherEngine *engine,
+ QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherInterface *engine,
bool aIsDir, TInt aPriority = EPriorityStandard);
~QNotifyChangeEvent();
bool isDir;
+ TPath watchedPath;
private:
void RunL();
void DoCancel();
RFs &fsSession;
- TPath watchedPath;
- QSymbianFileSystemWatcherEngine *engine;
+ QSymbianFileSystemWatcherInterface *engine;
int failureCount;
};
-class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine
+class QSymbianFileSystemWatcherInterface
+{
+public:
+ virtual void handlePathChanged(QNotifyChangeEvent *e) = 0;
+};
+
+class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine, public QSymbianFileSystemWatcherInterface
{
Q_OBJECT
@@ -111,7 +117,7 @@ public Q_SLOTS:
private:
friend class QNotifyChangeEvent;
- void emitPathChanged(QNotifyChangeEvent *e);
+ void handlePathChanged(QNotifyChangeEvent *e);
void startWatcher();