]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/props.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Network / props.cxx
index de1c870e05215f736431b9fdbd8df4e23c72c784..51b293177a83f5fafa938f6081715f28e208a1f6 100644 (file)
 
 #include <simgear/compiler.h>
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/commands.hxx>
 #include <simgear/misc/strutils.hxx>
-#include <simgear/misc/props.hxx>
-#include <simgear/misc/props_io.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
 
 #include STL_STRSTREAM
 
 
 #include "props.hxx"
 
+#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(strstream);
 SG_USING_STD(ends);
+#endif
 
 /**
  * Props connection class.
@@ -308,21 +311,53 @@ PropsChannel::foundTerminator()
        }
        else if ( command == "set" )
        {
-           if ( tokens.size() == 3 )
-           {
-               node->getNode( tokens[1].c_str(), true )->setStringValue(tokens[2].c_str());
+           if ( tokens.size() >= 2 )
+            {
+                string value, tmp;
+                if ( tokens.size() == 3 ) {
+                    value = tokens[2];
+                } else {
+                    value = "";
+                }
+                node->getNode( tokens[1].c_str(), true )
+                    ->setStringValue(value.c_str());
 
                if ( mode == PROMPT )
                {
                    // now fetch and write out the new value as confirmation
                    // of the change
-                   string value = node->getStringValue ( tokens[1].c_str(), "" );
-                   string tmp = tokens[1] + " = '" + value + "' (";
+                   value = node->getStringValue ( tokens[1].c_str(), "" );
+                   tmp = tokens[1] + " = '" + value + "' (";
                    tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
                    tmp += ")";
                    push( tmp.c_str() );
                    push( getTerminator() );
                }
+           } 
+       }
+       else if ( command == "run" )
+       {
+           if ( tokens.size() == 2 )
+           {
+               string tmp;     
+                SGPropertyNode args;
+                if ( !globals->get_commands()
+                         ->execute(tokens[1].c_str(), &args) )
+                {
+                    SG_LOG( SG_GENERAL, SG_ALERT,
+                            "Command " << tokens[1] << " failed.");
+                    if ( mode == PROMPT ) {
+                        tmp += "*failed*";
+                        push( tmp.c_str() );
+                        push( getTerminator() );
+                    }
+                } else {
+                    if ( mode == PROMPT ) {
+                        tmp += "<completed>";
+                        push( tmp.c_str() );
+                        push( getTerminator() );
+                    }
+                }
            }
        }
        else if (command == "quit")
@@ -353,6 +388,7 @@ ls [<dir>]         list directory\r\n\
 prompt             switch to interactive mode (default)\r\n\
 pwd                display your current path\r\n\
 quit               terminate connection\r\n\
+run <command>      run built in command\r\n\
 set <var> <val>    set <var> to a new <val>\r\n\
 show <var>         synonym for get\r\n";
            push( msg );