diff options
Diffstat (limited to 'sisinstall/sisinstaller.cpp')
-rw-r--r-- | sisinstall/sisinstaller.cpp | 259 |
1 files changed, 8 insertions, 251 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) |