Ejemplo n.º 1
0
template<> XmlNode NodeCreator<Text>::createNodeFromObject(const Text& t) {
	XmlNode n("text");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	XmlNode textMap("textMap");
	for(std::map<const boost::uuids::uuid, const std::string>::const_iterator i = t.getTextMap().begin(); i != t.getTextMap().end(); i++) {
		XmlNode entry("entry");
		entry.addChild(XmlNode("id", boost::lexical_cast<std::string>(i->first)));
		entry.addChild(XmlNode("value", boost::lexical_cast<std::string>(i->second)));
		textMap.addChild(entry);
	}
	n.addChild(textMap);
	return n;
}
Ejemplo n.º 2
0
bool XmlNodeReader::Read() const {
	switch (get_ReadState()) {
	case Ext::ReadState::EndOfFile:
	case Ext::ReadState::Error:
	case Ext::ReadState::Closed:
		return false;
	case Ext::ReadState::Initial:		
		m_linkedNode = m_cur = m_startNode;
		m_readState = Ext::ReadState::Interactive;
		return bool(m_cur);
	}
//	TRC(4, int(m_cur.NodeType) << "  " << &m_cur.R << "   StartNode type: " << int(m_startNode.NodeType) << "  " << &m_startNode.R);
	MoveToElement();

	if (XmlNode firstChild = !m_bEndElement ? m_cur.FirstChild : XmlNode()) {
		++m_depth;
		m_linkedNode = m_cur = firstChild;
		return true;
	}
	if (m_cur == m_startNode) {
		if (!(m_bEndElement = !IsEmptyElement() && !m_bEndElement)) {
			m_cur = XmlNode();
			m_readState = ReadState::EndOfFile;
		}
		m_linkedNode = m_cur;
		return m_bEndElement;
	}
	XmlNodeType curType = m_cur.NodeType;
	if (!m_bEndElement && !IsEmptyElement() && curType==XmlNodeType::Element)
		return m_bEndElement = true;
	if (XmlNode next = m_cur.NextSibling) {
		m_linkedNode = m_cur = next;
		return !(m_bEndElement = false);
	}
	XmlNode parent;
	if (curType != XmlNodeType::Document) {
		parent = m_cur.ParentNode;
	//	TRC(4, "Parent: " << int(parent.NodeType) << "  " << &parent.R);
	}
	if (m_bEndElement = parent && parent!=m_startNode) {
		m_cur = parent;
		--m_depth;
	} else {
		m_cur = nullptr;
		m_readState = ReadState::EndOfFile;
	}
	m_linkedNode = m_cur;
	return m_bEndElement;
}
Ejemplo n.º 3
0
XmlNode XmlAttributeList::GetAttribute(const std::wstring& name) const
{
	const _bstr_t attributenName(name.c_str());
	_DOMNodePtr_t attributePtr;
	
	_implPtr->getNamedItem(attributenName, &attributePtr);

	return XmlNode(std::move(attributePtr));
}
Ejemplo n.º 4
0
INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth(WPARAM hContact, LPARAM)
{
    if (hContact != NULL && m_bJabberOnline) {
        ptrT jid(getTStringA(hContact, "jid"));
        if (jid != NULL)
            m_ThreadInfo->send(XmlNode(_T("presence")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("unsubscribed")));
    }
    return 0;
}
Ejemplo n.º 5
0
XmlNode XmlAttributeList::GetAttribute(const std::wstring& local_name, const std::wstring& namespace_uri) const
{
	const _bstr_t localName(local_name.c_str());
	const _bstr_t namespaceURI(namespace_uri.c_str());
	_DOMNodePtr_t attributePtr;
	
	_implPtr->getQualifiedItem(localName, namespaceURI, &attributePtr);

	return XmlNode(std::move(attributePtr));
}
Ejemplo n.º 6
0
 XmlNode get_block_node(const Uint block_idx)
 {
   XmlNode block_node(my_node.content->first_node("block"));
   for(; block_node.is_valid(); block_node = XmlNode(block_node.content->next_sibling("block")))
   {
     if(from_str<Uint>(block_node.attribute_value("index")) == block_idx)
       return block_node;
   }
   
   throw SetupError(FromHere(), "Block with index " + to_str(block_idx) + " was not found");
 }
Ejemplo n.º 7
0
void XmlNode::refreshChildren()
{
    children_.clear();
    if (node_) {
        xmlNodePtr c(node_->children);
        while (c) {
            children_.push_back( XmlNode( c ) );
            c = c->next;
        }
    }
}
Ejemplo n.º 8
0
template<> XmlNode NodeCreator<WindowColors>::createNodeFromObject(const WindowColors& t) {
	XmlNode n("windowColors");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	n.addChild(XmlNode("fontID", boost::lexical_cast<std::string>(t.getFont()->getId())));
	n.addChild(XmlNode("textColorID", boost::lexical_cast<std::string>(t.getTextColor()->getId())));
	n.addChild(XmlNode("backgroundBrushID", boost::lexical_cast<std::string>(t.getBackgroundBrush()->getId())));
	n.addChild(XmlNode("borderPenID", boost::lexical_cast<std::string>(t.getBorderPen()->getId())));
	n.addChild(XmlNode("outerBorderPenID", boost::lexical_cast<std::string>(t.getOuterBorderPen()->getId())));
	n.addChild(XmlNode("highlightedBorderPenID", boost::lexical_cast<std::string>(t.getHighlightedBorderPen()->getId())));
	return n;
}
Ejemplo n.º 9
0
//---------------------------------------------------------------------------------------
void XmlParser::find_root()
{
    pugi::xml_node root = m_doc.first_child();
    m_encoding = "unknown";
    if (root.type() == pugi::node_declaration)
    {
        if (root.attribute("encoding") != NULL)
            m_encoding = root.attribute("encoding").value();
    }
    while (root && root.type() != pugi::node_element)
        root = root.next_sibling();

    m_root = XmlNode(root);
}
Ejemplo n.º 10
0
int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
{
    MessageWindowEventData *event = (MessageWindowEventData *)lParam;

    if (event->uType == MSG_WINDOW_EVT_OPEN) {
        if (!hDialogsList)
            hDialogsList = WindowList_Create();
        WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);

        ptrT jid(getTStringA(event->hContact, "jid"));
        if (jid != NULL) {
            JABBER_LIST_ITEM *pItem = ListGetItemPtr(LIST_ROSTER, jid);
            if (pItem && (m_ThreadInfo->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO) && m_options.EnableMsgArchive)
                RetrieveMessageArchive(event->hContact, pItem);
        }
    }
    else if (event->uType == MSG_WINDOW_EVT_CLOSING) {
        if (hDialogsList)
            WindowList_Remove(hDialogsList, event->hwndWindow);

        DBVARIANT dbv;
        BOOL bSupportTyping = FALSE;
        if (!db_get(event->hContact, "SRMsg", "SupportTyping", &dbv)) {
            bSupportTyping = dbv.bVal == 1;
            db_free(&dbv);
        }
        else if (!db_get(NULL, "SRMsg", "DefaultTyping", &dbv)) {
            bSupportTyping = dbv.bVal == 1;
            db_free(&dbv);
        }
        if (!bSupportTyping || !m_bJabberOnline)
            return 0;

        TCHAR jid[JABBER_MAX_JID_LEN];
        if (GetClientJID(event->hContact, jid, _countof(jid))) {
            pResourceStatus r(ResourceInfoFromJID(jid));
            if (r && r->m_bMessageSessionActive) {
                r->m_bMessageSessionActive = FALSE;

                if (GetResourceCapabilites(jid, TRUE) & JABBER_CAPS_CHATSTATES)
                    m_ThreadInfo->send(
                        XmlNode(_T("message")) << XATTR(_T("to"), jid) << XATTR(_T("type"), _T("chat")) << XATTRID(SerialNext())
                        << XCHILDNS(_T("gone"), JABBER_FEAT_CHATSTATES));
            }
        }
    }

    return 0;
}
Ejemplo n.º 11
0
void XmlParser::OnStartElement ( const tchar* _pName, const char** _ppAttrs )
{
    //
    XmlNode::smart_ptr_t   parent;
    XmlNode::smart_ptr_t   node;

    //
    node = XmlNode::smart_ptr_t( ex_new XmlNode(_pName) );

    //
    if ( !m_NodeStack.empty() )
    {
        parent = m_NodeStack.top();
    }
    else
    {
        m_Root = node;
    }
    m_NodeStack.push(node);

    //
    if ( parent )
    {
        parent->addChild(node);
    }

    // 
#ifdef EX_DEBUG 
    node->setLine( XML_GetCurrentLineNumber(m_pParser) );
#endif

    // get num of attributes
    int idx = 0;
    while ( _ppAttrs[idx] != NULL )
        idx += 2;

    node->ReserveAttr(idx/2);

    //
    idx = 0;
    while ( _ppAttrs[idx] != NULL )
    {
        node->setAttr( _ppAttrs[idx], _ppAttrs[idx+1] );
        idx += 2;
    }
}
Ejemplo n.º 12
0
bool CSpriteAnimated::GetFrameDataFromXml( const std::string& aPathToTexture)
{
	bool retValue = false;
	std::string PathToImage;
	std::vector<glm::vec4> FrameData;

	std::size_t found = aPathToTexture.find(".xml");
	if (found!=std::string::npos)
	{
		CXMLParserPUGI Parser( aPathToTexture );
		if (!Parser.Ready())
		{
			CCoreEngine::Instance().GetLogManager().LogOutput( LOG_ERROR, LOGSUB_RESOURCES, "FAILED LOADING %s", aPathToTexture.c_str() );
			return retValue;
		}
		std::size_t founddir = aPathToTexture.rfind("/");
		if (founddir!=std::string::npos)
		{
			PathToImage = aPathToTexture.substr(0,(founddir+1));
		}
		std::string l_File = Parser.GetStringAttributeValue( "TextureAtlas", "imagePath");
		PathToImage += l_File;

		u32 FramesCount = Parser.GetNodeNameCount("TextureAtlas/sprite");
		for ( u32 c = 0; c < FramesCount; c++ )
		{
			std::string XmlNode("TextureAtlas/sprite#");
			XmlNode += to_string( c );

			s32 l_Xi = Parser.GetIntAttributeValue( XmlNode, "x");
			s32 l_Yi = Parser.GetIntAttributeValue( XmlNode, "y");
			s32 l_Xf = l_Xi + Parser.GetIntAttributeValue( XmlNode, "w");
			s32 l_Yf = l_Yi + Parser.GetIntAttributeValue( XmlNode, "h");

			FrameData.push_back( glm::vec4(l_Xi,l_Yi,l_Xf,l_Yf) );
		}

		LoadTextureFromFile(PathToImage, FrameData.size(), FrameData );
		retValue = true;
	}

	return retValue;
}
Ejemplo n.º 13
0
void __cdecl CJabberProto::OnAddContactForever( DBCONTACTWRITESETTING* cws, HANDLE hContact )
{
	if ( cws->value.type != DBVT_DELETED && !( cws->value.type==DBVT_BYTE && cws->value.bVal==0 ))
		return;

	DBVARIANT jid, dbv;
	if ( JGetStringT( hContact, "jid", &jid ))
		return;

	TCHAR *nick;
	Log( "Add " TCHAR_STR_PARAM " permanently to list", jid.pszVal );
	if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv )) {
		nick = mir_tstrdup( dbv.ptszVal );
		JFreeVariant( &dbv );
	}
	else if ( !JGetStringT( hContact, "Nick", &dbv )) {
		nick = mir_tstrdup( dbv.ptszVal );
		JFreeVariant( &dbv );
	}
	else nick = JabberNickFromJID( jid.ptszVal );
	if ( nick == NULL ) {
		JFreeVariant( &jid );
		return;
	}

	if ( !DBGetContactSettingTString( hContact, "CList", "Group", &dbv )) {
		AddContactToRoster( jid.ptszVal, nick, dbv.ptszVal );
		JFreeVariant( &dbv );
	}
	else AddContactToRoster( jid.ptszVal, nick, NULL );

	m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), jid.ptszVal ) << XATTR( _T("type"), _T("subscribe")));

	SendGetVcard( jid.ptszVal );

	mir_free( nick );
	DBDeleteContactSetting( hContact, "CList", "Hidden" );
	JFreeVariant( &jid );
}
Ejemplo n.º 14
0
  XmlNode Protocol::add_reply_frame ( XmlNode& node )
  {
    cf3_assert( node.is_valid() );
    cf3_assert( is_not_null(node.content->parent()) );

    rapidxml::xml_node<>* xml_node = node.content;

    XmlNode replynode = XmlNode(node.content->parent()).add_node( Tags::node_frame());

    replynode.set_attribute( "type", Tags::node_type_reply() );

    // reply with same target
    rapidxml::xml_attribute<>* target_att = xml_node->first_attribute("target");
    std::string target = is_not_null(target_att) ? target_att->value() : "";
    replynode.set_attribute("target", target);

    // the sender becomes the receiver
    rapidxml::xml_attribute<>* sender_att = xml_node->first_attribute("sender");
    std::string receiver = is_not_null(sender_att) ? sender_att->value() : "";
    replynode.set_attribute("receiver", receiver);

    // same transaction type
    rapidxml::xml_attribute<>* trans_att = xml_node->first_attribute("transaction");
    std::string trans = is_not_null(trans_att) ? trans_att->value() : "auto";
    replynode.set_attribute("transaction", trans);

    // copy uuids, if any
    rapidxml::xml_attribute<>*  client_uuid_att = xml_node->first_attribute( Tags::attr_clientid() );
    rapidxml::xml_attribute<>*  frame_uuid_att = xml_node->first_attribute( Tags::attr_frameid() );

    if( is_not_null(client_uuid_att) )
      replynode.set_attribute(Tags::attr_clientid(), client_uuid_att->value());

    if( is_not_null(frame_uuid_att) )
      replynode.set_attribute(Tags::attr_frameid(), frame_uuid_att->value() );

    return replynode;
//    return XmlNode();
  }
Ejemplo n.º 15
0
template<> XmlNode NodeCreator<Color>::createNodeFromObject(const Color& t) {
	XmlNode n("color");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	XmlNode colorMap("colorMap");
	for(std::map<const boost::uuids::uuid, const SDL_Color>::const_iterator i = t.getColorMap().begin(); i != t.getColorMap().end(); i++) {
		XmlNode entry("entry");
		entry.addChild(XmlNode("themeId", boost::lexical_cast<std::string>(i->first)));
		entry.addChild(XmlNode("r", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.r))));
		entry.addChild(XmlNode("g", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.g))));
		entry.addChild(XmlNode("b", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.b))));
		entry.addChild(XmlNode("a", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.unused))));
		colorMap.addChild(entry);
	}

	n.addChild(colorMap);
	return n;
}
Ejemplo n.º 16
0
// XEP-0224 support (Attention/Nudge)
INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM wParam, LPARAM)
{
	if (!m_bJabberOnline)
		return 0;

	HANDLE hContact = (HANDLE)wParam;
	ptrT jid( getTStringA(hContact, "jid"));
	if (jid == NULL)
		return 0;

	TCHAR tszJid[JABBER_MAX_JID_LEN];
	TCHAR *szResource = ListGetBestClientResourceNamePtr(jid);
	if (szResource)
		mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, szResource);
	else
		mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s"), jid);

	JabberCapsBits jcb = GetResourceCapabilites(tszJid, FALSE);
	m_ThreadInfo->send(
		XmlNode(_T("message")) << XATTR(_T("type"), _T("headline")) << XATTR(_T("to"), tszJid)
			<< XCHILDNS(_T("attention"), JABBER_FEAT_ATTENTION));
	return 0;
}
Ejemplo n.º 17
0
  Implementation(const URI& file, const Uint rank) :
    xml_doc(XML::parse_file(file)),
    m_rank(rank)
  {
    XmlNode cfbinary(xml_doc->content->first_node("cfbinary"));
    cf3_assert(from_str<Uint>(cfbinary.attribute_value("version")) == version());

    XmlNode nodes(cfbinary.content->first_node(("nodes")));
    XmlNode node(nodes.content->first_node("node"));
    for(; node.is_valid(); node = XmlNode(node.content->next_sibling("node")))
    {
      const Uint found_rank = from_str<Uint>(node.attribute_value("rank"));
      if(found_rank != m_rank)
        continue;

      const std::string binary_file_name = node.attribute_value("filename");

      binary_file.open(binary_file_name, std::ios_base::in | std::ios_base::binary);
      my_node = node;
    }

    if(!my_node.is_valid())
      throw SetupError(FromHere(), "No node found for rank " + to_str(m_rank));
  }
Ejemplo n.º 18
0
//===========================================
// XmlNode::nextSibling
//===========================================
inline XmlNode XmlNode::nextSibling() const {
   if (isNull()) throw XmlException("Node is NULL", __FILE__, __LINE__);
   return XmlNode(m_doc, m_node->next_sibling(), m_file);
}
Ejemplo n.º 19
0
//===========================================
// XmlNode::firstChild
//===========================================
inline XmlNode XmlNode::firstChild() const {
   if (isNull()) throw XmlException("Node is NULL", __FILE__, __LINE__);
   return XmlNode(m_doc, m_node->first_node(), m_file);
}
Ejemplo n.º 20
0
template<> XmlNode NodeCreator<Language>::createNodeFromObject(const Language& t) {
	XmlNode n("language");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	n.addChild(XmlNode("nameID", boost::lexical_cast<std::string>(t.getName()->getId())));
	return n;
}
Ejemplo n.º 21
0
  XmlNode  Protocol::first_frame_node ( const XmlNode& node )
  {
    cf3_assert( node.is_valid() );

    return XmlNode( node.content->first_node( Protocol::Tags::node_frame() ));
  }