From 1ba2ce796e1b324b82c1443325c04c5fa7561d25 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 23 Jun 2016 17:20:39 +0100 Subject: [PATCH] Compatibility for VDR 2.1.2 --- handler.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/handler.c b/handler.c index f8750e6..28778d4 100755 --- a/handler.c +++ b/handler.c @@ -154,7 +154,12 @@ bool jsonserver_diskstats(Json::Value& js) int FreeMB; int UsedMB; + +#if APIVERSNUM > 20101 + int Percent = cVideoDirectory::VideoDiskSpace(&FreeMB, &UsedMB); +#else int Percent = VideoDiskSpace(&FreeMB, &UsedMB); +#endif js["FreeMiB"] = FreeMB; js["UsedMiB"] = UsedMB; @@ -461,8 +466,15 @@ bool jsonserver_recmove(Json::Value& js, const char* postData) // Find the foldername - log->log("JSONServer", Log::DEBUG, "j = %u, strlenvd = %u", j, strlen(VideoDirectory)); - if (j > (int)strlen(VideoDirectory)) // Rec is in a subfolder now +#if APIVERSNUM > 20101 + const char* vidDirStr = cVideoDirectory::Name(); +#else + const char* vidDirStr = VideoDirectory; +#endif + int vidDirStrLen = strlen(vidDirStr); + + log->log("JSONServer", Log::DEBUG, "j = %u, strlenvd = %u", j, vidDirStrLen); + if (j > vidDirStrLen) // Rec is in a subfolder now { for(m = j-1; m >= 0; m--) { @@ -481,13 +493,13 @@ bool jsonserver_recmove(Json::Value& js, const char* postData) log->log("JSONServer", Log::DEBUG, "datedirname: %s", dateDirName); log->log("JSONServer", Log::DEBUG, "titledirname: %s", titleDirName); - log->log("JSONServer", Log::DEBUG, "viddir: %s", VideoDirectory); + log->log("JSONServer", Log::DEBUG, "viddir: %s", vidDirStr); if (folderName) log->log("JSONServer", Log::DEBUG, "folderName: %s", folderName); log->log("JSONServer", Log::DEBUG, "EC: %s", requestedNewPath); // Could be a new path - construct that first and test - newContainer = new char[strlen(VideoDirectory) + strlen(requestedNewPath) + strlen(titleDirName) + 1]; - sprintf(newContainer, "%s%s", VideoDirectory, requestedNewPath); + newContainer = new char[vidDirStrLen + strlen(requestedNewPath) + strlen(titleDirName) + 1]; + sprintf(newContainer, "%s%s", vidDirStr, requestedNewPath); log->log("JSONServer", Log::DEBUG, "NPT: %s", newContainer); struct stat dstat; int statret = stat(newContainer, &dstat); @@ -505,7 +517,7 @@ bool jsonserver_recmove(Json::Value& js, const char* postData) // New path now created or was there already - sprintf(newContainer, "%s%s%s", VideoDirectory, requestedNewPath, titleDirName); + sprintf(newContainer, "%s%s%s", vidDirStr, requestedNewPath, titleDirName); log->log("JSONServer", Log::DEBUG, "%s", newContainer); statret = stat(newContainer, &dstat); @@ -684,9 +696,16 @@ bool jsonserver_recrename(Json::Value& js, const char* postData) } // Find the foldername - - log->log("JSONServer", Log::DEBUG, "j = %u, strlenvd = %u", j, strlen(VideoDirectory)); - if (j > (int)strlen(VideoDirectory)) // Rec is in a subfolder now + +#if APIVERSNUM > 20101 + const char* vidDirStr = cVideoDirectory::Name(); +#else + const char* vidDirStr = VideoDirectory; +#endif + int vidDirStrLen = strlen(vidDirStr); + + log->log("JSONServer", Log::DEBUG, "j = %u, strlenvd = %u", j, vidDirStrLen); + if (j > vidDirStrLen) // Rec is in a subfolder now { for(m = j-1; m >= 0; m--) { @@ -705,7 +724,7 @@ bool jsonserver_recrename(Json::Value& js, const char* postData) log->log("JSONServer", Log::DEBUG, "datedirname: %s", dateDirName); log->log("JSONServer", Log::DEBUG, "titledirname: %s", titleDirName); - log->log("JSONServer", Log::DEBUG, "viddir: %s", VideoDirectory); + log->log("JSONServer", Log::DEBUG, "viddir: %s", vidDirStr); if (folderName) log->log("JSONServer", Log::DEBUG, "folderName: %s", folderName); log->log("JSONServer", Log::DEBUG, "EC: %s", requestedNewName); @@ -713,13 +732,13 @@ bool jsonserver_recrename(Json::Value& js, const char* postData) if (folderName) { - newContainer = new char[strlen(VideoDirectory) + 1 + strlen(folderName) + 1 + strlen(requestedNewName) + 1]; - sprintf(newContainer, "%s/%s/%s", VideoDirectory, folderName, requestedNewName); + newContainer = new char[vidDirStrLen + 1 + strlen(folderName) + 1 + strlen(requestedNewName) + 1]; + sprintf(newContainer, "%s/%s/%s", vidDirStr, folderName, requestedNewName); } else { - newContainer = new char[strlen(VideoDirectory) + 1 + strlen(requestedNewName) + 1]; - sprintf(newContainer, "%s/%s", VideoDirectory, requestedNewName); + newContainer = new char[vidDirStrLen + 1 + strlen(requestedNewName) + 1]; + sprintf(newContainer, "%s/%s", vidDirStr, requestedNewName); } log->log("JSONServer", Log::DEBUG, "NPT: %s", newContainer); struct stat dstat; -- 2.39.2