Exemple #1
0
/*  Reading entire mailbox is very slow on a large mailbox  */
bool Search::matchesBody(const QMailMessage& mail) const
{
    if ( body.isEmpty() )
        return true;

    return match(body, mail.body().data());
}
Exemple #2
0
void EmailComposerInterface::setMessage( const QMailMessage &mail )
{
    if (mail.multipartType() == QMailMessagePartContainer::MultipartNone) {
        if (mail.hasBody())
            setText( mail.body().data(), mail.contentType().content() );
    } else {
        // The only type of multipart message we currently compose is Mixed, with
        // all but the first part as out-of-line attachments
        int textPart = -1;
        for ( uint i = 0; i < mail.partCount(); ++i ) {
            QMailMessagePart &part = const_cast<QMailMessagePart&>(mail.partAt(i));
            
            if (textPart == -1 && part.contentType().type().toLower() == "text") {
                // This is the first text part, we will use as the forwarded text body
                textPart = i;
            } else {
                QString attPath = part.attachmentPath();
                QMailMessage::AttachmentsAction action = QMailMessage::LinkToAttachments;

                // Detach the part data to a temporary file if necessary
                if (attPath.isEmpty()) {
                    if (part.detachAttachment(Qtopia::tempDir())) {
                        attPath = part.attachmentPath();
                        action = QMailMessage::CopyAttachments;

                        // Create a content object for the file
                        QContent doc(attPath);

                        if (part.hasBody()) {
                            QMailMessageContentType type(part.contentType());

                            if (doc.drmState() == QContent::Unprotected)
                                doc.setType(type.content());
                        }

                        doc.setName(part.displayName());
                        doc.setRole(QContent::Data);

                        doc.commit();

                        // This needs to be removed after composition
                        m_temporaries.append(doc);
                    }
                }

                if (!attPath.isEmpty())
                    attach(attPath, action);
            }
        }

        if (textPart != -1) {
            const QMailMessagePart& part = mail.partAt(textPart);
            setText( part.body().data(), part.contentType().content() );
        }
    }
}
Exemple #3
0
bool SmsClient::addMail(const QMailMessage& mail)
{
    QList<QMailAddress> smsRecipients = separateSmsAddresses(mail.recipients());
    Q_ASSERT(smsRecipients.count() > 0);

    QString smsBody = formatOutgoing(mail.subject(),mail.body().data());

    foreach (const QMailAddress& recipient, smsRecipients)
    {
        if(smsAddress(recipient))
        {
            if(!validSmsAddress(recipient))
            {
                QString temp = "<qt>" + tr("Invalid SMS recipient specified for\n "
                   "mail with subject:\n%1\n"
                   "NO mail has been sent.")
                .arg( mail.subject() ) + "</qt>";

                emit errorOccurred(0,temp);
                return false;
            }
            else
            {
                //address is valid, queue for sending

                // Extract the phone number from the e-mail address.
                RawSms msg;
                msg.msgId = mail.id();
                msg.number = QPhoneNumber::resolveLetters( recipient.address() );
                msg.body = smsBody;
                if (mail.contentType().content().toLower() == "text/x-vcard")
                    msg.mimetype = QLatin1String("text/x-vCard");
                else
                    msg.mimetype = QLatin1String("text/plain");
                smsList.append( msg );
            }
        }
    }

    return true;
}