src/corelib/io/qfilesystemwatcher_symbian_p.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtCore module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QFILESYSTEMWATCHER_SYMBIAN_P_H
       
    43 #define QFILESYSTEMWATCHER_SYMBIAN_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include "qfilesystemwatcher_p.h"
       
    57 
       
    58 #ifndef QT_NO_FILESYSTEMWATCHER
       
    59 
       
    60 #include "qhash.h"
       
    61 #include "qmutex.h"
       
    62 #include "qwaitcondition.h"
       
    63 
       
    64 #include <e32base.h>
       
    65 #include <f32file.h>
       
    66 
       
    67 QT_BEGIN_NAMESPACE
       
    68 
       
    69 class QSymbianFileSystemWatcherEngine;
       
    70 
       
    71 class QNotifyChangeEvent : public CActive
       
    72 {
       
    73 public:
       
    74     QNotifyChangeEvent(RFs &fsSession, const TDesC &file, QSymbianFileSystemWatcherEngine *engine,
       
    75                        bool aIsDir, TInt aPriority = EPriorityStandard);
       
    76     ~QNotifyChangeEvent();
       
    77 
       
    78     bool isDir;
       
    79 
       
    80 private:
       
    81     void RunL();
       
    82     void DoCancel();
       
    83 
       
    84     RFs &fsSession;
       
    85     TPath watchedPath;
       
    86     QSymbianFileSystemWatcherEngine *engine;
       
    87 
       
    88     int failureCount;
       
    89 };
       
    90 
       
    91 class QSymbianFileSystemWatcherEngine : public QFileSystemWatcherEngine
       
    92 {
       
    93     Q_OBJECT
       
    94 
       
    95 public:
       
    96     QSymbianFileSystemWatcherEngine();
       
    97     ~QSymbianFileSystemWatcherEngine();
       
    98 
       
    99     QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
       
   100     QStringList removePaths(const QStringList &paths, QStringList *files,
       
   101                             QStringList *directories);
       
   102 
       
   103     void stop();
       
   104 
       
   105 protected:
       
   106     void run();
       
   107 
       
   108 public Q_SLOTS:
       
   109     void addNativeListener(const QString &directoryPath);
       
   110     void removeNativeListener();
       
   111 
       
   112 private:
       
   113     friend class QNotifyChangeEvent;
       
   114     void emitPathChanged(QNotifyChangeEvent *e);
       
   115 
       
   116     bool startWatcher();
       
   117 
       
   118     QHash<QNotifyChangeEvent*, QString> activeObjectToPath;
       
   119     QMutex mutex;
       
   120     QWaitCondition syncCondition;
       
   121     int errorCode;
       
   122     bool watcherStarted;
       
   123     QNotifyChangeEvent *currentEvent;
       
   124 };
       
   125 
       
   126 #endif // QT_NO_FILESYSTEMWATCHER
       
   127 
       
   128 QT_END_NAMESPACE
       
   129 
       
   130 #endif // QFILESYSTEMWATCHER_WIN_P_H