Skip to content

Commit

Permalink
[iOS] Add "Copy to Kodi" functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTheMan827 authored and Daniel committed Jul 25, 2016
1 parent 527a251 commit 3e2d04f
Show file tree
Hide file tree
Showing 7 changed files with 389 additions and 4 deletions.
32 changes: 32 additions & 0 deletions userdata/iOS/sources.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<sources>
<programs>
<default pathversion="1"></default>
</programs>
<video>
<default pathversion="1"></default>
<source>
<name>Inbox</name>
<path pathversion="1">special://envhome/Documents/Inbox/</path>
<allowsharing>true</allowsharing>
</source>
</video>
<music>
<default pathversion="1"></default>
<source>
<name>Inbox</name>
<path pathversion="1">special://envhome/Documents/Inbox/</path>
<allowsharing>true</allowsharing>
</source>
</music>
<pictures>
<default pathversion="1"></default>
<source>
<name>Inbox</name>
<path pathversion="1">special://envhome/Documents/Inbox/</path>
<allowsharing>true</allowsharing>
</source>
</pictures>
<files>
<default pathversion="1"></default>
</files>
</sources>
20 changes: 17 additions & 3 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,14 @@ extern "C" void __stdcall cleanup_emu_environ();
// Utility function used to copy files from the application bundle
// over to the user data directory in Application Support/Kodi.
//
static void CopyUserDataIfNeeded(const std::string &strPath, const std::string &file)
static void CopyUserDataIfNeeded(const std::string &strPath, const std::string &file, const std::string &destname = "")
{
std::string destPath = URIUtils::AddFileToFolder(strPath, file);
std::string destPath;
if (destname == "")
destPath = URIUtils::AddFileToFolder(strPath, file);
else
destPath = URIUtils::AddFileToFolder(strPath, destname);

if (!CFile::Exists(destPath))
{
// need to copy it across
Expand Down Expand Up @@ -469,7 +474,12 @@ bool CApplication::Create()
win32_exception::install_handler();

#endif


#if defined(TARGET_POSIX)
// set special://envhome
CSpecialProtocol::SetEnvHomePath(getenv("HOME"));
#endif

// only the InitDirectories* for the current platform should return true
bool inited = InitDirectoriesLinux();
if (!inited)
Expand All @@ -481,6 +491,10 @@ bool CApplication::Create()
CopyUserDataIfNeeded("special://masterprofile/", "RssFeeds.xml");
CopyUserDataIfNeeded("special://masterprofile/", "favourites.xml");
CopyUserDataIfNeeded("special://masterprofile/", "Lircmap.xml");

#ifdef TARGET_DARWIN_IOS
CopyUserDataIfNeeded("special://masterprofile/", "iOS/sources.xml", "sources.xml");
#endif

if (!CLog::Init(CSpecialProtocol::TranslatePath("special://logpath").c_str()))
{
Expand Down
7 changes: 7 additions & 0 deletions xbmc/filesystem/SpecialProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ void CSpecialProtocol::SetUserHomePath(const std::string &dir)
SetPath("userhome", dir);
}

void CSpecialProtocol::SetEnvHomePath(const std::string &dir)
{
SetPath("envhome", dir);
}

void CSpecialProtocol::SetMasterProfilePath(const std::string &dir)
{
SetPath("masterprofile", dir);
Expand Down Expand Up @@ -154,6 +159,7 @@ std::string CSpecialProtocol::TranslatePath(const CURL &url)
else if (RootDir == "xbmc" ||
RootDir == "xbmcbin" ||
RootDir == "home" ||
RootDir == "envhome" ||
RootDir == "userhome" ||
RootDir == "temp" ||
RootDir == "profile" ||
Expand Down Expand Up @@ -247,6 +253,7 @@ void CSpecialProtocol::LogPaths()
CLog::Log(LOGNOTICE, "special://xbmc/ is mapped to: %s", GetPath("xbmc").c_str());
CLog::Log(LOGNOTICE, "special://xbmcbin/ is mapped to: %s", GetPath("xbmcbin").c_str());
CLog::Log(LOGNOTICE, "special://masterprofile/ is mapped to: %s", GetPath("masterprofile").c_str());
CLog::Log(LOGNOTICE, "special://envhome/ is mapped to: %s", GetPath("envhome").c_str());
CLog::Log(LOGNOTICE, "special://home/ is mapped to: %s", GetPath("home").c_str());
CLog::Log(LOGNOTICE, "special://temp/ is mapped to: %s", GetPath("temp").c_str());
CLog::Log(LOGNOTICE, "special://logpath/ is mapped to: %s", GetPath("logpath").c_str());
Expand Down
2 changes: 2 additions & 0 deletions xbmc/filesystem/SpecialProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Linux: ~/.kodi/
OS X: ~/Library/Application Support/Kodi/
Win32: ~/Application Data/XBMC/
special://envhome/ - on posix systems this will be equal to the $HOME
special://userhome/ - a writable version of the user home directory
Linux, OS X: ~/.kodi
Win32: home directory of user
Expand Down Expand Up @@ -58,6 +59,7 @@ class CSpecialProtocol
static void SetXBMCFrameworksPath(const std::string &path);
static void SetHomePath(const std::string &path);
static void SetUserHomePath(const std::string &path);
static void SetEnvHomePath(const std::string &path);
static void SetMasterProfilePath(const std::string &path);
static void SetTempPath(const std::string &path);
static void SetLogPath(const std::string &dir);
Expand Down
Loading

0 comments on commit 3e2d04f

Please sign in to comment.