Exemple #1
1
void UpdateDB(const char* api_addr, const char* out_xml)
{





	CkHttp http;
	int success = http.UnlockComponent("ARKTOSHttp_decCLPWFQXmU");
	if (success != 1) 
		r3dError("Internal error!!!");

	// get items DB
	{
		CkHttpRequest req;
		req.UsePost();
		req.put_Path("/api/php/api_getItemsDB.php");
		req.AddParam("serverkey", "8B1E58D9-1D8A-4942-A2AB-B6809F0A4CDF");

		CkHttpResponse *resp = 0;
		resp = http.SynchronousRequest(api_addr, gDomainPort, gDomainUseSSL, req);
		if(!resp)
			r3dError("timeout getting items db");

		// we can't use getBosyStr() because it'll fuckup characters inside UTF-8 xml
		CkByteData bodyData;
		resp->get_Body(bodyData);

		pugi::xml_document xmlFile;
		pugi::xml_parse_result parseResult = xmlFile.load_buffer_inplace(
			(void*)bodyData.getBytes(), 
			bodyData.getSize(), 
			pugi::parse_default, 
			pugi::encoding_utf8);
		if(!parseResult)
			r3dError("Failed to parse server weapon XML, error: %s", parseResult.description());

		xmlFile.save_file(
			out_xml, 
			PUGIXML_TEXT("\t"), 
			pugi::format_default, 
			pugi::encoding_utf8);
	}

	return;
}
StreamPtr ConfigParserXmlImpl::writeToStream(const char* indent) const {
    if(!mDocument)
        return MakeSharedPtr<MemoryStream>();

    myStreamWritter writter(indent);
    mDocument->save(writter, PUGIXML_TEXT("\t"), pugi::format_indent, pugi::encoding_utf8);
    return writter.stream;
}
ukn_string ConfigParserXmlImpl::writeToString(const char* indent) const {
    if(!mDocument)
        return ukn_string();

    myWritter writter(indent);
    mDocument->save(writter, PUGIXML_TEXT("\t"), pugi::format_indent, pugi::encoding_utf8);
    return writter.str;
}
static void insertUrlSchemes(const String& file, const StringSet& schemes)
{
    //
    // Inject registered URL schemes into the AppX manifest file, in this format:
    //
    // <Application>
    //     <Application ...>
    //         <Extensions>
    //             <uap:Extension Category="windows.protocol">
    //                 <uap:Protocol name="scheme1" />
    //             </uap:Extension>
    //             <uap:Extension Category="windows.protocol">
    //                 <uap:Protocol name="scheme2" />
    //             </uap:Extension>
    //         </Extensions>
    //     </Application>
    // </Application>
    //

    pugi::xml_document doc;
    if (!doc.load_file(file.c_str())) {
        SBLog::error() << "Failed to parse AppX manifest file " << file << std::endl;
        return;
    }

    pugi::xpath_node app = doc.select_single_node(PUGIXML_TEXT("/Package/Applications/Application"));
    if (!app) {
        SBLog::error() << "Failed to find Application element in AppX manifest file " << file << std::endl;
        return;
    }

    pugi::xml_node extensions = app.node().append_child(PUGIXML_TEXT("Extensions"));

    for (const String& scheme : schemes) {
        // pugixml doesn't have great support for handling namespaces. We just better hope
        // that our template manifests have the uap prefix mapped to the namespace
        // "http://schemas.microsoft.com/appx/manifest/uap/windows10".
        pugi::xml_node extension = extensions.append_child(PUGIXML_TEXT("uap:Extension"));

        extension.append_attribute(PUGIXML_TEXT("Category")).set_value(PUGIXML_TEXT("windows.protocol"));

        pugi::string_t schemeValue(scheme.begin(), scheme.end());

        pugi::xml_node protocol = extension.append_child(PUGIXML_TEXT("uap:Protocol"));
        protocol.append_attribute(PUGIXML_TEXT("Name")).set_value(schemeValue.c_str());
    }

    doc.save_file(file.c_str());
}
Exemple #5
0
void RemoteKeyboard::OnClickSyncBtn(TNotifyUI & msg, bool & handled)
{
	auto const &items = g_LessionMappingTable;
	DuiLib::CControlUI *ctrl;

	if (msg.pSender->GetName() == _T("sync_ok")) {
		pugi::xml_document xmldoc;
		pugi::xml_node root = xmldoc.append_child(PUGIXML_TEXT("lesson"));

		for (int i = 0; i < _countof(items); ++i) {
			pugi::xml_attribute attr = root.append_attribute(items[i].attr);
			if (ctrl = m_PaintManager.FindControl(items[i].name))
				attr = ctrl->GetText();
		}
		std::wostringstream oss;
		root.print(oss, L"", pugi::format_raw);

		auto _ExecuteExtendCmdWrap = [this](const std::wstring &buf) -> boolean {
			boolean ret = false;
			RpcTryExcept
				ret = rkbc_ExecuteExtendCmd(m_hwBinding, kExtendType_LessionInfo, reinterpret_cast<const byte *>(buf.data()), (buf.size() + 1) * sizeof(wchar_t));
			RpcExcept(1)
				ret = false;
			RpcEndExcept

				return ret;
		};

		if (_ExecuteExtendCmdWrap(oss.str())) {
			m_lession_info = oss.str();

			boost::crc_32_type result;
			result.process_bytes(reinterpret_cast<const byte *>(m_lession_info.data()), (m_lession_info.size() + 1) * sizeof(wchar_t));
			m_lession_info_checksum = result.checksum();
		}
	}