HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CMD_ServerSocketCommandListener.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CMD_ServerSocketCommandListener.h ( CMD Library, C++ )
7  *
8  * COMMENTS:
9  * This event generator opens a socket an waits for connections.
10  * When a client makes a connection and sends a command, that
11  * command is run and the command output is sent back.
12  * Note that multiple active connections can exist at once.
13  */
14 
15 #ifndef __CMD_ServerSocketCommandListener_h__
16 #define __CMD_ServerSocketCommandListener_h__
17 
18 #include "CMD_API.h"
20 #if !defined(GAMEOS)
21 #include <UT/UT_Spawn.h>
22 #endif
23 
24 class UT_WorkBuffer;
25 class CMD_Manager;
26 
28 {
29 public:
30  // Use this static method to create a instance of this class.
31  // Note that this method might return null if the socket could not be
32  // created (eg. if the port is already in use).
33  // separate_errors: if set, error output will be separated from
34  // regular output by ~~~~.
35  // restrict_to_safe_commands: if set, "unsafe" commands will not be
36  // executed.
37  // ip_mask: restricts who is allowed to connect to this socket. If
38  // it is null, it defaults to +.+.+.+.
39  // remap_privileged_ports: if set, port numbers will be mapped into
40  // the range of unprivileged port numbers.
41  static CMD_ServerSocketCommandListener *createCommandListener(int port,
42  CMD_Manager& command_manager,
43  bool separate_errors = false,
44  bool restrict_to_safe_commands = false,
45  const char *ip_mask = 0,
46  bool remap_privileged_ports = true,
47  bool browser_mode = false);
48 
49  virtual const char *className() const
50  { return "CMD_ServerSocketCommandListener"; }
51 
53  { return myRestrictToSafeCmds; }
54  void setRestrictToSafeCommands(bool restrict_to_safe_cmds)
55  { myRestrictToSafeCmds = restrict_to_safe_cmds; }
56 
57 private:
58  // This private constructor is called by the createCommandListener()
59  // static method.
61  int requested_port,
62  CMD_Manager &command_manager,
63  bool separate_errors,
64  bool restrict_to_safe_commands,
65  const char *ip_mask,
66  bool browser_mode);
67 
68  // This method is overriden so we can create a
69  // UI_ConnectSocketCommandListener to listen for commands from an active
70  // connection.
71  virtual void createConnectedSocketListener();
72 
73 
74  // Data:
75 
76  CMD_Manager &myCommandManager;
77  bool mySeparateErrors;
78  bool myRestrictToSafeCmds;
79  bool myBrowserMode;
80 };
81 
82 #endif
void setRestrictToSafeCommands(bool restrict_to_safe_cmds)
virtual void createConnectedSocketListener()
#define CMD_API
Definition: CMD_API.h:10