kpimidentities
identitymanager.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KPIMIDENTITIES_IDENTITYMANAGER_H
00021 #define KPIMIDENTITIES_IDENTITYMANAGER_H
00022
00023 #include <kpimidentities/kpimidentities_export.h>
00024 #include <kconfiggroup.h>
00025 #include <QtCore/QObject>
00026
00027 class KConfigBase;
00028 class KConfig;
00029 class QStringList;
00030
00031 namespace KPIMIdentities
00032 {
00033
00034 class Identity;
00039 class KPIMIDENTITIES_EXPORT IdentityManager : public QObject
00040 {
00041 Q_OBJECT
00042 public:
00051 explicit IdentityManager( bool readonly = false, QObject *parent=0,
00052 const char *name=0 );
00053 virtual ~IdentityManager();
00054
00055 public:
00056 typedef QList<Identity>::Iterator Iterator;
00057 typedef QList<Identity>::ConstIterator ConstIterator;
00058
00062 typedef Iterator iterator;
00063
00067 typedef ConstIterator const_iterator;
00068
00070 void commit();
00071
00073 void rollback();
00074
00076 bool hasPendingChanges() const;
00077
00079 QStringList identities() const;
00080
00086 QStringList shadowIdentities() const;
00087
00092 void sort();
00093
00097 const Identity &identityForAddress( const QString &addresses ) const;
00098
00103 bool thatIsMe( const QString &addressList ) const;
00104
00108 const Identity &identityForUoid( uint uoid ) const;
00109
00115 const Identity &identityForUoidOrDefault( uint uoid ) const;
00116
00118 const Identity &defaultIdentity() const;
00119
00126 bool setAsDefault( uint uoid );
00127
00132 Identity &modifyIdentityForName( const QString &identityName );
00133
00138 Identity &modifyIdentityForUoid( uint uoid );
00139
00144 bool removeIdentity( const QString &identityName );
00145
00146 ConstIterator begin() const;
00147 ConstIterator end() const;
00150 Iterator modifyBegin();
00151 Iterator modifyEnd();
00152
00153 Identity &newFromScratch( const QString &name );
00154 Identity &newFromControlCenter( const QString &name );
00155 Identity &newFromExisting( const Identity &other,
00156 const QString &name=QString() );
00157
00160 QStringList allEmails() const;
00161
00162 Q_SIGNALS:
00164 void changed();
00169 void changed( uint uoid );
00173 void changed( const KPIMIdentities::Identity &ident );
00177 void deleted( uint uoid );
00179 void added( const KPIMIdentities::Identity &ident );
00180
00181 protected:
00188 virtual void createDefaultIdentity( QString&,
00189 QString& ) {}
00190
00191 protected Q_SLOTS:
00192 void slotRollback();
00193
00194 protected:
00196 QList<Identity> mIdentities;
00198 QList<Identity> mShadowIdentities;
00199
00200 Q_SIGNALS:
00201 void identitiesChanged( const QString &id );
00202
00203 private Q_SLOTS:
00204
00205 void slotIdentitiesChanged( const QString &id );
00206
00207 private:
00208 void writeConfig() const;
00209 void readConfig( KConfig *config );
00210 QStringList groupList( KConfig *config ) const;
00211 void createDefaultIdentity();
00212
00213
00214 int newUoid();
00215
00216 private:
00217 KConfig *mConfig;
00218 bool mReadOnly;
00219 };
00220
00221 }
00222
00223 #endif // _KMAIL_IDENTITYMANAGER_H_