[droid] add vfs for listing android apps
[vuplus_xbmc] / xbmc / filesystem / AndroidAppFile.cpp
1 /*
2  *      Copyright (C) 2012 Team XBMC
3  *      http://www.xbmc.org
4  *
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)
8  *  any later version.
9  *
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.
14  *
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
19  *
20  */
21
22 #include "system.h"
23
24 #if defined(TARGET_ANDROID)
25
26 #include "AndroidAppFile.h"
27 #include <sys/stat.h>
28 #include "Util.h"
29 #include "URL.h"
30 #include "utils/log.h"
31 #include "utils/URIUtils.h"
32 #include <jni.h>
33 #include "android/activity/XBMCApp.h"
34 using namespace XFILE;
35
36 CFileAndroidApp::CFileAndroidApp(void)
37 {
38   m_iconWidth = 0;
39   m_iconHeight = 0;
40 }
41
42 CFileAndroidApp::~CFileAndroidApp(void)
43 {
44   Close();
45 }
46
47 bool CFileAndroidApp::Open(const CURL& url)
48 {
49
50   m_url = url;
51   m_appname =  URIUtils::GetFileName(url.Get());
52   m_appname = m_appname.Left(m_appname.size() - 4);
53
54   return m_appname.size() > 0;
55 }
56
57 bool CFileAndroidApp::Exists(const CURL& url)
58 {
59   return true;
60 }
61
62 unsigned int CFileAndroidApp::Read(void* lpBuf, int64_t uiBufSize)
63 {
64   CXBMCApp::GetIcon(m_appname, lpBuf, uiBufSize);
65   return uiBufSize;
66 }
67
68 void CFileAndroidApp::Close()
69 {
70 }
71
72 int64_t CFileAndroidApp::GetLength()
73 {
74   CXBMCApp::GetIconSize(m_appname, &m_iconWidth, &m_iconHeight);
75   return m_iconWidth * m_iconHeight * 4;
76 }
77
78 unsigned int CFileAndroidApp::GetIconWidth()
79 {
80   return m_iconWidth;
81 }
82
83 unsigned int CFileAndroidApp::GetIconHeight()
84 {
85   return m_iconHeight;
86 }
87
88 int CFileAndroidApp::GetChunkSize()
89 {
90   return 0;
91 }
92 int CFileAndroidApp::Stat(const CURL& url, struct __stat64* buffer)
93 {
94   return 0;
95 }
96 int CFileAndroidApp::IoControl(EIoControl request, void* param)
97 {
98   if(request == IOCTRL_SEEK_POSSIBLE)
99     return 0;
100   return 1;
101 }
102 #endif
103