Profile.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef PROFILE_H
#define PROFILE_H
#include <QList>
#include <QMap>
#include <QString>
#include <QStringList>
#include "ProfileField.h"
class QDomDocument;
class QDomElement;
namespace Buteo {
class ProfileTest;
class ProfilePrivate;
class Profile
{
public:
static const QString TYPE_CLIENT;
static const QString TYPE_SERVER;
static const QString TYPE_STORAGE;
//static const QString TYPE_SERVICE;
static const QString TYPE_SYNC;
Profile();
Profile(const QString &aName, const QString &aType);
explicit Profile(const QDomElement &aRoot);
Profile(const Profile &aSource);
virtual Profile *clone() const;
virtual ~Profile();
QString name() const;
QString displayname() const;
virtual void setName(const QString &aName);
virtual void setName(const QStringList &aKeys);
QString type() const;
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly = true) const;
QString toString() const;
QString key(const QString &aName, const QString &aDefault = QString()) const;
QMap<QString, QString> allKeys() const;
QMap<QString, QString> allNonStorageKeys() const;
bool boolKey(const QString &aName, bool aDefault = false) const;
QStringList keyValues(const QString &aName) const;
QStringList keyNames() const;
void setKey(const QString &aName, const QString &aValue);
void setKeyValues(const QString &aName, const QStringList &aValues);
void setBoolKey(const QString &aName, bool aValue);
void removeKey(const QString &aName);
const ProfileField *field(const QString &aName) const;
QList<const ProfileField *> allFields() const;
QList<const ProfileField *> visibleFields() const;
bool isValid() const;
QStringList subProfileNames(const QString &aType = "") const;
Profile *subProfile(const QString &aName, const QString &aType = "");
const Profile *subProfile(const QString &aName, const QString &aType = "") const;
const Profile *subProfileByKeyValue(const QString &aKey,
const QString &aValue,
const QString &aType,
bool aEnabledOnly) const;
QList<Profile *> allSubProfiles();
QList<const Profile *> allSubProfiles() const;
void merge(const Profile &aSource);
bool isLoaded() const;
void setLoaded(bool aLoaded);
virtual bool isEnabled() const;
void setEnabled(bool aEnabled);
bool isHidden() const;
bool isProtected() const;
private:
Profile &operator=(const Profile &aRhs);
ProfilePrivate *d_ptr;
QString generateProfileId(const QStringList &aKeys);
#ifdef SYNCFW_UNIT_TESTS
friend class ProfileTest;
#endif
};
}
#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::allSubProfiles
QList< Profile * > allSubProfiles()
Gets all sub-profiles.
Definition Profile.cpp:420
Buteo::Profile::allFields
QList< const ProfileField * > allFields() const
Gets all fields.
Definition Profile.cpp:235
Buteo::Profile::keyValues
QStringList keyValues(const QString &aName) const
Gets the values of all keys with the given name.
Definition Profile.cpp:171
Buteo::Profile::setEnabled
void setEnabled(bool aEnabled)
Set is the profile is enabled.
Definition Profile.cpp:484
Buteo::Profile::TYPE_SERVER
static const QString TYPE_SERVER
Server type .
Definition Profile.h:58
Buteo::Profile::isHidden
bool isHidden() const
Checks if the profile is hidden.
Definition Profile.cpp:489
Buteo::Profile::setKeyValues
void setKeyValues(const QString &aName, const QStringList &aValues)
Sets multiple values for a key.
Definition Profile.cpp:198
Buteo::Profile::Profile
Profile()
Default Constructor.
Definition Profile.cpp:41
Buteo::Profile::name
QString name() const
Gets the name of the profile.
Definition Profile.cpp:104
Buteo::Profile::clone
virtual Profile * clone() const
Creates a clone of the profile.
Definition Profile.cpp:93
Buteo::Profile::~Profile
virtual ~Profile()
Destructor.
Definition Profile.cpp:98
Buteo::Profile::TYPE_STORAGE
static const QString TYPE_STORAGE
Storage type.
Definition Profile.h:60
Buteo::Profile::setKey
void setKey(const QString &aName, const QString &aValue)
Sets the value of a key.
Definition Profile.cpp:181
Buteo::Profile::displayname
QString displayname() const
Gets the display name of the profile.
Definition Profile.cpp:499
Buteo::Profile::toXml
virtual QDomElement toXml(QDomDocument &aDoc, bool aLocalOnly=true) const
Creates a XML representation of the profile.
Definition Profile.cpp:263
Buteo::Profile::isValid
bool isValid() const
Checks if the profile is valid.
Definition Profile.cpp:322
Buteo::Profile::allNonStorageKeys
QMap< QString, QString > allNonStorageKeys() const
Gets all keys that are not related to storages.
Definition Profile.cpp:146
Buteo::Profile::removeKey
void removeKey(const QString &aName)
Removes a key from profile. All instances of the key are removed.
Definition Profile.cpp:218
Buteo::Profile::setLoaded
void setLoaded(bool aLoaded)
Sets if the profile is fully loaded.
Definition Profile.cpp:474
Buteo::Profile::key
QString key(const QString &aName, const QString &aDefault=QString()) const
Gets the value of the given key.
Definition Profile.cpp:125
Buteo::Profile::boolKey
bool boolKey(const QString &aName, bool aDefault=false) const
Gets the value of the given boolean key.
Definition Profile.cpp:161
Buteo::Profile::subProfileNames
QStringList subProfileNames(const QString &aType="") const
Gets the names of all sub-profiles with the given type.
Definition Profile.cpp:364
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:469
Buteo::Profile::field
const ProfileField * field(const QString &aName) const
Gets the field with the given name.
Definition Profile.cpp:224
Buteo::Profile::isEnabled
virtual bool isEnabled() const
Returns if the profile is enabled.
Definition Profile.cpp:479
Buteo::Profile::TYPE_CLIENT
static const QString TYPE_CLIENT
String constants for different profile type names.
Definition Profile.h:56
Buteo::Profile::type
QString type() const
Gets the type of the profile.
Definition Profile.cpp:120
Buteo::Profile::TYPE_SYNC
static const QString TYPE_SYNC
Service type.
Definition Profile.h:64
Buteo::Profile::setBoolKey
void setBoolKey(const QString &aName, bool aValue)
Sets the value of a boolean key.
Definition Profile.cpp:213
Buteo::Profile::merge
void merge(const Profile &aSource)
Merges a profile to this profile.
Definition Profile.cpp:435
Buteo::Profile::keyNames
QStringList keyNames() const
Gets the names of all keys.
Definition Profile.cpp:176
Buteo::Profile::toString
QString toString() const
Outputs a XML representation of the profile to a string.
Definition Profile.cpp:310
Buteo::Profile::subProfile
Profile * subProfile(const QString &aName, const QString &aType="")
Gets a sub-profile with the given name and type.
Definition Profile.cpp:377
Buteo::Profile::setName
virtual void setName(const QString &aName)
Sets the name of the profile.
Definition Profile.cpp:109
Buteo::Profile::visibleFields
QList< const ProfileField * > visibleFields() const
Gets all visible fields of the profile.
Definition Profile.cpp:242
Buteo::Profile::isProtected
bool isProtected() const
Checks if the profile is protected.
Definition Profile.cpp:494
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:403
Buteo::Profile::allKeys
QMap< QString, QString > allKeys() const
Gets all keys and their values.
Definition Profile.cpp:138
QList
Definition SyncBackupAdaptor.h:40
QMap
Definition SyncBackupAdaptor.h:41