The hostname/url stuff needs some help for sure.
--- /dev/null
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "system.h"
+
+#if defined(TARGET_ANDROID)
+#include "AndroidAppDirectory.h"
+#include "xbmc/android/activity/XBMCApp.h"
+#include "FileItem.h"
+#include "File.h"
+#include "utils/URIUtils.h"
+#include <vector>
+#include "utils/log.h"
+#include "URL.h"
+
+using namespace XFILE;
+using namespace std;
+
+CAndroidAppDirectory::CAndroidAppDirectory(void)
+{
+}
+
+CAndroidAppDirectory::~CAndroidAppDirectory(void)
+{
+}
+
+bool CAndroidAppDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
+{
+ CURL url(strPath);
+ CStdString dirname = url.GetFileName();
+ URIUtils::RemoveSlashAtEnd(dirname);
+ CLog::Log(LOGDEBUG, "CAndroidAppDirectory::GetDirectory: %s",dirname.c_str());
+ if (dirname == "apps")
+ {
+ vector<androidPackage> applications;
+ CXBMCApp::ListApplications(&applications);
+ if (!applications.size())
+ {
+ CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Application lookup listing failed");
+ return false;
+ }
+ for(unsigned int i = 0; i < applications.size(); i++)
+ {
+ if (applications[i].packageName == "org.xbmc.xbmc")
+ continue;
+ CFileItemPtr pItem(new CFileItem(applications[i].packageName));
+ pItem->m_bIsFolder = false;
+ CStdString path;
+ path.Format("androidapp://%s/%s/%s", url.GetHostName(), dirname, applications[i].packageName);
+ pItem->SetPath(path);
+ pItem->SetLabel(applications[i].packageLabel);
+ pItem->SetThumbnailImage(path+".png");
+ items.Add(pItem);
+ }
+ return true;
+ }
+
+ CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Failed to open %s",strPath.c_str());
+ return false;
+}
+
+bool CAndroidAppDirectory::IsAllowed(const CStdString& strFile) const
+{
+ // Entries are virtual, so we want them all.
+ return true;
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+#if defined(TARGET_ANDROID)
+#include "IDirectory.h"
+#include "FileItem.h"
+namespace XFILE
+{
+
+class CAndroidAppDirectory :
+ public IDirectory
+{
+public:
+ CAndroidAppDirectory(void);
+ virtual ~CAndroidAppDirectory(void);
+ virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
+ virtual bool Exists(const char* strPath) { return true; };
+ virtual bool IsAllowed(const CStdString& strFile) const;
+};
+}
+#endif
+
--- /dev/null
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "system.h"
+
+#if defined(TARGET_ANDROID)
+
+#include "AndroidAppFile.h"
+#include <sys/stat.h>
+#include "Util.h"
+#include "URL.h"
+#include "utils/log.h"
+#include "utils/URIUtils.h"
+#include <jni.h>
+#include "android/activity/XBMCApp.h"
+using namespace XFILE;
+
+CFileAndroidApp::CFileAndroidApp(void)
+{
+ m_iconWidth = 0;
+ m_iconHeight = 0;
+}
+
+CFileAndroidApp::~CFileAndroidApp(void)
+{
+ Close();
+}
+
+bool CFileAndroidApp::Open(const CURL& url)
+{
+
+ m_url = url;
+ m_appname = URIUtils::GetFileName(url.Get());
+ m_appname = m_appname.Left(m_appname.size() - 4);
+
+ return m_appname.size() > 0;
+}
+
+bool CFileAndroidApp::Exists(const CURL& url)
+{
+ return true;
+}
+
+unsigned int CFileAndroidApp::Read(void* lpBuf, int64_t uiBufSize)
+{
+ CXBMCApp::GetIcon(m_appname, lpBuf, uiBufSize);
+ return uiBufSize;
+}
+
+void CFileAndroidApp::Close()
+{
+}
+
+int64_t CFileAndroidApp::GetLength()
+{
+ CXBMCApp::GetIconSize(m_appname, &m_iconWidth, &m_iconHeight);
+ return m_iconWidth * m_iconHeight * 4;
+}
+
+unsigned int CFileAndroidApp::GetIconWidth()
+{
+ return m_iconWidth;
+}
+
+unsigned int CFileAndroidApp::GetIconHeight()
+{
+ return m_iconHeight;
+}
+
+int CFileAndroidApp::GetChunkSize()
+{
+ return 0;
+}
+int CFileAndroidApp::Stat(const CURL& url, struct __stat64* buffer)
+{
+ return 0;
+}
+int CFileAndroidApp::IoControl(EIoControl request, void* param)
+{
+ if(request == IOCTRL_SEEK_POSSIBLE)
+ return 0;
+ return 1;
+}
+#endif
+
--- /dev/null
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "system.h"
+
+#if defined(TARGET_ANDROID)
+#include "IFile.h"
+#include "URL.h"
+#include "utils/StdString.h"
+namespace XFILE
+{
+class CFileAndroidApp : public IFile
+{
+public:
+ /*! \brief Currently only used for retrieving App Icons. */
+ CFileAndroidApp(void);
+ virtual ~CFileAndroidApp(void);
+ virtual bool Open(const CURL& url);
+ virtual bool Exists(const CURL& url);
+ virtual int Stat(const CURL& url, struct __stat64* buffer);
+
+ /*! \brief Return 32bit rgba raw bitmap. */
+ virtual unsigned int Read(void* lpBuf, int64_t uiBufSize);
+ virtual void Close();
+ virtual int64_t GetLength();
+ virtual int64_t Seek(int64_t, int) {return -1;};
+ virtual int64_t GetPosition() {return 0;};
+ virtual int GetChunkSize();
+ virtual int IoControl(EIoControl request, void* param);
+
+ /*! \brief Only valid after GetLength() has been called, usually by Open(). */
+ unsigned int GetIconWidth();
+ /*! \brief Only valid after GetLength() has been called, usually by Open(). */
+ unsigned int GetIconHeight();
+
+protected:
+ bool IsValidFile(const CURL& url);
+
+private:
+ CURL m_url;
+ CStdString m_appname;
+ int m_iconWidth;
+ int m_iconHeight;
+};
+}
+
+#endif
+
#ifdef HAVE_LIBBLURAY
#include "BlurayDirectory.h"
#endif
+#if defined(TARGET_ANDROID)
+#include "AndroidAppDirectory.h"
+#endif
using namespace XFILE;
#ifdef HAVE_LIBBLURAY
if (strProtocol == "bluray") return new CBlurayDirectory();
#endif
+#if defined(TARGET_ANDROID)
+ if (strProtocol == "androidapp") return new CAndroidAppDirectory();
+#endif
}
CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );
#ifdef HAS_FILESYSTEM_AFP
#include "AFPFile.h"
#endif
+#if defined(TARGET_ANDROID)
+#include "AndroidAppFile.h"
+#endif
#include "UPnPFile.h"
#include "PipesManager.h"
#include "PipeFile.h"
#endif
else if (strProtocol == "pipe") return new CPipeFile();
else if (strProtocol == "upnp") return new CUPnPFile();
+#if defined(TARGET_ANDROID)
+ else if (strProtocol == "androidapp") return new CFileAndroidApp();
+#endif
}
CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );
CXXFLAGS+=-D__STDC_FORMAT_MACROS \
SRCS=AddonsDirectory.cpp \
+ AndroidAppFile.cpp \
+ AndroidAppDirectory.cpp \
ASAPFileDirectory.cpp \
CacheStrategy.cpp \
CircularCache.cpp \