PRBool
nsXFormsSelectableItemAccessible::IsItemSelected()
{
  nsresult rv;

  nsINode* parent = mContent;
  while ((parent = parent->GetNodeParent())) {
    nsCOMPtr<nsIContent> content(do_QueryInterface(parent));
    if (!content)
      return PR_FALSE;

    nsCOMPtr<nsINodeInfo> nodeinfo = content->NodeInfo();
    if (!nodeinfo->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS)))
      continue;

    nsCOMPtr<nsIDOMNode> select(do_QueryInterface(parent));
    if (!select)
      continue;

    nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
    if (nodeinfo->Equals(nsAccessibilityAtoms::select)) {
      PRBool isSelected = PR_FALSE;
      rv = sXFormsService->IsSelectItemSelected(select, DOMNode, &isSelected);
      return NS_SUCCEEDED(rv) && isSelected;
    }

    if (nodeinfo->Equals(nsAccessibilityAtoms::select1)) {
      nsCOMPtr<nsIDOMNode> selitem;
      rv = sXFormsService->GetSelectedItemForSelect1(select,
                                                     getter_AddRefs(selitem));
      return NS_SUCCEEDED(rv) && (selitem == DOMNode);
    }
  }

  return PR_FALSE;
}
Example #2
0
bool Game::addClient(book::Client* client)
{
    sf::Lock guard(_teamMutex);
    Team::type_ptr clientTeam = nullptr;
    for(Team::type_ptr team : _teams)
    {
        if(team->getClients().size() == 0 and team->isGameOver())
        {
            clientTeam = team;
            break;
        }
    }

    sf::Packet response;
    if(clientTeam != nullptr)
    {
        //send map informations
        std::ifstream file(_mapFileName);
        std::string content((std::istreambuf_iterator<char>(file)),(std::istreambuf_iterator<char>()));

        book::packet::JoinGameConfirmation conf(content,clientTeam->id());
        for(Team::type_ptr team : _teams)
        {
            book::packet::JoinGameConfirmation::Data data;
            data.team = team->id();
            data.gold = team->getGold();
            data.color = team->getColor();

            conf.addTeam(std::move(data));
        }
        response<<conf;

        client->send(response);

        {
            //send initial content
            response.clear();
            sf::Lock gameGuard(_gameMutex);
            book::packet::CreateEntity datas;

            for(auto id : entities)
                addCreate(datas,id);

            response<<datas;
            client->send(response);
        }

        std::cout<<"Add client to game"<<std::endl;

        client->setTeam(clientTeam);

        sf::Lock guardClients(_clientsMutex);
        _clients.emplace_back(client);
    }
    else
    {
        response<<book::packet::JoinGameReject(_id);
        client->send(response);
    }

    return clientTeam != nullptr;
}
Example #3
0
//----------------------------------------------------------------------------
// SAXParsor::parse_node
//----------------------------------------------------------------------------
void SAXParsor::parse_node(void *_pNode, INodeAnalyser* pAnalyser)
{
  xmlNode *pNode = (xmlNode *)_pNode;
  xmlNode *pCurrentNode;
  yat::String current_file;

  for( pCurrentNode = pNode; pCurrentNode != NULL; pCurrentNode = pCurrentNode->next )
  {
    // Default : next target is the same target
    INodeAnalyser *pNextAnalyser = pAnalyser;

    yat::String element_name;
    if( pCurrentNode->type == XML_ELEMENT_NODE )
    {
      element_name = (const char *)(pCurrentNode->name);

      // Search for 'xml:base' attribute
      for( xmlAttr *pAttr = pCurrentNode->properties; pAttr; pAttr = pAttr->next )
      {
        if( yat::String((const char *)(pAttr->name)).is_equal_no_case("base") )
        {
          yat::String content((const char *)(pAttr->children->content));
          if( content.find('/') != std::string::npos )
            // Remove path part of the base attribute value
            content.extract_token_right('/', &current_file);
        }
      }

      Attributes attributes;
      xmlAttr *pAttr = NULL;
      for( pAttr = pCurrentNode->properties; pAttr; pAttr = pAttr->next )
      {
        yat::String value((const char *)(pAttr->children->content));
        yat::String name((const char *)(pAttr->name));

        // Search for substitute in defines dictionnary
        attributes[name] = value;
      }

      if( NULL != pAnalyser )
        pNextAnalyser = pAnalyser->on_element(element_name, attributes, current_file);
    }

    else if (pCurrentNode->type == XML_TEXT_NODE && !xmlIsBlankNode(pCurrentNode) )
    {
      // Retreives element name
      yat::String element_name((const char *)(pCurrentNode->parent->name));
      yat::String content((const char *)(pCurrentNode->content));
      // Remove wasted white spaces
      content.trim();

      // Process content
      if( NULL != pAnalyser )
        pAnalyser->on_element_content(element_name, content, current_file);
    }

    if( NULL != pNextAnalyser )
    {
      // Parse children node using the next analyser
      parse_node(pCurrentNode->children, pNextAnalyser);
      
      if( pNextAnalyser != pAnalyser )
      {
        // Analyser created on previous call to OnElement no longer in use
        pNextAnalyser->release();
      }
    }

    // Notify target for end parsing
    if( pCurrentNode->type == XML_ELEMENT_NODE && NULL != pNextAnalyser )
      pAnalyser->on_end_element(element_name);
  }

}
Example #4
0
void nsWebBrowserFind::SetSelectionAndScroll(nsIDOMWindow* aWindow,
                                             nsIDOMRange*  aRange)
{
  nsCOMPtr<nsIDOMDocument> domDoc;    
  aWindow->GetDocument(getter_AddRefs(domDoc));
  if (!domDoc) return;

  nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
  nsIPresShell* presShell = doc->GetShell();
  if (!presShell) return;

  nsCOMPtr<nsIDOMNode> node;
  aRange->GetStartContainer(getter_AddRefs(node));
  nsCOMPtr<nsIContent> content(do_QueryInterface(node));
  nsIFrame* frame = content->GetPrimaryFrame();
  if (!frame)
      return;
  nsCOMPtr<nsISelectionController> selCon;
  frame->GetSelectionController(presShell->GetPresContext(),
                                getter_AddRefs(selCon));
  
  // since the match could be an anonymous textnode inside a
  // <textarea> or text <input>, we need to get the outer frame
  nsITextControlFrame *tcFrame = nullptr;
  for ( ; content; content = content->GetParent()) {
    if (!IsInNativeAnonymousSubtree(content)) {
      nsIFrame* f = content->GetPrimaryFrame();
      if (!f)
        return;
      tcFrame = do_QueryFrame(f);
      break;
    }
  }

  nsCOMPtr<nsISelection> selection;

  selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
  selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
    getter_AddRefs(selection));
  if (selection) {
    selection->RemoveAllRanges();
    selection->AddRange(aRange);

    nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
    if (fm) {
      if (tcFrame) {
        nsCOMPtr<nsIDOMElement> newFocusedElement(do_QueryInterface(content));
        fm->SetFocus(newFocusedElement, nsIFocusManager::FLAG_NOSCROLL);
      }
      else  {
        nsCOMPtr<nsIDOMElement> result;
        fm->MoveFocus(aWindow, nullptr, nsIFocusManager::MOVEFOCUS_CARET,
                      nsIFocusManager::FLAG_NOSCROLL,
                      getter_AddRefs(result));
      }
    }

    // Scroll if necessary to make the selection visible:
    // Must be the last thing to do - bug 242056

    // After ScrollSelectionIntoView(), the pending notifications might be
    // flushed and PresShell/PresContext/Frames may be dead. See bug 418470.
    selCon->ScrollSelectionIntoView
      (nsISelectionController::SELECTION_NORMAL,
       nsISelectionController::SELECTION_WHOLE_SELECTION,
       nsISelectionController::SCROLL_CENTER_VERTICALLY |
       nsISelectionController::SCROLL_SYNCHRONOUS);
  }
}
Example #5
0
void ChatWindowStyle::inheritContent(InternalIdentifier subType, InternalIdentifier superType)
{
    if (content(subType).isEmpty()) {
        setContent(subType, content(superType));
    }
}
Example #6
0
QString ChatWindowStyle::getOutgoingStateUnknownHtml() const
{
    return content(OutgoingStateUnknown);
}
Example #7
0
QString ChatWindowStyle::getOutgoingStateSentHtml() const
{
    return content(OutgoingStateSent);
}
Example #8
0
QString ChatWindowStyle::getFileTransferIncomingHtml() const
{
    return content(FileTransferIncoming);
}
Example #9
0
bool ChatWindowStyle::hasHeader() const
{
    return ! content(Header).isEmpty();
}
Example #10
0
void PeerListBox::searchQueryChanged(const QString &query) {
	onScrollToY(0);
	content()->searchQueryChanged(query);
}
Example #11
0
bool
nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
                                nsPresContext *aPresContext,
                                nsIDOMRange *aRange, bool aMustBeInViewPort,
                                bool aGetTopVisibleLeaf,
                                nsIDOMRange **aFirstVisibleRange,
                                bool *aUsesIndependentSelection)
{
  NS_ASSERTION(aPresShell && aPresContext && aRange && aFirstVisibleRange, 
               "params are invalid");

  // We need to know if the range start is visible.
  // Otherwise, return the first visible range start 
  // in aFirstVisibleRange

  aRange->CloneRange(aFirstVisibleRange);
  nsCOMPtr<nsIDOMNode> node;
  aRange->GetStartContainer(getter_AddRefs(node));

  nsCOMPtr<nsIContent> content(do_QueryInterface(node));
  if (!content)
    return false;

  nsIFrame *frame = content->GetPrimaryFrame();
  if (!frame)    
    return false;  // No frame! Not visible then.

  if (!frame->StyleVisibility()->IsVisible())
    return false;

  // Detect if we are _inside_ a text control, or something else with its own
  // selection controller.
  if (aUsesIndependentSelection) {
    *aUsesIndependentSelection = 
      (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION);
  }

  // ---- We have a frame ----
  if (!aMustBeInViewPort)   
    return true; //  Don't need it to be on screen, just in rendering tree

  // Get the next in flow frame that contains the range start
  int32_t startRangeOffset, startFrameOffset, endFrameOffset;
  aRange->GetStartOffset(&startRangeOffset);
  while (true) {
    frame->GetOffsets(startFrameOffset, endFrameOffset);
    if (startRangeOffset < endFrameOffset)
      break;

    nsIFrame *nextContinuationFrame = frame->GetNextContinuation();
    if (nextContinuationFrame)
      frame = nextContinuationFrame;
    else
      break;
  }

  // Set up the variables we need, return true if we can't get at them all
  const uint16_t kMinPixels  = 12;
  nscoord minDistance = nsPresContext::CSSPixelsToAppUnits(kMinPixels);

  // Get the bounds of the current frame, relative to the current view.
  // We don't use the more accurate AccGetBounds, because that is
  // more expensive and the STATE_OFFSCREEN flag that this is used
  // for only needs to be a rough indicator
  nsRectVisibility rectVisibility = nsRectVisibility_kAboveViewport;

  if (!aGetTopVisibleLeaf && !frame->GetRect().IsEmpty()) {
    rectVisibility =
      aPresShell->GetRectVisibility(frame,
                                    nsRect(nsPoint(0,0), frame->GetSize()),
                                    minDistance);

    if (rectVisibility != nsRectVisibility_kAboveViewport) {
      return true;
    }
  }

  // We know that the target range isn't usable because it's not in the
  // view port. Move range forward to first visible point,
  // this speeds us up a lot in long documents
  nsCOMPtr<nsIFrameEnumerator> frameTraversal;
  nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID));
  if (trav)
    trav->NewFrameTraversal(getter_AddRefs(frameTraversal),
                            aPresContext, frame,
                            eLeaf,
                            false, // aVisual
                            false, // aLockInScrollView
                            false     // aFollowOOFs
                            );

  if (!frameTraversal)
    return false;

  while (rectVisibility == nsRectVisibility_kAboveViewport) {
    frameTraversal->Next();
    frame = frameTraversal->CurrentItem();
    if (!frame)
      return false;

    if (!frame->GetRect().IsEmpty()) {
      rectVisibility =
        aPresShell->GetRectVisibility(frame,
                                      nsRect(nsPoint(0,0), frame->GetSize()),
                                      minDistance);
    }
  }

  if (frame) {
    nsCOMPtr<nsIDOMNode> firstVisibleNode = do_QueryInterface(frame->GetContent());

    if (firstVisibleNode) {
      frame->GetOffsets(startFrameOffset, endFrameOffset);
      (*aFirstVisibleRange)->SetStart(firstVisibleNode, startFrameOffset);
      (*aFirstVisibleRange)->SetEnd(firstVisibleNode, endFrameOffset);
    }
  }

  return false;
}
Example #12
0
QString ItemRDFImpl::id() const
{
    if (!m_item.resource()->isAnon())
        return m_item.resource()->uri();
    else
        return QLatin1String("hash:") + calcMD5Sum(title() + description() + link() + content());
}
Example #13
0
Sprite::Sprite(GameObject * object, std::string asset, std::string selectAsset)
{
    object_ = object;
    artAsset_ = asset;
    selectArtAsset_ = selectAsset;
    texture_ = nullptr;
    renderer_ = nullptr;
    height_ = object->height();
    width_ = object->width();

    currentAction_ = ACTION_IDLE;
    currentDirection_ = object_->rotation();

    // open xml doc
    rapidxml::xml_document<> doc;
    //std::ifstream file(kAssetSpriteXMLZombie);
    std::ifstream file(kAssetSpriteXMLHuman);
    std::stringstream buffer;
    buffer << file.rdbuf();
    file.close();
    std::string content(buffer.str());
    doc.parse<0>(&content[0]);

    rapidxml::xml_node<> *sprite = doc.first_node();     // this is the sprite element

    // Iterate through animations
    for(rapidxml::xml_node<> *animation = sprite->first_node("animation"); animation; animation = animation->next_sibling()) {

        std::string animationKey;
        int animationTime;

        for (rapidxml::xml_attribute<> *attribute = animation->first_attribute(); attribute; attribute = attribute->next_attribute()) {

                std::string attributeName = attribute->name();

                if(attributeName.compare("key") == 0) {
                    animationKey = attribute->value();
                }
                else if(attributeName.compare("time") == 0) {
                    animationTime = atoi(attribute->value());
                }

        }
        //Logger::write(Logger::ss << "Reading Animation: " << animationKey);
        Animation thisAnimation(animationKey, animationTime);

        // Iterate through frames
        for(rapidxml::xml_node<> *frame = animation->first_node("frame"); frame; frame = frame->next_sibling()) {

            std::string frameKey;
            int frameX, frameY, frameWidth, frameHeight;

            // Iterate through attributes
            for (rapidxml::xml_attribute<> *attribute = frame->first_attribute(); attribute; attribute = attribute->next_attribute()) {

                std::string attributeName = attribute->name();

                if(attributeName.compare("key") == 0) {
                    frameKey = attribute->value();
                }
                else if(attributeName.compare("x") == 0) {
                    frameX = atoi(attribute->value());
                }
                else if(attributeName.compare("y") == 0) {
                    frameY = atoi(attribute->value());
                }
                else if(attributeName.compare("width") == 0) {
                    frameWidth = atoi(attribute->value());
                }
                else if(attributeName.compare("height") == 0) {
                    frameHeight = atoi(attribute->value());
                }
            }

            SDL_Rect thisFrame = { frameX, frameY, frameWidth, frameHeight };
            thisAnimation.insertFrame(animationKey + frameKey, thisFrame);
        }

    animations_.insert(std::pair<std::string, Animation>(animationKey, thisAnimation));

    }

    animationTimer_.start();
    currentAnimation_ = animations_["idleRight"];

    double rotation = object_->rotation();

    if((rotation >= 45) && (rotation <= 135)) {
        currentAnimation_ = animations_["idleDown"];
    }
    else if((rotation >= 135) && (rotation <= 225)) {
        currentAnimation_ = animations_["idleLeft"];
    }
    else if((rotation >= 225) && (rotation <= 315)) {
        currentAnimation_ = animations_["idleUp"];
    }
    else {
        currentAnimation_ = animations_["idleRight"];
    }
}
Example #14
0
static std::string getValueFromOs_release(std::string key)
{
  FILE* os_rel = fopen("/etc/os-release", "r");
  if (!os_rel)
    return "";

  char* buf = new char[10 * 1024]; // more than enough
  size_t len = fread(buf, 1, 10 * 1024, os_rel);
  fclose(os_rel);
  if (len == 0)
  {
    delete[] buf;
    return "";
  }

  std::string content(buf, len);
  delete[] buf;

  // find begin of value string
  size_t valStart = 0, seachPos;
  key += '=';
  if (content.compare(0, key.length(), key) == 0)
    valStart = key.length();
  else
  {
    key = "\n" + key;
    seachPos = 0;
    do
    {
      seachPos = content.find(key, seachPos);
      if (seachPos == std::string::npos)
        return "";
      if (seachPos == 0 || content[seachPos - 1] != '\\')
        valStart = seachPos + key.length();
      else
        seachPos++;
    } while (valStart == 0);
  }

  if (content[valStart] == '\n')
    return "";
  
  // find end of value string
  seachPos = valStart;
  do
  {
    seachPos = content.find('\n', seachPos + 1);
  } while (seachPos != std::string::npos && content[seachPos - 1] == '\\');
  size_t const valEnd = seachPos;

  std::string value(content, valStart, valEnd - valStart);
  if (value.empty())
    return value;

  // remove quotes
  if (value[0] == '\'' || value[0] == '"')
  {
    if (value.length() < 2)
      return value;
    size_t qEnd = value.rfind(value[0]);
    if (qEnd != std::string::npos)
    {
      value.erase(qEnd);
      value.erase(0, 1);
    }
  }

  // unescape characters
  for (size_t slashPos = value.find('\\'); slashPos < value.length() - 1; slashPos = value.find('\\', slashPos))
  {
    if (value[slashPos + 1] == '\n')
      value.erase(slashPos, 2);
    else
    {
      value.erase(slashPos, 1);
      slashPos++; // skip unescaped character
    }
  }

  return value;
}
Example #15
0
void vector_cb_per_field(char *field_buffer, size_t field_length, struct vector_cb_data *data) {
  std::string content(field_buffer, field_length);
  data->lines[data->lines.size() - 1].push_back(content);
}
Example #16
0
QString ChatWindowStyle::getStatusHistoryHtml() const
{
    return content(StatusHistory);
}
Example #17
0
QString ChatWindowStyle::getActionOutgoingHtml() const
{
    return content(ActionOutgoing);
}
Example #18
0
QString ChatWindowStyle::getTemplateHtml() const
{
    return content(Template);
}
Example #19
0
QString ChatWindowStyle::getVoiceClipIncomingHtml() const
{
    return content(VoiceClipIncoming);
}
Example #20
0
QString ChatWindowStyle::getHeaderHtml() const
{
    return content(Header);
}
Example #21
0
QString ChatWindowStyle::getOutgoingStateErrorHtml() const
{
    return content(OutgoingStateError);
}
Example #22
0
QString ChatWindowStyle::getFooterHtml() const
{
    return content(Footer);
}
Example #23
0
bool ChatWindowStyle::hasActionTemplate() const
{
    return (!content(ActionIncoming).isEmpty() && !content(ActionOutgoing).isEmpty());
}
Example #24
0
QString ChatWindowStyle::getTopicHtml() const
{
    return content(Topic);
}
	connect(p	, SIGNAL( rename(AbstractFile*) ),
			this, SLOT  ( rename(AbstractFile*) ) );
	connect(p	, SIGNAL( deletion(AbstractFile*) ),
			this, SLOT  ( deletion(AbstractFile*) ) );
	connect(p	, SIGNAL( addFile(DevFolder*) ),
			this, SLOT  ( addFile(DevFolder*) ) );
	connect(p	, SIGNAL( subFolder(DevFolder*) ),
			this, SLOT  ( subFolder(DevFolder*) ) );
	
	DevTreeMap::insert(i, p);
	DevProjectMap::insert(name, p);
	
	addTopLevelItem(i);
	
	DevScope *top = p->global;
	QStringList keys, cfg = p->content("CONFIG");
	keys<<"SOURCES"<<"HEADERS"<<"FORMS"<<"RESOURCES"<<"TRANSLATIONS";
	
	createNested(top, keys, cfg, i);
	
	expandItem(i);
	scrollToItem(i, QAbstractItemView::PositionAtTop);
	
	return true;
}

void DevWorkSpace::createNested(DevScope *s, const QStringList& vars,
								const QStringList& cfg, QTreeWidgetItem *i)
{
	for (DevScopeMap::iterator it = s->nest.begin(); it != s->nest.end(); it++)
	{
Example #26
0
QString ChatWindowStyle::getIncomingNextContentHtml() const
{
    return content(IncomingNextContent);
}
Example #27
0
    int onGetInstantQuery(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method)
    {
        if(!stricmp(method, "LogoutUser")||!stricmp(method, "LogoutUserRequest"))
        {
            CEspCookie* logincookie = request->queryCookie("RELOGIN");
            if(logincookie == NULL || stricmp(logincookie->getValue(), "1") == 0)
            {
                response->addCookie(new CEspCookie("RELOGIN", "0"));

                StringBuffer content(
                "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
                    "<head>"
                        "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
                        "<title>Enterprise Services Platform</title>"
                    "</head>"
                    "<body onLoad=\"location.href='/ws_account/LogoutUserCancel'\">"
                    "</body>"
                "</html>");

                response->sendBasicChallenge("ESP", content.str());
            }
            else
            {
                response->addCookie(new CEspCookie("RELOGIN", "1"));
                response->setContentType("text/html; charset=UTF-8");
                StringBuffer content(
                "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
                    "<head>"
                        "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
                        "<title>Enterprise Services Platform</title>"
                    "</head>"
                    "<body>"
                    "<br/><b>Relogin successful, you're now logged in as ");
                content.append(context.queryUserId()).append(
                    "</b>"
                    "</body>"
                    "</html>");

                response->setContent(content.str());
                response->send();
            }

            return 0;
        }
        else if(!stricmp(method, "LogoutUserCancel")||!stricmp(method, "LogoutUserRequest"))
        {
            CEspCookie* logincookie = request->queryCookie("RELOGIN");
            response->addCookie(new CEspCookie("RELOGIN", "1"));
            response->setContentType("text/html; charset=UTF-8");
            StringBuffer content(
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
                "<head>"
                    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
                    "<title>Enterprise Services Platform</title>"
                    "<script type='text/javascript'>"
                        "function closeWin() { top.opener=top; top.close(); }"
                    "</script>"
                "</head>"
                "<body onload=\"javascript:closeWin();\">"
                    "<br/><b>Relogin canceled, you're now still logged in as ");
            content.append(context.queryUserId()).append(
                "</b>"
                "</body>"
            "</html>");

            response->setContent(content.str());
            response->send();
            return 0;
        }
        else
            return Cws_accountSoapBinding::onGetInstantQuery(context, request, response, service, method);
    }
Example #28
0
QString ChatWindowStyle::getIncomingNextHistoryHtml() const
{
    return content(IncomingNextHistory);
}
Example #29
0
http::doc urlhandle(const std::string &url, const std::string &querystr, const uint32_t remoteip)
{
	//std::cout << url << "\n";
	const uint32_t localip = util::str2ip("127.0.0.1"); // TODO Make this configurable
	std::vector<std::string> path = util::strsplit(url, '/');
	if (path.size() && path[0] == "") path.erase(path.begin());
	for (std::string &elem : path) elem = util::urldecode(elem);
	std::unordered_map<std::string, std::string> query{};
	if (querystr.size() > 0) for (const std::string &qu : util::strsplit(querystr, '&'))
	{
		std::string::size_type idx = qu.find("=");
		if (idx == qu.npos) query[util::urldecode(qu)] = "";
		else query[util::urldecode(qu.substr(0, idx), true)] = util::urldecode(qu.substr(idx + 1), true);
	}
	try
	{
		if (path.size() == 0 || path[0] == "") return home(remoteip == localip);
		if (path[0] == "search" || path[0] == "view" || path[0] == "content" || path[0] == "complete" || path[0] == "titles" || path[0] == "shuffle")
		{
			if (path.size() < 2) return error("Bad Request", "Missing volume ID");
			if (! volumes.check(path[1])) return error("Not Found", "No volume with ID “" + path[1] + "” exists");
			std::string input{};
			std::string::const_iterator start = util::find_nth(url.begin(), url.end(), '/', 3) + 1;
			if (start > url.end()) input = "";
			else input = util::urldecode(std::string{start, url.end()});
			std::string input_qstr = input + (querystr.size() ? "?" + querystr : "");
			if (path[0] == "search") return search(volumes.get(path[1]), input_qstr);
			else if (path[0] == "view") return content(volumes.get(path[1]), input, true);
			else if (path[0] == "complete") return complete(volumes.get(path[1]), input_qstr);
			else if (path[0] == "titles") return titles(volumes.get(path[1]), input_qstr);
			else if (path[0] == "shuffle") return shuffle(volumes.get(path[1]));
			else return content(volumes.get(path[1]), input);
		}
		else if (path[0] == "load" || path[0] == "unload")
		{
			if (path.size() < 2) return error("Bad Request", "Missing category name");
			if (path[0] == "load") return loadcat(path[1]);
			else return unloadcat(path[1]);
		}
		else if (path[0] == "external")
		{
			if (path.size() < 2) return error("Bad Request", "Missing external path");
			if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality");
			return http::doc{"text/plain", volumes.load_external(path[1])};
		}
		else if (path[0] == "pref") return pref();
		else if (path[0] == "rsrc") return rsrc(util::strjoin(path, '/', 1));
		else if (path[0] == "add") return http::doc{resource("html/add.html")};
		else if (path[0] == "action")
		{
			if (path.size() < 2) return error("Bad Request", "No action selected");
			if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality");
			return action(path[1], query);
		}
		else throw handle_error{"Unknown action “" + path[0] + "”"};
	}
	catch (std::exception &e)
	{
		return error("Error", e.what());
	}
}
Example #30
0
QString ChatWindowStyle::getOutgoingNextHistoryHtml() const
{
    return content(OutgoingNextHistory);
}