Example #1
0
void Incidence::loadAttachments()
{
    QStringList attachments;
    if(mResource->kmailListAttachments(attachments, mSubResource, mSernum))
    {
        for(QStringList::ConstIterator it = attachments.constBegin(); it != attachments.constEnd(); ++it)
        {
            QByteArray data;
            KURL url;
            if(mResource->kmailGetAttachment(url, mSubResource, mSernum, *it) && !url.isEmpty())
            {
                QFile f(url.path());
                if(f.open(IO_ReadOnly))
                {
                    data = f.readAll();
                    QString mimeType;
                    if(!mResource->kmailAttachmentMimetype(mimeType, mSubResource, mSernum, *it))
                        mimeType = "application/octet-stream";
                    KCal::Attachment *a = new KCal::Attachment(KCodecs::base64Encode(data).data(), mimeType);
                    a->setLabel(*it);
                    mAttachments.append(a);
                    f.close();
                }
                f.remove();
            }
        }
    }
}
void KOEditorAttachments::showAttachment( Q3IconViewItem *item )
{
  AttachmentIconItem *attitem = static_cast<AttachmentIconItem*>( item );
  if ( !attitem || !attitem->attachment() ) {
    return;
  }

  KCal::Attachment *att = attitem->attachment();
  if ( att->isUri() ) {
    emit openURL( att->uri() );
  } else {
    KRun::runUrl( mAttachments->tempFileForAttachment( att ), att->mimeType(), 0, true );
  }
}
Example #3
0
void Incidence::saveAttachments(QDomElement &element) const
{
    KCal::Attachment::List::ConstIterator it = mAttachments.begin();
    for(; it != mAttachments.end(); ++it)
    {
        KCal::Attachment *a = (*it);
        if(a->isUri())
        {
            writeString(element, "link-attachment", a->uri());
        }
        else if(a->isBinary())
        {
            writeString(element, "inline-attachment", a->label());
        }
    }
}