kcmshell renamed to kcmshell4 to fix co-installability between kdelibs3 and kdebase4...
[kdepim.git] / kmail / kmgroupware.cpp
blob64d6726382821bda9341ea315a7a9aa2a64cd5b4
1 /*
2 kmgroupware.cpp
4 This file is part of KMail.
6 Copyright (c) 2003 - 2004 Bo Thorsen <bo@sonofthor.dk>
7 Copyright (c) 2002 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se>
8 Copyright (c) 2003 Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
25 In addition, as a special exception, the copyright holders give
26 permission to link the code of this program with any edition of
27 the Qt library by Trolltech AS, Norway (or with modified versions
28 of Qt that use the same license as Qt), and distribute linked
29 combinations including the two. You must obey the GNU General
30 Public License in all respects for all of the code used other than
31 Qt. If you modify this file, you may extend this exception to
32 your version of the file, but you are not obligated to do so. If
33 you do not wish to do so, delete this exception statement from
34 your version.
38 #include "kmgroupware.h"
39 #include "kmmessage.h"
40 #include "kmmsgpart.h"
41 #include <kcal/incidenceformatter.h>
42 #include <ktnef/formatter.h>
43 #include <kdebug.h>
44 #include <mimelib/enum.h>
45 #include <assert.h>
48 bool vPartFoundAndDecoded( KMMessage* msg, QString& s )
50 assert( msg );
52 if( ( DwMime::kTypeText == msg->type() && ( DwMime::kSubtypeVCal == msg->subtype() ||
53 DwMime::kSubtypeXVCard == msg->subtype() ) ) ||
54 ( DwMime::kTypeApplication == msg->type() &&
55 DwMime::kSubtypeOctetStream == msg->subtype() ) )
57 s = QString::fromUtf8( msg->bodyDecoded() );
58 return true;
59 } else if( DwMime::kTypeMultipart == msg->type() &&
60 (DwMime::kSubtypeMixed == msg->subtype() ) ||
61 (DwMime::kSubtypeAlternative == msg->subtype() ))
63 // kDebug(5006) <<"KMGroupware looking for TNEF data";
64 DwBodyPart* dwPart = msg->findDwBodyPart( DwMime::kTypeApplication,
65 DwMime::kSubtypeMsTNEF );
66 if( !dwPart )
67 dwPart = msg->findDwBodyPart( DwMime::kTypeApplication,
68 DwMime::kSubtypeOctetStream );
69 if( dwPart ){
70 // kDebug(5006) <<"KMGroupware analyzing TNEF data";
71 KMMessagePart msgPart;
72 KMMessage::bodyPart(dwPart, &msgPart);
73 s = KTnef::msTNEFToVPart( msgPart.bodyDecodedBinary() );
74 return !s.isEmpty();
75 } else {
76 dwPart = msg->findDwBodyPart( DwMime::kTypeText, DwMime::kSubtypeVCal );
77 if (dwPart) {
78 KMMessagePart msgPart;
79 KMMessage::bodyPart(dwPart, &msgPart);
80 s = msgPart.body();
81 return true;
84 }else if( DwMime::kTypeMultipart == msg->type() &&
85 DwMime::kSubtypeMixed == msg->subtype() ) {
86 // TODO: Something?
89 return false;