当前位置: 首页>>代码示例>>C++>>正文


C++ QMailMessage::setFromMailbox方法代码示例

本文整理汇总了C++中QMailMessage::setFromMailbox方法的典型用法代码示例。如果您正苦于以下问题:C++ QMailMessage::setFromMailbox方法的具体用法?C++ QMailMessage::setFromMailbox怎么用?C++ QMailMessage::setFromMailbox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMailMessage的用法示例。


在下文中一共展示了QMailMessage::setFromMailbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fetched

void SmsClient::fetched( const QString& id, const QSMSMessage& message )
{
    if (!id.isEmpty()) {
        QMailMessage mail;
        QString subject;
        QString body;
        int part;

        // Construct a full identity for the message.  This should be
        // unique enough to identify messages on different SIM's.
        QDateTime dt = message.timestamp();
        QString identity = QString("sms:%1:%2%3%4%5%6%7:>%8")
                                .arg( simIdentity )
                                .arg( dt.date().year(), 4 )
                                .arg( dt.date().month(), 2 )
                                .arg( dt.date().day(), 2 )
                                .arg( dt.time().hour(), 2 )
                                .arg( dt.time().minute(), 2 )
                                .arg( dt.time().second(), 2 )
                                .arg( id );

        // Add it to the active list, so that we know what's on the
        // inserted SIM right now, as opposed to the cached copy in
        // the mailbox folder.
        activeIds += identity;
        timeStamps += dt;

        // If we already have this message in the mailbox, then ignore it.
        if ( account ) {
            QStringList list = account->getUidlList();
            if ( list.contains( identity ) ) {
                if ( account->deleteMail() )
                    deleteImmediately( id );
                req->nextMessage();
                return;
            }
            list += identity;
            account->setUidlList( list );
        }
        mail.setServerUid( identity );

        // If the sender is not set, but the recipient is, then this
        // is probably an outgoing message that was reflected back
        // by the phone simulator.
        if( !message.sender().isEmpty() )
            mail.setHeaderField( "From", message.sender() );
        else if( !message.recipient().isEmpty() )
            mail.setHeaderField( "From", message.recipient() );

        // Extract the subject and body.
        extractSubjectAndBody( message.text(), subject, body );

        // Set the subject from the first few words of the text.
        mail.setSubject( subject );

        // Determine if the entire body is text, or if it contains attachments.
        bool hasAttachments = false;
        QList<QSMSMessagePart> parts = message.parts();
        for ( part = 0; part < parts.count(); ++part ) {
            if ( !(parts[part].isText()) ) {
                hasAttachments = true;
                break;
            }
        }
        if( !hasAttachments ) {
            QMailMessageContentType type("text/plain; charset=UTF-8");
            mail.setBody( QMailMessageBody::fromData( body, type, QMailMessageBody::Base64 ) );
        } else {
            SMSDecoder::formatMessage( mail, message );
        }

        // Set the reception date.
        QDateTime date = message.timestamp();
        if (!date.isValid())
            date = QDateTime::currentDateTime();
        mail.setDate( QMailTimeStamp( date ) );

        // Synthesize some other headers
        QString smsType;
        switch(message.messageType()) {
            case QSMSMessage::Normal:
                smsType = "normal"; break;
            case QSMSMessage::CellBroadCast:
                smsType = "broadcast"; break;
            case QSMSMessage::StatusReport:
                smsType = "status-report"; break;
            default:
                smsType = "unknown"; break;
        }
        mail.setHeaderField( "X-Sms-Type", smsType );

        QMailId id;
        mail.setId( id );

        mail.setStatus( QMailMessage::Incoming, true);
        mail.setStatus( QMailMessage::Downloaded, true);
        mail.setFromAccount( account->id() );
        mail.setFromMailbox( "" );
        mail.setMessageType( QMailMessage::Sms );

//.........这里部分代码省略.........
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:101,代码来源:smsclient.cpp


注:本文中的QMailMessage::setFromMailbox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。