]> git.vomp.tv Git - jsonserver.git/commitdiff
Compatibility for VDR 2.1.2
authorChris Tallon <chris@vomp.tv>
Thu, 23 Jun 2016 16:20:39 +0000 (17:20 +0100)
committerChris Tallon <chris@vomp.tv>
Thu, 23 Jun 2016 16:20:39 +0000 (17:20 +0100)
handler.c

index f8750e63dbdc24f4eee2fe053bb92ce3c45a2164..28778d4de797ce68196d8949faf5b6e7eec4784d 100755 (executable)
--- 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;