summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/macro.cc23
-rw-r--r--client/macro.h2
-rw-r--r--client/main.cc64
3 files changed, 78 insertions, 11 deletions
diff --git a/client/macro.cc b/client/macro.cc
index 654557d..669674b 100644
--- a/client/macro.cc
+++ b/client/macro.cc
@@ -34,19 +34,23 @@
class MyEvent : public QEvent {
public:
- MyEvent(QString macro) : QEvent((QEvent::Type)MY_EVENT_ID)
+ MyEvent(QString macro, QString cpr, QString user) : QEvent((QEvent::Type)MY_EVENT_ID)
{
this->macro = macro;
+ this->cpr = cpr;
+ this->user = user;
}
QString macro;
+ QString cpr;
+ QString user;
};
-static QDomDocument xml_request(QString name);
+static QDomDocument xml_request(QString name, QString cpr, QString user);
-void create_macro(QString name)
+void create_macro(QString name, QString cpr, QString user)
{
// Build the XML request
- QDomDocument xml_req = xml_request(name);
+ QDomDocument xml_req = xml_request(name, cpr, user);
// Fetch the XML document
SendRecieve xml_acquire;
@@ -72,7 +76,7 @@ bool MyEventHandler::eventFilter( QObject *o, QEvent *e )
if ( e->type() == MY_EVENT_ID ) {
MyEvent *event = (MyEvent*)e;
- create_macro(event->macro);
+ create_macro(event->macro, event->cpr, event->user);
// ... DO SOMETHING WITH EVENT
return TRUE; // eat event
} else {
@@ -81,18 +85,19 @@ bool MyEventHandler::eventFilter( QObject *o, QEvent *e )
}
}
-void new_macro(QString macro)
+void new_macro(QString macro, QString cpr, QString user)
{
- MyEvent *event = new MyEvent(macro);
+ MyEvent *event = new MyEvent(macro, cpr, user);
qApp->postEvent(qApp, event);
}
-static QDomDocument xml_request(QString name)
+static QDomDocument xml_request(QString name, QString cpr, QString user)
{
// Create the xml request array
QByteArray xml_array;
+ printf("macro: %s, cpr: %s, user: %s\n", name.toStdString().c_str(), cpr.toStdString().c_str(), user.toStdString().c_str());
xml_array.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- xml_array.append("<pracro version=\"1.0\" cpr=\"1505050505\" user=\"tux\">\n");
+ xml_array.append("<pracro version=\"1.0\" cpr=\"" + cpr + "\" user=\"" + user + "\">\n");
xml_array.append(" <request macro=\"" + name + "\"/>\n");
xml_array.append("</pracro>");
diff --git a/client/macro.h b/client/macro.h
index 9863d3a..a3fadf5 100644
--- a/client/macro.h
+++ b/client/macro.h
@@ -36,6 +36,6 @@ protected:
bool eventFilter( QObject *o, QEvent *e );
};
-void new_macro(QString name);
+void new_macro(QString name, QString cpr, QString user);
#endif/*__PRACRO_MACRO_H__*/
diff --git a/client/main.cc b/client/main.cc
index 025b713..fbedfc2 100644
--- a/client/main.cc
+++ b/client/main.cc
@@ -36,8 +36,70 @@ int main(int argc, char *argv[])
MyEventHandler *eventhandler = new MyEventHandler();
app.installEventFilter( eventhandler );
+
+ char macro[100] = "example";
+ char cpr[11] = "0000000000";
+ char user[20] = "testuser";
+
+ int a;
+ for(a=1; a < argc; a++) {
+ /*
+ if(argv[a][0] != '-') {
+ strcpy(cprfile, argv[a]);
+ continue;
+ }
+ */
+ if(strcmp(argv[a], "-h") == 0 || strcmp(argv[a], "--help") == 0 ||
+ strcmp(argv[a], "-?") == 0) {
+ printf("Usage: pracro -m MACRO -c CPR -U USER\n");
+ printf("Executes the requested Pracro MACRO using supplied CPR "
+ "and USER.\n");
+ printf("\n");
+ printf(" -h, --help Displays this help text.\n");
+ printf(" -m, --macro MACRO Requests macro MACRO from the Pracro "
+ "Server, defaults to \"example\".\n");
+ printf(" -c, --cpr CPR Defines the cpr for use with the "
+ "macro, defaults to \"0000000000\".\n");
+ printf(" -U, --user USER Defines the requesting "
+ "user(not the patient), defaults to \"testuser\"");
+ printf("\n");
+ return 0;
+ }
+ if(strcmp(argv[a], "-m") == 0 || strcmp(argv[a], "--macro") == 0) {
+ if(a+1 == argc || argv[a+1][0] == '-') {
+ printf("Missing argument for macro, exiting...\n");
+ exit(1);
+ }
+ strcpy(macro, argv[a+1]);
+ a++;
+ continue;
+ }
+ if(strcmp(argv[a], "-c") == 0 || strcmp(argv[a], "--cpr") == 0) {
+ if(a+1 == argc || argv[a+1][0] == '-') {
+ printf("Missing argument for cpr, exiting...\n");
+ exit(1);
+ }
+ strcpy(cpr, argv[a+1]);
+ a++;
+ continue;
+ }
+ if(strcmp(argv[a], "-U") == 0 || strcmp(argv[a], "--user") == 0) {
+ if(a+1 == argc || argv[a+1][0] == '-') {
+ printf("Missing argument for user, exiting...\n");
+ exit(1);
+ }
+ strcpy(user, argv[a+1]);
+ a++;
+ continue;
+ }
+ }
+
+
+
+
+
- new_macro("example");
+ new_macro(macro, cpr, user);
return app.exec();
}