summaryrefslogtreecommitdiff
path: root/Source/Applications/PaperWork/PaperWork.cpp
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-16 18:22:58 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-16 18:22:58 +0100
commit3d5aca66b9712758aecb2e80bc5b2fb3df6256a4 (patch)
tree817e945218dbca029244315f36b960dd288b3cff /Source/Applications/PaperWork/PaperWork.cpp
parent5f87c447bdcb82beacbfb930942fe9995dcdb60f (diff)
downloadMelon-3d5aca66b9712758aecb2e80bc5b2fb3df6256a4.tar.gz
Melon-3d5aca66b9712758aecb2e80bc5b2fb3df6256a4.zip
New model, object-oriented, for applications
Diffstat (limited to 'Source/Applications/PaperWork/PaperWork.cpp')
-rw-r--r--Source/Applications/PaperWork/PaperWork.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/Source/Applications/PaperWork/PaperWork.cpp b/Source/Applications/PaperWork/PaperWork.cpp
new file mode 100644
index 0000000..0d6a821
--- /dev/null
+++ b/Source/Applications/PaperWork/PaperWork.cpp
@@ -0,0 +1,64 @@
+#include <App/ShellApp.proto.h>
+
+#define DEFAULT_SHELL "/Applications/Shell/Shell.app"
+
+class PaperWork : public ShellApp {
+ public:
+ PaperWork() : ShellApp() {}
+ int run();
+};
+
+APP(PaperWork);
+
+int PaperWork::run() {
+ String act = "init";
+ if (args.size() == 2) {
+ if (args[1] == "login") {
+ act = "login";
+ } else if (args[1] == "init") {
+ act = "init";
+ }
+ }
+
+ if (act == "init") {
+ while (1) {
+ Process p = Process::run("/System/Applications/PaperWork.app");
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.pushArg("login");
+ p.start();
+ p.wait();
+ } else {
+ return 1;
+ }
+ }
+ } else if (act == "login") {
+ outvt << "Logging in to Melon\n";
+ String user, pw;
+ while (1) {
+ outvt << "Username: ";
+ user = invt.readLine();
+ outvt << "Password: ";
+ pw = invt.readLine(false);
+ if (!Process::get().authenticatePW(user, pw)) {
+ outvt << "Authentication failed.\n\n";
+ continue;
+ }
+ outvt << "What shell to run [" << DEFAULT_SHELL << "]? ";
+ String sh = invt.readLine();
+ if (sh == "") sh = DEFAULT_SHELL;
+ Process p = Process::run(sh);
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.start();
+ p.wait();
+ outvt << "\n\n";
+ } else {
+ return 1;
+ }
+ return 0;
+ }
+ }
+}