4
* This file is part of KMail, the KDE mail client.
5
* Copyright (c) 2004 Marc Mutz <mutz@kde.org>
6
* Copyright (c) 2011 Torgny Nyblom <nyblom@kde.org>
8
* KMail is free software; you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License, version 2, as
10
* published by the Free Software Foundation.
12
* KMail is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* 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
* In addition, as a special exception, the copyright holders give
22
* permission to link the code of this program with any edition of
23
* the Qt library by Trolltech AS, Norway (or with modified versions
24
* of Qt that use the same license as Qt), and distribute linked
25
* combinations including the two. You must obey the GNU General
26
* Public License in all respects for all of the code used other than
27
* Qt. If you modify this file, you may extend this exception to
28
* your version of the file, but you are not obligated to do so. If
29
* you do not wish to do so, delete this exception statement from
34
#include "imagecollector.h"
36
#include "nodehelper.h"
39
#include <kmime/kmime_content.h>
41
static bool isInSkipList( KMime::Content* )
46
static bool isInExclusionList( KMime::Content * node )
51
if ( node->contentType()->mediaType() != "image" ) {
55
if ( node->contentType()->isMultipart()) {
62
class MessageCore::ImageCollector::Private
65
std::vector<KMime::Content*> mImages;
68
MessageCore::ImageCollector::ImageCollector()
73
MessageCore::ImageCollector::~ImageCollector()
78
void MessageCore::ImageCollector::collectImagesFrom( KMime::Content *node )
80
KMime::Content *parent;
83
parent = node->parent();
85
if ( node->topLevel()->textContent() == node ) {
86
node = MessageCore::NodeHelper::next( node );
90
if ( isInSkipList( node ) ) {
91
node = MessageCore::NodeHelper::next( node, false ); // skip even the children
95
if ( isInExclusionList( node ) ) {
96
node = MessageCore::NodeHelper::next( node );
100
if ( parent && parent->contentType()->isMultipart() &&
101
parent->contentType()->subType() == "related" ) {
102
kWarning() << "Adding image" << node->contentID();
103
d->mImages.push_back( node );
104
node = MessageCore::NodeHelper::next( node ); // skip embedded images
108
node = MessageCore::NodeHelper::next( node );
112
const std::vector<KMime::Content*>& MessageCore::ImageCollector::images() const