diff options
| -rw-r--r-- | project2/cgi/cgiAppEngine.cpp | 31 | ||||
| -rw-r--r-- | project2/cgi/cgiAppEngine.h | 14 | ||||
| -rw-r--r-- | project2/cgi/cgiStageFail.cpp | 2 | ||||
| -rw-r--r-- | project2/cgi/cgiStageRedirect.cpp | 2 | ||||
| -rw-r--r-- | project2/common/appEngine.cpp | 2 | ||||
| -rw-r--r-- | project2/common/appEngine.h | 8 | ||||
| -rw-r--r-- | project2/common/if.cpp | 2 | ||||
| -rw-r--r-- | project2/common/if.h | 2 | ||||
| -rw-r--r-- | project2/common/presenter.h | 1 | ||||
| -rw-r--r-- | project2/common/rowView.cpp | 2 | ||||
| -rw-r--r-- | project2/common/rowView.h | 4 | ||||
| -rw-r--r-- | project2/common/view.h | 4 | ||||
| -rw-r--r-- | project2/common/viewHost.h | 2 | ||||
| -rw-r--r-- | project2/console/consoleAppEngine.cpp | 4 | ||||
| -rw-r--r-- | project2/console/consoleAppEngine.h | 4 | ||||
| -rw-r--r-- | project2/xml/rawView.cpp | 12 | ||||
| -rw-r--r-- | project2/xml/rawView.h | 2 | ||||
| -rw-r--r-- | project2/xml/xmlDocumentPrefetch.cpp | 2 | ||||
| -rw-r--r-- | project2/xml/xmlDocumentPrefetch.h | 2 | 
19 files changed, 61 insertions, 41 deletions
| diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index 45ccd95..f647b0e 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -117,20 +117,30 @@ CgiApplicationEngine::Stage::~Stage()  }  void -CgiApplicationEngine::addEnvData(const Presenter * p) const +CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p) const  { -	// These were for debug... but why not pass them on? -	p->addNamedValue("servername", env()->xmlPrefix, env()->getServerName()); -	p->addNamedValue("scriptname", env()->xmlPrefix, env()->getScriptName()); - +	// Environment set up by web server +	p->addNewRowSet("environment", env()->xmlPrefix); +	// Server stuff +	addEnvToPresenter(p, "servername", &cgicc::CgiEnvironment::getServerName); +	addEnvToPresenter(p, "serversoftware", &cgicc::CgiEnvironment::getServerSoftware); +	addEnvToPresenter(p, "serverprotocol", &cgicc::CgiEnvironment::getServerProtocol); +	addEnvToPresenter(p, "serverport", &cgicc::CgiEnvironment::getServerPort); +	addEnvToPresenter(p, "serverhttps", &cgicc::CgiEnvironment::usingHTTPS); +	// Request stuff +	addEnvToPresenter(p, "referrer", &cgicc::CgiEnvironment::getReferrer); +	addEnvToPresenter(p, "querystring", &cgicc::CgiEnvironment::getQueryString); +	p->finishRowSet(); +	  	// URL elements  	p->addNewRowSet("uriElems", env()->xmlPrefix); +	p->addAttribute("full", _env->getRedirectURL());  	BOOST_FOREACH(std::string s, _env->elems) {  		p->addNewRow("uriElem");  		p->addAttribute("text", s);  		p->finishRow();  	} -	p->finishRow(); +	p->finishRowSet();  	// Parameters  	p->addNewRowSet("params", env()->xmlPrefix); @@ -143,24 +153,23 @@ CgiApplicationEngine::addEnvData(const Presenter * p) const  	p->finishRowSet();  } -static  void -addToPresenter(const Presenter * p, const Glib::ustring & name, const VariableType & value) +CgiApplicationEngine::addVarToPresenter(const MultiRowSetPresenter * p, const Glib::ustring & name, const VariableType & value) const  {  	p->addNewRow("var"); -	p->addAttribute("value", value);  	p->addAttribute("name", name); +	p->addAttribute("value", value);  	p->finishRow();  }  void -CgiApplicationEngine::addAppData(const Presenter * p) const +CgiApplicationEngine::addAppData(const MultiRowSetPresenter * p) const  {  	addCoreAppData(p);  	// Sessions variables  	p->addNewRowSet("session", env()->xmlPrefix);  	p->addAttribute("id", cursession->ID.str()); -	cursession->ForeachValue(boost::bind(addToPresenter, p, _1, _2)); +	cursession->ForeachValue(boost::bind(&CgiApplicationEngine::addVarToPresenter, this, p, _1, _2));  	p->finishRowSet();  	// Timing info diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h index 6e202e4..88419fb 100644 --- a/project2/cgi/cgiAppEngine.h +++ b/project2/cgi/cgiAppEngine.h @@ -18,6 +18,7 @@ class CgiEnvironment;  class Session;  namespace cgicc {  	class HTTPHeader; +	class CgiEnvironment;  }  namespace xmlpp {  	class Document; @@ -35,8 +36,8 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink  		const Environment * env() const;  		SessionPtr session() const;  		virtual Glib::ustring resolveCurrentConfig() const; -		void addAppData(const Presenter * p) const; -		void addEnvData(const Presenter * p) const; +		void addAppData(const MultiRowSetPresenter * p) const; +		void addEnvData(const MultiRowSetPresenter * p) const;  		const CgiEnvironment * _env;  	private: @@ -48,13 +49,20 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink  		bool checkDomain(const DomainPlatforms::value_type & i) const;  		void loadEngineSection(const xmlpp::Element *) const;  		SessionContainerPtr sessionsContainer; +		// Helpers +		void addVarToPresenter(const MultiRowSetPresenter * p, const Glib::ustring & name, const VariableType &) const; +		typedef std::string (cgicc::CgiEnvironment::*StrEnvGetter)() const; +		template <class X> +		void addEnvToPresenter(const MultiRowSetPresenter * p, const char * name, X (cgicc::CgiEnvironment::*getter)() const) const { +			addVarToPresenter(p, name, (_env->*getter)()); +		}  	public:  		class Stage;  		class ResponseStage;  		typedef boost::intrusive_ptr<Stage> StagePtr;  		typedef boost::intrusive_ptr<ResponseStage> ResponseStagePtr; -		typedef boost::tuple<StagePtr, ResponseStagePtr, TransformSourcePtr, PresenterPtr> NextStage; +		typedef boost::tuple<StagePtr, ResponseStagePtr, TransformSourcePtr, MultiRowSetPresenterPtr> NextStage;  		/// Base class for a stage iteration that should eventually produce a response for the client  		class Stage : public virtual IntrusivePtrBase {  			public: diff --git a/project2/cgi/cgiStageFail.cpp b/project2/cgi/cgiStageFail.cpp index 6a60700..97ac22a 100644 --- a/project2/cgi/cgiStageFail.cpp +++ b/project2/cgi/cgiStageFail.cpp @@ -36,7 +36,7 @@ namespace CgiApplicationExtras {  				code(e, "code", false, 500),  				message(e, "message", false, "Application error") {  			} -			void execute(const Presenter *) const { +			void execute(const MultiRowSetPresenter *) const {  				throw CgiApplicationEngine::ResponseStagePtr(  						new FailStage(dynamic_cast<const CgiEnvironment *>(Environment::getCurrent()), code(), message()));  			} diff --git a/project2/cgi/cgiStageRedirect.cpp b/project2/cgi/cgiStageRedirect.cpp index c2e498f..f72e986 100644 --- a/project2/cgi/cgiStageRedirect.cpp +++ b/project2/cgi/cgiStageRedirect.cpp @@ -34,7 +34,7 @@ namespace CgiApplicationExtras {  				View(e),  				url(e, "url", true) {  			} -			void execute(const Presenter *) const { +			void execute(const MultiRowSetPresenter *) const {  				throw CgiApplicationEngine::ResponseStagePtr(  						new RedirectStage(dynamic_cast<const CgiEnvironment *>(Environment::getCurrent()), url()));  			} diff --git a/project2/common/appEngine.cpp b/project2/common/appEngine.cpp index 59fa1ee..245f4e5 100644 --- a/project2/common/appEngine.cpp +++ b/project2/common/appEngine.cpp @@ -31,7 +31,7 @@ ApplicationEngine::logMessage(bool writeLog, const Glib::ustring & g, const Glib  }  void -ApplicationEngine::addCoreAppData(const Presenter * p) const +ApplicationEngine::addCoreAppData(const MultiRowSetPresenter * p) const  {  	// Message log  	p->addNewRowSet("messages", env()->xmlPrefix); diff --git a/project2/common/appEngine.h b/project2/common/appEngine.h index 39214d3..19df823 100644 --- a/project2/common/appEngine.h +++ b/project2/common/appEngine.h @@ -5,7 +5,7 @@  #include "session.h"  #include "config.h" -class Presenter; +class MultiRowSetPresenter;  class ApplicationEngine : public Configuration {  	public: @@ -27,13 +27,13 @@ class ApplicationEngine : public Configuration {  		virtual void process() const = 0;  		virtual const Environment * env() const = 0;  		virtual SessionPtr session() const = 0; -		virtual void addAppData(const Presenter * p) const = 0; -		virtual void addEnvData(const Presenter * p) const = 0; +		virtual void addAppData(const MultiRowSetPresenter * p) const = 0; +		virtual void addEnvData(const MultiRowSetPresenter * p) const = 0;  		static ApplicationEngine * getCurrent() { return currentEngine; }  	protected: -		void addCoreAppData(const Presenter * p) const; +		void addCoreAppData(const MultiRowSetPresenter * p) const;  		Messages appMessages; diff --git a/project2/common/if.cpp b/project2/common/if.cpp index eac55c5..f3c7102 100644 --- a/project2/common/if.cpp +++ b/project2/common/if.cpp @@ -54,7 +54,7 @@ If::If(const xmlpp::Element * e) :  }  void -If::execute(const Presenter * presenter) const +If::execute(const MultiRowSetPresenter * presenter) const  {  	if (passes()) {  		Logger()->messagef(LOG_DEBUG, "IfSet passed, showing %zu views", subViews.size()); diff --git a/project2/common/if.h b/project2/common/if.h index 7a13fea..28299ba 100644 --- a/project2/common/if.h +++ b/project2/common/if.h @@ -23,7 +23,7 @@ class If : public IHaveSubTasks, public View, public IfSet {  	public:  		If(const xmlpp::Element *); -		virtual void execute(const Presenter*) const; +		virtual void execute(const MultiRowSetPresenter*) const;  		virtual void execute() const;  	private: diff --git a/project2/common/presenter.h b/project2/common/presenter.h index 8ba7e6b..58af8dc 100644 --- a/project2/common/presenter.h +++ b/project2/common/presenter.h @@ -71,6 +71,7 @@ class ContentPresenter : public Presenter {  typedef boost::intrusive_ptr<const Presenter> PresenterCPtr;  typedef boost::intrusive_ptr<Presenter> PresenterPtr;  typedef boost::intrusive_ptr<RowSetPresenter> RowSetPresenterPtr; +typedef boost::intrusive_ptr<MultiRowSetPresenter> MultiRowSetPresenterPtr;  typedef boost::intrusive_ptr<NameValuePairPresenter> NameValuePairPresenterPtr;  /// Base class to implement presenter modules diff --git a/project2/common/rowView.cpp b/project2/common/rowView.cpp index 000222d..a35619d 100644 --- a/project2/common/rowView.cpp +++ b/project2/common/rowView.cpp @@ -54,7 +54,7 @@ RowView::rowReady(const RowState * rs) const  }  void -RowView::execute(const Presenter * p) const +RowView::execute(const MultiRowSetPresenter * p) const  {  	presenter = p;  	presenter->addNewRowSet(rootName()); diff --git a/project2/common/rowView.h b/project2/common/rowView.h index 2bab953..558284c 100644 --- a/project2/common/rowView.h +++ b/project2/common/rowView.h @@ -13,7 +13,7 @@ class RowView : public View, public RowProcessor {  		virtual ~RowView();  		void loadComplete(const CommonObjects *); -		void execute(const Presenter *) const; +		void execute(const MultiRowSetPresenter *) const;  		void rowReady(const RowState *) const;  		const Variable rootName; @@ -26,7 +26,7 @@ class RowView : public View, public RowProcessor {  		void executeChildren() const;  		typedef ANONSTORAGEOF(View) SubViews;  		SubViews subViews; -		mutable const Presenter * presenter; +		mutable const MultiRowSetPresenter * presenter;  };  #endif diff --git a/project2/common/view.h b/project2/common/view.h index 80d7b30..5a4b751 100644 --- a/project2/common/view.h +++ b/project2/common/view.h @@ -4,7 +4,7 @@  #include "sourceObject.h"  #include "xmlStorage.h" -class Presenter; +class MultiRowSetPresenter;  /// Base class for Project2 components that output data  class View : public virtual SourceObject { @@ -12,7 +12,7 @@ class View : public virtual SourceObject {  		View(const xmlpp::Element *);  		virtual ~View(); -		virtual void execute(const Presenter *) const = 0; +		virtual void execute(const MultiRowSetPresenter *) const = 0;  };  #endif diff --git a/project2/common/viewHost.h b/project2/common/viewHost.h index 920bef0..788b633 100644 --- a/project2/common/viewHost.h +++ b/project2/common/viewHost.h @@ -18,7 +18,7 @@ class ViewHost : virtual public XmlScriptParser, virtual public CheckHost {  		void executeViews(const DefaultPresenterProvider &) const;  		void doTransforms() const; -		mutable PresenterPtr presenter; +		mutable MultiRowSetPresenterPtr presenter;  	private:  		typedef ANONORDEREDSTORAGEOF(View) Views; diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp index a34e078..83ab311 100644 --- a/project2/console/consoleAppEngine.cpp +++ b/project2/console/consoleAppEngine.cpp @@ -68,12 +68,12 @@ ConsoleApplicationEngine::session() const  }  void -ConsoleApplicationEngine::addEnvData(const Presenter *) const +ConsoleApplicationEngine::addEnvData(const MultiRowSetPresenter *) const  {  }  void -ConsoleApplicationEngine::addAppData(const Presenter *) const +ConsoleApplicationEngine::addAppData(const MultiRowSetPresenter *) const  {  } diff --git a/project2/console/consoleAppEngine.h b/project2/console/consoleAppEngine.h index f547a99..681f4a9 100644 --- a/project2/console/consoleAppEngine.h +++ b/project2/console/consoleAppEngine.h @@ -23,8 +23,8 @@ class ConsoleApplicationEngine : public ApplicationEngine, TaskHost, ViewHost {  		const Environment * env() const;  		SessionPtr session() const;  		virtual Glib::ustring resolveCurrentConfig() const; -		virtual void addAppData(const Presenter * p) const; -		virtual void addEnvData(const Presenter * p) const; +		virtual void addAppData(const MultiRowSetPresenter * p) const; +		virtual void addEnvData(const MultiRowSetPresenter * p) const;  	protected:  		const ConsoleEnvironment * _env; diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp index 2070a2f..151d594 100644 --- a/project2/xml/rawView.cpp +++ b/project2/xml/rawView.cpp @@ -19,12 +19,14 @@ RawView::RawView(const xmlpp::Element * p) :  }  void -RawView::execute(const Presenter * p) const +RawView::execute(const MultiRowSetPresenter * mp) const  { -	BOOST_FOREACH(xmlpp::Node * node, copyRoot->get_children()) { -		const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(node); -		if (e) { -			copyNode(p, e); +	if (const Presenter * p = dynamic_cast<const Presenter *>(mp)) { +		BOOST_FOREACH(xmlpp::Node * node, copyRoot->get_children()) { +			const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(node); +			if (e) { +				copyNode(p, e); +			}  		}  	}  } diff --git a/project2/xml/rawView.h b/project2/xml/rawView.h index 87fcd5e..54f7b2e 100644 --- a/project2/xml/rawView.h +++ b/project2/xml/rawView.h @@ -10,7 +10,7 @@  class RawView : public View {  	public:  		RawView(const xmlpp::Element * p); -		void execute(const Presenter *) const; +		void execute(const MultiRowSetPresenter *) const;  	private:  		void copyNode(const Presenter *, const xmlpp::Element *) const; diff --git a/project2/xml/xmlDocumentPrefetch.cpp b/project2/xml/xmlDocumentPrefetch.cpp index 9ac912e..e5565e6 100644 --- a/project2/xml/xmlDocumentPrefetch.cpp +++ b/project2/xml/xmlDocumentPrefetch.cpp @@ -20,7 +20,7 @@ XmlDocumentPrefetch::~XmlDocumentPrefetch()  }  void -XmlDocumentPrefetch::execute(const Presenter*) const +XmlDocumentPrefetch::execute(const MultiRowSetPresenter*) const  {  	execute();  } diff --git a/project2/xml/xmlDocumentPrefetch.h b/project2/xml/xmlDocumentPrefetch.h index d8df77b..f75fabe 100644 --- a/project2/xml/xmlDocumentPrefetch.h +++ b/project2/xml/xmlDocumentPrefetch.h @@ -13,7 +13,7 @@ class XmlDocumentPrefetch : public View, public Task, XmlDocumentCache, Variable  		XmlDocumentPrefetch(const xmlpp::Element * p);  		~XmlDocumentPrefetch(); -		void execute(const Presenter*) const; +		void execute(const MultiRowSetPresenter*) const;  		void execute() const;  		const Variable html; | 
