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

kpimidentities

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

kdepimlibs API Reference

Skip menu "kdepimlibs 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

Search



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