2
This file is part of KContactManager.
3
Copyright (c) 2000 - 2009 Oliver Strutynski <olistrut@gmx.de>
4
Tobias Koenig <tokoe@kde.org>
5
Sebastian Sauer <sebsauer@kdab.net>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
As a special exception, permission is given to link this program
22
with any edition of Qt, and distribute the resulting executable,
23
without including the source code for Qt in the source distribution.
26
#include "ldap_xxport.h"
27
#include "ldapsearchdialog.h"
29
//#include <QtCore/QFile>
30
//#include <QtCore/QTextStream>
32
//#include <kabc/ldifconverter.h>
33
//#include <kcodecs.h>
34
//#include <kfiledialog.h>
35
//#include <kio/netaccess.h>
36
//#include <klocale.h>
37
//#include <kmessagebox.h>
38
//#include <ktemporaryfile.h>
42
LDAPXXPort::LDAPXXPort( QWidget *parentWidget )
43
: XXPort( parentWidget )
47
KABC::Addressee::List LDAPXXPort::importContacts() const
49
KABC::Addressee::List contacts;
51
KABC::AddressBook *ab = 0;
53
LDAPSearchDialog dlg(ab, core, parentWidget());
55
contacts = dlg.m_result;
58
const QString fileName = KFileDialog::getOpenFileName( QDir::homePath(), "text/x-ldif", 0 );
59
if ( fileName.isEmpty() )
62
QFile file( fileName );
63
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
64
const QString msg = i18n( "<qt>Unable to open <b>%1</b> for reading.</qt>", fileName );
65
KMessageBox::error( parentWidget(), msg );
69
QTextStream stream( &file );
70
stream.setCodec( "ISO 8859-1" );
72
const QString wholeFile = stream.readAll();
73
const QDateTime dtDefault = QFileInfo( file ).lastModified();
76
KABC::LDAPConverter::LDAPToAddressee( wholeFile, contacts, dtDefault );
81
bool LDAPXXPort::exportContacts( const KABC::Addressee::List &contacts ) const