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