qtmobility/plugins/contacts/maemo5/qcontactmaemo5backend_p.h
changeset 4 90517678cc4f
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     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 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 QCONTACTMAEMO5BACKEND_P_H
       
    43 #define QCONTACTMAEMO5BACKEND_P_H
       
    44 
       
    45 #include "qcontactmanager.h"
       
    46 #include "qcontactmanager_p.h"
       
    47 
       
    48 #include <QMap>
       
    49 #include <QString>
       
    50 #include <QList>
       
    51 
       
    52 #include <QDebug>
       
    53 
       
    54 #include "qtcontacts.h"
       
    55 #include "qcontactabook_p.h"
       
    56 #include "qcontactchangeset.h"
       
    57 
       
    58 #define MAEMO5_ENGINE_VERSION 0.1
       
    59 
       
    60 QTM_USE_NAMESPACE
       
    61 
       
    62 class Q_DECL_EXPORT ContactMaemo5Factory : public QObject, public QContactManagerEngineFactory
       
    63 {
       
    64   Q_OBJECT
       
    65   Q_INTERFACES(QtMobility::QContactManagerEngineFactory)
       
    66   public:
       
    67     QContactManagerEngine* engine(const QMap<QString, QString>& parameters, QContactManager::Error*);
       
    68     QString managerName() const;
       
    69 };
       
    70 
       
    71 class QContactMaemo5EngineData : public QSharedData
       
    72 {
       
    73 public:
       
    74     QContactMaemo5EngineData()
       
    75         : QSharedData(),
       
    76         m_refCount(QAtomicInt(1)),
       
    77         m_abook(new QContactABook)
       
    78     {  
       
    79     }
       
    80 
       
    81     QContactMaemo5EngineData(const QContactMaemo5EngineData& other)
       
    82         : QSharedData(other),
       
    83         m_refCount(QAtomicInt(1)),
       
    84         m_abook(other.m_abook)
       
    85     {
       
    86     }
       
    87 
       
    88     ~QContactMaemo5EngineData()
       
    89     {
       
    90       delete m_abook;
       
    91     }
       
    92 
       
    93     QAtomicInt m_refCount;
       
    94     QContactABook *m_abook;
       
    95 };
       
    96 
       
    97 class QContactMaemo5Engine : public QContactManagerEngine
       
    98 {
       
    99   Q_OBJECT
       
   100   public:
       
   101     QContactMaemo5Engine();
       
   102     QContactMaemo5Engine& operator=(const QContactMaemo5Engine& other);
       
   103 
       
   104     QString managerName() const;
       
   105     QString synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const;
       
   106     bool validateContact(const QContact&, QContactManager::Error* error) const;
       
   107     bool validateDefinition(const QContactDetailDefinition&, QContactManager::Error* error) const;
       
   108 
       
   109     /* "Self" contact id (MyCard) */
       
   110     QContactLocalId selfContactId(QContactManager::Error* errors) const;
       
   111 
       
   112     /* Filtering */
       
   113     QList<QContactLocalId> contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const;
       
   114 
       
   115     /* Contacts - Accessors and Mutators */
       
   116     QContact contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const;
       
   117     QList<QContact> contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, const QContactFetchHint& fetchHint, QContactManager::Error* error ) const;
       
   118     bool saveContact(QContact* contact, QContactManager::Error* error);
       
   119     bool removeContact(const QContactLocalId& contactId, QContactManager::Error* error);
       
   120     bool saveContacts(QList<QContact>*, QMap<int, QContactManager::Error>*, QContactManager::Error* error); // implemented in terms of the singular saveContact
       
   121     bool removeContacts(const QList<QContactLocalId>&, QMap<int, QContactManager::Error>*, QContactManager::Error* error); // implemented in terms of the singular removeContact
       
   122     
       
   123     /* Definitions - Accessors and Mutators */
       
   124     QMap<QString, QContactDetailDefinition> detailDefinitions(const QString& contactType, QContactManager::Error* error) const;
       
   125     QContactDetailDefinition detailDefinition(const QString& definitionName, const QString& contactType, QContactManager::Error* error) const; // implemented in terms of the plural detailDefinitions
       
   126 
       
   127     /* Version Reporting */
       
   128     int implementationVersion() const { return MAEMO5_ENGINE_VERSION; };
       
   129     int managerVersion() const { return MAEMO5_ENGINE_VERSION; }; 
       
   130     
       
   131     /* Capabilities reporting */
       
   132     bool hasFeature(QContactManager::ManagerFeature feature, const QString& contactType) const;
       
   133     bool isFilterSupported(const QContactFilter& filter) const;
       
   134     QList<QVariant::Type> supportedDataTypes() const;
       
   135     QStringList supportedContactTypes() const {return (QStringList() << QContactType::TypeContact);}
       
   136     
       
   137     // XXX TODO: FIXME - these are pure virtual and so MUST be implemented by the backend.  Stubs here.
       
   138     QMap<QString, QString> managerParameters() const {return QMap<QString,QString>();}
       
   139 
       
   140     QContact compatibleContact(const QContact&, QContactManager::Error* error) const {*error =  QContactManager::NotSupportedError;return QContact();}
       
   141 
       
   142     bool setSelfContactId(const QContactLocalId&, QContactManager::Error* error) {*error = QContactManager::NotSupportedError; return false;}
       
   143     bool saveDetailDefinition(const QContactDetailDefinition&, const QString&, QContactManager::Error* error) {*error = QContactManager::NotSupportedError; return false;}
       
   144     bool removeDetailDefinition(const QString&, const QString&, QContactManager::Error* error) {*error = QContactManager::NotSupportedError; return false;}
       
   145 
       
   146     void requestDestroyed(QContactAbstractRequest*) {}
       
   147     bool startRequest(QContactAbstractRequest*) {return false;}
       
   148     bool cancelRequest(QContactAbstractRequest*) {return false;}
       
   149     bool waitForRequestFinished(QContactAbstractRequest*, int) {return false;}
       
   150     
       
   151     bool saveRelationships(QList<QContactRelationship>*, QMap<int, QContactManager::Error>*, QContactManager::Error* error) {*error = QContactManager::NotSupportedError; return false;}
       
   152     bool removeRelationships(const QList<QContactRelationship>&, QMap<int, QContactManager::Error>*, QContactManager::Error* error) {*error = QContactManager::NotSupportedError; return false;}
       
   153     bool isRelationshipTypeSupported(const QString&, const QString&) const {return false;}
       
   154     QList<QContactRelationship> relationships(const QString&, const QContactId&, QContactRelationship::Role, QContactManager::Error* error) const {*error = QContactManager::NotSupportedError; return QList<QContactRelationship>();}
       
   155 
       
   156   private:
       
   157     QSharedDataPointer<QContactMaemo5EngineData> d;
       
   158 };
       
   159 
       
   160 #endif
       
   161