Ejemplo n.º 1
0
bool StPlayList::checkExtension(const StString& thePath) {
    if(StFolder::isFolder(thePath)) {
        // just folder
        return true;
    }
    StString anExtension = StFileNode::getExtension(thePath);
    for(size_t anExtId = 0; anExtId < myExtensions.size(); ++anExtId) {
        if(anExtension.isEqualsIgnoreCase(myExtensions[anExtId])) {
            return true;
        }
    }
    if(anExtension.isEqualsIgnoreCase(stCString("m3u"))) {
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
void StFolder::addItem(const StArrayList<StString>& theExtensions,
                       int theDeep,
                       const StString& theSearchFolderPath,
                       const StString& theCurrentItemName) {
    if(theCurrentItemName == IGNORE_DIR_CURR_NAME || theCurrentItemName == IGNORE_DIR_UP_NAME) {
        return;
    }

    StString aCurrItemFullName = theSearchFolderPath + SYS_FS_SPLITTER + theCurrentItemName;
    if(isFolder(aCurrItemFullName)) {
        if(theDeep > 1) {
            StFolder* aSubFolder = new StFolder(theCurrentItemName, this);
            aSubFolder->init(theExtensions, theDeep - 1);
            if(aSubFolder->size() > 0) {
                add(aSubFolder);
            } else {
                // ignore empty folders
                delete aSubFolder;
            }
        }
    } else {
        StString anItemExtension = StFileNode::getExtension(theCurrentItemName);
        for(size_t anExt = 0; anExt < theExtensions.size(); ++anExt) {
            if(anItemExtension.isEqualsIgnoreCase(theExtensions[anExt])) {
                add(new StFileNode(theCurrentItemName, this));
                break;
            }
        }
    }
}
Ejemplo n.º 3
0
StBrowserPlugin::StBrowserPlugin(NSPluginCreateData* theCreateDataStruct)
    : nppInstance(theCreateDataStruct->instance),
      myResMgr(new StResourceManager()),
      myParentWin((StNativeWin_t )NULL),
#ifdef _WIN32
      myProcOrig(NULL),
      myBackBrush(CreateSolidBrush(RGB(0, 0, 0))),
#endif
      myToLoadFull(false),
      myIsActive(false),
      myToQuit(false) {
    if(ST_PLUGIN_INSTANCES.increment() == 1) {
        StSearchMonitors aMonitors;
        aMonitors.init(true); // force update of cached state
    }

    StArgumentsMap aDrawerArgs;
    for(int aParamId = 0; aParamId < theCreateDataStruct->argc; ++aParamId) {
        StString aParamName  = StString(theCreateDataStruct->argn[aParamId]);
        StString aParamValue = StString(theCreateDataStruct->argv[aParamId]);

        StArgument stArg(aParamName, aParamValue);
        aDrawerArgs.add(stArg);

        if(aParamName.isEqualsIgnoreCase(stCString("data-prv-url"))) {
            myPreviewUrl = aParamValue;
            myPreviewUrlUtf8.fromUrl(aParamValue);
        }
    }
    const StString ST_ASTERIX = '*';
    StMIME stMIME(StString(theCreateDataStruct->type), ST_ASTERIX, ST_ASTERIX);
    myOpenInfo.setMIME(stMIME);

    const StString ST_SETTING_SRCFORMAT    = stCString("srcFormat");
    const StString ST_SETTING_COMPRESS     = stCString("toCompress");
    const StString ST_SETTING_ESCAPENOQUIT = stCString("escNoQuit");
    const StMIME ST_MIME_X_JPS("image/x-jps", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_JPS  ("image/jps",   ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_X_PNS("image/x-pns", ST_ASTERIX, ST_ASTERIX);
    const StMIME ST_MIME_PNS  ("image/pns",   ST_ASTERIX, ST_ASTERIX);
    StArgument anArgSrcFormat = aDrawerArgs[ST_SETTING_SRCFORMAT];
    if(!anArgSrcFormat.isValid()) {
        anArgSrcFormat.setKey(ST_SETTING_SRCFORMAT);
        if(stMIME == ST_MIME_X_JPS
                || stMIME == ST_MIME_JPS
                || stMIME == ST_MIME_X_PNS
                || stMIME == ST_MIME_PNS) {
            anArgSrcFormat.setValue(st::formatToString(StFormat_SideBySide_RL));
            aDrawerArgs.add(anArgSrcFormat);
        }
    }
    aDrawerArgs.add(StArgument(ST_SETTING_COMPRESS,     "true")); // optimize memory usage
    aDrawerArgs.add(StArgument(ST_SETTING_ESCAPENOQUIT, "true")); // do not close plugin instance by Escape key
    myOpenInfo.setArgumentsMap(aDrawerArgs);
}
Ejemplo n.º 4
0
StImageFile::ImageClass StImageFile::imgLibFromString(const StString& thePreferred) {
    StImageFile::ImageClass aPreferred = ST_LIBAV;
    if(thePreferred.isEqualsIgnoreCase(stCString("LibAV")) ||
       thePreferred.isEqualsIgnoreCase(stCString("FFmpeg")) ||
       thePreferred.isEqualsIgnoreCase(stCString("StAVImage"))) {
        aPreferred = ST_LIBAV;
    } else if(thePreferred.isEqualsIgnoreCase(stCString("FreeImage")) ||
              thePreferred.isEqualsIgnoreCase(stCString("StFreeImage"))) {
        aPreferred = ST_FREEIMAGE;
    } else if(thePreferred.isEqualsIgnoreCase(stCString("DevIL")) ||
              thePreferred.isEqualsIgnoreCase(stCString("StDevILImage"))) {
        aPreferred = ST_DEVIL;
    } else if(thePreferred.isEqualsIgnoreCase(stCString("WebP")) ||
              thePreferred.isEqualsIgnoreCase(stCString("StWebPImage"))) {
        aPreferred = ST_WEBP;
    }
    return aPreferred;
}
Ejemplo n.º 5
0
StFormatEnum st::formatFromString(const StString& theFormatString) {
    if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_MONO_STRING)) {
        return ST_V_SRC_MONO;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_SIDE_BY_SIDE_STRING)) {
        return ST_V_SRC_SIDE_BY_SIDE;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_PARALLEL_PAIR_STRING)) {
        return ST_V_SRC_PARALLEL_PAIR;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_OVER_UNDER_RL_STRING)) {
        return ST_V_SRC_OVER_UNDER_RL;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_OVER_UNDER_LR_STRING)) {
        return ST_V_SRC_OVER_UNDER_LR;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_ROW_INTERLACE_STRING)) {
        return ST_V_SRC_ROW_INTERLACE;
    } else if(theFormatString.isEqualsIgnoreCase(ST_V_SRC_PAGE_FLIP_STRING)) {
        return ST_V_SRC_PAGE_FLIP;
    } else {
        return ST_V_SRC_AUTODETECT;
    }
}
Ejemplo n.º 6
0
StImageFile::ImageType StImageFile::guessImageType(const StString& theFileName,
                                                   const StMIME&   theMIMEType) {
    StString anExt = !theMIMEType.isEmpty() ? theMIMEType.getExtension() : StFileNode::getExtension(theFileName);
    if(anExt.isEqualsIgnoreCase(stCString("mpo"))
    || theMIMEType.getMIMEType().isEquals(stCString("image/mpo"))
    || theMIMEType.getMIMEType().isEquals(stCString("image/x-mpo"))) {
        return StImageFile::ST_TYPE_MPO;
    } else if(anExt.isEqualsIgnoreCase(stCString("jps"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/jps"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/x-jps"))) {
        return StImageFile::ST_TYPE_JPS;
    } else if(anExt.isEqualsIgnoreCase(stCString("pns"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/pns"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/x-pns"))) {
        return StImageFile::ST_TYPE_PNS;
    } else if(anExt.isEqualsIgnoreCase(stCString("jpg"))
           || anExt.isEqualsIgnoreCase(stCString("jpeg"))
           || anExt.isEqualsIgnoreCase(stCString("jpe"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/jpg"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/jpeg"))) {
        return StImageFile::ST_TYPE_JPEG;
    } else if(anExt.isEqualsIgnoreCase(stCString("png"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/png"))) {
        return StImageFile::ST_TYPE_PNG;
    } else if(anExt.isEqualsIgnoreCase(stCString("exr"))) {
        return StImageFile::ST_TYPE_EXR;
    } else if(anExt.isEqualsIgnoreCase(stCString("psd"))) {
        return StImageFile::ST_TYPE_PSD;
    } else if(anExt.isEqualsIgnoreCase(stCString("ico"))) {
        return StImageFile::ST_TYPE_ICO;
    } else if(anExt.isEqualsIgnoreCase(stCString("hdr"))) {
        return StImageFile::ST_TYPE_HDR;
    } else if(anExt.isEqualsIgnoreCase(stCString("webp"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/webp"))) {
        return StImageFile::ST_TYPE_WEBP;
    } else if(anExt.isEqualsIgnoreCase(stCString("webpll"))
           || theMIMEType.getMIMEType().isEquals(stCString("image/webpll"))) {
        return StImageFile::ST_TYPE_WEBPLL;
    }
    return StImageFile::ST_TYPE_NONE;
}
Ejemplo n.º 7
0
void StPlayList::open(const StCString& thePath,
                      const StCString& theItem) {
    StMutexAuto anAutoLock(myMutex);

    // check if it is recently played playlist
    bool hasTarget = !theItem.isEmpty();
    StString aTarget = hasTarget ? theItem : thePath;
    if(!hasTarget) {
        for(size_t anIter = 0; anIter < myRecent.size(); ++anIter) {
            const StHandle<StRecentItem>& aRecent = myRecent[anIter];
            const StHandle<StFileNode>&   aFile   = aRecent->File;
            if(aFile->size() != 1) {
                continue;
            }

            if(thePath.isEquals(aFile->getPath())) {
                hasTarget = true;
                aTarget = aFile->getValue(0)->getSubPath();
                break;
            }
        }
    }

    clear();
    int aSearchDeep = myRecursionDeep;
    StString aFolderPath;
    StString aFileName;
    if(StFolder::isFolder(thePath)) {
        // add all files from the folder and subfolders
        aFolderPath = thePath;
        aSearchDeep = myRecursionDeep;
        myPlsFile   = addRecentFile(StFileNode(thePath)); // append to recent files list
    } else if(StFileNode::isFileExists(thePath)) {
        // search only current folder
        StFileNode::getFolderAndFile(thePath, aFolderPath, aFileName);
        aSearchDeep = 1;
        bool hasSupportedExt = false;
        StString anExt = StFileNode::getExtension(aFileName);
        for(size_t anExtId = 0; anExtId < myExtensions.size() && !hasSupportedExt; ++anExtId) {
            hasSupportedExt = anExt.isEqualsIgnoreCase(myExtensions[anExtId]);
        }

        // parse m3u playlist
        if(anExt.isEqualsIgnoreCase(stCString("m3u"))) {
            StRawFile aRawFile(thePath);
            if(aRawFile.readFile()) {
                StString aTitle;
                char* anIter = (char* )aRawFile.getBuffer();
                if(anIter[0] == '\xEF' && anIter[1] == '\xBB' && anIter[2] == '\xBF') {
                    // skip BOM for UTF8 written by some stupid programs
                    anIter += 3;
                }
                while(anIter != NULL) {
                    anIter = parseM3UIter(anIter, aTitle);
                }

                myPlsFile = addRecentFile(StFileNode(thePath)); // append to recent files list
                if(hasTarget) {
                    // set current item
                    for(StPlayItem* anItem = myFirst; anItem != NULL; anItem = anItem->getNext()) {
                        if(anItem->getPath() == aTarget) {
                            myCurrent = anItem;
                            break;
                        }
                    }
                }

                anAutoLock.unlock();
                signals.onPlaylistChange();
                return;
            }
        }

        if(!hasSupportedExt) {
            // file with unsupported extension?
            StFileNode* aFileNode = new StFileNode(thePath, &myFoldersRoot);
            myFoldersRoot.add(aFileNode);
            addPlayItem(new StPlayItem(aFileNode, myDefStParams));
        }
    } else {
        // not a filesystem element - probably url or invalid path
        StFileNode* aFileNode = new StFileNode(thePath, &myFoldersRoot);
        myFoldersRoot.add(aFileNode);
        addRecentFile(*aFileNode); // append to recent files list
        addPlayItem(new StPlayItem(aFileNode, myDefStParams));

        anAutoLock.unlock();
        signals.onPlaylistChange();
        return;
    }
    StFolder* aSubFolder = new StFolder(aFolderPath, &myFoldersRoot);
    aSubFolder->init(myExtensions, aSearchDeep);
    myFoldersRoot.add(aSubFolder);

    addToPlayList(aSubFolder);

    myCurrent = myFirst;
    if(hasTarget || !aFileName.isEmpty()) {
        // set current item
        for(StPlayItem* anItem = myFirst; anItem != NULL; anItem = anItem->getNext()) {
            if(anItem->getPath() == aTarget) {
                myCurrent = anItem;
                if(myPlsFile.isNull()) {
                    addRecentFile(*anItem->getFileNode()); // append to recent files list
                }
                break;
            }
        }
    }

    anAutoLock.unlock();
    signals.onPlaylistChange();
}