/* * Baltisot * Copyright (C) 1999-2008 Nicolas "Pixel" Noble * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __ACTION_H__ #define __ACTION_H__ #include #include #include #include #include //! This is the basic HTTP action. /*! This pure virtual class contains the framework to build a basic HTTP action. */ class Action : public Base { public: //! The provided string should contain the url of that action. /*! If no URL is provided, one will be generated on the fly. */ Action(const String & url = "", HtmlSkinner * = 0); virtual ~Action(); //! Will recursively resolve an URL, and return the corresponding action, or NULL if not found. Action * Look4URL(const String &); //! This pure virtual method has to be filled. It will be launched if the URL is called. /*! This method will be called when the URL gets invoked. The vars variable will contain the POST or GET variables. The headers is a single list of the HTTP headers. And the out handle will be dumped as the output to the brower. */ virtual Task * Do(Variables * vars, Variables * headers, Handle * out) = 0; //! This helper will dump the basic HTML headers. virtual void SendHead(Handle *); //! This helper will dump the basic HTML footers. virtual void SendFoot(Handle *); //! This helper will display a button. /*! The button will have the caption provided, and will redirect to the provided url. */ virtual void ShowButton(Handle *, const String & caption = " Ok ", const String & url = "start"); //! This pure virtual method has to gives the page title. Will be used in SendHead. virtual String GetTitle(void) = 0; //! This returns the recorded URL for that action. String GetURL(void); //! Mark this action to be erased as soon as the Do method ends. void CleanUp(void); //! Skinner accessor. HtmlSkinner * GetSkinner(); protected: //! Mark this action as beeing accessed. void Accessed(void); private: static Action * start; Action * next, * prev; String URL; bool hastoclean, accessed; HtmlSkinner * skin; }; #endif