• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

kpimidentities

  • kpimidentities
identitymanager.cpp
1 /*
2  Copyright (c) 2002 Marc Mutz <mutz@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 // config keys:
21 static const char configKeyDefaultIdentity[] = "Default Identity";
22 
23 #include "identitymanager.h"
24 #include "identity.h" // for IdentityList::{export,import}Data
25 
26 #include <kpimutils/email.h> // for static helper functions
27 
28 #include <kemailsettings.h> // for IdentityEntry::fromControlCenter()
29 #include <klocale.h>
30 #include <klocalizedstring.h>
31 #include <kglobal.h>
32 #include <kdebug.h>
33 #include <kconfig.h>
34 #include <kuser.h>
35 #include <kconfiggroup.h>
36 
37 #include <QList>
38 #include <QRegExp>
39 #include <QtDBus/QtDBus>
40 #include <QHostInfo>
41 
42 #include <assert.h>
43 #include <krandom.h>
44 
45 #include "identitymanageradaptor.h"
46 
47 using namespace KPIMIdentities;
48 
49 static QString newDBusObjectName()
50 {
51  static int s_count = 0;
52  QString name( QLatin1String("/KPIMIDENTITIES_IdentityManager") );
53  if ( s_count++ ) {
54  name += QLatin1Char('_');
55  name += QString::number( s_count );
56  }
57  return name;
58 }
59 
60 IdentityManager::IdentityManager( bool readonly, QObject *parent,
61  const char *name )
62  : QObject( parent )
63 {
64  setObjectName( QLatin1String(name) );
65  KGlobal::locale()->insertCatalog( QLatin1String("libkpimidentities") );
66  new IdentityManagerAdaptor( this );
67  QDBusConnection dbus = QDBusConnection::sessionBus();
68  const QString dbusPath = newDBusObjectName();
69  setProperty( "uniqueDBusPath", dbusPath );
70  const QString dbusInterface = QLatin1String("org.kde.pim.IdentityManager");
71  dbus.registerObject( dbusPath, this );
72  dbus.connect( QString(), QString(), dbusInterface, QLatin1String("identitiesChanged"), this,
73  SLOT(slotIdentitiesChanged(QString)) );
74 
75  mReadOnly = readonly;
76  mConfig = new KConfig( QLatin1String("emailidentities") );
77  readConfig( mConfig );
78  if ( mIdentities.isEmpty() ) {
79  kDebug( 5325 ) << "emailidentities is empty -> convert from kmailrc";
80  // No emailidentities file, or an empty one due to broken conversion
81  // (kconf_update bug in kdelibs <= 3.2.2)
82  // => convert it, i.e. read settings from kmailrc
83  KConfig kmailConf( QLatin1String("kmailrc") );
84  readConfig( &kmailConf );
85  }
86  // we need at least a default identity:
87  if ( mIdentities.isEmpty() ) {
88  kDebug( 5325 ) << "IdentityManager: No identity found. Creating default.";
89  createDefaultIdentity();
90  commit();
91  }
92 
93  KConfig kmailConf( QLatin1String("kmail2rc") );
94  if (!mReadOnly) {
95  bool needCommit = false;
96  if (kmailConf.hasGroup(QLatin1String("Composer"))) {
97  KConfigGroup composerGroup = kmailConf.group(QLatin1String("Composer"));
98  if (composerGroup.hasKey(QLatin1String("pgp-auto-sign"))) {
99  const bool pgpAutoSign = composerGroup.readEntry(QLatin1String("pgp-auto-sign"), false);
100  QList<Identity>::iterator end = mIdentities.end();
101  for ( QList<Identity>::iterator it = mIdentities.begin(); it != end; ++it ) {
102  it->setPgpAutoSign(pgpAutoSign);
103  }
104  composerGroup.deleteEntry(QLatin1String("pgp-auto-sign"));
105  composerGroup.sync();
106  needCommit = true;
107  }
108  }
109  if (kmailConf.hasGroup(QLatin1String("General"))) {
110  KConfigGroup generalGroup = kmailConf.group(QLatin1String("General"));
111  if (generalGroup.hasKey(QLatin1String("Default domain"))) {
112  QString defaultDomain = generalGroup.readEntry(QLatin1String("Default domain"));
113  if (defaultDomain.isEmpty()) {
114  defaultDomain = QHostInfo::localHostName();
115  }
116  QList<Identity>::iterator end = mIdentities.end();
117  for ( QList<Identity>::iterator it = mIdentities.begin(); it != end; ++it ) {
118  it->setDefaultDomainName(defaultDomain);
119  }
120  generalGroup.deleteEntry(QLatin1String("Default domain"));
121  generalGroup.sync();
122  needCommit = true;
123  }
124  }
125  if (needCommit)
126  commit();
127  }
128 
129  // Migration: people without settings in kemailsettings should get some
130  if ( KEMailSettings().getSetting( KEMailSettings::EmailAddress ).isEmpty() ) {
131  writeConfig();
132  }
133 }
134 
135 IdentityManager::~IdentityManager()
136 {
137  kWarning( hasPendingChanges(), 5325 )
138  << "IdentityManager: There were uncommitted changes!";
139  delete mConfig;
140 }
141 
142 QString IdentityManager::makeUnique( const QString &name ) const
143 {
144  int suffix = 1;
145  QString result = name;
146  while ( identities().contains( result ) ) {
147  result = i18nc( "%1: name; %2: number appended to it to make it unique "
148  "among a list of names", "%1 #%2",
149  name, suffix );
150  suffix++;
151  }
152  return result;
153 }
154 
155 bool IdentityManager::isUnique( const QString &name ) const
156 {
157  return !identities().contains( name );
158 }
159 
160 void IdentityManager::commit()
161 {
162  // early out:
163  if ( !hasPendingChanges() || mReadOnly ) {
164  return;
165  }
166 
167  QList<uint> seenUOIDs;
168  QList<Identity>::ConstIterator end = mIdentities.constEnd();
169  for ( QList<Identity>::ConstIterator it = mIdentities.constBegin();
170  it != end; ++it ) {
171  seenUOIDs << ( *it ).uoid();
172  }
173 
174  QList<uint> changedUOIDs;
175  // find added and changed identities:
176  for ( QList<Identity>::ConstIterator it = mShadowIdentities.constBegin();
177  it != mShadowIdentities.constEnd(); ++it ) {
178  int index = seenUOIDs.indexOf( ( *it ).uoid() );
179  if ( index != -1 ) {
180  uint uoid = seenUOIDs.at( index );
181  const Identity &orig = identityForUoid( uoid ); // look up in mIdentities
182  if ( *it != orig ) {
183  // changed identity
184  kDebug( 5325 ) << "emitting changed() for identity" << uoid;
185  emit changed( *it );
186  changedUOIDs << uoid;
187  }
188  seenUOIDs.removeAll( uoid );
189  } else {
190  // new identity
191  kDebug( 5325 ) << "emitting added() for identity" << ( *it ).uoid();
192  emit added( *it );
193  }
194  }
195 
196  // what's left are deleted identities:
197  for ( QList<uint>::ConstIterator it = seenUOIDs.constBegin();
198  it != seenUOIDs.constEnd(); ++it ) {
199  kDebug( 5325 ) << "emitting deleted() for identity" << ( *it );
200  emit deleted( *it );
201  }
202 
203  mIdentities = mShadowIdentities;
204  writeConfig();
205 
206  // now that mIdentities has all the new info, we can emit the added/changed
207  // signals that ship a uoid. This is because the slots might use
208  // identityForUoid(uoid)...
209  QList<uint>::ConstIterator changedEnd( changedUOIDs.constEnd() );
210  for ( QList<uint>::ConstIterator it = changedUOIDs.constBegin();
211  it != changedEnd; ++it ) {
212  emit changed( *it );
213  }
214 
215  emit changed(); // normal signal
216 
217  // DBus signal for other IdentityManager instances
218  const QString ourIdentifier = QString::fromLatin1( "%1/%2" ).
219  arg( QDBusConnection::sessionBus().baseService() ).
220  arg( property( "uniqueDBusPath" ).toString() );
221  emit identitiesChanged( ourIdentifier );
222 }
223 
224 void IdentityManager::rollback()
225 {
226  mShadowIdentities = mIdentities;
227 }
228 
229 bool IdentityManager::hasPendingChanges() const
230 {
231  return mIdentities != mShadowIdentities;
232 }
233 
234 QStringList IdentityManager::identities() const
235 {
236  QStringList result;
237  ConstIterator end = mIdentities.constEnd();
238  for ( ConstIterator it = mIdentities.constBegin();
239  it != end; ++it ) {
240  result << ( *it ).identityName();
241  }
242  return result;
243 }
244 
245 QStringList IdentityManager::shadowIdentities() const
246 {
247  QStringList result;
248  ConstIterator end = mShadowIdentities.constEnd();
249  for ( ConstIterator it = mShadowIdentities.constBegin();
250  it != end; ++it ) {
251  result << ( *it ).identityName();
252  }
253  return result;
254 }
255 
256 void IdentityManager::sort()
257 {
258  qSort( mShadowIdentities );
259 }
260 
261 void IdentityManager::writeConfig() const
262 {
263  const QStringList identities = groupList( mConfig );
264  QStringList::const_iterator groupEnd = identities.constEnd();
265  for ( QStringList::const_iterator group = identities.constBegin();
266  group != groupEnd; ++group ) {
267  mConfig->deleteGroup( *group );
268  }
269  int i = 0;
270  ConstIterator end = mIdentities.constEnd();
271  for ( ConstIterator it = mIdentities.constBegin();
272  it != end; ++it, ++i ) {
273  KConfigGroup cg( mConfig, QString::fromLatin1( "Identity #%1" ).arg( i ) );
274  ( *it ).writeConfig( cg );
275  if ( ( *it ).isDefault() ) {
276  // remember which one is default:
277  KConfigGroup general( mConfig, "General" );
278  general.writeEntry( configKeyDefaultIdentity, ( *it ).uoid() );
279 
280  // Also write the default identity to emailsettings
281  KEMailSettings es;
282  es.setSetting( KEMailSettings::RealName, ( *it ).fullName() );
283  es.setSetting( KEMailSettings::EmailAddress, ( *it ).primaryEmailAddress() );
284  es.setSetting( KEMailSettings::Organization, ( *it ).organization() );
285  es.setSetting( KEMailSettings::ReplyToAddress, ( *it ).replyToAddr() );
286  }
287  }
288  mConfig->sync();
289 
290 }
291 
292 void IdentityManager::readConfig( KConfig *config )
293 {
294  mIdentities.clear();
295 
296  const QStringList identities = groupList( config );
297  if ( identities.isEmpty() ) {
298  return; // nothing to be done...
299  }
300 
301  KConfigGroup general( config, "General" );
302  uint defaultIdentity = general.readEntry( configKeyDefaultIdentity, 0 );
303  bool haveDefault = false;
304  QStringList::const_iterator groupEnd = identities.constEnd();
305  for ( QStringList::const_iterator group = identities.constBegin();
306  group != groupEnd; ++group ) {
307  KConfigGroup configGroup( config, *group );
308  Identity identity;
309  identity.readConfig( configGroup );
310  //Don't load invalid identity
311  if (!identity.isNull() && !identity.primaryEmailAddress().isEmpty()) {
312  if ( !haveDefault && identity.uoid() == defaultIdentity ) {
313  haveDefault = true;
314  identity.setIsDefault( true );
315  }
316  mIdentities << identity;
317  }
318  }
319 
320  if ( !haveDefault ) {
321  if (mIdentities.isEmpty()) {
322  mIdentities << Identity();
323  }
324  kWarning( 5325 ) << "IdentityManager: There was no default identity."
325  << "Marking first one as default.";
326  mIdentities.first().setIsDefault( true );
327  }
328  qSort( mIdentities );
329 
330  mShadowIdentities = mIdentities;
331 }
332 
333 QStringList IdentityManager::groupList( KConfig *config ) const
334 {
335  return config->groupList().filter( QRegExp( QLatin1String("^Identity #\\d+$") ) );
336 }
337 
338 IdentityManager::ConstIterator IdentityManager::begin() const
339 {
340  return mIdentities.begin();
341 }
342 
343 IdentityManager::ConstIterator IdentityManager::end() const
344 {
345  return mIdentities.end();
346 }
347 
348 IdentityManager::Iterator IdentityManager::modifyBegin()
349 {
350  return mShadowIdentities.begin();
351 }
352 
353 IdentityManager::Iterator IdentityManager::modifyEnd()
354 {
355  return mShadowIdentities.end();
356 }
357 
358 const Identity &IdentityManager::identityForUoid( uint uoid ) const
359 {
360  for ( ConstIterator it = begin(); it != end(); ++it ) {
361  if ( ( *it ).uoid() == uoid ) {
362  return ( *it );
363  }
364  }
365  return Identity::null();
366 }
367 
368 const Identity &IdentityManager::identityForUoidOrDefault( uint uoid ) const
369 {
370  const Identity &ident = identityForUoid( uoid );
371  if ( ident.isNull() ) {
372  return defaultIdentity();
373  } else {
374  return ident;
375  }
376 }
377 
378 const Identity &IdentityManager::identityForAddress(
379  const QString &addresses ) const
380 {
381  const QStringList addressList = KPIMUtils::splitAddressList( addresses );
382  foreach ( const QString &fullAddress, addressList ) {
383  const QString addrSpec = KPIMUtils::extractEmailAddress( fullAddress ).toLower();
384  for ( ConstIterator it = begin(); it != end(); ++it ) {
385  const Identity &identity = *it;
386  if ( identity.matchesEmailAddress( addrSpec ) ) {
387  return identity;
388  }
389  }
390  }
391  return Identity::null();
392 }
393 
394 bool IdentityManager::thatIsMe( const QString &addressList ) const
395 {
396  return !identityForAddress( addressList ).isNull();
397 }
398 
399 Identity &IdentityManager::modifyIdentityForName( const QString &name )
400 {
401  for ( Iterator it = modifyBegin(); it != modifyEnd(); ++it ) {
402  if ( ( *it ).identityName() == name ) {
403  return ( *it );
404  }
405  }
406 
407  kWarning( 5325 ) << "IdentityManager::modifyIdentityForName() used as"
408  << "newFromScratch() replacement!"
409  << endl << " name == \"" << name << "\"";
410  return newFromScratch( name );
411 }
412 
413 Identity &IdentityManager::modifyIdentityForUoid( uint uoid )
414 {
415  for ( Iterator it = modifyBegin(); it != modifyEnd(); ++it ) {
416  if ( ( *it ).uoid() == uoid ) {
417  return ( *it );
418  }
419  }
420 
421  kWarning( 5325 ) << "IdentityManager::identityForUoid() used as"
422  << "newFromScratch() replacement!"
423  << endl << " uoid == \"" << uoid << "\"";
424  return newFromScratch( i18n( "Unnamed" ) );
425 }
426 
427 const Identity &IdentityManager::defaultIdentity() const
428 {
429  for ( ConstIterator it = begin(); it != end(); ++it ) {
430  if ( ( *it ).isDefault() ) {
431  return ( *it );
432  }
433  }
434 
435  if ( mIdentities.isEmpty() ) {
436  kFatal( 5325 ) << "IdentityManager: No default identity found!";
437  } else {
438  kWarning( 5325 ) << "IdentityManager: No default identity found!";
439  }
440  return *begin();
441 }
442 
443 bool IdentityManager::setAsDefault( uint uoid )
444 {
445  // First, check if the identity actually exists:
446  bool found = false;
447  for ( ConstIterator it = mShadowIdentities.constBegin();
448  it != mShadowIdentities.constEnd(); ++it ) {
449  if ( ( *it ).uoid() == uoid ) {
450  found = true;
451  break;
452  }
453  }
454 
455  if ( !found ) {
456  return false;
457  }
458 
459  // Then, change the default as requested:
460  for ( Iterator it = modifyBegin(); it != modifyEnd(); ++it ) {
461  ( *it ).setIsDefault( ( *it ).uoid() == uoid );
462  }
463 
464  // and re-sort:
465  sort();
466  return true;
467 }
468 
469 bool IdentityManager::removeIdentity( const QString &name )
470 {
471  if ( mShadowIdentities.size() <= 1 ) {
472  return false;
473  }
474 
475  for ( Iterator it = modifyBegin(); it != modifyEnd(); ++it ) {
476  if ( ( *it ).identityName() == name ) {
477  bool removedWasDefault = ( *it ).isDefault();
478  mShadowIdentities.erase( it );
479  if ( removedWasDefault && !mShadowIdentities.isEmpty() ) {
480  mShadowIdentities.first().setIsDefault( true );
481  }
482  return true;
483  }
484  }
485  return false;
486 }
487 
488 bool IdentityManager::removeIdentityForced( const QString &name )
489 {
490  for ( Iterator it = modifyBegin(); it != modifyEnd(); ++it ) {
491  if ( ( *it ).identityName() == name ) {
492  bool removedWasDefault = ( *it ).isDefault();
493  mShadowIdentities.erase( it );
494  if ( removedWasDefault && !mShadowIdentities.isEmpty() ) {
495  mShadowIdentities.first().setIsDefault( true );
496  }
497  return true;
498  }
499  }
500  return false;
501 }
502 
503 Identity &IdentityManager::newFromScratch( const QString &name )
504 {
505  return newFromExisting( Identity( name ) );
506 }
507 
508 Identity &IdentityManager::newFromControlCenter( const QString &name )
509 {
510  KEMailSettings es;
511  es.setProfile( es.defaultProfileName() );
512 
513  return
514  newFromExisting( Identity( name,
515  es.getSetting( KEMailSettings::RealName ),
516  es.getSetting( KEMailSettings::EmailAddress ),
517  es.getSetting( KEMailSettings::Organization ),
518  es.getSetting( KEMailSettings::ReplyToAddress ) ) );
519 }
520 
521 Identity &IdentityManager::newFromExisting( const Identity &other, const QString &name )
522 {
523  mShadowIdentities << other;
524  Identity &result = mShadowIdentities.last();
525  result.setIsDefault( false ); // we don't want two default identities!
526  result.setUoid( newUoid() ); // we don't want two identies w/ same UOID
527  if ( !name.isNull() ) {
528  result.setIdentityName( name );
529  }
530  return result;
531 }
532 
533 void IdentityManager::createDefaultIdentity()
534 {
535  QString fullName, emailAddress;
536  bool done = false;
537 
538  // Check if the application has any settings
539  createDefaultIdentity( fullName, emailAddress );
540 
541  // If not, then use the kcontrol settings
542  if ( fullName.isEmpty() && emailAddress.isEmpty() ) {
543  KEMailSettings emailSettings;
544  fullName = emailSettings.getSetting( KEMailSettings::RealName );
545  emailAddress = emailSettings.getSetting( KEMailSettings::EmailAddress );
546 
547  if ( !fullName.isEmpty() && !emailAddress.isEmpty() ) {
548  newFromControlCenter( i18nc( "use default address from control center",
549  "Default" ) );
550  done = true;
551  } else {
552  // If KEmailSettings doesn't have name and address, generate something from KUser
553  KUser user;
554  if ( fullName.isEmpty() ) {
555  fullName = user.property( KUser::FullName ).toString();
556  }
557  if ( emailAddress.isEmpty() ) {
558  emailAddress = user.loginName();
559  if ( !emailAddress.isEmpty() ) {
560  KConfigGroup general( mConfig, "General" );
561  QString defaultdomain = general.readEntry( "Default domain" );
562  if ( !defaultdomain.isEmpty() ) {
563  emailAddress += QLatin1Char('@') + defaultdomain;
564  } else {
565  emailAddress.clear();
566  }
567  }
568  }
569  }
570  }
571 
572  if ( !done ) {
573  // Default identity name
574  QString name( i18nc( "Default name for new email accounts/identities.", "Unnamed" ) );
575 
576  if ( !emailAddress.isEmpty() ) {
577  // If we have an email address, create a default identity name from it
578  QString idName = emailAddress;
579  int pos = idName.indexOf( QLatin1Char('@') );
580  if ( pos != -1 ) {
581  name = idName.mid( pos + 1, -1 );
582  }
583 
584  // Make the name a bit more human friendly
585  name.replace( QLatin1Char('.'), QLatin1Char(' ') );
586  pos = name.indexOf( QLatin1Char(' ') );
587  if ( pos != 0 ) {
588  name[pos + 1] = name[pos + 1].toUpper();
589  }
590  name[0] = name[0].toUpper();
591  } else if ( !fullName.isEmpty() ) {
592  // If we have a full name, create a default identity name from it
593  name = fullName;
594  }
595  mShadowIdentities << Identity( name, fullName, emailAddress );
596  }
597 
598  mShadowIdentities.last().setIsDefault( true );
599  mShadowIdentities.last().setUoid( newUoid() );
600  if ( mReadOnly ) { // commit won't do it in readonly mode
601  mIdentities = mShadowIdentities;
602  }
603 }
604 
605 int IdentityManager::newUoid()
606 {
607  int uoid;
608 
609  // determine the UOIDs of all saved identities
610  QList<uint> usedUOIDs;
611  QList<Identity>::ConstIterator end( mIdentities.constEnd() );
612  for ( QList<Identity>::ConstIterator it = mIdentities.constBegin();
613  it != end; ++it ) {
614  usedUOIDs << ( *it ).uoid();
615  }
616 
617  if ( hasPendingChanges() ) {
618  // add UOIDs of all shadow identities. Yes, we will add a lot of duplicate
619  // UOIDs, but avoiding duplicate UOIDs isn't worth the effort.
620  QList<Identity>::ConstIterator endShadow( mShadowIdentities.constEnd() );
621  for ( QList<Identity>::ConstIterator it = mShadowIdentities.constBegin();
622  it != endShadow; ++it ) {
623  usedUOIDs << ( *it ).uoid();
624  }
625  }
626 
627  usedUOIDs << 0; // no UOID must be 0 because this value always refers to the
628  // default identity
629 
630  do {
631  uoid = KRandom::random();
632  } while ( usedUOIDs.indexOf( uoid ) != -1 );
633 
634  return uoid;
635 }
636 
637 QStringList KPIMIdentities::IdentityManager::allEmails() const
638 {
639  QStringList lst;
640  for ( ConstIterator it = begin(); it != end(); ++it ) {
641  lst << ( *it ).primaryEmailAddress();
642  if ( !( *it ).emailAliases().isEmpty() ) {
643  lst << ( *it ).emailAliases();
644  }
645  }
646  return lst;
647 }
648 
649 void KPIMIdentities::IdentityManager::slotRollback()
650 {
651  rollback();
652 }
653 
654 void KPIMIdentities::IdentityManager::slotIdentitiesChanged( const QString &id )
655 {
656  kDebug( 5325 ) << " KPIMIdentities::IdentityManager::slotIdentitiesChanged :" << id;
657  const QString ourIdentifier = QString::fromLatin1( "%1/%2" ).
658  arg( QDBusConnection::sessionBus().baseService() ).
659  arg( property( "uniqueDBusPath" ).toString() );
660  if ( id != ourIdentifier ) {
661  mConfig->reparseConfiguration();
662  Q_ASSERT( !hasPendingChanges() );
663  readConfig( mConfig );
664  emit changed();
665  }
666 }
667 
KPIMIdentities::IdentityManager::makeUnique
QString makeUnique(const QString &name) const
Definition: identitymanager.cpp:142
KPIMIdentities::IdentityManager::deleted
void deleted(uint uoid)
Emitted on commit() for each deleted identity.
KPIMIdentities::IdentityManager::removeIdentityForced
bool removeIdentityForced(const QString &identityName)
Removes the identity with name identityName Will return false if the identity is not found...
Definition: identitymanager.cpp:488
KPIMIdentities::IdentityManager::IdentityManager
IdentityManager(bool readonly=false, QObject *parent=0, const char *name=0)
Create an identity manager, which loads the emailidentities file to create identities.
Definition: identitymanager.cpp:60
KPIMIdentities::IdentityManager::changed
void changed()
Emitted whenever a commit changes any configure option.
KPIMIdentities
Definition: identity.h:36
KPIMIdentities::Identity::setIsDefault
void setIsDefault(bool flag)
Set whether this identity is the default identity.
Definition: identity.cpp:625
KPIMIdentities::IdentityManager::rollback
void rollback()
Re-read the config from disk and forget changes.
Definition: identitymanager.cpp:224
KPIMIdentities::IdentityManager::identityForUoidOrDefault
const Identity & identityForUoidOrDefault(uint uoid) const
Convenience menthod.
Definition: identitymanager.cpp:368
KPIMIdentities::IdentityManager::isUnique
bool isUnique(const QString &name) const
Definition: identitymanager.cpp:155
KPIMIdentities::Identity::setIdentityName
void setIdentityName(const QString &name)
Identity/nickname for this collection.
Definition: identity.cpp:515
KPIMIdentities::Identity::primaryEmailAddress
QString primaryEmailAddress() const
primary email address (without the user name - only name@host).
Definition: identity.cpp:385
KPIMIdentities::Identity::uoid
uint uoid() const
Unique Object Identifier for this identity.
Definition: identity.cpp:340
KPIMIdentities::IdentityManager::modifyIdentityForUoid
Identity & modifyIdentityForUoid(uint uoid)
Definition: identitymanager.cpp:413
KPIMIdentities::IdentityManager::createDefaultIdentity
virtual void createDefaultIdentity(QString &, QString &)
This is called when no identity has been defined, so we need to create a default one.
Definition: identitymanager.h:216
KPIMIdentities::IdentityManager::identities
QStringList identities() const
Definition: identitymanager.cpp:234
KPIMIdentities::IdentityManager::thatIsMe
bool thatIsMe(const QString &addressList) const
Definition: identitymanager.cpp:394
KPIMIdentities::IdentityManager::added
void added(const KPIMIdentities::Identity &ident)
Emitted on commit() for each new identity.
KPIMIdentities::IdentityManager::mIdentities
QList< Identity > mIdentities
The list that will be seen by everyone.
Definition: identitymanager.h:224
KPIMIdentities::Identity::matchesEmailAddress
bool matchesEmailAddress(const QString &addr) const
Definition: identity.cpp:654
KPIMIdentities::Identity
User identity information.
Definition: identity.h:83
KPIMIdentities::IdentityManager::commit
void commit()
Commit changes to disk and emit changed() if necessary.
Definition: identitymanager.cpp:160
KPIMIdentities::IdentityManager::shadowIdentities
QStringList shadowIdentities() const
Convenience method.
Definition: identitymanager.cpp:245
KPIMIdentities::IdentityManager::identityForAddress
const Identity & identityForAddress(const QString &addresses) const
Definition: identitymanager.cpp:378
KPIMIdentities::Identity::isNull
bool isNull() const
Returns true when the identity contains no values, all null values or only empty values.
Definition: identity.cpp:65
KPIMIdentities::IdentityManager::setAsDefault
bool setAsDefault(uint uoid)
Sets the identity with Unique Object Identifier (UOID) uoid to be new the default identity...
Definition: identitymanager.cpp:443
KPIMIdentities::Identity::setUoid
void setUoid(uint aUoid)
set the uiod
Definition: identity.cpp:510
KPIMIdentities::IdentityManager::modifyIdentityForName
Identity & modifyIdentityForName(const QString &identityName)
Definition: identitymanager.cpp:399
KPIMIdentities::IdentityManager::sort
void sort()
Sort the identities by name (the default is always first).
Definition: identitymanager.cpp:256
KPIMIdentities::IdentityManager::hasPendingChanges
bool hasPendingChanges() const
Check whether there are any unsaved changes.
Definition: identitymanager.cpp:229
KPIMIdentities::Identity::readConfig
void readConfig(const KConfigGroup &)
Read configuration from config.
Definition: identity.cpp:97
KPIMIdentities::IdentityManager::identityForUoid
const Identity & identityForUoid(uint uoid) const
Definition: identitymanager.cpp:358
KPIMIdentities::IdentityManager::mShadowIdentities
QList< Identity > mShadowIdentities
The list that will be seen by the config dialog.
Definition: identitymanager.h:226
KPIMIdentities::IdentityManager::defaultIdentity
const Identity & defaultIdentity() const
Definition: identitymanager.cpp:427
KPIMIdentities::IdentityManager::modifyBegin
Iterator modifyBegin()
Iterator used by the configuration dialog, which works on a separate list of identities, for modification.
Definition: identitymanager.cpp:348
KPIMIdentities::IdentityManager::allEmails
QStringList allEmails() const
Returns the list of all email addresses (only name) from all identities.
Definition: identitymanager.cpp:637
KPIMIdentities::IdentityManager::removeIdentity
bool removeIdentity(const QString &identityName)
Removes the identity with name identityName Will return false if the identity is not found...
Definition: identitymanager.cpp:469
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Tue Sep 29 2015 19:28:33 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kpimidentities

Skip menu "kpimidentities"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal