kaddressbook Library API Documentation

kde2_xxport.cpp

00001 /* 00002 This file is part of KAddressbook. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 #include <qfile.h> 00025 00026 #include <kdebug.h> 00027 #include <kfiledialog.h> 00028 #include <kio/netaccess.h> 00029 #include <klocale.h> 00030 #include <kmessagebox.h> 00031 #include <kprocess.h> 00032 #include <kstandarddirs.h> 00033 #include <ktempfile.h> 00034 #include <kurl.h> 00035 00036 #include "xxportmanager.h" 00037 00038 #include "kde2_xxport.h" 00039 00040 class KDE2XXPortFactory : public KAB::XXPortFactory 00041 { 00042 public: 00043 KAB::XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 00044 { 00045 return new KDE2XXPort( ab, parent, name ); 00046 } 00047 }; 00048 00049 extern "C" 00050 { 00051 void *init_libkaddrbk_kde2_xxport() 00052 { 00053 return ( new KDE2XXPortFactory() ); 00054 } 00055 } 00056 00057 00058 KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 00059 : KAB::XXPort( ab, parent, name ) 00060 { 00061 createImportAction( i18n( "Import KDE 2 Addressbook..." ) ); 00062 } 00063 00064 KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const 00065 { 00066 QString fileName = locateLocal( "data", "kabc/std.vcf" ); 00067 if ( !QFile::exists( fileName ) ) { 00068 KMessageBox::sorry( parentWidget(), i18n( "<qt>Could not find a KDE 2 address book <b>%1</b>.</qt>" ).arg( fileName ) ); 00069 return KABC::AddresseeList(); 00070 } 00071 00072 int result = KMessageBox::questionYesNoCancel( parentWidget(), 00073 i18n( "Override previously imported entries?" ), 00074 i18n( "Import KDE 2 Addressbook" ) ); 00075 00076 if ( !result ) return KABC::AddresseeList(); 00077 00078 KProcess proc; 00079 00080 if ( result == KMessageBox::Yes ) { 00081 proc << "kab2kabc"; 00082 proc << "--override"; 00083 } else if ( result == KMessageBox::No ) 00084 proc << "kab2kabc"; 00085 else 00086 kdDebug(5720) << "KAddressBook::importKDE2(): Unknow return value." << endl; 00087 00088 proc.start( KProcess::Block ); 00089 00090 addressBook()->load(); 00091 00092 return KABC::AddresseeList(); 00093 } 00094 00095 #include "kde2_xxport.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:51:14 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003