Exemple #1
0
HArtistBox::HArtistBox(HArtist &rep, QWidget *parent) :
    HGrowingWidget(parent),
    s_rep(rep),
    ui(new Ui::HArtistBox)
{
    ui->setupUi(this);
    ui->label_artistName->setText("<A href=\"more\">"+rep.getName()+"</A>");
    connect(ui->label_artistName,SIGNAL(linkActivated(QString)),this,SLOT(requestContext()));
    connect(this,SIGNAL(contextRequested(HArtist&)),HMainWindow::singleton(),SLOT(showContext(HArtist&)));
    s_priority[1].push_back(s_rep.sendTagNames(this,"setTagNames"));
    s_priority[1].push_back(s_rep.sendBioShort(this,"setBioShort"));
    setMaximumHeight(130);
    readjustPriorities();
}
void IncludeComponent::loadChildren(const string& sourcePath) {
	//build the view on a clean new root for safety
	auto root = make_shared<Component>();

	/* add it as a temporary child so elements built from this component
	 * properly behave as children */
	link(getSelf(), root);
	
	auto includeFile = requestContext().getResourceResolver()->getResource(
			sourcePath);

	auto view = requestContext().getView();
	Component::load(*includeFile, sourcePath, root, nullptr);

	if (root->getChildren().size() == 1) {
		/*the expected format for an include is a single outer root
			*component (ie <html>) with namespace declarations that is
			*removed after the view is built. in effect, all children of the
			*root in the included document become children of the <include>
			*tag*/
		auto docRoot = *root->getChildren().begin();

		/*getChildren().assign(docRoot->getChildren().begin(),
				docRoot->getChildren().end());*/
		getChildren().clear();

		auto newChildren = docRoot->getChildren();
		for (auto newChild : newChildren) {
			link(getParent(), newChild);
		}
	}
	else {
		//is this check necessary? would libxml even load the document?
		throw IllegalStateException("Included document must not contain"
			" more than one root element");
	}
}
Exemple #3
0
void HttpServer::processRequest(const HttpMessage& request,
                                HttpMessage*& response,
                                OsConnectionSocket* connection
                                )
{
    UtlString method;
    response = NULL;

    if(true) // used to be authorization check, but I don't want to change all indenting
    {
        request.getRequestMethod(&method);
        method.toUpper();
        UtlString uri;
        request.getRequestUri(&uri);

        UtlString uriFileName(uri);
        ssize_t fileNameEnd = -1;
        if(method.compareTo(HTTP_GET_METHOD) == 0)
        {
            fileNameEnd = uriFileName.first('?');
            if(fileNameEnd > 0)
            {
               uriFileName.remove(fileNameEnd);
            }
        }

        UtlString mappedUriFileName;
        if (uriFileName.contains(".."))
        {
            OsSysLog::add(FAC_SIP, PRI_ERR, "HttpServer::processRequest "
                          "Disallowing URI: '%s' because it contains '..'",
                          uriFileName.data());

            // Disallow relative path names going up for security reasons
            mappedUriFileName.append("/");
        }
        else
        {
            OsSysLog::add(FAC_SIP, PRI_INFO, "HttpServer::processRequest "
                          "%s '%s'", method.data(), uriFileName.data());

            // Map the file name
            mapUri(mUriMaps, uriFileName.data(), mappedUriFileName);
        }

        // Build the request context
        HttpRequestContext requestContext(method.data(),
                                          uri.data(),
                                          mappedUriFileName.data(),
                                          NULL,
                                          NULL, // was userid
                                          connection
                                          );

        if(requestContext.methodIs(HTTP_POST_METHOD))
        {
            //Need to get the CGI/form variables from the body.
            const HttpBody* body = request.getBody();
            if(body  && !body->isMultipart())
            {
                requestContext.extractPostCgiVariables(*body);
            }
        }

        RequestProcessor* requestProcessorPtr = NULL;
        HttpService* pService = NULL;

        if(   (   requestContext.methodIs(HTTP_GET_METHOD)
               || requestContext.methodIs(HTTP_POST_METHOD)
               )
           && findRequestProcessor(uriFileName.data(), requestProcessorPtr))
        {
            // There is a request processor for this URI
           requestProcessorPtr(requestContext, request, response);
        }
        else if (   (   requestContext.methodIs(HTTP_GET_METHOD)
                     || requestContext.methodIs(HTTP_POST_METHOD)
                     || requestContext.methodIs(HTTP_PUT_METHOD)
                     || requestContext.methodIs(HTTP_DELETE_METHOD)
                     )
                 && findHttpService(uriFileName.data(), pService))
        {
           pService->processRequest(requestContext, request, response);
        }
        else
        {
           processNotSupportedRequest(requestContext, request, response);
        }
    }
}