kmgroupware.cpp
00001 /* 00002 kmgroupware.cpp 00003 00004 This file is part of KMail. 00005 00006 Copyright (c) 2003 - 2004 Bo Thorsen <bo@sonofthor.dk> 00007 Copyright (c) 2002 Karl-Heinz Zimmer <khz@klaralvdalens-datakonsult.se> 00008 Copyright (c) 2003 Steffen Hansen <steffen@klaralvdalens-datakonsult.se> 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Library General Public 00012 License as published by the Free Software Foundation; either 00013 version 2 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public License 00021 along with this library; see the file COPYING.LIB. If not, write to 00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 Boston, MA 02110-1301, USA. 00024 00025 In addition, as a special exception, the copyright holders give 00026 permission to link the code of this program with any edition of 00027 the TQt library by Trolltech AS, Norway (or with modified versions 00028 of TQt that use the same license as TQt), and distribute linked 00029 combinations including the two. You must obey the GNU General 00030 Public License in all respects for all of the code used other than 00031 TQt. If you modify this file, you may extend this exception to 00032 your version of the file, but you are not obligated to do so. If 00033 you do not wish to do so, delete this exception statement from 00034 your version. 00035 */ 00036 00037 #include "kmgroupware.h" 00038 #include "kmmessage.h" 00039 #include "kmmsgpart.h" 00040 #include "libkcal/incidenceformatter.h" 00041 #include <kdebug.h> 00042 #include <mimelib/enum.h> 00043 #include <assert.h> 00044 00045 00046 bool vPartFoundAndDecoded( KMMessage* msg, TQString& s ) 00047 { 00048 assert( msg ); 00049 00050 if( ( DwMime::kTypeText == msg->type() && ( DwMime::kSubtypeVCal == msg->subtype() || 00051 DwMime::kSubtypeXVCard == msg->subtype() ) ) || 00052 ( DwMime::kTypeApplication == msg->type() && 00053 DwMime::kSubtypeOctetStream == msg->subtype() ) ) 00054 { 00055 s = TQString::fromUtf8( msg->bodyDecoded() ); 00056 return true; 00057 } else if( DwMime::kTypeMultipart == msg->type() && 00058 ( (DwMime::kSubtypeMixed == msg->subtype() ) || 00059 (DwMime::kSubtypeAlternative == msg->subtype() ) )) 00060 { 00061 // kdDebug(5006) << "KMGroupware looking for TNEF data" << endl; 00062 DwBodyPart* dwPart = msg->findDwBodyPart( DwMime::kTypeApplication, 00063 DwMime::kSubtypeMsTNEF ); 00064 if( !dwPart ) 00065 dwPart = msg->findDwBodyPart( DwMime::kTypeApplication, 00066 DwMime::kSubtypeOctetStream ); 00067 if( dwPart ){ 00068 // kdDebug(5006) << "KMGroupware analyzing TNEF data" << endl; 00069 KMMessagePart msgPart; 00070 KMMessage::bodyPart(dwPart, &msgPart); 00071 s = KCal::IncidenceFormatter::msTNEFToVPart( msgPart.bodyDecodedBinary() ); 00072 return !s.isEmpty(); 00073 } else { 00074 dwPart = msg->findDwBodyPart( DwMime::kTypeText, DwMime::kSubtypeVCal ); 00075 if (dwPart) { 00076 KMMessagePart msgPart; 00077 KMMessage::bodyPart(dwPart, &msgPart); 00078 s = msgPart.body(); 00079 return true; 00080 } 00081 } 00082 }else if( DwMime::kTypeMultipart == msg->type() && 00083 DwMime::kSubtypeMixed == msg->subtype() ) { 00084 // TODO: Something? 00085 } 00086 00087 return false; 00088 }