1/*
2 ktnefparser.h
3
4 Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
5
6 This file is part of KTNEF, the KDE TNEF support library/program.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22 */
23/**
24 * @file
25 * This file is part of the API for handling TNEF data and
26 * defines the KTNEFParser class.
27 *
28 * @author Michael Goffioul
29 */
30
31#ifndef KTNEFPARSER_H
32#define KTNEFPARSER_H
33
34#include <QtCore/QString>
35#include <QtCore/QMap>
36#include <QtCore/QIODevice>
37#include "ktnef_export.h"
38
39namespace KTnef {
40 class KTNEFAttach;
41 class KTNEFMessage;
42 class KTNEFProperty;
43}
44
45namespace KTnef {
46
47/**
48 * @brief
49 * Provides an @acronym TNEF parser.
50 */
51class KTNEF_EXPORT KTNEFParser
52{
53 public:
54 /**
55 Constructs a @acronym TNEF parser object.
56 */
57 KTNEFParser();
58
59 /**
60 Destroys the @acronym TNEF parser object.
61 */
62 ~KTNEFParser();
63
64 /**
65 Opens the @p filename for parsing.
66
67 @param filename is the name of the file to open.
68 @return true if the open succeeded; otherwise false.
69 */
70 bool openFile( const QString &filename ) const;
71
72 /**
73 Opens the #QIODevice @p device for parsing.
74
75 @param device is the #QIODevice to open.
76 @return true if the open succeeded; otherwise false.
77 */
78 bool openDevice( QIODevice *device );
79
80 /**
81 Extracts a @acronym TNEF attachment having filename @p filename
82 into the default directory.
83
84 @param filename is the name of the file to extract the attachment into.
85 @return true if the extraction succeeds; otherwise false.
86 */
87 bool extractFile( const QString &filename ) const;
88
89 /**
90 Extracts a @acronym TNEF attachment having filename @p filename
91 into the directory @p dirname.
92
93 @param filename is the name of the file to extract the attachment into.
94 @param dirname is the name of the directory where the @p filename
95 should be written.
96
97 @return true if the extraction succeeds; otherwise false.
98 */
99 bool extractFileTo( const QString &filename, const QString &dirname ) const;
100
101 /**
102 Extracts all @acronym TNEF attachments into the default directory.
103
104 @return true if the extraction succeeds; otherwise false.
105 */
106 bool extractAll();
107
108 /**
109 Sets the default extraction directory to @p dirname.
110
111 @param dirname is the name of the default extraction directory.
112 */
113 void setDefaultExtractDir( const QString &dirname );
114
115 /**
116 Returns the KTNEFMessage used in the parsing process.
117
118 @return a pointer to a KTNEFMessage object.
119 */
120 KTNEFMessage *message() const;
121
122 private:
123 //@cond PRIVATE
124 class ParserPrivate;
125 ParserPrivate *const d;
126 //@endcond
127
128 Q_DISABLE_COPY( KTNEFParser )
129};
130
131}
132#endif
133