void CGUIAddonWindow::FreeResources(bool forceUnLoad /*= FALSE */)
{
- // Unload temporary language strings
- ClearAddonStrings();
-
CGUIMediaWindow::FreeResources(forceUnLoad);
}
m_actionEvent.Set();
}
-void CGUIAddonWindow::ClearAddonStrings()
-{
- // Unload temporary language strings
- g_localizeStrings.ClearBlock(m_addon->Path());
-}
-
bool CGUIAddonWindow::OnClick(int iItem)
{
// Hook Over calling CGUIMediaWindow::OnClick(iItem) results in it trying to PLAY the file item
protected:
virtual void Update();
virtual void GetContextButtons(int itemNumber, CContextButtons &buttons);
- void ClearAddonStrings();
void SetupShares();
bool (*CBOnInit)(GUIHANDLE cbhdl);
++it;
}
}
-
-uint32_t CLocalizeStrings::LoadBlock(const CStdString &id, const CStdString &path, const CStdString &language)
-{
- iBlocks it = m_blocks.find(id);
- if (it != m_blocks.end())
- return it->second; // already loaded
-
- // grab a new block
- uint32_t offset = block_start + m_blocks.size()*block_size;
- m_blocks.insert(make_pair(id, offset));
-
- // load the strings
- CStdString encoding;
- bool success = LoadStr2Mem(path, language, encoding, offset);
- if (!success)
- {
- if (language.Equals(SOURCE_LANGUAGE)) // no fallback, nothing to do
- return 0;
- }
-
- // load the fallback
- if (!language.Equals(SOURCE_LANGUAGE))
- success |= LoadStr2Mem(path, SOURCE_LANGUAGE, encoding, offset);
-
- return success ? offset : 0;
-}
-
-void CLocalizeStrings::ClearBlock(const CStdString &id)
-{
- iBlocks it = m_blocks.find(id);
- if (it == m_blocks.end())
- {
- CLog::Log(LOGERROR, "%s: Trying to clear non existent block %s", __FUNCTION__, id.c_str());
- return; // doesn't exist
- }
-
- // clear our block
- Clear(it->second, it->second + block_size);
- m_blocks.erase(it);
-}
void ClearSkinStrings();
const CStdString& Get(uint32_t code) const;
void Clear();
- uint32_t LoadBlock(const CStdString &id, const CStdString &path, const CStdString &language);
- void ClearBlock(const CStdString &id);
protected:
void Clear(uint32_t start, uint32_t end);
typedef std::map<uint32_t, LocStr>::const_iterator ciStrings;
typedef std::map<uint32_t, LocStr>::iterator iStrings;
- static const uint32_t block_start = 0xf000000;
- static const uint32_t block_size = 4096;
- std::map<CStdString, uint32_t> m_blocks;
- typedef std::map<CStdString, uint32_t>::iterator iBlocks;
CCriticalSection m_critSection;
};
void WindowXML::FreeResources(bool forceUnLoad /*= FALSE */)
{
TRACE;
- // Unload temporary language strings
- ClearScriptStrings();
ref(window)->FreeResources(forceUnLoad);
}
CLog::Log(LOGERROR, "%s: Unable to load skin file %s", __FUNCTION__, strPath.c_str());
return false;
}
- // load the strings in
- unsigned int offset = LoadScriptStrings();
CStdString xml;
char *buffer = new char[(unsigned int)file.GetLength()+1];
{
buffer[size] = 0;
xml = buffer;
- if (offset)
- {
- // replace the occurences of SCRIPT### with offset+###
- // not particularly efficient, but it works
- int pos = xml.Find("SCRIPT");
- while (pos != (int)CStdString::npos)
- {
- CStdString num = xml.Mid(pos + 6, 4);
- int number = atol(num.c_str());
- CStdString oldNumber, newNumber;
- oldNumber.Format("SCRIPT%d", number);
- newNumber.Format("%lu", offset + number);
- xml.Replace(oldNumber, newNumber);
- pos = xml.Find("SCRIPT", pos + 6);
- }
- }
}
delete[] buffer;
return interceptor->Load(xmlDoc.RootElement());
}
- unsigned int WindowXML::LoadScriptStrings()
- {
- TRACE;
- // Path where the language strings reside
- CStdString pathToLanguageFile = URIUtils::AddFileToFolder(m_scriptPath, "resources");
- pathToLanguageFile = URIUtils::AddFileToFolder(pathToLanguageFile, "language");
- URIUtils::AddSlashAtEnd(pathToLanguageFile);
-
- // allocate a bunch of strings
- return g_localizeStrings.LoadBlock(m_scriptPath, pathToLanguageFile, CSettings::Get().GetString("locale.language"));
- }
-
- void WindowXML::ClearScriptStrings()
- {
- TRACE;
- // Unload temporary language strings
- g_localizeStrings.ClearBlock(m_scriptPath);
- }
-
void WindowXML::SetupShares()
{
TRACE;
SWIGHIDDENVIRTUAL void GetContextButtons(int itemNumber, CContextButtons &buttons);
SWIGHIDDENVIRTUAL bool Update(const String &strPath);
- unsigned int LoadScriptStrings();
- void ClearScriptStrings();
void SetupShares();
String m_scriptPath;
String m_mediaDir;