ConfigObject* ConfigObject::addObject(const ConfigFieldDescriptor* field, const std::string& key) { BOOST_ASSERT(field && field->repeatedType == ConfigFieldDescriptor::MAP && "addObject field type must be map"); if (key.empty()) { LOG_ERROR << "can not add an empty key to the map."; return NULL; } std::map<std::string, ConfigObject*>* repeated = mutableRaw<std::map<std::string, ConfigObject*> >(field); // We must allocate a new object. const ConfigObject* prototype = ConfigObject::defaultObject(field->className); if (NULL == prototype) { LOG_ERROR << "can not find such object " << field->className; return NULL; } ConfigObject* newObject = prototype->create(); newObject->setName(key); repeated->insert(std::make_pair(key, newObject)); return newObject; }
void ConfigTreeObject_EventAction::slotEventAction_GrpNumchanged() { ConfigObject *pObj = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_GRPNUM); if(pObj) { quint32 groupNum = pObj->getData().toUInt(); pObj->setStrShowOn(QString("%1").arg(groupNum+1)); } }
void ConfigTreeObject_Math::slotMathConstantKItemChanged() { Menu *menu = static_cast<Menu *>(this->sender()); QString strName = menu->objectName(); ConfigObject *pConfigObj = ConfigTreeObject::getConfigObject(QString(MATH_DELEGATE_CONSTANTNUM_X).arg(strName)); QString valueStr = pConfigObj->getData().toString().toUpper(); pConfigObj->setStrShowOn(valueStr); }
// static void Sandbox::shutdown() { QMutexLocker locker(&s_mutex); ConfigObject<ConfigValue>* pSandboxPermissions = s_pSandboxPermissions; s_pSandboxPermissions = NULL; if (pSandboxPermissions) { pSandboxPermissions->save(); delete pSandboxPermissions; } }
void ConfigTreeObject_Math::updateAllConstKInfoMenu() { ConfigObject *pConfigObj; QString valueStr; for(int i=0;i<100;++i) { pConfigObj = ConfigTreeObject::getConfigObject(QString(MATH_DELEGATE_CONSTANTNUM_INDEX).arg(i+1, 3, 10, QChar('0'))); valueStr = pConfigObj->getData().toString().toUpper(); pConfigObj->setStrShowOn(valueStr); } }
void ConfigTreeObject_Report::slotReportChannelNumberChange() { QString num; ConfigObject *pObj = ConfigTreeObject::getConfigObject(Config_Report_Delegate_ReportChannnel_Number); if(pObj){ num = pObj->getData().toString(); pObj->setStrShowOn(QString("%1").arg(num.toInt()+1)); } }
RRDVisAnalyzer::RRDVisAnalyzer(const ConfigObject& configObject, ReporterBase& reporter) : AnalyzerBase(configObject, reporter), configSection("rrdvisualizer"), firstFlow(true), lastFlowStart(0) { configFile = configObject.getConfString(configSection, "configfile"); rrdPath = configObject.getConfString(configSection, "rrdtool_path"); rrdDbPath = configObject.getConfString(configSection, "db_path"); // parse subnet config file std::ifstream subnetConfig(configFile.c_str()); std::string token; bool subnet = true; std::string subnet_string; tree = lpm_init(); std::vector<std::string> subnetList; while (subnetConfig) { subnetConfig >> token; if (subnet) { subnet_string = token; subnet = false; } else { size_t pos = subnet_string.find("/"); if (pos == std::string::npos) { throw std::runtime_error("Error: Cannot parse subnet \"" + subnet_string + "\""); } std::string ip = subnet_string.substr(0, pos); std::string mask = subnet_string.substr(pos + 1, subnet_string.size()); rrdDBMap[subnet_string] = token; lpm_insert(tree, ip.c_str(), atoi(mask.c_str())); subnet = true; } } // define the number of values that need to be aggregated // by the rrdtools intervals.push_back(1); intervals.push_back(5); intervals.push_back(30); intervals.push_back(120); intervals.push_back(24*60); // graph time spans graphTimeSpans.push_back("-1d"); graphTimeSpans.push_back("-1w"); graphTimeSpans.push_back("-1m"); graphTimeSpans.push_back("-1y"); }
void ConfigTreeObject_EventAction::slotEventAction_A_Typechanged() { QFile file; Operation_Mode_Type mode = (Operation_Mode_Type)ConfigTreeObject \ ::getConfigObject(EVENT_DELEGATE_EVENT_MODE)->getData().toUInt(); switch(mode) { case Operation_Mode_Type_RisingEdge: case Operation_Mode_Type_FallingEdge: case Operation_Mode_Type_Edge: file.setFileName(XML_EVENT_ACTION_TYPE); break; case Operation_Mode_Type_Both: file.setFileName(XML_EVENT_ACTION_TYPE_C); break; } QVariant value = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_ACTION_TYPE)->getData(); if(!file.open(QFile::ReadOnly | QFile::Text)){ qWarning()<< "Can't open the file:EventAction_ActionType!"; }else{ XmlConfigParser::parseValueChangeXml(file, value); file.close(); } QMap<quint32,QString> m_map; Action_Type valueCur = (Action_Type)value.toUInt(); if(Action_Type1_Recorded == valueCur) { m_map.insert(Action_Detail_Start, tr("Start")); m_map.insert(Action_Detail_Stop, tr("Stop")); } else if (Action_Type1_Computation == valueCur) { m_map.insert(Action_Detail_Start, tr("Start")); m_map.insert(Action_Detail_Stop, tr("Stop")); m_map.insert(Action_Detail_Reset, tr("Reset")); } else if (Action_Type1_Message == valueCur) { m_map.insert(Action_Detail_AllGrp, tr("All groups")); m_map.insert(Action_Detail_SpecGrp, tr("Specified group")); } else { return; } ConfigObject* pObj = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_ACTION_DETAIL); if(pObj) { Action_Detail detailCur = (Action_Detail)pObj->getData().toUInt(); if(!(m_map.contains(detailCur))) { pObj->changeData(m_map.firstKey(), false); } } }
ControlDoublePrivate::~ControlDoublePrivate() { s_qCOHashMutex.lock(); //qDebug() << "ControlDoublePrivate::s_qCOHash.remove(" << m_key.group << "," << m_key.item << ")"; s_qCOHash.remove(m_key); s_qCOHashMutex.unlock(); if (m_bPersistInConfiguration) { ConfigObject<ConfigValue>* pConfig = ControlDoublePrivate::s_pUserConfig; if (pConfig != NULL) { pConfig->set(m_key, QString::number(get())); } } }
void ConfigTreeObject_Report::slotReportBasicTimeMinuteChange() { QString num; ConfigObject *pObj = ConfigTreeObject::getConfigObject(Config_Report_Delegate_Basic_Time_Minute); if(pObj){ num = pObj->getData().toString(); pObj->setStrShowOn(QString("%1").arg(num.toInt())); } }
void ConfigTreeObject_Math::resetPartialSettings() { ConfigObject* pObj = ConfigTreeObject::getConfigObject(DISP_DELEGATE_TREND_PARTIAL_SWITCH); if(pObj) { QVariant valueSwitch = pObj->getData(); if(valueSwitch.toUInt() == 1) { ConfigTreeObject::getConfigObject(MATH_DELEGATE_DISP_PART)->setHideFlag(false); ConfigTreeObject::getConfigObject(MATH_DELEGATE_DISP_PART_ONOFF)->setHideFlag(false); ConfigTreeObject::getConfigObject(MATH_DELEGATE_DISP_PART_ONOFF)->changeData(0, false, false); ConfigTreeObject::getConfigObject(MATH_DELEGATE_DISP_PART_BOUND)->setHideFlag(true); ConfigTreeObject::getConfigObject(MATH_DELEGATE_DISP_PART_EXPAND)->setHideFlag(true); } } }
void WinDIAlarmLvl1Type::initMenu() { m_map.clear(); ConfigObject* pObj = ConfigTreeObject::getConfigObject(DI_DELEGATE_RANG_RANGE_CALCU); if(pObj) { DI_Range_Calculate calcu = (DI_Range_Calculate)pObj->getData().toUInt(); if(calcu == DI_Range_Calculate_Delta) { m_map = m_map_AlarmLvl1Type_Delta; } else { m_map = m_map_AlarmLvl1Type; } } slotResetMenus(); }
void WinDIRangeRangeType::initMenu() { m_map.clear(); //此处有问题,只有一个模块能被设置为远程输入 TODO ConfigObject* pObj = ConfigTreeObject::getConfigObject(MEASURE_DELEGATE_U_M_DIMODE_MODE); if(pObj) { DI_OpeMode mode = (DI_OpeMode)pObj->getData().toUInt(); if(DI_OpeMode_Remote == mode) { m_map = m_map_RangeRangeType_noPluse; } else { m_map = m_map_RangeRangeType; } } slotResetMenus(); }
void WinDIRangeCalculation::initMenu() { m_map.clear(); ConfigObject* pObj = ConfigTreeObject::getConfigObject(DI_DELEGATE_RANG_RANGE_TYPE); if(pObj) { DI_Range_Type type = (DI_Range_Type)pObj->getData().toUInt(); if(DI_Range_Type_Disabled == type) { } else if(DI_Range_Type_Pluse == type) { m_map = m_map_RangeCalcu_off; } else { m_map = m_map_RangeCalcu; } } slotResetMenus(); }
void ControlDoublePrivate::initialize(double defaultValue) { m_defaultValue.setValue(defaultValue); double initialValue = defaultValue; if (m_bPersistInConfiguration) { ConfigObject<ConfigValue>* pConfig = ControlDoublePrivate::s_pUserConfig; if (pConfig != NULL) { // Assume toDouble() returns 0 if conversion fails. initialValue = pConfig->getValueString(m_key).toDouble(); } } m_value.setValue(initialValue); //qDebug() << "Creating:" << m_trackKey << "at" << &m_value << sizeof(m_value); if (m_bTrack) { // TODO(rryan): Make configurable. Stat::track(m_trackKey, static_cast<Stat::StatType>(m_trackType), static_cast<Stat::ComputeFlags>(m_trackFlags), m_value.getValue()); } }
Frontend *Frontend::Create( Adapter &adapter, std::string configfile ) { ConfigObject cfg; cfg.SetConfigFile( configfile ); cfg.ReadConfigFile( ); Source::Type type; cfg.ReadConfig( "Type", (int &) type ); switch( type ) { case Source::Type_DVBS: return new Frontend_DVBS( adapter, configfile ); case Source::Type_DVBC: return new Frontend_DVBC( adapter, configfile ); case Source::Type_DVBT: return new Frontend_DVBT( adapter, configfile ); case Source::Type_ATSC: return new Frontend_ATSC( adapter, configfile ); case Source::Type_Any: return NULL; } return NULL; }
void ConfigTreeObject_Math::slotMathFirst_chanSelectchanged() { QString chanNumF; QString chanNumL; ConfigObject *pObj = ConfigTreeObject::getConfigObject(MATH_DELEGATE_FIRSTCHAN); ConfigObject *qObj = ConfigTreeObject::getConfigObject(MATH_DELEGATE_LASTCHAN); if(pObj && qObj){ chanNumF = pObj->getData().toString(); chanNumL = qObj->getData().toString(); pObj->setStrShowOn(chanNumF); qObj->changeData(chanNumF, false); } }
void ConfigTreeObject_Math::slotMathLast_chanSelectchanged() { QString chanNumF; QString chanNumL; ConfigObject *pObj = ConfigTreeObject::getConfigObject(MATH_DELEGATE_FIRSTCHAN); ConfigObject *qObj = ConfigTreeObject::getConfigObject(MATH_DELEGATE_LASTCHAN); if(pObj && qObj){ chanNumL = qObj->getData().toString(); chanNumF = pObj->getData().toString(); int value = QString::compare(chanNumF, chanNumL); if(value <= 0) { qObj->setStrShowOn(chanNumL); } else{ qObj->setStrShowOn(chanNumL); pObj->changeData(chanNumL ,false); } } }
void WinDispTrendTrendIntervalSecond::initMenu() { m_map.clear(); //不同测量周期会影响趋势周期备选项的最小值 ConfigObject* pObj = ConfigTreeObject::getConfigObject(MEASURE_DELEGATE_INTERVAL_INTERVAL); Measure_Interval testPeriod; if(pObj) { testPeriod = (Measure_Interval)pObj->getData().toUInt(); switch(testPeriod) { case Measure_Interval_100ms: m_map = m_map_TrendTrendInterval_5s; break; case Measure_Interval_200ms: m_map = m_map_TrendTrendInterval_10s; break; case Measure_Interval_500ms: m_map = m_map_TrendTrendInterval_15s; break; case Measure_Interval_1s: m_map = m_map_TrendTrendInterval_30s; break; case Measure_Interval_2s: m_map = m_map_TrendTrendInterval_1min; break; case Measure_Interval_5s: m_map = m_map_TrendTrendInterval_5min; break; } } quint32 trendTimeDiv; Record_Mode Recmode; quint8 sw; quint8 countDIV; ConfigObject* qObj = ConfigTreeObject::getConfigObject(RECORD_DELEGATE_BASIC_MODE_VALUE); ConfigObject* rObj = ConfigTreeObject::getConfigObject(DISP_DELEGATE_TREND_INTERVAL_SWITCH); if(qObj && rObj) { Recmode = (Record_Mode)qObj->getData().toUInt(); sw = rObj->getData().toUInt(); if ((Record_Mode_Event == Recmode) && (sw == 0)) { //Do nothing 事件记录模式时,参考事件记录周期与趋势周期关系表,与配置无关,内定 } else { Trend_Interval first = (Trend_Interval)ConfigTreeObject::\ getConfigObject(DISP_DELEGATE_TREND_INTERVAL_INTERVAL)->getData().toUInt(); Trend_Interval backup; for(quint8 i=0;i<m_map.size();++i) { backup = (Trend_Interval)m_map.keys().at(i); if (1 == sw) { trendTimeDiv = qMin(first, backup); } else { trendTimeDiv = first; } countDIV = trendTimeDiv>Trend_Interval_10s ? 30 : 50; quint32 x = trendTimeDiv * 1000; quint32 y = countDIV * testPeriod; if(x%y != 0) { m_map.remove((quint32)backup); } } } } slotResetMenus(); }
void ConfigTreeObject_EventAction::slotEventAction_E_Typechanged() { QVariant value = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_EVENT_TYPE)->getData(); QFile file(XML_EVENT_EVENT_TYPE); if(!file.open(QFile::ReadOnly | QFile::Text)){ qWarning()<< "Can't open the file:EventAction_EventType!"; }else{ XmlConfigParser::parseValueChangeXml(file, value); file.close(); } QMap<quint32,QString> m_map_EventMode; m_map_EventMode.insert(Operation_Mode_Type_RisingEdge, tr("Rising edge")); m_map_EventMode.insert(Operation_Mode_Type_FallingEdge, tr("Falling edge")); m_map_EventMode.insert(Operation_Mode_Type_Both, tr("Rising / Falling edge")); m_map_EventMode.insert(Operation_Mode_Type_Edge, tr("Edge")); Event_Type valueCur = (Event_Type)value.toUInt(); if ((Event_Type_Timer == valueCur) || (Event_Type_Timer_Match == valueCur) || (Event_Type_UserFunc == valueCur)) { m_map_EventMode.remove(Operation_Mode_Type_RisingEdge); m_map_EventMode.remove(Operation_Mode_Type_FallingEdge); m_map_EventMode.remove(Operation_Mode_Type_Both); } else { m_map_EventMode.remove(Operation_Mode_Type_Edge); } ConfigObject* pObj = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_EVENT_MODE); if(pObj) { Operation_Mode_Type modeCur = (Operation_Mode_Type)pObj->getData().toUInt(); if(!(m_map_EventMode.contains(modeCur))) { pObj->changeData(m_map_EventMode.firstKey(), false); } } ConfigObject* qObj = ConfigTreeObject::getConfigObject(EVENT_DELEGATE_EVENT_NUMBER); if(qObj) { switch(valueCur) { case Event_Type_InterSwitch: case Event_Type_Timer: case Event_Type_Timer_Match: case Event_Type_UserFunc: qObj->changeData(1, false); break; case Event_Type_Remote://need to modify TODO qObj->changeData(CfgChannel::instance()->getExistChannelDI().first(), false); break; case Event_Type_Relay: qObj->changeData(CfgChannel::instance()->getExistChannelDO().first(), false); break; case Event_Type_Alarm_IO: qObj->changeData(CfgChannel::instance()->getExistChannel().first(), false); break; case Event_Type_Alarm_Math: qObj->changeData(CfgChannel::instance()->getExistChannelMath().first(), false); break; case Event_Type_Alarm_Comm: qObj->changeData(CfgChannel::instance()->getExistChannelComm().first(), false); break; case Event_Type_Alarm_All: case Event_Type_Status: break; default: break; } } }
void SpriteFactory::addConfig(ConfigObject& object){ addConfig(object.configName(), object.spriteSheetName(), object.config()); }
// We return the ConfigObject here because we have to make changes to the // configuration and the location of the file may change between releases. ConfigObject<ConfigValue>* Upgrade::versionUpgrade(const QString& settingsPath) { /* Pre-1.7.0: * * Since we didn't store version numbers in the config file prior to 1.7.0, * we check to see if the user is upgrading if his config files are in the old location, * since we moved them in 1.7.0. This code takes care of moving them. */ QString oldLocation = QDir::homePath().append("/%1"); #ifdef __WINDOWS__ QFileInfo* pre170Config = new QFileInfo(oldLocation.arg("mixxx.cfg")); #else QFileInfo* pre170Config = new QFileInfo(oldLocation.arg(".mixxx.cfg")); #endif if (pre170Config->exists()) { // Move the files to their new location QString newLocation = settingsPath; if (!QDir(newLocation).exists()) { qDebug() << "Creating new settings directory" << newLocation; QDir().mkpath(newLocation); } newLocation.append("%1"); QString errorText = "Error moving your %1 file %2 to the new location %3: \n"; #ifdef __WINDOWS__ QString oldFilePath = oldLocation.arg("mixxxtrack.xml"); #else QString oldFilePath = oldLocation.arg(".mixxxtrack.xml"); #endif QString newFilePath = newLocation.arg("mixxxtrack.xml"); QFile* oldFile = new QFile(oldFilePath); if (oldFile->exists()) { if (oldFile->copy(newFilePath)) { oldFile->remove(); m_bUpgraded = true; } else { if (oldFile->error()==14) qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } delete oldFile; #ifdef __WINDOWS__ oldFilePath = oldLocation.arg("mixxxbpmschemes.xml"); #else oldFilePath = oldLocation.arg(".mixxxbpmscheme.xml"); #endif newFilePath = newLocation.arg("mixxxbpmscheme.xml"); oldFile = new QFile(oldFilePath); if (oldFile->exists()) { if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } delete oldFile; #ifdef __WINDOWS__ oldFilePath = oldLocation.arg("MixxxMIDIBindings.xml"); #else oldFilePath = oldLocation.arg(".MixxxMIDIBindings.xml"); #endif newFilePath = newLocation.arg("MixxxMIDIBindings.xml"); oldFile = new QFile(oldFilePath); if (oldFile->exists()) { qWarning() << "The MIDI mapping file format has changed in this version of Mixxx. You will need to reconfigure your MIDI controller. See the Wiki for full details on the new format."; if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } // Tidy up delete oldFile; QFile::remove(oldLocation.arg(".MixxxMIDIDevice.xml")); // Obsolete file, so just delete it #ifdef __WINDOWS__ oldFilePath = oldLocation.arg("mixxx.cfg"); #else oldFilePath = oldLocation.arg(".mixxx.cfg"); #endif newFilePath = newLocation.arg(SETTINGS_FILE); oldFile = new QFile(oldFilePath); if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("configuration", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("configuration", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } delete oldFile; } // Tidy up delete pre170Config; // End pre-1.7.0 code /*************************************************************************** * Post-1.7.0 upgrade code * * Add entries to the IF ladder below if anything needs to change from the * previous to the current version. This allows for incremental upgrades * incase a user upgrades from a few versions prior. ****************************************************************************/ // Read the config file from home directory ConfigObject<ConfigValue> *config = new ConfigObject<ConfigValue>(settingsPath + SETTINGS_FILE); QString configVersion = config->getValueString(ConfigKey("[Config]","Version")); if (configVersion.isEmpty()) { #ifdef __APPLE__ qDebug() << "Config version is empty, trying to read pre-1.9.0 config"; //Try to read the config from the pre-1.9.0 final directory on OS X (we moved it in 1.9.0 final) QFile* oldFile = new QFile(QDir::homePath().append("/").append(".mixxx/mixxx.cfg")); if (oldFile->exists()) { qDebug() << "Found pre-1.9.0 config for OS X"; config = new ConfigObject<ConfigValue>(QDir::homePath().append("/").append(".mixxx/mixxx.cfg")); //Note: We changed SETTINGS_PATH in 1.9.0 final on OS X so it must be hardcoded to ".mixxx" here for legacy. configVersion = config->getValueString(ConfigKey("[Config]","Version")); delete oldFile; } else { #endif //This must have been the first run... right? :) qDebug() << "No version number in configuration file. Setting to" << VERSION; config->set(ConfigKey("[Config]","Version"), ConfigValue(VERSION)); m_bFirstRun = true; return config; #ifdef __APPLE__ } #endif } // If it's already current, stop here if (configVersion == VERSION) { qDebug() << "Configuration file is at the current version" << VERSION; return config; } // Allows for incremental upgrades incase someone upgrades from a few versions prior // (I wish we could do a switch on a QString.) /* // Examples, since we didn't store the version number prior to v1.7.0 if (configVersion.startsWith("1.6.0")) { qDebug() << "Upgrading from v1.6.0 to 1.6.1..."; // Upgrade tasks go here configVersion = "1.6.1"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.6.1")); } if (configVersion.startsWith("1.6.1")) { qDebug() << "Upgrading from v1.6.1 to 1.7.0..."; // Upgrade tasks go here configVersion = "1.7.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.7.0")); } */ //We use the following blocks to detect if this is the first time //you've run the latest version of Mixxx. This lets us show //the promo tracks stats agreement stuff for all users that are //upgrading Mixxx. if (configVersion.startsWith("1.7")) { qDebug() << "Upgrading from v1.7.x..."; // Upgrade tasks go here // Nothing to change, really configVersion = "1.8.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.8.0")); } if (configVersion.startsWith("1.8.0~beta1") || configVersion.startsWith("1.8.0~beta2")) { qDebug() << "Upgrading from v1.8.0~beta..."; // Upgrade tasks go here configVersion = "1.8.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.8.0")); } if (configVersion.startsWith("1.8") || configVersion.startsWith("1.9.0beta1")) { qDebug() << "Upgrading from" << configVersion << "..."; // Upgrade tasks go here #ifdef __APPLE__ QString OSXLocation180 = QDir::homePath().append("/").append(".mixxx"); QString OSXLocation190 = settingsPath; QDir newOSXDir(OSXLocation190); newOSXDir.mkpath(OSXLocation190); QList<QPair<QString, QString> > dirsToMove; dirsToMove.push_back(QPair<QString, QString>(OSXLocation180, OSXLocation190)); dirsToMove.push_back(QPair<QString, QString>(OSXLocation180 + "/midi", OSXLocation190 + "midi")); dirsToMove.push_back(QPair<QString, QString>(OSXLocation180 + "/presets", OSXLocation190 + "presets")); QListIterator<QPair<QString, QString> > dirIt(dirsToMove); QPair<QString, QString> curPair; while (dirIt.hasNext()) { curPair = dirIt.next(); qDebug() << "Moving" << curPair.first << "to" << curPair.second; QDir oldSubDir(curPair.first); QDir newSubDir(curPair.second); newSubDir.mkpath(curPair.second); //Create the new destination directory QStringList contents = oldSubDir.entryList(QDir::Files | QDir::NoDotAndDotDot); QStringListIterator it(contents); QString cur; //Iterate over all the files in the source directory and copy them to the dest dir. while (it.hasNext()) { cur = it.next(); QString src = curPair.first + "/" + cur; QString dest = curPair.second + "/" + cur; qDebug() << "Copying" << src << "to" << dest; if (!QFile::copy(src, dest)) { qDebug() << "Failed to move file during upgrade."; } } //Rename the old directory. newOSXDir.rename(OSXLocation180, OSXLocation180 + "-1.8"); } //Reload the configuration file from the new location. //(We want to make sure we save to the new location...) config = new ConfigObject<ConfigValue>(settingsPath + SETTINGS_FILE); #endif configVersion = "1.9.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.9.0")); } if (configVersion.startsWith("1.9") || configVersion.startsWith("1.10")) { qDebug() << "Upgrading from v1.9.x/1.10.x..."; bool successful = true; qDebug() << "Copying midi/ to controllers/"; QString midiPath = legacyUserPresetsPath(config); QString controllerPath = userPresetsPath(config); QDir oldDir(midiPath); QDir newDir(controllerPath); newDir.mkpath(controllerPath); // create the new directory QStringList contents = oldDir.entryList(QDir::Files | QDir::NoDotAndDotDot); QStringListIterator it(contents); QString cur; //Iterate over all the files in the source directory and copy them to the dest dir. while (it.hasNext()) { cur = it.next(); if (newDir.exists(cur)) { qDebug() << cur << "already exists in" << controllerPath << "Skipping."; continue; } QString src = oldDir.absoluteFilePath(cur); QString dest = newDir.absoluteFilePath(cur); qDebug() << "Copying" << src << "to" << dest; if (!QFile::copy(src, dest)) { qDebug() << "Failed to copy file during upgrade."; successful = false; } } bool reanalyze_choice = askReanalyzeBeats(); config->set(ConfigKey(BPM_CONFIG_KEY, BPM_REANALYZE_WHEN_SETTINGS_CHANGE), ConfigValue(reanalyze_choice)); if (successful) { qDebug() << "Upgrade Successful"; configVersion = "1.11.0"; m_bUpgraded = true; config->set(ConfigKey("[Config]","Version"), ConfigValue(configVersion)); } else { qDebug() << "Upgrade Failed"; } } if (configVersion.startsWith("1.11")) { qDebug() << "Upgrading from v1.11.x..."; // upgrade to the multi library folder settings QString currentFolder = config->getValueString(PREF_LEGACY_LIBRARY_DIR); // to migrate the DB just add the current directory to the new // directories table TrackCollection tc(config); DirectoryDAO directoryDAO = tc.getDirectoryDAO(); // NOTE(rryan): We don't have to ask for sandbox permission to this // directory because the normal startup integrity check in Library will // notice if we don't have permission and ask for access. Also, the // Sandbox isn't setup yet at this point in startup because it relies on // the config settings path and this function is what loads the config // so it's not ready yet. bool successful = directoryDAO.addDirectory(currentFolder); // ask for library rescan to activate cover art. We can later ask for // this variable when the library scanner is constructed. m_bRescanLibrary = askReScanLibrary(); // if everything until here worked fine we can mark the configuration as // updated if (successful) { configVersion = VERSION; m_bUpgraded = true; config->set(ConfigKey("[Config]","Version"), ConfigValue(VERSION)); } else { qDebug() << "Upgrade failed!\n"; } } if (configVersion == VERSION) qDebug() << "Configuration file is now at the current version" << VERSION; else { /* Way too verbose, this confuses the hell out of Linux users when they see this: qWarning() << "Configuration file is at version" << configVersion << "and I don't know how to upgrade it to the current" << VERSION << "\n (That means a function to do this needs to be added to upgrade.cpp.)" << "\n-> Leaving the configuration file version as-is."; */ qWarning() << "Configuration file is at version" << configVersion << "instead of the current" << VERSION; } return config; }
void setUpData(const ConfigObject& config) { m_timeout = config.getInt("SERVER.timeout", m_timeout); m_port = config.getInt("SERVER.port", m_port); m_addr = config.getString("SERVER.ip", m_addr); }