Example #1
0
NPError StBrowserPlugin::streamNew(NPMIMEType ,
                                   NPStream* theStream,
                                   NPBool ,
                                   uint16_t* theStreamType) {
    *theStreamType = NP_ASFILEONLY;
    // here we got MIME from server header (not object MIME-type!)
    // because jps/pns/mpo are actually jpeg/png files - we ignore returned MIME here
    //myOpenInfo.setMIME(StString(mimeString) + ST_TEXT(":*:*"));

    if(myToLoadFull) {
        // load full-size image only when switched to fullscreen
        return NPERR_NO_ERROR;
    }

    // notice that some browsers (Chromium) returns NOT the same string as requested by NPNFuncs.geturl()!
    // instead here we got URL with decoded Unicode characters
    const StString anUrl((theStream->url != NULL) ? theStream->url : "");
    if(myPreviewUrl.isEmpty()
            || anUrl.isEndsWith(myPreviewUrl)
            || anUrl.isEndsWith(myPreviewUrlUtf8)) {
        return NPERR_NO_ERROR;
    }
    myFullUrl = anUrl;

    // block wrong streams
    return NPERR_INVALID_URL;
}
Example #2
0
void StBrowserPlugin::streamAsFile(NPStream*   theStream,
                                   const char* theFileName) {
    if(theFileName == NULL) {
        ///ST_DEBUG_LOG("streamAsFile ERROR");
        return;
    }

    const StString anUrl((theStream->url != NULL) ? theStream->url : "");
    const bool isPreview = !myPreviewUrl.isEmpty()
                           && (anUrl.isEndsWith(myPreviewUrl) || anUrl.isEndsWith(myPreviewUrlUtf8));
    StString aFileName = StString(theFileName);
    StString aFolder, aDummy;
    StFileNode::getFolderAndFile(aFileName, aFolder, aDummy);
    if(aFileName.isStartsWith(StProcess::getTempFolder())) {
        // Some browsers (Safari) returns file copies in temporary folder
        // and imidiatly remove it after function execution.
        // sView load image async, so we need to copy file until it will be read.
        StString aFileNameNew = aFileName + ".sView.tmp";
        if(StFileNode::moveFile(aFileName, aFileNameNew)) {
            aFileName = aFileNameNew;
            myTmpFiles.add(aFileName);
        }
    }

    StMutexAuto aLock(myMutex);
    if(isPreview) {
        myPreviewPath = aFileName;
    } else {
        myFullPath    = aFileName;
    }
}
Example #3
0
StString StProcess::getStCoreFolder() {
    StString aCoreEnvValue = getEnv(ST_ENV_NAME_STCORE_PATH);
#ifdef _WIN32
    if(aCoreEnvValue.isEmpty()) {
        // read env. value directly from registry (before first log off / log in)
        const StString aRegisterPath = "Environment";
        loadStringFromRegister(aRegisterPath, ST_ENV_NAME_STCORE_PATH, aCoreEnvValue);
    }
#endif

    // repair filesystem splitter
    if(!aCoreEnvValue.isEmpty() && !aCoreEnvValue.isEndsWith(SYS_FS_SPLITTER)) {
        aCoreEnvValue += StString(SYS_FS_SPLITTER);
    }

    if(isValidStCorePath(aCoreEnvValue)) {
        // environment variable is correctly set
        return aCoreEnvValue;
    }

    const StString aProcessPath = getProcessFolder();
    if(isValidStCorePath(aProcessPath)) {
        return aProcessPath;
    }
    return StString();
}