void ActionDialog::on_buttonBox_clicked(QAbstractButton* button) { Command cmd; ConfigurationManager *cm; switch ( ui->buttonBox->standardButton(button) ) { case QDialogButtonBox::Ok: createAction(); break; case QDialogButtonBox::Save: cmd.name = cmd.cmd = ui->cmdEdit->currentText(); cmd.input = ui->comboBoxInputFormat->currentText(); cmd.output = ui->comboBoxOutputFormat->currentText(); cmd.sep = ui->separatorEdit->text(); cmd.outputTab = ui->comboBoxOutputTab->currentText(); cm = ConfigurationManager::instance(); cm->addCommand(cmd); cm->saveSettings(); QMessageBox::information( this, tr("Command saved"), tr("Command was saved and can be accessed from item menu.\n" "You can set up the command in preferences.") ); break; case QDialogButtonBox::Cancel: close(); break; default: break; } }
void ActionDialog::restoreHistory() { ConfigurationManager *cm = ConfigurationManager::instance(); int maxCount = cm->value("command_history_size").toInt(); ui->comboBoxCommands->setMaxCount(maxCount); QFile file( dataFilename() ); file.open(QIODevice::ReadOnly); QDataStream in(&file); QVariant v; ui->comboBoxCommands->clear(); ui->comboBoxCommands->addItem(QString()); while( !in.atEnd() ) { in >> v; if (v.canConvert(QVariant::String)) { // backwards compatibility with versions up to 1.8.2 QVariantMap values; values["cmd"] = v; ui->comboBoxCommands->addItem(commandToLabel(v.toString()), values); } else { QVariantMap values = v.value<QVariantMap>(); ui->comboBoxCommands->addItem(commandToLabel(values["cmd"].toString()), v); } } ui->comboBoxCommands->setCurrentIndex(0); }
CommandWidget::CommandWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::CommandWidget) { ui->setupUi(this); updateWidgets(); #ifdef NO_GLOBAL_SHORTCUTS ui->checkBoxGlobalShortcut->hide(); ui->shortcutButtonGlobalShortcut->hide(); #else ui->checkBoxGlobalShortcut->setIcon(iconShortcut()); ui->shortcutButtonGlobalShortcut->setExpectModifier(true); #endif ui->groupBoxCommand->setFocusProxy(ui->commandEdit); ui->checkBoxAutomatic->setIcon(iconClipboard()); ui->checkBoxInMenu->setIcon(iconMenu()); ConfigurationManager *cm = ConfigurationManager::instance(); // Add tab names to combo boxes. cm->initTabComboBox(ui->comboBoxCopyToTab); cm->initTabComboBox(ui->comboBoxOutputTab); // Add formats to combo boxex. QStringList formats = cm->itemFactory()->formatsToSave(); formats.prepend(mimeText); formats.removeDuplicates(); setComboBoxItems(ui->comboBoxInputFormat, formats); setComboBoxItems(ui->comboBoxOutputFormat, formats); }
// Fetches the singleton Configuration Manager object ConfigurationManager * ConfigurationManager::get() { static ConfigurationManager ConfigManager; if (ConfigManager.initialized == false) { ConfigManager.init(); ConfigManager.initialized = true; } return &ConfigManager; }
void init() { configuration = ConfigurationManager("next0.txt"); mapLoader = configuration.GetMapLoader(); renderEngine = configuration.GetRenderEngine(); system("mode 650"); utility = Utilities(); playerX = 5; playerY = 7; }
Component::Component(ConfigurationManager& params) : ResourceAccessor(params, params.getConfigurationNodeForCurrentComponent()) , m_type(params.getTypeForCurrentComponent()) , m_configurationNode(params.getConfigurationNodeForCurrentComponent()) , m_prefix(params.getPrefixForCurrentComponent()) { // Telling the ConfigurationManager that the object for the group in prefix is about // to be created m_confManager->setComponentFromGroupStatusToCreating(m_prefix, this); // Declaring self as a resource of ours declareResource(ConfigurationNode::separateLastElement(confPath()).element, this); }
void ClipboardBrowserShared::loadFromConfiguration() { ConfigurationManager *cm = ConfigurationManager::instance(); editor = cm->value("editor").toString(); maxItems = cm->value("maxitems").toInt(); formats = ItemFactory::instance()->formatsToSave(); maxImageWidth = cm->value("max_image_width").toInt(); maxImageHeight = cm->value("max_image_height").toInt(); textWrap = cm->value("text_wrap").toBool(); commands = cm->commands(); viMode = cm->value("vi").toBool(); saveOnReturnKey = !cm->value("edit_ctrl_return").toBool(); moveItemOnReturnKey = cm->value("move").toBool(); }
void ActionDialog::loadSettings() { ConfigurationManager *cm = ConfigurationManager::instance(); restoreHistory(); ui->comboBoxInputFormat->clear(); ui->comboBoxInputFormat->addItems(standardFormats); ui->comboBoxInputFormat->setCurrentIndex(cm->value("action_has_input").toBool() ? 1 : 0); ui->comboBoxOutputFormat->clear(); ui->comboBoxOutputFormat->addItems(standardFormats); ui->comboBoxOutputFormat->setCurrentIndex(cm->value("action_has_output").toBool() ? 1 : 0); ui->separatorEdit->setText(cm->value("action_separator").toString()); ui->comboBoxOutputTab->setEditText(cm->value("action_output_tab").toString()); }
void CommandMapper::buildCommandMapping() { ConfigurationManager* cfgMgr = ConfigurationManager::getSingletonPtr(); InputManager* inputMgr = InputManager::getSingletonPtr(); // First get the movement commands const NameValuePairList& commands = cfgMgr->getSettings("Movement keys"); for (NameValuePairList::const_iterator it = commands.begin(); it != commands.end(); it++) { // Split the path at the ',' character StringVector keys = Ogre::StringUtil::split(it->second, ","); for (size_t i = 0; i < keys.size(); i++) { mMovementCommands[inputMgr->getScanCode(keys[i])] = getMovement(it->first); LOG_MESSAGE(Logger::UI, Ogre::String("Key ") + keys[i] + " (" + StringConverter::toString(inputMgr->getScanCode(keys[i])) + ") is assigned to movement " + it->first +" (" + StringConverter::toString(getMovement(it->first))+")"); } } buildCommandMap(mKeyGlobalActions, cfgMgr->getSettings("Action keys")); buildCommandMap(mKeyMovementControlState, cfgMgr->getSettings("MovementController keys")); buildCommandMap(mKeyFreeflightControlState, cfgMgr->getSettings("FreeflightController keys")); buildCommandMap(mKeyDialogControlState, cfgMgr->getSettings("DialogController keys")); buildCommandMap(mKeyCombatControlState, cfgMgr->getSettings("CombatController keys")); buildCommandMap(mKeyCutsceneControlState, cfgMgr->getSettings("CutsceneController keys")); }
void ClipboardBrowserShared::loadFromConfiguration() { ConfigurationManager *cm = ConfigurationManager::instance(); editor = cm->value("editor").toString(); maxItems = cm->value("maxitems").toInt(); textWrap = cm->value("text_wrap").toBool(); viMode = cm->value("vi").toBool(); saveOnReturnKey = !cm->value("edit_ctrl_return").toBool(); moveItemOnReturnKey = cm->value("move").toBool(); minutesToExpire = cm->value("expire_tab").toInt(); }
void ActionDialog::restoreHistory() { ConfigurationManager *cm = ConfigurationManager::instance(); int maxCount = cm->value("command_history_size").toInt(); ui->cmdEdit->setMaxCount(maxCount); QFile file( dataFilename() ); file.open(QIODevice::ReadOnly); QDataStream in(&file); QVariant v; ui->cmdEdit->clear(); while( !in.atEnd() ) { in >> v; ui->cmdEdit->addItem(v.toString()); } ui->cmdEdit->setCurrentIndex(0); ui->cmdEdit->lineEdit()->selectAll(); }
/** * The client is requesting an offer. * * @returns true. * * @param pDhcpMsg The message. * @param cb The message size. */ bool NetworkManager::handleDhcpReqRequest(PCRTNETBOOTP pDhcpMsg, size_t cb) { ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); /* 1. find client */ Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb); /* 2. find bound lease */ Lease l = client.lease(); if (l != Lease::NullLease) { if (l.isExpired()) { /* send client to INIT state */ Client c(client); nak(client, pDhcpMsg->bp_xid); confManager->expireLease4Client(c); return true; } else { /* XXX: Validate request */ RawOption opt; RT_ZERO(opt); Client c(client); int rc = confManager->commitLease4Client(c); AssertRCReturn(rc, false); rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt); AssertRCReturn(rc, false); ack(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt); } } else { nak(client, pDhcpMsg->bp_xid); } return true; }
int VBoxNetDhcp::initNoMain() { CmdParameterIterator it; RTNETADDRIPV4 address = getIpv4Address(); RTNETADDRIPV4 netmask = getIpv4Netmask(); RTNETADDRIPV4 networkId; networkId.u = address.u & netmask.u; RTNETADDRIPV4 UpperAddress; RTNETADDRIPV4 LowerAddress = networkId; UpperAddress.u = RT_H2N_U32(RT_N2H_U32(LowerAddress.u) | RT_N2H_U32(netmask.u)); for (it = CmdParameterll.begin(); it != CmdParameterll.end(); ++it) { switch(it->Key) { case 'l': RTNetStrToIPv4Addr(it->strValue.c_str(), &LowerAddress); break; case 'u': RTNetStrToIPv4Addr(it->strValue.c_str(), &UpperAddress); break; case 'b': break; } } ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); AssertPtrReturn(confManager, VERR_INTERNAL_ERROR); confManager->addNetwork(unconst(g_RootConfig), networkId, netmask, LowerAddress, UpperAddress); return VINF_SUCCESS; }
int VBoxNetDhcp::fetchAndUpdateDnsInfo() { ComHostPtr host; if (SUCCEEDED(virtualbox->COMGETTER(Host)(host.asOutParam()))) { AddressToOffsetMapping mapIp4Addr2Off; int rc = localMappings(m_NATNetwork, mapIp4Addr2Off); /* XXX: here could be several cases: 1. COM error, 2. not found (empty) 3. ? */ AssertMsgRCReturn(rc, ("Can't fetch local mappings"), rc); RTNETADDRIPV4 address = getIpv4Address(); RTNETADDRIPV4 netmask = getIpv4Netmask(); AddressList nameservers; rc = hostDnsServers(host, networkid(address, netmask), mapIp4Addr2Off, nameservers); AssertMsgRCReturn(rc, ("Debug me!!!"), rc); /* XXX: Search strings */ std::string domain; rc = hostDnsDomain(host, domain); AssertMsgRCReturn(rc, ("Debug me!!"), rc); { VBoxNetALock(this); ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); confManager->flushAddressList(RTNET_DHCP_OPT_DNS); for (AddressList::iterator it = nameservers.begin(); it != nameservers.end(); ++it) confManager->addToAddressList(RTNET_DHCP_OPT_DNS, *it); confManager->setString(RTNET_DHCP_OPT_DOMAIN_NAME, domain); } } return VINF_SUCCESS; }
/** * The client is requesting an offer. * * @returns true. * * @param pDhcpMsg The message. * @param cb The message size. */ bool NetworkManager::handleDhcpReqDiscover(PCRTNETBOOTP pDhcpMsg, size_t cb) { RawOption opt; RT_ZERO(opt); /* 1. Find client */ ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); Client client = confManager->getClientByDhcpPacket(pDhcpMsg, cb); /* 2. Find/Bind lease for client */ Lease lease = confManager->allocateLease4Client(client, pDhcpMsg, cb); AssertReturn(lease != Lease::NullLease, VINF_SUCCESS); int rc = ConfigurationManager::extractRequestList(pDhcpMsg, cb, opt); /* 3. Send of offer */ lease.bindingPhase(true); lease.phaseStart(RTTimeMilliTS()); lease.setExpiration(300); /* 3 min. */ offer4Client(client, pDhcpMsg->bp_xid, opt.au8RawOpt, opt.cbRawOpt); return VINF_SUCCESS; }
void ActionDialog::saveSettings() { ConfigurationManager *cm = ConfigurationManager::instance(); cm->saveGeometry(this); cm->setValue("action_has_input", ui->comboBoxInputFormat->currentText() == QString("text/plain")); cm->setValue("action_has_output", ui->comboBoxOutputFormat->currentText() == QString("text/plain")); cm->setValue("action_separator", ui->separatorEdit->text()); cm->setValue("action_output_tab", ui->comboBoxOutputTab->currentText()); saveHistory(); }
TransportHeartBeat::TransportHeartBeat(ConfigurationManager &config) : _configurationManager(config) { _timer.setInterval(config.getHeartBeatInterval()); connect(&_timer, SIGNAL(timeout()), this, SLOT(beat())); _timer.start(); }
int VBoxNetDhcp::initWithMain() { /* ok, here we should initiate instance of dhcp server * and listener for Dhcp configuration events */ AssertRCReturn(virtualbox.isNull(), VERR_INTERNAL_ERROR); std::string networkName = getNetwork(); int rc = findDhcpServer(virtualbox, networkName, m_DhcpServer); AssertRCReturn(rc, rc); rc = findNatNetwork(virtualbox, networkName, m_NATNetwork); AssertRCReturn(rc, rc); BOOL fNeedDhcpServer = isDhcpRequired(m_NATNetwork); if (!fNeedDhcpServer) return VERR_CANCELLED; RTNETADDRIPV4 gateway; com::Bstr strGateway; HRESULT hrc = m_NATNetwork->COMGETTER(Gateway)(strGateway.asOutParam()); AssertComRCReturn(hrc, VERR_INTERNAL_ERROR); RTNetStrToIPv4Addr(com::Utf8Str(strGateway).c_str(), &gateway); ConfigurationManager *confManager = ConfigurationManager::getConfigurationManager(); AssertPtrReturn(confManager, VERR_INTERNAL_ERROR); confManager->addToAddressList(RTNET_DHCP_OPT_ROUTERS, gateway); rc = fetchAndUpdateDnsInfo(); AssertMsgRCReturn(rc, ("Wasn't able to fetch Dns info"), rc); ComEventTypeArray aVBoxEvents; aVBoxEvents.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange); rc = createNatListener(m_vboxListener, virtualbox, this, aVBoxEvents); AssertRCReturn(rc, rc); RTNETADDRIPV4 LowerAddress; rc = configGetBoundryAddress(m_DhcpServer, false, LowerAddress); AssertMsgRCReturn(rc, ("can't get lower boundrary adderss'"),rc); RTNETADDRIPV4 UpperAddress; rc = configGetBoundryAddress(m_DhcpServer, true, UpperAddress); AssertMsgRCReturn(rc, ("can't get upper boundrary adderss'"),rc); RTNETADDRIPV4 address = getIpv4Address(); RTNETADDRIPV4 netmask = getIpv4Netmask(); RTNETADDRIPV4 networkId = networkid(address, netmask); std::string name = std::string("default"); confManager->addNetwork(unconst(g_RootConfig), networkId, netmask, LowerAddress, UpperAddress); com::Bstr bstr; hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam()); com::Utf8StrFmt strXmlLeaseFile("%ls%c%s.leases", bstr.raw(), RTPATH_DELIMITER, networkName.c_str()); confManager->loadFromFile(strXmlLeaseFile); return VINF_SUCCESS; }
Map CreateMap(ConfigurationManager config) { std::vector<unsigned char> image; unsigned width, height; unsigned int x, y; const char* path = config.getMapPath(); unsigned error = lodepng::decode(image, width, height, path); if (error) { std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl; } // Get parameters double gridResoultion = config.getGridResolutionCM(); double mapResoultion = config.getMapResolutionCM(); int divider = ceil(gridResoultion/mapResoultion); // Numbers of pixels for 1 cell in matrix // Create map as png pixels char** map = initializeMatrix(height + (divider - 1) * 2,width + (divider - 1) * 2, FREE_CELL); unsigned char color; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (image[y * width * 4 + x * 4 + 0] || image[y * width * 4 + x * 4 + 1] || image[y * width * 4 + x * 4 + 2]) { // There is an obstacle in the map color = FREE_CELL; } else { // There is no obstacle color = BLOCK_CELL; } map[y + divider - 1][x + divider - 1] = color; } } // Create map as config cm size int newMapHieght = height/divider; int newMapWidth = width/divider; char** mapBlow = initializeMatrix(newMapHieght, newMapWidth, FREE_CELL); unsigned i,j; int mapBlowY = 0, mapBlowX = 0; bool hasObstacle = false; for (y = divider - 1; y < height; y += divider) { for (x = divider - 1; x < width; x += divider) { for (i = 0; i < divider && !hasObstacle; i++) { for (j = 0; j < divider && !hasObstacle; j++) { if (map[y + i][x + j] == BLOCK_CELL) { hasObstacle = true; } } } if (hasObstacle) { mapBlow[mapBlowY][mapBlowX] = BLOCK_CELL; } hasObstacle = false; mapBlowX++; } mapBlowX = 0; mapBlowY++; } // ReSize obstacle double* robotSize = config.getRobotSize(); int sizeH = ceil(((robotSize[0] / gridResoultion)- 1) / 2); int sizeW = ceil(((robotSize[1] / gridResoultion)- 1) / 2); char** newMap = initializeMatrix(newMapHieght + sizeH*2, newMapWidth + sizeW*2, FREE_CELL); for (int i = 0; i < newMapHieght; i++) { for (int j = 0; j < newMapWidth; j++) { if (mapBlow[i][j] == BLOCK_CELL) { for (int iNewMap = i; iNewMap <= i + sizeH + 1; iNewMap++) { for (int jNewMap = j; jNewMap <= j + sizeW + 1; jNewMap++) { newMap[iNewMap][jNewMap] = BLOCK_CELL; } } } } } // Initialize final map with wall block of size 1. char** finalMap = initializeMatrix(newMapHieght + 2, newMapWidth + 2, BLOCK_CELL); for (int i=1; i < newMapHieght + 1; i++) { for (int j=1; j< newMapWidth + 1; j++) { finalMap[i][j] = newMap[sizeH + i - 1][sizeW + j -1]; } } printMap(map, height + 6, width + 6); printMap(mapBlow, newMapHieght, newMapWidth); printMap(newMap, newMapHieght + sizeH, newMapWidth + sizeW); printMap(finalMap, newMapHieght + 2, newMapWidth + 2); return Map(finalMap, newMapHieght + 2, newMapWidth + 2, gridResoultion / 100); }
void Map::initMap(const char* filename) { std::vector<unsigned char> image; std::vector<unsigned char> FatImage; unsigned width, height; unsigned x, y, bX, bY; // Get the config ConfigurationManager* config = ConfigurationManager::GetInstance(); //decode unsigned error = lodepng::decode(image, width, height, config->getPngMapPath()); //if there's an error, display it if (error) std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl; // Create the fat img FatImage.resize(width * height); // calc the size of the robot in pic px unsigned PxToBlow = ceil( config->getRobotSize().RadiosSize() / config->getPngGridResolution()); // run on the map and find the unsigned char color; for (y = 0; y < height; y++) for (x = 0; x < width; x++) { if (image[y * width * 4 + x * 4 + 0] || image[y * width * 4 + x * 4 + 1] || image[y * width * 4 + x * 4 + 2]) color = 0; // add oppstical to the fat img for (bX = std::max(x - PxToBlow, static_cast<unsigned int>(0)); bX < PxToBlow + x; bX++) for (bY = std::max(x - PxToBlow, static_cast<unsigned int>(0)); bY < PxToBlow + y; bY++) { FatImage[y * width * 4 + x * 4 + 0] = color; FatImage[y * width * 4 + x * 4 + 1] = color; FatImage[y * width * 4 + x * 4 + 2] = color; FatImage[y * width * 4 + x * 4 + 3] = 255; } } // create grid from the fat and regular map this->FatGrid = this->CreatGridFromMap(FatImage, height, width, config->getPngGridResolution(), config->getPixelPerCm(), this->m_Cols, this->m_Rows); unsigned error2 = lodepng::encode("try.png", this->FatGrid, width, height); this->RegGrid = this->CreatGridFromMap(image, height, width, config->getPngGridResolution(), config->getPixelPerCm(), this->m_Cols, this->m_Rows); }