Esempio n. 1
0
bool PluginPackage::fetchInfo()
{
#if defined(XP_UNIX)
    if (!load())
        return false;

    NP_GetMIMEDescriptionFuncPtr NP_GetMIMEDescription;
    NPP_GetValueProcPtr NPP_GetValue;

    g_module_symbol(m_module, "NP_GetMIMEDescription", (void**)&NP_GetMIMEDescription);
    g_module_symbol(m_module, "NP_GetValue", (void**)&NPP_GetValue);

    char* buffer = 0;
    NPError err = NPP_GetValue(0, NPPVpluginNameString, &buffer);
    if (err == NPERR_NO_ERROR)
        m_name = buffer;

    buffer = 0;
    err = NPP_GetValue(0, NPPVpluginDescriptionString, &buffer);
    if (err == NPERR_NO_ERROR) {
        m_description = buffer;
        m_moduleVersion = getModuleVersion(buffer); 
    }

    const gchar* types = NP_GetMIMEDescription();
    gchar** mimeDescs = g_strsplit(types, ";", -1);
    for (int i = 0; mimeDescs[i] && mimeDescs[i][0]; i++) {
        gchar** mimeData = g_strsplit(mimeDescs[i], ":", 3);
        if (g_strv_length(mimeData) < 3) {
            g_strfreev(mimeData);
            continue;
        }

        String description = String::fromUTF8(mimeData[2]);
        gchar** extensions = g_strsplit(mimeData[1], ",", -1);

        Vector<String> extVector;
        for (int j = 0; extensions[j]; j++)
            extVector.append(String::fromUTF8(extensions[j]));

        determineQuirks(mimeData[0]);
        m_mimeToExtensions.add(mimeData[0], extVector);
        m_mimeToDescriptions.add(mimeData[0], description);

        g_strfreev(extensions);
        g_strfreev(mimeData);
    }
    g_strfreev(mimeDescs);

    return true;
#else
    notImplemented();
    return false;
#endif
}
Esempio n. 2
0
/*--------------------------------------------------------------------------*/
types::Function::ReturnValue sci_getversion(types::typed_list &in, int _iRetCount, types::typed_list &out)
{
    if (in.size() > 2)
    {
        Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), "getversion", 0, 2);
        return types::Function::Error;
    }

    if (in.size() == 0)
    {
        if (_iRetCount != 1 && _iRetCount != 2)
        {
            Scierror(78, _("%s: Wrong number of output argument(s): %d to %d expected.\n"), "getveresion", 1, 2);
            return types::Function::Error;
        }

        wchar_t *pwstVer = getScilabVersionAsWideString();
        types::String* pOut1 = new types::String(pwstVer);
        out.push_back(pOut1);
        FREE(pwstVer);

        if (_iRetCount == 2)
        {
            int iOption = 0;
            wchar_t** pwstOption = getScilabVersionOptions(&iOption);
            types::String* pOut2 = new types::String(1, iOption);
            pOut2->set(pwstOption);
            out.push_back(pOut2);
            freeArrayOfWideString(pwstOption, iOption);
        }

    }
    else if (in.size() == 1)
    {
        if (in[0]->isString() == false || in[0]->getAs<types::String>()->isScalar() == false)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 1);
            return types::Function::Error;
        }

        if (_iRetCount != 1)
        {
            Scierror(78, _("%s: Wrong number of output argument(s): %d expected.\n"), "getveresion", 1);
            return types::Function::Error;
        }

        wchar_t* pwstModule = in[0]->getAs<types::String>()->get()[0];
        if (with_module(pwstModule) || (wcscmp(pwstModule, L"scilab") == 0))
        {
            int versionSize = 0;
            int *version = getModuleVersion(pwstModule, &versionSize);
            if (version == NULL)
            {
                Scierror(999, _("%s: Wrong file version.xml %s.\n"), "getversion", pwstModule);
                return types::Function::Error;
            }

            types::Double* pOut = new types::Double(1, versionSize);
            pOut->setInt(version);
            out.push_back(pOut);
            FREE(version);
        }
    }
    else //in.size() == 2
    {
        if (in[0]->isString() == false || in[0]->getAs<types::String>()->getSize() != 1)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 1);
            return types::Function::Error;
        }

        if (in[1]->isString() == false || in[1]->getAs<types::String>()->getSize() != 1)
        {
            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), "getversion", 2);
            return types::Function::Error;
        }

        wchar_t* pwstModule = in[0]->getAs<types::String>()->get()[0];
        wchar_t* pwstOption = in[1]->getAs<types::String>()->get()[0];

        if ( with_module(pwstModule) || (wcscmp(pwstModule, L"scilab") == 0) )
        {
            if ( wcscmp(pwstOption, VERSION_STRING) == 0)
            {
                wchar_t *pwstInfo = getModuleVersionInfoAsString(pwstModule);
                types::String* pOut = new types::String(pwstInfo);
                out.push_back(pOut);
                FREE(pwstInfo);
            }
        }
    }

    return types::Function::OK;
}