summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2011-02-07 11:16:27 +0000
committerdeva <deva>2011-02-07 11:16:27 +0000
commitae91057323802dbfe5797cab6fd923149503b213 (patch)
treea0ef887fda6cd3f6edf6e8c1ed9fbc212a24e158
parent4ea34b413bd21c0e8ec4c3b93840bfe928d3c9c4 (diff)
Made isreadonly propagate to session file and back to live object.
-rw-r--r--server/src/connection.h3
-rw-r--r--server/src/session.cc7
-rw-r--r--server/src/sessionparser.cc1
-rw-r--r--server/src/sessionparser.h3
-rw-r--r--server/src/sessionserialiser.cc2
5 files changed, 10 insertions, 6 deletions
diff --git a/server/src/connection.h b/server/src/connection.h
index 153e865..ec18d00 100644
--- a/server/src/connection.h
+++ b/server/src/connection.h
@@ -35,8 +35,7 @@
class Connection {
public:
virtual bool handle(const char *data, size_t size) = 0;
- virtual std::string getResponse() = 0;
- virtual headers_t getHeaders() = 0;
+ virtual void getReply(Httpd::Reply &reply) = 0;
};
#endif/*__PRACRO_CONNECTION_H__*/
diff --git a/server/src/session.cc b/server/src/session.cc
index 7290c31..530efac 100644
--- a/server/src/session.cc
+++ b/server/src/session.cc
@@ -182,9 +182,9 @@ Session *Sessions::newSession(std::string patientid, std::string templ)
while(i != sessions.end()) {
if(i->second->patientid == patientid &&
i->second->templ == templ) {
- Session *s = i->second;
- if(s->active()) throw SessionAlreadyActive(s->id());
- return s;
+ Session *session = i->second;
+ if(session->active()) throw SessionAlreadyActive(session->id());
+ return session;
}
i++;
@@ -195,6 +195,7 @@ Session *Sessions::newSession(std::string patientid, std::string templ)
Session *session = ser.findFromTupple(patientid, templ);
if(session) {
sessions[session->id()] = session;
+ if(session->active()) throw SessionAlreadyActive(session->id());
return session;
}
}
diff --git a/server/src/sessionparser.cc b/server/src/sessionparser.cc
index 9666c2f..21bc95f 100644
--- a/server/src/sessionparser.cc
+++ b/server/src/sessionparser.cc
@@ -63,6 +63,7 @@ void SessionParser::startTag(std::string name,
patientid = attributes["patientid"];
sessionid = attributes["id"];
templ = attributes["template"];
+ status = attributes["status"];
}
if(name == "journal") {
diff --git a/server/src/sessionparser.h b/server/src/sessionparser.h
index 903dc56..314f4ce 100644
--- a/server/src/sessionparser.h
+++ b/server/src/sessionparser.h
@@ -43,7 +43,8 @@ public:
std::map< std::string, std::string> attributes);
void endTag(std::string name);
void parseError(const char *buf, size_t len, std::string error, int lineno);
-
+
+ std::string status;
std::string templ;
std::string sessionid;
std::string patientid;
diff --git a/server/src/sessionserialiser.cc b/server/src/sessionserialiser.cc
index 0929a30..b20e4c4 100644
--- a/server/src/sessionserialiser.cc
+++ b/server/src/sessionserialiser.cc
@@ -82,6 +82,7 @@ Session *SessionSerialiser::loadStr(const std::string &xml)
XDEC(parser.sessionid),
XDEC(parser.patientid),
XDEC(parser.templ));
+ session->isreadonly = parser.status == "readonly";
Journal *j = session->journal();
j->setUser(XDEC(parser.userid));
j->setPatientID(XDEC(parser.patientid));
@@ -104,6 +105,7 @@ std::string SessionSerialiser::saveStr(Session *session)
xml += "<?xml version='1.0' encoding='UTF-8'?>\n";
xml += "<session timestamp=\""+itostr(time(NULL))+"\" "
+ "status=\"" + XENC(session->isreadonly?"readonly":"") + "\" "
"id=\""+XENC(session->id())+"\" "
"template=\""+XENC(session->templ)+ "\" "
"patientid=\"" + XENC(session->patientid) + "\">\n";