void LibreOfficeInspector::_readLanguage() { XmlParser parser; wstring lang_found, file; _getPreferencesFile(file); if (parser.Load(file)) { parser.Parse(_readNodeCallback, &lang_found); if (m_version.size() > 0 && lang_found.size() == 0) { wstring locale; _readLocale(locale); lang_found = L"locale:" + locale; } g_log.Log(L"LibreOfficeInspector::_readLanguage. Preferences file '%s', language '%s'", (wchar_t *)file.c_str(), (wchar_t *) lang_found.c_str()); } else { g_log.Log(L"LibreOfficeInspector::_readLanguage. Could not open '%s'", (wchar_t *) file.c_str()); } m_KeyValues.push_back(InspectorKeyValue(L"lang",lang_found)); }
void SkypeProfile::SetDefaultLanguage() { bool bRslt; XmlParser parser; wstring file, account; if (_readDefaultAccount(account) == false) return; _getConfigFile(file, account); if (parser.Load(file) == false) { g_log.Log(L"SkypeProfile::SetDefaultLanguage. Could not open '%s'", (wchar_t *) file.c_str()); return; } XmlNode currentNode(parser.getDocument()); bRslt = parser.FindNode(L"//Language", currentNode); if (bRslt) { XmlNode newNode(parser.getDocument()); newNode.SetName(L"Language"); newNode.SetText(CATALAN_LANG_PROFILE); newNode.CreateElement(); parser.ReplaceNode(newNode, currentNode); bRslt = parser.Save(file); g_log.Log(L"SkypeProfile::SetDefaultLanguage. Saved file '%s', result %u", (wchar_t *)file.c_str(), (wchar_t *) bRslt); } else { g_log.Log(L"SkypeProfile::SetDefaultLanguage. Could not find language node."); } }
void ConfigurationRemoteXmlParser::Parse() { XmlParser parser; if (parser.Load(m_file) == false) { g_log.Log(L"ConfigurationXmlParser::Parse. Could not open / error parsing '%s'", (wchar_t *) m_file.c_str()); return; } m_configurationBlock = ConfigurationBlockNone; parser.Parse(_readNodeCallback, this); }
bool SkypeProfile::_readDefaultAccount(wstring& account) { XmlParser parser; wstring file; _getSharedFile(file); if (parser.Load(file) == false) { g_log.Log(L"SkypeProfile::_readDefaultAccount. Could not open '%s'", (wchar_t *) file.c_str()); return false; } parser.Parse(_readDefaultAccountNodeCallback, &account); return account.size() > 0; }
bool SkypeProfile::_readDefaultAccountLanguage(wstring& language) { XmlParser parser; wstring file, account; if (_readDefaultAccount(account) == false) return false; _getConfigFile(file, account); if (parser.Load(file) == false) { g_log.Log(L"SkypeProfile::_readDefaultAccountLanguage. Could not open '%s'", (wchar_t *) file.c_str()); return false; } parser.Parse(_readDefaultAccountLanguageNodeCallback, &language); return language.size() >0; }
bool OpenOfficeAction::_isDefaultLanguage() { XmlParser parser; wstring lang_found, file; bool bRslt; _getPreferencesFile(file); if (parser.Load(file) == false) { g_log.Log(L"OpenOfficeAction::_isDefaultLanguage. Could not open '%s'", (wchar_t *) file.c_str()); return false; } parser.Parse(_readNodeCallback, &lang_found); // TODO: We should look for != "ca" but right now we can only add Catalan if no language is present bRslt = lang_found.size() != 0; g_log.Log(L"OpenOfficeAction::_isDefaultLanguage. Preferences file '%s', isdefault %u", (wchar_t *)file.c_str(), (wchar_t *) bRslt); return bRslt; }
void OpenOfficeAction::_setDefaultLanguage() { XmlParser parser; wstring file; bool bRslt; _getPreferencesFile(file); if (parser.Load(file) == false) { g_log.Log(L"OpenOfficeAction::_setDefaultLanguage. Could not open '%s'", (wchar_t *) file.c_str()); return; } /* XML fragment to generate <item oor:path="/org.openoffice.Office.Linguistic/General"> <prop oor:name="UILocale" oor:op="fuse"> <value>DEFAULT_LANGUAGE</value> </prop> </item> */ XmlNode item(parser.getDocument()), prop(parser.getDocument()), value(parser.getDocument()); value.SetName(wstring(L"value")); value.SetText(wstring(DEFAULT_LANGUAGE)); prop.SetName(wstring(L"prop")); prop.AddAttribute(XmlAttribute(L"oor:name", L"UILocale")); prop.AddAttribute(XmlAttribute(L"oor:op", L"fuse")); prop.AddChildren(value); item.SetName(wstring(L"item")); item.AddAttribute(XmlAttribute(L"oor:path", L"/org.openoffice.Office.Linguistic/General")); item.AddChildren(prop); parser.AppendNode(item); bRslt = parser.Save(file); g_log.Log(L"OpenOfficeAction::_setDefaultLanguage. Saved file '%s', result %u", (wchar_t *)file.c_str(), (wchar_t *) bRslt); }