aboutsummaryrefslogtreecommitdiffstats
path: root/sisinstall
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2007-12-09 15:22:33 +0000
committerReuben Thomas <rrt@sc3d.org>2007-12-09 15:22:33 +0000
commitc24d09ec87e2d0f210f6dbc43041283e9900c63e (patch)
tree0a143502d3913051ce534a1b28f8eb2cf1af469b /sisinstall
parent17eecf8b0a97e1155a99d1b58700544db5a6d7dd (diff)
downloadplptools-c24d09ec87e2d0f210f6dbc43041283e9900c63e.tar.gz
plptools-c24d09ec87e2d0f210f6dbc43041283e9900c63e.tar.bz2
plptools-c24d09ec87e2d0f210f6dbc43041283e9900c63e.zip
Remove newt interface of sisinstall, as it was a pretty small gain for
a whole dependency. Most command-line users will be happy with the plain text interface; GUI users will want kpsion back.
Diffstat (limited to 'sisinstall')
-rw-r--r--sisinstall/sisinstaller.cpp259
-rw-r--r--sisinstall/sisinstaller.h18
-rw-r--r--sisinstall/sismain.cpp70
3 files changed, 10 insertions, 337 deletions
diff --git a/sisinstall/sisinstaller.cpp b/sisinstall/sisinstaller.cpp
index b9df146..d159496 100644
--- a/sisinstall/sisinstaller.cpp
+++ b/sisinstall/sisinstaller.cpp
@@ -69,9 +69,6 @@ SISInstaller::createDirs(char* filename)
if ((res != rfsv::E_PSI_GEN_NONE) &&
(res != rfsv::E_PSI_FILE_EXIST))
{
-#if HAVE_LIBNEWT
- if (!m_useNewt)
-#endif
fprintf(stderr, " -> Failed: %s\n", (const char*)res);
}
}
@@ -110,14 +107,6 @@ SISInstaller::copyFile(SISFileRecord* fileRecord)
sprintf(msgbuf,
"Copying %d bytes to %s\n",
fileRecord->m_fileLengths[m_fileNo], dest);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPushHelpLine(msgbuf);
- newtRefresh();
- }
- else
-#endif
{
printf("%s\n", msgbuf);
}
@@ -126,13 +115,6 @@ SISInstaller::copyFile(SISFileRecord* fileRecord)
fileRecord->m_fileLengths[m_fileNo],
dest);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPopHelpLine();
- newtRefresh();
- }
-#endif
}
void
@@ -144,9 +126,6 @@ SISInstaller::copyBuf(const uint8_t* buf, int len, char* name)
int fd = mkstemp(srcName);
if (-1 == fd)
{
-#if HAVE_LIBNEWT
- if (!m_useNewt)
-#endif
fprintf(stderr,
"Couldn't create temp file: %s\n", strerror(errno));
return;
@@ -165,12 +144,7 @@ SISInstaller::copyBuf(const uint8_t* buf, int len, char* name)
}
else
{
-#if HAVE_LIBNEWT
- if (!m_useNewt)
-#endif
- {
fprintf(stderr, " -> Fail: %s\n", (const char*)res);
- }
}
unlink(srcName);
}
@@ -186,80 +160,6 @@ SISInstaller::installFile(SISFileRecord* fileRecord)
break;
case 1:
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- int len = fileRecord->m_fileLengths[m_fileNo];
- char* msgbuf = new char[len + 1];
- memcpy(msgbuf, fileRecord->getFilePtr(m_fileNo), len);
- msgbuf[len] = 0;
- int j = 0;
- for (int i = 0; i < len; ++i)
- {
- if (msgbuf[i] != '\r')
- msgbuf[j++] = msgbuf[i];
- }
- msgbuf[j] = 0;
- int cols = 0;
- int rows = 0;
- char* reflowedText =
- newtReflowText(msgbuf, 40, 20, 30, &cols, &rows);
- int flags = NEWT_FLAG_WRAP;
- if (rows > 15)
- {
- rows = 15;
- flags |= NEWT_FLAG_SCROLL;
- }
- newtComponent text = newtTextbox(0, 0, cols, rows, flags);
- newtTextboxSetText(text, reflowedText);
- newtOpenWindow(10, 5, cols + 2, rows + 5, "Info");
- newtComponent form = newtForm(NULL, NULL, 0);
- newtFormAddComponent(form, text);
- newtComponent button1;
- newtComponent button2 = 0;
- const char* b1;
- const char* b2;
- int rc = FILE_OK;
- switch (fileRecord->m_fileDetails)
- {
- case 0:
- b1 = _("Continue");
- button1 = newtButton((cols - strlen(b1)) / 2 - 1,
- rows + 1, b1);
- break;
- case 1:
- b1 = _("Yes");
- b2 = _("No");
- button1 = newtButton(cols / 3 - strlen(b1) / 2 - 1,
- rows + 1, b1);
- button2 = newtButton(cols / 3 * 2 - strlen(b2) / 2 - 1,
- rows + 1, b2);
- rc = FILE_SKIP;
- break;
- case 2:
- b1 = _("Yes");
- b2 = _("No");
- button1 = newtButton(cols / 3 - strlen(b1) / 2 - 1,
- rows + 1, b1);
- button2 = newtButton(cols / 3 * 2 - strlen(b2) / 2 - 1,
- rows + 1, b2);
- rc = FILE_ABORT;
- break;
- }
- newtFormAddComponent(form, button1);
- if (button2)
- newtFormAddComponent(form, button2);
- newtComponent ender = newtRunForm(form);
- if (ender == button1)
- rc = FILE_OK;
- newtFormDestroy(form);
- newtPopWindow();
- delete reflowedText;
- delete msgbuf;
- return rc;
- }
- else
-#endif
{
printf("Info:\n%.*s\n",
fileRecord->m_fileLengths[m_fileNo],
@@ -310,9 +210,6 @@ SISInstaller::installFile(SISFileRecord* fileRecord)
}
SISInstaller installer;
installer.setPsion(m_psion);
-#if HAVE_LIBNEWT
- installer.useNewt(m_useNewt);
-#endif
installer.setInstalled(m_installed);
rc = installer.run(&sisFile, buf2, len, m_file);
if (0 == m_drive)
@@ -354,13 +251,6 @@ SISInstaller::loadInstalled()
}
else
{
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPushHelpLine(_("Loading installed sis files."));
- newtRefresh();
- }
-#endif
while (!files.empty())
{
PlpDirent file = files[0];
@@ -371,13 +261,6 @@ SISInstaller::loadInstalled()
loadPsionSis(sisname);
files.pop_front();
}
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPopHelpLine();
- newtRefresh();
- }
-#endif
}
}
@@ -456,9 +339,6 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
long lang;
m_file = file;
m_buf = buf;
-#if HAVE_LIBNEWT
- newtComponent form, button, text, listbox;
-#endif
char msgbuf[1024];
if (parent == 0)
{
@@ -468,65 +348,15 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
sprintf(msgbuf,
_("You have only one language: %s"),
m_file->getLanguage(0)->m_name);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
-# if 0
- text = newtTextboxReflowed(1, 1, msgbuf, 37, 5, 5, 0);
- int th = newtTextboxGetNumLines(text);
- const char* okText = _("Ok");
- button = newtButton(18 - strlen(okText) / 2, th + 2, okText);
- newtOpenWindow(10, 5, 40, th + 6, "Language");
- form = newtForm(NULL, NULL, 0);
- newtFormAddComponent(form, text);
- newtFormAddComponent(form, button);
- newtRunForm(form);
- newtFormDestroy(form);
- newtPopWindow();
-# endif
- }
- else
-#endif
- {
- printf("%s\n", msgbuf);
- }
+ printf("%s\n", msgbuf);
lang = 0;
}
else
{
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- sprintf(msgbuf, _("Select a language."));
- text = newtTextboxReflowed(1, 1, msgbuf, 37, 5, 5, 0);
- int th = newtTextboxGetNumLines(text);
- listbox = newtListbox(1, th + 2, 6,
- NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
- int boxwidth = 0;
- for (int i = 0; i < n; ++i)
- {
- const char* txt = m_file->getLanguage(i)->m_name;
- if (strlen(txt) > boxwidth)
- boxwidth = strlen(txt);
- newtListboxAppendEntry(listbox, txt, (void*) i);
- }
- newtOpenWindow(10, 5, 40, th + 8, "Language");
- form = newtForm(NULL, NULL, 0);
- newtFormAddComponent(form, text);
- newtFormAddComponent(form, listbox);
- newtRunForm(form);
- lang = (long)newtListboxGetCurrent(listbox);
- newtFormDestroy(form);
- newtPopWindow();
- }
- else
-#endif
- {
printf("Select a language (%d alternatives):\n", n);
for (int i = 0; i < n; ++i)
printf(" %d. %s\n", i, m_file->getLanguage(i)->m_name);
lang = 0;
- }
}
}
else
@@ -542,17 +372,7 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
m_file->setLanguage(lang);
uint8_t* compName = m_file->getName();
sprintf(msgbuf, _("Installing component: `%s'"), compName);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPushHelpLine(msgbuf);
- newtRefresh();
- }
- else
-#endif
- {
- printf("%s\n", msgbuf);
- }
+ printf("%s\n", msgbuf);
// In order to check requisites and previous versions, we need to
// load all sis files from the c:/system/install directory.
@@ -625,25 +445,8 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
else
{
sprintf(msgbuf, _("Uninstalling the previous version first."));
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPushHelpLine(msgbuf);
- newtRefresh();
- }
- else
-#endif
- {
- printf("%s\n", msgbuf);
- }
+ printf("%s\n", msgbuf);
uninstall(oldFile);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPopHelpLine();
- newtRefresh();
- }
-#endif
}
}
@@ -712,12 +515,6 @@ SISInstaller::run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent)
if (logLevel >= 1)
fprintf(stderr, "Creating residual sis file %s\n", resname);
copyBuf(buf, m_file->getResidualEnd(), resname);
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- newtPopHelpLine();
- }
-#endif
if (aborted)
return SIS_ABORTED;
return SIS_OK;
@@ -746,15 +543,10 @@ SISInstaller::selectDrive()
drivelist[ndrives] = 'A' + i;
space[ndrives] = plpdrive.getSpace();
size[ndrives] = plpdrive.getSize();
-#if HAVE_LIBNEWT
- if (!m_useNewt)
-#endif
- {
- printf("%c: %d bytes free, %d bytes total\n",
- 'A' + i,
- plpdrive.getSpace(),
- plpdrive.getSize());
- }
+ printf("%c: %d bytes free, %d bytes total\n",
+ 'A' + i,
+ plpdrive.getSpace(),
+ plpdrive.getSize());
++ndrives;
}
}
@@ -777,37 +569,6 @@ SISInstaller::selectDrive()
else
{
-#if HAVE_LIBNEWT
- if (m_useNewt)
- {
- char msgbuf[256];
- sprintf(msgbuf, _("Select a drive."));
- newtComponent text = newtTextboxReflowed(1, 1, msgbuf, 37, 5, 5, 0);
- int th = newtTextboxGetNumLines(text);
- newtComponent listbox =
- newtListbox(1, th + 2, 6,
- NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
- int boxwidth = 0;
- for (int i = 0; i < ndrives; ++i)
- {
- char txt[256];
- sprintf(txt, "%c: %d kbytes free, %d kbytes total",
- drivelist[i], space[i] / 1024, size[i] / 1024);
- if (strlen(txt) > boxwidth)
- boxwidth = strlen(txt);
- newtListboxAppendEntry(listbox, txt, (void*) i);
- }
- newtOpenWindow(10, 5, boxwidth + 5, th + 8, "Drive");
- newtComponent form = newtForm(NULL, NULL, 0);
- newtFormAddComponent(form, text);
- newtFormAddComponent(form, listbox);
- newtRunForm(form);
- m_drive = 'A' + (long)newtListboxGetCurrent(listbox);
- newtFormDestroy(form);
- newtPopWindow();
- }
- else
-#endif
{
printf("Please select a drive\n");
char ch;
@@ -872,8 +633,7 @@ SISInstaller::uninstallFile(SISFileRecord* fileRecord)
#if 0
// This is messy... We can't remove the sis component unless
// we've stored the entire component in the residual sis
- // file no the target machine.
- //
+ // file on the target machine.
if (logLevel >= 1)
fprintf(stderr, "Recursive sis file...\n");
SISFile sisFile;
@@ -891,9 +651,6 @@ SISInstaller::uninstallFile(SISFileRecord* fileRecord)
}
SISInstaller installer;
installer.setPsion(m_psion);
-#if HAVE_LIBNEWT
- installer.useNewt(m_useNewt);
-#endif
installer.setInstalled(m_installed);
rc = installer.run(&sisFile, buf2, len, m_file);
if (0 == m_drive)
diff --git a/sisinstall/sisinstaller.h b/sisinstall/sisinstaller.h
index 493d839..28e110f 100644
--- a/sisinstall/sisinstaller.h
+++ b/sisinstall/sisinstaller.h
@@ -3,10 +3,6 @@
#include "sistypes.h"
-#if HAVE_LIBNEWT
-# include <newt.h>
-#endif
-
#include <sys/types.h>
class Psion;
@@ -50,16 +46,6 @@ public:
*/
void setPsion(Psion* psion);
-#if HAVE_LIBNEWT
- /**
- * Shall we do use feedback via newt?
- */
- void useNewt(bool usenewt)
- {
- m_useNewt = usenewt;
- }
-#endif
-
private:
char m_drive;
@@ -78,10 +64,6 @@ private:
bool m_ownInstalled;
-#if HAVE_LIBNEWT
- bool m_useNewt;
-#endif
-
enum {
FILE_OK,
FILE_SKIP,
diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp
index c845408..479fbf8 100644
--- a/sisinstall/sismain.cpp
+++ b/sisinstall/sismain.cpp
@@ -13,28 +13,13 @@
#include <sys/types.h>
#include <sys/stat.h>
-#if HAVE_LIBNEWT
-# include <newt.h>
-#endif
-
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <getopt.h>
-bool usenewt = false;
-
static void error(int line)
{
-#if HAVE_LIBNEWT
- if (usenewt)
- {
- newtPopHelpLine();
- newtPushHelpLine(_("Got an error, Press any key to exit."));
- newtWaitForKey();
- newtFinished();
- }
-#endif
fprintf(stderr, _("Error %d on line %d: %s\n"), errno, line,
strerror(errno));
exit(1);
@@ -45,9 +30,6 @@ static struct option opts[] = {
{ "version", no_argument, 0, 'V' },
{ "verbose", required_argument, 0, 'v' },
{ "dry-run", no_argument, 0, 'n' },
-#if HAVE_LIBNEWT
- { "newt", no_argument, 0, 'w' },
-#endif
{ NULL, 0, 0, 0 },
};
@@ -62,9 +44,6 @@ void printHelp()
" -V, --version Print version and exit.\n"
" -v, --verbose=LEVEL Set the verbosity level, by default 0.\n"
" -n, --dry-run Just parse the file.\n"
-#if HAVE_LIBNEWT
- " -w, --newt Use the Newt interface.\n"
-#endif
));
}
@@ -82,11 +61,7 @@ int main(int argc, char* argv[])
while (1)
{
option = getopt_long(argc, argv,
-#if HAVE_LIBNEWT
- "hnv:Vw"
-#else
"hnv:V"
-#endif
, opts, NULL);
if (option == -1)
break;
@@ -102,48 +77,19 @@ int main(int argc, char* argv[])
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];
-#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") : "");
+ printf(_("Installing sis file %s%s.\n"), filename,
+ dryrun ? _(", not really") : "");
}
else
{
-#if HAVE_LIBNEWT
- if (usenewt)
- newtFinished();
-#endif
fprintf(stderr, _("Missing SIS filename\n"));
exit(1);
}
@@ -180,9 +126,6 @@ int main(int argc, char* argv[])
{
SISInstaller installer;
installer.setPsion(psion);
-#if HAVE_LIBNEWT
- installer.useNewt(usenewt);
-#endif
installer.run(&sisFile, buf, len);
}
}
@@ -193,15 +136,6 @@ int main(int argc, char* argv[])
psion->disconnect();
}
-#if HAVE_LIBNEWT
- if (usenewt)
- {
- newtPopHelpLine();
- newtPushHelpLine(_("Installation complete. Press any key to exit."));
- newtWaitForKey();
- newtFinished();
- }
-#endif
return 0;
}