bool KAppRes::LoadFontRes() { bool retval = false; void* pBuffer = NULL; unsigned long dwBuffer = 0; TiXmlDocument xmlDoc; const TiXmlElement* pXmlChild = NULL; const TiXmlElement* pXmlItem = NULL; if (!GetRawDataFromRes("fonts.xml", &pBuffer, dwBuffer)) goto clean0; if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8)) goto clean0; pXmlChild = xmlDoc.FirstChildElement("fonts"); if (!pXmlChild) goto clean0; pXmlItem = pXmlChild->FirstChildElement("font"); while (pXmlItem) { std::string strId; std::wstring strFontface; int nFontSize = 11; int nUnderline = 0; int nBold = 0; int nItalic = 0; strId = pXmlItem->Attribute("id"); strFontface = AnsiToUnicode(pXmlItem->Attribute("fontface")); pXmlItem->Attribute("fontsize", &nFontSize); pXmlItem->Attribute("underline", &nUnderline); pXmlItem->Attribute("bold", &nBold); pXmlItem->Attribute("italic", &nItalic); if (strId.length() && strFontface.length()) { m_mapFontTable[strId] = CreateFont( strFontface, nFontSize, nBold ? TRUE : FALSE, nUnderline ? TRUE : FALSE, nItalic ? TRUE : FALSE ); } pXmlItem = pXmlItem->NextSiblingElement("font"); } clean0: if (pBuffer) { FreeRawData(pBuffer); } return retval; }
bool KAppRes::LoadStringRes() { bool retval = false; void* pBuffer = NULL; unsigned long dwBuffer = 0; TiXmlDocument xmlDoc; const TiXmlElement* pXmlChild = NULL; const TiXmlElement* pXmlItem = NULL; if (!GetRawDataFromRes("strings.xml", &pBuffer, dwBuffer)) goto clean0; if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8)) goto clean0; pXmlChild = xmlDoc.FirstChildElement("strings"); if (!pXmlChild) goto clean0; pXmlItem = pXmlChild->FirstChildElement("string"); while (pXmlItem) { std::string strId; std::string strValue; strId = pXmlItem->Attribute("id"); strValue = pXmlItem->Attribute("value"); if (strId.length() && strValue.length()) { std::wstring strTemp = Utf8ToUnicode(strValue); update_string(strTemp); m_mapStringTable[strId] = strTemp; } pXmlItem = pXmlItem->NextSiblingElement("string"); } retval = true; clean0: if (pBuffer) { FreeRawData(pBuffer); } return retval; }
bool KAppRes::LoadXmlRes() { bool retval = false; void* pBuffer = NULL; unsigned long dwBuffer = 0; TiXmlDocument xmlDoc; const TiXmlElement* pXmlChild = NULL; const TiXmlElement* pXmlItem = NULL; if (!GetRawDataFromRes("xmls.xml", &pBuffer, dwBuffer)) goto clean0; if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8)) goto clean0; pXmlChild = xmlDoc.FirstChildElement("xmls"); if (!pXmlChild) goto clean0; pXmlItem = pXmlChild->FirstChildElement("xml"); while (pXmlItem) { std::string strId; std::string strPath; strId = pXmlItem->Attribute("id"); strPath = pXmlItem->Attribute("path"); if (strId.length() && strPath.length()) { m_mapXmlTable[strId] = strPath; } pXmlItem = pXmlItem->NextSiblingElement("xml"); } retval = true; clean0: if (pBuffer) { FreeRawData(pBuffer); } return retval; }
bool KAppRes::LoadColorRes() { bool retval = false; void* pBuffer = NULL; unsigned long dwBuffer = 0; TiXmlDocument xmlDoc; const TiXmlElement* pXmlChild = NULL; const TiXmlElement* pXmlItem = NULL; if (!GetRawDataFromRes("colors.xml", &pBuffer, dwBuffer)) goto clean0; if (!xmlDoc.LoadBuffer((char*)pBuffer, (long)dwBuffer, TIXML_ENCODING_UTF8)) goto clean0; pXmlChild = xmlDoc.FirstChildElement("colors"); if (!pXmlChild) goto clean0; pXmlItem = pXmlChild->FirstChildElement("color"); while (pXmlItem) { std::string strId; std::string strColor; strId = pXmlItem->Attribute("id"); strColor = pXmlItem->Attribute("value"); if (strId.length() && strColor.length()) { m_mapColorTable[strId] = HexStringToColor(strColor.c_str()); } pXmlItem = pXmlItem->NextSiblingElement("color"); } clean0: if (pBuffer) { FreeRawData(pBuffer); } return retval; }
void MCF::parseXml(char* buff, uint32 buffLen) { if (m_bStopped) return; TiXmlDocument doc; doc.SetCondenseWhiteSpace(false); doc.LoadBuffer(buff, buffLen); TiXmlNode *fNode = doc.FirstChild("files"); if (!fNode) throw gcException(ERR_XML_NOPRIMENODE); TiXmlElement* pChild = fNode->FirstChildElement(); while (pChild) { if (m_bStopped) return; MCFCore::MCFFile* temp = new MCFCore::MCFFile(); try { temp->loadXmlData(pChild); m_pFileList.push_back( temp ); } catch (gcException &) { safe_delete(temp); } pChild = pChild->NextSiblingElement(); } }
bool UploadDump(const char* file, const char* user, int build, int branch, DelegateI<Prog_s>* progress) { Logger log; log.write("---------------------------------------\r\n"); time_t ltime; /* calendar time */ ltime=time(NULL); /* get current cal time */ #ifdef WIN32 char buff[255] = {0}; struct tm t; localtime_s(&t, <ime); asctime_s(buff, 255, &t); #else struct tm *t = localtime(<ime); char* buff = asctime(t); #endif log.write("%s\r\n", buff); log.write("---------------------------------------\r\n"); log.write("Uploaded crash dump: [%s]\r\n", file); gcString dump(file); if (PrepDumpForUpload(dump) == false) { log.write("Failed to prepare crash dump.\r\n"); return false; } else { log.write("Prepared crash dump to: [%s]\r\n", dump.c_str()); } std::string os = UTIL::OS::getOSString(); HttpHandle hh(DUMP_UPLOAD_URL); if (progress) hh->getProgressEvent() += progress; hh->setUserAgent(DUMP_UPLOAD_AGENT); hh->cleanUp(); hh->addPostText("os", os.c_str()); hh->addPostText("build", build); hh->addPostText("appid", branch); if (user) hh->addPostText("user", user); hh->addPostFile("crashfile", dump.c_str()); try { hh->postWeb(); } catch (gcException &except) { log.write("Failed to upload crash: %s [%d.%d].\r\n", except.getErrMsg(), except.getErrId(), except.getSecErrId()); return false; } TiXmlDocument doc; doc.LoadBuffer(const_cast<char*>(hh->getData()), hh->getDataSize()); try { XML::processStatus(doc, "crashupload"); log.write("Uploaded dump\r\n"); UTIL::FS::delFile(UTIL::FS::Path(dump, "", true)); } catch (gcException &) { log.write("Bad status returned from upload crash dump.\r\n"); gcString res; res.assign(hh->getData(), hh->getDataSize()); log.write("Result: \r\n\r\n%s\r\n\r\n", res.c_str()); return false; } return true; }
BOOL CStubbornFiles::_LoadFromFile() { BOOL retval = FALSE; CDataFileLoader dataLoader; TiXmlDocument xmlDoc; const TiXmlElement* pXmlItems = NULL; const TiXmlElement* pXmlItem = NULL; const TiXmlElement* pXmlTime = NULL; TCHAR szConfPath[MAX_PATH] = { 0 }; CStringA strXmlAnsi; CStringW strPathUtf16; CStringA strPathAnsi; SYSTEMTIME sysTime = { 0 }; CStringA strTime; GetLocalTime(&sysTime); strTime.Format("%d.%d.%d", sysTime.wYear, sysTime.wMonth, sysTime.wDay); GetModuleFileName(NULL, szConfPath, MAX_PATH); PathRemoveFileSpec(szConfPath); PathAppend(szConfPath, _T("data\\strash.dat")); if (!dataLoader.LoadFile(szConfPath, strXmlAnsi)) goto clean0; if (!xmlDoc.LoadBuffer((LPSTR)(LPCSTR)strXmlAnsi, strXmlAnsi.GetLength(), TIXML_ENCODING_UTF8)) goto clean0; pXmlTime = xmlDoc.FirstChildElement("time"); if (!pXmlTime) goto clean0; if (strTime.Compare(pXmlTime->GetText())) goto clean0; pXmlItems = xmlDoc.FirstChildElement("items"); if (!pXmlItems) goto clean0; pXmlItem = pXmlItems->FirstChildElement("item"); while (pXmlItem) { strPathAnsi = pXmlItem->GetText(); if (strPathAnsi.GetLength()) { strPathUtf16 = KUTF8_To_UTF16(strPathAnsi); if (GetFileAttributes(strPathUtf16) != INVALID_FILE_ATTRIBUTES) { m_fileList.AddTail(strPathUtf16); m_fileMap[strPathUtf16] = TRUE; } } pXmlItem = pXmlItem->NextSiblingElement("item"); } retval = TRUE; clean0: return retval; }