00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <iostream>
00010 #include <iomanip>
00011 #include <set>
00012 #include "cgiClass.h"
00013 #include "../sessions/connectstring"
00014 #include "read_write_base.hpp"
00015 #include "cgiCookie.h"
00016 #include "Session.hpp"
00017 #include "xml_forms.hpp"
00018
00019 using namespace std;
00020
00021 typedef class set< string > expandoSet;
00022 class expanded
00023 {
00024 expandoSet expandos;
00025 public:
00026 expanded( ocString toParse )
00027 {
00028 string val=toParse.parse(",");
00029 while( val.length() )
00030 {
00031 expandos.insert(val);
00032 val = toParse.parse(",");
00033 }
00034 }
00035 ~expanded(){;}
00036 expanded & add( string toAdd )
00037 {
00038 expandos.insert(toAdd);
00039 return *this;
00040 }
00041 expanded & remove( string toRemove )
00042 {
00043 expandos.erase(toRemove);
00044 return *this;
00045 }
00046 string toString(void)
00047 {
00048 string ret;
00049 expandoSet::iterator it = expandos.begin();
00050 while(it!=expandos.end())
00051 {
00052 ret += *it;
00053 ++it;
00054 if( it!=expandos.end())
00055 ret += ",";
00056 }
00057 return ret;
00058 }
00059 expandoSet Expanded ( void )
00060 {
00061 return expandos;
00062 }
00063
00064 };
00065 class Session_form: public Session_Obj, public xml_form
00066 {
00067 public:
00068 Session_form(cgiScript & script)
00069 :Session_Obj()
00070 ,xml_form(script)
00071 {setKey(*this);}
00072
00073 virtual ~Session_form()
00074 {;}
00075
00076 void form_id_transfer( void )
00077 {
00078 llongFXfer( "Id", Id );
00079 }
00080
00081 void form_data_transfer( void )
00082 {
00083
00084 queryStringMap & args = script.ClientArguments().TheMap();
00085
00086 queryStringMap::iterator it;
00087
00088
00089 it = args.find("TreeUid");
00090 if( it != args.end() )
00091 {
00092 string treeId = it->second.c_str();
00093
00094 expanded exState(GetData(treeId));
00095
00096
00097 it = args.find("expand");
00098 if( it != args.end() )
00099 {
00100 exState.add(it->second.c_str());
00101 SetData( treeId, exState.toString() );
00102 }
00103
00104
00105 it = args.find("contract");
00106 if( it != args.end() )
00107 {
00108 exState.remove(it->second.c_str());
00109 SetData( treeId, exState.toString() );
00110 }
00111
00112
00113 it = args.find("flip");
00114 if( it != args.end() )
00115 {
00116 treeId += "_flip";
00117
00118 string flip_id = GetData(treeId);
00119 if( it->second == flip_id.c_str() )
00120 {
00121 flip_id = "";
00122 }
00123 SetData( treeId, flip_id );
00124 }
00125 }
00126 }
00127
00128 bool dbf_action( string mode, changeMap & changes )
00129 {
00130 return Synch();
00131 }
00132
00133
00134 bool form_display( void )
00135 {
00136 bool breturn = true;
00137 script << "<Session id=\"" << Id << "\">" << endl;
00138 script << "<Id>" << Id << "</Id>" << endl;
00139 script << "<User_Id>" << User_Id << "</User_Id>" << endl;
00140 script << "<UUID>" << UUID << "</UUID>" << endl;
00141 script << "<Instance_Stamp>" << Instance_Stamp << "</Instance_Stamp>" << endl;
00142 script << "<XML_Variables>" << XML_Variables << "</XML_Variables>" << endl;
00143 script << "</Session>" << endl;
00144 return breturn;
00145 }
00146 };
00147
00148 int main( int argc, char ** argv )
00149 {
00150 cgiScript script("text/xml",true);
00151 script << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << endl;
00152 script << "<W3SysService>" << endl;
00153
00154 Session_form myFrm(script);
00155 bool is_good = myFrm.form_action();
00156 if(is_good)
00157 {
00158 myFrm.form_display();
00159 }
00160 script << "<status>";
00161 if(is_good) script << "GOOD";
00162 else script << myFrm.last_result();
00163 script << "</status>" << endl;
00164
00165 script << "</W3SysService>" << endl;
00166 return 0;
00167 }
00168
00169 #include "read_write_base.cpp"
00170 #include "xml_forms.cpp"
00171