contentstorage/casoftwareregistry/src/casoftwareregistry.cpp
author hgs
Fri, 11 Jun 2010 16:13:51 +0300
changeset 98 d2f833ab7940
parent 94 dbb8300717f7
child 102 8b8b34fa9751
child 109 e0aa398e6810
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:  ?Description
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
#include <QtGlobal>
hgs
parents:
diff changeset
    18
#include <QString>
98
hgs
parents: 94
diff changeset
    19
#include <QStringList>
94
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
#include "casoftwareregistry.h"
hgs
parents:
diff changeset
    23
#include "casoftwareregistry_p.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
// ======== MEMBER FUNCTIONS ========
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
/*!
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
 \class CaSoftwareRegistry.
hgs
parents:
diff changeset
    31
 \brief This class provides access to USIF provided data and converting
hgs
parents:
diff changeset
    32
 them from Symbian to Qt types.
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
 CaSoftwareRegistry class provides a factory method which returns smart pointer
hgs
parents:
diff changeset
    35
 to CaSoftwareRegistry instnce to ensure
hgs
parents:
diff changeset
    36
 automatical memory cleanup once the reference count drops to 0.
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
 \code
hgs
parents:
diff changeset
    39
 QSharedPointer<CaSoftwareRegistry> service = CaSoftwareRegistry::create();
hgs
parents:
diff changeset
    40
 \endcode
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
 Subsequent calls to CaSoftwareRegistry::create() may return pointers to different
hgs
parents:
diff changeset
    43
 instances. It is a case when between the calls instance counter of the created
hgs
parents:
diff changeset
    44
 object dropped to 0 and it was deleted.
hgs
parents:
diff changeset
    45
 
hgs
parents:
diff changeset
    46
 */
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
/*! \typedef typedef QHash<QString, QString> DetailMap;
hgs
parents:
diff changeset
    49
 * Defines map type for component details.
hgs
parents:
diff changeset
    50
 * 
hgs
parents:
diff changeset
    51
 */
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
/*!
hgs
parents:
diff changeset
    54
 \var CaSoftwareRegistryPrivate::m_q
hgs
parents:
diff changeset
    55
 Points to the CaSoftwareRegistry instance that uses this private implementation.
hgs
parents:
diff changeset
    56
 */
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
// Initialization of a static member variable.
hgs
parents:
diff changeset
    60
QWeakPointer<CaSoftwareRegistry> CaSoftwareRegistry::m_instance = 
hgs
parents:
diff changeset
    61
    QWeakPointer<CaSoftwareRegistry>();
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
/*!
hgs
parents:
diff changeset
    65
 Constructor.
hgs
parents:
diff changeset
    66
 \param parent pointer to a parent. It defaults to NULL.
hgs
parents:
diff changeset
    67
 */
hgs
parents:
diff changeset
    68
CaSoftwareRegistry::CaSoftwareRegistry(QObject *parent) :
hgs
parents:
diff changeset
    69
    QObject(parent), m_d(new CaSoftwareRegistryPrivate(this))
hgs
parents:
diff changeset
    70
{
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
}
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
/*!
hgs
parents:
diff changeset
    75
 Returns a pointer to an instance of the CaSoftwareRegistry class.
hgs
parents:
diff changeset
    76
 \retval A pointer to an instance of the CaSoftwareRegistry class.
hgs
parents:
diff changeset
    77
 */
hgs
parents:
diff changeset
    78
QSharedPointer<CaSoftwareRegistry> CaSoftwareRegistry::create()
hgs
parents:
diff changeset
    79
{
hgs
parents:
diff changeset
    80
    QSharedPointer<CaSoftwareRegistry> service(m_instance);
hgs
parents:
diff changeset
    81
    if (!service) {
hgs
parents:
diff changeset
    82
        service = QSharedPointer<CaSoftwareRegistry>(new CaSoftwareRegistry);
hgs
parents:
diff changeset
    83
        m_instance = service.toWeakRef();
hgs
parents:
diff changeset
    84
    }
hgs
parents:
diff changeset
    85
    return service;
hgs
parents:
diff changeset
    86
}
hgs
parents:
diff changeset
    87
hgs
parents:
diff changeset
    88
/*!
hgs
parents:
diff changeset
    89
 Destructor.
hgs
parents:
diff changeset
    90
 */
hgs
parents:
diff changeset
    91
CaSoftwareRegistry::~CaSoftwareRegistry()
hgs
parents:
diff changeset
    92
{
hgs
parents:
diff changeset
    93
    delete m_d;
hgs
parents:
diff changeset
    94
}
hgs
parents:
diff changeset
    95
hgs
parents:
diff changeset
    96
/*!
98
hgs
parents: 94
diff changeset
    97
 Provides details needed for uninstalling process of Java applications.
hgs
parents: 94
diff changeset
    98
 \code
hgs
parents: 94
diff changeset
    99
 QSharedPointer<CaSoftwareRegistry> service = CaSoftwareRegistry::create();
hgs
parents: 94
diff changeset
   100
 int componentId(20);
hgs
parents: 94
diff changeset
   101
 QString &componentName,
hgs
parents: 94
diff changeset
   102
 QStringList applicationsUids;
hgs
parents: 94
diff changeset
   103
 QString confirmationMessage;
hgs
parents: 94
diff changeset
   104
 CaSoftwareRegistry::DetailMap detailMap = service->getUninstallDetails(
hgs
parents: 94
diff changeset
   105
    componentId,
hgs
parents: 94
diff changeset
   106
    componentName,
hgs
parents: 94
diff changeset
   107
    applicationsUids,
hgs
parents: 94
diff changeset
   108
    confirmationMessage);
hgs
parents: 94
diff changeset
   109
 \endcode
hgs
parents: 94
diff changeset
   110
 \param[in] componentId component id of an application to be uninstalled.
hgs
parents: 94
diff changeset
   111
 \param[out] componentName a name of the component.
hgs
parents: 94
diff changeset
   112
 \param[out] applicationsUids a list of uids of applications in the package
hgs
parents: 94
diff changeset
   113
      of the given component id.
hgs
parents: 94
diff changeset
   114
 \param[out] confirmationMessage optional deletion confirmation message,
hgs
parents: 94
diff changeset
   115
      null string means the lack of the message.
hgs
parents: 94
diff changeset
   116
 \retval true if there is no error.
hgs
parents: 94
diff changeset
   117
 */
hgs
parents: 94
diff changeset
   118
bool CaSoftwareRegistry::getUninstallDetails(int componentId,
hgs
parents: 94
diff changeset
   119
    QString &componentName,
hgs
parents: 94
diff changeset
   120
    QStringList &applicationsUids,
hgs
parents: 94
diff changeset
   121
    QString &confirmationMessage)
hgs
parents: 94
diff changeset
   122
{
hgs
parents: 94
diff changeset
   123
    return m_d->getUninstallDetails(componentId,
hgs
parents: 94
diff changeset
   124
        componentName,
hgs
parents: 94
diff changeset
   125
        applicationsUids,
hgs
parents: 94
diff changeset
   126
        confirmationMessage);
hgs
parents: 94
diff changeset
   127
}
hgs
parents: 94
diff changeset
   128
hgs
parents: 94
diff changeset
   129
/*!
hgs
parents: 94
diff changeset
   130
 Provides a list of uids of applications installed by the given package.
hgs
parents: 94
diff changeset
   131
 \param[in] componentId component id of an application to be uninstalled.
hgs
parents: 94
diff changeset
   132
 \param[out] applicationsUids a list of uids of applications in the package
hgs
parents: 94
diff changeset
   133
      of the given component id.
hgs
parents: 94
diff changeset
   134
 \retval true if there is no error.
hgs
parents: 94
diff changeset
   135
 */
hgs
parents: 94
diff changeset
   136
hgs
parents: 94
diff changeset
   137
bool CaSoftwareRegistry::getApplicationsUids(int componentId,
hgs
parents: 94
diff changeset
   138
    QStringList &applicationsUids)
hgs
parents: 94
diff changeset
   139
{
hgs
parents: 94
diff changeset
   140
    return m_d->getApplicationsUids(componentId, applicationsUids);
hgs
parents: 94
diff changeset
   141
}
hgs
parents: 94
diff changeset
   142
hgs
parents: 94
diff changeset
   143
/*!
94
hgs
parents:
diff changeset
   144
 The method provides component details from USIF for a given component id.
hgs
parents:
diff changeset
   145
 \code
hgs
parents:
diff changeset
   146
 QSharedPointer<CaSoftwareRegistry> service = CaSoftwareRegistry::create();
hgs
parents:
diff changeset
   147
 CaSoftwareRegistry::DetailMap detailMap = service->entryDetails(5);
hgs
parents:
diff changeset
   148
 QString appName = detailMap[CaSoftwareRegistry::componentNameKey()];
hgs
parents:
diff changeset
   149
 \endcode
hgs
parents:
diff changeset
   150
 \param componentId Component id of the entry details are requested for.
hgs
parents:
diff changeset
   151
 \return Map of the component details if component id was greater than 0 or
hgs
parents:
diff changeset
   152
 empty map otherwise. 
hgs
parents:
diff changeset
   153
hgs
parents:
diff changeset
   154
 */
hgs
parents:
diff changeset
   155
CaSoftwareRegistry::DetailMap CaSoftwareRegistry::entryDetails(
hgs
parents:
diff changeset
   156
    int componentId) const
hgs
parents:
diff changeset
   157
{
hgs
parents:
diff changeset
   158
    return m_d->entryDetails(componentId);
hgs
parents:
diff changeset
   159
}
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
/*!
hgs
parents:
diff changeset
   162
 * \return Component name key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   163
 */
hgs
parents:
diff changeset
   164
QString CaSoftwareRegistry::componentNameKey()
hgs
parents:
diff changeset
   165
{
hgs
parents:
diff changeset
   166
    static const QString key("name");
hgs
parents:
diff changeset
   167
    return key;
hgs
parents:
diff changeset
   168
}
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
/*!
hgs
parents:
diff changeset
   171
 * \return Component version key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   172
 */
hgs
parents:
diff changeset
   173
QString CaSoftwareRegistry::componentVersionKey()
hgs
parents:
diff changeset
   174
{
hgs
parents:
diff changeset
   175
    static const QString key("version");
hgs
parents:
diff changeset
   176
    return key;
hgs
parents:
diff changeset
   177
}
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
/*!
hgs
parents:
diff changeset
   180
 * \return Component vendor key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   181
 */
hgs
parents:
diff changeset
   182
QString CaSoftwareRegistry::componentVendorKey()
hgs
parents:
diff changeset
   183
{
hgs
parents:
diff changeset
   184
    static const QString key("vendor");
hgs
parents:
diff changeset
   185
    return key;
hgs
parents:
diff changeset
   186
}
hgs
parents:
diff changeset
   187
hgs
parents:
diff changeset
   188
/*!
hgs
parents:
diff changeset
   189
 * \return Component drive info key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   190
 */
hgs
parents:
diff changeset
   191
QString CaSoftwareRegistry::componentDriveInfoKey()
hgs
parents:
diff changeset
   192
{
hgs
parents:
diff changeset
   193
    static const QString key("driveInfo");
hgs
parents:
diff changeset
   194
    return key;
hgs
parents:
diff changeset
   195
}
hgs
parents:
diff changeset
   196
hgs
parents:
diff changeset
   197
/*!
hgs
parents:
diff changeset
   198
 * \return Component size info key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   199
 */
hgs
parents:
diff changeset
   200
QString CaSoftwareRegistry::componentSizeKey()
hgs
parents:
diff changeset
   201
{
hgs
parents:
diff changeset
   202
    static const QString key("size");
hgs
parents:
diff changeset
   203
    return key;
hgs
parents:
diff changeset
   204
}
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
/*!
hgs
parents:
diff changeset
   207
 * \return Component type key in CaSoftwareRegistry::DetailMap.
hgs
parents:
diff changeset
   208
 */
hgs
parents:
diff changeset
   209
QString CaSoftwareRegistry::componentTypeKey()
hgs
parents:
diff changeset
   210
{
hgs
parents:
diff changeset
   211
    static const QString key("type");
hgs
parents:
diff changeset
   212
    return key;
hgs
parents:
diff changeset
   213
}
hgs
parents:
diff changeset
   214