From 77436dedbe1bd5a5320fe9f263adebb3264d3607 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Sun, 14 Apr 2002 06:57:02 +0000 Subject: Newt stuff --- sisinstall/Makefile.am | 2 +- sisinstall/sismain.cpp | 94 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 20 deletions(-) (limited to 'sisinstall') diff --git a/sisinstall/Makefile.am b/sisinstall/Makefile.am index a02fb20..1d54c6f 100644 --- a/sisinstall/Makefile.am +++ b/sisinstall/Makefile.am @@ -3,7 +3,7 @@ INCLUDES=-I$(top_srcdir)/lib bin_PROGRAMS = sisinstall -sisinstall_LDADD = $(top_srcdir)/lib/libplp.la +sisinstall_LDADD = $(top_srcdir)/lib/libplp.la $(LIBNEWT) sisinstall_SOURCES = psion.cpp sisinstaller.cpp sismain.cpp \ fakepsion.cpp sisfilelink.cpp sisfilelink.h EXTRA_DIST = psion.h sisinstaller.h fakepsion.h diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp index 0cfb370..404cb20 100644 --- a/sisinstall/sismain.cpp +++ b/sisinstall/sismain.cpp @@ -13,6 +13,10 @@ #include #include +#if HAVE_LIBNEWT +# include +#endif + #define _GNU_SOURCE #include @@ -25,8 +29,11 @@ static void error(int line) static struct option opts[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'V' }, - { "loglevel", required_argument, 0, 'l' }, + { "verbose", required_argument, 0, 'v' }, { "dry-run", no_argument, 0, 'n' }, +#if HAVE_LIBNEWT + { "newt", no_argument, 0, 'w' }, +#endif { NULL, 0, 0, 0 }, }; @@ -39,8 +46,11 @@ void printHelp() "\n" " -h, --help Display this text.\n" " -V, --version Print version and exit.\n" - " -l, --loglevel=LEVEL Set the log level, by default 0.\n" + " -v, --verbose=LEVEL Set the verbosity level, by default 0.\n" " -n, --dry-run Just parse file file.\n" +#if HAVE_LIBNEWT + " -w, --newt Use the Newt interface.\n" +#endif )); } @@ -49,6 +59,7 @@ void main(int argc, char* argv[]) char* filename = 0; char option; bool dryrun = false; + bool usenewt = false; #ifdef LC_ALL setlocale(LC_ALL, ""); @@ -57,7 +68,13 @@ void main(int argc, char* argv[]) while (1) { - option = getopt_long(argc, argv, "hnl:V", opts, NULL); + option = getopt_long(argc, argv, +#if HAVE_LIBNEWT + "hnv:Vw" +#else + "hnv:V" +#endif + , opts, NULL); if (option == -1) break; switch (option) @@ -66,22 +83,47 @@ void main(int argc, char* argv[]) case '?': printHelp(); exit(0); - case 'l': + case 'v': logLevel = atoi(optarg); break; case 'n': dryrun = true; break; +#if HAVE_LIBNEWT + case 'w': + usenewt = true; + break; +#endif case 'V': printf(_("sisinstall version 0.1\n")); exit(0); } } +#if HAVE_LIBNEWT + if (usenewt) + { + newtInit(); + newtCls(); + } +#endif if (optind < argc) { filename = argv[optind]; - printf(_("Installing sis file %s%s\n"), filename, - dryrun ? _(", not really") : ""); +#if HAVE_LIBNEWT + if (usenewt) + { + char helpline[256]; + sprintf(helpline, + _("Installing sis file %s%s.\n"), + filename, + dryrun ? _(", not really") : ""); + newtPushHelpLine(helpline); +// newtWaitForKey(); + } + else +#endif + printf(_("Installing sis file %s%s.\n"), filename, + dryrun ? _(", not really") : ""); } struct stat st; if (-1 == stat(filename, &st)) @@ -104,26 +146,40 @@ void main(int argc, char* argv[]) if (!psion->connect()) { printf(_("Couldn't connect with the Psion\n")); - exit(1); } - createCRCTable(); - SISFile sisFile; - SisRC rc = sisFile.fillFrom(buf, len); - if (rc == SIS_OK) + else { - if (!dryrun) + createCRCTable(); + SISFile sisFile; + SisRC rc = sisFile.fillFrom(buf, len); + if (rc == SIS_OK) + { +// if (!dryrun) + { + SISInstaller installer; + installer.setPsion(psion); +#if HAVE_LIBNEWT + installer.useNewt(usenewt); +#endif + installer.run(&sisFile, buf, len); + } + } + else { - SISInstaller installer; - installer.setPsion(psion); - installer.run(&sisFile, buf, len); + printf(_("Could not parse the sis file.\n")); } + psion->disconnect(); } - else + +#if HAVE_LIBNEWT + if (usenewt) { - printf(_("Could not parse the sis file.\n")); + newtPopHelpLine(); + newtPushHelpLine(_("Installation complete. Press any key to exit.")); + newtWaitForKey(); + newtFinished(); } - psion->disconnect(); - +#endif exit(0); } -- cgit v1.2.3