kpimidentities
identitymanager.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _KPIM_IDENTITYMANAGER_H_
00021 #define _KPIM_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();
00072 void rollback();
00073
00075 bool hasPendingChanges() const;
00076
00078 QStringList identities() const;
00079
00085 QStringList shadowIdentities() const;
00086
00091 void sort();
00092
00096 const Identity &identityForAddress( const QString &addresses ) const;
00097
00102 bool thatIsMe( const QString &addressList ) const;
00103
00107 const Identity &identityForUoid( uint uoid ) const;
00108
00114 const Identity &identityForUoidOrDefault( uint uoid ) const;
00115
00117 const Identity &defaultIdentity() const;
00118
00125 bool setAsDefault( uint uoid );
00126
00131 Identity &modifyIdentityForName( const QString &identityName );
00132
00137 Identity &modifyIdentityForUoid( uint uoid );
00138
00143 bool removeIdentity( const QString &identityName );
00144
00145 ConstIterator begin() const;
00146 ConstIterator end() const;
00149 Iterator modifyBegin();
00150 Iterator modifyEnd();
00151
00152 Identity &newFromScratch( const QString &name );
00153 Identity &newFromControlCenter( const QString &name );
00154 Identity &newFromExisting( const Identity &other,
00155 const QString &name=QString() );
00156
00159 QStringList allEmails() const;
00160
00161 Q_SIGNALS:
00163 void changed();
00168 void changed( uint uoid );
00172 void changed( const KPIMIdentities::Identity &ident );
00176 void deleted( uint uoid );
00178 void added( const KPIMIdentities::Identity &ident );
00179
00180 protected:
00187 virtual void createDefaultIdentity( QString&,
00188 QString& ) {}
00189
00190 protected Q_SLOTS:
00191 void slotRollback();
00192
00193 protected:
00195 QList<Identity> mIdentities;
00197 QList<Identity> mShadowIdentities;
00198
00199 Q_SIGNALS:
00200 void identitiesChanged( const QString &id );
00201
00202 private Q_SLOTS:
00203
00204 void slotIdentitiesChanged( const QString &id );
00205
00206 private:
00207 void writeConfig() const;
00208 void readConfig( KConfig *config );
00209 QStringList groupList( KConfig *config ) const;
00210 void createDefaultIdentity();
00211
00212
00213 int newUoid();
00214
00215 private:
00216 KConfig *mConfig;
00217 bool mReadOnly;
00218 };
00219
00220 }
00221
00222 #endif // _KMAIL_IDENTITYMANAGER_H_