Ejemplo n.º 1
0
 virtual LVStreamRef OpenStream( const lChar16 * fname, lvopen_mode_t mode ) {
     if ( mode!=LVOM_READ )
         return LVStreamRef();
     for ( int i=0; i<_list.length(); i++ ) {
         //CRLog::trace("OpenStream(%s) : %s", LCSTR(lString16(fname)), LCSTR(lString16(_list[i]->GetName())) );
         if ( !lStr_cmp(_list[i]->GetName(), fname) )
             return _list[i]->openStream();
     }
     return LVStreamRef();
 }
Ejemplo n.º 2
0
LVStreamRef CRJNIEnv::jbyteArrayToStream( jbyteArray array )
{
	if ( !array )
		return LVStreamRef();
	int len = env->GetArrayLength(array);
	if ( !len )
		return LVStreamRef();
    lUInt8 * data = (lUInt8 *)env->GetByteArrayElements(array, 0);
    LVStreamRef res = LVCreateMemoryStream(data, len, true, LVOM_READ);
    env->ReleaseByteArrayElements(array, (jbyte*)data, 0);
    return res;
} 
Ejemplo n.º 3
0
    virtual LVStreamRef OpenStream( const lChar16 * fname, lvopen_mode_t mode ) {

        LVStreamRef res = _container->OpenStream(fname, mode);
        if (res.isNull())
            return res;
        if (isEncryptedItem(fname))
            return LVStreamRef(new FontDemanglingStream(res, _fontManglingKey));
        return res;
    }
Ejemplo n.º 4
0
LVStreamRef GetEpubCoverpage(LVContainerRef arc)
{
    // check root media type
    lString16 rootfilePath = EpubGetRootFilePath(arc);
    if ( rootfilePath.empty() )
        return LVStreamRef();

    EncryptedDataContainer * decryptor = new EncryptedDataContainer(arc);
    if (decryptor->open()) {
        CRLog::debug("EPUB: encrypted items detected");
    }

    LVContainerRef m_arc = LVContainerRef(decryptor);

    lString16 codeBase = LVExtractPath(rootfilePath, false);
    CRLog::trace("codeBase=%s", LCSTR(codeBase));

    LVStreamRef content_stream = m_arc->OpenStream(rootfilePath.c_str(), LVOM_READ);
    if ( content_stream.isNull() )
        return LVStreamRef();


    LVStreamRef coverPageImageStream;
    // reading content stream
    {
        lString16 coverId;
        ldomDocument * doc = LVParseXMLStream( content_stream );
        if ( !doc )
            return LVStreamRef();

        for ( int i=1; i<20; i++ ) {
            ldomNode * item = doc->nodeFromXPath( lString16(L"package/metadata/meta[") + lString16::itoa(i) + L"]" );
            if ( !item )
                break;
            lString16 name = item->getAttributeValue(L"name");
            lString16 content = item->getAttributeValue(L"content");
            if (name == L"cover")
                coverId = content;
        }

        // items
        for ( int i=1; i<50000; i++ ) {
            ldomNode * item = doc->nodeFromXPath( lString16(L"package/manifest/item[") + lString16::itoa(i) + L"]" );
            if ( !item )
                break;
            lString16 href = item->getAttributeValue(L"href");
            lString16 id = item->getAttributeValue(L"id");
            if ( !href.empty() && !id.empty() ) {
                if (id == coverId) {
                    // coverpage file
                    lString16 coverFileName = codeBase + href;
                    CRLog::info("EPUB coverpage file: %s", LCSTR(coverFileName));
                    coverPageImageStream = m_arc->OpenStream(coverFileName.c_str(), LVOM_READ);
                }
            }
        }
        delete doc;
    }

    return coverPageImageStream;
}
Ejemplo n.º 5
0
 virtual LVStreamRef openStream() {
     // return region of base stream
     return LVStreamRef( new LVStreamFragment( _stream, _startBlock, _size ) );
 }
Ejemplo n.º 6
0
 virtual LVStreamRef openStream() {
     // TODO: implement stream creation
     return LVStreamRef();
 }