diff -r 000000000000 -r 876b1a06bc25 plugins/contacts/symbian/plugin/inc/cntsymbianengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/contacts/symbian/plugin/inc/cntsymbianengine.h Wed Aug 25 15:49:42 2010 +0300 @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CNTSYMBIANBACKEND_P_H +#define CNTSYMBIANBACKEND_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include +#include "qtcontactsglobal.h" +#include "qcontact.h" +#include "qcontactname.h" +#include "qcontactphonenumber.h" +#include "qcontactmanager.h" +#include "qcontactmanagerengine.h" +#include "qcontactmanagerenginefactory.h" + +QTM_BEGIN_NAMESPACE +class QContactChangeSet; +class QContactAbstractRequest; +QTM_END_NAMESPACE +class CntSymbianDatabase; +class CntSymbianSrvConnection; +class CntTransformContact; +class CntSymbianFilter; +class CntAbstractContactSorter; +class CntRelationship; +class CntDisplayLabel; + +QTM_USE_NAMESPACE + +#define CNT_SYMBIAN_MANAGER_NAME "symbian" + +class CntSymbianEngine : public QContactManagerEngine +{ + Q_OBJECT + +public: + CntSymbianEngine(const QMap& parameters, QContactManager::Error* error); + ~CntSymbianEngine(); + + /* URI reporting */ + QString managerName() const; + + /* XXX TODO - implement these correctly */ + int managerVersion() const { return 1;} + QContact compatibleContact(const QContact& contact, QContactManager::Error* error) const {return QContactManagerEngine::compatibleContact(contact, error);} + + /* Functions that are optional in the base API */ + bool saveRelationship(QContactRelationship* relationship, QContactManager::Error* error); + bool removeRelationship(const QContactRelationship& relationship, QContactManager::Error* error); + bool saveContact(QContact* contact, QContactManager::Error* error); + bool removeContact(const QContactLocalId& contactId, QContactManager::Error* error); + + /* Contacts - Accessors and Mutators */ + QList contactIds(const QContactFilter& filter, const QList& sortOrders, QContactManager::Error* error) const; + QList contacts(const QContactFilter& filter, const QList& sortOrders, const QContactFetchHint& fetchHint, QContactManager::Error* error) const; + QContact contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const; + + bool saveContacts(QList* contacts, QMap* errorMap, QContactManager::Error* error); + bool removeContacts(const QList& contactIds, QMap* errorMap, QContactManager::Error* error); + + /* Synthesize the display label of a contact */ + QString synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const; + + /* "Self" contact id (MyCard) */ + bool setSelfContactId(const QContactLocalId& contactId, QContactManager::Error* error); + QContactLocalId selfContactId(QContactManager::Error* error) const; + + /* Relationships between contacts */ + QList relationships(const QString& relationshipType, const QContactId& participantId, QContactRelationship::Role role, QContactManager::Error* error) const; + bool saveRelationships(QList* relationships, QMap* errorMap, QContactManager::Error* error); + bool removeRelationships(const QList& relationships, QMap* errorMap, QContactManager::Error* error); + + /* Definitions - Accessors and Mutators */ + QMap detailDefinitions(const QString& contactType, QContactManager::Error* error) const; + + /* Capabilities reporting */ + bool hasFeature(QContactManager::ManagerFeature feature, const QString& contactType) const; + bool isRelationshipTypeSupported(const QString& relationshipType, const QString& contactType) const; + bool isFilterSupported(const QContactFilter& filter) const; + QList supportedDataTypes() const; + +private: + QList slowFilter(const QContactFilter& filter, const QList& contacts, QContactManager::Error* error) const; + QList slowSort(const QList& contactIds, const QList& sortOrders, QContactManager::Error* error) const; + bool doSaveContact(QContact* contact, QContactChangeSet& changeSet, QContactManager::Error* error); + + QContact fetchContactL(const QContactLocalId &localId, const QStringList& detailDefinitionsHint) const; + + /* Add contact */ + bool addContact(QContact& contact, QContactChangeSet& changeSet, QContactManager::Error* qtError); + int addContactL(QContact &contact); + + /* Update contact */ + bool updateContact(QContact& contact, QContactChangeSet& changeSet, QContactManager::Error* qtError); + void updateContactL(QContact &contact); + + /* Remove contact */ + bool removeContact(const QContactLocalId &id, QContactChangeSet& changeSet, QContactManager::Error* qtError); + void removeContactL(QContactLocalId id); + + void updateDisplayLabel(QContact& contact) const; + + /* Asynchronous Request Support - synchronous versions until thread worker is stable */ + void requestDestroyed(QContactAbstractRequest* req); + bool startRequest(QContactAbstractRequest* req); + bool cancelRequest(QContactAbstractRequest* req); + bool waitForRequestProgress(QContactAbstractRequest* req, int msecs); + bool waitForRequestFinished(QContactAbstractRequest* req, int msecs); + +private slots: + void performAsynchronousOperation(); + +private: + CntSymbianDatabase *m_dataBase; + CntSymbianSrvConnection *m_srvConnection; + QString m_managerUri; + CntTransformContact *m_transformContact; + CntSymbianFilter *m_contactFilter; +#ifndef SYMBIAN_BACKEND_USE_SQLITE + CntAbstractContactSorter *m_contactSorter; +#endif + CntRelationship *m_relationship; + CntDisplayLabel *m_displayLabel; + + QQueue m_asynchronousOperations; // async requests to be performed. +#ifdef PBK_UNIT_TEST + friend class TestSymbianEngine; + friend class TestCntRelationship; +#endif //PBK_UNIT_TEST +}; +#ifndef PBK_UNIT_TEST +class CntSymbianFactory : public QObject, public QContactManagerEngineFactory +{ + Q_OBJECT + Q_INTERFACES(QtMobility::QContactManagerEngineFactory) + public: + QContactManagerEngine* engine(const QMap& parameters, QContactManager::Error* error); + QString managerName() const; +}; +#endif //PBK_UNIT_TEST +#endif //CNTSYMBIANBACKEND_P_H