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, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 #if defined(TARGET_ANDROID)
25 #include "AndroidAppDirectory.h"
26 #include "xbmc/android/activity/XBMCApp.h"
29 #include "utils/URIUtils.h"
31 #include "utils/log.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;
67 path.Format("androidapp://%s/%s/%s", url.GetHostName(), dirname, applications[i].packageName);
69 pItem->SetLabel(applications[i].packageLabel);
70 pItem->SetThumbnailImage(path+".png");
76 CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Failed to open %s",strPath.c_str());
80 bool CAndroidAppDirectory::IsAllowed(const CStdString& strFile) const
82 // Entries are virtual, so we want them all.