2 * Copyright (C) 2012-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #if defined(TARGET_ANDROID)
24 #include "AndroidAppDirectory.h"
25 #include "xbmc/android/activity/XBMCApp.h"
28 #include "utils/URIUtils.h"
30 #include "utils/log.h"
31 #include "utils/StringUtils.h"
34 using namespace XFILE;
37 CAndroidAppDirectory::CAndroidAppDirectory(void)
41 CAndroidAppDirectory::~CAndroidAppDirectory(void)
45 bool CAndroidAppDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
48 CStdString dirname = url.GetFileName();
49 URIUtils::RemoveSlashAtEnd(dirname);
50 CLog::Log(LOGDEBUG, "CAndroidAppDirectory::GetDirectory: %s",dirname.c_str());
51 if (dirname == "apps")
53 vector<androidPackage> applications;
54 CXBMCApp::ListApplications(&applications);
55 if (!applications.size())
57 CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Application lookup listing failed");
60 for(unsigned int i = 0; i < applications.size(); i++)
62 if (applications[i].packageName == "org.xbmc.xbmc")
64 CFileItemPtr pItem(new CFileItem(applications[i].packageName));
65 pItem->m_bIsFolder = false;
66 CStdString path = StringUtils::Format("androidapp://%s/%s/%s", url.GetHostName().c_str(), dirname.c_str(), applications[i].packageName.c_str());
68 pItem->SetLabel(applications[i].packageLabel);
69 pItem->SetArt("thumb", path+".png");
75 CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Failed to open %s",strPath.c_str());
79 bool CAndroidAppDirectory::IsAllowed(const CStdString& strFile) const
81 // Entries are virtual, so we want them all.