contentstorage/casoftwareregistry/src/casoftwareregistry.cpp
changeset 94 dbb8300717f7
child 98 d2f833ab7940
equal deleted inserted replaced
93:82b66994846c 94:dbb8300717f7
       
     1 /*
       
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  ?Description
       
    15  *
       
    16  */
       
    17 #include <QtGlobal>
       
    18 #include <QMetaType>
       
    19 #include <QString>
       
    20 
       
    21 
       
    22 #include "casoftwareregistry.h"
       
    23 #include "casoftwareregistry_p.h"
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 /*!
       
    29 
       
    30  \class CaSoftwareRegistry.
       
    31  \brief This class provides access to USIF provided data and converting
       
    32  them from Symbian to Qt types.
       
    33 
       
    34  CaSoftwareRegistry class provides a factory method which returns smart pointer
       
    35  to CaSoftwareRegistry instnce to ensure
       
    36  automatical memory cleanup once the reference count drops to 0.
       
    37 
       
    38  \code
       
    39  QSharedPointer<CaSoftwareRegistry> service = CaSoftwareRegistry::create();
       
    40  \endcode
       
    41 
       
    42  Subsequent calls to CaSoftwareRegistry::create() may return pointers to different
       
    43  instances. It is a case when between the calls instance counter of the created
       
    44  object dropped to 0 and it was deleted.
       
    45  
       
    46  */
       
    47 
       
    48 /*! \typedef typedef QHash<QString, QString> DetailMap;
       
    49  * Defines map type for component details.
       
    50  * 
       
    51  */
       
    52 
       
    53 /*!
       
    54  \var CaSoftwareRegistryPrivate::m_q
       
    55  Points to the CaSoftwareRegistry instance that uses this private implementation.
       
    56  */
       
    57 
       
    58 
       
    59 // Initialization of a static member variable.
       
    60 QWeakPointer<CaSoftwareRegistry> CaSoftwareRegistry::m_instance = 
       
    61     QWeakPointer<CaSoftwareRegistry>();
       
    62 
       
    63 
       
    64 /*!
       
    65  Constructor.
       
    66  \param parent pointer to a parent. It defaults to NULL.
       
    67  */
       
    68 CaSoftwareRegistry::CaSoftwareRegistry(QObject *parent) :
       
    69     QObject(parent), m_d(new CaSoftwareRegistryPrivate(this))
       
    70 {
       
    71 
       
    72 }
       
    73 
       
    74 /*!
       
    75  Returns a pointer to an instance of the CaSoftwareRegistry class.
       
    76  \retval A pointer to an instance of the CaSoftwareRegistry class.
       
    77  */
       
    78 QSharedPointer<CaSoftwareRegistry> CaSoftwareRegistry::create()
       
    79 {
       
    80     QSharedPointer<CaSoftwareRegistry> service(m_instance);
       
    81     if (!service) {
       
    82         service = QSharedPointer<CaSoftwareRegistry>(new CaSoftwareRegistry);
       
    83         m_instance = service.toWeakRef();
       
    84     }
       
    85     return service;
       
    86 }
       
    87 
       
    88 /*!
       
    89  Destructor.
       
    90  */
       
    91 CaSoftwareRegistry::~CaSoftwareRegistry()
       
    92 {
       
    93     delete m_d;
       
    94 }
       
    95 
       
    96 /*!
       
    97  The method provides component details from USIF for a given component id.
       
    98  \code
       
    99  QSharedPointer<CaSoftwareRegistry> service = CaSoftwareRegistry::create();
       
   100  CaSoftwareRegistry::DetailMap detailMap = service->entryDetails(5);
       
   101  QString appName = detailMap[CaSoftwareRegistry::componentNameKey()];
       
   102  \endcode
       
   103  \param componentId Component id of the entry details are requested for.
       
   104  \return Map of the component details if component id was greater than 0 or
       
   105  empty map otherwise. 
       
   106 
       
   107  */
       
   108 CaSoftwareRegistry::DetailMap CaSoftwareRegistry::entryDetails(
       
   109     int componentId) const
       
   110 {
       
   111     return m_d->entryDetails(componentId);
       
   112 }
       
   113 
       
   114 /*!
       
   115  * \return Component name key in CaSoftwareRegistry::DetailMap.
       
   116  */
       
   117 QString CaSoftwareRegistry::componentNameKey()
       
   118 {
       
   119     static const QString key("name");
       
   120     return key;
       
   121 }
       
   122 
       
   123 /*!
       
   124  * \return Component version key in CaSoftwareRegistry::DetailMap.
       
   125  */
       
   126 QString CaSoftwareRegistry::componentVersionKey()
       
   127 {
       
   128     static const QString key("version");
       
   129     return key;
       
   130 }
       
   131 
       
   132 /*!
       
   133  * \return Component vendor key in CaSoftwareRegistry::DetailMap.
       
   134  */
       
   135 QString CaSoftwareRegistry::componentVendorKey()
       
   136 {
       
   137     static const QString key("vendor");
       
   138     return key;
       
   139 }
       
   140 
       
   141 /*!
       
   142  * \return Component drive info key in CaSoftwareRegistry::DetailMap.
       
   143  */
       
   144 QString CaSoftwareRegistry::componentDriveInfoKey()
       
   145 {
       
   146     static const QString key("driveInfo");
       
   147     return key;
       
   148 }
       
   149 
       
   150 /*!
       
   151  * \return Component size info key in CaSoftwareRegistry::DetailMap.
       
   152  */
       
   153 QString CaSoftwareRegistry::componentSizeKey()
       
   154 {
       
   155     static const QString key("size");
       
   156     return key;
       
   157 }
       
   158 
       
   159 /*!
       
   160  * \return Component type key in CaSoftwareRegistry::DetailMap.
       
   161  */
       
   162 QString CaSoftwareRegistry::componentTypeKey()
       
   163 {
       
   164     static const QString key("type");
       
   165     return key;
       
   166 }
       
   167 
       
   168 
       
   169