1/*
2 This file is part of libkabc.
3 Copyright (c) 2003 Helge Deller <deller@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 only as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KABC_LDIFCONVERTER_H
21#define KABC_LDIFCONVERTER_H
22
23#include "addressee.h"
24#include "addresseelist.h"
25
26#include <QtCore/QDateTime>
27#include <QtCore/QString>
28
29namespace KABC {
30
31 /**
32 A set of functions to convert a string with LDIF information to addressees
33 and vice versa. It is useful for addressbook import- and exportfilters
34 and might be used to read and write Mozilla and Netscape addresssbooks.
35 */
36
37 namespace LDIFConverter {
38
39 /**
40 Converts a LDIF string to a list of addressees.
41
42 @param str The vcard string.
43 @param addrList The addresseelist.
44 @param dt The date & time value of the last modification (e.g. file modification time).
45 */
46 KABC_EXPORT bool LDIFToAddressee( const QString &str, AddresseeList &addrList,
47 const QDateTime &dt = QDateTime::currentDateTime() );
48
49 /**
50 Converts a list of addressees to a LDIF string.
51
52 @param addrList The addresseelist.
53 @param str The LDIF string.
54 */
55 KABC_EXPORT bool addresseeToLDIF( const AddresseeList &addrList, QString &str );
56
57 /**
58 Converts an addressee to a LDIF string.
59
60 @param addr The addressee.
61 @param str The LDIF string.
62 */
63 KABC_EXPORT bool addresseeToLDIF( const Addressee &addr, QString &str );
64
65 /* internal functions - do not use !! */
66
67 /**
68 @internal
69
70 Evaluates @p fieldname and sets the @p value at the addressee or the address
71 objects when appropriate.
72
73 @param a The addressee to store information into
74 @param homeAddr The home address to store respective information into
75 @param workAddr The work address to store respective information into
76 @param fieldname LDIF field name to evaluate
77 @param value The value of the field addressed by @p fieldname
78 */
79 KABC_EXPORT bool evaluatePair( Addressee &a, Address &homeAddr,
80 Address &workAddr,
81 QString &fieldname, QString &value,
82 int &birthday, int &birthmonth, int &birthyear );
83
84 }
85
86}
87#endif
88
89