コード例 #1
0
ファイル: Common.cpp プロジェクト: martinpaljak/qt-common
QString Common::applicationOs()
{
#if defined(Q_OS_LINUX)
	QProcess p;
	p.start( "lsb_release", QStringList() << "-s" << "-d" );
	p.waitForFinished();
	return QString::fromLocal8Bit( p.readAll().trimmed() );
#elif defined(Q_OS_MAC)
	struct utsname unameData;
	uname( &unameData );
	QFile f( "/System/Library/CoreServices/SystemVersion.plist" );
	if( f.open( QFile::ReadOnly ) )
	{
		QXmlStreamReader xml( &f );
		while( xml.readNext() != QXmlStreamReader::Invalid )
		{
			if( !xml.isStartElement() || xml.name() != "key" || xml.readElementText() != "ProductVersion" )
				continue;
			xml.readNextStartElement();
			return QString( "Mac OS %1 (%2/%3)" )
				.arg( xml.readElementText() ).arg( QSysInfo::WordSize ).arg( unameData.machine );
		}
	}
#elif defined(Q_OS_WIN)
	OSVERSIONINFOEX osvi = { sizeof( OSVERSIONINFOEX ) };
	if( GetVersionEx( (OSVERSIONINFO *)&osvi ) )
	{
		bool workstation = osvi.wProductType == VER_NT_WORKSTATION;
		SYSTEM_INFO si;
		typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
		if( PGNSI pGNSI = PGNSI( QLibrary( "kernel32" ).resolve( "GetNativeSystemInfo" ) ) )
			pGNSI( &si );
		else
			GetSystemInfo( &si );
		QString os;
		switch( (osvi.dwMajorVersion << 8) + osvi.dwMinorVersion )
		{
		case 0x0500: os = workstation ? "2000 Professional" : "2000 Server"; break;
		case 0x0501: os = osvi.wSuiteMask & VER_SUITE_PERSONAL ? "XP Home" : "XP Professional"; break;
		case 0x0502:
			if( GetSystemMetrics( SM_SERVERR2 ) )
				os = "Server 2003 R2";
			else if( workstation && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
				os = "XP Professional";
			else
				os = "Server 2003";
			break;
		case 0x0600: os = workstation ? "Vista" : "Server 2008"; break;
		case 0x0601: os = workstation ? "7" : "Server 2008 R2"; break;
		case 0x0602: os = workstation ? "8" : "Server 2012"; break;
		case 0x0603: os = workstation ? "8.1" : "Server 2012 R2"; break;
		case 0x0A00: os = workstation ? "10" : "Server 10"; break;
		default: break;
		}
		QString extversion( (const QChar*)osvi.szCSDVersion );
		return QString( "Windows %1 %2(%3 bit)" ).arg( os )
			.arg( extversion.isEmpty() ? "" : extversion + " " )
			.arg( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ? "64" : "32" );
	}
コード例 #2
0
ファイル: Plugin.cpp プロジェクト: Penguinum/lmms
void Plugin::getDescriptorsOfAvailPlugins( DescriptorList& pluginDescriptors )
{
	QDir directory( ConfigManager::inst()->pluginDir() );
#ifdef LMMS_BUILD_WIN32
	QFileInfoList list = directory.entryInfoList( QStringList( "*.dll" ) );
#else
	QFileInfoList list = directory.entryInfoList( QStringList( "lib*.so" ) );
#endif
	foreach( const QFileInfo& f, list )
	{
		QLibrary( f.absoluteFilePath() ).load();
	}
コード例 #3
0
DictionaryProviderVoikko::DictionaryProviderVoikko()
{
	if (f_voikko_loaded) {
		return;
	}

	QString lib = "libvoikko";
#ifdef Q_OS_WIN
	QStringList dictdirs = QDir::searchPaths("dict");
	foreach (const QString dictdir, dictdirs) {
		lib = dictdir + "/libvoikko-1.dll";
		if (QLibrary(lib).load()) {
			f_voikko_path = QFile::encodeName(QDir::toNativeSeparators(QFileInfo(lib).path()));
			break;
		}
	}
コード例 #4
0
ファイル: PluginFactory.cpp プロジェクト: JohannesLorenz/lmms
void PluginFactory::discoverPlugins()
{
	DescriptorMap descriptors;
	PluginInfoList pluginInfos;
	m_pluginByExt.clear();

	QSet<QFileInfo> files;
	for (const QString& searchPath : QDir::searchPaths("plugins"))
	{
		files.unite(QDir(searchPath).entryInfoList(nameFilters).toSet());
	}

	// Cheap dependency handling: zynaddsubfx needs ZynAddSubFxCore. By loading
	// all libraries twice we ensure that libZynAddSubFxCore is found.
	for (const QFileInfo& file : files)
	{
		QLibrary(file.absoluteFilePath()).load();
	}

	for (const QFileInfo& file : files)
	{
		auto library = std::make_shared<QLibrary>(file.absoluteFilePath());
		if (! library->load()) {
			m_errors[file.baseName()] = library->errorString();
			qWarning("%s", library->errorString().toLocal8Bit().data());
			continue;
		}

		Plugin::Descriptor* pluginDescriptor = nullptr;
		if (library->resolve("lmms_plugin_main"))
		{
			QString descriptorName = file.baseName() + "_plugin_descriptor";
			if( descriptorName.left(3) == "lib" )
			{
				descriptorName = descriptorName.mid(3);
			}

			pluginDescriptor = reinterpret_cast<Plugin::Descriptor*>(library->resolve(descriptorName.toUtf8().constData()));
			if(pluginDescriptor == nullptr)
			{
				qWarning() << qApp->translate("PluginFactory", "LMMS plugin %1 does not have a plugin descriptor named %2!").
							  arg(file.absoluteFilePath()).arg(descriptorName);
				continue;
			}
		}

		if(pluginDescriptor)
		{
			PluginInfo info;
			info.file = file;
			info.library = library;
			info.descriptor = pluginDescriptor;
			pluginInfos << info;

			auto addSupportedFileTypes =
				[this](QString supportedFileTypes,
					const PluginInfo& info,
					const Plugin::Descriptor::SubPluginFeatures::Key* key = nullptr)
			{
				if(!supportedFileTypes.isNull())
				{
					for (const QString& ext : supportedFileTypes.split(','))
					{
						//qDebug() << "Plugin " << info.name()
						//	<< "supports" << ext;
						PluginInfoAndKey infoAndKey;
						infoAndKey.info = info;
						infoAndKey.key = key
							? *key
							: Plugin::Descriptor::SubPluginFeatures::Key();
						m_pluginByExt.insert(ext, infoAndKey);
					}
				}
			};

			if (info.descriptor->supportedFileTypes)
				addSupportedFileTypes(QString(info.descriptor->supportedFileTypes), info);

			if (info.descriptor->subPluginFeatures)
			{
				Plugin::Descriptor::SubPluginFeatures::KeyList
					subPluginKeys;
				info.descriptor->subPluginFeatures->listSubPluginKeys(
					info.descriptor,
					subPluginKeys);
				for(const Plugin::Descriptor::SubPluginFeatures::Key& key
					: subPluginKeys)
				{
					addSupportedFileTypes(key.additionalFileExtensions(), info, &key);
				}
			}

			descriptors.insert(info.descriptor->type, info.descriptor);
		}
	}

	m_pluginInfos = pluginInfos;
	m_descriptors = descriptors;
}
コード例 #5
0
ファイル: Common.cpp プロジェクト: Krabi/idkaart_public
QString Common::applicationOs()
{
#if defined(Q_OS_LINUX)
	QProcess p;
	p.start( "lsb_release", QStringList() << "-s" << "-d" );
	p.waitForFinished();
	return QString::fromLocal8Bit( p.readAll().trimmed() );
#elif defined(Q_OS_MAC)
	struct utsname unameData;
	uname(&unameData);
	SInt32 major, minor, bugfix;
	if( Gestalt(gestaltSystemVersionMajor, &major) == noErr &&
			Gestalt(gestaltSystemVersionMinor, &minor) == noErr &&
			Gestalt(gestaltSystemVersionBugFix, &bugfix) == noErr )
		return QString( "Mac OS %1.%2.%3 (%4/%5)" )
			.arg( major ).arg( minor ).arg( bugfix ).arg( QSysInfo::WordSize ).arg( unameData.machine );
	else
		return QString( "Mac OS 10.3 (%1)" ).arg( QSysInfo::WordSize );
#elif defined(Q_OS_WIN)
	QString os;
	OSVERSIONINFOEX osvi = { sizeof( OSVERSIONINFOEX ) };
	bool is64bit = false;
	if( GetVersionEx( (OSVERSIONINFO *)&osvi ) )
	{
		SYSTEM_INFO si;
		typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
		if( PGNSI pGNSI = PGNSI( QLibrary( "kernel32" ).resolve( "GetNativeSystemInfo" ) ) )
			pGNSI( &si );
		else
			GetSystemInfo( &si );
		switch( osvi.dwMajorVersion )
		{
		case 5:
			switch( osvi.dwMinorVersion )
			{
			case 0:
				os = QString( "Windows 2000 %1" ).arg( osvi.wProductType == VER_NT_WORKSTATION ? "Professional" : "Server" );
				break;
			case 1:
				os = QString( "Windows XP %1" ).arg( osvi.wSuiteMask & VER_SUITE_PERSONAL ? "Home" : "Professional" );
				break;
			case 2:
				if( GetSystemMetrics( SM_SERVERR2 ) )
					os = "Windows Server 2003 R2";
				else if( osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
				{
					is64bit = true;
					os = "Windows XP Professional";
				} else {
					os = "Windows Server 2003";
					if ( osvi.wProductType != VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
						is64bit = true;
				}
				break;
			default: break;
			}
			break;
		case 6:
			switch( osvi.dwMinorVersion )
			{
			case 0:
				os = osvi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008";
				break;
			case 1:
				os = osvi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2";
				break;
			case 2:
				os = osvi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 8";
				break;
			}
			if ( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
				is64bit = true;
			break;
		default: break;
		}
	}
コード例 #6
0
ファイル: PluginFactory.cpp プロジェクト: Lukas-W/lmms
void PluginFactory::discoverPlugins()
{
	DescriptorMap descriptors;
	PluginInfoList pluginInfos;
	m_pluginByExt.clear();

	QSet<QFileInfo> files;
	for (const QString& searchPath : QDir::searchPaths("plugins"))
	{
		files.unite(QDir(searchPath).entryInfoList(nameFilters).toSet());
	}

	// Cheap dependency handling: zynaddsubfx needs ZynAddSubFxCore. By loading
	// all libraries twice we ensure that libZynAddSubFxCore is found.
	for (const QFileInfo& file : files)
	{
		QLibrary(file.absoluteFilePath()).load();
	}

	for (const QFileInfo& file : files)
	{
		auto library = std::make_shared<QLibrary>(file.absoluteFilePath());

		if (! library->load()) {
			m_errors[file.baseName()] = library->errorString();
			qWarning("%s", library->errorString().toLocal8Bit().data());
			continue;
		}
		if (library->resolve("lmms_plugin_main") == nullptr) {
			continue;
		}

		QString descriptorName = file.baseName() + "_plugin_descriptor";
		if( descriptorName.left(3) == "lib" )
		{
			descriptorName = descriptorName.mid(3);
		}

		Plugin::Descriptor* pluginDescriptor = reinterpret_cast<Plugin::Descriptor*>(library->resolve(descriptorName.toUtf8().constData()));
		if(pluginDescriptor == nullptr)
		{
			qWarning() << qApp->translate("PluginFactory", "LMMS plugin %1 does not have a plugin descriptor named %2!").
						  arg(file.absoluteFilePath()).arg(descriptorName);
			continue;
		}

		PluginInfo info;
		info.file = file;
		info.library = library;
		info.descriptor = pluginDescriptor;
		pluginInfos << info;

		for (const QString& ext : QString(info.descriptor->supportedFileTypes).split(','))
		{
			m_pluginByExt.insert(ext, info);
		}

		descriptors.insert(info.descriptor->type, info.descriptor);
	}

	m_pluginInfos = pluginInfos;
	m_descriptors = descriptors;
}