Buteo Synchronization Framework: Profile.h Source File

Buteo Synchronization Framework

Profile.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef PROFILE_H
25#define PROFILE_H
26
27#include <QList>
28#include <QMap>
29#include <QString>
30#include <QStringList>
31#include "ProfileField.h"
32
33class QDomDocument;
34class QDomElement;
35
36namespace Buteo {
37
38class ProfileTest;
39class ProfilePrivate;
40
41
52 class Profile
53{
54public:
55
57 static const QString TYPE_CLIENT;
59 static const QString TYPE_SERVER;
61 static const QString TYPE_STORAGE;
63 //static const QString TYPE_SERVICE;
65 static const QString TYPE_SYNC;
66
70 Profile();
71
72
79 Profile(const QString &aName, const QString &aType);
80
85 explicit Profile(const QDomElement &aRoot);
86
91 Profile(const Profile &aSource);
92
97 virtual Profile *clone() const;
98
100 virtual ~Profile();
101
106 QString name() const;
107
112 QString displayname() const;
113
118 virtual void setName(const QString &aName);
119
124 virtual void setName(const QStringList &aKeys);
125
130 QString type() const;
131
142 virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly = true) const;
143
149 QString toString() const;
150
159 QString key(const QString &aName, const QString &aDefault = QString()) const;
160
165 QMap<QString, QString> allKeys() const;
166
171 QMap<QString, QString> allNonStorageKeys() const;
172
181 bool boolKey(const QString &aName, bool aDefault = false) const;
182
189 QStringList keyValues(const QString &aName) const;
190
195 QStringList keyNames() const;
196
203 void setKey(const QString &aName, const QString &aValue);
204
212 void setKeyValues(const QString &aName, const QStringList &aValues);
213
221 void setBoolKey(const QString &aName, bool aValue);
222
227 void removeKey(const QString &aName);
228
237 const ProfileField *field(const QString &aName) const;
238
243 QList<const ProfileField *> allFields() const;
244
251 QList<const ProfileField *> visibleFields() const;
252
263 bool isValid() const;
264
271 QStringList subProfileNames(const QString &aType = "") const;
272
282 Profile *subProfile(const QString &aName, const QString &aType = "");
283
287 const Profile *subProfile(const QString &aName, const QString &aType = "") const;
288
298 const Profile *subProfileByKeyValue(const QString &aKey,
299 const QString &aValue,
300 const QString &aType,
301 bool aEnabledOnly) const;
302
308 QList<Profile *> allSubProfiles();
309
315 QList<const Profile *> allSubProfiles() const;
316
325 void merge(const Profile &aSource);
326
337 bool isLoaded() const;
338
346 void setLoaded(bool aLoaded);
347
352 virtual bool isEnabled() const;
353
358 void setEnabled(bool aEnabled);
359
365 bool isHidden() const;
366
372 bool isProtected() const;
373
374private:
375
376 Profile &operator=(const Profile &aRhs);
377
378 ProfilePrivate *d_ptr;
379
386 QString generateProfileId(const QStringList &aKeys);
387
388#ifdef SYNCFW_UNIT_TESTS
389 friend class ProfileTest;
390#endif
391
392};
393
394}
395
396#endif // PROFILE_H
Buteo::ProfileField
This class represents a profile field.
Definition: ProfileField.h:49
Buteo::ProfilePrivate
Private implementation class for Profile class.
Definition: Profile_p.h:35
Buteo::Profile
This class represents a single profile, a collection of settings or data releated to some entity.
Definition: Profile.h:53
Buteo::Profile::allSubProfiles
QList< Profile * > allSubProfiles()
Gets all sub-profiles.
Definition: Profile.cpp:427
Buteo::Profile::allFields
QList< const ProfileField * > allFields() const
Gets all fields.
Definition: Profile.cpp:240
Buteo::Profile::keyValues
QStringList keyValues(const QString &aName) const
Gets the values of all keys with the given name.
Definition: Profile.cpp:175
Buteo::Profile::setEnabled
void setEnabled(bool aEnabled)
Set is the profile is enabled.
Definition: Profile.cpp:491
Buteo::Profile::TYPE_SERVER
static const QString TYPE_SERVER
Server type .
Definition: Profile.h:59
Buteo::Profile::isHidden
bool isHidden() const
Checks if the profile is hidden.
Definition: Profile.cpp:496
Buteo::Profile::setKeyValues
void setKeyValues(const QString &aName, const QStringList &aValues)
Sets multiple values for a key.
Definition: Profile.cpp:203
Buteo::Profile::Profile
Profile()
Default Constructor.
Definition: Profile.cpp:45
Buteo::Profile::name
QString name() const
Gets the name of the profile.
Definition: Profile.cpp:108
Buteo::Profile::clone
virtual Profile * clone() const
Creates a clone of the profile.
Definition: Profile.cpp:97
Buteo::Profile::~Profile
virtual ~Profile()
Destructor.
Definition: Profile.cpp:102
Buteo::Profile::TYPE_STORAGE
static const QString TYPE_STORAGE
Storage type.
Definition: Profile.h:61
Buteo::Profile::setKey
void setKey(const QString &aName, const QString &aValue)
Sets the value of a key.
Definition: Profile.cpp:186
Buteo::Profile::displayname
QString displayname() const
Gets the display name of the profile.
Definition: Profile.cpp:506
Buteo::Profile::toXml
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly=true) const
Creates a XML representation of the profile.
Definition: Profile.cpp:268
Buteo::Profile::isValid
bool isValid() const
Checks if the profile is valid.
Definition: Profile.cpp:329
Buteo::Profile::allNonStorageKeys
QMap< QString, QString > allNonStorageKeys() const
Gets all keys that are not related to storages.
Definition: Profile.cpp:150
Buteo::Profile::removeKey
void removeKey(const QString &aName)
Removes a key from profile. All instances of the key are removed.
Definition: Profile.cpp:223
Buteo::Profile::setLoaded
void setLoaded(bool aLoaded)
Sets if the profile is fully loaded.
Definition: Profile.cpp:481
Buteo::Profile::key
QString key(const QString &aName, const QString &aDefault=QString()) const
Gets the value of the given key.
Definition: Profile.cpp:129
Buteo::Profile::boolKey
bool boolKey(const QString &aName, bool aDefault=false) const
Gets the value of the given boolean key.
Definition: Profile.cpp:165
Buteo::Profile::subProfileNames
QStringList subProfileNames(const QString &aType="") const
Gets the names of all sub-profiles with the given type.
Definition: Profile.cpp:371
Buteo::Profile::isLoaded
bool isLoaded() const
Checks if the profile is fully constructed by loading all sub-profiles from separate profile files.
Definition: Profile.cpp:476
Buteo::Profile::field
const ProfileField * field(const QString &aName) const
Gets the field with the given name.
Definition: Profile.cpp:229
Buteo::Profile::isEnabled
virtual bool isEnabled() const
Returns if the profile is enabled.
Definition: Profile.cpp:486
Buteo::Profile::TYPE_CLIENT
static const QString TYPE_CLIENT
String constants for different profile type names.
Definition: Profile.h:57
Buteo::Profile::type
QString type() const
Gets the type of the profile.
Definition: Profile.cpp:124
Buteo::Profile::TYPE_SYNC
static const QString TYPE_SYNC
Service type.
Definition: Profile.h:65
Buteo::Profile::setBoolKey
void setBoolKey(const QString &aName, bool aValue)
Sets the value of a boolean key.
Definition: Profile.cpp:218
Buteo::Profile::merge
void merge(const Profile &aSource)
Merges a profile to this profile.
Definition: Profile.cpp:442
Buteo::Profile::keyNames
QStringList keyNames() const
Gets the names of all keys.
Definition: Profile.cpp:181
Buteo::Profile::toString
QString toString() const
Outputs a XML representation of the profile to a string.
Definition: Profile.cpp:316
Buteo::Profile::subProfile
Profile * subProfile(const QString &aName, const QString &aType="")
Gets a sub-profile with the given name and type.
Definition: Profile.cpp:384
Buteo::Profile::setName
virtual void setName(const QString &aName)
Sets the name of the profile.
Definition: Profile.cpp:113
Buteo::Profile::visibleFields
QList< const ProfileField * > visibleFields() const
Gets all visible fields of the profile.
Definition: Profile.cpp:247
Buteo::Profile::isProtected
bool isProtected() const
Checks if the profile is protected.
Definition: Profile.cpp:501
Buteo::Profile::subProfileByKeyValue
const Profile * subProfileByKeyValue(const QString &aKey, const QString &aValue, const QString &aType, bool aEnabledOnly) const
Gets a sub-profile by key value.
Definition: Profile.cpp:410
Buteo::Profile::allKeys
QMap< QString, QString > allKeys() const
Gets all keys and their values.
Definition: Profile.cpp:142
QList
Definition: SyncBackupAdaptor.h:40
QMap< QString, QString >