libkpimidentities
identitymanager.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _KPIM_IDENTITYMANAGER_H_
00032 #define _KPIM_IDENTITYMANAGER_H_
00033
00034 #include <libkdepim/configmanager.h>
00035
00036 #include <qvaluelist.h>
00037 #include <dcopobject.h>
00038 #include <kdepimmacros.h>
00039
00040 class KConfigBase;
00041 class KConfig;
00042 class KMKernel;
00043 class QStringList;
00044 class KMIdentity;
00045
00046 namespace KPIM {
00047
00048 class Identity;
00053 #define IdentityManager KDE_EXPORT IdentityManager
00054 class IdentityManager : public ConfigManager, public DCOPObject
00055 #undef IdentityManager
00056 {
00057 Q_OBJECT
00058 K_DCOP
00059
00060 public:
00068 IdentityManager( bool readonly = false, QObject * parent=0, const char * name=0 );
00069 virtual ~IdentityManager();
00070
00071 public:
00072 typedef QValueList<Identity>::Iterator Iterator;
00073 typedef QValueList<Identity>::ConstIterator ConstIterator;
00074
00076 void commit();
00078 void rollback();
00079
00081 bool hasPendingChanges() const;
00082
00084 QStringList identities() const;
00085
00091 QStringList shadowIdentities() const;
00092
00097 void sort();
00098
00102 const Identity & identityForAddress( const QString & addresses ) const;
00103
00108 bool thatIsMe( const QString & addressList ) const;
00109
00114 const Identity & identityForName( const QString & identityName ) const;
00115
00119 const Identity & identityForUoid( uint uoid ) const;
00120
00127 const Identity & identityForNameOrDefault( const QString & identityName ) const;
00128
00134 const Identity & identityForUoidOrDefault( uint uoid ) const;
00135
00137 const Identity & defaultIdentity() const;
00138
00145 bool setAsDefault( const QString & identityName );
00146
00153 bool setAsDefault( uint uoid );
00154
00159 Identity & modifyIdentityForName( const QString & identityName );
00160
00165 Identity & modifyIdentityForUoid( uint uoid );
00166
00168 bool removeIdentity( const QString & identityName );
00169
00170 ConstIterator begin() const;
00171 ConstIterator end() const;
00174 Iterator modifyBegin();
00175 Iterator modifyEnd();
00176
00177 Identity & newFromScratch( const QString & name );
00178 Identity & newFromControlCenter( const QString & name );
00179 Identity & newFromExisting( const Identity & other,
00180 const QString & name=QString::null );
00181
00183 QStringList allEmails() const;
00184
00185 signals:
00190 void changed( uint uoid );
00194 void changed( const KPIM::Identity & ident );
00198 void deleted( uint uoid );
00200 void added( const KPIM::Identity & ident );
00201
00202 protected:
00208 virtual void createDefaultIdentity( QString& , QString& ) {}
00209
00210 protected slots:
00211 void slotRollback() { rollback(); };
00212
00213 protected:
00215 QValueList<Identity> mIdentities;
00217 QValueList<Identity> mShadowIdentities;
00218
00219
00220
00221
00222 k_dcop:
00223
00224 void slotIdentitiesChanged( QCString appId, QCString objId );
00225
00226 private:
00227 void writeConfig() const;
00228 void readConfig(KConfigBase* config);
00229 QStringList groupList(KConfigBase* config) const;
00230 void createDefaultIdentity();
00231
00232
00233 int newUoid();
00234
00235 private:
00236 KConfig* mConfig;
00237 bool mReadOnly;
00238 };
00239
00240 }
00241
00242 #endif // _KMAIL_IDENTITYMANAGER_H_
|