]> git.sesse.net Git - casparcg/commitdiff
2.0. amcp: Fixed CG UPDATE to use DATA.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 19 Aug 2011 13:00:49 +0000 (13:00 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 19 Aug 2011 13:00:49 +0000 (13:00 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1232 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

protocol/amcp/AMCPCommandsImpl.cpp

index bb6b11fe5d4b69bae0383e64945cdbd2357ae04d..ccf4fa0f11b6cc6101de4fe79bebc343cb516deb 100644 (file)
@@ -1008,6 +1008,7 @@ bool CGCommand::DoExecuteNext()
                        SetReplyString(TEXT("403 CG ERROR\r\n"));\r
                        return false;\r
                }\r
+\r
                int layer = _ttoi(_parameters[1].c_str());\r
                get_default_cg_producer(safe_ptr<core::video_channel>(GetChannel()), GetLayerIndex(cg_producer::DEFAULT_LAYER))->next(layer);\r
        }\r
@@ -1030,6 +1031,7 @@ bool CGCommand::DoExecuteRemove()
                        SetReplyString(TEXT("403 CG ERROR\r\n"));\r
                        return false;\r
                }\r
+\r
                int layer = _ttoi(_parameters[1].c_str());\r
                get_default_cg_producer(safe_ptr<core::video_channel>(GetChannel()), GetLayerIndex(cg_producer::DEFAULT_LAYER))->remove(layer);\r
        }\r
@@ -1052,18 +1054,40 @@ bool CGCommand::DoExecuteClear()
 \r
 bool CGCommand::DoExecuteUpdate() \r
 {\r
-       if(_parameters.size() > 2) \r
+       try\r
        {\r
-               if(!ValidateLayer(_parameters[1]))\r
+               if(!ValidateLayer(_parameters.at(1)))\r
                {\r
                        SetReplyString(TEXT("403 CG ERROR\r\n"));\r
                        return false;\r
                }\r
-               int layer = _ttoi(_parameters[1].c_str());\r
-               //TODO: Implement indirect data loading from file. Same as in Add\r
-               get_default_cg_producer(safe_ptr<core::video_channel>(GetChannel()), GetLayerIndex(cg_producer::DEFAULT_LAYER))->update(layer, _parameters2[2]);\r
+                                               \r
+               std::wstring dataString = _parameters2.at(2);                           \r
+               if(dataString.at(0) != TEXT('<'))\r
+               {\r
+                       //The data is not an XML-string, it must be a filename\r
+                       std::wstring filename = env::data_folder();\r
+                       filename.append(dataString);\r
+                       filename.append(TEXT(".ftd"));\r
+\r
+                       //open file\r
+                       std::wifstream datafile(filename.c_str());\r
+                       if(datafile) \r
+                       {\r
+                               std::wstringstream data;\r
+                               //read all data\r
+                               data << datafile.rdbuf();\r
+                               datafile.close();\r
+\r
+                               //extract data to _parameters\r
+                               dataString = data.str();\r
+                       }\r
+               }               \r
+\r
+               int layer = _ttoi(_parameters.at(1).c_str());\r
+               get_default_cg_producer(safe_ptr<core::video_channel>(GetChannel()), GetLayerIndex(cg_producer::DEFAULT_LAYER))->update(layer, dataString);\r
        }\r
-       else \r
+       catch(...)\r
        {\r
                SetReplyString(TEXT("402 CG ERROR\r\n"));\r
                return true;\r