コード例 #1
0
bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin& plugin)
{
        String pathCopy = pluginPath;
    DWORD versionInfoSize = ::GetFileVersionInfoSizeW(pathCopy.charactersWithNullTermination(), 0);
    if (!versionInfoSize)
        return false;

    OwnArrayPtr<char> versionInfoData = adoptArrayPtr(new char[versionInfoSize]);
    if (!::GetFileVersionInfoW(pathCopy.charactersWithNullTermination(), 0, versionInfoSize, versionInfoData.get()))
        return false;

    String name = getVersionInfo(versionInfoData.get(), "ProductName");
    String description = getVersionInfo(versionInfoData.get(), "FileDescription");
    if (name.isNull() || description.isNull())
        return false;

    VS_FIXEDFILEINFO* info;
    UINT infoSize;
    if (!::VerQueryValueW(versionInfoData.get(), L"\\", reinterpret_cast<void**>(&info), &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO))
        return false;

    Vector<String> types;
    getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types);
    Vector<String> extensionLists;
    getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists);
    Vector<String> descriptions;
    getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions);

    Vector<MimeClassInfo> mimes(types.size());
    for (size_t i = 0; i < types.size(); i++) {
        String type = types[i].lower();
        String description = i < descriptions.size() ? descriptions[i] : "";
        String extensionList = i < extensionLists.size() ? extensionLists[i] : "";

        Vector<String> extensionsVector;
        extensionList.split(',', extensionsVector);

        // Get rid of the extension list that may be at the end of the description string.
        int pos = description.find("(*");
        if (pos != -1) {
            // There might be a space that we need to get rid of.
            if (pos > 1 && description[pos - 1] == ' ')
                pos--;
            description = description.left(pos);
        }

        mimes[i].type = type;
        mimes[i].desc = description;
        mimes[i].extensions.swap(extensionsVector);
    }

    plugin.path = pluginPath;
    plugin.info.desc = description;
    plugin.info.name = name;
    plugin.info.file = pathGetFileName(pluginPath);
    plugin.info.mimes.swap(mimes);
    plugin.fileVersion = fileVersion(info->dwFileVersionLS, info->dwFileVersionMS);

    return true;
}
コード例 #2
0
ファイル: objectbase.cpp プロジェクト: heyuqi/wxFormBuilder
void ObjectBase::Serialize( ticpp::Document* serializedDocument )
{
	ticpp::Document document( "document" );

  #if wxUSE_UNICODE
	ticpp::Declaration dec( "1.0", "UTF-8", "yes" );
	#else
	ticpp::Declaration dec( "1.0", "ISO-8859-13", "yes" );
	#endif
	document.LinkEndChild( &dec );

	ticpp::Element root( "wxFormBuilder_Project" );

	ticpp::Element fileVersion( "FileVersion" );
	fileVersion.SetAttribute( "major", AppData()->m_fbpVerMajor );
	fileVersion.SetAttribute( "minor", AppData()->m_fbpVerMinor );

	root.LinkEndChild( &fileVersion );

	ticpp::Element element;
	SerializeObject( &element );

	root.LinkEndChild( &element );
	document.LinkEndChild( &root );

	*serializedDocument = document;
}
コード例 #3
0
void NetscapePluginModule::determineQuirks()
{
    PluginInfoStore::Plugin plugin;
    getPluginInfo(m_pluginPath, plugin);

    Vector<MimeClassInfo> mimeTypes = plugin.info.mimes;
    for (size_t i = 0; i < mimeTypes.size(); ++i) {
        // FIXME: It seems strange to assume that any plugin that handles this MIME type needs this quirk. Should
        // we be be checking the plugin's name instead?
        if (mimeTypes[i].type == "application/x-shockwave-flash") {
            uint64_t flashTenVersion = fileVersion(0x00000000, 0x000a0000);
            uint64_t version = plugin.fileVersion;

            // Pre Flash v10 only requests windowless plugins if we use a Mozilla user agent.
            // For testing information, see: https://bugs.webkit.org/show_bug.cgi?id=60726.
            if (version < flashTenVersion)
                m_pluginQuirks.add(PluginQuirks::WantsMozillaUserAgent);

            break;
        }
    }
}
コード例 #4
0
ファイル: qgsmaplayer.cpp プロジェクト: FlavioFalcao/QGIS
QString QgsMapLayer::loadNamedStyle( const QString &theURI, bool &theResultFlag )
{
  QgsDebugMsg( QString( "uri = %1 myURI = %2" ).arg( theURI ).arg( publicSource() ) );

  theResultFlag = false;

  QDomDocument myDocument( "qgis" );

  // location of problem associated with errorMsg
  int line, column;
  QString myErrorMessage;

  QFile myFile( theURI );
  if ( myFile.open( QFile::ReadOnly ) )
  {
    // read file
    theResultFlag = myDocument.setContent( &myFile, &myErrorMessage, &line, &column );
    if ( !theResultFlag )
      myErrorMessage = tr( "%1 at line %2 column %3" ).arg( myErrorMessage ).arg( line ).arg( column );
    myFile.close();
  }
  else
  {
    QFileInfo project( QgsProject::instance()->fileName() );
    QgsDebugMsg( QString( "project fileName: %1" ).arg( project.absoluteFilePath() ) );

    QString qml;
    if ( loadNamedStyleFromDb( QDir( QgsApplication::qgisSettingsDirPath() ).absoluteFilePath( "qgis.qmldb" ), theURI, qml ) ||
         ( project.exists() && loadNamedStyleFromDb( project.absoluteDir().absoluteFilePath( project.baseName() + ".qmldb" ), theURI, qml ) ) ||
         loadNamedStyleFromDb( QDir( QgsApplication::pkgDataPath() ).absoluteFilePath( "resources/qgis.qmldb" ), theURI, qml ) )
    {
      theResultFlag = myDocument.setContent( qml, &myErrorMessage, &line, &column );
      if ( !theResultFlag )
      {
        myErrorMessage = tr( "%1 at line %2 column %3" ).arg( myErrorMessage ).arg( line ).arg( column );
      }
    }
    else
    {
      myErrorMessage = tr( "style not found in database" );
    }
  }

  if ( !theResultFlag )
  {
    return myErrorMessage;
  }

  // get style file version string, if any
  QgsProjectVersion fileVersion( myDocument.firstChildElement( "qgis" ).attribute( "version" ) );
  QgsProjectVersion thisVersion( QGis::QGIS_VERSION );

  if ( thisVersion > fileVersion )
  {
    QgsLogger::warning( "Loading a style file that was saved with an older "
                        "version of qgis (saved in " + fileVersion.text() +
                        ", loaded in " + QGis::QGIS_VERSION +
                        "). Problems may occur." );

    QgsProjectFileTransform styleFile( myDocument, fileVersion );
    // styleFile.dump();
    styleFile.updateRevision( thisVersion );
    // styleFile.dump();
  }

  // now get the layer node out and pass it over to the layer
  // to deserialise...
  QDomElement myRoot = myDocument.firstChildElement( "qgis" );
  if ( myRoot.isNull() )
  {
    myErrorMessage = tr( "Error: qgis element could not be found in %1" ).arg( theURI );
    theResultFlag = false;
    return myErrorMessage;
  }

  // use scale dependent visibility flag
  toggleScaleBasedVisibility( myRoot.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 );
  setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
  setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );

#if 0
  //read transparency level
  QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
  if ( ! transparencyNode.isNull() )
  {
    // set transparency level only if it's in project
    // (otherwise it sets the layer transparent)
    QDomElement myElement = transparencyNode.toElement();
    setTransparency( myElement.text().toInt() );
  }
#endif

  QString errorMsg;
  theResultFlag = readSymbology( myRoot, errorMsg );
  if ( !theResultFlag )
  {
    myErrorMessage = tr( "Loading style file %1 failed because:\n%2" ).arg( theURI ).arg( errorMsg );
    return myErrorMessage;
  }

  return "";
}
コード例 #5
0
ファイル: PluginInfoStoreWin.cpp プロジェクト: dzhshf/WebKit
bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
{
    if (plugin.info.name == "Citrix ICA Client") {
        // The Citrix ICA Client plug-in requires a Mozilla-based browser; see <rdar://6418681>.
        return false;
    }

    if (plugin.info.name == "Silverlight Plug-In") {
        // workaround for <rdar://5557379> Crash in Silverlight when opening microsoft.com.
        // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it
        // and any newer versions
        static const uint64_t minimumRequiredVersion = fileVersion(0x51BE0000, 0x00010000);
        return plugin.fileVersion >= minimumRequiredVersion;
    }

    if (equalIgnoringCase(plugin.info.file, "npmozax.dll")) {
        // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll
        return false;
    }

    if (equalIgnoringCase(plugin.info.file, "npwpf.dll")) {
        // Bug 57119: Microsoft Windows Presentation Foundation (WPF) plug-in complains about missing xpcom.dll
        return false;
    }

    if (plugin.info.name == "Yahoo Application State Plugin") {
        // https://bugs.webkit.org/show_bug.cgi?id=26860
        // Bug in Yahoo Application State plug-in earlier than 1.0.0.6 leads to heap corruption.
        static const uint64_t minimumRequiredVersion = fileVersion(0x00000006, 0x00010000);
        return plugin.fileVersion >= minimumRequiredVersion;
    }

    if (isOldWindowsMediaPlayerPlugin(plugin)) {
        // Don't load the old Windows Media Player plugin if we've already loaded the new Windows
        // Media Player plugin.
        for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
            if (!isNewWindowsMediaPlayerPlugin(alreadyLoadedPlugins[i]))
                continue;
            return false;
        }
        return true;
    }

    if (isNewWindowsMediaPlayerPlugin(plugin)) {
        // Remove the old Windows Media Player plugin if we've already added it.
        for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
            if (!isOldWindowsMediaPlayerPlugin(alreadyLoadedPlugins[i]))
                continue;
            alreadyLoadedPlugins.remove(i);
        }
        return true;
    }

    // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading
    // only the first. <http://webkit.org/b/58469>
    String pluginFileName = pathGetFileName(plugin.path);
    for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
        const PluginModuleInfo& loadedPlugin = alreadyLoadedPlugins[i];

        // If a plug-in with the same filename already exists, we don't want to load it.
        if (equalIgnoringCase(pluginFileName, pathGetFileName(loadedPlugin.path)))
            return false;
    }

    return true;
}