kmail Library API Documentation

kmaddrbook.cpp

00001 // -*- mode: C++; c-file-style: "gnu" -*-
00002 // kmaddrbook.cpp
00003 // Author: Stefan Taferner <taferner@kde.org>
00004 // This code is under GPL
00005 
00006 #include <config.h>
00007 #include <unistd.h>
00008 
00009 #include "kmaddrbook.h"
00010 #include "kcursorsaver.h"
00011 #include "kmmessage.h"
00012 #include "kmkernel.h" // for KabcBridge
00013 
00014 #include <kapplication.h>
00015 #include <kdebug.h>
00016 #include <klocale.h>
00017 #include <kmessagebox.h>
00018 #include <kabc/stdaddressbook.h>
00019 #include <kabc/distributionlist.h>
00020 #include <kabc/vcardconverter.h>
00021 #include <dcopref.h>
00022 
00023 #include <qregexp.h>
00024 
00025 //-----------------------------------------------------------------------------
00026 QString KabcBridge::expandNickName( const QString& nickName )
00027 {
00028   if ( nickName.isEmpty() )
00029     return QString::null;
00030 
00031   const QString lowerNickName = nickName.lower();
00032   const KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
00033   for( KABC::AddressBook::ConstIterator it = addressBook->begin();
00034        it != addressBook->end(); ++it ) {
00035     if ( (*it).nickName().lower() == lowerNickName )
00036       return (*it).fullEmail();
00037   }
00038   return QString::null;
00039 }
00040 
00041 
00042 //-----------------------------------------------------------------------------
00043 
00044 QStringList KabcBridge::categories()
00045 {
00046   KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
00047   KABC::Addressee::List addresses = addressBook->allAddressees();
00048   QStringList allcategories, aux;
00049 
00050   for ( KABC::Addressee::List::Iterator it = addresses.begin();
00051         it != addresses.end(); ++it ) {
00052     aux = ( *it ).categories();
00053     for ( QStringList::ConstIterator itAux = aux.begin();
00054           itAux != aux.end(); ++itAux ) {
00055       // don't have duplicates in allcategories
00056       if ( allcategories.find( *itAux ) == allcategories.end() )
00057         allcategories += *itAux;
00058     }
00059   }
00060   return allcategories;
00061 }
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:24:43 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003