示例#1
0
    void ExplorerReplicaSetFolderItem::on_repSetStatus()
    {
        if (!_server->replicaSetInfo()->primary.empty()) {
            openCurrentServerShell(_server, "rs.status()");
        }
        else // primary is unreachable
        {
            // Todo: do this before 
            // Run rs.status only if there is a reachable secondary
            mongo::HostAndPort onlineMember;
            for (auto const& member : _server->replicaSetInfo()->membersAndHealths) {
                if (member.second) {
                    onlineMember = mongo::HostAndPort(member.first);
                    break;
                }
            }
            if (onlineMember.empty())   // todo: throw error
                return;

            auto connSetting = _server->connectionRecord()->clone();    // todo: unique_ptr
            // Set connection settings of this replica member
            connSetting->setConnectionName(onlineMember.toString() + 
                                           " [member of " + connSetting->connectionName() + "]");
            connSetting->setServerHost(onlineMember.host());
            connSetting->setServerPort(onlineMember.port());
            connSetting->setReplicaSet(false);
            connSetting->replicaSetSettings()->setMembers(std::vector<std::string>()); 

            openCurrentServerShell(_server, connSetting, "rs.status()");
        }
    }
示例#2
0
// Load server URL
void SoffidEssoManager::LoadServerURL ()
{
	std::string firstServer;	// First server of list
	std::string servers;		// List of available servers
	size_t pos;					// End post for first server

	SeyconCommon::getServerList(servers);

	// Search delimiter of servers on list
	pos = servers.find(",");

	// Check search first server
	if (pos != std::string::npos)
	{
		setServerUrl(servers.substr(0, pos));
	}

	else
	{
		setServerUrl(servers);
	}

	// Get server port
	setServerPort(SeyconCommon::getServerPort());
}
示例#3
0
void OptionsWidget::createSettings()
{
  m_settings.setValue("channel", m_channelEdit->text());
  m_settings.setValue("user", m_nameEdit->text());
  m_settings.setValue("password", m_passwordEdit->text());

  QNetworkProxy::ProxyType proxy_type = (QNetworkProxy::ProxyType)m_proxyType->itemData(m_proxyType->currentIndex()).toInt();
  m_settings.setValue("proxy_type", proxy_type);
  if(proxy_type != QNetworkProxy::DefaultProxy && proxy_type != QNetworkProxy::NoProxy)
  {
    m_settings.setValue("proxy_host", m_proxyHostEdit->text());
    m_settings.setValue("proxy_port", m_proxyPortEdit->value());
  }
  else
  {
    m_settings.remove("proxy_host");
    m_settings.remove("proxy_port");
  }

  setServerUrl(m_serverUrlEdit->text());
  setServerPort(m_serverPortEdit->value());

  m_settings.setValue("cache_type", m_cacheType->itemData(m_cacheType->currentIndex()).toInt());
  if(m_cacheType->itemData(m_cacheType->currentIndex()).toInt() > 0)
    m_settings.setValue("cache_path", m_cachePath->text());
  else
  if (m_productName == "tracker")
  {
    m_settings.setValue("visibleName", m_visibleNameEdit->text());
  }
  m_settings.remove("cache_path");
  m_settings.setValue("magic", APP_MAGIC);
}
void TcpClient::tryConnectToHost(const QString &host, int port)
{
    setServerPort(port);
    if (host == zeroHost) {
        if (!findLocalIpv4InterfaceData()) {
            return;
        }
    } else {
        if (connectToHost(host, port)) {
            setServerIp(host);
        }
    }
}
示例#5
0
文件: DB.cpp 项目: karolherbst/toc
		void
		DBImpl::
		setConnectionInfo(std::string& server,
		                  uint32_t port,
		                  std::string& user,
		                  std::string& pw,
		                  std::string& db)
		{
			setServerURL(server);
			setServerPort(port);
			setUserName(user);
			setUserPassword(pw);
			setDatabaseName(db);
		}
示例#6
0
FClient::FClient()
{
	char buf[PATH_MAX];
	
	/* set the default server name */
	setServerName("localhost");

	/* set the default port number */
	setServerPort(10002);

	/* set the directory to the current working directory */
	getcwd(buf,PATH_MAX);
	setTargetDirectory(buf);
	
}
示例#7
0
void PluginQt::Init()
{
    if (m_isInit)
        return;

    QSettings cfg(TSHelpers::GetFullConfigPath(), QSettings::IniFormat);
    bool ok;
    quint16 port = cfg.value("server_port",64736).toUInt(&ok);
    if (!ok)
        TSLogging::Error("Could not read port from settings");
    else
    {
        setServerPort(port);
        setServerEnabled(cfg.value("server_enabled",false).toBool());
    }

//#ifdef USE_QT_WEB_APP
//    m_HttpServer = new TsHttpServer();
//    m_HttpServer->init();
//#endif

    m_isInit = true;
}
示例#8
0
    /**
     * Discards current state and applies state from 'source' ConnectionSettings.
     */
    void ConnectionSettings::apply(const ConnectionSettings *source)
    {
        setConnectionName(source->connectionName());
        setServerHost(source->serverHost());
        setServerPort(source->serverPort());
        setDefaultDatabase(source->defaultDatabase());
        setImported(source->imported());
        setReplicaSet(source->isReplicaSet());

        clearCredentials();
        QList<CredentialSettings *> cred = source->credentials();
        for (QList<CredentialSettings *>::iterator it = cred.begin(); it != cred.end(); ++it) {
            addCredential((*it)->clone());
        }

        _sshSettings.reset(source->sshSettings()->clone());
        _sslSettings.reset(source->sslSettings()->clone());
        _replicaSetSettings.reset(source->_replicaSetSettings->clone());

//#ifdef MONGO_SSL
//        setSslInfo(source->sslInfo());
//#endif
    }
示例#9
0
    void ConnectionSettings::fromVariant(const QVariantMap &map) {
        setConnectionName(QtUtils::toStdString(map.value("connectionName").toString()));
        setServerHost(QtUtils::toStdString(map.value("serverHost").toString().left(maxLength)));
        setServerPort(map.value("serverPort").toInt());
        setDefaultDatabase(QtUtils::toStdString(map.value("defaultDatabase").toString()));
        setReplicaSet(map.value("isReplicaSet").toBool());       
        
        QVariantList list = map.value("credentials").toList();
        for (QVariantList::const_iterator it = list.begin(); it != list.end(); ++it) {
            QVariant var = *it;
            CredentialSettings *credential = new CredentialSettings(var.toMap());
            addCredential(credential);
        }

        if (map.contains("ssh")) {
            _sshSettings->fromVariant(map.value("ssh").toMap());
        }

        if (map.contains("ssl")) {
            _sslSettings->fromVariant(map.value("ssl").toMap());
        }

        if (isReplicaSet()) {
            _replicaSetSettings->fromVariant(map.value("replicaSet").toMap());
        }

        // If UUID has never been created or is empty, create a new one. Otherwise load the existing.
        if (!map.contains("uuid") || map.value("uuid").toString().isEmpty())
            _uuid = QUuid::createUuid().toString();
        else
            _uuid = map.value("uuid").toString();


//#ifdef MONGO_SSL
//      ,SSLInfo(map.value("sslEnabled").toBool(),QtUtils::toStdString(map.value("sslPemKeyFile").toString()))
//#endif
    }
示例#10
0
bool TcpServer::listen(const IpAddress& address, uint16_t port)	
{
	if(address.isNull())
		return false;

	int fd = socket(AF_INET, SOCK_STREAM, 0);

	struct sockaddr_in addr;
	bzero(&addr, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	inet_pton(AF_INET, address.toString().c_str(), &addr.sin_addr);	
	
	if(bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == 0)
	{
		setServerAddress(address); 
	 	setServerPort(port);
		setSocketDescriptor(fd);
		if(::listen(fd, SOMAXCONN) == 0)
			return true;
	}

	return false;
}
示例#11
0
// Configure the MotionStar with the given config element.
bool MotionStar::config(jccl::ConfigElementPtr e)
{
   bool retval(false);

   if ( Input::config(e) &&  Position::config(e) )
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
         << "MotionStar::config(jccl::ConfigElementPtr)\n"
         << vprDEBUG_FLUSH;

      const unsigned int cur_version(2);

      if ( e->getVersion() < cur_version )
      {
         vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << clrOutBOLD(clrRED, "ERROR")
            << " [gadget::MotionStar::config()] Element named '"
            << e->getName() << "'" << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "is version " << e->getVersion()
            << ", but we require at least version " << cur_version
            << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << "Ignoring this element and moving on." << std::endl
            << vprDEBUG_FLUSH;
         retval = false;
      }
      else
      {
         // Configure mMotionStar with the config info.
         const unsigned num_filters = e->getNum("position_filters");

         // Sanity check.  There has to be at least one position filter
         // configured.
         if ( num_filters == 0 )
         {
            vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
               << clrOutBOLD(clrRED, "ERROR")
               << ": [MotionStar::config(jccl::ConfigElementPtr)] No position "
               << "filters configured in " << e->getName() << std::endl
               << vprDEBUG_FLUSH;
            retval = false;
         }
         else
         {
            BIRDNET::units expected_units;

            // Find the first position_transform_filter instance and get its
            // device_units property value.  This will tell us what units we're
            // expecting from the hardware.
            const std::string filter_type("position_transform_filter");
            for ( unsigned i = 0; i < num_filters; ++i )
            {
               jccl::ConfigElementPtr pos_elt =
                  e->getProperty<jccl::ConfigElementPtr>("position_filters", i);

               if ( pos_elt->getID() == filter_type )
               {
                  const float unit_conv =
                     pos_elt->getProperty<float>("device_units");

                  vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_VERB_LVL)
                     << "[gadget::MotionStar::config()] Read " << unit_conv
                     << " as the conversion from device units to meters.\n"
                     << vprDEBUG_FLUSH;

                  // Inches.  This is the most likely configuration as of this
                  // writing.
                  if ( unit_conv == 0.0254f )
                  {
                     expected_units = BIRDNET::INCHES;
                  }
                  // Feet.
                  else if ( unit_conv == 0.3048f )
                  {
                     expected_units = BIRDNET::FEET;
                  }
                  // Meters.
                  else if ( unit_conv == 1.0f )
                  {
                     expected_units = BIRDNET::METERS;
                  }
                  // Unexpected value.
                  else
                  {
                     vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "[MotionStar::config(jccl::ConfigElementPtr)] "
                        << clrOutBOLD(clrRED, "ERROR")
                        << ": Unsupported device unit value " << unit_conv
                        << " in " << pos_elt->getFullName() << std::endl
                        << vprDEBUG_FLUSH;
                     vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
                        << "Check your configuration for errors.\n"
                        << vprDEBUG_FLUSH;

                     // Break out of this method early because the
                     // configuration element we were given is bad.
                     return false;
                  }

                  // We're done checking for unit conversion values.
                  break;
               }
            }

            mMotionStar.setExpectedUnits(expected_units);

            setAddressName(e->getProperty<std::string>("address").c_str());
            setServerPort((unsigned short) e->getProperty<int>("server_port"));
            setMasterStatus(e->getProperty<bool>("is_master"));
            setHemisphere((unsigned char) e->getProperty<int>("hemisphere"));
            setBirdFormat((unsigned int) e->getProperty<int>("data_format"));
            setRunMode((unsigned int) e->getProperty<int>("mode"));
            setReportRate((unsigned char) e->getProperty<int>("report_rate"));
            setMeasurementRate(e->getProperty<float>("measurement_rate"));
            retval = true;
         }
      }
   }

   return retval;
}
示例#12
0
/***********************************************************************
		module		:	[WIFI]
		function	:	[WIFI网络设置子菜单]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[WIFI]
		date		:	[11/07/26]
 		author		:	[chen-zhengkai]
************************************************************************/
void wifinet_set()
{
	int select = -1;
	char db_menu_str[] =		"1. 设置本机IP  "
							"2. 设置子网掩码"
							"3. 设置网关    "
							"4. 设置服务器IP"
							"5. 设置端口    "
							"6. 设置ssid    "
							"7. 设置密码    "
							"8. 清空安全设置";

//	if ( adminPassword(0) ) {
//		return;
//	}
	BROWINFO	info;
	info.iStr = db_menu_str;		//浏览内容指针
	info.lPtr = 0;					//显示内容iStr的起始显示行
	info.cPtr = 0;					//当前选择行

	while (1) {
		//以下BROWINFO结构成员变量必须参与循环,有可能会被EXT_Brow_Select函数改变
		info.startLine = 0;				//在LCD上的显示起始行
		info.dispLines = 7;				//在LCD上的显示行数
		info.mInt = 8;					//显示内容的总行数
		info.lineMax = 15;				//每行最大字符数
		info.sFont = 0;					//7x9大字体显示
		info.numEnable = 0;				//是否允许数字键代替方向控制
		info.qEvent = EXIT_KEY_F1|EXIT_AUTO_QUIT|EXIT_KEY_POWER|EXIT_KEY_CANCEL;    //可导致函数退出的事件标志
		info.autoexit = 1200;			//自动退出的时间
		//菜单
		Disp_Clear();
		select = EXT_Brow_Select(&info);

		switch (select) {
			case 0:		//设置本机IP
				setIP();
				break;
			case 1:		//设置子网掩码
				setNetMask();
				break;
			case 2:		//设置网关
				setGateway();
				break;
			case 3:		//设置服务器IP
				setServerIP();
				break;
			case 4:		//设置端口
				setServerPort();
				break;
			case 5:		//设置SSID
				setServerSSID();
				break;
			case 6:		//设置密码
				setPassword();
				break;
			case 7:		//清空安全设置
				clearPSK();
				break;
			default:	//降低CPU占用率,降低能耗
				if (info.qEvent == EXIT_KEY_F1  || EXIT_AUTO_QUIT 
                                || EXIT_KEY_POWER || EXIT_KEY_CANCEL) { //返回上级菜单 
					return;
				}
				Sys_Power_Sleep(3);
				break;
		}
	}
}
示例#13
0
void Settings::loadDefaults()
{
    setServerIP("localhost");
    setServerPort(8080);
    setSimilarityThreshold(0.75);
}