Skip to content

Commit

Permalink
fix include structure
Browse files Browse the repository at this point in the history
add session providers
  • Loading branch information
s2x committed Jan 27, 2015
1 parent e54267e commit dca3944
Show file tree
Hide file tree
Showing 64 changed files with 857 additions and 386 deletions.
38 changes: 22 additions & 16 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,36 @@ vendor/yaml-cpp/setting.h\
vendor/ctemplate/htmlparser/statemachine.h\
vendor/md5/md5.cc \
vendor/md5/md5.h \
ccframework/ccApp.cc \
ccframework/ccCommon.cc \
ccframework/ccController.cc \
ccframework/ccCookie.cc \
ccframework/parsers/ccQueryParser.cc \
ccframework/parsers/ccMultipartParser.cc \
ccframework/ccRequest.cc \
ccframework/ccSession.cc \
ccframework/ccException.cc \
ccframework/config/ccConfig.cc \
ccframework/config/ccConfigLoader.cc \
ccframework/events/ccEvent.cc \
ccframework/events/ccEventDispatcher.cc \
ccframework/response/ccResponse.cc \
ccframework/response/ccTemplateResponse.cc \
ccframework/router/ccRoute.cc \
ccframework/router/ccRouter.cc \
ccframework/acl/ccRole.cc \
ccframework/acl/ccAcl.cc \
ccframework/acl/ccResource.cc \
ccframework/acl/ccAcl.cc \
ccframework/events/ccEvent.cc \
ccframework/events/ccEventDispatcher.cc \
ccframework/ccException.cc \
ccframework/ccCookie.cc \
ccframework/helpers/ccBaseHelper.cc \
ccframework/helpers/ccComponentHelper.cc \
ccframework/session/ccSession.cc \
ccframework/session/ccSessionProvider.cc \
ccframework/session/ccMemorySessionProvider.cc \
ccframework/session/ccYamlSessionProvider.cc \
ccframework/parsers/ccQueryParser.cc \
ccframework/parsers/ccMultipartParser.cc \
ccframework/router/ccRoute.cc \
ccframework/router/ccPregRoute.cc \
ccframework/router/ccStaticRoute.cc \
ccframework/router/ccRouter.cc \
ccframework/ccController.cc \
ccframework/ccRequest.cc \
ccframework/response/ccResponse.cc \
ccframework/response/ccTemplateResponse.cc \
ccframework/form/ccBaseForm.cc \
ccframework/form/element/ccBaseFormElement.cc
ccframework/form/element/ccBaseFormElement.cc \
ccframework/ccApp.cc


libccframework_la_CXXFLAGS = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Iinclude -Ivendor/ctemplate -Iinclude/ccframework -std=c++0x
libccframework_la_LDFLAGS =
Expand Down
4 changes: 3 additions & 1 deletion src/ccframework/acl/ccAcl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Author: piotr
*/

#include "../../include/ccframework/ccFramework.h"
#include "ccAcl.h"
#include "ccRole.h"
#include "ccResource.h"

namespace ccFramework {

Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/acl/ccResource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "../../include/ccframework/ccFramework.h"
#include "ccResource.h"

namespace ccFramework {

Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/acl/ccRole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "../../include/ccframework/ccFramework.h"
#include "ccRole.h"

namespace ccFramework {

Expand Down
20 changes: 17 additions & 3 deletions src/ccframework/ccApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccApp.h"
#include "fcgio.h"
#include "fcgi_config.h" // HAVE_IOSTREAM_WITHASSIGN_STREAMBUF
#include "ccRouter.h"
#include "ctemplate/template.h"
#include "ccConfigLoader.h"
#include "ccController.h"
#include "ccAcl.h"
#include "ccComponentHelper.h"
#include "ccSession.h"
#include "ccRequest.h"
#include "ccException.h"
#include "ccRoute.h"
#include "ccCookie.h"
#include "ccResponse.h"

namespace ccFramework {

ccApp *ccApp::instance = NULL;
Expand Down Expand Up @@ -39,7 +52,7 @@ ccApp::ccApp(std::string config_file) {
this->acl->setAllowAll(true);

ctemplate::addTemplateHelper("COMPONENT",new ccComponentHelper());

this->session_provider = new ccSessionProvider("");
}
ccApp::~ccApp() {
#if HAVE_IOSTREAM_WITHASSIGN_STREAMBUF
Expand All @@ -63,6 +76,7 @@ ccApp::~ccApp() {

ccResponse *ccApp::processRequest(FCGX_Request fcgi_request) {


ccResponse *ret = NULL;

//reload cache if template changes
Expand All @@ -78,7 +92,7 @@ ccResponse *ccApp::processRequest(FCGX_Request fcgi_request) {
this->request = new ccRequest(fcgi_request);

// autostart session
this->getRequest()->setSession(new ccSession(request));
this->getRequest()->setSession(new ccSession(request, this->getSessionProvider()));
if (this->getConfigValue("session.autostart", "0") == "1") {
//autosave
this->getRequest()->getSession()->setSave(true);
Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/ccCommon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccCommon.h"
#include <fstream>
#include "../vendor/md5/md5.h"

Expand Down
11 changes: 9 additions & 2 deletions src/ccframework/ccController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"

#include "ccController.h"
#include "ccApp.h"
#include "ccResponse.h"
#include "ccController.h"
#include "ccRequest.h"
#include "ccRouter.h"
#include "ccTemplateResponse.h"
#include "ccRoute.h"
#include "ccException.h"
namespace ccFramework {

ccController::ccController(ccApp *app) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/ccCookie.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccCookie.h"

namespace ccFramework {

Expand Down
8 changes: 7 additions & 1 deletion src/ccframework/ccRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccRequest.h"
#include <sstream>
#include "ccSession.h"
#include "ccQueryParser.h"
#include "ccMultipartParser.h"
#include "ccCommon.h"
#include <stdio.h>
#include <string.h>
namespace ccFramework {

ccRequest::ccRequest(FCGX_Request request) {
Expand Down
60 changes: 0 additions & 60 deletions src/ccframework/ccSession.cc

This file was deleted.

3 changes: 2 additions & 1 deletion src/ccframework/config/ccConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccConfig.h"
#include "ccConfigLoader.h"

namespace ccFramework {

Expand Down
4 changes: 2 additions & 2 deletions src/ccframework/config/ccConfigLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"

#include "ccConfigLoader.h"
#include "ccCommon.h"
namespace ccFramework {

ccConfigLoader::ccConfigLoader(std::string filename) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/events/ccEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccEvent.h"

namespace ccFramework {

Expand Down
4 changes: 2 additions & 2 deletions src/ccframework/events/ccEventDispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"

#include "ccEventDispatcher.h"
#include "ccEvent.h"
namespace ccFramework {

ccEventDispatcher *ccEventDispatcher::instance = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/ccframework/form/ccBaseForm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

#include "ccBaseForm.h"
#include "ccBaseFormElement.h"
#include "ccFormElementFormStart.h"
namespace ccFramework {

ccBaseForm::ccBaseForm(std::string name) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/form/element/ccBaseFormElement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccBaseFormElement.h"

namespace ccFramework {

Expand Down
4 changes: 3 additions & 1 deletion src/ccframework/helpers/ccBaseHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccBaseHelper.h"
#include "ccRequest.h"
#include "ccApp.h"
namespace ccFramework {

ccRequest* ccBaseHelper::getRequest() {
Expand Down
2 changes: 1 addition & 1 deletion src/ccframework/helpers/ccComponentHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include "ccComponentHelper.h"

#include "ccResponse.h"
namespace ccFramework {

std::map<std::string, ccResponse* (*)(std::map<std::string, std::string> params)> ccComponentHelper::components;
Expand Down
4 changes: 2 additions & 2 deletions src/ccframework/parsers/ccMultipartParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"

#include "ccMultipartParser.h"
#include "ccCommon.h"
namespace ccFramework {

ccMultipartParser::ccMultipartParser(std::string query, std::string sep) {
Expand Down
3 changes: 2 additions & 1 deletion src/ccframework/parsers/ccQueryParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"
#include "ccQueryParser.h"
#include "ccCommon.h"

namespace ccFramework {

Expand Down
35 changes: 33 additions & 2 deletions src/ccframework/response/ccResponse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* Author: piotr
*/

#include "ccframework/ccFramework.h"

#include "ccResponse.h"
#include "ccCookie.h"
#include <sstream>
namespace ccFramework {

ccResponse::ccResponse() {
Expand All @@ -30,5 +31,35 @@ ccResponse::~ccResponse() {

}

void ccResponse::addCookie(ccCookie *cookie) {
std::map<std::string, ccCookie*>::iterator it;
it = this->cookies.find(cookie->getName());
if ( it != this->cookies.end()) {
this->cookies.erase(it);
delete it->second;
}

this->cookies[cookie->getName()]= cookie;
}

std::string ccResponse:: getHeaders() {
std::string ret;
std::ostringstream ss;
ss<< this->content.length();
this->setHeader("Content-length",ss.str());

for (std::map<std::string, std::string>::const_iterator it =
this->headers.begin(); it != this->headers.end(); ++it) {
ret = ret + it->first + ":" + it->second + "\r\n";
}

for (std::map<std::string, ccCookie*>::const_iterator it =
this->cookies.begin(); it != this->cookies.end(); ++it) {
ret = ret + "Set-Cookie: " + it->second->serialize() + "\r\n";
}

return ret;
}

} /* namespace ccFramework */

Loading

0 comments on commit dca3944

Please sign in to comment.