2 * Copyright (C) 2012 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"
33 using namespace XFILE;
36 CAndroidAppDirectory::CAndroidAppDirectory(void)
40 CAndroidAppDirectory::~CAndroidAppDirectory(void)
44 bool CAndroidAppDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
47 CStdString dirname = url.GetFileName();
48 URIUtils::RemoveSlashAtEnd(dirname);
49 CLog::Log(LOGDEBUG, "CAndroidAppDirectory::GetDirectory: %s",dirname.c_str());
50 if (dirname == "apps")
52 vector<androidPackage> applications;
53 CXBMCApp::ListApplications(&applications);
54 if (!applications.size())
56 CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Application lookup listing failed");
59 for(unsigned int i = 0; i < applications.size(); i++)
61 if (applications[i].packageName == "org.xbmc.xbmc")
63 CFileItemPtr pItem(new CFileItem(applications[i].packageName));
64 pItem->m_bIsFolder = false;
66 path.Format("androidapp://%s/%s/%s", url.GetHostName(), dirname, applications[i].packageName);
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.