示例#1
0
void GitEditor::setPlainTextFiltered(const QString &text)
{
    QString modText = text;
    GitPlugin *plugin = GitPlugin::instance();
    // If desired, filter out the date from annotation
    switch (contentType())
    {
    case VcsBase::AnnotateOutput: {
        const bool omitAnnotationDate = plugin->settings().boolValue(GitSettings::omitAnnotationDateKey);
        if (omitAnnotationDate)
            modText = removeAnnotationDate(text);
        break;
    }
    case VcsBase::DiffOutput: {
        if (modText.isEmpty()) {
            modText = QLatin1String("No difference to HEAD");
        } else {
            const QFileInfo fi(source());
            const QString workingDirectory = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
            modText = plugin->gitClient()->extendedShowDescription(workingDirectory, modText);
        }
        break;
    }
    default:
        break;
    }

    setPlainText(modText);
}
void CodeClassFieldDeclarationBlock::syncToParent ()
{
    // for role-based accessors, we DON'T write ourselves out when
    // the name of the role is not defined.
    if (!(getParentClassField()->parentIsAttribute()))
    {
        UMLRole * parent = getParentObject()->asUMLRole();
        if (parent == 0)
            return;
        if (parent->name().isEmpty())
        {
            getComment()->setWriteOutText(false);
            setWriteOutText(false);
        } else {
            getComment()->setWriteOutText(true);
            setWriteOutText(true);
        }
    }

    // only update IF we are NOT AutoGenerated
    if (contentType() != AutoGenerated)
        return;

    updateContent();
}
示例#3
0
文件: web_server.c 项目: Zanaku/AEs
void writeRequested(int connfd,char* protocol,char* url){
    struct stat fs;
    char response[1024];
    char* page; 
    char* contType;
    contType = contentType(url);

    int fd = open(url+1, O_RDONLY);
    if(fd==-1){
        writeFileNotFound(connfd,protocol);
        return;
    }
    if(fstat(fd,&fs)==-1){
        printf("Could Not retrieve file size!\n");
        writeInternal(connfd,protocol);
    }

    page = (char*)malloc(fs.st_size);
    read(fd,page,fs.st_size);

    sprintf(response,"%s 200 OK\nContent-Type: %s\nContent-Length: %d\r\n\r\n",protocol,contType,(int)fs.st_size);

    if(write(connfd,response,strlen(response))==-1){
        fprintf(stderr,"200 Errno %d: %s\n",errno,strerror(errno));
    }
    if(write(connfd,page,fs.st_size)==-1){
        fprintf(stderr,"200 Errno %d: %s\n",errno,strerror(errno));
    }
    printf("Returning Response from Thread %lu\n",pthread_self());
    printf("****Writing Response****\n%s\n",response);
    close(fd);
    free(page); 
}
// -----------------------------------------------------------------------------
// CWPPushMessage::ParseHeader
// -----------------------------------------------------------------------------
//
EXPORT_C void CWPPushMessage::ParseHeaderL()
    {
    // CHTTPResponse panicks if it is used for parsing a zero-length 
    // descriptor.
    if( iHeader->Response().Length() > 0 )
        {
        // We use lexer for safety.
        TLex8 contentType( ContentTypeHeader( *iHeader ) );
        if( !contentType.Eos() )
            {
            ParseContentType( contentType );
            }
        
        TLex8 initiatorURI( InitiatorURIHeader( *iHeader ) );
        if( !initiatorURI.Eos() )
            {
            ParseInitiatorURI( initiatorURI );
            }
        
        TLex8 pushFlag( PushFlagHeader( *iHeader ) );
        if( !pushFlag.Eos() )
            {
            ParsePushFlag( pushFlag );
            }
        }
    }
示例#5
0
void IcyConnector::ProcessHeaders(const QString &hdrs)
{
    QStringList f0;
    QStringList f1;
    QString txt;

    f0=hdrs.split("\r\n");
    if(f0[0]!="OK2") {
        Log(LOG_WARNING,
            QString().sprintf("login to \"%s:%d\" rejected: %s",
                              (const char *)hostHostname().toUtf8(),
                              0xFFFF&hostPort(),
                              (const char *)f0[0].toUtf8()));
        return;
    }
    icy_authenticated=true;
    WriteHeader("icy-name: "+streamName());
    WriteHeader("icy-genre: "+streamGenre());
    WriteHeader("icy-pub: "+QString().sprintf("%d",streamPublic()));
    WriteHeader("icy-br: "+QString().sprintf("%u",audioBitrate()));
    if(icy_protocol_version==1) {
        WriteHeader("icy-url: "+streamUrl());
    }
    WriteHeader("icy-irc: "+streamIrc());
    WriteHeader("icy-icq: "+streamIcq());
    WriteHeader("icy-aim: "+streamAim());
    WriteHeader("Content-Type: "+contentType());
    WriteHeader("");

    setConnected(true);
}
示例#6
0
void SCgNode::updateContentViewer()
{
    bool isCntVis = mContentVisible;

    if(isCntVis)
        hideContent();

    if (mContentViewer != 0)
    {
        delete mContentViewer;
        mContentViewer = 0;
    }

    if (!contentType() == SCgContent::Empty)
    {
        // creating new viewer
        if (!mContentViewer) mContentViewer = SCgContentFactory::createViewer(contentFormat());
        Q_ASSERT(mContentViewer);

        mContentViewer->setData(contentData());
        mContentViewer->setParentItem(this);

        if (isCntVis)
            showContent();
    }
    update();
}
void OwnedHierarchicalCodeBlock::syncToParent()
{
    if (contentType() != CodeBlock::AutoGenerated)
        return;

    updateContent();
}
示例#8
0
QString CvsEditorWidget::changeUnderCursor(const QTextCursor &c) const
{
    // Try to match "1.1" strictly:
    // 1) Annotation: Check for a revision number at the beginning of the line.
    //    Note that "cursor.select(QTextCursor::WordUnderCursor)" will
    //    only select the part up until the dot.
    //    Check if we are at the beginning of a line within a reasonable offset.
    // 2) Log: check for lines like "revision 1.1", cursor past "revision"
    switch (contentType()) {
    case VcsBase::OtherContent:
    case VcsBase::DiffOutput:
        break;
    case VcsBase::AnnotateOutput: {
            const QTextBlock block = c.block();
            if (c.atBlockStart() || (c.position() - block.position() < 3)) {
                const QString line = block.text();
                if (m_revisionAnnotationPattern.exactMatch(line))
                    return m_revisionAnnotationPattern.cap(1);
            }
        }
        break;
    case VcsBase::LogOutput: {
            const QTextBlock block = c.block();
            if (c.position() - block.position() > 8 && m_revisionLogPattern.exactMatch(block.text()))
                return m_revisionLogPattern.cap(1);
        }
        break;
    }
    return QString();
}
/*!
     * returns email part attachment name
     * @return attachment name
 */
QString NmMessagePart::attachmentName() const
{
    NM_FUNCTION;
    
    // Look first from Content-Type param "name"
    QString content = contentType();
    int ptr = content.indexOf(NmContentTypeParamName);
    if(ptr >= 0) {
        d->mAttachmentName = content.section('"',1,1);
        return d->mAttachmentName;
    }
    // then if Content-Disposition is "attachment" look from 
    // Content-Disposition param "filename" and
    content = contentDisposition();
    ptr = content.indexOf(NmContentDispAttachment);
    if(ptr >= 0) {
        ptr = content.indexOf(NmContentDispParamFilename);
        if(ptr > 0) {
            d->mAttachmentName = content.section('"',1,1);
            return d->mAttachmentName;
            }
        }
    // finally look if there is Content-Description.
    return d->mContentDescription;
}
示例#10
0
bool ccWebServerResponse::notFoundFile(const std::string& strURI)
{
    std::string strContent;

    ccString::format(
        strContent,
        "<!DOCTYPE html>\r\n"
        "<html lang=en>\r\n"
        "<head>\r\n"
        "  <meta charset=utf-8>\r\n"
        "  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\r\n"
        "  <title>Error 404 (Not Found)!!1</title>\r\n"
        "</head>\r\n"
        "<body>\r\n"
        "  <p><b>404.</b> <ins>That's an error.</ins></p>\r\n"
        "  <p>The requested URL <code>%s</code> was not found on this server.</p>\r\n"
        "</body>\r\n"
        "</html>\r\n",
        strURI.c_str());

    status(404, "Not Found");
    contentType("text/html", strContent.length());

    doWriteContentToConnector(strContent.c_str(), strContent.length());

    return true;
}
示例#11
0
MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, const MediaRecorderOptions& options, ExceptionState& exceptionState)
    : ActiveDOMObject(context)
    , m_stream(stream)
    , m_streamAmountOfTracks(stream->getTracks().size())
    , m_mimeType(options.mimeType())
    , m_stopped(true)
    , m_ignoreMutedMedia(true)
    , m_state(State::Inactive)
    , m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(this, &MediaRecorder::dispatchScheduledEvent))
{
    ASSERT(m_stream->getTracks().size());

    m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler());
    ASSERT(m_recorderHandler);

    // We deviate from the spec by not returning |UnsupportedOption|, see https://github.com/w3c/mediacapture-record/issues/18
    if (!m_recorderHandler) {
        exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder handler can be created.");
        return;
    }
    ContentType contentType(m_mimeType);
    if (!m_recorderHandler->initialize(this, stream->descriptor(), contentType.type(), contentType.parameter("codecs"))) {
        exceptionState.throwDOMException(NotSupportedError, "Failed to initialize native MediaRecorder, the type provided " + m_mimeType + "is unsupported." );
        return;
    }
    m_stopped = false;
}
示例#12
0
bool MediaSource::isTypeSupported(const String& type)
{
    LOG(MediaSource, "MediaSource::isTypeSupported(%s)", type.ascii().data());

    // Section 2.2 isTypeSupported() method steps.
    // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#widl-MediaSource-isTypeSupported-boolean-DOMString-type
    // 1. If type is an empty string, then return false.
    if (type.isNull() || type.isEmpty())
        return false;

    // FIXME: Why do we convert to lowercase here, but not in MediaSource::addSourceBuffer?
    ContentType contentType(type.convertToASCIILowercase());
    String codecs = contentType.parameter("codecs");

    // 2. If type does not contain a valid MIME type string, then return false.
    if (contentType.type().isEmpty())
        return false;

    // 3. If type contains a media type or media subtype that the MediaSource does not support, then return false.
    // 4. If type contains at a codec that the MediaSource does not support, then return false.
    // 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
    // 6. Return true.
    MediaEngineSupportParameters parameters;
    parameters.type = contentType.type();
    parameters.codecs = codecs;
    parameters.isMediaSource = true;
    MediaPlayer::SupportsType supported = MediaPlayer::supportsType(parameters, 0);

    if (codecs.isEmpty())
        return supported != MediaPlayer::IsNotSupported;

    return supported == MediaPlayer::IsSupported;
}
示例#13
0
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec)
{
    // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-addsourcebuffer
    // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and
    // abort these steps.
    if (type.isNull() || type.isEmpty()) {
        ec = INVALID_ACCESS_ERR;
        return 0;
    }

    // 2. If type contains a MIME type that is not supported ..., then throw a
    // NOT_SUPPORTED_ERR exception and abort these steps.
    ContentType contentType(type);
    Vector<String> codecs = contentType.codecs();

    if (!codecs.size()) {
        ec = NOT_SUPPORTED_ERR;
        return 0;
    }

    // 4. If the readyState attribute is not in the "open" state then throw an
    // INVALID_STATE_ERR exception and abort these steps.
    if (!m_player || m_readyState != openKeyword()) {
        ec = INVALID_STATE_ERR;
        return 0;
    }

    // 5. Create a new SourceBuffer object and associated resources.
    String id = m_sourceBuffers->generateUniqueId();
    if (id == emptyString()) {
        ec = QUOTA_EXCEEDED_ERR;
        return 0;
    }

    RefPtr<SourceBuffer> buffer = SourceBuffer::create(id, this);

    switch (m_player->sourceAddId(buffer->id(), contentType.type(), codecs)) {
    case MediaPlayer::Ok:
        // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
        m_sourceBuffers->add(buffer);
        m_activeSourceBuffers->add(buffer);
        // 7. Return the new object to the caller.
        return buffer.get();
    case MediaPlayer::NotSupported:
        // 2 (cont). If type contains a MIME type ... that is not supported with the types 
        // specified for the other SourceBuffer objects in sourceBuffers, then throw
        // a NOT_SUPPORTED_ERR exception and abort these steps.
        ec = NOT_SUPPORTED_ERR;
        return 0;
    case MediaPlayer::ReachedIdLimit:
        // 3 (cont). If the user agent can't handle any more SourceBuffer objects then throw 
        // a QUOTA_EXCEEDED_ERR exception and abort these steps.
        ec = QUOTA_EXCEEDED_ERR;
        return 0;
    }

    ASSERT_NOT_REACHED();
    return 0;
}
示例#14
0
void GitEditor::addChangeActions(QMenu *menu, const QString &change)
{
    m_currentChange = change;
    if (contentType() != VcsBase::OtherContent) {
        menu->addAction(tr("Cherry-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
        menu->addAction(tr("Revert Change %1").arg(change), this, SLOT(revertChange()));
    }
}
示例#15
0
文件: mpform.cpp 项目: UIKit0/digikam
void MPForm::reset()
{
    m_buffer.resize(0);
    QByteArray str(contentType().toLatin1());
    str += "\r\n";
    str += "MIME-version: 1.0";
    str += "\r\n\r\n";
    m_buffer.append(str);
}
void tst_QMailMessageBody::toFile()
{
    QFETCH( QString, string_input );
    QFETCH( QByteArray, bytearray_input );
    QFETCH( QByteArray, type );
    QFETCH( QMailMessageBody::EncodingFormat, format );
    QFETCH( QByteArray, bytearray_output );

    QTemporaryFile file(QString("%1/%2").arg(QDir::tempPath()).arg(metaObject()->className()));
    QVERIFY( file.open() );
    QString name = file.fileName();
    file.close();

    QMailMessageContentType contentType( type );

    // Create a body from whatever data was supplied
    if ( !string_input.isEmpty() )
    {
        QMailMessageBody body = QMailMessageBody::fromData( string_input, contentType, QMailMessageBody::Base64 );
        body.toFile( name, format );
    }
    else
    {
        QMailMessageBody body = QMailMessageBody::fromData( bytearray_input, contentType, QMailMessageBody::Base64, QMailMessageBody::RequiresEncoding );
        body.toFile( name, format );
    }

    QVERIFY( file.open() );
    if ( !string_input.isEmpty() && format == QMailMessageBody::Decoded )
    {
        // Read the string from the file and compare
        QTextStream in( &file );
        in.setCodec( contentType.charset() );
        QString data = in.readAll();
        QCOMPARE( data, string_input );
    }
    else
    {
        // Find the size of the file data
        QFileInfo fi( name );
        QByteArray data( fi.size(), '\0' );

        // Read the file data in for comparison
        QDataStream in( &file );
        in.readRawData( data.data(), data.length() );

        if ( !bytearray_output.isEmpty() )
        {
            QCOMPARE( data, bytearray_output );
        }
        else
        {
            QCOMPARE( data, bytearray_input );
        }
    }
}
void SidebarPrivate::linkClickedFinished()
{
    QNetworkReply * reply = static_cast< QNetworkReply * >(sender());

    QString target = reply->property("__target").toString();
    QVariant redirectsVariant = reply->property("__redirects");
    int redirects = redirectsVariant.isNull() ? 20 : redirectsVariant.toInt();

    // Redirect?
    QUrl redirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (redirectedUrl.isValid())
    {
        if (redirectedUrl.isRelative())
        {
            QUrl oldUrl = reply->url();
            redirectedUrl.setScheme(oldUrl.scheme());
            redirectedUrl.setAuthority(oldUrl.authority());
        }
        if (redirects > 0)
        {
            QNetworkRequest request = reply->request();
            request.setUrl(redirectedUrl);
            QNetworkReply * reply = networkAccessManager()->get(request);
            reply->setProperty("__target", target);
            connect(reply, SIGNAL(finished()), this, SLOT(linkClickedFinished()));
        }
        else
        {
            // TOO MANY REDIRECTS
        }
        reply->deleteLater();
        return;
    }

    // Check headers... if PDF then launch a new window, otherwise give it to the OS
    QString contentType(reply->header(QNetworkRequest::ContentTypeHeader).toString());
    if (contentType.contains("application/pdf")) {
        emit urlRequested(reply->request().url(), "tab");
    } else {
        QUrl href(reply->request().url());
        if (href.isValid()) {
            if (href.scheme() == "http" || href.scheme() == "https") {
                if (target == "sidebar") {
                    webView->setUrl(href);
                    slideLayout->push("web");
                    return;
                }
            }

            QDesktopServices::openUrl(href);
        }
        // FIXME error
    }

    reply->deleteLater();
}
示例#18
0
void ccWebServerResponse::doCheckHeadersSent()
{
    if (_bHeadersSent)
        return;

    if (!_bContentTypeSet)
        contentType("text/plain");

    _bHeadersSent = true;
}
// -----------------------------------------------------------------------------
// 
// -----------------------------------------------------------------------------
MEmailMessageContent* CEmailMessage::ContentL() const
    {
    if ( iTextContent )
        {
        return iTextContent;
        }
    if ( iContent )
        {
        return iContent;
        }

    User::LeaveIfNull( iPluginMessage );
    
    RPointerArray<CFSMailMessagePart> parts;
    CleanupResetAndDestroyPushL( parts );
    iPluginMessage->ChildPartsL( parts );
    TInt count( parts.Count() );
    if( count == 0 )
        {
        /* No content, return NULL */
        CleanupStack::PopAndDestroy( &parts ); // in case heap allocated but not used
        return NULL;
        }
    CFSMailMessagePart* part = parts[0];
    TContentType contentType( part->GetContentType() );
    TMessageContentId msgContentId = TMessageContentId(
                        part->GetPartId().Id(),
                        iMessageId.iId,
                        iMessageId.iFolderId.iId,
                        iMessageId.iFolderId.iMailboxId );

    if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
        contentType.Equals( KFSMailContentTypeTextHtml ) )
        {                                
        iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );
        parts[0] = NULL; // ownership of part transferred
        }
    else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
              contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
              contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
              contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
              contentType.Equals( KFSMailContentTypeMultipartParallel ) )
        {
        iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns);
        parts[0] = NULL; // ownership of part transferred
        }

    CleanupStack::PopAndDestroy( &parts ); // parts

    if (iTextContent)
        {
        return iTextContent;
        }
    return iContent;
    }
示例#20
0
// 获取 Content-Type
string RequestBaseTask::GetContentType() const
{
	string contentType("");
	if (NULL != mpHttpRequestManager) {
		const HttpRequest* request = mpHttpRequestManager->GetRequestById(mRequestId);
		if (NULL != request) {
			contentType = request->GetContentType();
		}
	}
	return contentType;
}
示例#21
0
HttpFileData::HttpFileData(QHttpFileData *data, QObject *parent)
    : QObject(parent)
{
    fileName(data->fileName());
    contentType(data->contentType());
    if (m_file.open()) {
        m_file.write(data->readAll());
        m_file.close();
        filePath(m_file.fileName());
    }
}
NS_IMETHODIMP
WebBrowserPersistSerializeChild::OnFinish(nsIWebBrowserPersistDocument* aDocument,
                                          nsIOutputStream* aStream,
                                          const nsACString& aContentType,
                                          nsresult aStatus)
{
    MOZ_ASSERT(aStream == this);
    nsCString contentType(aContentType);
    Send__delete__(this, contentType, aStatus);
    return NS_OK;
}
void tst_QMailMessageBody::fromFile()
{
    QFETCH( QString, string_input );
    QFETCH( QByteArray, bytearray_input );
    QFETCH( QByteArray, type );
    QFETCH( QMailMessageBody::TransferEncoding, encoding );
    QFETCH( QMailMessageBody::EncodingStatus, status );
    QFETCH( QByteArray, encoded );
    QFETCH( QByteArray, bytearray_decoded );
    QFETCH( QString, string_decoded );
    QFETCH( QStringList, content_properties );

    QMailMessageContentType contentType( type );

    QTemporaryFile file(QString("%1/%2").arg(QDir::tempPath()).arg(metaObject()->className()));
    QVERIFY( file.open() );
    QString name = file.fileName();
    if ( !string_input.isEmpty() )
    {
        {
            QTextStream out( &file );
            out.setCodec( contentType.charset() );
            out << string_input;
        }
        file.close();

        QMailMessageBody body = QMailMessageBody::fromFile( name, contentType, encoding, status );
        QCOMPARE( body.transferEncoding(), encoding );
        QCOMPARE( body.data( QMailMessageBody::Encoded ), encoded );
        QCOMPARE( body.data(), string_decoded );

        QCOMPARE( body.contentType().type().toLower(), content_properties[0].toLatin1().toLower() );
        QCOMPARE( body.contentType().subType().toLower(), content_properties[1].toLatin1().toLower() );
        QCOMPARE( body.contentType().charset().toLower(), content_properties[2].toLatin1().toLower() );
    }
    else
    {
        {
            QDataStream out( &file );
            out.writeRawData( bytearray_input.constData(), bytearray_input.length() );
        }
        file.close();

        QMailMessageBody body = QMailMessageBody::fromFile( name, contentType, encoding, status );
        QCOMPARE( body.transferEncoding(), encoding );
        QCOMPARE( body.data( QMailMessageBody::Encoded ), encoded );
        QCOMPARE( body.data( QMailMessageBody::Decoded ), bytearray_decoded );

        QCOMPARE( body.contentType().type().toLower(), content_properties[0].toLatin1().toLower() );
        QCOMPARE( body.contentType().subType().toLower(), content_properties[1].toLatin1().toLower() );
        QCOMPARE( body.contentType().charset().toLower(), content_properties[2].toLatin1().toLower() );
    }
}
示例#24
0
void Response::checkHeadersSent()
{
    if( ! headersSent )
    {
        if( ! contentTypeSet )
        {
            contentType("text/plain");
        }
        mg_write(conn, "\r\n", 2);
        headersSent = true;
    }
}
示例#25
0
void KSecretCreateItemJob::start()
{
    BackendReturn<BackendItem*> rc = m_collection->createItem(label(), attributes(),
                                     secret(), contentType(), replace(), locked());
    if(rc.isError()) {
        setError(rc.error(), rc.errorMessage());
        setItem(0);
    } else {
        setItem(rc.value());
    }
    emitResult();
}
示例#26
0
void MailMessage::readMultipart(std::istream& istr, PartHandler& handler)
{
	MediaType contentType(getContentType());
	_boundary = contentType.getParameter("boundary");
	MultipartReader reader(istr, _boundary);
	while (reader.hasNextPart())
	{
		MessageHeader partHeader;
		reader.nextPart(partHeader);
		readPart(reader.stream(), partHeader, handler);
	}
}
void GitEditor::setPlainTextDataFiltered(const QByteArray &a)
{
    // If desired, filter out the date from annotation
    const bool omitAnnotationDate = contentType() == VCSBase::AnnotateOutput
                                    && GitPlugin::instance()->settings().omitAnnotationDate;
    if (omitAnnotationDate) {
        QString text = codec()->toUnicode(a);
        removeAnnotationDate(&text);
        setPlainText(text);
    } else {
        setPlainTextData(a);
    }
}
示例#28
0
bool MediaRecorder::isTypeSupported(const String& type)
{
    RawPtr<WebMediaRecorderHandler> handler = Platform::current()->createMediaRecorderHandler();
    if (!handler)
        return false;

    // If true is returned from this method, it only indicates that the
    // MediaRecorder implementation is capable of recording Blob objects for the
    // specified MIME type. Recording may still fail if sufficient resources are
    // not available to support the concrete media encoding.
    // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods
    ContentType contentType(type);
    return handler->canSupportMimeType(contentType.type(), contentType.parameter("codecs"));
}
示例#29
0
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec)
{
    LOG(Media, "MediaSource::addSourceBuffer(%s) %p", type.ascii().data(), this);

    // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
    // 1. If type is null or an empty then throw an INVALID_ACCESS_ERR exception and
    // abort these steps.
    if (type.isNull() || type.isEmpty()) {
        ec = INVALID_ACCESS_ERR;
        return nullptr;
    }

    // 2. If type contains a MIME type that is not supported ..., then throw a
    // NOT_SUPPORTED_ERR exception and abort these steps.
    if (!isTypeSupported(type)) {
        ec = NOT_SUPPORTED_ERR;
        return nullptr;
    }

    // 4. If the readyState attribute is not in the "open" state then throw an
    // INVALID_STATE_ERR exception and abort these steps.
    if (!isOpen()) {
        ec = INVALID_STATE_ERR;
        return nullptr;
    }

    // 5. Create a new SourceBuffer object and associated resources.
    ContentType contentType(type);
    RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);

    if (!sourceBufferPrivate) {
        ASSERT(ec == NOT_SUPPORTED_ERR || ec == QUOTA_EXCEEDED_ERR);
        // 2. If type contains a MIME type that is not supported ..., then throw a NOT_SUPPORTED_ERR exception and abort these steps.
        // 3. If the user agent can't handle any more SourceBuffer objects then throw a QUOTA_EXCEEDED_ERR exception and abort these steps
        return nullptr;
    }

    RefPtr<SourceBuffer> buffer = SourceBuffer::create(sourceBufferPrivate.releaseNonNull(), this);
    // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
    m_sourceBuffers->add(buffer);

    if (buffer->active())
        m_activeSourceBuffers->add(buffer);
    // 7. Return the new object to the caller.
    return buffer.get();
}
示例#30
0
	virtual	VError HandleRequest( IHTTPResponse* inResponse)
			{
				if (inResponse == NULL)
					return VE_INVALID_PARAMETER;

				VError err = VE_OK;
				bool done = false;

				// First, extract the relative path from the url
				VString path = inResponse->GetRequest().GetURLPath();
				VRegexMatcher *matcher = VRegexMatcher::Create( fPattern, &err);
				if ((matcher != NULL) && (err == VE_OK))
				{
					bool match = matcher->Find( path, 1, false, &err);
					if (match && (err == VE_OK))
					{
						// Remove the pattern from the path
						path.Remove( matcher->GetGroupStart(0), matcher->GetGroupLength(0));

						// Check whether a namespace is specified
						VString lNamespaceKey( L"namespace=");
						VString lNamespace = inResponse->GetRequest().GetURLQuery();
						if (lNamespace.BeginsWith( lNamespaceKey))
							lNamespace.Remove( 1, lNamespaceKey.GetLength());
						else
							lNamespace.Clear();

						// Now, we have a relative  module path
						VString proxy;
						err = fService->GetProxy( proxy, path, lNamespace, &inResponse->GetRequest(), inResponse);
						if (err == VE_OK)
						{
							VString contentType( L"application/javascript");
							err = SetHTTPResponseString( inResponse, proxy, &contentType);
							done = true;
						}
					}
				}
				ReleaseRefCountable( &matcher);

				if (!done)
					err = inResponse->ReplyWithStatusCode( HTTP_NOT_FOUND);

				return err;
			}