Ejemplo n.º 1
0
void MainWindow::loadSettings()
{
  QVariant geometry     = m_settings.value(QString::fromAscii("main/geometry"), QVariant::Invalid);
  QVariant state        = m_settings.value(QString::fromAscii("main/state"),    QVariant::Invalid);
  QVariant wizState     = m_settings.value(QString::fromAscii("wizard/state"),  QVariant::Invalid);
  QVariant loadSettings = m_settings.value(QString::fromAscii("wizard/loadsettings"),  QVariant::Invalid);
  QVariant workingDir   = m_settings.value(QString::fromAscii("wizard/workingdir"), QVariant::Invalid);

  if (geometry  !=QVariant::Invalid) restoreGeometry(geometry.toByteArray());
  if (state     !=QVariant::Invalid) restoreState   (state.toByteArray());
  if (wizState  !=QVariant::Invalid) m_wizard->restoreState(wizState.toByteArray());
  if (loadSettings!=QVariant::Invalid && loadSettings.toBool())
  {
    m_expert->loadSettings(&m_settings);
    if (workingDir!=QVariant::Invalid && QDir(workingDir.toString()).exists())
    {
      setWorkingDir(workingDir.toString());
    }
  }

  for (int i=0;i<MAX_RECENT_FILES;i++)
  {
    QString entry = m_settings.value(QString().sprintf("recent/config%d",i)).toString();
    if (!entry.isEmpty() && QFileInfo(entry).exists())
    {
      addRecentFile(entry);
    }
  }

}
Ejemplo n.º 2
0
void test_suite:: init(const std::string &dir){
	setWorkingDir(dir);
	if(fp)
	{
		fclose(fp);
		fp = NULL;
	}
	if(getWorkingDir().size()>0)
	{	
        
		std::string filePath(dir);
        if(filePath[filePath.length()-1]!='/' || filePath[filePath.length()-1] != '\\'){
            filePath.append("/");
        }
		filePath.append("test_performance.csv");

		fp=fopen(filePath.c_str(),"a+");
	}
	else
	{
		fp=fopen("test_performance.csv","a+");
	}

	printHeading();
}
Ejemplo n.º 3
0
void MainWindow::selectWorkingDir()
{
  QString dirName = QFileDialog::getExistingDirectory(this,
        tr("Select working directory"),m_workingDir->text());
  if (!dirName.isEmpty())
  {
    setWorkingDir(dirName);
  }
}
Ejemplo n.º 4
0
void MainWindow::updateConfigFileName(const QString &fileName)
{
  if (m_fileName!=fileName)
  {
    m_fileName = fileName;
    QString curPath = QFileInfo(fileName).path();
    setWorkingDir(curPath);
    addRecentFile(fileName);
    updateTitle();
  }
}
Ejemplo n.º 5
0
VideoConverter::VideoConverter(QString ffmpegApp, QString workingDir,
                               VideoConversionConfig convConf, bool deleteOriginalVideo)
{
	setObjectName("VideoConverter");
	// set vars
	setFFmpegApp(ffmpegApp);
	setWorkingDir(workingDir);
	setConversionConfig(convConf);
	setDeleteOriginalVideo(deleteOriginalVideo);
	//
	internalTimer = 0;
	// create a new qprocess
	ffmpegProcess = new QProcess();
	// connect signals
	connect(ffmpegProcess, SIGNAL(started()), this, SLOT(started()));
	connect(ffmpegProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
	connect(ffmpegProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
	connect(ffmpegProcess, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
	// cofnigure process
	ffmpegProcess->setWorkingDirectory(workingDir);
}
Ejemplo n.º 6
0
void MainWindow::updateWorkingDir()
{
  setWorkingDir(m_workingDir->text());
}
Ejemplo n.º 7
0
void configManager::loadConfigFile()
{
	// read the XML file and create DOM tree
	QFile cfg_file( m_lmmsRcFile );
	QDomDocument dom_tree;

	if( cfg_file.open( QIODevice::ReadOnly ) )
	{
		QString errorString;
		int errorLine, errorCol;
		if( dom_tree.setContent( &cfg_file, false, &errorString, &errorLine, &errorCol ) )
		{
			// get the head information from the DOM
			QDomElement root = dom_tree.documentElement();

			QDomNode node = root.firstChild();

			// create the settings-map out of the DOM
			while( !node.isNull() )
			{
				if( node.isElement() &&
					node.toElement().hasAttributes () )
				{
					stringPairVector attr;
					QDomNamedNodeMap node_attr =
						node.toElement().attributes();
					for( int i = 0; i < node_attr.count();
									++i )
					{
		QDomNode n = node_attr.item( i );
		if( n.isAttr() )
		{
			attr.push_back( qMakePair( n.toAttr().name(),
							n.toAttr().value() ) );
		}
					}
					m_settings[node.nodeName()] = attr;
				}
				else if( node.nodeName() == "recentfiles" )
				{
					m_recentlyOpenedProjects.clear();
					QDomNode n = node.firstChild();
					while( !n.isNull() )
					{
		if( n.isElement() && n.toElement().hasAttributes() )
		{
			m_recentlyOpenedProjects <<
					n.toElement().attribute( "path" );
		}
		n = n.nextSibling();
					}
				}
				node = node.nextSibling();
			}

			if( value( "paths", "artwork" ) != "" )
			{
				m_artworkDir = value( "paths", "artwork" );
				if( !QDir( m_artworkDir ).exists() )
				{
					m_artworkDir = defaultArtworkDir();
				}
				if( m_artworkDir.right( 1 ) !=
							QDir::separator() )
				{
					m_artworkDir += QDir::separator();
				}
			}
			setWorkingDir( value( "paths", "workingdir" ) );
			setVSTDir( value( "paths", "vstdir" ) );
			setFLDir( value( "paths", "fldir" ) );
			setLADSPADir( value( "paths", "laddir" ) );
		#ifdef LMMS_HAVE_STK
			setSTKDir( value( "paths", "stkdir" ) );
		#endif
		#ifdef LMMS_HAVE_FLUIDSYNTH
			setDefaultSoundfont( value( "paths", "defaultsf2" ) );
		#endif
			setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
		}
		else
		{
			QMessageBox::warning( NULL, MainWindow::tr( "Configuration file" ),
									MainWindow::tr( "Error while parsing configuration file at line %1:%2: %3" ).
													arg( errorLine ).
													arg( errorCol ).
													arg( errorString ) );
		}
		cfg_file.close();
	}


	if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() ||
			!QDir( m_vstDir ).exists() )
	{
#ifdef LMMS_BUILD_WIN32
		m_vstDir = windowsConfigPath( CSIDL_PROGRAM_FILES ) +
											QDir::separator() + "VstPlugins";
#else
		m_vstDir = ensureTrailingSlash( QDir::home().absolutePath() );
#endif
	}

	if( m_flDir.isEmpty() || m_flDir == QDir::separator() )
	{
		m_flDir = ensureTrailingSlash( QDir::home().absolutePath() );
	}

	if( m_ladDir.isEmpty() || m_ladDir == QDir::separator() ||
			( !m_ladDir.contains( ':' ) && !QDir( m_ladDir ).exists() ) )
	{
#if defined(LMMS_BUILD_WIN32)
		m_ladDir = m_pluginDir + "ladspa" + QDir::separator();
#elif defined(LMMS_BUILD_APPLE)
		m_ladDir = qApp->applicationDirPath() + "/../lib/lmms/ladspa/";
#else
		m_ladDir = qApp->applicationDirPath() + '/' + LIB_DIR + "/ladspa/";
#endif
	}

#ifdef LMMS_HAVE_STK
	if( m_stkDir.isEmpty() || m_stkDir == QDir::separator() ||
			!QDir( m_stkDir ).exists() )
	{
#if defined(LMMS_BUILD_WIN32)
		m_stkDir = m_dataDir + "stk/rawwaves/";
#elif defined(LMMS_BUILD_APPLE)
		m_stkDir = qApp->applicationDirPath() + "/../share/stk/rawwaves/";
#else
		m_stkDir = "/usr/share/stk/rawwaves/";
#endif
	}
#endif


	QDir::setSearchPaths( "resources", QStringList() << artworkDir()
						<< defaultArtworkDir() );

	if( !QDir( m_workingDir ).exists() )
	{
		if( QMessageBox::question( 0,
			MainWindow::tr( "Working directory" ),
			MainWindow::tr( "The LMMS working directory %1 does not "
				"exist. Create it now? You can change the directory "
				"later via Edit -> Settings." ).arg( m_workingDir ),
					QMessageBox::Yes, QMessageBox::No ) ==
								QMessageBox::Yes )
		{
			QDir().mkpath( m_workingDir );
		}
	}
	if( QDir( m_workingDir ).exists() )
	{
		QDir().mkpath( userProjectsDir() );
		QDir().mkpath( userSamplesDir() );
		QDir().mkpath( userPresetsDir() );
	}
}
Ejemplo n.º 8
0
void Awstats::config(HttpVHost *pVHost, int val, char* achBuf, const XmlNode *pAwNode, 
              char* iconURI, const char* vhDomain, int vhAliasesLen )
{
    const char *pURI;
    const char *pValue;
    char *p;
    int handlerType;
    int len = strlen( achBuf );
    int iChrootLen = 0;
    if ( HttpGlobals::s_psChroot != NULL )
    iChrootLen = HttpGlobals::s_psChroot->len();
    setMode( val );
    

    if ( achBuf[len - 1] == '/' )
        achBuf[len - 1] = 0;

    setWorkingDir( achBuf );

    pURI = pAwNode->getChildValue( "awstatsURI" );

    if ( ( !pURI ) || ( *pURI != '/' ) || ( * ( pURI + strlen( pURI ) - 1 ) != '/' )
            || ( strlen( pURI ) > 100 ) )
    {
        ConfigCtx::getCurConfigCtx()->log_warn( "AWStats URI is invalid"
                             ", use default [/awstats/]." );
        iconURI[9] = 0;;
        pURI = iconURI;
    }

    setURI( pURI );

    if ( val == AWS_STATIC )
    {
        handlerType = HandlerType::HT_NULL;
        strcat( achBuf, "/html/" );
    }
    else
    {
        ConfigCtx::getCurConfigCtx()->getValidPath( achBuf, "$SERVER_ROOT/add-ons/awstats/wwwroot/cgi-bin/",
                      "AWStats CGI-BIN directory" );

        if ( pVHost->getRootContext().determineMime( "pl", NULL )->getHandler()->getHandlerType() )
            handlerType = HandlerType::HT_NULL;
        else
            handlerType = HandlerType::HT_CGI;
    }

    HttpContext *pContext =
        pVHost->addContext( pURI, handlerType, &achBuf[iChrootLen], NULL, 1 );

    p = achBuf;
    if ( ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "securedConn", 0, 1, 0 ) == 1 )
    {
        p += safe_snprintf( achBuf, 8192,
                "rewriteCond %%{HTTPS} !on\n"
                "rewriteCond %%{HTTP:X-Forwarded-Proto} !https\n"
                "rewriteRule ^(.*)$ https://%%{SERVER_NAME}%%{REQUEST_URI} [R,L]\n" );

    }
    if ( val == AWS_STATIC )
    {
        safe_snprintf( p, &achBuf[8192] - p,
                       "RewriteRule ^$ awstats.%s.html\n",
                       pVHost->getName() );
    }
    else
    {
        safe_snprintf( p, &achBuf[8192] - p, 
                       "RewriteRule ^$ awstats.pl\n"
                       "RewriteCond %%{QUERY_STRING} !configdir=\n"
                       "RewriteRule ^awstats.pl "
                       "$0?config=%s&configdir=%s/conf [QSA]\n",
                       pVHost->getName(),
                       getWorkingDir() + iChrootLen );
        pContext->setUidMode( UID_DOCROOT );
    }

    pContext->enableRewrite( 1 );
    pContext->configRewriteRule( pVHost->getRewriteMaps(), achBuf );

    pValue = pAwNode->getChildValue( "realm" );

    if ( pValue )
        pVHost->configAuthRealm( pContext, pValue );

    pValue = pAwNode->getChildValue( "siteDomain" );

    if ( !pValue )
    {
        ConfigCtx::getCurConfigCtx()->log_warn( "SiteDomain configuration is invalid"
                             ", use default [%s].",  vhDomain );
        pValue = vhDomain;
    }
    else
    {
        ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, achBuf, 4096 );
        pValue = achBuf;
    }

    setSiteDomain( pValue );

    pValue = pAwNode->getChildValue( "siteAliases" );
    int needConvert = 1;

    if ( !pValue )
    {
        if ( vhAliasesLen == 0 )
        {
            safe_snprintf( achBuf, 8192, "127.0.0.1 localhost REGEX[%s]",
                           getSiteDomain() );
            ConfigCtx::getCurConfigCtx()->log_warn( "SiteAliases configuration is invalid"
                                 ", use default [%s].", achBuf );
            pValue = achBuf;
            needConvert = 0;
        }
        else
            pValue = "$vh_aliases";
    }

    if ( needConvert )
    {
        ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, &achBuf[4096], 4096, ' ' );
        ConfigCtx::getCurConfigCtx()->convertToRegex( &achBuf[4096], achBuf, 4096 );
        pValue = achBuf;
        ConfigCtx::getCurConfigCtx()->log_info( "SiteAliases is set to '%s'", achBuf );
    }

    setAliases( pValue );

    val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateInterval", 3600, 3600 * 24, 3600 * 24 );

    if ( val % 3600 != 0 )
        val = ( ( val + 3599 ) / 3600 ) * 3600;

    setInterval( val );

    val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateOffset", 0, LONG_MAX, 0 );

    if ( val > getInterval() )
        val %= getInterval();

    setOffset( val );

    pVHost->setAwstats( this );    
}
Ejemplo n.º 9
0
/***************************************************************
* Function: main()
* Purpose : Command-line entry point function
* Initial : Maxime Chevalier-Boisvert on October 19, 2008
* Modified: Nurudeen A. Lameed on May 5, 2009.
****************************************************************
Revisions and bug fixes:
*/
int main(int argc, char** argv)
{
    // Print the McVM header
    std::cout << "*******************************************************" << std::endl;
    std::cout << "         McVM - The McLab Virtual Machine v1.0         " << std::endl;
    std::cout << "Visit http://www.sable.mcgill.ca for more information. " << std::endl;
    std::cout << "*******************************************************" << std::endl;
    std::cout << std::endl;

    // Initialize the config manager
    ConfigManager::initialize();

    // Initialize the interpreter
    Interpreter::initialize();

    // Initialize the JIT compiler
    JITCompiler::initialize();

    // Initialize the profiler
    Profiler::initialize();

    // Parse the command-line arguments
    ConfigManager::parseCmdArgs(argc, argv);

    // TODO NAL: get host name and port from Config ...
    // create and connect to natlab (server mode)
    Client::openSocketStream(Client::FRONTEND_DEFAULT_HOST, Client::FRONTEND_DEFAULT_PORT);

    // Load the standard library
    mcvm::stdlib::loadLibrary();

    // Change to the starting directory
    bool cdResult = setWorkingDir(ConfigManager::s_startDirVar.getStringValue());

    // If the directory change failed
    if (cdResult == false)
    {
        // Print out a warning message
        std::cout << "WARNING: could not change to specified starting directory" << std::endl;
    }

    // If the target file name was set
    if (ConfigManager::getFileName() != "")
    {
        // Setup a try block to catch errors
        try
        {
            // Attempt to run the target file as an M-file
            Interpreter::callByName(ConfigManager::getFileName());
        }

        // If any error occurs
        catch (RunError error)
        {
            // Print the run-time error
            std::cout << std::endl << "Run-time error: " << std::endl << error.toString() << std::endl;
        }
    }

    // Otherwise, by default
    else
    {
        // Run the read-eval-print loop
        runREPLoop();
    }

    // Close the interface to Natlab
    Client::shutdown();

    // Shut down the JIT compiler
    JITCompiler::shutdown();

    // Nothing went wrong
    return 0;
}