diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-07-29 02:42:25 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-07-29 02:42:25 +0000 |
commit | 6ef0a749a05301e1541ebb13c5e672153adae02e (patch) | |
tree | 497786997be8d0901df0765c4f63fa40b62e9bb3 | |
parent | dafcbeece4df3d112c3b2ea73f8b495cf591f907 (diff) |
fixed: Ticket #9771 - No custom windows loading when using a windows username with non-ascii characters in it.
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@32270 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | xbmc/Application.cpp | 144 |
1 files changed, 66 insertions, 78 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 42a22dbfad..e0434c3c1b 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -1686,92 +1686,80 @@ bool CApplication::LoadUserWindows() g_SkinInfo->GetSkinPaths(vecSkinPath); for (unsigned int i = 0;i < vecSkinPath.size();++i) { - CStdString strPath = CUtil::AddFileToFolder(vecSkinPath[i], "custom*.xml"); CLog::Log(LOGINFO, "Loading user windows, path %s", vecSkinPath[i].c_str()); - - WIN32_FIND_DATA NextFindFileData; - HANDLE hFind = FindFirstFile(_P(strPath).c_str(), &NextFindFileData); - while (hFind != INVALID_HANDLE_VALUE) + CFileItemList items; + if (CDirectory::GetDirectory(vecSkinPath[i], items, ".xml", false)) { - WIN32_FIND_DATA FindFileData = NextFindFileData; - - if (!FindNextFile(hFind, &NextFindFileData)) + for (int i = 0; i < items.Size(); ++i) { - FindClose(hFind); - hFind = INVALID_HANDLE_VALUE; - } - - // skip "up" directories, which come in all queries - if (!strcmp(FindFileData.cFileName, ".") || !strcmp(FindFileData.cFileName, "..")) - continue; - - CStdString strFileName = CUtil::AddFileToFolder(vecSkinPath[i], FindFileData.cFileName); - CLog::Log(LOGINFO, "Loading skin file: %s", strFileName.c_str()); - CStdString strLower(FindFileData.cFileName); - strLower.MakeLower(); - strLower = CUtil::AddFileToFolder(vecSkinPath[i], strLower); - TiXmlDocument xmlDoc; - if (!xmlDoc.LoadFile(strFileName) && !xmlDoc.LoadFile(strLower)) - { - CLog::Log(LOGERROR, "unable to load:%s, Line %d\n%s", strFileName.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); - continue; - } + if (items[i]->m_bIsFolder) + continue; + CStdString skinFile = CUtil::GetFileName(items[i]->m_strPath); + if (skinFile.Left(6).CompareNoCase("custom") == 0) + { + TiXmlDocument xmlDoc; + if (!xmlDoc.LoadFile(items[i]->m_strPath)) + { + CLog::Log(LOGERROR, "unable to load:%s, Line %d\n%s", items[i]->m_strPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); + continue; + } - // Root element should be <window> - TiXmlElement* pRootElement = xmlDoc.RootElement(); - CStdString strValue = pRootElement->Value(); - if (!strValue.Equals("window")) - { - CLog::Log(LOGERROR, "file :%s doesnt contain <window>", strFileName.c_str()); - continue; - } + // Root element should be <window> + TiXmlElement* pRootElement = xmlDoc.RootElement(); + CStdString strValue = pRootElement->Value(); + if (!strValue.Equals("window")) + { + CLog::Log(LOGERROR, "file :%s doesnt contain <window>", skinFile.c_str()); + continue; + } - // Read the <type> element to get the window type to create - // If no type is specified, create a CGUIWindow as default - CGUIWindow* pWindow = NULL; - CStdString strType; - if (pRootElement->Attribute("type")) - strType = pRootElement->Attribute("type"); - else - { - const TiXmlNode *pType = pRootElement->FirstChild("type"); - if (pType && pType->FirstChild()) - strType = pType->FirstChild()->Value(); - } - int id = WINDOW_INVALID; - if (!pRootElement->Attribute("id", &id)) - { - const TiXmlNode *pType = pRootElement->FirstChild("id"); - if (pType && pType->FirstChild()) - id = atol(pType->FirstChild()->Value()); - } - int visibleCondition = 0; - CGUIControlFactory::GetConditionalVisibility(pRootElement, visibleCondition); - - if (strType.Equals("dialog")) - pWindow = new CGUIDialog(id + WINDOW_HOME, FindFileData.cFileName); - else if (strType.Equals("submenu")) - pWindow = new CGUIDialogSubMenu(id + WINDOW_HOME, FindFileData.cFileName); - else if (strType.Equals("buttonmenu")) - pWindow = new CGUIDialogButtonMenu(id + WINDOW_HOME, FindFileData.cFileName); - else - pWindow = new CGUIStandardWindow(id + WINDOW_HOME, FindFileData.cFileName); + // Read the <type> element to get the window type to create + // If no type is specified, create a CGUIWindow as default + CGUIWindow* pWindow = NULL; + CStdString strType; + if (pRootElement->Attribute("type")) + strType = pRootElement->Attribute("type"); + else + { + const TiXmlNode *pType = pRootElement->FirstChild("type"); + if (pType && pType->FirstChild()) + strType = pType->FirstChild()->Value(); + } + int id = WINDOW_INVALID; + if (!pRootElement->Attribute("id", &id)) + { + const TiXmlNode *pType = pRootElement->FirstChild("id"); + if (pType && pType->FirstChild()) + id = atol(pType->FirstChild()->Value()); + } + int visibleCondition = 0; + CGUIControlFactory::GetConditionalVisibility(pRootElement, visibleCondition); + + if (strType.Equals("dialog")) + pWindow = new CGUIDialog(id + WINDOW_HOME, skinFile); + else if (strType.Equals("submenu")) + pWindow = new CGUIDialogSubMenu(id + WINDOW_HOME, skinFile); + else if (strType.Equals("buttonmenu")) + pWindow = new CGUIDialogButtonMenu(id + WINDOW_HOME, skinFile); + else + pWindow = new CGUIStandardWindow(id + WINDOW_HOME, skinFile); - // Check to make sure the pointer isn't still null - if (pWindow == NULL) - { - CLog::Log(LOGERROR, "Out of memory / Failed to create new object in LoadUserWindows"); - return false; - } - if (id == WINDOW_INVALID || g_windowManager.GetWindow(WINDOW_HOME + id)) - { - delete pWindow; - continue; + // Check to make sure the pointer isn't still null + if (pWindow == NULL) + { + CLog::Log(LOGERROR, "Out of memory / Failed to create new object in LoadUserWindows"); + return false; + } + if (id == WINDOW_INVALID || g_windowManager.GetWindow(WINDOW_HOME + id)) + { + delete pWindow; + continue; + } + pWindow->SetVisibleCondition(visibleCondition, false); + g_windowManager.AddCustomWindow(pWindow); + } } - pWindow->SetVisibleCondition(visibleCondition, false); - g_windowManager.AddCustomWindow(pWindow); } - CloseHandle(hFind); } return true; } |