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
53{
54public:
56 static const QString TYPE_CLIENT;
58 static const QString TYPE_SERVER;
60 static const QString TYPE_STORAGE;
62 //static const QString TYPE_SERVICE;
64 static const QString TYPE_SYNC;
65
69 Profile();
70
77 Profile(const QString &aName, const QString &aType);
78
83 explicit Profile(const QDomElement &aRoot);
84
89 Profile(const Profile &aSource);
90
95 virtual Profile *clone() const;
96
98 virtual ~Profile();
99
104 QString name() const;
105
110 QString displayname() const;
111
116 virtual void setName(const QString &aName);
117
122 virtual void setName(const QStringList &aKeys);
123
128 QString type() const;
129
140 virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly = true) const;
141
147 QString toString() const;
148
157 QString key(const QString &aName, const QString &aDefault = QString()) const;
158
164
170
179 bool boolKey(const QString &aName, bool aDefault = false) const;
180
187 QStringList keyValues(const QString &aName) const;
188
193 QStringList keyNames() const;
194
201 void setKey(const QString &aName, const QString &aValue);
202
210 void setKeyValues(const QString &aName, const QStringList &aValues);
211
219 void setBoolKey(const QString &aName, bool aValue);
220
225 void removeKey(const QString &aName);
226
235 const ProfileField *field(const QString &aName) const;
236
242
250
261 bool isValid() const;
262
269 QStringList subProfileNames(const QString &aType = "") const;
270
280 Profile *subProfile(const QString &aName, const QString &aType = "");
281
285 const Profile *subProfile(const QString &aName, const QString &aType = "") const;
286
296 const Profile *subProfileByKeyValue(const QString &aKey,
297 const QString &aValue,
298 const QString &aType,
299 bool aEnabledOnly) const;
300
307
314
323 void merge(const Profile &aSource);
324
335 bool isLoaded() const;
336
344 void setLoaded(bool aLoaded);
345
350 virtual bool isEnabled() const;
351
356 void setEnabled(bool aEnabled);
357
363 bool isHidden() const;
364
370 bool isProtected() const;
371
372private:
373 Profile &operator=(const Profile &aRhs);
374 ProfilePrivate *d_ptr;
375
382 QString generateProfileId(const QStringList &aKeys);
383
384#ifdef SYNCFW_UNIT_TESTS
385 friend class ProfileTest;
386#endif
387};
388
389}
390
391#endif // PROFILE_H
This class represents a profile field.
Definition ProfileField.h:49
Private implementation class for Profile class.
Definition Profile_p.h:35
This class represents a single profile, a collection of settings or data releated to some entity.
Definition Profile.h:53
QList< Profile * > allSubProfiles()
Gets all sub-profiles.
Definition Profile.cpp:455
QList< const ProfileField * > allFields() const
Gets all fields.
Definition Profile.cpp:268
QStringList keyValues(const QString &aName) const
Gets the values of all keys with the given name.
Definition Profile.cpp:188
void setEnabled(bool aEnabled)
Set is the profile is enabled.
Definition Profile.cpp:524
static const QString TYPE_SERVER
Server type .
Definition Profile.h:58
bool isHidden() const
Checks if the profile is hidden.
Definition Profile.cpp:529
void setKeyValues(const QString &aName, const QStringList &aValues)
Sets multiple values for a key.
Definition Profile.cpp:227
Profile()
Default Constructor.
Definition Profile.cpp:45
QString name() const
Gets the name of the profile.
Definition Profile.cpp:112
virtual Profile * clone() const
Creates a clone of the profile.
Definition Profile.cpp:101
virtual ~Profile()
Destructor.
Definition Profile.cpp:106
static const QString TYPE_STORAGE
Storage type.
Definition Profile.h:60
void setKey(const QString &aName, const QString &aValue)
Sets the value of a key.
Definition Profile.cpp:210
QString displayname() const
Gets the display name of the profile.
Definition Profile.cpp:539
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly=true) const
Creates a XML representation of the profile.
Definition Profile.cpp:296
bool isValid() const
Checks if the profile is valid.
Definition Profile.cpp:357
QMap< QString, QString > allNonStorageKeys() const
Gets all keys that are not related to storages.
Definition Profile.cpp:157
void removeKey(const QString &aName)
Removes a key from profile. All instances of the key are removed.
Definition Profile.cpp:251
void setLoaded(bool aLoaded)
Sets if the profile is fully loaded.
Definition Profile.cpp:514
QString key(const QString &aName, const QString &aDefault=QString()) const
Gets the value of the given key.
Definition Profile.cpp:133
bool boolKey(const QString &aName, bool aDefault=false) const
Gets the value of the given boolean key.
Definition Profile.cpp:178
QStringList subProfileNames(const QString &aType="") const
Gets the names of all sub-profiles with the given type.
Definition Profile.cpp:399
bool isLoaded() const
Checks if the profile is fully constructed by loading all sub-profiles from separate profile files.
Definition Profile.cpp:509
const ProfileField * field(const QString &aName) const
Gets the field with the given name.
Definition Profile.cpp:257
virtual bool isEnabled() const
Returns if the profile is enabled.
Definition Profile.cpp:519
static const QString TYPE_CLIENT
String constants for different profile type names.
Definition Profile.h:56
QString type() const
Gets the type of the profile.
Definition Profile.cpp:128
static const QString TYPE_SYNC
Service type.
Definition Profile.h:64
void setBoolKey(const QString &aName, bool aValue)
Sets the value of a boolean key.
Definition Profile.cpp:246
void merge(const Profile &aSource)
Merges a profile to this profile.
Definition Profile.cpp:470
QStringList keyNames() const
Gets the names of all keys.
Definition Profile.cpp:201
QString toString() const
Outputs a XML representation of the profile to a string.
Definition Profile.cpp:344
Profile * subProfile(const QString &aName, const QString &aType="")
Gets a sub-profile with the given name and type.
Definition Profile.cpp:412
virtual void setName(const QString &aName)
Sets the name of the profile.
Definition Profile.cpp:117
QList< const ProfileField * > visibleFields() const
Gets all visible fields of the profile.
Definition Profile.cpp:275
bool isProtected() const
Checks if the profile is protected.
Definition Profile.cpp:534
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:438
QMap< QString, QString > allKeys() const
Gets all keys and their values.
Definition Profile.cpp:146
Definition SyncBackupAdaptor.h:41