void KMail::FolderDialogACLTab::ListViewItem::save( ACLList& aclList,
                                                 KABC::AddressBook* addressBook,
                                                 IMAPUserIdFormat userIdFormat )
{
  // expand distribution lists
  KABC::DistributionList* list = addressBook->findDistributionListByName( userId(),  Qt::CaseInsensitive );
  if ( list ) {
    Q_ASSERT( mModified ); // it has to be new, it couldn't be stored as a distr list name....
    KABC::DistributionList::Entry::List entryList = list->entries();
    KABC::DistributionList::Entry::List::ConstIterator it; // nice number of "::"!
    for( it = entryList.constBegin(); it != entryList.constEnd(); ++it ) {
      QString email = (*it).email();
      if ( email.isEmpty() )
        email = addresseeToUserId( (*it).addressee(), userIdFormat );
      ACLListEntry entry( email, QString(), mPermissions );
      entry.changed = true;
      aclList.append( entry );
    }
  } else { // it wasn't a distribution list
    ACLListEntry entry( userId(), mInternalRightsList, mPermissions );
    if ( mModified ) {
      entry.internalRightsList.clear();
      entry.changed = true;
    }
    aclList.append( entry );
  }
}
Esempio n. 2
0
bool AddresseeEmailSelection::distributionListMatches( const KABC::DistributionList *distributionList,
                                                       const QString &pattern ) const
{
  // check whether the name of the distribution list matches the pattern or one of its entries.
  bool ok = distributionList->name().startsWith( pattern, false );

  KABC::DistributionList::Entry::List entries = distributionList->entries();
  KABC::DistributionList::Entry::List::ConstIterator it;
  for ( it = entries.begin(); it != entries.end(); ++it ) {
    ok = ok || (*it).addressee.formattedName().startsWith( pattern, false ) ||
               (*it).email.startsWith( pattern, false );
  }

  return ok;
}
KABC::Addressee::List
AddressesDialog::allToAddressesNoDuplicates()  const
{
  KABC::Addressee::List aList = allAddressee( d->toItem );
  const QStringList dList = toDistributionLists();
  KABC::AddressBook* abook = KABC::StdAddressBook::self( true );
  for ( QStringList::ConstIterator it = dList.constBegin(); it != dList.constEnd(); ++it ) {
    const KABC::DistributionList *list = abook->findDistributionListByName( *it );
    if ( !list )
      continue;
    const KABC::DistributionList::Entry::List eList = list->entries();
    KABC::DistributionList::Entry::List::ConstIterator eit;
    for( eit = eList.constBegin(); eit != eList.constEnd(); ++eit ) {
      KABC::Addressee a = (*eit).addressee();
      if ( !a.preferredEmail().isEmpty() && !aList.contains( a ) ) {
        aList.append( a ) ;
      }
    }
  }
  return aList;
}
Esempio n. 4
0
void KWMailMergeKABC::parseList( const QString& listName )
{
    if( listName.isEmpty() )
        return;

    kdDebug() << "KWMailMergeKABC::parseList: " << listName << endl;
    KABC::DistributionListManager dlm ( _addressBook );
    dlm.load();

    QStringList::Iterator listIt;

    KABC::DistributionList* list = dlm.list( listName );
    KABC::DistributionList::Entry::List entries = list->entries();

    KABC::DistributionList::Entry::List::Iterator itemIt;
    for ( itemIt = entries.begin(); itemIt != entries.end(); ++itemIt )
    {
        kdDebug() << "WMailMergeKABC::parseList: Listentry UID: " <<
        (*itemIt).addressee.uid() << endl;
        _listUIDs.append( (*itemIt).addressee.uid() );
    }
}