Exemple #1
0
void Actions::on_buttonBox_clicked(QAbstractButton *button){
    if(ui->buttonBox->standardButton(button) == QDialogButtonBox::Ok){
        emit setMethod(ui->comboBox->currentIndex(), ui->label_4->text(), ui->textEdit->toPlainText().split("\n"));
    }
    if(ui->buttonBox->standardButton(button) == QDialogButtonBox::Apply){
        emit setMethod(ui->comboBox->currentIndex(), ui->label_4->text(), ui->textEdit->toPlainText().split("\n"));
        ui->checkBox->setChecked(true);
        setEnabledButtons(false);
    }
}
        DemoBrowserObject (JuceDemoBrowserPlugin* bp)  : owner (bp)
        {
            // Add a couple of methods to our object..
            setMethod ("printText", printText);
            setMethod ("popUpMessageBox", popUpMessageBox);
            setMethod ("registerCallbackObject", registerCallbackObject);

            // Add some value properties that the webpage can access
            setProperty ("property1", "testing testing...");
            setProperty ("property2", 12345678.0);
        }
bool HttpRequest::parseHeader(const string& header)
{
    //解析Http消息头的第一行,即请求行,Method Location HttpVer : GET /index.html HTTP/1.1
    std::vector<std::string> token;
    auto start = header.begin();
    for (auto it = header.begin(); it != header.end(); ++it)
    {
        if (*it == ' ' || *it == '\r' || *it == '\0')
        {
            std::string tmp;
            copy(start, it, std::back_inserter(tmp));
            token.push_back( tmp );

            start = ++it;
        }
        if( *it == '\n' )
            break;
    }

    auto& method = token[0];
    std::transform(method.begin(), method.end(), method.begin(), ::tolower);
    if(strcmp(method.c_str(), "get") == 0)
        setMethod(HttpMethod::HttpGet);
    else if (strcmp(method.c_str(), "post") == 0)
        setMethod(HttpMethod::HttpPost);
    else if (strcmp(method.c_str(), "put") == 0)
        setMethod(HttpMethod::HttpPut);
    else if (strcmp(method.c_str(), "delete") == 0)
        setMethod(HttpMethod::HttpDelete);

    //HttpVersion,Client发过来的http协议版本号
    setVersion((token[2] == "HTTP/1.1" ? HttpVersion::HTTP_VERSION_1_1 : HttpVersion::HTTP_VERSION_1_0));

    ///* 解析剩余的选项行 */
    //std::regex expr("([a-zA-Z_-]*)\\s?:\\s?(.*)");
    //std::smatch match;
    //std::string request = header;
    //while(std::regex_search(request, match, expr))
    //{
    //    std::string key = match[1].str();
    //    std::string value = match[2].str();
    //    std::transform(key.begin(), key.end(), key.begin(), ::tolower);

    //    headers_.insert(std::make_pair(key, value));

    //    request = match.suffix().str();
    //}

    return true;
}
int VPLHttp2__Impl::Put(const std::string &reqBodyFilePath,
                        VPLHttp2_ProgressCb sendProgCb,
                        void *sendProgCtx,
                        std::string &respBody)
{
    int rv = 0;

    GET_HANDLE(&(this->mutex), this->handleInUse);

    setMethod(PUT);
    rv = sendFromFile(reqBodyFilePath);
    if (rv == 0) {
        rv = setupProgressCallback(sendProgCb, sendProgCtx);
    }
    if (rv == 0) {
        rv = recvToString(respBody);
    }
    if (rv == 0) {
        rv = connect();
    }

    PUT_HANDLE(&(this->mutex), this->handleInUse);

    return rv;
}
Exemple #5
0
int RtspConnection::sendAndVerify(int method) {
	setMethod(method);
	SetRequestHeader("CSeq", intToString(CSeq));

	if(gotSessionId) {
		SetRequestHeader("Session", sessionId);
	}

	if(finish()<0) return CONNERR_GENERIC;
	const std::string *cseqStr = GetResponseHeader("CSeq");
	if(!cseqStr) return CONNERR_GENERIC;
	int recvCSeq = atoi(cseqStr->c_str());
	if(recvCSeq != CSeq) return CONNERR_GENERIC;

	const std::string *recvSessionId = GetResponseHeader("Session");
	if(recvSessionId) {
		std::string temp = *recvSessionId + ";";
		if(gotSessionId) {
			if(temp != sessionId) {
				return CONNERR_GENERIC;
			}
		} else {
			gotSessionId = true;
			sessionId = temp;
		}
	}

	return 0;
}
int VPLHttp2__Impl::Post(const std::string &reqBody,
                         VPLHttp2_RecvCb recvCb, 
                         void *recvCtx,
                         VPLHttp2_ProgressCb recvProgCb, 
                         void *recvProgCtx)
{

    int rv = 0;

    GET_HANDLE(&(this->mutex), this->handleInUse);

    setMethod(POST);
    rv = sendFromString(reqBody);
    if( rv == 0) {
        rv = recvToCallback(recvCb, recvCtx);
    }
    if (rv == 0) {
        rv = setupProgressCallback(recvProgCb, recvProgCtx);
    }
    if (rv == 0) {
        rv = connect();
    }

    PUT_HANDLE(&(this->mutex), this->handleInUse);

    return rv;
}
void HTTPRequest::read(std::istream& istr)
{
	static const int eof = std::char_traits<char>::eof();

	std::string method;
	std::string uri;
	std::string version;
	method.reserve(16);
	uri.reserve(64);
	version.reserve(16);
	int ch = istr.get();
	if (istr.bad()) throw NetException("Error reading HTTP request header");
	if (ch == eof) throw NoMessageException();
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	if (ch == eof) throw MessageException("No HTTP request header");
	while (!Poco::Ascii::isSpace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request method invalid or too long");
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	while (!Poco::Ascii::isSpace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request URI invalid or too long");
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	while (!Poco::Ascii::isSpace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("Invalid HTTP version string");
	while (ch != '\n' && ch != eof) { ch = istr.get(); }
	HTTPMessage::read(istr);
	ch = istr.get();
	while (ch != '\n' && ch != eof) { ch = istr.get(); }
	setMethod(method);
	setURI(uri);
	setVersion(version);
}
Exemple #8
0
void dao::setFluxSlot(QString type) {
    soap = new QtSoapHttpTransport();
    if(type=="user"){
        connect(soap, SIGNAL(responseReady()), this, SLOT(slotFluxUser()));
        setMethod("GetUserInfo");
    }else if(type=="bill"){
        connect(soap, SIGNAL(responseReady()), this, SLOT(slotFluxBill()));
        setMethod("GetBillInfo");
    }else if(type=="month"){
        connect(soap, SIGNAL(responseReady()), this, SLOT(slotFluxMonth()));
        setMethod("CurrentMonthFlux");
    }else if(type=="day"){
        connect(soap, SIGNAL(responseReady()), this, SLOT(slotFluxDay()));
        setMethod("GetDayFlux");
    }else{}
}
std::unique_ptr<HTTPMessage> getRequest(HTTPMethod type) {
  auto req = folly::make_unique<HTTPMessage>();
  req->setMethod(type);
  req->setHTTPVersion(1, 1);
  req->setURL("/");
  return req;
}
Exemple #10
0
void Request::requestReceived(const QString &peerAddress, const QStringList &header, const bool &is_http10, const QString &method, const QString &argument, const QHash<QString, QString> &paramsHeader, const QString &content, HttpRange *range, const int &timeSeekRangeStart, const int &timeSeekRangeEnd)
{
    if (!replyInProgress)
    {
        replyInProgress = true;
        clock.start();

        setPeerAddress(peerAddress);
        setHttp10(is_http10);
        setMethod(method);
        setArgument(argument);
        setTextContent(content);
        m_params = paramsHeader;
        m_range = range;
        m_header = header;
        this->timeSeekRangeStart = timeSeekRangeStart;
        this->timeSeekRangeEnd = timeSeekRangeEnd;

        emit readyToReply(method, argument, paramsHeader, isHttp10(), data(contentRole).toString(), getRange(), getTimeSeekRangeStart(), getTimeSeekRangeEnd());

        if (data(argumentRole) == "description/fetch") {
            // new renderer is connecting to server
            emit newRenderer(data(peerAddressRole).toString(), getPort(), getParamHeader("USER-AGENT"));
        }
    }
    else
    {
        qWarning() << QString("unable to read request (socket %1), a reply is in progress.").arg(socketDescriptor()).toUtf8().constData();
    }
}
Exemple #11
0
void dynpm(GtkWidget *widget, gpointer data){
    char **cards = getCards((char*) DEFAULT_DRM_DIR);
    if (cards == NULL) {
        g_printerr("Card list is empty.\n");
        return;
    }

    int idx = 0;
    while (cards[idx] != NULL) {
        g_print("Found card: %s\n", cards[idx]);

        if (canModifyPM()) {
            g_print("Setting dynpm\n");
            setMethod(cards[idx], DYNPM);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }
        } else {
            g_print("Insufficient permission to modify PM method\n");
        }
        idx++;
    }
    freeCards(cards);
}
Exemple #12
0
void dao::setAccount(QString account, QString password){
    iaccount=account;
    ipassword=password;
    soap = new QtSoapHttpTransport();
    connect(soap, SIGNAL(responseReady()), this, SLOT(slotPassport()));
    setMethod("GetPassport",ipassword);
}
Exemple #13
0
	int HybridBase::class__newindex(lua_State *L)
	{
		SLB_DEBUG_CALL;
		SLB_DEBUG_CLEAN_STACK(L,-2);
		// 1 - obj (table with classInfo)
		ClassInfo *ci = Manager::getInstance().getClass(L,1);
		if (ci == 0) luaL_error(L, "Invalid Class at #1");

		// 2 - key (string)
		const int key = 2;

		// 3 - value (func)
		const int value = 3;

		if (lua_isstring(L,key) && lua_isfunction(L,value))
		{
			// create a closure with the function to call
			lua_pushcclosure(L, HybridBase::call_lua_method, 1); // replaces [value]
			setMethod(L, ci);	
		}
		else
		{
			luaL_error(L,
				"hybrid instances can only have new methods (functions) "
				"indexed by strings ( called with: class[ (%s) ] = (%s) )",
				lua_typename(L, lua_type(L,key)), lua_typename(L, lua_type(L,value))
				);
		}
		return 0;
	}
int VPLHttp2__Impl::Post(VPLHttp2_SendCb sendCb,
                         void *sendCtx, u64 sendSize,
                         VPLHttp2_ProgressCb sendProgCb,
                         void *sendProgCtx,
                         std::string &respBody)
{
    int rv = 0;

    GET_HANDLE(&(this->mutex), this->handleInUse);

    setMethod(POST);
    rv = sendFromCallback(sendCb, sendCtx, sendSize);
    if (rv == 0) {
        rv = setupProgressCallback(sendProgCb, sendProgCtx);
    }
    if (rv == 0) {
        rv = recvToString(respBody);
    }
    if (rv == 0) {
        rv = connect();
    }

    PUT_HANDLE(&(this->mutex), this->handleInUse);

    return rv;
}
Exemple #15
0
Cell::Cell()
	:
	solverClock_( 2 ),
	solverName_( "_integ" ),
	shell_( reinterpret_cast< Shell* >( Id().eref().data() ) )
{
	setMethod( "hsolve" );
}
MovingObject::MovingObject(int queueSize)
{
    if ((queueSize>QUEUESIZE)||(queueSize<1)) queueSize=QUEUESIZE;
    _realQueueSize = queueSize;
    _last = -1;
    _filled=false;
    setMethod('s');
}
TaskOrientation::TaskOrientation(std::string name, MotorID baseNode, MotorID effectorNode, MotorID referenceCoordinateSystem, const KinematicTree &tree, arma::colvec3 target, Axis axis) :
		Task(name, baseNode, effectorNode, tree),
		m_axis(axis),
		m_referenceCoordinateSystem(referenceCoordinateSystem),
		m_methodPoint(target)
{
	setMethod(&m_methodPoint);
}
TaskOrientation::TaskOrientation(std::string name, MotorID baseNode, MotorID effectorNode, const KinematicTree &tree, Axis axis) :
				Task(name, baseNode, effectorNode, tree),
		m_axis(axis),
		m_referenceCoordinateSystem(baseNode),
		m_methodPoint()
{
	setMethod(&m_methodPoint);
}
Exemple #19
0
void TessellationLevel::setToDefaults( void )
{
	SingleAttribute::setToDefaults();
	setMethod( (UNIFORM) );
	setCustomDeclarations( std::string() );
	setCustomCode( std::string() );
	setComposeMode( (REPLACE) );
}
Exemple #20
0
Inductance::Inductance( double inductance, double delta )
	: Reactive(delta)
{
	m_inductance = inductance;
	scaled_inductance = v_eq_old = 0.0;
	m_numCNodes = 2;
	m_numCBranches = 1;
	setMethod( Inductance::m_euler );
}
Exemple #21
0
void SmoothFilter::init (int m)
{
    setObjectName(tr("Smoothed"));
    setMethod(m);
    d_points = d_n;
    d_smooth_points = 2;
    d_sav_gol_points = 2;
    d_polynom_order = 2;
}
Exemple #22
0
Inductance::Inductance(const double inductance, const double delta)
    : Reactive(delta)
{
    m_inductance = inductance;
    scaled_inductance = 0.0;
    m_numCNodes = 2;
    m_numCBranches = 1; // DC short-circuit.
    setMethod(Inductance::m_euler);
}
void SmoothFilter::init (int m)
{
    setObjectName(tr("Smoothed"));
    setMethod(m);
    d_points = d_n;
    d_right_points = 2;
    d_left_points = 2;
    d_polynom_order = 2;
}
//!
//! Constructor of the ThreeDCirclesLayouterNode class.
//!
//! \param name The name for the new node.
//! \param parameterRoot A copy of the parameter tree specific for the type of the node.
//!
ThreeDCirclesLayouterNode::ThreeDCirclesLayouterNode ( const QString &name, ParameterGroup *parameterRoot ) :
    VTKGraphLayoutNode(name, parameterRoot)
{
	setTypeName("ThreeDCirclesLayouterNode");

	m_layoutInstance = vtkSimple3DCirclesStrategy::New();

	// These properties relate to graph layout
	// none for this layout

	// These properties relate specifically to the layout strategy
	setChangeFunction("Set Method", SLOT(setMethod()));
    setCommandFunction("Set Method", SLOT(setMethod()));

	setChangeFunction("Set Radius", SLOT(setRadius()));
    setCommandFunction("Set Radius", SLOT(setRadius()));

	setChangeFunction("Set Height", SLOT(setHeight()));
    setCommandFunction("Set Height", SLOT(setHeight()));

	setChangeFunction("Set Marked Start Vertices", SLOT(setMarkedStartVertices()));
    setCommandFunction("Set Marked Start Vertices", SLOT(setMarkedStartVertices()));

	setChangeFunction("Set Marked Value", SLOT(setMarkedValue()));
    setCommandFunction("Set Marked Value", SLOT(setMarkedValue()));

	setChangeFunction("Set Force To Use Universal Start Points Finder", SLOT(setForceToUseUniversalStartPointsFinder()));
    setCommandFunction("Set Force To Use Universal Start Points Finder", SLOT(setForceToUseUniversalStartPointsFinder()));

	setChangeFunction("Set Auto Height", SLOT(setAutoHeight()));
    setCommandFunction("Set Auto Height", SLOT(setAutoHeight()));

	setChangeFunction("Set Minimum Radian", SLOT(setMinimumRadian()));
    setCommandFunction("Set Minimum Radian", SLOT(setMinimumRadian()));

	setChangeFunction("Set Minimum Degree", SLOT(setMinimumDegree()));
    setCommandFunction("Set Minimum Degree", SLOT(setMinimumDegree()));

	setChangeFunction("Set Hierarchical Layers", SLOT(setHierarchicalLayers()));
    setCommandFunction("Set Hierarchical Layers", SLOT(setHierarchicalLayers()));

	INC_INSTANCE_COUNTER
}
Exemple #25
0
/**
 * 
 * @param widget
 * @param data
 */
static void
print_hello(GtkWidget *widget,
        gpointer data) {
    
    char **cards = getCards((char*) DEFAULT_DRM_DIR);
    if (cards == NULL) {
        g_printerr("Card list is empty.\n");
        return;
    }

    int idx = 0;
    while (cards[idx] != NULL) {
        g_print("Found card: %s\n", cards[idx]);

        g_print("method = %d\n", getMethod(cards[idx]));
        if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
            g_print("profile = %d\n", getProfile(cards[idx]));
        }

        if (canModifyPM()) {
            g_print("Setting dynpm\n");
            setMethod(cards[idx], DYNPM);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }

            g_print("Setting low profile\n");
            setMethod(cards[idx], PROFILE);
            setProfile(cards[idx], LOW);
            g_print("method = %d\n", getMethod(cards[idx]));
            if (getMethod(cards[idx]) != METHOD_UNKNOWN) {
                g_print("profile = %d\n", getProfile(cards[idx]));
            }
        }

        g_print("Current temperature: %d\n", getTemperature(cards[idx]));

        idx++;
    }
    freeCards(cards);

}
Exemple #26
0
bool SiteResponseModel::loadJson(const QString & fileName)
{
    setModified(false);
    m_isLoaded = false;

    // Save the file name
    m_fileName = fileName;

    QFile file(m_fileName);
    if (!file.open(QIODevice::ReadOnly)) {
        qCritical("Unable to open file: %s", qPrintable(fileName));
        return false;
    }

    QByteArray savedData = file.readAll();
    QJsonDocument jsonDoc = QJsonDocument::fromJson(savedData);

    QJsonObject json = jsonDoc.object();

    //
    m_notes->setHtml(json["notes"].toString());
    Units::instance()->setSystem(json["system"].toInt());

    m_randNumGen->fromJson(json["randNumGen"].toObject());
    m_siteProfile->fromJson(json["siteProfile"].toObject());
    m_motionLibrary->fromJson(json["motionLibrary"].toObject());
    m_outputCatalog->fromJson(json["outputCatalog"].toObject());

    setMethod(json["method"].toInt());
    const QJsonObject cjo = json["calculator"].toObject();
    switch (m_method)
    {
    case SiteResponseModel::EquivalentLinear:
        qobject_cast<EquivalentLinearCalculator*>(m_calculator)->fromJson(cjo);
        break;
    case SiteResponseModel::FrequencyDependent:
        qobject_cast<FrequencyDependentCalculator*>(m_calculator)->fromJson(cjo);
        break;
    case SiteResponseModel::LinearElastic:
    default:
        break;
    }

    setHasResults(json["hasResults"].toBool());

    m_outputCatalog->initialize(
        m_siteProfile->isVaried() ?  m_siteProfile->profileCount() : 1, m_motionLibrary);

    if (m_hasResults) {
        m_outputCatalog->finalize();
    }

    setModified(false);
    return true;
}
Exemple #27
0
RKWidget::RKWidget ( QWidget* parent ) : SolvWidget(parent)
{   int iwid = 4;
    unstable = false;
    lwork = 0;
    nrhs  = 1;
    nStage = 0;
    setTitle(tr("Runge Kutta"));

    methodLabel = new QLabel ( tr ( "Method" ) );
    methodBox = new QComboBox ( this );
    methodBox->addItem( tr("Mid-Point"));
    methodBox->addItem( tr("Trapezoid"));
    methodBox->addItem( tr("RK4"));
    methodBox->addItem( tr("Arb-RK-4"));
    methodBox->addItem( tr("RKG-4"));
    methodBox->addItem( tr("TVD-RK-3"));
    connect ( methodBox, SIGNAL( activated(int) ), this, SLOT( setMethod(int) ) );
    verticalLayout->insertWidget ( iwid++, methodLabel );
    verticalLayout->insertWidget ( iwid++, methodBox );
    weightLabel = new QLabel ( tr ( "Basis Functions" ) );
    weightBox = new QComboBox ( this );
    weightBox->addItem ( tr ( "Linear Basis" ) );
    weightBox->addItem ( tr ( "Cosine Basis" ) );
    weightBox->addItem ( tr ( "Finite Diff" ) );
    weightBox->addItem ( tr ( "Finite Diff - 4th ord" ) );
    //weightBox->addItem ( tr ( "Parabolic Basis" ) );
    //weightBox->addItem ( tr ( "Fourier 4 Basis" ) );
    verticalLayout->insertWidget ( iwid++, weightLabel );
    verticalLayout->insertWidget ( iwid++, weightBox );
    connect ( weightBox, SIGNAL( activated(int) ), this, SLOT( setBasis(int) ) );
    plotNameEdit->setText ( title );

    /* Set the default values for options argument: */
    options.Fact = DOFACT;
    options.Equil = YES;
    options.ColPerm = COLAMD;
    options.DiagPivotThresh = 1.0;
    options.Trans = NOTRANS;
    options.IterRefine = NOREFINE;
    options.SymmetricMode = NO;
    options.PivotGrowth = NO;
    options.ConditionNumber = NO;
    options.PrintStat = NO;
    setColor ( Qt::magenta );
    ncoef = 0;
    aexist = false;
    dirty = true;
    nblock = 1;
    setSize(100);
    setBasis(0);
    method=-1;
    setMethod(0);
    //set_default_options(&options);
}
Exemple #28
0
void NetworkManager::Ipv6Setting::fromMap(const QVariantMap &setting)
{
    if (setting.contains(QLatin1String(NM_SETTING_IP6_CONFIG_METHOD))) {
        const QString methodType = setting.value(QLatin1String(NM_SETTING_IP6_CONFIG_METHOD)).toString();

        if (methodType.toLower() == QLatin1String(NM_SETTING_IP6_CONFIG_METHOD_AUTO)) {
            setMethod(Automatic);
        } else if (methodType.toLower() == QLatin1String(NM_SETTING_IP6_CONFIG_METHOD_DHCP)) {
            setMethod(Dhcp);
        } else if (methodType.toLower() == QLatin1String(NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)) {
            setMethod(LinkLocal);
        } else if (methodType.toLower() == QLatin1String(NM_SETTING_IP6_CONFIG_METHOD_MANUAL)) {
            setMethod(Manual);
        } else if (methodType.toLower() == QLatin1String(NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) {
            setMethod(Ignored);
        } else {
            setMethod(Automatic);
        }
    }

    if (setting.contains(QLatin1String(NM_SETTING_IP6_CONFIG_DNS))) {
        QList<QHostAddress> dbusDns;
        QList<QByteArray> temp;
        if (setting.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).canConvert<QDBusArgument>()) {
            QDBusArgument dnsArg = setting.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).value< QDBusArgument>();
            temp = qdbus_cast<QList<QByteArray> >(dnsArg);
        } else {
            temp = setting.value(QLatin1String(NM_SETTING_IP6_CONFIG_DNS)).value<QList<QByteArray> >();
        }

        foreach (const QByteArray &utmp, temp) {
            dbusDns << Utils::ipv6AddressAsHostAddress(utmp);
        }
Exemple #29
0
void NetworkManager::Ipv4Setting::fromMap(const QVariantMap &setting)
{
    if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD))) {
        const QString methodType = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD)).toString();

        if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_AUTO)) {
            setMethod(Automatic);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)) {
            setMethod(LinkLocal);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
            setMethod(Manual);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_SHARED)) {
            setMethod(Shared);
        } else if (methodType.toLower() == QLatin1String(NMQT_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
            setMethod(Disabled);
        } else {
            setMethod(Automatic);
        }
    }

    if (setting.contains(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS))) {
        QList<QHostAddress> dbusDns;
        QList<uint> temp;
        if (setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).canConvert<QDBusArgument>()) {
            QDBusArgument dnsArg = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value<QDBusArgument>();
            temp = qdbus_cast<QList<uint> >(dnsArg);
        } else {
            temp = setting.value(QLatin1String(NMQT_SETTING_IP4_CONFIG_DNS)).value<QList<uint> >();
        }

        Q_FOREACH (const uint utmp, temp) {
            QHostAddress tmpHost(ntohl(utmp));
            dbusDns << tmpHost;
        }
Exemple #30
0
bool HttpRequest::parseMethod(const std::string &header)
{
	vector<std::string>::type tokens;
	size_t count = algorithms::split(header, tokens, true).size();
	if(count == 0)
		return false;

	HttpMethod method = conversions::from_string<HttpMethod>(tokens[0]);
	if(method == httpMethodUnknown)
		return false;

	setMethod(method);

    if(count > 1)
	{
		m_rawurl = tokens[1];

		size_t question = m_rawurl.find("?");
		if(question != std::string::npos)
		{
			m_url = HttpParser::urlDecodeA(algorithms::left(m_rawurl, question)); // VERYVERYURGENT

			// Nota: l'extra non deve essere decodificato per garantire il corretto caricamento dei parametri dell'url.
			// Esempio: url?param=alfa%26beta decodificato vale url?param=alfa&beta verrebbe interpretato come param = alfa, beta = String::EMPTY,
			// mentre il valore effettivo di param è alfa&beta
			m_extra = algorithms::mid(m_rawurl, question + 1);
		}
		else
		{
			m_url = HttpParser::urlDecodeA(m_rawurl); // VERYVERYURGENT
		}

		if(count > 2)
		{
			if(HttpParser::parseHttpVersion(tokens[2], m_httpVersion) == false)
				return false;
		}
		else
		{
			m_httpVersion = OS_HTTP_VERSION_1_0();
		}

		// Nel caso di HTTP 1.0 ogni connessione viene chiusa dopo essere stata processata
		if(m_httpVersion == OS_HTTP_VERSION_1_0())
		{
			m_keepAlive = 0;
			m_closeConnection = true;
		}
	}

	return true;
}