llcommandhandler.h

Go to the documentation of this file.
00001 
00033 #ifndef LLCOMMANDHANDLER_H
00034 #define LLCOMMANDHANDLER_H
00035 
00036 /* To implement a command "foo" that takes one parameter,
00037    a UUID, do this:
00038 
00039 class LLFooHandler : public LLCommandHandler
00040 {
00041 public:
00042     // Inform the system you handle commands starting
00043         // with "foo" and they are not allowed from external web
00044         // browser links.
00045         LLFooHandler() : LLCommandHandler("foo", false) { }
00046 
00047     // Your code here
00048         bool handle(const LLSD& tokens, const LLSD& queryMap)
00049         {
00050                 if (tokens.size() < 1) return false;
00051                 LLUUID id( tokens[0] );
00052                 return doFoo(id);
00053         }
00054 };
00055 
00056 // Creating the object registers with the dispatcher.
00057 LLFooHandler gFooHandler;
00058 */
00059 
00060 class LLCommandHandler
00061 {
00062 public:
00063         LLCommandHandler(const char* command, bool allow_from_external_browser);
00064                 // Automatically registers object to get called when 
00065                 // command is executed.  All commands can be processed
00066                 // in links from LLWebBrowserCtrl, but some (like teleport)
00067                 // should not be allowed from outside the app.
00068                 
00069         virtual ~LLCommandHandler();
00070 
00071         virtual bool handle(const LLSD& params,
00072                                                 const LLSD& queryMap) = 0;
00073                 // Execute the command with a provided (possibly empty)
00074                 // list of parameters.
00075                 // Return true if you did something, false if the parameters
00076                 // are invalid or on error.
00077 };
00078 
00079 
00080 class LLCommandDispatcher
00081 {
00082 public:
00083         static bool dispatch(const std::string& cmd,
00084                                                  bool from_external_browser,
00085                                                  const LLSD& params,
00086                                                  const LLSD& queryMap);
00087                 // Execute a command registered via the above mechanism,
00088                 // passing string parameters.
00089                 // Returns true if command was found and executed correctly.
00090 };
00091 
00092 #endif

Generated on Fri May 16 08:33:16 2008 for SecondLife by  doxygen 1.5.5