Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

abstract_application.cc

00001 /*
00002 *  Name:      application.cc
00003 *  Authors:   Angel Jimenez Jimenez
00004 *             Rafael Jesus Alcantara Perez
00005 *  Summary:   CGI base application
00006 *  Date:      $Date: 2003/10/06 12:45:11 $
00007 *  Revision:  $Revision: 1.1 $
00008 *
00009 *  Copyright (C) 1994-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00010 *
00011 *  This program is free software; you can redistribute it and/or modify
00012 *  it under the terms of the GNU General Public License as published by
00013 *  the Free Software Foundation; either version 2 of the License, or
00014 *  (at your option) any later version.
00015 *
00016 *  This program is distributed in the hope that it will be useful,
00017 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 *  GNU General Public License for more details.
00020 *
00021 *  You should have received a copy of the GNU General Public License
00022 *  along with this program; if not, write to the Free Software
00023 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024 *  MA 02111-1307, USA.
00025 */
00026 
00027 #include <mpcl/net/cgi/abstract_application.hh>
00028 #include <mpcl/net/cgi/exceptions.hh>
00029 
00030 
00031 //
00032 //  C O N S T R U C T O R S
00033 //
00034 
00035 void mpcl::net::cgi::TAbstractApplication::
00036 buildSourcePage (void)
00037 {
00038 
00039   using text::html::TBasePage;
00040   using text::html::kcIdentifierSeparator;
00041 
00042   TString   yPathInfo (tConfigProcessor.environmentValue ("PATH_INFO"));
00043 
00044   qtSourcePage = (TBasePage*) NULL;
00045   ptSourceForm = NULL;
00046   if ( !yPathInfo.empty() )
00047   {
00048     TString              yPageName;
00049     TString              yFormName;
00050     TString::size_type   zOffset;
00051     TString::size_type   zBegin = 0;
00052 
00053     //
00054     //  Else gets the calling page/form.
00055     //
00056     if ( yPathInfo [0] == kcIdentifierSeparator )
00057     {
00058       //
00059       //  Remove leading separator.
00060       //
00061       ++zBegin;
00062     }
00063     zOffset      = yPathInfo.find (kcIdentifierSeparator, zBegin);
00064     yPageName    = yPathInfo.substr (zBegin, (zOffset - zBegin));
00065     yFormName    = yPathInfo.substr (zOffset + 1);
00066     qtSourcePage = buildPage (yPageName);
00067     if ( !qtSourcePage.isNull() )
00068     {
00069       ptSourceForm = qtSourcePage->tag (yFormName).dynamicCast<TForm*>();
00070       if ( tConfigProcessor.hasInput() && ptSourceForm )
00071       {
00072         tConfigProcessor.updateForm (*ptSourceForm);
00073       }
00074     }
00075   }
00076 
00077 }  // buildSourcePage()
00078 
00079 
00080 //
00081 //  S E L E C T O R S
00082 //
00083 
00084 void mpcl::net::cgi::TAbstractApplication::
00085 writeResponse (void) const
00086 {
00087 
00088   if ( gIsRedirected )
00089   {
00090     *ptTargetOstream << "Location: " << yTargetUrl << "\n";
00091     if ( !tSession.isEmpty() )
00092     {
00093       *ptTargetOstream << tSession;
00094     }
00095     *ptTargetOstream << std::endl;
00096   }
00097   else
00098   {
00099     qtTargetPage->update();
00100     *ptTargetOstream << "Content-type: text/html\n";
00101     if ( !tSession.isEmpty() )
00102     {
00103       *ptTargetOstream << tSession;
00104     }
00105     *ptTargetOstream << std::endl;
00106     *ptTargetOstream << *qtTargetPage;
00107   }
00108 
00109 }  // writeResponse()

Generated on Mon Oct 13 02:35:22 2003 for MPCL by doxygen1.2.18