示例#1
0
文件: Config.cpp 项目: xdv/divvyd
beast::File Config::getModuleDatabasePath () const
{
    boost::filesystem::path dbPath (legacy ("database_path"));

    beast::String const s (dbPath.native ().c_str ());
    if (s.isNotEmpty ())
        return beast::File (s);
    return beast::File::nonexistent ();
}
示例#2
0
QWidget* SkinLoader::loadDefaultSkin(QWidget* pParent,
                                     MixxxKeyboard* pKeyboard,
                                     PlayerManager* pPlayerManager,
                                     ControllerManager* pControllerManager,
                                     Library* pLibrary,
                                     VinylControlManager* pVCMan) {
    QString skinPath = getConfiguredSkinPath();

    LegacySkinParser legacy(m_pConfig, pKeyboard, pPlayerManager, pControllerManager, pLibrary, pVCMan);
    return legacy.parseSkin(skinPath, pParent);
}
示例#3
0
QWidget* SkinLoader::loadDefaultSkin(QWidget* pParent,
                                     MixxxKeyboard* pKeyboard,
                                     PlayerManager* pPlayerManager,
                                     ControllerManager* pControllerManager,
                                     Library* pLibrary,
                                     VinylControlManager* pVCMan,
                                     EffectsManager* pEffectsManager) {
    QString skinPath = getSkinPath();

    // If we don't have a skin path then fail.
    if (skinPath.isEmpty()) {
        return NULL;
    }

    LegacySkinParser legacy(m_pConfig, pKeyboard, pPlayerManager,
                            pControllerManager, pLibrary, pVCMan,
                            pEffectsManager);
    return legacy.parseSkin(skinPath, pParent);
}
示例#4
0
void StunMessageTestSuite::testLegacyMode() 
{
    StunMessage legacy(NULL, true) ;
    StunMessage nonLegacy(NULL, false) ;
    StunMessage responseWithLegacy(&legacy, false) ;
    StunMessage responseWithNonLegacy(&nonLegacy, true) ;

    STUN_MAGIC_ID magicId ;

    legacy.getMagicId(&magicId) ;
    CPPUNIT_ASSERT(magicId.id != STUN_MAGIC_COOKIE) ;

    nonLegacy.getMagicId(&magicId) ;
    CPPUNIT_ASSERT(magicId.id == STUN_MAGIC_COOKIE) ;

    responseWithLegacy.getMagicId(&magicId) ;
    CPPUNIT_ASSERT(magicId.id != STUN_MAGIC_COOKIE) ;

    responseWithNonLegacy.getMagicId(&magicId) ;
    CPPUNIT_ASSERT(magicId.id == STUN_MAGIC_COOKIE) ;
}
示例#5
0
std::vector<LLMute> LLMuteList::getMutes() const
{
	std::vector<LLMute> mutes;
	
	for (mute_set_t::const_iterator it = mMutes.begin();
		 it != mMutes.end();
		 ++it)
	{
		mutes.push_back(*it);
	}
	
	for (string_set_t::const_iterator it = mLegacyMutes.begin();
		 it != mLegacyMutes.end();
		 ++it)
	{
		LLMute legacy(LLUUID::null, *it);
		mutes.push_back(legacy);
	}
	
	std::sort(mutes.begin(), mutes.end(), compare_by_name());
	return mutes;
}
void IndicationHandlerService::_handle_async_request(AsyncRequest *req)
{
    if ( req->getType() == async_messages::CIMSERVICE_STOP )
    {
        req->op->processing();
        handle_CimServiceStop(static_cast<CimServiceStop *>(req));
    }
    else if ( req->getType() == async_messages::ASYNC_LEGACY_OP_START )
    {
        req->op->processing();
        AutoPtr<Message> legacy(static_cast<AsyncLegacyOperationStart *>(req)->get_action()); //PEP 101
        if (legacy->getType() == CIM_HANDLE_INDICATION_REQUEST_MESSAGE)
        {
            AutoPtr<Message> legacy_response(_handleIndication(
                (CIMHandleIndicationRequestMessage*) legacy.get())); //PEP 101
            legacy.release();
            AutoPtr<AsyncLegacyOperationResult> async_result(new AsyncLegacyOperationResult(
                    req->getKey(),
                    req->getRouting(),
                    req->op,
                    legacy_response.get())); //PEP 101
            legacy_response.release();
            async_result.release();
            _complete_op_node(req->op, ASYNC_OPSTATE_COMPLETE, 0, 0);
        }
        else
        {
            Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                "IndicationHandlerService::_handle_async_request got "
                    "unexpected legacy message type '%u'", legacy->getType());
            _make_response(req, async_results::CIM_NAK);
        }
    }
    else
    {
        Base::_handle_async_request(req);
    }
}
void IndicationHandlerService::_handle_async_request(AsyncRequest* req)
{
    if (req->getType() == ASYNC_CIMSERVICE_STOP)
    {
        handle_CimServiceStop(static_cast<CimServiceStop *>(req));
    }
    else if (req->getType() == ASYNC_ASYNC_LEGACY_OP_START)
    {
        AutoPtr<Message> legacy(
            static_cast<AsyncLegacyOperationStart *>(req)->get_action());
        if (legacy->getType() == CIM_HANDLE_INDICATION_REQUEST_MESSAGE)
        {
            AutoPtr<Message> legacy_response(_handleIndication(
                (CIMHandleIndicationRequestMessage*) legacy.get()));
            legacy.release();
            AutoPtr<AsyncLegacyOperationResult> async_result(
                new AsyncLegacyOperationResult(
                    req->op,
                    legacy_response.get()));
            legacy_response.release();
            async_result.release();
            _complete_op_node(req->op);
        }
        else
        {
            PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL2,
                "IndicationHandlerService::_handle_async_request got "
                    "unexpected legacy message type '%u'", legacy->getType()));
            _make_response(req, async_results::CIM_NAK);
        }
    }
    else
    {
        Base::_handle_async_request(req);
    }
}
示例#8
0
文件: Config.cpp 项目: xdv/divvyd
void Config::loadFromString (std::string const& fileContents)
{
    IniFileSections secConfig = parseIniFile (fileContents, true);

    build (secConfig);

    if (auto s = getIniFileSection (secConfig, SECTION_VALIDATORS))
        validators  = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_CLUSTER_NODES))
        CLUSTER_NODES = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_IPS))
        IPS = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_IPS_FIXED))
        IPS_FIXED = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_SNTP))
        SNTP_SERVERS = *s;

    if (auto s = getIniFileSection (secConfig, SECTION_RPC_STARTUP))
    {
        RPC_STARTUP = Json::arrayValue;

        for (auto const& strJson : *s)
        {
            Json::Reader    jrReader;
            Json::Value     jvCommand;

            if (!jrReader.parse (strJson, jvCommand))
                throw std::runtime_error (
                    boost::str (boost::format (
                        "Couldn't parse [" SECTION_RPC_STARTUP "] command: %s") % strJson));

            RPC_STARTUP.append (jvCommand);
        }
    }

    {
        std::string dbPath;
        if (getSingleSection (secConfig, "database_path", dbPath))
        {
            boost::filesystem::path p(dbPath);
            legacy("database_path", 
                   boost::filesystem::absolute (p).string ());
        }
    }

    (void) getSingleSection (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE);

    std::string strTemp;
    if (getSingleSection (secConfig, SECTION_PEER_PRIVATE, strTemp))
        PEER_PRIVATE        = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_PEERS_MAX, strTemp))
        PEERS_MAX           = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp))
    {
        if (strTemp == "tiny")
            NODE_SIZE = 0;
        else if (strTemp == "small")
            NODE_SIZE = 1;
        else if (strTemp == "medium")
            NODE_SIZE = 2;
        else if (strTemp == "large")
            NODE_SIZE = 3;
        else if (strTemp == "huge")
            NODE_SIZE = 4;
        else
        {
            NODE_SIZE = beast::lexicalCastThrow <int> (strTemp);

            if (NODE_SIZE < 0)
                NODE_SIZE = 0;
            else if (NODE_SIZE > 4)
                NODE_SIZE = 4;
        }
    }

    if (getSingleSection (secConfig, SECTION_ELB_SUPPORT, strTemp))
        ELB_SUPPORT         = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp))
        WEBSOCKET_PING_FREQ = beast::lexicalCastThrow <int> (strTemp);

    getSingleSection (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE);
    getSingleSection (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR);

    if (getSingleSection (secConfig, SECTION_SSL_VERIFY, strTemp))
        SSL_VERIFY          = beast::lexicalCastThrow <bool> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATION_SEED, strTemp))
    {
        VALIDATION_SEED.setSeedGeneric (strTemp);

        if (VALIDATION_SEED.isValid ())
        {
            VALIDATION_PUB = DivvyAddress::createNodePublic (VALIDATION_SEED);
            VALIDATION_PRIV = DivvyAddress::createNodePrivate (VALIDATION_SEED);
        }
    }

    if (getSingleSection (secConfig, SECTION_NODE_SEED, strTemp))
    {
        NODE_SEED.setSeedGeneric (strTemp);

        if (NODE_SEED.isValid ())
        {
            NODE_PUB = DivvyAddress::createNodePublic (NODE_SEED);
            NODE_PRIV = DivvyAddress::createNodePrivate (NODE_SEED);
        }
    }

    if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp))
        NETWORK_QUORUM      = beast::lexicalCastThrow <std::size_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATION_QUORUM, strTemp))
        VALIDATION_QUORUM   = std::max (0, beast::lexicalCastThrow <int> (strTemp));

    if (getSingleSection (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp))
        FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow <std::uint64_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp))
        FEE_OWNER_RESERVE   = beast::lexicalCastThrow <std::uint64_t> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OFFER, strTemp))
        FEE_OFFER           = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_DEFAULT, strTemp))
        FEE_DEFAULT         = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_FEE_OPERATION, strTemp))
        FEE_CONTRACT_OPERATION  = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp))
    {
        boost::to_lower (strTemp);

        if (strTemp == "full")
            LEDGER_HISTORY = 1000000000u;
        else if (strTemp == "none")
            LEDGER_HISTORY = 0;
        else
            LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp);
    }

    if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp))
    {
        boost::to_lower (strTemp);

        if (strTemp == "none")
            FETCH_DEPTH = 0;
        else if (strTemp == "full")
            FETCH_DEPTH = 1000000000u;
        else
            FETCH_DEPTH = beast::lexicalCastThrow <std::uint32_t> (strTemp);

        if (FETCH_DEPTH < 10)
            FETCH_DEPTH = 10;
    }

    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_OLD, strTemp))
        PATH_SEARCH_OLD     = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH, strTemp))
        PATH_SEARCH         = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_FAST, strTemp))
        PATH_SEARCH_FAST    = beast::lexicalCastThrow <int> (strTemp);
    if (getSingleSection (secConfig, SECTION_PATH_SEARCH_MAX, strTemp))
        PATH_SEARCH_MAX     = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_ACCOUNT_PROBE_MAX, strTemp))
        ACCOUNT_PROBE_MAX   = beast::lexicalCastThrow <int> (strTemp);

    if (getSingleSection (secConfig, SECTION_VALIDATORS_FILE, strTemp))
    {
        VALIDATORS_FILE     = strTemp;
    }

    if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp))
        DEBUG_LOGFILE       = strTemp;
}
示例#9
0
文件: Config.cpp 项目: xdv/divvyd
void Config::setup (std::string const& strConf, bool bQuiet)
{
    boost::filesystem::path dataDir;
    boost::system::error_code   ec;
    std::string                 strDbPath, strConfFile;

    //
    // Determine the config and data directories.
    // If the config file is found in the current working directory, use the current working directory as the config directory and
    // that with "db" as the data directory.
    //

    QUIET       = bQuiet;
    NODE_SIZE   = 0;

    strDbPath           = Helpers::getDatabaseDirName ();
    strConfFile         = strConf.empty () ? Helpers::getConfigFileName () : strConf;

    VALIDATORS_BASE     = Helpers::getValidatorsFileName ();

    VALIDATORS_URI      = boost::str (boost::format ("/%s") % VALIDATORS_BASE);

    if (!strConf.empty ())
    {
        // --conf=<path> : everything is relative that file.
        CONFIG_FILE             = strConfFile;
        CONFIG_DIR              = boost::filesystem::absolute (CONFIG_FILE);
        CONFIG_DIR.remove_filename ();
        dataDir                 = CONFIG_DIR / strDbPath;
    }
    else
    {
        CONFIG_DIR              = boost::filesystem::current_path ();
        CONFIG_FILE             = CONFIG_DIR / strConfFile;
        dataDir                 = CONFIG_DIR / strDbPath;

        // Construct XDG config and data home.
        // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
        std::string strHome          = getEnvVar ("HOME");
        std::string strXdgConfigHome = getEnvVar ("XDG_CONFIG_HOME");
        std::string strXdgDataHome   = getEnvVar ("XDG_DATA_HOME");

        if (boost::filesystem::exists (CONFIG_FILE)
                // Can we figure out XDG dirs?
                || (strHome.empty () && (strXdgConfigHome.empty () || strXdgDataHome.empty ())))
        {
            // Current working directory is fine, put dbs in a subdir.
        }
        else
        {
            if (strXdgConfigHome.empty ())
            {
                // $XDG_CONFIG_HOME was not set, use default based on $HOME.
                strXdgConfigHome    = strHome + "/.config";
            }

            if (strXdgDataHome.empty ())
            {
                // $XDG_DATA_HOME was not set, use default based on $HOME.
                strXdgDataHome  = strHome + "/.local/share";
            }

            CONFIG_DIR  = strXdgConfigHome + "/" + systemName ();
            CONFIG_FILE = CONFIG_DIR / strConfFile;
            dataDir    = strXdgDataHome + "/" + systemName ();

            boost::filesystem::create_directories (CONFIG_DIR, ec);

            if (ec)
                throw std::runtime_error (boost::str (boost::format ("Can not create %s") % CONFIG_DIR));
        }
    }

    HTTPClient::initializeSSLContext();

    // Update default values
    load ();
    {
        // load() may have set a new value for the dataDir
        std::string const dbPath (legacy ("database_path"));
        if (!dbPath.empty ())
        {
            dataDir = boost::filesystem::path (dbPath);
        }
    }

    boost::filesystem::create_directories (dataDir, ec);

    if (ec)
        throw std::runtime_error (
            boost::str (boost::format ("Can not create %s") % dataDir));

    legacy ("database_path", boost::filesystem::absolute (dataDir).string ());
}