libkcal
attachment.cpp
Go to the documentation of this file.00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2002 Michael Brade <brade@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include "attachment.h" 00023 00024 using namespace KCal; 00025 00026 Attachment::Attachment( const Attachment &attachment) 00027 { 00028 mMimeType = attachment.mMimeType; 00029 mData = attachment.mData; 00030 mBinary = attachment.mBinary; 00031 mShowInline = attachment.mShowInline; 00032 mLabel = attachment.mLabel; 00033 } 00034 00035 Attachment::Attachment(const QString& uri, const QString& mime) 00036 { 00037 mMimeType = mime; 00038 mData = uri; 00039 mBinary = false; 00040 mShowInline = false; 00041 mLabel = QString::null; 00042 } 00043 00044 Attachment::Attachment(const char *base64, const QString& mime) 00045 { 00046 mMimeType = mime; 00047 mData = QString::fromUtf8(base64); 00048 mBinary = true; 00049 mShowInline = false; 00050 mLabel = QString::null; 00051 } 00052 00053 bool Attachment::isUri() const 00054 { 00055 return !mBinary; 00056 } 00057 00058 QString Attachment::uri() const 00059 { 00060 if (!mBinary) 00061 return mData; 00062 else 00063 return QString::null; 00064 } 00065 00066 void Attachment::setUri(const QString& uri) 00067 { 00068 mData = uri; 00069 mBinary = false; 00070 } 00071 00072 bool Attachment::isBinary() const 00073 { 00074 return mBinary; 00075 } 00076 00077 char *Attachment::data() const 00078 { 00079 if (mBinary) 00080 // this method actually return a const char*, but that can't be done because of the uneededly non-const libical API 00081 return const_cast<char*>( mData.latin1() ); //mData.utf8().data(); 00082 else 00083 return 0; 00084 } 00085 00086 void Attachment::setData(const char *base64) 00087 { 00088 mData = QString::fromUtf8(base64); 00089 mBinary = true; 00090 } 00091 00092 QString Attachment::mimeType() const 00093 { 00094 return mMimeType; 00095 } 00096 00097 void Attachment::setMimeType(const QString& mime) 00098 { 00099 mMimeType = mime; 00100 } 00101 00102 bool Attachment::showInline() const 00103 { 00104 return mShowInline; 00105 } 00106 00107 void Attachment::setShowInline( bool showinline ) 00108 { 00109 mShowInline = showinline; 00110 } 00111 00112 QString Attachment::label() const 00113 { 00114 return mLabel; 00115 } 00116 00117 void Attachment::setLabel( const QString& label ) 00118 { 00119 mLabel = label; 00120 } 00121