src/publishsubscribe/settingslayer_symbian_p.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 Qt Mobility Components.
       
     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 SYMBIANSETTINGSLAYER_H
       
    43 #define SYMBIANSETTINGSLAYER_H
       
    44 
       
    45 #include "qvaluespace_p.h"
       
    46 #include "qvaluespacepublisher.h"
       
    47 
       
    48 #include <QHash>
       
    49 #include <QSet>
       
    50 #include <QByteArray>
       
    51 #include <QMultiMap>
       
    52 
       
    53 #ifdef __WINS__
       
    54     #include "pathmapper_symbian_p.h"
       
    55 #else
       
    56     #include "pathmapper_proxy_symbian_p.h"
       
    57 #endif
       
    58 
       
    59 #include "xqsettingsmanager.h"
       
    60 
       
    61 QTM_BEGIN_NAMESPACE
       
    62 
       
    63 class SymbianSettingsLayer : public QAbstractValueSpaceLayer
       
    64 {
       
    65     Q_OBJECT
       
    66 
       
    67 public:
       
    68     SymbianSettingsLayer();
       
    69     virtual ~SymbianSettingsLayer();
       
    70 
       
    71 protected:
       
    72     /*virtual*/ QString name();
       
    73 
       
    74     /*virtual*/ bool startup(Type type);
       
    75 
       
    76     /*virtual*/ QUuid id();
       
    77     /*virtual*/ unsigned int order();
       
    78 
       
    79     /*virtual*/ Handle item(Handle parent, const QString &subPath);
       
    80     /*virtual*/ void removeHandle(Handle handle);
       
    81     /*virtual*/ void setProperty(Handle handle, Properties properties);
       
    82 
       
    83     /*virtual*/ bool value(Handle handle, QVariant *data);
       
    84     /*virtual*/ bool value(Handle handle, const QString &subPath, QVariant *data);
       
    85     /*virtual*/ QSet<QString> children(Handle handle);
       
    86 
       
    87     /*virtual*/ QValueSpace::LayerOptions layerOptions() const;
       
    88 
       
    89     /* QValueSpaceSubscriber functions */
       
    90     /*virtual*/ bool supportsInterestNotification() const;
       
    91     /*virtual*/ bool notifyInterest(Handle handle, bool interested);
       
    92 
       
    93     /* QValueSpacePublisher functions */
       
    94     /*virtual*/ bool setValue(QValueSpacePublisher *creator, Handle handle,
       
    95                               const QString &subPath, const QVariant &value);
       
    96     /*virtual*/ bool removeValue(QValueSpacePublisher *creator, Handle handle,
       
    97                                  const QString &subPath);
       
    98     /*virtual*/ bool removeSubTree(QValueSpacePublisher *creator, Handle handle);
       
    99     /*virtual*/ void addWatch(QValueSpacePublisher *creator, Handle handle);
       
   100     /*virtual*/ void removeWatches(QValueSpacePublisher *creator, Handle parent);
       
   101     /*virtual*/ void sync();
       
   102 
       
   103 public:
       
   104     static SymbianSettingsLayer *instance();
       
   105 
       
   106 private:
       
   107     struct SymbianSettingsHandle {
       
   108         SymbianSettingsHandle(const QString &p)
       
   109         :   path(p), refCount(1)
       
   110         {
       
   111         }
       
   112 
       
   113         QString path;
       
   114         unsigned int refCount;
       
   115     };
       
   116 
       
   117     QHash<QString, SymbianSettingsHandle *> m_handles;
       
   118 
       
   119     SymbianSettingsHandle *symbianSettingsHandle(Handle handle)
       
   120     {
       
   121         if (handle == InvalidHandle)
       
   122             return 0;
       
   123 
       
   124         SymbianSettingsHandle *h = reinterpret_cast<SymbianSettingsHandle *>(handle);
       
   125         if (m_handles.values().contains(h))
       
   126             return h;
       
   127 
       
   128         return 0;
       
   129     }
       
   130 
       
   131 private slots:
       
   132     void notifyChange(const XQSettingsKey& key);
       
   133 
       
   134 private:    //data
       
   135     PathMapper m_pathMapper;
       
   136     XQSettingsManager m_settingsManager;
       
   137     QHash<QByteArray, SymbianSettingsHandle *> m_monitoringHandles;
       
   138     QSet<QString> m_monitoringPaths;
       
   139 };
       
   140 
       
   141 QTM_END_NAMESPACE
       
   142 
       
   143 #endif //SYMBIANSETTINGSLAYER_H