summaryrefslogtreecommitdiff
path: root/server/src/sessionserialiser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/sessionserialiser.cc')
-rw-r--r--server/src/sessionserialiser.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/server/src/sessionserialiser.cc b/server/src/sessionserialiser.cc
index 10d449d..2c35d2a 100644
--- a/server/src/sessionserialiser.cc
+++ b/server/src/sessionserialiser.cc
@@ -30,6 +30,9 @@
#include "journalwriter.h"
#include "sessionparser.h"
+#include "database.h"
+
+#include "xml_encode_decode.h"
#include <stdio.h>
#include <string.h>
@@ -54,19 +57,25 @@ SessionSerialiser::SessionSerialiser(std::string path, Session *session)
this->path = path;
}
+#define XENC(s) xml_encode(s)
+#define XDEC(s) xml_decode(s)
+
void SessionSerialiser::loadStr(const std::string &xml)
{
// SessionAutolock lock(*session);
SessionParser parser;
parser.parse(xml.data(), xml.length());
+
JournalWriter *j = session->journal();
- j->currentuser = parser.userid;
- j->currentcpr = parser.patientid;
+ j->currentuser = XDEC(parser.userid);
+ j->currentcpr = XDEC(parser.patientid);
std::vector<SessionParser::Entry>::iterator i = parser.entries.begin();
while(i != parser.entries.end()) {
- j->addEntry(i->resume, i->macro, i->index);
+ j->addEntry(XDEC(i->resume), xml_decode(i->macro), i->index);
i++;
}
+
+ session->database()->restore(XDEC(parser.database));
}
std::string SessionSerialiser::saveStr()
@@ -81,8 +90,8 @@ std::string SessionSerialiser::saveStr()
JournalWriter *journal = session->journal();
- xml += " <journal patientid=\"" + journal->currentcpr +
- "\" userid=\"" + journal->currentuser + "\">\n";
+ xml += " <journal patientid=\"" + XENC(journal->currentcpr) +
+ "\" userid=\"" + XENC(journal->currentuser) + "\">\n";
std::map< int, JournalWriter::ResumeEntry >::iterator i =
journal->entrylist.begin();
@@ -90,13 +99,19 @@ std::string SessionSerialiser::saveStr()
xml += " <entry index=\""+itostr(i->first) + "\""
" macro=\"" + i->second.macro + "\">\n";
- xml += " <resume>" + i->second.resume + "</resume>\n";
+ xml += " <resume>" + XENC(i->second.resume) + "</resume>\n";
xml += " </entry>\n";
i++;
}
xml += " </journal>\n";
+
+ std::string dbtype = "pgsql";
+ xml += " <database type=\""+dbtype+"\">"+
+ XENC(session->database()->serialise())+
+ "</database>\n";
+
xml += "</session>\n";
return xml;