Update of /cvsroot/sharedaemon/sharedaemon-ui-web/src/server/http/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv7511/src/server/http/servlet Modified Files: HttpServletResponse.h HttpServletResponse.cpp HttpServletRequest.h HttpServletRequest.cpp Added Files: HttpSession.h HttpSession.cpp Log Message: 30/12/2003 Mikael Barbeaux * Implemented first version of HttpSession object. --- NEW FILE: HttpSession.h --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * 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 */ #include <time.h> #include <vector> #include <string> using namespace std; /** * Defines a session object for managing client informations * into servlets. */ class HttpSession { public: /** * Creates a HttpSession object. */ HttpSession(); /** * Destructor for HttpSession. */ ~HttpSession(); /** * Returns the value of a given attribute. * * @param name * @return void* */ void *getAttribute(string name); /** * Returns a vector of all attribute names. * * @return vector<string> */ vector<string> getAttributeNames(); /** * Returns the creation time of this session. * * @return time_t */ time_t getCreationTime(); /** * Returns the identifiant of this session. * * @return string */ string getId(); /** * Returns the last accessed time to this servlet. * * @return time_t */ time_t getLastAccessedTime(); /** * Invalidates this session. */ void invalidate(); /** * Removes the given attribute from the session. * * @param name */ void removeAttribute(string name); /** * Adds a attribute into the session with the given * name and value. * * @param name * @param value */ void setAttribute(string name, void *value); }; --- NEW FILE: HttpSession.cpp --- /* * This file is part of webInterface. * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> * * 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 */ #include "HttpSession.h" /** * Creates a HttpSession object. */ HttpSession::HttpSession() { } /** * Destructor for HttpSession. */ HttpSession::~HttpSession() { } /** * Returns the value of a given attribute. * */ void *HttpSession::getAttribute(string name) { return 0; } /** * Returns a vector of all attribute names. */ vector<string> HttpSession::getAttributeNames() { vector<string> v; return v; } /** * Returns the creation time of this session. */ time_t HttpSession::getCreationTime() { return 0; } /** * Returns the identifiant of this session. */ string HttpSession::getId() { return ""; } /** * Returns the last accessed time to this servlet. */ time_t HttpSession::getLastAccessedTime() { return 0; } /** * Invalidates this session. */ void HttpSession::invalidate() { } /** * Removes the given attribute from the session. */ void HttpSession::removeAttribute(string name) { } /** * Adds a attribute into the session with the given * name and value. */ void HttpSession::setAttribute(string name, void *value) { } Index: HttpServletResponse.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/server/http/servlet/HttpServletResponse.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- HttpServletResponse.h 30 Dec 2003 14:33:28 -0000 1.3 +++ HttpServletResponse.h 30 Dec 2003 17:11:59 -0000 1.4 @@ -23,13 +23,38 @@ #include "../HttpResponse.h" #include "../TextWriter.h" +/** + * Defines a http response for handling servlet. + * A Servlet response is the same as a normal + * http response, except the fact that only + * text informations can be handled and that + * it can manage cookies. + */ class HttpServletResponse : public HttpResponse { -public: - HttpServletResponse(TextWriter *writer); - ~HttpServletResponse(); + public: + + /** + * Creates a HttpServletResponse object + * with the given writer. + * + * @param writer - a text writer + */ + HttpServletResponse(TextWriter *writer); - TextWriter *getWriter(); + /** + * Destructor for HttpServletResponse + */ + ~HttpServletResponse(); + + /** + * Returns the text writer associated to this + * servlet. + * + * @return TextWriter* + */ + TextWriter *getWriter(); + }; #endif Index: HttpServletResponse.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/server/http/servlet/HttpServletResponse.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- HttpServletResponse.cpp 30 Dec 2003 14:33:28 -0000 1.3 +++ HttpServletResponse.cpp 30 Dec 2003 17:11:59 -0000 1.4 @@ -1,12 +1,41 @@ +/* + * This file is part of webInterface. + * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> + * + * 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 + */ + #include "HttpServletResponse.h" +/** + * Creates a HttpServletResponse object with the given + * text writer. + */ HttpServletResponse::HttpServletResponse(TextWriter *writer) : - HttpResponse(writer) -{} + HttpResponse(writer) { +} -HttpServletResponse::~HttpServletResponse() -{} +/** + * Destructor for HttpServletResponse + */ +HttpServletResponse::~HttpServletResponse() { +} +/** + * Returns the text writer associated to this response. + */ TextWriter *HttpServletResponse::getWriter() { return (TextWriter*) writer; } Index: HttpServletRequest.h =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/server/http/servlet/HttpServletRequest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- HttpServletRequest.h 30 Dec 2003 12:08:19 -0000 1.1 +++ HttpServletRequest.h 30 Dec 2003 17:11:59 -0000 1.2 @@ -21,12 +21,52 @@ #define _HTTP_SERVLET_REQUEST_H_ #include "../HttpRequest.h" +#include "HttpSession.h" +/** + * Defines an object for handling request into http servlets. + * It extends a typical http request, mostly by adding + * the http sessions feature. + */ class HttpServletRequest : public HttpRequest { -public: - HttpServletRequest(); - ~HttpServletRequest(); + public: + + /** + * Creates a HttpServletRequest object. + */ + HttpServletRequest(); + + /** + * Destructor for HttpServlet object. + */ + ~HttpServletRequest(); + + /** + * Returns the session associated to this request. + * If create is true, then the session is created + * if not yet done. + * + * @param create + */ + HttpSession *getSession(bool create = true); + + /** + * Returns the session id specified by the + * client. + * + * @return string + */ + string getSessionId(); + + /** + * Tests if the session associated to this request is + * still valid or not. + * + * @return bool + */ + bool isSessionIdValid(); + }; #endif Index: HttpServletRequest.cpp =================================================================== RCS file: /cvsroot/sharedaemon/sharedaemon-ui-web/src/server/http/servlet/HttpServletRequest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- HttpServletRequest.cpp 30 Dec 2003 12:08:19 -0000 1.1 +++ HttpServletRequest.cpp 30 Dec 2003 17:11:59 -0000 1.2 @@ -1,6 +1,58 @@ +/* + * This file is part of webInterface. + * Copyright (C) 2003 Mikael Barbeaux <mik...@us...> + * + * 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 + */ + #include "HttpServletRequest.h" -HttpServletRequest::HttpServletRequest() -{} -HttpServletRequest::~HttpServletRequest() -{} +/** + * Creates a HttpServletRequest object. + */ +HttpServletRequest::HttpServletRequest() { +} + +/** + * Destructor for HttpServlet object. + */ +HttpServletRequest::~HttpServletRequest() { +} + +/** + * Returns the session associated to this request. + * If create is true, then the session is created + * if not yet done. + */ +HttpSession *HttpServletRequest::getSession(bool create) { + return 0; +} + +/** + * Returns the session id specified by the + * client. + */ +string HttpServletRequest::getSessionId() { + return ""; +} + +/** + * Tests if the session associated to this request is + * still valid or not. + */ +bool HttpServletRequest::isSessionIdValid() { + return true; +} + |