Esempio n. 1
2
 void read_arguments(po::variables_map& arguments) {
     if (arguments.count("lumi") == 0) {
         TERMINATE("No Luminosity specified!");
     }
     if (arguments.count("xs") == 0) {
         TERMINATE("No cross-section file specified!");
     }
     std::ifstream xsf(xs_file);
     FATAL_ASSERT(xsf.good(), "Couldn't read xs file");
     while(!xsf.eof()) {
         std::string _ln;
         std::getline(xsf, _ln);
         if (_ln.size() < 2) continue;
         if (_ln[0] == '#') continue;
         std::stringstream ln(_ln);
         int run; double w, k, filt;
         ln >> std::skipws;
         ln >> run >> w;
         if (ln.fail()) {
             WARNING("Failed to read line: ", ln.str());
             continue;
         }
         ln >> k >> filt;
         if (!ln.fail()) w *= k*filt;
         xs[run] = w;
     }
 }
Esempio n. 2
2
    void ProcessVariables(const po::variables_map& variables) override {
        IndexWriterConfig.Verbose = variables.count("verbose");
        if (variables.count("chunk-size"))
            IndexWriterConfig.ChunkSize = variables["chunk-size"].as<size_t>();

        Home = variables["home"].as<std::string>();
        Proxy = variables["proxy"].as<std::string>();
    }
bool ThorScriptParserStage::parseOptions(po::variables_map& vm)
{
	debug_parser = (vm.count("debug-parser") > 0);
	debug_ast = (vm.count("debug-parser-ast") > 0);
	debug_ast_with_loc = (vm.count("debug-parser-ast-with-loc") > 0);
	use_relative_path = (vm.count("use-relative-path") > 0);
	dump_graphviz = (vm.count("dump-graphviz") > 0);
    if(vm.count("dump-graphviz-dir") > 0)
    {
        dump_graphviz_dir = vm["dump-graphviz-dir"].as<std::string>();
    }
    if(vm.count("prepand-package"))
    {
        prepand_package = vm["prepand-package"].as<std::string>();
    }

	if(vm.count("root-dir") == 0)
		root_dir = boost::filesystem::current_path() / "src";
	else
	{
		root_dir = vm["root-dir"].as<std::string>();
		root_dir = normalize_path(root_dir);
	}

	if(vm.count("input") == 0)
		return false;

	inputs = vm["input"].as<std::vector<std::string>>();
	return true;
}
Esempio n. 4
1
//从vm导入配置信息到pmdOptions
//vm[PMD_OPTION_CONFPATH]  -> _confPath
//"./"CONFFILENAME -> _confPath
int pmdOptions::importVM ( const po::variables_map &vm, bool isDefault )
{
	int rc = EDB_OK ;
	
	const char *p = NULL ;
	
	// conf path
	if ( vm.count ( PMD_OPTION_CONFPATH ) )
	{
		p = vm[PMD_OPTION_CONFPATH].as<string>().c_str() ;
		strncpy ( _confPath, p, OSS_MAX_PATHSIZE ) ;
	}
	else if ( isDefault )
	{
		strcpy ( _confPath, "./"CONFFILENAME ) ;
	}
	
	// log path
	if ( vm.count ( PMD_OPTION_LOGPATH ) )
	{
		p = vm[PMD_OPTION_LOGPATH].as<string>().c_str() ;
		strncpy ( _logPath, p, OSS_MAX_PATHSIZE ) ;
	}
	else if ( isDefault )
	{
		strcpy ( _logPath, "./"LOGFILENAME ) ;
	}
	
	// db file path
	if ( vm.count ( PMD_OPTION_DBPATH ) )
	{
		p = vm[PMD_OPTION_DBPATH].as<string>().c_str() ;
		strncpy ( _dbPath, p, OSS_MAX_PATHSIZE ) ;
	}
	else if ( isDefault )
	{
		strcpy ( _dbPath, "./"DBFILENAME ) ;
	}
	
	// maxpool
	if ( vm.count ( PMD_OPTION_MAXPOOL ) )
	{
		_maxPool = vm [ PMD_OPTION_MAXPOOL ].as<unsigned int> () ;
	}
	else if ( isDefault )
	{
		_maxPool = NUMPOOL ;
	}
	
	return rc ;
}
Esempio n. 5
0
    void ProcessVariables(const po::variables_map& variables) override {
        ListerConfig.Verbose = variables.count("verbose");
        ListerConfig.Recursive = variables["recursive"].as<bool>();
        ListerConfig.IgnoreHidden = variables.count("hidden");

        IndexWriterConfig.Verbose = variables.count("verbose");

        DocsPath = variables["path"].as<std::string>();
        IndexPath = variables["index"].as<std::string>();
    }
Esempio n. 6
0
void options_io::filterate( po::variables_map const & vm )
{
	if( !vm.count("out") ){
		// TODO: Guess output from input.
	}

	if( !vm.count("export-as") ){
		fmt = llvm_ir;
	} else {
		to_lower(fmt_str);
		if( fmt_str == "llvm" || fmt_str == "llvm_ir" ){
			fmt = llvm_ir;
		}
	}
}
Esempio n. 7
0
bool SceneParameters::_parse( const po::variables_map& vm )
{
    if( vm.count( PARAM_TIMESTAMP ))
        _timestamp = vm[PARAM_TIMESTAMP].as< size_t >( );

    return true;
}
Esempio n. 8
0
  int parse( const int & argc, char * argv[] ) {
    try {
      po::positional_options_description p;
      po::store(
        po::command_line_parser(argc, argv)
           .options( descriptions )
           .positional( p ) // we don't support positional parameters for now
           .run(),
        map );
      po::notify( map );

      if ( map.count("help") ) {
        printUsage( std::cout ) << std::endl;
        return EXIT_SUCCESS;
      } else
        return -1;
    } catch ( const std::exception & e ) {
      std::cerr << "command line parsing error: " << e.what() << std::endl;
      printUsage( std::cerr ) << std::endl;
      return EXIT_FAILURE;
    } catch(...) {
      std::cerr << "command line parsing error:  Unknown error!" << std::endl;
      printUsage( std::cerr ) << std::endl;
      return EXIT_FAILURE;
    }
  }
Esempio n. 9
0
   // initialize options
   INT32 initArgs ( INT32 argc, CHAR **argv, po::variables_map &vm )
   {
      INT32 rc = SDB_OK ;
      po::options_description desc ( "Command options" ) ;
      po::options_description all ( "Command options" ) ;

      PMD_ADD_PARAM_OPTIONS_BEGIN ( all )
         COMMANDS_OPTIONS
         COMMANDS_HIDE_OPTIONS
      PMD_ADD_PARAM_OPTIONS_END

      PMD_ADD_PARAM_OPTIONS_BEGIN ( desc )
         COMMANDS_OPTIONS
      PMD_ADD_PARAM_OPTIONS_END

      // validate arguments
      rc = utilReadCommandLine( argc, argv, all, vm ) ;
      if ( rc )
      {
         std::cout << "Invalid arguments: " << rc << std::endl ;
         displayArg ( desc ) ;
         goto done ;
      }

      /// read cmd first
      if ( vm.count( PMD_OPTION_HELP ) )
      {
         displayArg( desc ) ;
         rc = SDB_PMD_HELP_ONLY ;
         goto done ;
      }
      if ( vm.count( PMD_OPTION_HELPFULL ) )
      {
         displayArg( all ) ;
         rc = SDB_PMD_HELP_ONLY ;
         goto done ;
      }
      if ( vm.count( PMD_OPTION_VERSION ) )
      {
         ossPrintVersion( "Sdb CM version" ) ;
         rc = SDB_PMD_VERSION_ONLY ;
         goto done ;
      }

   done:
      return rc ;
   }
void GlyphEditor::setVM(po::variables_map& vm, po::options_description& desc){
    this->desc = &desc;
    if (vm.count("threshold")) setThreshold(vm["threshold"].as<float>());
    if (vm.count("radius")) setRadius(vm["radius"].as<float>());
    if (vm.count("normalization")) setNormalization(vm["normalization"].as<float>());
    if (vm.count("primsize")) setSize(vm["primsize"].as<float>());
    if (vm.count("display")) setDisplay(vm["display"].as<int>());
    if (vm.count("color")) setColor(vm["color"].as<int>());
    if (vm.count("geometry")) setGeometry(vm["geometry"].as<int>());
    if (vm.count("glyphstyle")) setGlyphstyle(vm["glyphstyle"].as<int>());
    if (vm.count("primitives")) setPrimitives(vm["primitives"].as<int>());
    if (vm.count("minlength")) setMinlength(vm["minlength"].as<float>());
    if (vm.count("minlsource")) {
        setMinlSource(vm["minlsource"].as<int>());
        qDebug() << "***** minlsource: " << minlSource;
    }
}
bool StaticTestVerificationStage::parseOptions(po::variables_map& vm)
{
    if(vm.count("enable-static-test"))
    {
        enabled = true;
    }
	return true;
}
Esempio n. 12
0
bool IsParameterAvailable(const std::string& parameterAvailable, po::variables_map& vm)
{
    bool success = false;
    if(vm.count(parameterAvailable) >0)
        success = true;
    else
        LOGWARNING(parameterAvailable << " is not available");
    return success;
}
Esempio n. 13
0
AdvectionDiffusion::AdvectionDiffusion( po::variables_map const& vm )
    :
    M_vm( vm ),
    backend( backend_type::build( vm ) ),
    meshSize( vm["hsize"].as<double>() ),
    M_do_export( !vm.count( "no-export" ) ),
    export_number( 0 ),
    M_Dmu( new parameterspace_type )
{}
Esempio n. 14
0
//==============================================================================
bool CC_Base::read_options(const po::options_description &desc, const po::variables_map &vm)
{
	if (vm.count("help"))
	{
		on_help(desc);
		return false;
	}

	if (vm.count("device"))
	{
		uint_t bus = 0, device = 0;
		if (!extract_usb_address(option_device_address_, bus, device))
			throw po::error("Bad device address format");
	}

	option_fast_interface_speed_ = vm.count("fast") > 0;
	return true;
}
Esempio n. 15
0
bool should_search_path(const std::string& file,
                        const po::variables_map& config) {
    auto p = boost::filesystem::path(file);
    auto extension = boost::filesystem::extension(p);
    if (!config.count("search-all-extensions") && extension != ".cpp" &&
        extension != ".c" && extension != ".h" && extension != ".hpp") {
        return false;
    }
    return true;
}
Esempio n. 16
0
AnisotropicWavespeed::AnisotropicWavespeed( po::variables_map const& vm )
    :
    M_is_initialized( false ),
    M_vm( vm ),
    backend( backend_type::build( vm ) ),
    meshSize( vm["hsize"].as<double>() ),
    M_gammabc( vm["gamma-dir"].as<double>() ),
    M_do_export( !vm.count( "no-export" ) ),
    exporter( Exporter<mesh_type>::New( vm, "AnisotropicWavespeed" ) ),
    M_Dmu( new parameterspace_type )
{
}
Esempio n. 17
0
T
getOption( std::string const& name, std::string const& prefix, std::string const& sub, std::vector<std::string> const& prefixOverwrite,
           po::variables_map vm = Environment::vm() )
{
    T res = option(_name=name,_prefix=prefix,_sub=sub,_vm=vm).template as<T>();
    std::string optctx = (sub.empty())? "": sub+"-";
    for ( std::string const& prefixAdded : prefixOverwrite )
        if ( /*Environment::vm()*/vm.count( prefixvm(prefixAdded,optctx+name) ) )
            res = option(_name=name,_prefix=prefixAdded,_sub=sub,_vm=vm).template as<T>();

    return res;
}
Esempio n. 18
0
std::pair<bool,T>
getOptionIfAvalaible( std::string const& name, std::string const& prefix, std::string const& sub, std::vector<std::string> const& prefixOverwrite,
                      po::variables_map vm = Environment::vm() )
{
    bool hasOption=false;
    T res;
    std::string optctx = (sub.empty())? "": sub+"-";
    if ( vm.count( prefixvm(prefix,optctx+name) ) )
    {
        hasOption = true;
        res = option(_name=name,_prefix=prefix,_sub=sub,_vm=vm).template as<T>();
    }
    for ( std::string const& prefixAdded : prefixOverwrite )
        if ( vm.count( prefixvm(prefixAdded,optctx+name) ) )
        {
            hasOption = true;
            res = option(_name=name,_prefix=prefixAdded,_sub=sub,_vm=vm).template as<T>();
        }

    return std::make_pair(hasOption,res);
}
Esempio n. 19
0
   INT32 initArgs ( INT32 argc, CHAR **argv, po::variables_map &vm,
                    BOOLEAN &asProc )
   {
      INT32 rc = SDB_OK ;
      po::options_description desc ( "Command options" ) ;

      PMD_ADD_PARAM_OPTIONS_BEGIN ( desc )
         COMMANDS_OPTIONS
      PMD_ADD_PARAM_OPTIONS_END

      rc = utilReadCommandLine( argc, argv, desc, vm ) ;
      if ( rc )
      {
         std::cout << "Invalid arguments: " << rc << std::endl ;
         displayArg ( desc ) ;
         goto done ;
      }

      if ( vm.count( PMD_OPTION_HELP ) )
      {
         displayArg( desc ) ;
         rc = SDB_PMD_HELP_ONLY ;
         goto done ;
      }
      if ( vm.count( PMD_OPTION_VERSION ) )
      {
         ossPrintVersion( "Sdb CMD version" ) ;
         rc = SDB_PMD_VERSION_ONLY ;
         goto done ;
      }
#if defined( _WINDOWS )
      if ( vm.count( PMD_OPTION_AS_PROC ) )
      {
         asProc = TRUE ;
      }
#endif //_WINDOWS

   done:
      return rc ;
   }
Esempio n. 20
0
Microphone::Microphone( po::variables_map const& vm )
    :
    M_is_initialized( false ),
    M_vm( vm ),
    backend( backend_type::build( vm ) ),
    meshSize( vm["hsize"].as<double>() ),
    M_gammabc( vm["gamma-dir"].as<double>() ),
    M_do_export( !vm.count( "no-export" ) ),
    exporter( Exporter<mesh_type>::New( vm, "Microphone" ) ),
    M_Dmu( new parameterspace_type )
{
    this->init();
}
Esempio n. 21
0
void CInfoCommand::Execute (po::variables_map const& options, std::string const& arg)
{
  bool bBasicInfo = false;
  bool bDisplayAtOffset = false;
  int offset = 0;

  if (options.count("basic"))
    bBasicInfo = true;
  if (options.count("offset"))
  {
    bDisplayAtOffset = true;
    offset = options["offset"].as<int> ();
  }

  std::auto_ptr <SSRecordFile> pFile (SSRecordFile::MakeFile (arg));
  
  if (pFile.get ())
  {
    GetFormatter()->BeginFile (arg);
    if (bDisplayAtOffset)
    {
      SSRecordPtr pRecord = pFile->GetRecord(offset);
      Info (pRecord, bBasicInfo);
    }
    else
    {
      SSRecordPtr pRecord = pFile->GetFirstRecord();
      while (pRecord)
      {
        Info (pRecord, bBasicInfo);
        pRecord = pFile->FindNextRecord(pRecord);
      }
    }

    GetFormatter()->EndFile ();
  }
}
Esempio n. 22
0
// Continue work with machine
void continueWithMachine(machine::Machine &machine, po::variables_map const& variables)
{
    if(variables.count("state-in"))
    {
        auto file_path = variables["state-in"].as<std::string>();
        actions::loadMachine(machine, file_path);
    }

    auto messages = variables.count("message") ?
                    variables["message"].as<Messages_t>() : Messages_t();

    if(!messages.empty())
        actions::convertArguments(machine, messages);
    else
        actions::startInteractiveSession(machine);

    if(variables.count("state-out"))
    {
        auto file_paths = variables["state-out"].as<std::vector<std::string>>();

        for(auto const& file_path : file_paths)
            actions::saveMachine(machine, file_path);
    }
}
Esempio n. 23
0
void DBConsistencyChecker::run(po::variables_map &vm, SQLiteDBConnection *sqlConn)
{
	_sqlConn = sqlConn;

	_doRepair = false;
	if (vm.count("inconsistency-action"))
		_doRepair = vm["inconsistency-action"].as<string>().compare("repair") == 0;

	// find (and erase) duplicate image entries
	DupImageFinder dupImgFinder;
	dupImgFinder.run(vm,sqlConn);

	findImgsWOFaces();

	_sqlConn = 0;
}
Esempio n. 24
0
void CMultiArgCommand::Execute (po::variables_map const& options, std::vector<po::option> const& args)
{
  if (options.count("input") > 0)
  {
    std::vector <std::string> const& args = options["input"].as <std::vector<std::string> > ();
    std::vector <std::string>::const_iterator end = args.end ();
    for (std::vector <std::string>::const_iterator citor = args.begin (); citor != end; ++citor)
      Execute (options, *citor);
  }
  else
  {
      throw std::runtime_error("missing argument");
  }
//  std::vector<po::option>::const_iterator end = args.end();
//  for (std::vector<po::option>::const_iterator citor = args.begin (); citor != end; ++citor)
//  {
//    Execute (options, *citor);
//  }
}
Esempio n. 25
0
void options_global::filterate( po::variables_map const & vm )
{
	detail = normal;
	if( vm.count("detail-level") ){

		to_lower( detail_str );

		if( detail_str == "quite" || detail_str == "q" ){
			detail = quite;
		} else if( detail_str == "brief" || detail_str == "b" ){
			detail = brief;
		} else if( detail_str == "normal" || detail_str == "n" ){
			detail = normal;
		} else if( detail_str == "verbose" || detail_str == "v" ){
			detail = verbose;
		} else if( detail_str == "debug" || detail_str == "d" ){
			detail = debug;
		}

	}
}
Esempio n. 26
0
BOOLEAN _dpsFilterOption::checkInput( const po::variables_map &vm )
{
    BOOLEAN valid = FALSE ;

    if( vm.count( DPS_LOG_FILTER_HELP )
            || vm.count( DPS_LOG_FILTER_VER )
            || vm.count( DPS_LOG_FILTER_TYPE )
            || vm.count( DPS_LOG_FILTER_NAME )
            || vm.count( DPS_LOG_FILTER_META )
            || vm.count( DPS_LOG_FILTER_LSN )
            || vm.count( DPS_LOG_FILTER_SOURCE )
            || vm.count( DPS_LOG_FILTER_OUTPUT )
            || vm.count( DPS_LOG_FILTER_LAST ) )
    {
        valid = TRUE ;
    }

    return valid ;
}
Esempio n. 27
0
	void parse(const po::parsed_options& parsed_opts, const po::variables_map& vm) const override {
		if (vm.count("help")) { 
			std::cout << *parsed_opts.description << std::endl;
			exit(0);
		} 
	}
Esempio n. 28
0
bool process_command_line(int argc, char* argv[],
                          po::variables_map& options)
{
    std::string config_file;

    // Command line
    po::options_description generic("Generic options");
    generic.add_options()
    ("version,v", "Show version")
    ("help", "Print help message")
    ("config,c", po::value<std::string>(&config_file)->default_value("conf/dm.conf"), "Path of the configuration file")
    ("no-daemon,n", "Do not daemonize")
    ;

    // Configuration
    po::options_description config("Configuration");
    config.add_options()
    ("port,p", po::value<int>()->default_value(1234), "Port to listen on")
    ("interface", po::value<std::string>()->default_value(""), "Interface to use	")
    ;

    // Hidden
    po::options_description hidden("Hidden");
    hidden.add_options()
    ("main.log", po::value<std::string>()->default_value("/var/log/dm/dm.log"), "Log file")
    ;

    po::options_description visible("Allowed options");
    visible.add(generic).add(config);

    po::options_description config_file_options;
    config_file_options.add(config).add(hidden);
    //config_file_options.add(config);

    po::store(po::parse_command_line(argc, argv, visible), options);
    po::notify(options);

    std::ifstream ifs(config_file.c_str());
    if (ifs)
    {
        po::store(po::parse_config_file(ifs, config_file_options, true), options);
        po::notify(options);
    }
    else
    {
        std::cout << "could not open config file:" << config_file << std::endl;
        return false;
    }

    if (options.count("help"))
    {
        std::cout << visible << std::endl;
        return false;
    }

    if (options.count("version"))
    {
#ifdef VERSION
        std::cout << "dm, version " << std::string(VERSION) << std::endl;
#else
        std::cout << "dm, version " << std::string(1.0) << std::endl;
#endif
        return false;
    }

    return true;
}
Esempio n. 29
0
INT32 _dpsFilterOption::handle( const po::options_description &desc,
                                const po::variables_map &vm,
                                iFilter *&filter )
{
    INT32 rc            = SDB_OK ;
    iFilter *nextFilter = NULL ;

    if( vm.count( DPS_LOG_FILTER_HELP ) )
    {
        displayArgs( desc ) ;
        rc = SDB_DPS_DUMP_HELP ;
        goto done ;
    }

    if( vm.count( DPS_LOG_FILTER_VER ) )
    {
        ossPrintVersion( "SequoiaDB version" ) ;
        rc = SDB_DPS_DUMP_VER ;
        goto done ;
    }

    if( vm.count( DPS_LOG_FILTER_OUTPUT ) )
    {
        _cmdData.output = FALSE ;
    }
    else
    {
        _cmdData.output = TRUE ;
    }

    if( vm.count( DPS_LOG_FILTER_LSN ) && vm.count( DPS_LOG_FILTER_LAST ) )
    {
        printf( "--lsn cannot be used with --last!!\n" ) ;
        rc = SDB_INVALIDARG ;
        goto error ;
    }

    if( vm.count( DPS_LOG_FILTER_LSN ) )
    {
        filter = dpsFilterFactory::getInstance()
                 ->createFilter( SDB_LOG_FILTER_LSN ) ;
        CHECK_FILTER( filter ) ;
        const CHAR *pLsn = vm[ DPS_LOG_FILTER_LSN ].as<std::string>().c_str() ;
        try
        {
            _cmdData.lsn = boost::lexical_cast< UINT64 >( pLsn ) ;
        }
        catch( boost::bad_lexical_cast& e )
        {
            printf( "Unable to cast lsn to UINT64\n" ) ;
            rc = SDB_INVALIDARG ;
            goto error ;
        }
    }
    else if( vm.count( DPS_LOG_FILTER_LAST ) )
    {
        filter = dpsFilterFactory::getInstance()
                 ->createFilter( SDB_LOG_FILTER_LAST ) ;
        CHECK_FILTER( filter ) ;
    }

    if( vm.count( DPS_LOG_FILTER_TYPE ) )
    {
        nextFilter = dpsFilterFactory::getInstance()
                     ->createFilter( SDB_LOG_FILTER_TYPE ) ;
        CHECK_FILTER( nextFilter ) ;
        ASSIGNED_FILTER( filter, nextFilter ) ;
    }

    if( vm.count( DPS_LOG_FILTER_NAME ) )
    {
        nextFilter = dpsFilterFactory::getInstance()
                     ->createFilter( SDB_LOG_FILTER_NAME ) ;
        CHECK_FILTER( nextFilter ) ;
        ASSIGNED_FILTER( filter, nextFilter ) ;
    }

    if( vm.count( DPS_LOG_FILTER_META ) )
    {
        if( NULL != filter )
        {
            printf( "meta command must be used alone!\n" ) ;
            rc = SDB_INVALIDARG ;
            goto error ;
        }

        filter = dpsFilterFactory::getInstance()
                 ->createFilter( SDB_LOG_FILTER_META ) ;
        CHECK_FILTER( filter ) ;
        goto done ;
    }

    if( NULL == filter )
    {
        filter = dpsFilterFactory::getInstance()
                 ->createFilter( SDB_LOG_FILTER_NONE ) ;
        CHECK_FILTER( filter ) ;
    }

done:
    return rc ;
error:
    goto done ;
}
Esempio n. 30
0
QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMainThreadCaller_), autoUpdater_(NULL), idleDetector_(&idleQuerier_, networkFactories_.getTimerFactory(), 1000) {
	QCoreApplication::setApplicationName(SWIFT_APPLICATION_NAME);
	QCoreApplication::setOrganizationName(SWIFT_ORGANIZATION_NAME);
	QCoreApplication::setOrganizationDomain(SWIFT_ORGANIZATION_DOMAIN);
	QCoreApplication::setApplicationVersion(buildVersion);

	qtSettings_ = new QtSettingsProvider();
	xmlSettings_ = loadSettingsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "system-settings.xml")));
	settingsHierachy_ = new SettingsProviderHierachy();
	settingsHierachy_->addProviderToTopOfStack(xmlSettings_);
	settingsHierachy_->addProviderToTopOfStack(qtSettings_);

	networkFactories_.getTLSContextFactory()->setDisconnectOnCardRemoval(settingsHierachy_->getSetting(SettingConstants::DISCONNECT_ON_CARD_REMOVAL));

	std::map<std::string, std::string> emoticons;
	loadEmoticonsFile(":/emoticons/emoticons.txt", emoticons);
	loadEmoticonsFile(P2QSTRING(pathToString(Paths::getExecutablePath() / "emoticons.txt")), emoticons);

	if (options.count("netbook-mode")) {
		splitter_ = new QtSingleWindow(qtSettings_);
	} else {
		splitter_ = NULL;
	}

	int numberOfAccounts = 1;
	try {
		numberOfAccounts = options["multi-account"].as<int>();
	} catch (...) {
		/* This seems to fail on a Mac when the .app is launched directly (the usual path).*/
		numberOfAccounts = 1;
	}

	if (options.count("debug")) {
		Log::setLogLevel(Swift::Log::debug);
	}

	bool enableAdHocCommandOnJID = options.count("enable-jid-adhocs") > 0;
	tabs_ = NULL;
	if (options.count("no-tabs") && !splitter_) {
		tabs_ = new QtChatTabsShortcutOnlySubstitute();
	}
	else {
		tabs_ = new QtChatTabs(splitter_ != NULL, settingsHierachy_, options.count("trellis"));
	}
	bool startMinimized = options.count("start-minimized") > 0;
	applicationPathProvider_ = new PlatformApplicationPathProvider(SWIFT_APPLICATION_NAME);
	storagesFactory_ = new FileStoragesFactory(applicationPathProvider_->getDataDir(), networkFactories_.getCryptoProvider());
	certificateStorageFactory_ = new CertificateFileStorageFactory(applicationPathProvider_->getDataDir(), tlsFactories_.getCertificateFactory(), networkFactories_.getCryptoProvider());
	chatWindowFactory_ = new QtChatWindowFactory(splitter_, settingsHierachy_, qtSettings_, tabs_, "", emoticons);
	soundPlayer_ = new QtSoundPlayer(applicationPathProvider_);

	// Ugly, because the dock depends on the tray, but the temporary
	// multi-account hack creates one tray per account.
	QtSystemTray* systemTray = new QtSystemTray();
	systemTrays_.push_back(systemTray);

#if defined(HAVE_GROWL)
	notifier_ = new GrowlNotifier(SWIFT_APPLICATION_NAME);
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
	notifier_ = new WindowsNotifier(SWIFT_APPLICATION_NAME, applicationPathProvider_->getResourcePath("/images/logo-icon-32.png"), systemTray->getQSystemTrayIcon());
#elif defined(SWIFTEN_PLATFORM_LINUX)
	notifier_ = new FreeDesktopNotifier(SWIFT_APPLICATION_NAME);
#elif defined(SWIFTEN_PLATFORM_MACOSX)
	notifier_ = new NotificationCenterNotifier();
#else
	notifier_ = new NullNotifier();
#endif

#if defined(SWIFTEN_PLATFORM_MACOSX)
	dock_ = new MacOSXDock(&cocoaApplication_);
#else
	dock_ = new NullDock();
#endif

#if defined(SWIFTEN_PLATFORM_MACOSX)
	uriHandler_ = new QtURIHandler();
#elif defined(SWIFTEN_PLATFORM_WIN32)
	uriHandler_ = new NullURIHandler();
#else
	uriHandler_ = new QtDBUSURIHandler();
#endif

	statusCache_ = new StatusCache(applicationPathProvider_);

	if (splitter_) {
		splitter_->show();
	}

	for (int i = 0; i < numberOfAccounts; i++) {
		if (i > 0) {
			// Don't add the first tray (see note above)
			systemTrays_.push_back(new QtSystemTray());
		}
		QtUIFactory* uiFactory = new QtUIFactory(settingsHierachy_, qtSettings_, tabs_, splitter_, systemTrays_[i], chatWindowFactory_, networkFactories_.getTimerFactory(), statusCache_, startMinimized, !emoticons.empty(), enableAdHocCommandOnJID);
		uiFactories_.push_back(uiFactory);
		MainController* mainController = new MainController(
				&clientMainThreadCaller_,
				&networkFactories_,
				uiFactory,
				settingsHierachy_,
				systemTrays_[i],
				soundPlayer_,
				storagesFactory_,
				certificateStorageFactory_,
				dock_,
				notifier_,
				uriHandler_,
				&idleDetector_,
				emoticons,
				options.count("latency-debug") > 0);
		mainControllers_.push_back(mainController);
	}


	// PlatformAutoUpdaterFactory autoUpdaterFactory;
	// if (autoUpdaterFactory.isSupported()) {
	// 	autoUpdater_ = autoUpdaterFactory.createAutoUpdater(SWIFT_APPCAST_URL);
	// 	autoUpdater_->checkForUpdates();
	// }
}