2 * Copyright (C) 2005-2013 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/>.
21 #if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
24 #include "network/Network.h"
26 #include "FileFactory.h"
31 #include "ShoutcastFile.h"
32 #include "FileReaderFile.h"
33 #ifdef HAS_FILESYSTEM_SMB
35 #include "windows/WINFileSmb.h"
40 #ifdef HAS_FILESYSTEM_CDDA
45 #ifdef HAS_FILESYSTEM_RTV
48 #ifdef HAS_FILESYSTEM_DAAP
52 #ifdef HAS_FILESYSTEM_SAP
55 #ifdef HAS_FILESYSTEM_VTP
61 #if defined(TARGET_ANDROID)
65 #ifdef HAS_FILESYSTEM_RAR
68 #ifdef HAS_FILESYSTEM_SFTP
71 #ifdef HAS_FILESYSTEM_NFS
74 #ifdef HAS_FILESYSTEM_AFP
77 #if defined(TARGET_ANDROID)
78 #include "AndroidAppFile.h"
83 #include "PipesManager.h"
85 #include "MusicDatabaseFile.h"
86 #include "SpecialProtocolFile.h"
87 #include "MultiPathFile.h"
88 #include "TuxBoxFile.h"
91 #include "HDHomeRunFile.h"
92 #include "SlingboxFile.h"
93 #include "ImageFile.h"
94 #include "Application.h"
96 #include "utils/log.h"
97 #include "utils/StringUtils.h"
98 #include "network/WakeOnAccess.h"
100 using namespace XFILE;
102 CFileFactory::CFileFactory()
106 CFileFactory::~CFileFactory()
110 IFile* CFileFactory::CreateLoader(const CStdString& strFileName)
112 CURL url(strFileName);
113 return CreateLoader(url);
116 IFile* CFileFactory::CreateLoader(const CURL& url)
118 if (!CWakeOnAccess::Get().WakeUpHost(url))
121 CStdString strProtocol = url.GetProtocol();
122 StringUtils::ToLower(strProtocol);
124 #if defined(TARGET_ANDROID)
125 if (strProtocol == "apk") return new CAPKFile();
127 if (strProtocol == "zip") return new CZipFile();
128 else if (strProtocol == "rar")
130 #ifdef HAS_FILESYSTEM_RAR
131 return new CRarFile();
133 CLog::Log(LOGWARNING, "%s - Compiled without non-free, rar support is disabled", __FUNCTION__);
136 else if (strProtocol == "musicdb") return new CMusicDatabaseFile();
137 else if (strProtocol == "videodb") return NULL;
138 else if (strProtocol == "special") return new CSpecialProtocolFile();
139 else if (strProtocol == "multipath") return new CMultiPathFile();
140 else if (strProtocol == "image") return new CImageFile();
141 else if (strProtocol == "file" || strProtocol.empty()) return new CHDFile();
142 else if (strProtocol == "filereader") return new CFileReaderFile();
143 #if defined(HAS_FILESYSTEM_CDDA) && defined(HAS_DVD_DRIVE)
144 else if (strProtocol == "cdda") return new CFileCDDA();
146 #ifdef HAS_FILESYSTEM
147 else if (strProtocol == "iso9660") return new CISOFile();
149 else if(strProtocol == "udf") return new CUDFFile();
150 #if defined(TARGET_ANDROID)
151 else if (strProtocol == "androidapp") return new CFileAndroidApp();
154 if( g_application.getNetwork().IsAvailable() )
156 if (strProtocol == "ftp"
157 || strProtocol == "ftps"
158 || strProtocol == "rss") return new CCurlFile();
159 else if (strProtocol == "http" || strProtocol == "https") return new CHTTPFile();
160 else if (strProtocol == "dav" || strProtocol == "davs") return new CDAVFile();
161 #ifdef HAS_FILESYSTEM_SFTP
162 else if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPFile();
164 else if (strProtocol == "shout") return new CShoutcastFile();
165 else if (strProtocol == "tuxbox") return new CTuxBoxFile();
166 else if (strProtocol == "hdhomerun") return new CHomeRunFile();
167 else if (strProtocol == "sling") return new CSlingboxFile();
168 else if (strProtocol == "myth") return new CMythFile();
169 else if (strProtocol == "cmyth") return new CMythFile();
170 #ifdef HAS_FILESYSTEM_SMB
171 #ifdef TARGET_WINDOWS
172 else if (strProtocol == "smb") return new CWINFileSMB();
174 else if (strProtocol == "smb") return new CSmbFile();
177 #ifdef HAS_FILESYSTEM
178 #ifdef HAS_FILESYSTEM_RTV
179 else if (strProtocol == "rtv") return new CRTVFile();
181 #ifdef HAS_FILESYSTEM_DAAP
182 else if (strProtocol == "daap") return new CDAAPFile();
185 #ifdef HAS_FILESYSTEM_SAP
186 else if (strProtocol == "sap") return new CSAPFile();
188 #ifdef HAS_FILESYSTEM_VTP
189 else if (strProtocol == "vtp") return new CVTPFile();
191 #ifdef HAS_PVRCLIENTS
192 else if (strProtocol == "pvr") return new CPVRFile();
194 #ifdef HAS_FILESYSTEM_NFS
195 else if (strProtocol == "nfs") return new CNFSFile();
197 #ifdef HAS_FILESYSTEM_AFP
198 else if (strProtocol == "afp") return new CAFPFile();
200 else if (strProtocol == "pipe") return new CPipeFile();
202 else if (strProtocol == "upnp") return new CUPnPFile();
206 CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );