kmail

kmgroupware.cpp
1 /*
2  kmgroupware.cpp
3 
4  This file is part of KMail.
5 
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>
9 
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.
14 
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.
19 
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.
24 
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 TQt library by Trolltech AS, Norway (or with modified versions
28  of TQt that use the same license as TQt), 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  TQt. 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.
35 */
36 
37 #include "kmgroupware.h"
38 #include "kmmessage.h"
39 #include "kmmsgpart.h"
40 #include "libkcal/incidenceformatter.h"
41 #include <kdebug.h>
42 #include <mimelib/enum.h>
43 #include <assert.h>
44 
45 
46 bool vPartFoundAndDecoded( KMMessage* msg, TQString& s )
47 {
48  assert( msg );
49 
50  if( ( DwMime::kTypeText == msg->type() && ( DwMime::kSubtypeVCal == msg->subtype() ||
51  DwMime::kSubtypeXVCard == msg->subtype() ) ) ||
52  ( DwMime::kTypeApplication == msg->type() &&
53  DwMime::kSubtypeOctetStream == msg->subtype() ) )
54  {
55  s = TQString::fromUtf8( msg->bodyDecoded() );
56  return true;
57  } else if( DwMime::kTypeMultipart == msg->type() &&
58  ( (DwMime::kSubtypeMixed == msg->subtype() ) ||
59  (DwMime::kSubtypeAlternative == msg->subtype() ) ))
60  {
61  // kdDebug(5006) << "KMGroupware looking for TNEF data" << endl;
62  DwBodyPart* dwPart = msg->findDwBodyPart( DwMime::kTypeApplication,
63  DwMime::kSubtypeMsTNEF );
64  if( !dwPart )
65  dwPart = msg->findDwBodyPart( DwMime::kTypeApplication,
66  DwMime::kSubtypeOctetStream );
67  if( dwPart ){
68  // kdDebug(5006) << "KMGroupware analyzing TNEF data" << endl;
69  KMMessagePart msgPart;
70  KMMessage::bodyPart(dwPart, &msgPart);
71  s = KCal::IncidenceFormatter::msTNEFToVPart( msgPart.bodyDecodedBinary() );
72  return !s.isEmpty();
73  } else {
74  dwPart = msg->findDwBodyPart( DwMime::kTypeText, DwMime::kSubtypeVCal );
75  if (dwPart) {
76  KMMessagePart msgPart;
77  KMMessage::bodyPart(dwPart, &msgPart);
78  s = msgPart.body();
79  return true;
80  }
81  }
82  }else if( DwMime::kTypeMultipart == msg->type() &&
83  DwMime::kSubtypeMixed == msg->subtype() ) {
84  // TODO: Something?
85  }
86 
87  return false;
88 }
This is a Mime Message.
Definition: kmmessage.h:68
TQCString bodyDecoded() const
Returns a decoded version of the body from the current content transfer encoding.
Definition: kmmessage.cpp:2608
static void bodyPart(DwBodyPart *aDwBodyPart, KMMessagePart *aPart, bool withBody=true)
Fill the KMMessagePart structure for a given DwBodyPart.
Definition: kmmessage.cpp:3108
DwBodyPart * findDwBodyPart(int type, int subtype) const
Return the first DwBodyPart matching a given Content-Type or zero, if no found.
Definition: kmmessage.cpp:2935