qtmobileextensions/src/settingsmanager/xqcentralrepositoryutils.cpp
branchRCL_3
changeset 10 cd2778e5acfe
parent 9 5d007b20cfd0
child 11 19a54be74e5e
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #include "xqcentralrepositoryutils.h"
       
    23 #include "xqcentralrepositoryutils_p.h"
       
    24 
       
    25 /*!
       
    26     \class XQCentralRepositoryUtils
       
    27 
       
    28     \brief The XQCentralRepositoryUtils implements Central Repository related special
       
    29     features in SettingsManager. This class is just a Qt-like wrapper to
       
    30     Symbian OS' CRepository class.
       
    31     
       
    32     See Symbian documentation for more detailed information about e.g. the use of transactions.
       
    33     
       
    34     This class co-operates with XQSettingsManager so central repositories accessed via this class
       
    35     share the same CRepository instances.
       
    36 */
       
    37 
       
    38 
       
    39 /*!
       
    40     \enum XQCentralRepositoryUtils::TransactionMode
       
    41 
       
    42     This enum defines the possible transaction modes.
       
    43 */
       
    44 /*! \var XQCentralRepositoryUtils::ConcurrentReadWriteTransaction XQCentralRepositoryUtils::ConcurrentReadWriteTransaction
       
    45     See Symbian documentation for CRepository transactions.
       
    46 */
       
    47 /*! \var XQCentralRepositoryUtils::ReadTransaction XQCentralRepositoryUtils::ReadTransaction
       
    48     See Symbian documentation for CRepository transactions.
       
    49 */
       
    50 /*! \var XQCentralRepositoryUtils::ReadWriteTransaction XQCentralRepositoryUtils::ReadWriteTransaction
       
    51     See Symbian documentation for CRepository transactions.
       
    52 */
       
    53 
       
    54 /*!
       
    55     \enum XQCentralRepositoryUtils::TransactionState
       
    56 
       
    57     This enum defines the possible transaction states.
       
    58 */
       
    59 /*! \var XQCentralRepositoryUtils::NotInTransaction XQCentralRepositoryUtils::NotInTransaction
       
    60     See Symbian documentation for CRepository transactions.
       
    61 */
       
    62 /*! \var XQCentralRepositoryUtils::ActiveTransaction XQCentralRepositoryUtils::ActiveTransaction
       
    63     See Symbian documentation for CRepository transactions.
       
    64 */
       
    65 /*! \var XQCentralRepositoryUtils::FailedTransaction XQCentralRepositoryUtils::FailedTransaction
       
    66     See Symbian documentation for CRepository transactions.
       
    67 */
       
    68 /*! \var XQCentralRepositoryUtils::UnknownTransaction XQCentralRepositoryUtils::UnknownTransaction
       
    69     Transaction state is not known.
       
    70 */
       
    71 
       
    72 
       
    73 /*!
       
    74     Constructs an XQCentralRepositoryUtils object.
       
    75     \param settingsManager Reference to XQSettingsManager instance
       
    76 */
       
    77 XQCentralRepositoryUtils::XQCentralRepositoryUtils(XQSettingsManager& settingsManager, QObject* parent)
       
    78     : QObject(parent), d(new XQCentralRepositoryUtilsPrivate(settingsManager))
       
    79 {
       
    80 }
       
    81 
       
    82 /*!
       
    83     Destructs an XQCentralRepositoryUtils.
       
    84 */
       
    85 XQCentralRepositoryUtils::~XQCentralRepositoryUtils()
       
    86 {
       
    87 }
       
    88 
       
    89 /*!
       
    90     Creates a key to central repository. (NOTE: This function is not enabled in public
       
    91     releases by default.)
       
    92     \param key XQCentralRepositorySettingsKey which defines the key details
       
    93     \param value Initial value to be written into central repository. The type is determined with
       
    94     QVariant.type() and it must be either QVariant::Int, QVariant::Double, QVariant::String or
       
    95     QVariant::ByteArray.
       
    96     \return True if the key was succesfully created, otherwise return false.
       
    97 */
       
    98 bool XQCentralRepositoryUtils::createKey(const XQCentralRepositorySettingsKey& key, const QVariant& value)
       
    99 {
       
   100     return d->createKey(key, value);
       
   101 }
       
   102 
       
   103 /*!
       
   104     Deletes a key from central repository. (NOTE: This function is not enabled in public
       
   105     releases by default.)
       
   106     \param key XQCentralRepositorySettingsKey which defines the key details
       
   107     \return True if the key was succesfully deleted, otherwise return false.
       
   108 */
       
   109 bool XQCentralRepositoryUtils::deleteKey(const XQCentralRepositorySettingsKey& key)
       
   110 {
       
   111     return d->deleteKey(key);
       
   112 }
       
   113 
       
   114 /*!
       
   115     Resets a key in central repository to it's initial value defined in .ini file.
       
   116     \param key XQCentralRepositorySettingsKey which defines the key details
       
   117     \return True if the key was succesfully reset, otherwise return false.
       
   118 */
       
   119 bool XQCentralRepositoryUtils::resetKey(const XQCentralRepositorySettingsKey& key)
       
   120 {
       
   121     return d->resetKey(key);
       
   122 }
       
   123 
       
   124 /*!
       
   125     Resets the whole central repository file to it's initial state defined in .ini file.
       
   126     \param repositoryUid Repository UID
       
   127     \return True if the repository was succesfully reset, otherwise return false.
       
   128 */
       
   129 bool XQCentralRepositoryUtils::resetRepository(long int repositoryUid)
       
   130 {
       
   131     return d->resetRepository(repositoryUid);
       
   132 }
       
   133 
       
   134 /*!
       
   135     Finds keys in central repository.
       
   136     \param criteria Search criteria
       
   137     \return List of XQCentralRepositorySettingsKey objects that match with criteria
       
   138 */
       
   139 QList<XQCentralRepositorySettingsKey> XQCentralRepositoryUtils::findKeys(const XQCentralRepositorySearchCriteria& criteria)
       
   140 {
       
   141     return d->findKeys(criteria);
       
   142 }
       
   143 
       
   144 /*!
       
   145     Starts transaction. See Symbian documentation for more info.
       
   146     \param repositoryUid Repository UID
       
   147     \param transactionMode Transaction mode.
       
   148     \return True if the transaction was succesfully started, otherwise return false.
       
   149 */
       
   150 bool XQCentralRepositoryUtils::startTransaction(long int repositoryUid, TransactionMode transactionMode)
       
   151 {
       
   152     return d->startTransaction(repositoryUid, transactionMode);
       
   153 }
       
   154 
       
   155 /*!
       
   156     Commits transaction. See Symbian documentation for more info.
       
   157     \param repositoryUid Repository UID
       
   158     \return True if the transaction was succesfully committed, otherwise return false.
       
   159 */
       
   160 bool XQCentralRepositoryUtils::commitTransaction(long int repositoryUid)
       
   161 {
       
   162     return d->commitTransaction(repositoryUid);
       
   163 }
       
   164 
       
   165 /*!
       
   166     Cancels transaction. See Symbian documentation for more info.
       
   167     \param repositoryUid Repository UID
       
   168 */
       
   169 void XQCentralRepositoryUtils::cancelTransaction(long int repositoryUid)
       
   170 {
       
   171     d->cancelTransaction(repositoryUid);
       
   172 }
       
   173 
       
   174 /*!
       
   175     Fails transaction. See Symbian documentation for more info.
       
   176     \param repositoryUid Repository UID
       
   177 */
       
   178 void XQCentralRepositoryUtils::failTransaction(long int repositoryUid)
       
   179 {
       
   180     d->failTransaction(repositoryUid);
       
   181 }
       
   182 
       
   183 /*!
       
   184     \return Current transaction state.
       
   185 */
       
   186 XQCentralRepositoryUtils::TransactionState XQCentralRepositoryUtils::transactionState(long int repositoryUid) const
       
   187 {
       
   188     return d->transactionState(repositoryUid);
       
   189 }