libkpimidentities

identitymanager.h
1 /*
2  identitymanager.h
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2002 Marc Mutz <mutz@kde.org>
6 
7  KMail is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License, version 2, as
9  published by the Free Software Foundation.
10 
11  KMail is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20  In addition, as a special exception, the copyright holders give
21  permission to link the code of this program with any edition of
22  the TQt library by Trolltech AS, Norway (or with modified versions
23  of TQt that use the same license as TQt), and distribute linked
24  combinations including the two. You must obey the GNU General
25  Public License in all respects for all of the code used other than
26  TQt. If you modify this file, you may extend this exception to
27  your version of the file, but you are not obligated to do so. If
28  you do not wish to do so, delete this exception statement from
29  your version.
30 */
31 #ifndef _KPIM_IDENTITYMANAGER_H_
32 #define _KPIM_IDENTITYMANAGER_H_
33 
34 #include <libtdepim/configmanager.h>
35 
36 #include <tqvaluelist.h>
37 #include <dcopobject.h>
38 #include <kdemacros.h>
39 
40 class TDEConfigBase;
41 class TDEConfig;
42 class KMKernel;
43 class TQStringList;
44 class KMIdentity;
45 
46 namespace KPIM {
47 
48 class Identity;
53 #define IdentityManager TDE_EXPORT IdentityManager
54 class IdentityManager : public ConfigManager, public DCOPObject
55 #undef IdentityManager
56 {
57  TQ_OBJECT
58 //
59  K_DCOP
60 
61 public:
69  IdentityManager( bool readonly = false, TQObject * parent=0, const char * name=0 );
70  virtual ~IdentityManager();
71 
72 public:
73  typedef TQValueList<Identity>::Iterator Iterator;
74  typedef TQValueList<Identity>::ConstIterator ConstIterator;
75 
77  void commit();
79  void rollback();
80 
82  bool hasPendingChanges() const;
83 
85  TQStringList identities() const;
86 
92  TQStringList shadowIdentities() const;
93 
98  void sort();
99 
103  const Identity & identityForAddress( const TQString & addresses ) const;
104 
109  bool thatIsMe( const TQString & addressList ) const;
110 
115  const Identity & identityForName( const TQString & identityName ) const;
116 
120  const Identity & identityForUoid( uint uoid ) const;
121 
128  const Identity & identityForNameOrDefault( const TQString & identityName ) const;
129 
135  const Identity & identityForUoidOrDefault( uint uoid ) const;
136 
138  const Identity & defaultIdentity() const;
139 
146  bool setAsDefault( const TQString & identityName );
147 
154  bool setAsDefault( uint uoid );
155 
160  Identity & modifyIdentityForName( const TQString & identityName );
161 
166  Identity & modifyIdentityForUoid( uint uoid );
167 
169  bool removeIdentity( const TQString & identityName );
170 
171  ConstIterator begin() const;
172  ConstIterator end() const;
175  Iterator modifyBegin();
176  Iterator modifyEnd();
177 
178  Identity & newFromScratch( const TQString & name );
179  Identity & newFromControlCenter( const TQString & name );
180  Identity & newFromExisting( const Identity & other,
181  const TQString & name=TQString() );
182 
184  TQStringList allEmails() const;
185 
186 signals:
191  void changed( uint uoid );
195  void changed( const KPIM::Identity & ident );
199  void deleted( uint uoid );
201  void added( const KPIM::Identity & ident );
202 
203 protected:
209  virtual void createDefaultIdentity( TQString& /*fullName*/, TQString& /*emailAddress*/ ) {}
210 
211 protected slots:
212  void slotRollback() { rollback(); };
213 
214 protected:
216  TQValueList<Identity> mIdentities;
218  TQValueList<Identity> mShadowIdentities;
219 
220 //k_dcop_signals:
221 // void identitiesChanged( TQCString appId, TQCString objId );
222 
223 k_dcop:
224  // Connected to the DCOP signal
225  void slotIdentitiesChanged( TQCString appId, TQCString objId );
226 
227 private:
228  void writeConfig() const;
229  void readConfig(TDEConfigBase* config);
230  TQStringList groupList(TDEConfigBase* config) const;
231  void createDefaultIdentity();
232 
233  // returns a new Unique Object Identifier
234  int newUoid();
235 
236 private:
237  TDEConfig* mConfig;
238  bool mReadOnly;
239 };
240 
241 } // namespace
242 
243 #endif // _KMAIL_IDENTITYMANAGER_H_
User identity information.
Definition: identity.h:96