summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport/kde2_xxport.cpp
Unidiff
Diffstat (limited to 'kaddressbook/xxport/kde2_xxport.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/kde2_xxport.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/kaddressbook/xxport/kde2_xxport.cpp b/kaddressbook/xxport/kde2_xxport.cpp
new file mode 100644
index 0000000..d5fc075
--- a/dev/null
+++ b/kaddressbook/xxport/kde2_xxport.cpp
@@ -0,0 +1,116 @@
1/*
2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk
27
28$Id$
29*/
30
31#include <qfile.h>
32
33#include <kdebug.h>
34#include <kfiledialog.h>
35#ifndef KAB_EMBEDDED
36#include <kio/netaccess.h>
37#endif //KAB_EMBEDDED
38#include <klocale.h>
39#include <kmessagebox.h>
40#include <kprocess.h>
41#include <kstandarddirs.h>
42#include <ktempfile.h>
43#include <kurl.h>
44
45#include "xxportmanager.h"
46
47#include "kde2_xxport.h"
48
49#ifndef KAB_EMBEDDED
50
51class KDE2XXPortFactory : public XXPortFactory
52{
53 public:
54 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
55 {
56 return new KDE2XXPort( ab, parent, name );
57 }
58};
59
60
61extern "C"
62{
63 void *init_libkaddrbk_kde2_xxport()
64 {
65 return ( new KDE2XXPortFactory() );
66 }
67}
68#endif //KAB_EMBEDDED
69
70
71KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
72 : XXPortObject( ab, parent, name )
73{
74 createImportAction( i18n( "Import KDE 2 Addressbook..." ) );
75}
76
77KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const
78{
79 QString fileName = locateLocal( "data", "kabc/std.vcf" );
80 if ( !QFile::exists( fileName ) ) {
81 KMessageBox::sorry( parentWidget(), i18n( "<qt>Couldn't find a KDE 2 address book <b>%1</b>.</qt>" ).arg( fileName ) );
82 return KABC::AddresseeList();
83 }
84
85#ifndef KAB_EMBEDDED
86 int result = KMessageBox::questionYesNoCancel( parentWidget(),
87 i18n( "Override previously imported entries?" ),
88 i18n( "Import KDE 2 Addressbook" ) );
89#else //KAB_EMBEDDED
90 int result = KMessageBox::warningYesNoCancel( parentWidget(),
91 i18n( "Override previously imported entries?" ),
92 i18n( "Import KDE 2 Addressbook" ) );
93#endif //KAB_EMBEDDED
94
95 if ( !result ) return KABC::AddresseeList();
96
97 KProcess proc;
98
99 if ( result == KMessageBox::Yes ) {
100 proc << "kab2kabc";
101 proc << "--override";
102 } else if ( result == KMessageBox::No )
103 proc << "kab2kabc";
104 else
105 kdDebug(5720) << "KAddressBook::importKDE2(): Unknow return value." << endl;
106
107 proc.start( KProcess::Block );
108
109 addressBook()->load();
110
111 return KABC::AddresseeList();
112}
113
114#ifndef KAB_EMBEDDED
115#include "kde2_xxport.moc"
116#endif //KAB_EMBEDDED