summaryrefslogtreecommitdiff
path: root/client/netcom.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/netcom.cc')
-rw-r--r--client/netcom.cc82
1 files changed, 57 insertions, 25 deletions
diff --git a/client/netcom.cc b/client/netcom.cc
index 7873c2b..9c755b5 100644
--- a/client/netcom.cc
+++ b/client/netcom.cc
@@ -87,85 +87,116 @@ void NetCom::replyFinished(QNetworkReply *reply)
}
}
-void NetCom::makeTransfer(QDomDocument &doc, session_state_t state)
+void NetCom::makeTransfer(QByteArray body, session_state_t state, QString uri)
{
- DEBUG(netcom, "Making transfer:\n%s", doc.toString().toStdString().c_str());
+ // Use '/course/template/' uri if empty.
+ if(uri == "") {
+ uri = "/";
+ if(course != "") {
+ uri += course + "/";
+ if(templ != "") {
+ uri += templ + "/";
+ }
+ }
+ }
+
+ DEBUG(netcom, "Making transfer:\n%s", QString(body).toStdString().c_str());
LOG(netcom, "SESSION ID: %s\n", sessionid.toStdString().c_str());
request.setRawHeader("User-Agent", "Pracro Client v"VERSION);
-
+ /*
if(sessionid != "") {
request.setRawHeader("SessionID", sessionid.toStdString().c_str());
} else {
request.setRawHeader("SessionPatientID", patientid.toStdString().c_str());
request.setRawHeader("SessionTemplate", templ.toStdString().c_str());
}
+ */
+
+ QUrl url;
+ url.setHost(request.url().host());
+ url.setPort(request.url().port());
+ url.setScheme(request.url().scheme());
switch(state) {
case ::commit:
- request.setRawHeader("SessionCommit", "yes");
+ // request.setRawHeader("SessionCommit", "yes");
+ url.addQueryItem("statechange", "commit");
break;
case ::discard:
- request.setRawHeader("SessionDiscard", "yes");
+ // request.setRawHeader("SessionDiscard", "yes");
+ url.addQueryItem("statechange", "discard");
break;
case ::nocommit:
- request.setRawHeader("SessionNoCommit", "yes");
+ // request.setRawHeader("SessionNoCommit", "yes");
+ url.addQueryItem("statechange", "nocommit");
break;
default:
case ::none:
break;
}
- manager->post(request, doc.toByteArray());
+ url.setPath(uri);
+ if(sessionid != "") url.addQueryItem("sessionid", sessionid);
+ if(patientid != "") url.addQueryItem("patientid", patientid);
+ request.setUrl(url);
+
+ manager->post(request, body);
}
void NetCom::initConnection()
{
- send(templ); // Initialise by sending a template-only request.
+ send(course, templ); // Initialise by sending a template-only request.
}
void NetCom::commit()
{
- QDomDocument doc;
- makeTransfer(doc, ::commit);
+ makeTransfer("", ::commit);
}
void NetCom::nocommit()
{
- QDomDocument doc;
- makeTransfer(doc, ::nocommit);
+ makeTransfer("", ::nocommit);
}
void NetCom::discard()
{
- QDomDocument doc;
- makeTransfer(doc, ::discard);
+ makeTransfer("", ::discard);
}
-void NetCom::send(QString templ, QString macro)
+void NetCom::send(QString course, QString templ, QString macro)
{
- QDomDocument doc;
-
+ /*
QDomProcessingInstruction header =
doc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
doc.appendChild(header);
QDomElement pracro_elem = doc.createElement("pracro");
pracro_elem.setAttribute("version", "1.0");
- pracro_elem.setAttribute("cpr", patientid);
+ pracro_elem.setAttribute("patientid", patientid);
pracro_elem.setAttribute("user", user);
doc.appendChild(pracro_elem);
QDomElement request_elem = doc.createElement("request");
- request_elem.setAttribute("template", templ);
+ request_elem.setAttribute("course", course);
+ if(templ != "") request_elem.setAttribute("template", templ);
if(macro != "") request_elem.setAttribute("macro", macro);
pracro_elem.appendChild(request_elem);
+ */
+ QString uri = "/";
+ if(course != "") {
+ uri += course + "/";
+ if(templ != "") {
+ uri += templ + "/";
+ if(macro != "") uri += macro + "/";
+ }
+ }
- makeTransfer(doc);
+ makeTransfer("", ::none, uri);
}
-void NetCom::send(QVector< Widget* > widgets, QString templ,
+void NetCom::send(QVector< Widget* > widgets, QString course, QString templ,
QString macro, QString version)
{
QDomDocument doc;
@@ -176,11 +207,12 @@ void NetCom::send(QVector< Widget* > widgets, QString templ,
QDomElement pracro_elem = doc.createElement("pracro");
pracro_elem.setAttribute("version", "1.0");
- pracro_elem.setAttribute("cpr", patientid);
+ pracro_elem.setAttribute("patientid", patientid);
pracro_elem.setAttribute("user", user);
doc.appendChild(pracro_elem);
QDomElement commit_elem = doc.createElement("commit");
+ commit_elem.setAttribute("course", course);
commit_elem.setAttribute("template", templ);
commit_elem.setAttribute("macro", macro);
commit_elem.setAttribute("version", version);
@@ -204,10 +236,10 @@ void NetCom::send(QVector< Widget* > widgets, QString templ,
}
i++;
}
-
+ /*
QDomElement request_elem = doc.createElement("request");
request_elem.setAttribute("template", templ);
pracro_elem.appendChild(request_elem);
-
- makeTransfer(doc);
+ */
+ makeTransfer(doc.toByteArray(), ::none, "");
}