kaddressbook

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 K_EXPORT_KADDRESSBOOK_XXFILTER( libkaddrbk_kde2_xxport, KDE2XXPort )
00041 
00042 KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
00043   : KAB::XXPort( ab, parent, name )
00044 {
00045   createImportAction( i18n( "Import KDE 2 Addressbook..." ) );
00046 }
00047 
00048 KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const
00049 {
00050   QString fileName = locateLocal( "data", "kabc/std.vcf" );
00051   if ( !QFile::exists( fileName ) ) {
00052     KMessageBox::sorry( parentWidget(), i18n( "<qt>Could not find a KDE 2 address book <b>%1</b>.</qt>" ).arg( fileName ) );
00053     return KABC::AddresseeList();
00054   }
00055 
00056   int result = KMessageBox::questionYesNoCancel( parentWidget(),
00057       i18n( "Override previously imported entries?" ),
00058       i18n( "Import KDE 2 Addressbook" ), i18n("Import"), i18n("Do Not Import") );
00059 
00060   if ( !result ) return KABC::AddresseeList();
00061 
00062   KProcess proc;
00063 
00064   if ( result == KMessageBox::Yes ) {
00065     proc << "kab2kabc";
00066     proc << "--override";
00067   } else if ( result == KMessageBox::No )
00068     proc << "kab2kabc";
00069   else
00070     kdDebug(5720) << "KAddressBook::importKDE2(): Unknow return value." << endl;
00071 
00072   proc.start( KProcess::Block );
00073 
00074   addressBook()->load();
00075 
00076   return KABC::AddresseeList();
00077 }
00078 
00079 #include "kde2_xxport.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys