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


C++ Content::contentType方法代码示例

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


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

示例1: testAttachments

void ComposerTest::testAttachments()
{
    Composer *composer = new Composer;
    fillComposerData(composer);
    AttachmentPart::Ptr attachment = AttachmentPart::Ptr(new AttachmentPart);
    attachment->setData("abc");
    attachment->setMimeType("x-some/x-type");
    composer->addAttachmentPart(attachment);

    QVERIFY(composer->exec());
    QCOMPARE(composer->resultMessages().size(), 1);
    KMime::Message::Ptr message = composer->resultMessages().first();
    delete composer;
    composer = Q_NULLPTR;

    // multipart/mixed
    {
        QVERIFY(message->contentType(false));
        QCOMPARE(message->contentType()->mimeType(), QByteArray("multipart/mixed"));
        QCOMPARE(message->contents().count(), 2);
        // text/plain
        {
            Content *plain = message->contents().at(0);
            QVERIFY(plain->contentType(false));
            QCOMPARE(plain->contentType()->mimeType(), QByteArray("text/plain"));
        }
        // x-some/x-type (attachment)
        {
            Content *plain = message->contents().at(1);
            QVERIFY(plain->contentType(false));
            QCOMPARE(plain->contentType()->mimeType(), QByteArray("x-some/x-type"));
        }
    }
}
开发者ID:VolkerChristian,项目名称:messagelib,代码行数:34,代码来源:composertest.cpp

示例2: testImplicitMultipartGeneration

void ContentTest::testImplicitMultipartGeneration()
{
  Content *c1 = new Content();
  c1->contentType()->from7BitString( "text/plain" );
  c1->setBody( "textpart" );

  Content *c2 = new Content();
  c2->contentType()->from7BitString( "text/html" );
  c2->setBody( "htmlpart" );

  c1->addContent( c2 );

  // c1 implicitly converted into a multipart/mixed node.
  QVERIFY( c1->contentType( false ) );
  QCOMPARE( c1->contentType()->mimeType(), QByteArray( "multipart/mixed" ) );
  QVERIFY( c1->body().isEmpty() );

  QCOMPARE( c1->contents().count(), 2 );
  Content *c = c1->contents().at( 0 ); // Former c1.
  QVERIFY( c->contentType( false ) );
  QCOMPARE( c->contentType()->mimeType(), QByteArray( "text/plain" ) );
  QCOMPARE( c->body(), QByteArray( "textpart" ) );

  QCOMPARE( c1->contents().at( 1 ), c2 );

  // Now remove c2. c1 should be converted back to a text/plain content.
  c1->removeContent( c2, false );
  QVERIFY( c1->contents().isEmpty() );
  QVERIFY( c1->contentType( false ) );
  QCOMPARE( c1->contentType()->mimeType(), QByteArray( "text/plain" ) );
  QCOMPARE( c1->body(), QByteArray( "textpart" ) );

  // c2 should not have been touched.
  QVERIFY( c2->contents().isEmpty() );
  QVERIFY( c2->contentType( false ) );
  QCOMPARE( c2->contentType()->mimeType(), QByteArray( "text/html" ) );
  QCOMPARE( c2->body(), QByteArray( "htmlpart" ) );

  // Clean up.
  delete c1;
  delete c2;
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:42,代码来源:contenttest.cpp


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