1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the test suite of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
43
/* We build multiple plugins with the same code, just different names */
44
#ifndef DUMMYPLUGINTARGET
45
#define DUMMYPLUGINTARGET contacts_testdummy
48
#define makestr(x) (#x)
49
#define makename(x) makestr(x)
51
#include "qcontactmanager.h"
52
#include "qcontactmanagerengine.h"
53
#include "qcontactmanagerenginefactory.h"
55
#include "dummyplugin.h"
57
QTCONTACTS_USE_NAMESPACE
59
QContactManagerEngine* DummyEngineFactory::engine(const QMap<QString, QString>& parameters, QContactManager::Error* error)
61
return new DummyEngine(parameters, error);
64
QString DummyEngineFactory::managerName() const
66
#ifdef DUMMYPLUGINNAME
67
return QString(makename(DUMMYPLUGINNAME));
73
DummyEngine::DummyEngine(const QMap<QString, QString>& parameters, QContactManager::Error* error)
76
*error = QContactManager::AlreadyExistsError; // Another random choice
79
DummyEngine::DummyEngine(const DummyEngine& other)
80
: QContactManagerEngine()
85
DummyEngine& DummyEngine::operator=(const DummyEngine& other)
91
DummyEngine::~DummyEngine()
95
QContactManagerEngine* DummyEngine::clone()
98
return new DummyEngine(*this);
101
void DummyEngine::deref()
106
QString DummyEngine::managerName() const
108
#ifdef DUMMYPLUGINNAME
109
return QString(makename(DUMMYPLUGINNAME));
115
QList<QContactId> DummyEngine::contacts(QContactManager::Error* error) const
117
QList<QContactId> allCIds;
119
if (allCIds.count() > 0 && *error == QContactManager::NoError)
120
*error = QContactManager::DoesNotExistError;
125
QContact DummyEngine::contact(const QContactId& contactId, QContactManager::Error* error) const
128
*error = QContactManager::DoesNotExistError;
132
QContact DummyEngine::contact(const QContactId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const
136
*error = QContactManager::DoesNotExistError;
140
bool DummyEngine::saveContact(QContact* contact, bool batch, QContactManager::Error* error)
142
// ensure that the contact's details conform to their definitions
143
if (!validateContact(*contact, error)) {
144
*error = QContactManager::InvalidDetailError;
150
contact->setId(newId);
151
*error = QContactManager::NoError;
153
// if we need to emit signals (ie, this isn't part of a batch operation)
154
// then emit the correct one.
156
QList<QContactId> emitList;
157
emitList.append(contact->id());
158
emit contactsAdded(emitList);
164
bool DummyEngine::removeContact(const QContactId& contactId, bool batch, QContactManager::Error* error)
167
if (contactId != "5") {
168
*error = QContactManager::DoesNotExistError;
172
*error = QContactManager::NoError;
174
// if we need to emit signals (ie, this isn't part of a batch operation)
175
// then emit the correct one.
177
QList<QContactId> emitList;
178
emitList.append(contactId);
179
emit contactsRemoved(emitList);
185
/*! Returns the capabilities of the in-memory engine. */
186
QStringList DummyEngine::capabilities() const
189
caplist << "Locking" << "Batch" << "ReadOnly" << "Filtering" << "Sorting" << "Preferences";
190
// ie, doesn't support: Changelog, Volatile, Asynchronous.
195
* Returns a list of definition identifiers which are natively (fast) filterable
196
* on the default backend store managed by the manager from which the capabilities object was accessed
198
QStringList DummyEngine::fastFilterableDefinitions() const
200
QStringList fastlist;
201
fastlist << "Name::First" << "Name::Last" << "PhoneNumber::PhoneNumber" << "EmailAddress::EmailAddress";
206
* Returns the list of data types supported by the vCard engine
208
QList<QVariant::Type> DummyEngine::supportedDataTypes() const
210
QList<QVariant::Type> st;
211
st.append(QVariant::String);
212
st.append(QVariant::Date);
213
st.append(QVariant::DateTime);
218
QContactEngineId* DummyEngineFactory::createContactEngineId(const QMap<QString, QString>& parameters, const QString& engineIdString) const
223
#include "moc_dummyplugin.cpp"