libkcal

attachment.cpp

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     return mData.utf8().data();
00081   else
00082     return 0;
00083 }
00084 
00085 void Attachment::setData(const char *base64)
00086 {
00087   mData = QString::fromUtf8(base64);
00088   mBinary = true;
00089 }
00090 
00091 QString Attachment::mimeType() const
00092 {
00093   return mMimeType;
00094 }
00095 
00096 void Attachment::setMimeType(const QString& mime)
00097 {
00098   mMimeType = mime;
00099 }
00100 
00101 bool Attachment::showInline() const
00102 {
00103   return mShowInline;
00104 }
00105 
00106 void Attachment::setShowInline( bool showinline )
00107 {
00108   mShowInline = showinline;
00109 }
00110 
00111 QString Attachment::label() const
00112 {
00113   return mLabel;
00114 }
00115 
00116 void Attachment::setLabel( const QString& label )
00117 {
00118   mLabel = label;
00119 }
00120 
KDE Home | KDE Accessibility Home | Description of Access Keys