summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Main.cc74
1 files changed, 62 insertions, 12 deletions
diff --git a/src/Main.cc b/src/Main.cc
index e874fcf..cd74b60 100644
--- a/src/Main.cc
+++ b/src/Main.cc
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <list>
-#include "Action.h"
+#include <sys/types.h>
+#include <sys/wait.h>
#include "Handle.h"
#include "HttpServ.h"
#include "Socket.h"
@@ -11,7 +12,6 @@
#include "Form.h"
#include "Confirm.h"
#include "Table.h"
-#include "IRC.h"
class InPipe : public Handle {
public:
@@ -25,11 +25,66 @@ class InPipe : public Handle {
int m_out;
} * in;
+class ad_t : public Action {
+ public:
+ ad_t() : Action("menu6") { }
+ virtual ~ad_t() { }
+ virtual String GetTitle() { return "Action dynamique"; }
+ virtual void Do(Variables * v, Handle * h) {
+ String ut, un;
+
+ if (!fork()) {
+ execlp("uptime", "uptime", NULL);
+ }
+ (*in) >> ut;
+ wait(NULL);
+
+ if (!fork()) {
+ execlp("uname", "uname", "-a", NULL);
+ }
+ (*in) >> un;
+ wait(NULL);
+
+ Action * m = new Message("Action dynamique",
+ String("Vous avez choisi l'action dynamique. L'uptime de la machine est '") +
+ ut + "' et sa définition complète est '" + un + "'", "");
+
+ m->Do(v, h);
+
+ delete m;
+ }
+};
+Action * ad = new ad_t();
+
+String Noms[] = {"Champ1", "Champ2", "Champ3"};
+String Defaults[] = {"Default1", "Default2", 0};
+String Invites[] = {"Champ 1:", "Champ 2:", "Champ 3:"};
+String Options[] = {"Option1", "Option2", ""};
+String ODescs[] = {"Description 1", "Description 2", ""};
+String * Lists[] = {0, 0, Options};
+String * Descs[] = {0, 0, ODescs};
+String Titres[] = {"Titre 1", "Titre 2", "Titre 3"};
+String Cells[] = {"L1C1", "L1C2", "L1C3", "L2C1", "L2C2", "L2C3", "L3C1", "L3C2", "L3C3", "L4C1", "L4C2", "L4C3"};
+Action * a1 = new Message("Action 1", "Vous avez cliqué sur l'option 1 du menu", "menu1");
+Action * a2 = new Table("Petite table", "menu2", Titres, Cells, 3, 4);
+Action * a3 = new Message("Schéma EA",
+"Voici le Schéma EA de cette application."
+"<center><table border=0><td><tr><img src=\"/image/schemaea.png\"></tr></td></table></center>",
+"schemaea");
+Action * a4 = new Form("Test de formulaire...", "menu4", "Rentrez des trucs...", Noms, Invites, Defaults, Lists, Descs, 3);
+Action * a5 = new Confirm("Confirmation", "Oui ou non?", "menu5", 0, 0);
+Action * Liste[] = {a1, a2, a3, a4, a5, ad};
+String Labels[] = {"Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action dynamique"};
+
+Action * buildmenu(void) {
+ return new Menu("Menu Principal", "start", Labels, Liste, 6);
+}
+
int main(int argc, char ** argv) {
int p[2], c;
- list<String> testlist;
- IRC ircclient("botalacon");
+ String port = "1500";
+ list<String> testlist;
testlist.push_front("poide");
if (pipe(p)) {
@@ -53,6 +108,7 @@ int main(int argc, char ** argv) {
while ((c = getopt(argc, argv, "p:")) != EOF) {
switch (c) {
case 'p':
+ port = optarg;
break;
default:
cerr << "Usage: " << argv[0] << " [-p port]\n";
@@ -61,17 +117,11 @@ int main(int argc, char ** argv) {
}
try {
- cerr << "Connecting..." << endl;
- if (ircclient.Connect()) {
- cerr << "Doing main loop..." << endl;
- ircclient.MainLoop();
- } else {
- cerr << "Error connecting..." << endl;
- }
+ HttpServ h(port.to_int());
+ h.MainLoop(buildmenu());
}
catch (GeneralException e) {
cerr << e.GetMsg() << endl;
- delete in;
exit(-1);
}