void main()
{
    MUtils::WinSockHelper wshelper;
	
    // make sure the file 'boot.ini' is in the root directory on driver C
    SMailer::TextPlainContent  content1("plain text content");
    SMailer::TextHtmlContent   content2("<a href='http://morningspace.51.net'>click me</a>");
    SMailer::AppOctStrmContent content3("c:\\smtp_boot.ini");
	
    SMailer::MailInfo info;
    info.setSenderName("linshenglong888");
    info.setSenderAddress("*****@*****.**");
    info.addReceiver("linshenglong777", "*****@*****.**");
    info.addReceiver("shenglonglin1986", "*****@*****.**");
    info.setPriority(SMailer::Priority::normal);
    info.setSubject("a test mail");
    info.addMimeContent(&content1);
    info.addMimeContent(&content2);
    info.addMimeContent(&content3);
	
    try
    {
        SMailer::MailSender sender("smtp.126.com", "linshenglong888", "051335");
        sender.setMail(&SMailer::MailWrapper(&info));
        sender.sendMail();
    }
    catch (SMailer::MailException& e)
    {
        std::cout << e.what() << std::endl;
    }
    catch (...)
    {
        std::cout << "Unkown error" << std::endl;
    }
}
void tst_QMediaPlaylistNavigator::linearPlayback()
{
    QMediaNetworkPlaylistProvider playlist;
    QMediaPlaylistNavigator navigator(&playlist);

    navigator.setPlaybackMode(QMediaPlaylist::Sequential);
    navigator.jump(0);
    QVERIFY(navigator.currentItem().isNull());
    QCOMPARE(navigator.currentIndex(), -1);

    QMediaContent content1(QUrl(QLatin1String("file:///1")));
    playlist.addMedia(content1);
    navigator.jump(0);
    QVERIFY(!navigator.currentItem().isNull());

    QCOMPARE(navigator.currentIndex(), 0);
    QCOMPARE(navigator.currentItem(), content1);
    QCOMPARE(navigator.nextItem(), QMediaContent());
    QCOMPARE(navigator.nextItem(2), QMediaContent());
    QCOMPARE(navigator.previousItem(), QMediaContent());
    QCOMPARE(navigator.previousItem(2), QMediaContent());

    QMediaContent content2(QUrl(QLatin1String("file:///2")));
    playlist.addMedia(content2);
    QCOMPARE(navigator.currentIndex(), 0);
    QCOMPARE(navigator.currentItem(), content1);
    QCOMPARE(navigator.nextItem(), content2);
    QCOMPARE(navigator.nextItem(2), QMediaContent());
    QCOMPARE(navigator.previousItem(), QMediaContent());
    QCOMPARE(navigator.previousItem(2), QMediaContent());

    navigator.jump(1);
    QCOMPARE(navigator.currentIndex(), 1);
    QCOMPARE(navigator.currentItem(), content2);
    QCOMPARE(navigator.nextItem(), QMediaContent());
    QCOMPARE(navigator.nextItem(2), QMediaContent());
    QCOMPARE(navigator.previousItem(), content1);
    QCOMPARE(navigator.previousItem(2), QMediaContent());

    navigator.jump(0);
    navigator.next();
    QCOMPARE(navigator.currentIndex(), 1);
    navigator.next();
    QCOMPARE(navigator.currentIndex(), -1);
    navigator.next();//jump to the first item
    QCOMPARE(navigator.currentIndex(), 0);

    navigator.previous();
    QCOMPARE(navigator.currentIndex(), -1);
    navigator.previous();//jump to the last item
    QCOMPARE(navigator.currentIndex(), 1);
}
void tst_QMediaPlaylistNavigator::loopPlayback()
{
    QMediaNetworkPlaylistProvider playlist;
    QMediaPlaylistNavigator navigator(&playlist);

    navigator.setPlaybackMode(QMediaPlaylist::Loop);
    navigator.jump(0);
    QVERIFY(navigator.currentItem().isNull());
    QCOMPARE(navigator.currentIndex(), -1);

    QMediaContent content1(QUrl(QLatin1String("file:///1")));
    playlist.addMedia(content1);
    navigator.jump(0);
    QVERIFY(!navigator.currentItem().isNull());

    QCOMPARE(navigator.currentIndex(), 0);
    QCOMPARE(navigator.currentItem(), content1);
    QCOMPARE(navigator.nextItem(), content1);
    QCOMPARE(navigator.nextItem(2), content1);
    QCOMPARE(navigator.previousItem(), content1);
    QCOMPARE(navigator.previousItem(2), content1);

    QMediaContent content2(QUrl(QLatin1String("file:///2")));
    playlist.addMedia(content2);
    QCOMPARE(navigator.currentIndex(), 0);
    QCOMPARE(navigator.currentItem(), content1);
    QCOMPARE(navigator.nextItem(), content2);
    QCOMPARE(navigator.nextItem(2), content1); //loop over end of the list
    QCOMPARE(navigator.previousItem(), content2);
    QCOMPARE(navigator.previousItem(2), content1);

    navigator.jump(1);
    QCOMPARE(navigator.currentIndex(), 1);
    QCOMPARE(navigator.currentItem(), content2);
    QCOMPARE(navigator.nextItem(), content1);
    QCOMPARE(navigator.nextItem(2), content2);
    QCOMPARE(navigator.previousItem(), content1);
    QCOMPARE(navigator.previousItem(2), content2);

    navigator.jump(0);
    navigator.next();
    QCOMPARE(navigator.currentIndex(), 1);
    navigator.next();
    QCOMPARE(navigator.currentIndex(), 0);
    navigator.previous();
    QCOMPARE(navigator.currentIndex(), 1);
    navigator.previous();
    QCOMPARE(navigator.currentIndex(), 0);
}