From e1408c833c9c8dfc99f75d22faf6d50aeca4571c Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 20 Nov 2007 21:32:27 +0000 Subject: Remove the KDE code. It was nice, but it's nicer just to treat the Psion as a file system, and use plpftp to do out-of-band things. Also, with KDE 4 this code will surely stop working. --- kde2/kpsion/.cvsignore | 9 - kde2/kpsion/Makefile.am | 44 - kde2/kpsion/hi16-action-psion_backup.png | Bin 458 -> 0 bytes kde2/kpsion/hi16-action-psion_format.png | Bin 560 -> 0 bytes kde2/kpsion/hi16-action-psion_restore.png | Bin 471 -> 0 bytes kde2/kpsion/hi16-app-kpsion.png | Bin 438 -> 0 bytes kde2/kpsion/hi22-action-psion_backup.png | Bin 1102 -> 0 bytes kde2/kpsion/hi22-action-psion_restore.png | Bin 1110 -> 0 bytes kde2/kpsion/hi22-app-kpsion.png | Bin 1043 -> 0 bytes kde2/kpsion/hi32-app-kpsion.png | Bin 309 -> 0 bytes kde2/kpsion/kpsion.cpp | 1859 ----------------------------- kde2/kpsion/kpsion.desktop | 10 - kde2/kpsion/kpsion.h | 164 --- kde2/kpsion/kpsionbackuplistview.cpp | 519 -------- kde2/kpsion/kpsionbackuplistview.h | 141 --- kde2/kpsion/kpsionconfig.cpp | 171 --- kde2/kpsion/kpsionconfig.h | 89 -- kde2/kpsion/kpsionrestoredialog.cpp | 91 -- kde2/kpsion/kpsionrestoredialog.h | 56 - kde2/kpsion/kpsionui.rc | 15 - kde2/kpsion/lo16-action-psion_backup.png | Bin 268 -> 0 bytes kde2/kpsion/lo16-action-psion_restore.png | Bin 274 -> 0 bytes kde2/kpsion/lo16-app-kpsion.png | Bin 250 -> 0 bytes kde2/kpsion/lo22-action-psion_backup.png | Bin 318 -> 0 bytes kde2/kpsion/lo22-action-psion_restore.png | Bin 318 -> 0 bytes kde2/kpsion/lo32-action-psion_backup.png | Bin 366 -> 0 bytes kde2/kpsion/lo32-action-psion_restore.png | Bin 368 -> 0 bytes kde2/kpsion/lo32-app-kpsion.png | Bin 309 -> 0 bytes kde2/kpsion/main.cpp | 123 -- kde2/kpsion/setupdialog.cpp | 615 ---------- kde2/kpsion/setupdialog.h | 89 -- kde2/kpsion/statusbarprogress.cpp | 439 ------- kde2/kpsion/statusbarprogress.h | 169 --- kde2/kpsion/wizards.cpp | 598 ---------- kde2/kpsion/wizards.h | 78 -- 35 files changed, 5279 deletions(-) delete mode 100644 kde2/kpsion/.cvsignore delete mode 100644 kde2/kpsion/Makefile.am delete mode 100644 kde2/kpsion/hi16-action-psion_backup.png delete mode 100644 kde2/kpsion/hi16-action-psion_format.png delete mode 100644 kde2/kpsion/hi16-action-psion_restore.png delete mode 100644 kde2/kpsion/hi16-app-kpsion.png delete mode 100644 kde2/kpsion/hi22-action-psion_backup.png delete mode 100644 kde2/kpsion/hi22-action-psion_restore.png delete mode 100644 kde2/kpsion/hi22-app-kpsion.png delete mode 100644 kde2/kpsion/hi32-app-kpsion.png delete mode 100644 kde2/kpsion/kpsion.cpp delete mode 100644 kde2/kpsion/kpsion.desktop delete mode 100644 kde2/kpsion/kpsion.h delete mode 100644 kde2/kpsion/kpsionbackuplistview.cpp delete mode 100644 kde2/kpsion/kpsionbackuplistview.h delete mode 100644 kde2/kpsion/kpsionconfig.cpp delete mode 100644 kde2/kpsion/kpsionconfig.h delete mode 100644 kde2/kpsion/kpsionrestoredialog.cpp delete mode 100644 kde2/kpsion/kpsionrestoredialog.h delete mode 100644 kde2/kpsion/kpsionui.rc delete mode 100644 kde2/kpsion/lo16-action-psion_backup.png delete mode 100644 kde2/kpsion/lo16-action-psion_restore.png delete mode 100644 kde2/kpsion/lo16-app-kpsion.png delete mode 100644 kde2/kpsion/lo22-action-psion_backup.png delete mode 100644 kde2/kpsion/lo22-action-psion_restore.png delete mode 100644 kde2/kpsion/lo32-action-psion_backup.png delete mode 100644 kde2/kpsion/lo32-action-psion_restore.png delete mode 100644 kde2/kpsion/lo32-app-kpsion.png delete mode 100644 kde2/kpsion/main.cpp delete mode 100644 kde2/kpsion/setupdialog.cpp delete mode 100644 kde2/kpsion/setupdialog.h delete mode 100644 kde2/kpsion/statusbarprogress.cpp delete mode 100644 kde2/kpsion/statusbarprogress.h delete mode 100644 kde2/kpsion/wizards.cpp delete mode 100644 kde2/kpsion/wizards.h (limited to 'kde2/kpsion') diff --git a/kde2/kpsion/.cvsignore b/kde2/kpsion/.cvsignore deleted file mode 100644 index 250cdbf..0000000 --- a/kde2/kpsion/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -Makefile.in -Makefile -.xvpics -.libs -.deps -*.lo -*.moc.cpp -libkpsion* -kpsion diff --git a/kde2/kpsion/Makefile.am b/kde2/kpsion/Makefile.am deleted file mode 100644 index fbf31e2..0000000 --- a/kde2/kpsion/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# $Id$ - -libdir=$(kde_libraries) - -bindir=$(kde_bindir) - -maintainer-clean-local: - rm -f Makefile.in - -METASOURCES = AUTO - -KDE_ICON = AUTO - -INCLUDES = $(all_includes) -I$(top_srcdir)/lib - -DISTCLEANFILES = $(kpsion_METASOURCES) ./.deps/* ./.deps/.P - -lib_LTLIBRARIES = libkpsion.la -bin_PROGRAMS = kpsion - -libkpsion_la_LDFLAGS = $(X_LDFLAGS) $(PLP_LDFLAGS) $(KDE_LDFLAGS) $(LIBDEBUG) $(KDE_PLUGIN) -libkpsion_la_SOURCES = kpsion.cpp setupdialog.cpp wizards.cpp \ - statusbarprogress.cpp kpsionconfig.cpp kpsionbackuplistview.cpp \ - kpsionrestoredialog.cpp - -libkpsion_la_LIBADD = $(LIB_PLP) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(LIB_KFILE) $(LIB_QT) - -kpsion_SOURCES = main.cpp -kpsion_LDFLAGS = $(KDE_RPATH) $(X_LDFLAGS) -kpsion_LDADD = libkpsion.la $(LIB_PLP) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(LIB_KFILE) $(LIB_QT) - -applnk_DATA = kpsion.desktop -applnkdir = $(kde_appsdir)/Utilities -EXTRA_DIST = kpsion.desktop - -rcdir = $(kde_datadir)/kpsion -rc_DATA = kpsionui.rc -EXTRA_DIST += kpsionui.rc - -noinst_HEADERS = kpsion.h setupdialog.h wizards.h kpsionrestoredialog.h \ - kpsionconfig.h kpsionbackuplistview.h statusbarprogress.h - -messages: - $(XGETTEXT) -C -ki18n -kI18N_NOOP -ktranslate -kaliasLocale *.cpp *.h && mv messages.po ../po/kpsion.pot diff --git a/kde2/kpsion/hi16-action-psion_backup.png b/kde2/kpsion/hi16-action-psion_backup.png deleted file mode 100644 index fe34db8..0000000 Binary files a/kde2/kpsion/hi16-action-psion_backup.png and /dev/null differ diff --git a/kde2/kpsion/hi16-action-psion_format.png b/kde2/kpsion/hi16-action-psion_format.png deleted file mode 100644 index b74cca8..0000000 Binary files a/kde2/kpsion/hi16-action-psion_format.png and /dev/null differ diff --git a/kde2/kpsion/hi16-action-psion_restore.png b/kde2/kpsion/hi16-action-psion_restore.png deleted file mode 100644 index 25ce627..0000000 Binary files a/kde2/kpsion/hi16-action-psion_restore.png and /dev/null differ diff --git a/kde2/kpsion/hi16-app-kpsion.png b/kde2/kpsion/hi16-app-kpsion.png deleted file mode 100644 index d1f2e5e..0000000 Binary files a/kde2/kpsion/hi16-app-kpsion.png and /dev/null differ diff --git a/kde2/kpsion/hi22-action-psion_backup.png b/kde2/kpsion/hi22-action-psion_backup.png deleted file mode 100644 index 9796f91..0000000 Binary files a/kde2/kpsion/hi22-action-psion_backup.png and /dev/null differ diff --git a/kde2/kpsion/hi22-action-psion_restore.png b/kde2/kpsion/hi22-action-psion_restore.png deleted file mode 100644 index 89e1e20..0000000 Binary files a/kde2/kpsion/hi22-action-psion_restore.png and /dev/null differ diff --git a/kde2/kpsion/hi22-app-kpsion.png b/kde2/kpsion/hi22-app-kpsion.png deleted file mode 100644 index c13dbd6..0000000 Binary files a/kde2/kpsion/hi22-app-kpsion.png and /dev/null differ diff --git a/kde2/kpsion/hi32-app-kpsion.png b/kde2/kpsion/hi32-app-kpsion.png deleted file mode 100644 index 7285992..0000000 Binary files a/kde2/kpsion/hi32-app-kpsion.png and /dev/null differ diff --git a/kde2/kpsion/kpsion.cpp b/kde2/kpsion/kpsion.cpp deleted file mode 100644 index d897e70..0000000 --- a/kde2/kpsion/kpsion.cpp +++ /dev/null @@ -1,1859 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 2000-2002 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "kpsion.h" -#include "kpsionconfig.h" -#include "wizards.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#define STID_CONNECTION 1 - -using namespace std; - -KPsionMainWindow::KPsionMainWindow() - : KMainWindow() { - setupActions(); - - statusBar()->insertItem(i18n("Idle"), STID_CONNECTION, 1); - statusBar()->setItemAlignment(STID_CONNECTION, - QLabel::AlignLeft|QLabel::AlignVCenter); - - progress = new KPsionStatusBarProgress(statusBar(), "progressBar"); - statusBar()->addWidget(progress, 10); - - connect(progress, SIGNAL(pressed()), this, SLOT(slotProgressBarPressed())); - connect(this, SIGNAL(setProgress(int)), progress, SLOT(setValue(int))); - connect(this, SIGNAL(setProgress(int, int)), progress, - SLOT(setValue(int, int))); - connect(this, SIGNAL(setProgressText(const QString &)), progress, - SLOT(setText(const QString &))); - connect(this, SIGNAL(enableProgressText(bool)), progress, - SLOT(setTextEnabled(bool))); - - backupRunning = false; - restoreRunning = false; - formatRunning = false; - doScheduledBackup = false; - quitImmediately = false; - - view = new KIconView(this, "iconview"); - view->setSelectionMode(KIconView::Multi); - view->setResizeMode(KIconView::Adjust); - view->setItemsMovable(false); - connect(view, SIGNAL(clicked(QIconViewItem *)), - SLOT(iconClicked(QIconViewItem *))); - connect(view, SIGNAL(onItem(QIconViewItem *)), - SLOT(iconOver(QIconViewItem *))); - connect(this, SIGNAL(rearrangeIcons(bool)), view, - SLOT(arrangeItemsInGrid(bool))); - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_UIDS)); - QStringList uids = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_UIDS)); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_MACHNAME)); - QString tmp = pcfg.getOptionName(KPsionConfig::OPT_MACHNAME); - - for (QStringList::Iterator it = uids.begin(); it != uids.end(); it++) - machines.insert(*it, config->readEntry(tmp.arg(*it))); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - backupDir = config->readEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR)); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_CONNRETRY)); - reconnectTime = config->readNumEntry( - pcfg.getOptionName(KPsionConfig::OPT_CONNRETRY)); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALDEV)); - ncpdDevice = config->readEntry(pcfg.getOptionName( - KPsionConfig::OPT_SERIALDEV), "off"); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_NCPDPATH)); - ncpdPath = config->readEntry(pcfg.getOptionName( - KPsionConfig::OPT_NCPDPATH), "ncpd"); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALSPEED)); - ncpdSpeed = config->readEntry( - pcfg.getOptionName(KPsionConfig::OPT_SERIALSPEED), "115200"); - - QWhatsThis::add(view, i18n( - "Here, you see your Psion's drives.
" - "Every drive is represented by an Icon. If you " - "click on it, it gets selected for the next " - "operation. E.g.: backup, restore or format.
" - "To unselect it, simply click on it again.
" - "Select as many drives a you want, then choose " - "an operation.
")); - setCentralWidget(view); - - rfsvSocket = 0L; - rpcsSocket = 0L; - plpRfsv = 0L; - plpRpcs = 0L; - - firstTry = true; - connected = false; - shuttingDown = false; - - args = KCmdLineArgs::parsedArgs(); - if (args->isSet("autobackup")) { - firstTry = false; - reconnectTime = 0; - } - tryConnect(); -} - -KPsionMainWindow::~KPsionMainWindow() { - shuttingDown = true; - if (plpRfsv) - delete plpRfsv; - if (plpRpcs) - delete plpRpcs; - if (rfsvSocket) - delete rfsvSocket; - if (rfsvSocket) - delete rpcsSocket; -} - -QString KPsionMainWindow:: -unix2psion(const char * const path) { - QString tmp = path; - tmp.replace(QRegExp("/"), "\\"); - tmp.replace(QRegExp("%2f"), "/"); - tmp.replace(QRegExp("%25"), "%"); - return tmp; -} - -QString KPsionMainWindow:: -psion2unix(const char * const path) { - QString tmp = path; - tmp.replace(QRegExp("%"), "%25"); - tmp.replace(QRegExp("/"), "%2f"); -#if QT_VERSION >= 300 - tmp.replace(QRegExp("\\\\"), "/"); -#else - tmp.replace(QRegExp("\\"), "/"); -#endif - return tmp; -} - -void KPsionMainWindow:: -setupActions() { - - KStdAction::quit(this, SLOT(close()), actionCollection()); - KStdAction::showToolbar(this, SLOT(slotToggleToolbar()), - actionCollection()); - KStdAction::showStatusbar(this, SLOT(slotToggleStatusbar()), - actionCollection()); - KStdAction::preferences(this, SLOT(slotPreferences()), - actionCollection()); - new KAction(i18n("Start &Format"), "psion_format", 0, this, - SLOT(slotStartFormat()), actionCollection(), "format"); - new KAction(i18n("Start Full &Backup"), "psion_backup", 0, this, - SLOT(slotStartFullBackup()), actionCollection(), - "fullbackup"); - new KAction(i18n("Start &Incremental Backup"), "psion_backup", 0, this, - SLOT(slotStartIncBackup()), actionCollection(), "incbackup"); - new KAction(i18n("Start &Restore"), "psion_restore", 0, this, - SLOT(slotStartRestore()), actionCollection(), "restore"); - createGUI(); - - actionCollection()->action("fullbackup")->setEnabled(false); - actionCollection()->action("incbackup")->setEnabled(false); - actionCollection()->action("restore")->setEnabled(false); - actionCollection()->action("format")->setEnabled(false); - - actionCollection()->action("fullbackup")-> - setToolTip(i18n("Full backup of selected drive(s)")); - actionCollection()->action("incbackup")-> - setToolTip(i18n("Incremental backup of selected drive(s)")); - actionCollection()->action("restore")-> - setToolTip(i18n("Restore selected drive(s)")); - actionCollection()->action("format")-> - setToolTip(i18n("Format selected drive(s)")); -} - -void KPsionMainWindow:: -iconOver(QIconViewItem *i) { - lastSelected = i->isSelected(); -} - -void KPsionMainWindow:: -switchActions() { - QIconViewItem *i; - bool rwSelected = false; - bool anySelected = false; - - if (backupRunning | restoreRunning | formatRunning) - view->setEnabled(false); - else { - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->isSelected()) { - anySelected = true; - if (i->key() != "Z") { - rwSelected = true; - break; - } - } - } - view->setEnabled(true); - } - actionCollection()->action("restore")->setEnabled(rwSelected); - actionCollection()->action("format")->setEnabled(rwSelected); - actionCollection()->action("fullbackup")->setEnabled(anySelected); - actionCollection()->action("incbackup")->setEnabled(anySelected); -} - -void KPsionMainWindow:: -iconClicked(QIconViewItem *i) { - if (i == 0L) - return; - lastSelected = !lastSelected; - i->setSelected(lastSelected); - switchActions(); -} - -void KPsionMainWindow:: -insertDrive(char letter, const char * const name) { - QString tmp; - - if (name && strlen(name)) - tmp = QString::fromLatin1("%1 (%2:)").arg(name).arg(letter); - else - tmp = QString::fromLatin1("%1:").arg(letter); - drives.insert(letter,tmp); - QIconViewItem *it = - new QIconViewItem(view, tmp, - KGlobal::iconLoader()->loadIcon("psion_drive", - KIcon::Desktop)); - tmp = QString::fromLatin1("%1").arg(letter); - it->setKey(tmp); - it->setDropEnabled(false); - it->setDragEnabled(false); - it->setRenameEnabled(false); -} - -bool KPsionMainWindow:: -shouldQuit() { - return quitImmediately; -} - -void KPsionMainWindow:: -syncTime(QString uid) { -} - -void KPsionMainWindow:: -queryPsion() { - u_int32_t devbits; - Enum res; - - statusBar()->changeItem(i18n("Retrieving machine info ..."), - STID_CONNECTION); - - Enum machType; - if (plpRpcs->getMachineType(machType) != rfsv::E_PSI_GEN_NONE) { - QString msg = i18n("Could not get Psion machine type"); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - if (machType == rpcs::PSI_MACH_S5) { - rpcs::machineInfo mi; - if ((res = plpRpcs->getMachineInfo(mi)) != rfsv::E_PSI_GEN_NONE) { - QString msg = i18n("Could not get Psion machine info"); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - machineUID = mi.machineUID; - S5mx = (strcmp(mi.machineName, "SERIES5mx") == 0); - } else { - // On a SIBO, first check for a file 'SYS$PT.CFG' on the default - // directory. If it exists, read the UID from it. Otherwise - // calculate a virtual machine UID from the OwnerInfo data and - // write it to that file. - bufferArray b; - u_int32_t handle; - u_int32_t count; - - res = plpRfsv->fopen(plpRfsv->opMode(rfsv::PSI_O_RDONLY), - "SYS$PT.CFG", handle); - if (res == rfsv::E_PSI_GEN_NONE) { - res = plpRfsv->fread(handle, (unsigned char *)&machineUID, - sizeof(machineUID), count); - plpRfsv->fclose(handle); - if ((res != rfsv::E_PSI_GEN_NONE) || (count != sizeof(machineUID))) { - QString msg = i18n("Could not read SIBO UID file"); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - } else { - if ((res = plpRpcs->getOwnerInfo(b)) != rfsv::E_PSI_GEN_NONE) { - QString msg = i18n("Could not get Psion owner info"); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - machineUID = 0; - std::string oi = ""; - while (!b.empty()) { - oi += b.pop().getString(); - oi += "\n"; - } - const char *p = oi.c_str(); - unsigned long long z; - int i = 0; - - while (*p) { - z = *p; - machineUID ^= (z << i); - p++; i++; - i &= ((sizeof(machineUID) * 8) - 1); - } - res = plpRfsv->fcreatefile(plpRfsv->opMode(rfsv::PSI_O_RDWR), - "SYS$PT.CFG", handle); - if (res == rfsv::E_PSI_GEN_NONE) { - res = plpRfsv->fwrite(handle, (const unsigned char *)&machineUID, - sizeof(machineUID), count); - plpRfsv->fclose(handle); - } - if (res != rfsv::E_PSI_GEN_NONE) { - QString msg = i18n("Could not write SIBO UID file %1").arg((const char *)res); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - } - S5mx = false; - } - - QString uid = getMachineUID(); - bool machineFound = false; - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDRIVES)); - QString tmp = pcfg.getOptionName(KPsionConfig::OPT_BACKUPDRIVES); - machineName = i18n("an unknown machine"); - psionMap::Iterator it; - for (it = machines.begin(); it != machines.end(); it++) { - if (uid == it.key()) { - machineName = it.data(); - backupDrives = config->readListEntry(tmp.arg(it.key())); - machineFound = true; - } - } - - drives.clear(); - statusBar()->changeItem(i18n("Retrieving drive list ..."), - STID_CONNECTION); - if ((res = plpRfsv->devlist(devbits)) != rfsv::E_PSI_GEN_NONE) { - QString msg = i18n("Could not get list of drives"); - statusBar()->changeItem(msg, STID_CONNECTION); - KMessageBox::error(this, msg); - return; - } - for (int i = 0; i < 26; i++) { - if ((devbits & 1) != 0) { - PlpDrive drive; - if (plpRfsv->devinfo('A' + i, drive) == rfsv::E_PSI_GEN_NONE) - insertDrive('A' + i, drive.getName().c_str()); - } - devbits >>= 1; - } - - if (!machineFound) { - if (args->isSet("autobackup")) { - connected = false; - if (plpRfsv) - delete plpRfsv; - if (plpRpcs) - delete plpRpcs; - if (rfsvSocket) - delete rfsvSocket; - if (rfsvSocket) - delete rpcsSocket; - quitImmediately = true; - return; - } - NewPsionWizard *wiz = new NewPsionWizard(this, "newpsionwiz"); - wiz->exec(); - } - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - - syncTime(uid); - - if (args->isSet("autobackup")) { - // Check, if scheduled backups to perform - - doScheduledBackup = false; - KPsionConfig pcfg; - QIconViewItem *i; - QStringList::Iterator it; - QDateTime d; - KConfig *config = kapp->config(); - QString uid = getMachineUID(); - QString key; - int fi = pcfg.getIntervalDays(config, KPsionConfig::OPT_FULLINTERVAL); - int ii = pcfg.getIntervalDays(config, KPsionConfig::OPT_INCINTERVAL); - - // Check for Full Backup - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_LASTFULL)); - for (it = backupDrives.begin(); it != backupDrives.end(); ++it) { - key = - pcfg.getOptionName(KPsionConfig::OPT_LASTFULL).arg(uid).arg(*it); - d.setTime_t(config->readNumEntry(key)); - - if (fi && d.daysTo(QDateTime::currentDateTime()) >= fi) { - fullBackup = true; - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == *it) { - i->setSelected(true); - doScheduledBackup = true; - } - } - } - } - if (!doScheduledBackup) { - // Check for Incremental Backup - fullBackup = false; - view->clearSelection(); - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_LASTINC)); - for (it = backupDrives.begin(); it != backupDrives.end(); ++it) { - key = - pcfg.getOptionName(KPsionConfig::OPT_LASTINC).arg(uid).arg(*it); - d.setTime_t(config->readNumEntry(key)); - if (ii && d.daysTo(QDateTime::currentDateTime()) >= ii) { - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == *it) { - i->setSelected(true); - doScheduledBackup = true; - } - } - } - } - } - if (!doScheduledBackup) { - quitImmediately = true; - return; - } - - } - if (doScheduledBackup || args->isSet("backup") || - args->isSet("restore") || args->isSet("format")) { - view->setEnabled(false); - actionCollection()->action("restore")->setEnabled(false); - actionCollection()->action("format")->setEnabled(false); - actionCollection()->action("fullbackup")->setEnabled(false); - actionCollection()->action("incbackup")->setEnabled(false); - QTimer::singleShot(1000, this, SLOT(slotAutoAction())); - } -} - -void KPsionMainWindow:: -slotAutoAction() { - QIconViewItem *i; - - if (doScheduledBackup) { - doBackup(); - QTimer::singleShot(1000, this, SLOT(close())); - return; - } - - if (args->isSet("backup")) { - bool any = false; - - QCStringList argl = args->getOptionList("backup"); - QCStringList::Iterator it; - - for (it = argl.begin(); it != argl.end(); ++it) { - i = 0L; - if ((*it).left(7) == "psion:/") { - QString volname((*it).mid(7)); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->text().startsWith(volname + " ")) - break; - } - } else { - QString drv((*it).upper()); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == drv) - break; - } - } - if (i) { - i->setSelected(true); - any = true; - } - } - if (any) { - fullBackup = true; - doBackup(); - } - QTimer::singleShot(1000, this, SLOT(close())); - return; - } - - if (args->isSet("restore")) { - bool any = false; - - QCStringList argl = args->getOptionList("restore"); - QCStringList::Iterator it; - - for (it = argl.begin(); it != argl.end(); ++it) { - i = 0L; - if ((*it).left(7) == "psion:/") { - QString volname((*it).mid(7)); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->text().startsWith(volname + " ")) - break; - } - } else { - QString drv((*it).upper()); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == drv) - break; - } - } - if (i) { - if (i->key() == "Z") { - KMessageBox::sorry(this, i18n( - "The selected drive Z: is " - "a ROM drive and therefore cannot be restored.")); - continue; - } - i->setSelected(true); - any = true; - } - } - if (any) - slotStartRestore(); - QTimer::singleShot(1000, this, SLOT(close())); - return; - } - - if (args->isSet("format")) { - bool any = false; - QCStringList argl = args->getOptionList("format"); - QCStringList::Iterator it; - - for (it = argl.begin(); it != argl.end(); ++it) { - i = 0L; - if ((*it).left(7) == "psion:/") { - QString volname((*it).mid(7)); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->text().startsWith(volname + " ")) - break; - } - } else { - QString drv((*it).upper()); - for (i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == drv) - break; - } - } - if (i) { - if (i->key() == "Z") { - KMessageBox::sorry(this, i18n( - "The selected drive Z: is " - "a ROM drive and therefore cannot be formatted.")); - continue; - } - i->setSelected(true); - any = true; - } - } - if (any) - slotStartFormat(); - QTimer::singleShot(1000, this, SLOT(close())); - return; - } - QTimer::singleShot(1000, this, SLOT(close())); -} - -QString KPsionMainWindow:: -getMachineUID() { - // ??! None of QString's formatting methods knows about long long. - char tmp[20]; - sprintf(tmp, "%16llx", machineUID); - return QString(tmp); -} - -bool KPsionMainWindow:: -queryClose() { - QString msg = 0L; - - if (backupRunning) - msg = i18n("A backup is running.\nDo you really want to quit?"); - if (restoreRunning) - msg = i18n("A restore is running.\nDo you really want to quit?"); - if (formatRunning) - msg = i18n("A format is running.\nDo you really want to quit?"); - - if ((!msg.isNull()) && - (KMessageBox::warningYesNo(this, msg) == KMessageBox::No)) - return false; - return true; -} - -void KPsionMainWindow:: -startupNcpd() { - if (ncpdDevice == "off") - return; - KProcess proc; - ppsocket *testSocket; - time_t start_time = time(0L) + 2; - bool connectOk = false; - - testSocket = new ppsocket(); - if (!testSocket->connect(NULL, 7501)) { - - statusBar()->changeItem(i18n("Starting ncpd daemon ..."), - STID_CONNECTION); - proc << ncpdPath; - proc << "-s" << ncpdDevice << "-b" << ncpdSpeed; - proc.start(KProcess::DontCare); - while ((time(0L) < start_time) && - (!(connectOk = testSocket->connect(NULL, 7501)))) - kapp->processEvents(); - } - delete testSocket; - if (connectOk) { - // 2 more seconds for ncpd to negotiate with the Psion. - start_time = time(0L) + 2; - while (time(0L) < start_time) - kapp->processEvents(); - } -} - -void KPsionMainWindow:: -tryConnect() { - if (shuttingDown || connected) - return; - bool showMB = firstTry; - firstTry = false; - - if (plpRfsv) - delete plpRfsv; - if (plpRpcs) - delete plpRpcs; - if (rfsvSocket) - delete rfsvSocket; - if (rfsvSocket) - delete rpcsSocket; - - startupNcpd(); - rfsvSocket = new ppsocket(); - statusBar()->changeItem(i18n("Connecting ..."), STID_CONNECTION); - if (!rfsvSocket->connect(NULL, 7501)) { - if (args->isSet("autobackup")) { - quitImmediately = true; - return; - } - statusMsg = i18n("RFSV could not connect to ncpd at %1:%2. ").arg("localhost").arg(7501); - if (reconnectTime) { - nextTry = reconnectTime; - statusMsg += i18n(" (Retry in %1 seconds.)"); - QTimer::singleShot(1000, this, SLOT(slotUpdateTimer())); - - statusBar()->changeItem(statusMsg.arg(reconnectTime), - STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg.arg(reconnectTime)); - } else { - statusBar()->changeItem(statusMsg, STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg); - } - return; - } - rfsvfactory factory(rfsvSocket); - plpRfsv = factory.create(false); - if (plpRfsv == 0L) { - if (args->isSet("autobackup")) { - quitImmediately = true; - return; - } - statusMsg = i18n("RFSV could not establish link: %1.").arg(KGlobal::locale()->translate(factory.getError())); - delete rfsvSocket; - rfsvSocket = 0L; - if (reconnectTime) { - nextTry = reconnectTime; - statusMsg += i18n(" (Retry in %1 seconds.)"); - QTimer::singleShot(1000, this, SLOT(slotUpdateTimer())); - statusBar()->changeItem(statusMsg.arg(reconnectTime), - STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg.arg(reconnectTime)); - } else { - statusBar()->changeItem(statusMsg, STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg); - } - return; - } - - rpcsSocket = new ppsocket(); - if (!rpcsSocket->connect(NULL, 7501)) { - if (args->isSet("autobackup")) { - quitImmediately = true; - return; - } - statusMsg = i18n("RPCS could not connect to ncpd at %1:%2.").arg("localhost").arg(7501); - delete plpRfsv; - plpRfsv = 0L; - delete rfsvSocket; - rfsvSocket = 0L; - if (reconnectTime) { - nextTry = reconnectTime; - statusMsg += i18n(" (Retry in %1 seconds.)"); - QTimer::singleShot(1000, this, SLOT(slotUpdateTimer())); - statusBar()->changeItem(statusMsg.arg(reconnectTime), - STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg.arg(reconnectTime)); - } else { - statusBar()->changeItem(statusMsg, STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg); - } - return; - } - rpcsfactory factory2(rpcsSocket); - plpRpcs = factory2.create(false); - if (plpRpcs == 0L) { - if (args->isSet("autobackup")) { - quitImmediately = true; - return; - } - statusMsg = i18n("RPCS could not establish link: %1.").arg(KGlobal::locale()->translate(factory2.getError())); - delete plpRfsv; - plpRfsv = 0L; - delete rfsvSocket; - rfsvSocket = 0L; - delete rpcsSocket; - rpcsSocket = 0L; - if (reconnectTime) { - nextTry = reconnectTime; - statusMsg += i18n(" (Retry in %1 seconds.)"); - QTimer::singleShot(1000, this, SLOT(slotUpdateTimer())); - statusBar()->changeItem(statusMsg.arg(reconnectTime), - STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg.arg(reconnectTime)); - } else { - statusBar()->changeItem(statusMsg, STID_CONNECTION); - if (showMB) - KMessageBox::error(this, statusMsg); - } - return; - } - connected = true; - queryPsion(); -} - -void KPsionMainWindow:: -slotUpdateTimer() { - nextTry--; - if (nextTry <= 0) - tryConnect(); - else { - statusBar()->changeItem(statusMsg.arg(nextTry), STID_CONNECTION); - QTimer::singleShot(1000, this, SLOT(slotUpdateTimer())); - } -} - -void KPsionMainWindow:: -slotProgressBarPressed() { -} - -void KPsionMainWindow:: -slotStartFullBackup() { - fullBackup = true; - doBackup(); -} - -void KPsionMainWindow:: -slotStartIncBackup() { - fullBackup = false; - doBackup(); -} - -const KTarEntry *KPsionMainWindow:: -findTarEntry(const KTarEntry *te, QString path, QString rpath) { - const KTarEntry *fte = NULL; - if (te->isDirectory() && (path.left(rpath.length()) == rpath)) { - KTarDirectory *td = (KTarDirectory *)te; - QStringList files = td->entries(); - for (QStringList::Iterator f = files.begin(); f != files.end(); f++) { - QString tmp = rpath; - if (tmp.length()) - tmp += "/"; - tmp += *f; - fte = findTarEntry(td->entry(*f), path, tmp); - if (fte != 0L) - break; - } - } else { - if (path == rpath) - fte = te; - } - return fte; -} - -void KPsionMainWindow:: -updateBackupStamps() { - KConfig *config = kapp->config(); - KPsionConfig pcfg; - QString uid = getMachineUID(); - int cfgBtype = (fullBackup) - ? KPsionConfig::OPT_LASTFULL : KPsionConfig::OPT_LASTINC; - - config->setGroup(pcfg.getSectionName(cfgBtype)); - for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { - QString key = pcfg.getOptionName(cfgBtype).arg(uid).arg(i->key()); - if (i->isSelected()) - config->writeEntry(key, time(0)); - } -} - -void KPsionMainWindow:: -doBackup() { - backupRunning = true; - switchActions(); - QStringList processDrives; - toBackup.clear(); - - // Collect list of files to backup - backupSize = 0; - backupCount = 0; - progressTotal = 0; - emit enableProgressText(true); - emit setProgress(0); - for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { - if (i->isSelected()) { - QString drv = i->key(); - drv += ":"; - int drvChar = drv[0].latin1(); - PlpDrive drive; - if (plpRfsv->devinfo(drvChar, drive) != rfsv::E_PSI_GEN_NONE) { - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - emit enableProgressText(false); - emit setProgress(0); - KMessageBox::error(this, i18n("Could not retrieve drive details for drive %1").arg(drv)); - backupRunning = false; - switchActions(); - return; - } - emit setProgressText(i18n("Scanning drive %1").arg(drv)); - - progressLocal = drive.getSize() - drive.getSpace(); - progressLocalCount = 0; - progressLocalPercent = -1; - progress->setValue(0); - collectFiles(drv); - processDrives += drv; - } - } - emit setProgressText(i18n("%1 files need backup").arg(backupSize)); - if (backupCount == 0) { - emit enableProgressText(false); - emit setProgress(0); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - updateBackupStamps(); - if (!args->isSet("autobackup")) - KMessageBox::information(this, i18n("No files need backup")); - backupRunning = false; - switchActions(); - return; - } - - progressCount = 0; - progressTotal = backupSize; - progressPercent = -1; - - // Create tgz with index file. - QString archiveName = backupDir; - if (archiveName.right(1) != "/") - archiveName += "/"; - archiveName += getMachineUID(); - QDir archiveDir(archiveName); - if (!archiveDir.exists()) - if (!archiveDir.mkdir(archiveName)) { - emit enableProgressText(false); - emit setProgress(0); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - KMessageBox::error(this, i18n("Could not create backup folder %1").arg(archiveName)); - backupRunning = false; - switchActions(); - return; - } - - archiveName += (fullBackup) ? "/F-" : "/I-"; - time_t now = time(0); - char tstr[30]; - strftime(tstr, sizeof(tstr), "%Y-%m-%d-%H-%M-%S.tmp.gz", - localtime(&now)); - archiveName += tstr; - backupTgz = new KTar(archiveName, "application/x-gzip"); - backupTgz->open(IO_WriteOnly); - createIndex(); - - // Kill all running applications on the Psion - // and save their state. - killSave(); - - bool badBackup = false; - Enum res; - // Now the real backup - progressTotalText = i18n("Backup %1% done"); - for (int i = 0; i < toBackup.size(); i++) { - PlpDirent e = toBackup[i]; - const char *fn = e.getName(); - QByteArray ba; - QDataStream os(ba, IO_WriteOnly); - - emit setProgressText(QString("%1").arg(fn)); - progressLocal = e.getSize(); - progressLocalCount = 0; - progressLocalPercent = -1; - emit setProgress(0); - - u_int32_t handle; - - kapp->processEvents(); - bool tryLoop = true; - do { - res = plpRfsv->fopen(plpRfsv->opMode(rfsv::PSI_O_RDONLY), fn, - handle); - if (res == rfsv::E_PSI_GEN_NONE) { - unsigned char *buff = new unsigned char[RFSV_SENDLEN]; - u_int32_t len; - do { - if ((res = plpRfsv->fread(handle, buff, RFSV_SENDLEN, - len)) == rfsv::E_PSI_GEN_NONE) { - os.writeRawBytes((char *)buff, len); - updateProgress(len); - } - } while ((len > 0) && (res == rfsv::E_PSI_GEN_NONE)); - delete[]buff; - plpRfsv->fclose(handle); - } - if (res != rfsv::E_PSI_GEN_NONE) { - switch (KMessageBox::warningYesNoCancel( - this, i18n( - "Could not backup
%1
" - "%2
" - ).arg(fn).arg((const char *)res), - QString::null, i18n("Retry"), i18n("Ignore"))) { - case KMessageBox::Cancel: - badBackup = true; - tryLoop = false; - break; - case KMessageBox::No: - e.setName("!"); - tryLoop = false; - break; - case KMessageBox::Yes: - break; - } - } else { - tryLoop = false; - } - } while (tryLoop); - if (badBackup) - break; - if (res != rfsv::E_PSI_GEN_NONE) - continue; - backupTgz->writeFile(psion2unix(fn), "root", "root", ba.size(), - ba.data()); - } - - if (!badBackup) { - // Reset archive attributes of all backuped files. - emit setProgressText(i18n("Resetting archive attributes")); - progressLocal = backupSize; - progressLocalCount = 0; - progressLocalPercent = -1; - emit setProgress(0); - kapp->processEvents(); - progressTotal = 0; - for (int i = 0; i < toBackup.size(); i++) { - PlpDirent e = toBackup[i]; - const char *fn = e.getName(); - if ((e.getAttr() & rfsv::PSI_A_ARCHIVE) && - (strcmp(fn, "!") != 0)) { - kapp->processEvents(); - res = plpRfsv->fsetattr(fn, 0, rfsv::PSI_A_ARCHIVE); - if (res != rfsv::E_PSI_GEN_NONE) { - if (KMessageBox::warningYesNo(this, i18n("Could not set attributes of
%1
%2
Continue?
").arg(fn)) == KMessageBox::No) { - break; - } - } - } - updateProgress(e.getSize()); - } - updateBackupStamps(); - } - // Restart previously running applications on the Psion - // from saved state info. - runRestore(); - - backupTgz->close(); - delete backupTgz; - emit enableProgressText(false); - emit setProgress(0); - - if (badBackup) - ::unlink(archiveName.latin1()); - else { - QString newName = archiveName; - newName.replace(QRegExp("\\.tmp\\.gz$"), ".tar.gz"); - // Rename Tarfile to its final name; - if (::rename(archiveName.latin1(), newName.latin1()) != 0) - KMessageBox::sorry(this, i18n("Could not rename backup archive from
%1 to
%2
").arg(archiveName).arg(newName)); - else - removeOldBackups(processDrives); - } - - backupRunning = false; - switchActions(); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - emit enableProgressText(false); - emit setProgress(0); - statusBar()->message(i18n("Backup done"), 2000); -} - -class Barchive { -public: - Barchive() - : n(""), d(0) {} - Barchive(const QString &name, time_t date) - : n(name), d(date) {} - - QString name() const { return n; } - time_t date() const { return d; } - bool operator==(const Barchive &a) { return (a.n == n); } -private: - QString n; - time_t d; -}; - -typedef QValueListArchList; - -void KPsionMainWindow:: -removeOldBackups(QStringList &drives) { - - if (!fullBackup) - return; - - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPGEN)); - int bgen = config->readNumEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPGEN)); - - if (bgen == 0) - return; - - statusBar()->changeItem(i18n("Removing old backups ..."), STID_CONNECTION); - QString bdir(backupDir); - bdir += "/"; - bdir += getMachineUID(); - QDir d(bdir); - kapp->processEvents(); - const QFileInfoList *fil = - d.entryInfoList("*.tar.gz", QDir::Files|QDir::Readable, QDir::Name); - QFileInfoListIterator it(*fil); - QFileInfo *fi; - ArchList alist; - - // Build a list of full-backups sorted by date - while ((fi = it.current())) { - kapp->processEvents(); - - KTar tgz(fi->absFilePath()); - const KTarEntry *te; - - tgz.open(IO_ReadOnly); - te = tgz.directory()->entry("KPsionFullIndex"); - if (te && (!te->isDirectory())) { - for (QStringList::Iterator d = drives.begin(); d != drives.end(); - d++) { - const KTarEntry *de = tgz.directory()->entry(*d); - if (de && (de->isDirectory())) { - Barchive a(tgz.fileName(), te->date()); - if (!alist.contains(a)) { - if (alist.isEmpty() || (alist.first().date()>te->date())) - alist.prepend(a); - else - alist.append(a); - } - } - } - } - tgz.close(); - ++it; - } - - // Remove entries from the beginning of the list if there are more than - // bgen entries. This leaves at most bgen of the youngest backups in the - // list. - while (alist.count() > bgen) { - Barchive r = alist.first(); - alist.remove(r); - } - - // Finally iterate over all backups and delete those which are older - // than the first entry in alist. - - (void)it.toFirst(); - - while ((fi = it.current())) { - kapp->processEvents(); - - KTar tgz(fi->absFilePath()); - const KTarEntry *te; - bool valid = false; - bool del = false; - - tgz.open(IO_ReadOnly); - te = tgz.directory()->entry("KPsionFullIndex"); - if (te && (!te->isDirectory())) - valid = true; - else { - te = tgz.directory()->entry("KPsionIncrementalIndex"); - if (te && (!te->isDirectory())) - valid = true; - } - if (valid) { - Barchive a(tgz.fileName(), te->date()); - if (alist.isEmpty() || - ((!alist.contains(a)) && (te->date() < alist.first().date()))) - del = true; - } - tgz.close(); - if (del) - ::remove(fi->absFilePath().data()); - ++it; - } -} - -bool KPsionMainWindow:: -askOverwrite(PlpDirent e) { - if (overWriteAll) - return true; - const char *fn = e.getName(); - if (overWriteList.contains(QString(fn))) - return true; - PlpDirent old; - Enum res = plpRfsv->fgeteattr(fn, old); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not get attributes of
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - return false; - } - - // Don't ask if size and attribs are same - if ((old.getSize() == e.getSize()) && - ((old.getAttr() & ~rfsv::PSI_A_ARCHIVE) == - (e.getAttr() & ~rfsv::PSI_A_ARCHIVE))) - return true; - - QDateTime odate; - QDateTime ndate; - - odate.setTime_t(old.getPsiTime().getTime()); - ndate.setTime_t(e.getPsiTime().getTime()); - - // Dates - QString od = KGlobal::locale()->formatDateTime(odate, false); - QString nd = KGlobal::locale()->formatDateTime(ndate, false); - - // Sizes - QString os = QString("%1 (%2)").arg(KIO::convertSize(old.getSize())).arg(KGlobal::locale()->formatNumber(old.getSize(), 0)); - QString ns = QString("%1 (%2)").arg(KIO::convertSize(e.getSize())).arg(KGlobal::locale()->formatNumber(e.getSize(), 0)); - - // Attributes - QString oa(plpRfsv->attr2String(old.getAttr()).c_str()); - QString na(plpRfsv->attr2String(e.getAttr()).c_str()); - - KDialogBase dialog(i18n("Overwrite"), KDialogBase::Yes | KDialogBase::No | - KDialogBase::Cancel, KDialogBase::No, - KDialogBase::Cancel, this, "overwriteDialog", true, true, - QString::null, QString::null, i18n("Overwrite &All")); - - QWidget *contents = new QWidget(&dialog); - QHBoxLayout * lay = new QHBoxLayout(contents); - lay->setSpacing(KDialog::spacingHint()*2); - lay->setMargin(KDialog::marginHint()*2); - - lay->addStretch(1); - QLabel *label1 = new QLabel(contents); - -#if (QT_VERSION >= 300) - label1->setPixmap(kapp->style().stylePixmap( - kapp->style().SP_MessageBoxWarning)); -#else - label1->setPixmap(QMessageBox::standardIcon(QMessageBox::Warning, - kapp->style().guiStyle())); -#endif - lay->add(label1); - lay->add(new QLabel(i18n( - "The file %1 exists already on the Psion with " - "different size and/or attributes." - "

On the Psion:
" - " Size: %2
" - " Date: %3
" - " Attributes: %4

" - "

In backup:
" - " Size: %5
" - " Date: %6
" - " Attributes: %7

" - "Do you want to overwrite it?
").arg(fn).arg(os).arg(od).arg(oa).arg(ns).arg(nd).arg(na), contents)); - lay->addStretch(1); - - dialog.setMainWidget(contents); - dialog.enableButtonSeparator(false); - - int result = dialog.exec(); - switch (result) { - case KDialogBase::Yes: - return true; - case KDialogBase::No: - return false; - case KDialogBase::Cancel: - overWriteAll = true; - return true; - default: // Huh? - break; - } - - return false; // Default -} - -void KPsionMainWindow:: -slotStartRestore() { - restoreRunning = true; - switchActions(); - - kapp->setOverrideCursor(Qt::waitCursor); - statusBar()->changeItem(i18n("Reading backups ..."), STID_CONNECTION); - update(); - kapp->processEvents(); - KPsionRestoreDialog restoreDialog(this, getMachineUID()); - kapp->restoreOverrideCursor(); - statusBar()->changeItem(i18n("Selecting backups ..."), STID_CONNECTION); - - for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { - if (i->isSelected() && (i->key() != "Z")) - restoreDialog.autoSelect(i->key()); - } - - overWriteList.clear(); - overWriteAll = false; - - if (restoreDialog.exec() == KDialogBase::Accepted) { - QStringList tars = restoreDialog.getSelectedTars(); - QStringList fmtDrives = restoreDialog.getFormatDrives(); - QStringList::Iterator t; - - backupSize = 0; - backupCount = 0; - for (t = tars.begin(); t != tars.end(); t++) { - PlpDir toRestore = restoreDialog.getRestoreList(*t); - for (int r = 0; r < toRestore.size(); r++) { - PlpDirent e = toRestore[r]; - backupSize += e.getSize(); - backupCount++; - } - } - if (backupCount == 0) { - restoreRunning = false; - switchActions(); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - return; - } - - progressTotalText = i18n("Restore %1% done"); - progressTotal = backupSize; - progressCount = 0; - progressPercent = -1; - emit setProgressText(""); - emit enableProgressText(true); - emit setProgress(0); - - // Kill all running applications on the Psion - // and save their state. - killSave(); - - for (t = tars.begin(); t != tars.end(); t++) { - PlpDir toRestore = restoreDialog.getRestoreList(*t); - if (toRestore.size() > 0) { - KTar tgz(*t); - const KTarEntry *te; - QString pDir(""); - - tgz.open(IO_ReadOnly); - for (int r = 0; r < toRestore.size(); r++) { - PlpDirent e = toRestore[r]; - PlpDirent olde; - - const char *fn = e.getName(); - Enum res; - - progressLocal = e.getSize(); - progressLocalCount = 0; - progressLocalPercent = -1; - emit setProgressText(QString("%1").arg(fn)); - emit setProgress(0); - - te = findTarEntry(tgz.directory(), psion2unix(fn)); - if (te != 0L) { - u_int32_t handle; - QString cpDir(fn); - QByteArray ba = ((KTarFile *)te)->data(); - int bslash = cpDir.findRev('\\'); - if (bslash > 0) - cpDir = cpDir.left(bslash); - - QString drv = cpDir.left(1); - if (fmtDrives.find(drv) != fmtDrives.end()) { - int tSave = progressCount; - doFormat(drv); - fmtDrives.remove(drv); - progressTotalText = i18n("Restore %1% done"); - progressTotal = backupSize; - progressCount = tSave; - progressLocal = e.getSize(); - progressLocalCount = 0; - progressLocalPercent = -1; - emit setProgressText(QString("%1").arg(fn)); - emit enableProgressText(true); - emit setProgress(0); - } - if (pDir != cpDir) { - pDir = cpDir; - res = plpRfsv->mkdir(pDir); - if ((res != rfsv::E_PSI_GEN_NONE) && - (res != rfsv::E_PSI_FILE_EXIST)) { - KMessageBox::error(this, i18n( - "Could not create directory
" - "%1
Reason: %2
").arg(pDir).arg(KGlobal::locale()->translate(res))); - continue; - } - } - res = plpRfsv->fcreatefile( - plpRfsv->opMode(rfsv::PSI_O_RDWR), fn, handle); - if (res == rfsv::E_PSI_FILE_EXIST) { - if (!askOverwrite(e)) - continue; - res = plpRfsv->freplacefile( - plpRfsv->opMode(rfsv::PSI_O_RDWR), fn, handle); - } - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not create
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - continue; - } - const unsigned char *data = - (const unsigned char *)(ba.data()); - long len = ba.size(); - - do { - u_int32_t written; - u_int32_t count = - (len > RFSV_SENDLEN) ? RFSV_SENDLEN : len; - res = plpRfsv->fwrite(handle, data, count, written); - if (res != rfsv::E_PSI_GEN_NONE) - break; - len -= written; - data += written; - updateProgress(written); - } while (len > 0); - plpRfsv->fclose(handle); - - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not write to
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - continue; - } - u_int32_t oldattr; - res = plpRfsv->fgetattr(fn, oldattr); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not get attributes of
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - continue; - } - u_int32_t mask = e.getAttr() ^ oldattr; - u_int32_t sattr = e.getAttr() & mask; - u_int32_t dattr = ~sattr & mask; - int retry = 10; - // Retry, because file somtimes takes some time - // to close; - do { - res = plpRfsv->fsetattr(fn, sattr, dattr); - if (res != rfsv::E_PSI_GEN_NONE) - usleep(100000); - retry--; - } while ((res != rfsv::E_PSI_GEN_NONE) && (retry > 0)); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not set attributes of
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - continue; - } - retry = 10; - do { - res = plpRfsv->fsetmtime(fn, e.getPsiTime()); - if (res != rfsv::E_PSI_GEN_NONE) - usleep(100000); - retry--; - } while ((res != rfsv::E_PSI_GEN_NONE) && (retry > 0)); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not set modification time of
" - "%1
Reason: %2
").arg(fn).arg(KGlobal::locale()->translate(res))); - continue; - } - overWriteList += QString(fn); - } - } - tgz.close(); - } - } - // Restart previously running applications on the Psion - // from saved state info. - runRestore(); - } else { - restoreRunning = false; - switchActions(); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - return; - } - - restoreRunning = false; - switchActions(); - emit setProgress(0); - emit enableProgressText(false); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - statusBar()->message(i18n("Restore done"), 2000); -} - -void KPsionMainWindow:: -doFormat(QString drive) { - int handle; - int count; - const char dchar = drive[0].latin1(); - QString dname(""); - - PlpDrive drv; - if (plpRfsv->devinfo(dchar, drv) == rfsv::E_PSI_GEN_NONE) - dname = QString(drv.getName().c_str()); - - statusBar()->changeItem(i18n("Formatting drive %1:").arg(dchar), - STID_CONNECTION); - update(); - - emit setProgressText(QString("")); - emit setProgress(0); - emit enableProgressText(true); - - Enum res = plpRpcs->formatOpen(dchar, handle, count); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Could not format drive %1:
" - "%2
").arg(dchar).arg(KGlobal::locale()->translate(res))); - emit setProgress(0); - emit enableProgressText(false); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - return; - } - progressTotal = 0; - progressLocal = count; - progressLocalCount = 0; - progressLocalPercent = -1; - updateProgress(0); - for (int i = 0; i < count; i++) { - res = plpRpcs->formatRead(handle); - if (res != rfsv::E_PSI_GEN_NONE) { - KMessageBox::error(this, i18n( - "Error during format of drive %1:
" - "%2
").arg(dchar).arg(KGlobal::locale()->translate(res))); - emit setProgress(0); - emit enableProgressText(false); - statusBar()->changeItem( - i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - count = 0; - return; - } - updateProgress(1); - } - setDriveName(dchar, dname); - - emit setProgress(0); - emit enableProgressText(false); - statusBar()->changeItem(i18n("Connected to %1").arg(machineName), - STID_CONNECTION); - statusBar()->message(i18n("Format done"), 2000); -} - -void KPsionMainWindow:: -slotStartFormat() { - if (KMessageBox::warningYesNo(this, i18n( - "This erases ALL data " - "on the drive(s).
Do you really " - "want to proceed?" - )) == KMessageBox::No) - return; - formatRunning = true; - switchActions(); - killSave(); - - for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { - if (i->isSelected() && (i->key() != "Z")) - doFormat(i->key()); - } - - runRestore(); - formatRunning = false; - switchActions(); -} - -void KPsionMainWindow:: -setDriveName(const char dchar, QString dname) { - KDialogBase dialog(this, "drivenameDialog", true, i18n("Assign drive name"), - KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, - true); - - QWidget *w = new QWidget(&dialog); - QGridLayout *gl = new QGridLayout(w, 1, 1, KDialog::marginHint()*2, - KDialog::spacingHint()*2); - - QLabel *l = new QLabel(i18n( - "Formatting of drive %1: finished. Please assign a name for " - "that drive.").arg(dchar), w); - gl->addMultiCellWidget(l, 0, 0, 0, 1); - - l = new QLabel(i18n("New name of drive %1:").arg(dchar), w); - gl->addWidget(l, 1, 0); - - KLineEdit *e = new KLineEdit(dname, w, "nameEntry"); - gl->addWidget(e, 1, 1); - - gl->setColStretch(1, 1); - dialog.setMainWidget(w); - - int result = dialog.exec(); - QString newname = QString("%1:").arg(dchar); - QString dstr; - dstr = dchar; - - switch (result) { - case QDialog::Accepted: - if (!e->text().isEmpty()) { - Enum res; - res = plpRfsv->setVolumeName(dchar, e->text()); - if (res == rfsv::E_PSI_GEN_NONE) - newname = QString("%1 (%2:)").arg(e->text()).arg(dchar); - } - drives.replace(dchar, newname); - for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { - if (i->key() == dstr) { - i->setText(newname); - break; - } - } - emit rearrangeIcons(true); - break; - default: // Huh? - break; - } -} - -void KPsionMainWindow:: -slotToggleToolbar() { - if (toolBar()->isVisible()) - toolBar()->hide(); - else - toolBar()->show(); -} - -void KPsionMainWindow:: -slotToggleStatusbar() { - if (statusBar()->isVisible()) - statusBar()->hide(); - else - statusBar()->show(); -} - -void KPsionMainWindow:: -slotSaveOptions() { -} - -void KPsionMainWindow:: -slotPreferences() { - SetupDialog d(this, plpRfsv, plpRpcs); - d.exec(); -} - -void KPsionMainWindow:: -updateProgress(unsigned long amount) { - progressLocalCount += amount; - int lastPercent = progressLocalPercent; - if (progressLocal) - progressLocalPercent = progressLocalCount * 100 / progressLocal; - else - progressLocalPercent = 100; - if (progressLocalPercent != lastPercent) - emit setProgress(progressLocalPercent); - if (progressTotal > 0) { - progressCount += amount; - lastPercent = progressPercent; - if (progressTotal) - progressPercent = progressCount * 100 / progressTotal; - else - progressPercent = 100; - if (progressPercent != lastPercent) - statusBar()->changeItem(progressTotalText.arg(progressPercent), - STID_CONNECTION); - } - kapp->processEvents(); -} - -void KPsionMainWindow:: -collectFiles(QString dir) { - Enum res; - PlpDir files; - QString tmp = dir; - - kapp->processEvents(); - tmp += "\\"; - if ((res = plpRfsv->dir(tmp.data(), files)) != rfsv::E_PSI_GEN_NONE) { - // messagebox "Couldn't get directory ...." - } else - for (int i = 0; i < files.size(); i++) { - PlpDirent e = files[i]; - - - long attr = e.getAttr(); - tmp = dir; - tmp += "\\"; - tmp += e.getName(); - if (attr & rfsv::PSI_A_DIR) { - collectFiles(tmp); - } else { - updateProgress(e.getSize()); - if ((attr & rfsv::PSI_A_ARCHIVE) || fullBackup) { - backupCount++; - backupSize += e.getSize(); - e.setName(tmp.data()); - toBackup.push_back(e); - } - } - } -} - -void KPsionMainWindow:: -killSave() { - Enum res; - processList tmp; - - savedCommands.clear(); - if ((res = plpRpcs->queryPrograms(tmp)) != rfsv::E_PSI_GEN_NONE) { - cerr << "Could not get process list, Error: " << res << endl; - return; - } else { - for (processList::iterator i = tmp.begin(); i != tmp.end(); i++) { - savedCommands += i->getArgs(); - emit setProgressText(i18n("Stopping %1").arg(i->getName())); - kapp->processEvents(); - plpRpcs->stopProgram(i->getProcId()); - } - } - time_t tstart = time(0) + 5; - while (true) { - kapp->processEvents(); - usleep(100000); - kapp->processEvents(); - if ((res = plpRpcs->queryPrograms(tmp)) != rfsv::E_PSI_GEN_NONE) { - cerr << "Could not get process list, Error: " << res << endl; - return; - } - if (tmp.empty()) - break; - if (time(0) > tstart) { - KMessageBox::error(this, i18n( - "Could not stop all processes.
" - "Please stop running programs manually on the Psion, " - "then click Ok.")); - tstart = time(0) + 5; - } - } - return; -} - -void KPsionMainWindow:: -runRestore() { - Enum res; - - for (QStringList::Iterator it = savedCommands.begin(); it != savedCommands.end(); it++) { - int firstBlank = (*it).find(' '); - QString cmd = (*it).left(firstBlank); - QString arg = (*it).mid(firstBlank + 1); - - if (!cmd.isEmpty()) { - // Workaround for broken programs like Backlite. - // These do not storethe full program path. - // In that case we try running the arg1 which - // results in starting the program via recog. facility. - emit setProgressText(i18n("Starting %1").arg(cmd)); - kapp->processEvents(); - if ((arg.length() > 2) && (arg[1] == ':') && (arg[0] >= 'A') && - (arg[0] <= 'Z')) - res = plpRpcs->execProgram(arg.data(), ""); - else - res = plpRpcs->execProgram(cmd.data(), arg.data()); - if (res != rfsv::E_PSI_GEN_NONE) { - // If we got an error here, that happened probably because - // we have no path at all (e.g. Macro5) and the program is - // not registered in the Psion's path properly. Now try - // the ususal \System\Apps\\.app - // on all drives. - if (cmd.find('\\') == -1) { - driveMap::Iterator it; - for (it = drives.begin(); it != drives.end(); it++) { - QString newcmd = QString::fromLatin1("%1:\\System\\Apps\\%2\\%3").arg(it.key()).arg(cmd).arg(cmd); - res = plpRpcs->execProgram(newcmd.data(), ""); - if (res == rfsv::E_PSI_GEN_NONE) - break; - newcmd += ".app"; - res = plpRpcs->execProgram(newcmd.data(), ""); - if (res == rfsv::E_PSI_GEN_NONE) - break; - - } - } - } - } - } - return; -} - -void KPsionMainWindow:: -createIndex() { - QByteArray ba; - QTextOStream os(ba); - os << "#plpbackup index " << - (fullBackup ? "F" : "I") << endl; - for (int i = 0; i < toBackup.size(); i++) { - PlpDirent e = toBackup[i]; - PsiTime t = e.getPsiTime(); - long attr = e.getAttr() & - ~rfsv::PSI_A_ARCHIVE; -#if (QT_VERSION < 300) - os << hex - << setw(8) << setfill('0') << - t.getPsiTimeHi() << " " - << setw(8) << setfill('0') << - t.getPsiTimeLo() << " " - << setw(8) << setfill('0') << - e.getSize() << " " - << setw(8) << setfill('0') << - attr << " " - << setw(0) << e.getName() << endl; -#else - os << hex - << qSetW(8) << qSetFill('0') << - t.getPsiTimeHi() << " " - << qSetW(8) << qSetFill('0') << - t.getPsiTimeLo() << " " - << qSetW(8) << qSetFill('0') << - e.getSize() << " " - << qSetW(8) << qSetFill('0') << - attr << " " - << qSetW(0) << e.getName() << endl; -#endif - kapp->processEvents(); - } - QString idxName = - QString::fromLatin1("KPsion%1Index").arg(fullBackup ? - "Full" : "Incremental"); - backupTgz->writeFile(idxName, "root", "root", ba.size(), ba.data()); -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsion.desktop b/kde2/kpsion/kpsion.desktop deleted file mode 100644 index e29bb73..0000000 --- a/kde2/kpsion/kpsion.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -DocPath=kpsion/index.html -Exec=kpsion -Terminal=0 -Type=Application -Icon=psion_desktop -Comment=My Psion PDA -Comment[de]=Mein Psion -Name=KPsion -Name[de]=KPsion diff --git a/kde2/kpsion/kpsion.h b/kde2/kpsion/kpsion.h deleted file mode 100644 index 97a50dc..0000000 --- a/kde2/kpsion/kpsion.h +++ /dev/null @@ -1,164 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _KPSION_H_ -#define _KPSION_H_ - -#include -#include -#include - -// get KDE_VERSION -#include - -#include "setupdialog.h" -#include "statusbarprogress.h" -#include "kpsionrestoredialog.h" - -#include -#include -#include -#include - -typedef QMap driveMap; -typedef QMap psionMap; - -class KPsionMainWindow : public KMainWindow { - Q_OBJECT - -public: - KPsionMainWindow(); - ~KPsionMainWindow(); - void setMachineName(QString &_name) { machineName = _name; } - QString getMachineUID(); - driveMap &getDrives() { return drives; } - psionMap &getMachines() { return machines; } - QString &getMachineName() { return machineName; } - QString &getBackupDir() { return backupDir; } - bool isConnected() { return connected; } - const KTarEntry *findTarEntry(const KTarEntry *te, QString path, - QString rpath = ""); - bool shouldQuit(); - static QString unix2psion(const char * const); - static QString psion2unix(const char * const); - -signals: - void setProgress(int); - void setProgress(int, int); - void setProgressText(const QString &); - void enableProgressText(bool); - void rearrangeIcons(bool); - -public slots: - void slotStartRestore(); - void slotStartFullBackup(); - void slotStartIncBackup(); - void slotStartFormat(); - void slotToggleToolbar(); - void slotToggleStatusbar(); - void slotSaveOptions(); - void slotPreferences(); - void slotProgressBarPressed(); - -protected: - virtual bool queryClose(); - void setupActions(); - void switchActions(); - void queryPsion(); - void insertDrive(char letter, const char * const name); - -private slots: - void iconClicked(QIconViewItem *i); - void iconOver(QIconViewItem *i); - void slotUpdateTimer(); - void slotAutoAction(); - -private: - void doBackup(); - void tryConnect(); - void updateProgress(unsigned long); - void collectFiles(QString dir); - void killSave(); - void runRestore(); - void createIndex(); - bool askOverwrite(PlpDirent e); - void setDriveName(const char dchar, QString dname); - void doFormat(QString drive); - void updateBackupStamps(); - void startupNcpd(); - void removeOldBackups(QStringList &drives); - void syncTime(QString uid); - - rfsv *plpRfsv; - rpcs *plpRpcs; - ppsocket *rfsvSocket; - ppsocket *rpcsSocket; - SetupDialog *setupDialog; - KIconView *view; - KPsionStatusBarProgress *progress; - KTar *backupTgz; - KCmdLineArgs *args; - - driveMap drives; - psionMap machines; - QStringList overWriteList; - QStringList backupDrives; - QStringList savedCommands; - QString backupDir; - QString machineName; - QString statusMsg; - QString ncpdDevice; - QString ncpdSpeed; - QString ncpdPath; - QString progressTotalText; - bool S5mx; - bool backupRunning; - bool restoreRunning; - bool formatRunning; - bool lastSelected; - bool connected; - bool firstTry; - bool shuttingDown; - bool fullBackup; - bool doScheduledBackup; - bool overWriteAll; - bool quitImmediately; - int reconnectTime; - int nextTry; - unsigned long long machineUID; - PlpDir toBackup; - unsigned long backupSize; - unsigned long backupCount; - unsigned long progressTotal; - unsigned long progressLocal; - unsigned long progressCount; - unsigned long progressLocalCount; - int progressPercent; - int progressLocalPercent; -}; -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionbackuplistview.cpp b/kde2/kpsion/kpsionbackuplistview.cpp deleted file mode 100644 index 70bec21..0000000 --- a/kde2/kpsion/kpsionbackuplistview.cpp +++ /dev/null @@ -1,519 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999 Philip Proudman - * Copyright (C) 2000, 2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "kpsion.h" -#include "kpsionbackuplistview.h" -#include "kpsionconfig.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -class KPsionCheckListItem::KPsionCheckListItemMetaData { - friend class KPsionCheckListItem; - -private: - KPsionCheckListItemMetaData(); - ~KPsionCheckListItemMetaData() { }; - - bool parentIsKPsionCheckListItem; - bool dontPropagate; - bool gray; - int backupType; - int size; - time_t when; - u_int32_t timeHi; - u_int32_t timeLo; - u_int32_t attr; - QString name; -}; - -KPsionCheckListItem::KPsionCheckListItemMetaData::KPsionCheckListItemMetaData() { - when = 0; - size = 0; - timeHi = 0; - timeLo = 0; - attr = 0; - gray = false; - name = QString::null; - backupType = KPsionBackupListView::UNKNOWN; -} - -KPsionCheckListItem::~KPsionCheckListItem() { - delete meta; -} - -/** - * Must re-implement this since QT3 does not leave the expansion square - * enabled anymore if the item is disabled. - */ -void KPsionCheckListItem:: -paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align) -{ - QColorGroup tmp(cg); - if (meta->gray) - tmp.setColor(QColorGroup::Text, - listView()->palette().color(QPalette::Disabled, - QColorGroup::Text)); - else - tmp.setColor(QColorGroup::Text, - listView()->palette().color(QPalette::Normal, - QColorGroup::Text)); - QCheckListItem::paintCell(p, tmp, column, width, align); -} - -KPsionCheckListItem *KPsionCheckListItem:: -firstChild() const { - return (KPsionCheckListItem *)QListViewItem::firstChild(); -} - -KPsionCheckListItem *KPsionCheckListItem:: -nextSibling() const { - return (KPsionCheckListItem *)QListViewItem::nextSibling(); -} - -void KPsionCheckListItem:: -init(bool myparent) { - setSelectable(false); - meta = new KPsionCheckListItemMetaData(); - meta->dontPropagate = false; - meta->parentIsKPsionCheckListItem = myparent; -} - -void KPsionCheckListItem:: -setMetaData(int type, time_t when, QString name, int size, - u_int32_t tHi, u_int32_t tLo, u_int32_t attr) { - meta->backupType = type; - meta->when = when; - meta->name = name; - meta->size = size; - meta->timeHi = tHi; - meta->timeLo = tLo; - meta->attr = attr; -} - -void KPsionCheckListItem:: -stateChange(bool state) { - if (!state) - meta->gray = false; - QCheckListItem::stateChange(state); - if (meta->dontPropagate) - return; - if (meta->parentIsKPsionCheckListItem) - ((KPsionCheckListItem *)QListViewItem::parent())->propagateUp(state); - else - emit rootToggled(); - propagateDown(state); -} - -void KPsionCheckListItem:: -propagateDown(bool state) { - setOn(state); - KPsionCheckListItem *child = firstChild(); - while (child) { - child->meta->dontPropagate = true; - child->propagateDown(state); - child->meta->dontPropagate = false; - child = child->nextSibling(); - } -} - -void KPsionCheckListItem:: -propagateUp(bool state) { - bool makeGray = false; - - KPsionCheckListItem *child = firstChild(); - while (child) { - if (child->isOn() != state) { - makeGray = true; - break; - } - child = child->nextSibling(); - } - meta->dontPropagate = true; - if (makeGray) { - meta->gray = true; - setOn(true); - } else { - meta->gray = false; - setOn(state); - } - // Bug in QListView? It doesn't update, when - // enabled/disabled without activating. - // -> force it. - listView()->repaintItem(this); - meta->dontPropagate = false; - if (meta->parentIsKPsionCheckListItem) - ((KPsionCheckListItem *)QListViewItem::parent())->propagateUp(state); - else - emit rootToggled(); -} - -QString KPsionCheckListItem:: -key(int column, bool ascending) const { - if (meta->when) { - QString tmp; - tmp.sprintf("%08d", meta->when); - return tmp; - } - return text(); -} - -QString KPsionCheckListItem:: -psionname() { - if (meta->parentIsKPsionCheckListItem) - return meta->name; - else - return QString::null; -} - -QString KPsionCheckListItem:: -unixname() { - if (meta->parentIsKPsionCheckListItem) - return KPsionMainWindow::psion2unix(meta->name); - else - return QString::null; -} - -QString KPsionCheckListItem:: -tarname() { - if (meta->parentIsKPsionCheckListItem) - return ((KPsionCheckListItem *)QListViewItem::parent())->tarname(); - else - return meta->name; -} - -QString KPsionCheckListItem:: -psionpath() { - QString tmp = text(); - QCheckListItem *p = this; - while (p->depth() > 1) { - p = (QCheckListItem *)p->parent(); - tmp = p->text() + "/" + tmp; - } - return KPsionMainWindow::unix2psion(tmp); -} - -int KPsionCheckListItem:: -backupType() { - if (meta->parentIsKPsionCheckListItem) - return ((KPsionCheckListItem *)QListViewItem::parent())->backupType(); - else - return meta->backupType; -} - -time_t KPsionCheckListItem:: -when() { - if (meta->parentIsKPsionCheckListItem) - return ((KPsionCheckListItem *)QListViewItem::parent())->when(); - else - return meta->when; -} - -PlpDirent KPsionCheckListItem:: -plpdirent() { - assert(meta->parentIsKPsionCheckListItem); - return PlpDirent(meta->size, meta->attr, meta->timeHi, meta->timeLo, - meta->name); -} - -KPsionBackupListView::KPsionBackupListView(QWidget *parent, const char *name) - : KListView(parent, name) { - - toRestore.clear(); - uid = QString::null; - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - backupDir = config->readEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR)); - addColumn(i18n("Available backups")); - setRootIsDecorated(true); - setSorting(-1); -} - -KPsionCheckListItem *KPsionBackupListView:: -firstChild() const { - return (KPsionCheckListItem *)QListView::firstChild(); -} - -void KPsionBackupListView:: -readBackups(QString uid) { - QString bdir(backupDir); - bdir += "/"; - bdir += uid; - QDir d(bdir); - kapp->processEvents(); - const QFileInfoList *fil = - d.entryInfoList("*.tar.gz", QDir::Files|QDir::Readable, QDir::Time); - QFileInfoListIterator it(*fil); - QFileInfo *fi; - while ((fi = it.current())) { - kapp->processEvents(); - - bool isValid = false; -#if KDE_VERSION >= 300 - KTar tgz(fi->absFilePath()); -#else - KTarGz tgz(fi->absFilePath()); -#endif - const KTarEntry *te; - QString bTypeName; - int bType; - QDateTime date; - - tgz.open(IO_ReadOnly); - te = tgz.directory()->entry("KPsionFullIndex"); - if (te && (!te->isDirectory())) { - date.setTime_t(te->date()); - bTypeName = i18n("Full"); - bType = FULL; - isValid = true; - } else { - te = tgz.directory()->entry("KPsionIncrementalIndex"); - if (te && (!te->isDirectory())) { - date.setTime_t(te->date()); - bTypeName = i18n("Incremental"); - bType = INCREMENTAL; - isValid = true; - } - } - - if (isValid) { - QString n = i18n("%1 backup, created at %2").arg(bTypeName).arg(KGlobal::locale()->formatDateTime(date, false)); - QByteArray a = ((KTarFile *)te)->data(); - QTextIStream indexData(a); - - indexData.readLine(); - indexData.flags(QTextStream::hex); - indexData.fill('0'); - indexData.width(8); - - KPsionCheckListItem *i = - new KPsionCheckListItem(this, n, - KPsionCheckListItem::CheckBox); - i->setMetaData(bType, te->date(), tgz.fileName(), 0, 0, 0, 0); - i->setPixmap(0, KGlobal::iconLoader()->loadIcon("tgz", - KIcon::Small)); - connect(i, SIGNAL(rootToggled()), this, SLOT(slotRootToggled())); - - indexDataList_t idList; - while (!indexData.atEnd()) { - indexData_t id; - - indexData >> id.timeHi >> id.timeLo >> id.size >> id.attr; - id.name = indexData.readLine().mid(1); - idList.push_back(id); - } - - QStringList files = tgz.directory()->entries(); - for (QStringList::Iterator f = files.begin(); - f != files.end(); f++) - if ((*f != "KPsionFullIndex") && - (*f != "KPsionIncrementalIndex")) - listTree(i, tgz.directory()->entry(*f), idList, 0); - } - tgz.close(); - ++it; - } - header()->setClickEnabled(false); - header()->setResizeEnabled(false); - header()->setMovingEnabled(false); - setMinimumSize(columnWidth(0) + 4, height()); - QWhatsThis::add(this, i18n( - "Here, you can select the available backups." - " Select the items you want to restore, the click" - " on Start to start restoring these items." - "")); -} - -void KPsionBackupListView:: -listTree(KPsionCheckListItem *cli, const KTarEntry *te, indexDataList_t &idx, - int level) { - KPsionCheckListItem *i = - new KPsionCheckListItem(cli, te->name(), - KPsionCheckListItem::CheckBox); - kapp->processEvents(); - if (te->isDirectory()) { - if (level) - i->setPixmap(0, KGlobal::iconLoader()->loadIcon("folder", - KIcon::Small)); - else - i->setPixmap(0, KGlobal::iconLoader()->loadIcon("hdd_unmount", - KIcon::Small)); - i->setMetaData(0, 0, QString::null, 0, 0, 0, 0); - KTarDirectory *td = (KTarDirectory *)te; - QStringList files = td->entries(); - for (QStringList::Iterator f = files.begin(); f != files.end(); f++) - listTree(i, td->entry(*f), idx, level + 1); - } else { - indexDataList_t::iterator ii; - - QString name = i->psionpath(); - for (ii = idx.begin(); ii != idx.end(); ii++) { - if (ii->name == name) { - i->setMetaData(0, 0, name, ii->size, ii->timeHi, ii->timeLo, - ii->attr); - break; - } - } - - i->setPixmap(0, KGlobal::iconLoader()->loadIcon("mime_empty", - KIcon::Small)); - } -} - -void KPsionBackupListView:: -slotRootToggled() { - bool anyOn = false; - KPsionCheckListItem *i = firstChild(); - while (i != 0L) { - if (i->isOn()) { - anyOn = true; - break; - } - i = i->nextSibling(); - } - emit itemsEnabled(anyOn); -} - -QStringList KPsionBackupListView:: -getSelectedTars() { - QStringList l; - - KPsionCheckListItem *i = firstChild(); - while (i != 0L) { - if (i->isOn()) - l += i->tarname(); - i = i->nextSibling(); - } - return l; -} - -QStringList KPsionBackupListView:: -getFormatDrives() { - QStringList l; - - KPsionCheckListItem *i = firstChild(); - while (i != 0L) { - if (i->isOn()) { - KPsionCheckListItem *c = i->firstChild(); - while (c != 0L) { - if (c->isOn()) { - QString drv = c->text().left(1); - if (l.find(drv) == l.end()) - l += drv; - } - c = c->nextSibling(); - } - } - i = i->nextSibling(); - } - return l; -} - -bool KPsionBackupListView:: -autoSelect(QString drive) { - KPsionCheckListItem *latest = NULL; - time_t stamp = 0; - - drive += ":"; - // Find latest full backup for given drive - KPsionCheckListItem *i = firstChild(); - while (i != 0L) { - if ((i->backupType() == FULL) && (i->when() > stamp)) { - KPsionCheckListItem *c = i->firstChild(); - while (c != 0L) { - if (c->text() == drive) { - latest = c; - stamp = i->when(); - break; - } - c = c->nextSibling(); - } - } - i = i->nextSibling(); - } - // Now find all incremental backups for given drive which are newer than - // selected backup - if (latest != 0) { - latest->setOn(true); - i = firstChild(); - while (i != 0L) { - if ((i->backupType() == INCREMENTAL) && (i->when() >= stamp)) { - KPsionCheckListItem *c = i->firstChild(); - while (c != 0L) { - if (c->text() == drive) - c->setOn(true); - c = c->nextSibling(); - } - } - i = i->nextSibling(); - } - } - return (latest != 0L); -} - -void KPsionBackupListView:: -collectEntries(KPsionCheckListItem *i) { - while (i != 0L) { - KPsionCheckListItem *c = i->firstChild(); - if (c == 0L) { - if (i->isOn()) - toRestore.push_back(i->plpdirent()); - } else - collectEntries(c); - i = i->nextSibling(); - } -} - -PlpDir &KPsionBackupListView:: -getRestoreList(QString tarname) { - toRestore.clear(); - KPsionCheckListItem *i = firstChild(); - while (i != 0L) { - if ((i->tarname() == tarname) && (i->isOn())) { - collectEntries(i->firstChild()); - break; - } - i = i->nextSibling(); - } - return toRestore; -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionbackuplistview.h b/kde2/kpsion/kpsionbackuplistview.h deleted file mode 100644 index 5da193a..0000000 --- a/kde2/kpsion/kpsionbackuplistview.h +++ /dev/null @@ -1,141 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _KPSIONBACKUPLISTVIEW_H_ -#define _KPSIONBACKUPLISTVIEW_H_ - -#include - -#include -#include - -#include -#include -#include -#include - -#include - -typedef struct { - u_int32_t timeHi; - u_int32_t timeLo; - u_int32_t attr; - u_int32_t size; - QString name; -} indexData_t; - -typedef std::vector indexDataList_t; - -class KPsionCheckListItem : public QObject, public QCheckListItem { - Q_OBJECT - -public: - KPsionCheckListItem(KPsionCheckListItem *parent, const QString &text, - Type tt) - : QCheckListItem(parent, text, tt) { init(true); } - KPsionCheckListItem(QCheckListItem *parent, const QString &text, Type tt) - : QCheckListItem(parent, text, tt) { init(false); } - KPsionCheckListItem(QListViewItem *parent, const QString &text, Type tt) - : QCheckListItem(parent, text, tt) { init(false); } - KPsionCheckListItem(QListView *parent, const QString &text, Type tt) - : QCheckListItem(parent, text, tt) { init(false); } - KPsionCheckListItem(QListViewItem *parent, const QString &text, - const QPixmap &p) - : QCheckListItem(parent, text, p) { init(false); } - KPsionCheckListItem(QListView *parent, const QString &text, - const QPixmap &p) - : QCheckListItem(parent, text, p) { init(false); } - - KPsionCheckListItem *firstChild() const; - KPsionCheckListItem *nextSibling() const; - - ~KPsionCheckListItem(); - - virtual QString key(int column, bool ascending) const; - void setMetaData(int bType, time_t bTime, QString tarName, int size, - u_int32_t tHi, u_int32_t tLo, u_int32_t attr); - - QString unixname(); - QString psionname(); - QString tarname(); - PlpDirent plpdirent(); - int backupType(); - int size(); - time_t when(); - bool isPathChecked(QString path); - QString psionpath(); - virtual void paintCell(QPainter *, const QColorGroup &, int, int, int); - -signals: - void rootToggled(void); - -protected: - virtual void stateChange(bool); - void propagateUp(bool); - void propagateDown(bool); - -private: - void init(bool); - class KPsionCheckListItemMetaData; - KPsionCheckListItemMetaData *meta; -}; - -class KPsionBackupListView : public KListView { - Q_OBJECT - -public: - enum backupTypes { - UNKNOWN = 0, - FULL = 1, - INCREMENTAL = 2, - }; - - KPsionBackupListView(QWidget *parent = 0, const char *name = 0); - KPsionCheckListItem *firstChild() const; - - void readBackups(QString uid); - PlpDir &getRestoreList(QString tarname); - QStringList getSelectedTars(); - QStringList getFormatDrives(); - bool autoSelect(QString drive); - -signals: - void itemsEnabled(bool); - -private slots: - void slotRootToggled(void); - -private: - void collectEntries(KPsionCheckListItem *i); - void listTree(KPsionCheckListItem *cli, const KTarEntry *te, - indexDataList_t &idx, int level); - QString uid; - QString backupDir; - PlpDir toRestore; -}; -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionconfig.cpp b/kde2/kpsion/kpsionconfig.cpp deleted file mode 100644 index becfaa8..0000000 --- a/kde2/kpsion/kpsionconfig.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "kpsionconfig.h" - -#include -#include - -#include - -KPsionConfig::KPsionConfig() { - optionNames.insert(OPT_BACKUPDIR, QString("Settings/BackupDir")); - optionNames.insert(OPT_BACKUPGEN, QString("Settings/BackupGenerations")); - optionNames.insert(OPT_INCINTERVAL, QString("Settings/IncrementalInterval")); - optionNames.insert(OPT_FULLINTERVAL, QString("Settings/FullInterval")); - optionNames.insert(OPT_CONNRETRY, QString("Connection/Retry")); - optionNames.insert(OPT_SERIALDEV, QString("Connection/Device")); - optionNames.insert(OPT_SERIALSPEED, QString("Connection/Speed")); - optionNames.insert(OPT_NCPDPATH, QString("Connection/NcpdPath")); - optionNames.insert(OPT_UIDS, QString("Psion/MachineUIDs")); - optionNames.insert(OPT_MACHNAME, QString("Psion/Name_%1")); - optionNames.insert(OPT_BACKUPDRIVES, QString("Psion/BackupDrives_%1")); - optionNames.insert(OPT_DRIVES, QString("Psion/Drives_%1")); - optionNames.insert(OPT_LASTFULL, QString("Psion/LastFull_%1_%1")); - optionNames.insert(OPT_LASTINC, QString("Psion/LastInc_%1_%1")); - optionNames.insert(OPT_SYNCTIME, QString("Psion/SyncTime_%1")); - - defaults.insert(DEF_INCINTERVAL, QString("1")); - defaults.insert(DEF_FULLINTERVAL, QString("7")); - defaults.insert(DEF_CONNRETRY, QString("30")); - defaults.insert(DEF_SERIALDEV, QString("0")); - defaults.insert(DEF_SERIALSPEED, QString("4")); - defaults.insert(DEF_BACKUPGEN, QString("3")); - defaults.insert(DEF_NCPDPATH, QString("ncpd")); - defaults.insert(DEF_SYNCTIME, QString("false")); -} - -const QString KPsionConfig:: -getStrDefault(int optIdx) { - if (optIdx != DEF_BACKUPDIR) - return QString::null; - return locateLocal("data", "kpsion/backups"); -} - -int KPsionConfig:: -getIntDefault(int optIdx) { - cfgMap::Iterator it = defaults.find(optIdx); - if (it == defaults.end()) - return 0; - return (*it).toInt(); -} - -bool KPsionConfig:: -getBoolDefault(int optIdx) { - cfgMap::Iterator it = defaults.find(optIdx); - if (it == defaults.end()) - return false; - return ((*it).compare("true") == 0); -} - -const QString KPsionConfig:: -getOptionName(int optIdx) { - cfgMap::Iterator it = optionNames.find(optIdx); - if (it == optionNames.end()) - return QString::null; - int slash = (*it).find('/'); - return (*it).mid(slash + 1); -} - -const QString KPsionConfig:: -getSectionName(int optIdx) { - cfgMap::Iterator it = optionNames.find(optIdx); - if (it == optionNames.end()) - return QString::null; - int slash = (*it).find('/'); - return (*it).left(slash); -} - -QStringList KPsionConfig:: -getConfigDevices() { - QStringList l; - - l += i18n("off"); - l += QString("/dev/ttyS0"); - l += QString("/dev/ttyS1"); - l += QString("/dev/ttyS2"); - l += QString("/dev/ttyS3"); - l += QString("/dev/ttyUSB0"); - l += QString("/dev/ttyUSB1"); - l += QString("/dev/ttyUSB2"); - l += QString("/dev/ttyUSB3"); - l += QString("/dev/ircomm0"); - l += QString("/dev/ircomm1"); - l += QString("/dev/ircomm2"); - l += QString("/dev/ircomm3"); - - return l; -} - -QStringList KPsionConfig:: -getConfigSpeeds() { - QStringList l; - - l += QString("9600"); - l += QString("19200"); - l += QString("38400"); - l += QString("57600"); - l += QString("115200"); - - return l; -} - -QStringList KPsionConfig:: -getConfigBackupInterval() { - QStringList l; - - l += i18n("none"); - l += i18n("daily"); - l += i18n("every 2 days"); - l += i18n("every 3 days"); - l += i18n("every 4 days"); - l += i18n("every 5 days"); - l += i18n("every 6 days"); - l += i18n("weekly"); - l += i18n("every 2 weeks"); - l += i18n("every 3 weeks"); - l += i18n("monthly"); - - return l; -} - -int KPsionConfig:: -getIntervalDays(KConfig *config, int optIdx) { - config->setGroup(getSectionName(optIdx)); - int i = config->readNumEntry(getOptionName(optIdx)); - switch (i) { - case 8: - return 14; - case 9: - return 21; - case 10: - return 28; - } - return i; -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionconfig.h b/kde2/kpsion/kpsionconfig.h deleted file mode 100644 index f2906a0..0000000 --- a/kde2/kpsion/kpsionconfig.h +++ /dev/null @@ -1,89 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _KPSIONCONFIG_H_ -#define _KPSIONCONFIG_H_ - -#include - -#include -#include - -typedef QMap cfgMap; - -class KPsionConfig { -public: - - enum cfgOptions { - OPT_BACKUPDIR = 0, - OPT_INCINTERVAL = 1, - OPT_FULLINTERVAL = 2, - OPT_CONNRETRY = 3, - OPT_SERIALDEV = 4, - OPT_SERIALSPEED = 5, - OPT_BACKUPGEN = 6, - OPT_UIDS = 7, - OPT_MACHNAME = 8, - OPT_BACKUPDRIVES = 9, - OPT_DRIVES = 10, - OPT_LASTFULL = 11, - OPT_LASTINC = 12, - OPT_NCPDPATH = 13, - OPT_SYNCTIME = 14, - }; - - enum cfgDefaults { - DEF_BACKUPDIR = 0, - DEF_INCINTERVAL = 1, - DEF_FULLINTERVAL = 2, - DEF_CONNRETRY = 3, - DEF_SERIALDEV = 4, - DEF_SERIALSPEED = 5, - DEF_BACKUPGEN = 6, - DEF_NCPDPATH = 7, - DEF_SYNCTIME = 8, - }; - - KPsionConfig(); - - QStringList getConfigDevices(); - QStringList getConfigSpeeds(); - QStringList getConfigBackupInterval(); - const QString getOptionName(int); - const QString getSectionName(int); - const QString getStrDefault(int); - int getIntDefault(int); - int getIntervalDays(KConfig *, int); - bool getBoolDefault(int); - -private: - cfgMap optionNames; - cfgMap defaults; - -}; -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionrestoredialog.cpp b/kde2/kpsion/kpsionrestoredialog.cpp deleted file mode 100644 index 972dc17..0000000 --- a/kde2/kpsion/kpsionrestoredialog.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999 Philip Proudman - * Copyright (C) 2000, 2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "kpsionrestoredialog.h" - -#include - -#include - -KPsionRestoreDialog::KPsionRestoreDialog(QWidget *parent, QString uid) - : KDialogBase(parent, "restoreDialog", true, i18n("Restore"), - KDialogBase::Cancel | KDialogBase::Ok, - KDialogBase::Ok, true) { - - setButtonOKText(i18n("Start")); - enableButtonOK(false); - setButtonWhatsThis(KDialogBase::Ok, - i18n("Select items in the list of" - " available backups, then click" - " here to start restore of these" - " items.")); - - QWidget *w = new QWidget(this); - setMainWidget(w); - QGridLayout *gl = new QGridLayout(w, 1, 1, KDialog::marginHint(), - KDialog::marginHint()); - backupView = new KPsionBackupListView(w, "restoreSelector"); - gl->addWidget(backupView, 0, 0); - fmtCheck = new QCheckBox(i18n("Format drive before restore"), w, "fmtCheck"); - gl->addWidget(fmtCheck, 1, 0); - backupView->readBackups(uid); - connect(backupView, SIGNAL(itemsEnabled(bool)), this, - SLOT(slotBackupsSelected(bool))); -} - -void KPsionRestoreDialog:: -slotBackupsSelected(bool any) { - enableButtonOK(any); -} - -QStringList KPsionRestoreDialog:: -getSelectedTars() { - return backupView->getSelectedTars(); -} - -bool KPsionRestoreDialog:: -autoSelect(QString drive) { - return backupView->autoSelect(drive); -} - -QStringList KPsionRestoreDialog:: -getFormatDrives() { - if (fmtCheck->isChecked()) - return backupView->getFormatDrives(); - return QStringList(); -} - -PlpDir &KPsionRestoreDialog:: -getRestoreList(QString tarname) { - return backupView->getRestoreList(tarname); -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/kpsionrestoredialog.h b/kde2/kpsion/kpsionrestoredialog.h deleted file mode 100644 index e946f1c..0000000 --- a/kde2/kpsion/kpsionrestoredialog.h +++ /dev/null @@ -1,56 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _KPSIONRESTOREDIALOG_H_ -#define _KPSIONRESTOREDIALOG_H_ - -#include "kpsionbackuplistview.h" - -#include - -#include -#include - -#include - -typedef QMap driveMap; -typedef QMap psionMap; - -class KPsionRestoreDialog : public KDialogBase { - Q_OBJECT - -public: - KPsionRestoreDialog(QWidget *parent, QString uid); - - PlpDir &getRestoreList(QString tarname); - QStringList getSelectedTars(); - QStringList getFormatDrives(); - bool autoSelect(QString drive); - -private slots: - void slotBackupsSelected(bool); - -private: - KPsionBackupListView *backupView; - QCheckBox *fmtCheck; -}; -#endif diff --git a/kde2/kpsion/kpsionui.rc b/kde2/kpsion/kpsionui.rc deleted file mode 100644 index 17302c5..0000000 --- a/kde2/kpsion/kpsionui.rc +++ /dev/null @@ -1,15 +0,0 @@ - - - - &File - - - - - - - - - - - diff --git a/kde2/kpsion/lo16-action-psion_backup.png b/kde2/kpsion/lo16-action-psion_backup.png deleted file mode 100644 index 4d0f815..0000000 Binary files a/kde2/kpsion/lo16-action-psion_backup.png and /dev/null differ diff --git a/kde2/kpsion/lo16-action-psion_restore.png b/kde2/kpsion/lo16-action-psion_restore.png deleted file mode 100644 index 8f3103b..0000000 Binary files a/kde2/kpsion/lo16-action-psion_restore.png and /dev/null differ diff --git a/kde2/kpsion/lo16-app-kpsion.png b/kde2/kpsion/lo16-app-kpsion.png deleted file mode 100644 index 2382c76..0000000 Binary files a/kde2/kpsion/lo16-app-kpsion.png and /dev/null differ diff --git a/kde2/kpsion/lo22-action-psion_backup.png b/kde2/kpsion/lo22-action-psion_backup.png deleted file mode 100644 index b5ebd45..0000000 Binary files a/kde2/kpsion/lo22-action-psion_backup.png and /dev/null differ diff --git a/kde2/kpsion/lo22-action-psion_restore.png b/kde2/kpsion/lo22-action-psion_restore.png deleted file mode 100644 index 47780b8..0000000 Binary files a/kde2/kpsion/lo22-action-psion_restore.png and /dev/null differ diff --git a/kde2/kpsion/lo32-action-psion_backup.png b/kde2/kpsion/lo32-action-psion_backup.png deleted file mode 100644 index 4a99260..0000000 Binary files a/kde2/kpsion/lo32-action-psion_backup.png and /dev/null differ diff --git a/kde2/kpsion/lo32-action-psion_restore.png b/kde2/kpsion/lo32-action-psion_restore.png deleted file mode 100644 index 782e2d9..0000000 Binary files a/kde2/kpsion/lo32-action-psion_restore.png and /dev/null differ diff --git a/kde2/kpsion/lo32-app-kpsion.png b/kde2/kpsion/lo32-app-kpsion.png deleted file mode 100644 index 7285992..0000000 Binary files a/kde2/kpsion/lo32-app-kpsion.png and /dev/null differ diff --git a/kde2/kpsion/main.cpp b/kde2/kpsion/main.cpp deleted file mode 100644 index 06f5e25..0000000 --- a/kde2/kpsion/main.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "kpsion.h" -#include "kpsionconfig.h" -#include "wizards.h" -#include -#include -#include -#include -#include - -namespace LIBPLP { -extern "C" { -#include - void init_libplp_i18n() { - setlocale(LC_ALL, ""); - textdomain(PACKAGE); - } -}; -}; - - -static KCmdLineOptions options[] = { -// {"a", 0, 0}, - {"autobackup", I18N_NOOP("perform scheduled backup"), 0}, -// {"b ", 0, 0}, - {"backup ", I18N_NOOP("perform backup"), 0}, -// {"r ", 0, 0}, - {"restore ", I18N_NOOP("perform restore"), 0}, -// {"f ", 0, 0}, - {"format ", I18N_NOOP("format drive"), 0}, - { 0, 0, 0}, -}; - -int main(int argc, char **argv) { - KAboutData *about = new KAboutData("kpsion", I18N_NOOP("KPsion"), - VERSION, - I18N_NOOP("Psion connectivity utility"), - KAboutData::License_GPL, - "(C) 2001, Fritz Elfert", 0L, - "http://plptools.sourceforge.net", - "plptools-developers@sourceforge.net"); - about->addAuthor("Fritz Elfert", I18N_NOOP("Original Developer/Maintainer"), - "felfert@users.sourceforge.net", - "http://plptools.sourceforge.net"); - KCmdLineArgs::init(argc, argv, about); - KCmdLineArgs::addCmdLineOptions(options); - - KApplication a; - - // Install additional translations - LIBPLP::init_libplp_i18n(); - KGlobal::locale()->insertCatalogue(QString::fromLatin1("plptools")); - - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - QString backupDir = config->readEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR)); - - if (backupDir.isEmpty()) { - FirstTimeWizard *wiz = new FirstTimeWizard(0L, "firsttimewizard"); - wiz->exec(); - } - - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - int acnt = 0; - if (args->isSet("backup")) - acnt++; - if (args->isSet("restore")) - acnt++; - if (args->isSet("format")) - acnt++; - if (args->isSet("autobackup")) - acnt++; - - if (acnt > 1) - KCmdLineArgs::usage(i18n( - "The actions are mutually exclusive. " - "I.e. You cannot specify more than one action at once.")); - - KPsionMainWindow *w = new KPsionMainWindow(); - - if (w->shouldQuit()) - return 0; - - w->resize(300, 170); - a.setMainWidget(w); - w->show(); - return a.exec(); -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/setupdialog.cpp b/kde2/kpsion/setupdialog.cpp deleted file mode 100644 index 8225f84..0000000 --- a/kde2/kpsion/setupdialog.cpp +++ /dev/null @@ -1,615 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "kpsionconfig.h" -#include "setupdialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -SetupDialog::SetupDialog(QWidget *parent, rfsv *plpRfsv, rpcs *plpRpcs) - : KDialogBase(Tabbed, i18n("Settings"), Ok|Apply|Default|Cancel, Ok, parent, - "settingsDialog", true, true) -{ - int i; - QString tmp; - QStringList sl; - QStringList::Iterator sli; - QLabel *l; - KPsionConfig pcfg; - - KConfig *config = kapp->config(); - - // Page 1 - page1 = addPage(i18n("&Backup")); - QBoxLayout *box = new QVBoxLayout(page1, KDialog::spacingHint()); - - QGroupBox *gb = new QGroupBox(i18n("Backup folder"), page1, "bdirBox"); - box->addWidget(gb); - - QGridLayout *grid = new QGridLayout(gb, 1, 1, marginHint() * 2, - spacingHint() * 2); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - tmp = config->readEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR)); - oldBDir = tmp; - bdirLabel = new QLabel(gb, "bdirLabel"); - bdirLabel->setText(tmp); - bdirButton = new QPushButton(i18n("Browse"), gb); - - QWhatsThis::add(bdirLabel, i18n( - "This is the name of the backup folder. " - "Click on Browse, for opening a dialog which lets you easily " - "select the backup folder. If the backup folder is changed and " - "it already contains backups, these are moved to the new " - "location.")); - QWhatsThis::add(bdirButton, i18n( - "Click here, for opening a dialog which lets you easily " - "select the backup folder. If the backup folder is changed and " - "it already contains backups, these are moved to the new " - "location.")); - grid->addWidget(bdirLabel, 0, 0); - grid->addWidget(bdirButton, 0, 1); - connect(bdirButton, SIGNAL(clicked()), SLOT(slotBdirBrowse())); - - grid->addRowSpacing(0, marginHint()); - grid->setColStretch(0, 1); - - gb = new QGroupBox(i18n("Backup strategy"), page1, "stratBox"); - box->addWidget(gb); - - grid = new QGridLayout(gb, 1, 1, marginHint() * 2, spacingHint() * 2); - l = new QLabel(i18n("&Incremental backup interval"), gb, - "iBackupIntLabel"); - grid->addWidget(l, 0, 0); - QWhatsThis::add(l, i18n( - "If you select an interval here, KPsion creates an entry " - "in your Autostart directory which performs an incremental backup of " - "selected drives. If your Psion is not connected at that time, " - "nothing will happen.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_INCINTERVAL)); - i = config->readNumEntry(pcfg.getOptionName(KPsionConfig::OPT_INCINTERVAL)); - iIntCombo = new KComboBox(false, gb, "iIntCombo"); - iIntCombo->insertStringList(pcfg.getConfigBackupInterval()); - iIntCombo->setCurrentItem(i); - grid->addWidget(iIntCombo, 0, 1); - l->setBuddy(iIntCombo); - QWhatsThis::add(iIntCombo, i18n( - "If you select an interval here, KPsion creates an entry " - "in your Autostart directory which performs an incremental backup of " - "selected drives. If your Psion is not connected at that time, " - "nothing will happen.")); - - l = new QLabel(i18n("&Full backup interval"), gb, "fBackupIntLabel"); - grid->addWidget(l, 1, 0); - QWhatsThis::add(l, i18n( - "If you select an interval here, KPsion creates an entry " - "in your Autostart directory which performs a full backup of " - "selected drives. If your Psion is not connected at that time, " - "nothing will happen.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_FULLINTERVAL)); - i = config->readNumEntry(pcfg.getOptionName(KPsionConfig::OPT_FULLINTERVAL)); - fIntCombo = new KComboBox(false, gb, "fIntCombo"); - fIntCombo->insertStringList(pcfg.getConfigBackupInterval()); - fIntCombo->setCurrentItem(i); - grid->addWidget(fIntCombo, 1, 1); - l->setBuddy(fIntCombo); - QWhatsThis::add(fIntCombo, i18n( - "If you select an interval here, KPsion creates an entry " - "in your Autostart directory which performs a full backup of " - "selected drives. If your Psion is not connected at that time, " - "nothing will happen.")); - - l = new QLabel(i18n("Backup &generations"), gb, "backupGenLabel"); - grid->addWidget(l, 2, 0); - QWhatsThis::add(l, i18n( - "Specify the number of backup generations you want to keep " - "on your machine. One backup generation means a full backup of " - "a drive plus eventually made incrmental backups of that drive. " - "This is checked every time, a full backup is done and if the " - "number of existing backups is exceeded, the oldest backup and " - "its corresponding incremental backups are deleted.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPGEN)); - i = config->readNumEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPGEN)); - genSpin = new KIntSpinBox(0, 10, 1, i, 10, gb, "backupGenSpin"); - grid->addWidget(genSpin, 2, 1); - l->setBuddy(genSpin); - QWhatsThis::add(genSpin, i18n( - "Specify the number of backup generations you want to keep " - "on your machine. One backup generation means a full backup of " - "a drive plus eventually made incrmental backups of that drive. " - "This is checked every time, a full backup is done and if the " - "number of existing backups is exceeded, the oldest backup and " - "its corresponding incremental backups are deleted.")); - - grid->addRowSpacing(0, marginHint()); - grid->setColStretch(0, 1); - - // Page 3 - page2 = addPage(i18n("&Connection")); - grid = new QGridLayout(page2, 1, 1, marginHint() * 2, spacingHint() * 2); - - l = new QLabel(i18n("&Connection retry interval (sec.)"), page2, - "rconLabel"); - grid->addWidget(l, 0, 0); - QWhatsThis::add(l, i18n( - "If this is not 0, KPsion attempts to retry connection " - "setup.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_CONNRETRY)); - i = config->readNumEntry(pcfg.getOptionName(KPsionConfig::OPT_CONNRETRY)); - rconSpin = new KIntSpinBox(0, 600, 1, i, 10, page2, "rconSpin"); - grid->addWidget(rconSpin, 0, 1); - l->setBuddy(rconSpin); - QWhatsThis::add(rconSpin, i18n( - "If this is not 0, KPsion attempts to retry connection " - "setup.")); - - l = new QLabel(i18n("Serial &device"), page2, "devLabel"); - grid->addWidget(l, 1, 0); - QWhatsThis::add(l, i18n( - "If a device is selected here and the connection can not " - "established at startup, KPsion will attempt to start " - "the ncpd daemon with appropriate parameters.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALDEV)); - tmp = config->readEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALDEV)); - - devCombo = new KComboBox(false, page2, "devCombo"); - sl = pcfg.getConfigDevices(); - devCombo->insertStringList(sl); - if (tmp == "off") - devCombo->setCurrentItem(0); - else - for (i = 0, sli = sl.begin(); sli != sl.end(); ++i, ++sli) { - if (*sli == tmp) - devCombo->setCurrentItem(i); - } - grid->addWidget(devCombo, 1, 1); - l->setBuddy(devCombo); - QWhatsThis::add(devCombo, i18n( - "If a device is selected here and the connection can not " - "established at startup, KPsion will attempt to start " - "the ncpd daemon with appropriate parameters.")); - - l = new QLabel(i18n("Serial &speed"), page2, "speedLabel"); - grid->addWidget(l, 2, 0); - QWhatsThis::add(l, i18n( - "If a device is selected at Serial device and the " - "connection can not established at startup, KPsion will " - "attempt to start the ncpd daemon with appropriate parameters.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALSPEED)); - tmp = config->readEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALSPEED)); - - speedCombo = new KComboBox(false, page2, "speedCombo"); - sl = pcfg.getConfigSpeeds(); - speedCombo->insertStringList(sl); - for (i = 0, sli = sl.begin(); sli != sl.end(); ++i, ++sli) { - if (*sli == tmp) - speedCombo->setCurrentItem(i); - } - grid->addWidget(speedCombo, 2, 1); - l->setBuddy(speedCombo); - QWhatsThis::add(speedCombo, i18n( - "If a device is selected at Serial device and the " - "connection can not established at startup, KPsion will " - "attempt to start the ncpd daemon with appropriate parameters.")); - - - grid->setColStretch(0, 1); - - // Page 4 - page3 = addPage(i18n("&Machines")); - grid = new QGridLayout(page3, 1, 1, marginHint() * 2, spacingHint() * 2); - - l = new QLabel(page3, "nameLabel"); - l->setText(i18n("Machine &UID")); - grid->addWidget(l, 0, 0); - QWhatsThis::add(l, i18n( - "This shows the known machines. Select an entry here and you " - "will be able to change its name and specify the drives that should " - "be selected for automatic backups. You also can delete a machine " - "which includes deleting all backups for it.")); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_UIDS)); - sl = config->readListEntry(pcfg.getOptionName(KPsionConfig::OPT_UIDS)); - machCombo = new KComboBox(false, page3, "machCombo"); - machCombo->insertStringList(sl); - grid->addWidget(machCombo, 0, 1); - l->setBuddy(machCombo); - QWhatsThis::add(machCombo, i18n( - "This shows the known machines. Select an entry here and you " - "will be able to change its name and specify the drives that should " - "be selected for automatic backups. You also can delete a machine " - "which includes deleting all backups for it.")); - - l = new QLabel(page3, "nameLabel"); - l->setText(i18n("Machine &Name")); - grid->addWidget(l, 1, 0); - QWhatsThis::add(l, i18n( - "You can change the name of the machine here. The name " - "is not used internally but only provided for display purposes.")); - - nameEdit = new KLineEdit(page3, "nameEdit"); - grid->addWidget(nameEdit, 1, 1); - l->setBuddy(nameEdit); - QWhatsThis::add(nameEdit, i18n( - "You can change the name of the machine here. The name " - "is not used internally but only provided for display purposes.")); - - mdelButton = new QPushButton(i18n("Delete"), page3); - grid->addMultiCellWidget(mdelButton, 0, 1, 2, 2); - connect(mdelButton, SIGNAL(clicked()), SLOT(slotDeleteMachine())); - QWhatsThis::add(mdelButton, i18n( - "Click here to delete the selected machine from the list of " - "known machines. This includes deleting all backups of that " - "machine.")); - - backupListView = new KListView(page3, "bdriveListView"); - backupListView->addColumn(i18n("Automatic backup drives")); - - backupListView->header()->setClickEnabled(false); - backupListView->header()->setResizeEnabled(false); - backupListView->header()->setMovingEnabled(false); - int height = backupListView->header()->height(); - backupListView->setMinimumWidth(backupListView->columnWidth(0) + 4); - backupListView->setMinimumHeight(height + 10); - backupListView->setMaximumHeight(height + 10); - QWhatsThis::add(backupListView, i18n( - "Here, you can select the drives which shall be included in " - "atomatic backups.")); - - grid->addMultiCellWidget(backupListView, 2, 2, 0, 2); - connect(machCombo, SIGNAL(activated(int)), SLOT(slotMachineChanged(int))); - slotMachineChanged(0); - grid->setColStretch(0, 1); - grid->setRowStretch(2, 1); - - connect(this, SIGNAL(defaultClicked()), SLOT(slotDefaultClicked())); - connect(this, SIGNAL(okClicked()), SLOT(slotSaveSettings())); - connect(this, SIGNAL(applyClicked()), SLOT(slotSaveSettings())); -} - -void SetupDialog:: -slotMachineChanged(int idx) { - KPsionConfig pcfg; - KConfig *config = kapp->config(); - int height = 0; - QString mach = machCombo->currentText(); - - backupListView->clear(); - nameEdit->clear(); - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_MACHNAME)); - nameEdit->setText(config->readEntry( - pcfg.getOptionName(KPsionConfig::OPT_MACHNAME).arg(mach))); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_DRIVES)); - QStringList drives = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_DRIVES).arg(mach)); - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDRIVES)); - QStringList bDrives = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPDRIVES).arg(mach)); - - QStringList::Iterator it; - for (it = drives.begin(); it != drives.end(); it++) { - QCheckListItem *i = new QCheckListItem(backupListView, *it, - QCheckListItem::CheckBox); - height += i->height(); - if (bDrives.find(*it) != bDrives.end()) - i->setOn(true); - i->setSelectable(false); - } - if (idx == -1) - return; - height += backupListView->header()->height(); - backupListView->setMinimumWidth(backupListView->columnWidth(0) + 4); - backupListView->setMinimumHeight(height + 10); - backupListView->setMaximumHeight(height + 10); -} - -void SetupDialog:: -slotDeleteMachine() { - KPsionConfig pcfg; - KConfig *config = kapp->config(); - - QString mach = machCombo->currentText(); - - int res = KMessageBox::questionYesNo(this, i18n( - "Removing a machine also removes all backups of this machine.
" - "This can not be reverted!
" - "Do you really want to remove the machine %1 (%2)?
" - ).arg(mach).arg(nameEdit->text())); - if (res != KMessageBox::Yes) - return; - - QString bdir = bdirLabel->text() + "/" + mach; - QDir d(bdir); - if (d.exists()) { - d.setFilter(QDir::Files); - QStringList entries = d.entryList(); - QStringList::Iterator ei; - for (ei = entries.begin(); ei != entries.end(); ++ei) { - if (!d.remove(*ei)) { - KMessageBox::error(this, - i18n("Could not remove backup file %1.").arg(*ei)); - return; - } - } - d.rmdir(bdir); - } - - machCombo->removeItem(machCombo->currentItem()); - - QStringList sl = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_DRIVES).arg(mach)); - config->sync(); - - QString dcfgName = - KGlobal::dirs()->saveLocation("config", QString::null, false); - dcfgName += "kpsionrc"; - KSimpleConfig dcfg(dcfgName); - dcfg.setGroup(pcfg.getSectionName(KPsionConfig::OPT_MACHNAME)); - dcfg.deleteEntry(pcfg.getOptionName( - KPsionConfig::OPT_MACHNAME).arg(mach), false); - dcfg.setGroup(pcfg.getSectionName(KPsionConfig::OPT_DRIVES)); - dcfg.deleteEntry(pcfg.getOptionName( - KPsionConfig::OPT_DRIVES).arg(mach), false); - dcfg.setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDRIVES)); - dcfg.deleteEntry(pcfg.getOptionName( - KPsionConfig::OPT_BACKUPDRIVES).arg(mach), false); - QStringList::Iterator it; - for (it = sl.begin(); it != sl.end(); it++) { - dcfg.setGroup(pcfg.getSectionName(KPsionConfig::OPT_LASTFULL)); - dcfg.deleteEntry(pcfg.getOptionName( - KPsionConfig::OPT_LASTFULL).arg(mach).arg(*it), false); - dcfg.setGroup(pcfg.getSectionName(KPsionConfig::OPT_LASTINC)); - dcfg.deleteEntry(pcfg.getOptionName( - KPsionConfig::OPT_LASTINC).arg(mach).arg(*it), false); - } - dcfg.sync(); - config->reparseConfiguration(); - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_UIDS)); - sl = config->readListEntry(pcfg.getOptionName(KPsionConfig::OPT_UIDS)); - sl.remove(mach); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_UIDS), sl); - - slotMachineChanged(-1); -} - -void SetupDialog:: -slotDefaultClicked() { - KPsionConfig pcfg; - - bdirLabel->setText(pcfg.getStrDefault(KPsionConfig::DEF_BACKUPDIR)); - iIntCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_INCINTERVAL)); - fIntCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_FULLINTERVAL)); - genSpin->setValue(pcfg.getIntDefault(KPsionConfig::DEF_BACKUPGEN)); - rconSpin->setValue(pcfg.getIntDefault(KPsionConfig::DEF_CONNRETRY)); - devCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_SERIALDEV)); - speedCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_SERIALSPEED)); -} - -void SetupDialog:: -slotBdirBrowse() { - QString dir = KFileDialog::getExistingDirectory(bdirLabel->text(), this, - i18n("Backup folder")); - checkBackupDir(dir); -} - -void SetupDialog:: -slotSaveSettings() { - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR), - bdirLabel->text()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPGEN)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPGEN), - genSpin->value()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_INCINTERVAL)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_INCINTERVAL), - iIntCombo->currentItem()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_FULLINTERVAL)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_FULLINTERVAL), - fIntCombo->currentItem()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_CONNRETRY)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_CONNRETRY), - rconSpin->value()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALDEV)); - if (devCombo->currentItem() == 0) - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALDEV), - "off"); - else - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALDEV), - devCombo->currentText()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALSPEED)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALSPEED), - speedCombo->currentText()); - - QString asFile = KGlobalSettings::autostartPath() + "/PsionBackup.desktop"; - // Create or remove autostart entry - if (iIntCombo->currentItem() || fIntCombo->currentItem()) { - KDesktopFile f(asFile); - f.setGroup("Desktop Entry"); - f.writeEntry("Type", "Application"); - f.writeEntry("Exec", "kpsion --autobackup"); - f.writeEntry("Icon", "kpsion"); - f.writeEntry("Terminal", false); - f.writeEntry("Comment", "Scheduled backup of your Psion"); - } else - unlink(asFile.latin1()); -} - -bool SetupDialog:: -showPage(int index) { - switch (activePageIndex()) { - case 1: - QString dir(bdirLabel->text()); - if (!checkBackupDir(dir)) - return false; - } - return KDialogBase::showPage(index); -} - -void SetupDialog:: -closeEvent(QCloseEvent *e) { - reject(); -} - -bool SetupDialog:: -checkBackupDir(QString &dir) { - KConfig *config = kapp->config(); - KPsionConfig pcfg; - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - QString tmp = - config->readEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR)); - - bool rmFlag = false; - - if (!bdirCreated.isEmpty()) { - if (bdirCreated != dir) { - rmFlag = true; - bdirCreated = ""; - } - } - if (!dir.isEmpty()) { - QDir d(dir); - if (!d.exists()) { - if (KMessageBox::questionYesNo(this, - i18n("The folder %1 does not exist.
Should it be created?
").arg(dir)) == KMessageBox::No) { - bdirLabel->setText(tmp); - return false; - } - if (mkdir(dir.data(), 0700) != 0) { - QString msg = i18n("The specified folder
%1
could not be created"); - switch (errno) { - case EACCES: - case EPERM: - case EROFS: - msg += i18n(", because you either don't have sufficient rights to do that, or the filesystem is readonly."); - // Insufficient permissions/ readonly FS - break; - case ENOSPC: - msg += i18n(", because the filesystem has not enough space."); - // No space - break; - case EEXIST: - // shouldn't happen, we checked already - // for existence. - msg += i18n(", because there already exists another object with the same name."); - break; - case EFAULT: - case ENOMEM: - case ENAMETOOLONG: - // shouldn't happen. - msg += "."; - break; - case ENOENT: - // propably dangling symlink - msg += i18n(", because you specified a path which probably contains a dangling symbolic link."); - break; - case ENOTDIR: - msg += i18n(", because you specified a path which contains an element which is not a folder."); - // path element not dir. - break; - case ELOOP: - msg += i18n(", because you specified a path which contains too many symbolic links."); - // Too many symlinks - break; - - - } - bdirLabel->setText(tmp); - msg += i18n("
Please select another folder.
"); - KMessageBox::error(this, msg.arg(dir)); - return false; - } - bdirCreated = dir; - } - QDir od(oldBDir); - if ((!oldBDir.isEmpty()) && (oldBDir != dir) && (od.exists())) { - QStringList entries = od.entryList(); - QStringList::Iterator ui; - QStringList::Iterator ei; - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_UIDS)); - QStringList uids = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_UIDS)); - for (ei = entries.begin(); ei != entries.end(); ++ei) { - for (ui = uids.begin(); ui != uids.end(); ++ui) { - if ((*ei) == (*ui)) { - QString from = oldBDir; - QString to = dir; - - from += "/"; from += *ui; - to += "/"; to += *ui; - if (::rename(from.latin1(), to.latin1()) != 0) { - KMessageBox::error(this, - i18n("Could not move existing backup " - "for machine %1 to %2.").arg(*ui).arg(to)); - } - } - } - } - } - if (rmFlag) - ::rmdir(oldBDir.latin1()); - bdirLabel->setText(dir); - oldBDir = dir; - return true; - } - bdirLabel->setText(tmp); - return false; -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/setupdialog.h b/kde2/kpsion/setupdialog.h deleted file mode 100644 index a7e4487..0000000 --- a/kde2/kpsion/setupdialog.h +++ /dev/null @@ -1,89 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 1999-2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifndef _SETUPDIALOGS_H_ -#define _SETUPDIALOGS_H_ - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -class SetupDialog : public KDialogBase { - Q_OBJECT - -public: - SetupDialog(QWidget *parent, rfsv *plpRfsv, rpcs *plpRpcs); - bool showPage(int index); - -protected: - virtual void closeEvent(QCloseEvent *e); - -private slots: - void slotDefaultClicked(); - void slotSaveSettings(); - void slotBdirBrowse(); - void slotDeleteMachine(); - void slotMachineChanged(int); - -private: - bool checkBackupDir(QString &dir); - - QFrame *page1; - QFrame *page2; - QFrame *page3; - QFrame *page4; - - QLabel *bdirLabel; - KIntSpinBox *genSpin; - KIntSpinBox *rconSpin; - QPushButton *bdirButton; - QPushButton *mdelButton; - QCheckBox *remCheck; - KComboBox *iIntCombo; - KComboBox *fIntCombo; - KComboBox *devCombo; - KComboBox *speedCombo; - KComboBox *machCombo; - KLineEdit *nameEdit; - KListView *backupListView; - - QString bdirDefault; - QString bdirCreated; - QString oldBDir; -}; - -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/statusbarprogress.cpp b/kde2/kpsion/statusbarprogress.cpp deleted file mode 100644 index 7951b4f..0000000 --- a/kde2/kpsion/statusbarprogress.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * Shamlessly stolen from: - * khexedit - Versatile hex editor - * Copyright (C) 1999 Espen Sand, espensa@online.no - * This file is based on the work by Martynas Kunigelis (KProgress) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "statusbarprogress.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -KPsionStatusBarProgress:: -KPsionStatusBarProgress(QWidget *parent, - const char *name) - : QFrame(parent, name), QRangeControl(0, 100, 1, 10, 0), -mOrientation(Horizontal) { - initialize(); -} - -KPsionStatusBarProgress:: -KPsionStatusBarProgress(Orientation orientation, - QWidget *parent, - const char *name) - : QFrame(parent, name), QRangeControl(0, 100, 1, 10, 0), -mOrientation(orientation) { - initialize(); -} - -KPsionStatusBarProgress:: -KPsionStatusBarProgress(int minValue, int maxValue, - int value, - Orientation orientation, - QWidget *parent, - const char *name) - : QFrame(parent, name), QRangeControl(minValue, maxValue, 1, 10, value), -mOrientation(orientation) { - initialize(); -} - -KPsionStatusBarProgress:: -~KPsionStatusBarProgress() { - delete mBarPixmap; -} - -void KPsionStatusBarProgress:: -advance(int offset) { - setValue(value() + offset); -} - -void KPsionStatusBarProgress:: -initialize(void) { - mBarPixmap = 0; - mBarStyle = Solid; - - mBarColor = palette().normal().highlight(); - mBarTextColor = palette().normal().highlightedText(); - mTextColor = palette().normal().text(); - setBackgroundColor(palette().normal().background()); - - QFont font(KGlobalSettings::generalFont()); - // font.setBold(true); - setFont(font); - - mTextEnabled = false; - adjustStyle(); -} - - -void KPsionStatusBarProgress:: -setBarPixmap(const QPixmap &pixmap) { - if (pixmap.isNull() == true) - return; - if (mBarPixmap != 0) { - delete mBarPixmap; - mBarPixmap = 0; - } - mBarPixmap = new QPixmap(pixmap); -} - -void KPsionStatusBarProgress:: -setBarColor(const QColor &color) { - mBarColor = color; - if (mBarPixmap != 0) { - delete mBarPixmap; - mBarPixmap = 0; - } -} - -void KPsionStatusBarProgress:: -setBarStyle(BarStyle style) { - if (mBarStyle != style) { - mBarStyle = style; - update(); - } -} - -void KPsionStatusBarProgress:: -setOrientation(Orientation orientation) { - if (mOrientation != orientation) { - mOrientation = orientation; - update(); - } -} - -void KPsionStatusBarProgress:: -setValue(int value) { - mCurItem = mMaxItem = -1; - QRangeControl::setValue(value); -} - -void KPsionStatusBarProgress:: -setValue(int curItem, int maxItem) { - if (curItem <= 0 || maxItem <= 0 || curItem > maxItem) { - mCurItem = mMaxItem = -1; - QRangeControl::setValue(0); - } else { - mCurItem = curItem; - mMaxItem = maxItem; - float fraction = (float)curItem/(float)maxItem; - QRangeControl::setValue((int)(fraction * 100.0)); - } -} - - -void KPsionStatusBarProgress:: -setTextEnabled(bool state) { - if (mTextEnabled != state) { - mTextEnabled = state; - update(); - } -} - -void KPsionStatusBarProgress:: -setText(const QString &msg) { - labelMsg = msg; - if (mTextEnabled == true) - update(); -} - - - - -const QColor & KPsionStatusBarProgress:: -barColor(void) const { - return(mBarColor); -} - -const QPixmap * KPsionStatusBarProgress:: -barPixmap(void) const { - return(mBarPixmap); -} - -bool KPsionStatusBarProgress:: -textEnabled(void) const { - return(mTextEnabled); -} - -QSize KPsionStatusBarProgress:: -sizeHint(void) const { - QSize s(size()); - - if (orientation() == KPsionStatusBarProgress::Vertical) - s.setWidth(fontMetrics().lineSpacing()); - else - s.setHeight(fontMetrics().lineSpacing()); - return(s); -} - - -KPsionStatusBarProgress::Orientation KPsionStatusBarProgress:: -orientation(void) const { - return(mOrientation); -} - -KPsionStatusBarProgress::BarStyle KPsionStatusBarProgress:: -barStyle() const { - return(mBarStyle); -} - -int KPsionStatusBarProgress:: -recalcValue(int range) { - int abs_value = value() - minValue(); - int abs_range = maxValue() - minValue(); - if (abs_range == 0) - return range; - return range * abs_value / abs_range; -} - -void KPsionStatusBarProgress:: -valueChange() { - repaint(contentsRect(), FALSE); - emit percentageChanged(recalcValue(100)); -} - -void KPsionStatusBarProgress:: -rangeChange() { - repaint(contentsRect(), FALSE); - emit percentageChanged(recalcValue(100)); -} - -void KPsionStatusBarProgress:: -styleChange(GUIStyle) { - adjustStyle(); -} - -void KPsionStatusBarProgress:: -adjustStyle(void) { -#if (QT_VERSION < 300) - bool isWinStyle = (style().guiStyle() == WindowsStyle); -#else - bool isWinStyle = (style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle); -#endif - if (isWinStyle) - setFrameStyle(QFrame::NoFrame); - else { - setFrameStyle(QFrame::Panel|QFrame::Sunken); - setLineWidth(1); - } - update(); -} - -void KPsionStatusBarProgress:: -paletteChange(const QPalette &) { - mBarColor = palette().normal().highlight(); - mBarTextColor = palette().normal().highlightedText(); - mTextColor = palette().normal().text(); - setBackgroundColor(palette().normal().background()); -} - -void KPsionStatusBarProgress:: -drawText(QPainter *p) { - QRect r(contentsRect()); - - squeezeTextToLabel(); - p->setPen(mTextColor); - p->drawText(r, AlignCenter, labelText); - p->setClipRegion(fr); - p->setPen(mBarTextColor); - p->drawText(r, AlignCenter, labelText); -} - -void KPsionStatusBarProgress:: -drawContents(QPainter *p) { - QRect cr = contentsRect(), er = cr; - fr = cr; - QBrush fb(mBarColor), eb(backgroundColor()); - - if (mBarPixmap != 0) - fb.setPixmap(*mBarPixmap); - - if (backgroundPixmap()) - eb.setPixmap(*backgroundPixmap()); - - switch(mBarStyle) { - case Solid: - if (mOrientation == Horizontal) { - fr.setWidth(recalcValue(cr.width())); - er.setLeft(fr.right() + 1); - } else { - fr.setTop(cr.bottom() - recalcValue(cr.height())); - er.setBottom(fr.top() - 1); - } - - p->setBrushOrigin(cr.topLeft()); - p->fillRect(fr, fb); - p->fillRect(er, eb); - - if (mTextEnabled == true) - drawText(p); - break; - - case Blocked: - const int margin = 2; - int max, num, dx, dy; - if (mOrientation == Horizontal) { - fr.setHeight(cr.height() - 2 * margin); - fr.setWidth((int)(0.67 * fr.height())); - fr.moveTopLeft(QPoint(cr.left() + margin, cr.top() + margin)); - dx = fr.width() + margin; - dy = 0; - max = (cr.width() - margin) / (fr.width() + margin) + 1; - num = recalcValue(max); - } else { - fr.setWidth(cr.width() - 2 * margin); - fr.setHeight((int)(0.67 * fr.width())); - fr.moveBottomLeft(QPoint(cr.left() + margin, cr.bottom() - margin)); - dx = 0; - dy = - (fr.height() + margin); - max = (cr.height() - margin) / (fr.height() + margin) + 1; - num = recalcValue(max); - } - p->setClipRect(cr.x() + margin, cr.y() + margin, - cr.width() - margin, cr.height() - margin); - for (int i = 0; i < num; i++) { - p->setBrushOrigin(fr.topLeft()); - p->fillRect(fr, fb); - fr.moveBy(dx, dy); - } - - if (num != max) { - if (mOrientation == Horizontal) - er.setLeft(fr.right() + 1); - else - er.setBottom(fr.bottom() + 1); - if (!er.isNull()) { - p->setBrushOrigin(cr.topLeft()); - p->fillRect(er, eb); - } - } - break; - } - -} - -void KPsionStatusBarProgress:: -mousePressEvent(QMouseEvent */*e*/) { - emit pressed(); -} - -void KPsionStatusBarProgress:: -squeezeTextToLabel() { - QFontMetrics fm(fontMetrics()); - int labelWidth = size().width(); - int percent; - QString fullText; - - if (labelMsg.isEmpty() == true) { - labelText = QString("%1%").arg(recalcValue(100)); - return; - } else { - if (mCurItem > 0) - fullText = i18n("%1 %2 of %3").arg(labelMsg).arg(mCurItem).arg(mMaxItem); - else { - percent = recalcValue(100); - fullText = QString("%1 %2%").arg(labelMsg).arg(percent); - } - } - int textWidth = fm.width(fullText); - if (textWidth > labelWidth) { - // start with the dots only - QString squeezedMsg = "..."; - QString squeezedText; - - if (mCurItem > 0) - squeezedText = i18n("%1 %2 of %3").arg(squeezedMsg).arg(mCurItem).arg(mMaxItem); - else - squeezedText = QString("%1 %2%").arg(squeezedMsg).arg(percent); - int squeezedWidth = fm.width(squeezedText); - - // estimate how many letters we can add to the dots on both sides - int letters = fullText.length() * (labelWidth - squeezedWidth) / textWidth / 2; - squeezedMsg = labelMsg.left(letters) + "..." + labelMsg.right(letters); - if (mCurItem > 0) - squeezedText = i18n("%1 %2 of %3").arg(squeezedMsg).arg(mCurItem).arg(mMaxItem); - else - squeezedText = QString("%1 %2%").arg(squeezedMsg).arg(percent); - squeezedWidth = fm.width(squeezedText); - - if (squeezedWidth < labelWidth) { - // we estimated too short - // add letters while text < label - do { - letters++; - squeezedMsg = labelMsg.left(letters) + "..." + - labelMsg.right(letters); - if (mCurItem > 0) - squeezedText = i18n("%1 %2 of %3").arg(squeezedMsg).arg(mCurItem).arg(mMaxItem); - else - squeezedText = QString("%1 %2%").arg(squeezedMsg).arg(percent); - squeezedWidth = fm.width(squeezedText); - } while (squeezedWidth < labelWidth); - letters--; - squeezedMsg = labelMsg.left(letters) + "..." + - labelMsg.right(letters); - if (mCurItem > 0) - squeezedText = i18n("%1 %2 of %3").arg(squeezedMsg).arg(mCurItem).arg(mMaxItem); - else - squeezedText = QString("%1 %2%").arg(squeezedMsg).arg(percent); - } else if (squeezedWidth > labelWidth) { - // we estimated too long - // remove letters while text > label - do { - letters--; - squeezedMsg = labelMsg.left(letters) + "..." + - labelMsg.right(letters); - if (mCurItem > 0) - squeezedText = i18n("%1 %2 of %3").arg(squeezedMsg).arg(mCurItem).arg(mMaxItem); - else - squeezedText = QString("%1 %2%").arg(squeezedMsg).arg(percent); - squeezedWidth = fm.width(squeezedText); - } while (squeezedWidth > labelWidth); - } - - if (letters < 5) { - // too few letters added -> we give up squeezing - labelText = fullText; - } else - labelText = squeezedText; - - QToolTip::remove(this); - QToolTip::add(this, fullText); - } else { - labelText = fullText; - QToolTip::remove( this ); - QToolTip::hide(); - }; -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/statusbarprogress.h b/kde2/kpsion/statusbarprogress.h deleted file mode 100644 index 9b1ae4d..0000000 --- a/kde2/kpsion/statusbarprogress.h +++ /dev/null @@ -1,169 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * Shamelessly stolen from: - * khexedit - Versatile hex editor - * Copyright (C) 1999 Espen Sand, espensa@online.no - * This file is based on the work by Martynas Kunigelis (KProgress) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef _STATUSBAR_PROGRESS_H_ -#define _STATUSBAR_PROGRESS_H_ - -#include -#include - -class KPsionStatusBarProgress : public QFrame, public QRangeControl { - Q_OBJECT - -public: - /** - * Possible values for orientation - */ - enum Orientation { Horizontal, Vertical }; - - /** - * Possible values for bar style. - * - * Solid means one continuous progress bar, Blocked means a - * progress bar made up of several blocks. - */ - enum BarStyle { Solid, Blocked }; - - /** - * Construct a default progress bar. Orientation is horizontal. - */ - KPsionStatusBarProgress(QWidget *parent=0, const char *name=0); - - /** - * Construct a KProgress bar with an orientation. - */ - KPsionStatusBarProgress(Orientation, QWidget *parent=0, const char *name=0); - - /** - * Construct a KProgress bar with minimum, maximum and initial value. - */ - KPsionStatusBarProgress(int minValue, int maxValue, int value, Orientation, - QWidget *parent=0, const char *name=0); - - /** - * Destructor - */ - ~KPsionStatusBarProgress( void ); - - /** - * Set the progress bar style. Allowed values are Solid and Blocked. - */ - void setBarStyle(BarStyle style); - - /** - * Set the color of the progress bar. - */ - void setBarColor(const QColor &); - - /** - * Set a pixmap to be shown in the progress bar. - */ - void setBarPixmap(const QPixmap &); - - /** - * Set the orientation of the progress bar. - * Allowed values are Horizonzal and Vertical. - */ - void setOrientation(Orientation); - - /** - * Retrieve the bar style. - */ - BarStyle barStyle() const; - - /** - * Retrieve the bar color. - */ - const QColor &barColor() const; - - /** - * Retrieve the bar pixmap. - */ - const QPixmap *barPixmap() const; - - /** - * Retrieve the orientation. - */ - Orientation orientation() const; - - /** - * Returns TRUE if progress text will be displayed, FALSE otherwise. - */ - bool textEnabled() const; - - /** - * Returns the recommended width for vertical progress bars or - * the recommended height for vertical progress bars - */ - virtual QSize sizeHint() const; - - -public slots: - void setValue( int ); - void setValue( int, int); - void advance( int ); - void setTextEnabled( bool state ); - void setText( const QString &msg ); - -signals: - void percentageChanged(int); - void pressed( void ); - -protected: - void valueChange(); - void rangeChange(); - void styleChange( GUIStyle ); - void paletteChange( const QPalette & ); - void drawContents( QPainter * ); - void mousePressEvent( QMouseEvent *e ); - -private: - QPixmap *mBarPixmap; - QColor mBarColor; - QColor mBarTextColor; - QColor mTextColor; - QRect fr; - BarStyle mBarStyle; - Orientation mOrientation; - bool mTextEnabled; - QString labelMsg; - QString labelText; - int mCurItem; - int mMaxItem; - - void initialize(void); - int recalcValue(int); - void drawText(QPainter *); - void adjustStyle(void); - void squeezeTextToLabel(void); -}; - - -#endif - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/wizards.cpp b/kde2/kpsion/wizards.cpp deleted file mode 100644 index ea9bf46..0000000 --- a/kde2/kpsion/wizards.cpp +++ /dev/null @@ -1,598 +0,0 @@ -/*-*-c++-*- - * $Id$ - * - * This file is part of plptools. - * - * Copyright (C) 2001 Fritz Elfert - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "kpsionconfig.h" -#include "wizards.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -FirstTimeWizard::FirstTimeWizard(QWidget *parent, const char *name) - : KWizard(parent, name, true) -{ - QStringList sl; - KPsionConfig pcfg; - - setCaption(i18n("KPsion Configuration")); - QWhatsThis::add(nextButton(), - i18n("Click this button to continue with the next page.")); - QWhatsThis::add(backButton(), - i18n("Click this button, to go to a previous page.")); - QWhatsThis::add(cancelButton(), - i18n("If you click this button, the setup of KPSion will be aborted and next time you start KPsion, it will run this setup again.")); - - bdirDefault = pcfg.getStrDefault(KPsionConfig::DEF_BACKUPDIR); - bdirCreated = ""; - - // Page 1 - page1 = new QWidget(this, "welcome"); - QGridLayout *grid = new QGridLayout(page1); - - QLabel *l = new QLabel(page1, "welcome message"); - l->setText(i18n( - "" - "

Welcome to KPsion!

" - "It looks like you started KPsion the first time. " - "At least, i could not find any valid configuration.
" - "On the following pages, we will gather some information, " - "which is needed for working with KPsion.
" - "
" - "Have fun." - "
" - )); - grid->addWidget(l, 1, 1, Qt::AlignTop); - grid->setColStretch(1, 1); - grid->setRowStretch(1, 1); - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(2, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(2, KDialog::marginHint()); - addPage(page1, i18n("Welcome")); - - // Page 2 - page2 = new QWidget(this, "step1"); - grid = new QGridLayout(page2); - - l = new QLabel(page2, "step1"); - l->setText(i18n( - "" - "First, we need a folder for storing backups of " - "your Psion. You probably don't want others to " - "have access to it, so it's best to choose a " - "location somewhere in your home directory. " - "Please browse through existing folders and select a suitable " - "location or simply accept the default shown below." - "" - )); - grid->addMultiCellWidget(l, 1, 1, 1, 2, Qt::AlignTop); - - bdirLabel = new QLabel(page2, "bdirLabel"); - bdirLabel->setText(bdirDefault); - bdirButton = new QPushButton(i18n("Browse"), page2); - - QWhatsThis::add(bdirLabel, - i18n("This is the name of the backup folder.")); - QWhatsThis::add(bdirButton, - i18n("Click here, for opening a dialog which lets you easily select the backup folder.")); - grid->addWidget(bdirLabel, 3, 1); - grid->addWidget(bdirButton, 3, 2); - - grid->setRowStretch(1, 1); - grid->setColStretch(1, 1); - - grid->addRowSpacing(2, KDialog::spacingHint()); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(4, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(3, KDialog::marginHint()); - - connect(bdirButton, SIGNAL(clicked()), SLOT(slotBdirBrowse())); - addPage(page2, i18n("Step 1 - Specify backup directory")); - // Page 3 - page3 = new QWidget(this, "step2"); - grid = new QGridLayout(page3); - - l = new QLabel(page3, "step2"); - l->setText(i18n( - "" - "Next, please specify some information regarding " - "backup policy:
  • How many generations of backups " - "do you want to keep?
  • Should I perform automatic " - "backups?
  • If yes, how often do you want backups" - "to happen?
" - "
" - )); - grid->addMultiCellWidget(l, 1, 1, 1, 2, Qt::AlignTop); - - l = new QLabel( - i18n("&Incremental backup interval"), page3, "iBackupIntLabel"); - grid->addWidget(l, 3, 1); - iIntCombo = new KComboBox(false, page3, "iIntCombo"); - iIntCombo->insertStringList(pcfg.getConfigBackupInterval()); - iIntCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_INCINTERVAL)); - grid->addWidget(iIntCombo, 3, 2); - l->setBuddy(iIntCombo); - - l = new QLabel(i18n("&Full backup interval"), page3, "fBackupIntLabel"); - grid->addWidget(l, 5, 1); - fIntCombo = new KComboBox(false, page3, "fIntCombo"); - fIntCombo->insertStringList(pcfg.getConfigBackupInterval()); - fIntCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_FULLINTERVAL)); - grid->addWidget(fIntCombo, 5, 2); - l->setBuddy(fIntCombo); - - l = new QLabel(i18n("Backup &generations"), page3, "backupGenLabel"); - grid->addWidget(l, 7, 1); - genSpin = new KIntSpinBox(0, 10, 1, - pcfg.getIntDefault(KPsionConfig::DEF_BACKUPGEN), - 10, page3, "backupGenSpin"); - grid->addWidget(genSpin, 7, 2); - l->setBuddy(genSpin); - - grid->setRowStretch(1, 1); - grid->setColStretch(1, 1); - - grid->addRowSpacing(2, KDialog::spacingHint()); - grid->addRowSpacing(4, KDialog::spacingHint()); - grid->addRowSpacing(6, KDialog::spacingHint()); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(8, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(3, KDialog::marginHint()); - - addPage(page3, i18n("Step 2 - Backup policy")); - - // Page 4 - page4 = new QWidget(this, "step3"); - grid = new QGridLayout(page4); - - l = new QLabel(page4, "step2"); - l->setText(i18n( - "" - "If no connection could be established on startup, " - "KPsion will attempt to connect in regular " - "intervals. Please specify the interval after which " - "a connection attempt should happen. If you don't want " - "automatic retry, set the interval to zero. Furthermore, " - "KPsion can try to start ncpd if it is not already " - "running. For that to work correctly, you need to" - "
  • specify the serial port to use.
  • " - "
  • specify the baud rate
  • " - "
  • have permission to use the specified port
" - "
" - )); - grid->addMultiCellWidget(l, 1, 1, 1, 2, Qt::AlignTop); - - l = new QLabel( - i18n("&Connection retry interval (sec.)"), page4, "rconLabel"); - grid->addWidget(l, 3, 1); - rconSpin = new KIntSpinBox(0, 600, 1, - pcfg.getIntDefault(KPsionConfig::DEF_CONNRETRY), - 10, page4, "rconSpin"); - grid->addWidget(rconSpin, 3, 2); - l->setBuddy(rconSpin); - - l = new QLabel(i18n("Serial &device"), page4, "devLabel"); - grid->addWidget(l, 5, 1); - devCombo = new KComboBox(false, page4, "devCombo"); - sl = pcfg.getConfigDevices(); - devCombo->insertStringList(sl); - devCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_SERIALDEV)); - grid->addWidget(devCombo, 5, 2); - l->setBuddy(devCombo); - - l = new QLabel(i18n("Serial &speed"), page4, "speedLabel"); - grid->addWidget(l, 7, 1); - speedCombo = new KComboBox(false, page4, "speedCombo"); - sl = pcfg.getConfigSpeeds(); - speedCombo->insertStringList(sl); - speedCombo->setCurrentItem(pcfg.getIntDefault(KPsionConfig::DEF_SERIALSPEED)); - grid->addWidget(speedCombo, 7, 2); - l->setBuddy(speedCombo); - - grid->setRowStretch(1, 1); - grid->setColStretch(1, 1); - - grid->addRowSpacing(2, KDialog::spacingHint()); - grid->addRowSpacing(4, KDialog::spacingHint()); - grid->addRowSpacing(6, KDialog::spacingHint()); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(8, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(3, KDialog::marginHint()); - - addPage(page4, - i18n("Step 3 - Connection parameters")); - - // Page 5 - page5 = new QWidget(this, "step3"); - grid = new QGridLayout(page5); - - l = new QLabel(page5, "step2"); - l->setText(i18n( - "" - "That's it!
" - "Now I will start KPsion and if your Psion is already " - "connected and its communication link turned on (use" - "Ctrl-L on the System screen), then KPsion will " - "bring up a dialog similar to this which lets you assign it a " - "name. After that, I suggest you perform a full backup.
" - "Please click Finish now.
" - )); - grid->addWidget(l, 1, 1, Qt::AlignTop); - - grid->setRowStretch(1, 1); - grid->setColStretch(1, 1); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(2, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(2, KDialog::marginHint()); - - addPage(page5, i18n("Finished")); - - setFinishEnabled(page5, true); -} - -void FirstTimeWizard:: -slotBdirBrowse() { - QString dir = KFileDialog::getExistingDirectory(bdirLabel->text(), this, - i18n("Backup folder")); - checkBackupDir(dir); -} - -void FirstTimeWizard:: -reject() { - // kapp->quit() and [QK]Application::exit(0) don't work here?! - // probably because we didn't call kapp->exec() yet? - // -> brute force - if (KMessageBox::questionYesNo(this, - i18n("You are about to abort the initial setup of KPsion. No configuration will be stored and you will have to repeat this procedure when you start KPsion next time.
Do you really want to exit now?
")) == KMessageBox::Yes) { - if (!bdirCreated.isEmpty()) - ::rmdir(bdirCreated.data()); - ::exit(0); - } -} - -void FirstTimeWizard:: -accept() { - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDIR)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR), - bdirLabel->text()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPGEN)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_BACKUPGEN), - genSpin->value()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_INCINTERVAL)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_INCINTERVAL), - iIntCombo->currentItem()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_FULLINTERVAL)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_FULLINTERVAL), - fIntCombo->currentItem()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_CONNRETRY)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_CONNRETRY), - rconSpin->value()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALDEV)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALDEV), - devCombo->currentText()); - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_SERIALSPEED)); - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_SERIALSPEED), - speedCombo->currentText()); - - hide(); - setResult(Accepted); -} - -void FirstTimeWizard:: -next() { - for (int i = 0; i < pageCount(); i++) - if (currentPage() == page(i)) { - switch (i) { - case 1: - QString dir(bdirLabel->text()); - if (!checkBackupDir(dir)) - return; - } - break; - } - KWizard::next(); -} - -void FirstTimeWizard:: -closeEvent(QCloseEvent *e) { - reject(); -} - -bool FirstTimeWizard:: -checkBackupDir(QString &dir) { - if (!bdirCreated.isEmpty()) { - if (bdirCreated != dir) { - ::rmdir(bdirCreated.data()); - bdirCreated = ""; - } - } - if (!dir.isEmpty()) { - QDir d(dir); - if (!d.exists()) { - if (KMessageBox::questionYesNo(this, - i18n("The folder %1 does not exist.
Shall it be created?
").arg(dir)) == KMessageBox::No) { - bdirLabel->setText(bdirDefault); - return false; - } - if (mkdir(dir.data(), 0700) != 0) { - QString msg = i18n("The specified folder
%1
could not be created"); - switch (errno) { - case EACCES: - case EPERM: - case EROFS: - msg += i18n(", because you either don't have sufficient rights to do that, or the filesystem is readonly."); - // Insufficient permissions/ readonly FS - break; - case ENOSPC: - msg += i18n(", because the filesystem has not enough space."); - // No space - break; - case EEXIST: - // shouldn't happen, we checked already - // for existence. - msg += i18n(", because there already exists another object with the same name."); - break; - case EFAULT: - case ENOMEM: - case ENAMETOOLONG: - // shouldn't happen. - msg += "."; - break; - case ENOENT: - // propably dangling symlink - msg += i18n(", because you specified a path which probably contains a dangling symbolic link."); - break; - case ENOTDIR: - msg += i18n(", because you specified a path which contains an element which is not a folder."); - // path element not dir. - break; - case ELOOP: - msg += i18n(", because you specified a path which contains too many symbolic links."); - // Too many symlinks - break; - - - } - bdirLabel->setText(bdirDefault); - msg += i18n("
Please select another folder.
"); - KMessageBox::error(this, msg.arg(dir)); - return false; - } - bdirCreated = dir; - } - bdirLabel->setText(dir); - return true; - } - bdirLabel->setText(bdirDefault); - return false; -} - -NewPsionWizard::NewPsionWizard(QWidget *parent, const char *name) - : KWizard(parent, name, true) { - - setCaption(i18n("New Psion detected")); - psion = (KPsionMainWindow *)parent; - - QWhatsThis::add(nextButton(), - i18n("Click this button to continue with the next page.")); - QWhatsThis::add(backButton(), - i18n("Click this button, to go to a previous page.")); - QWhatsThis::add(cancelButton(), - i18n("If you click this button, the setup for the new connected Psion will be aborted and next time you connect this Psion again, KPsion will run this setup again.")); - - // Page 1 - page1 = new QWidget(this, "newmachine"); - QGridLayout *grid = new QGridLayout(page1); - - QLabel *l = new QLabel(page1, "newmachmessage"); - uid = psion->getMachineUID(); - l->setText(i18n( - "" - "The Psion with the unique ID %1 " - "is connected the first time. Please assign a name to it." - "").arg(uid)); - grid->addMultiCellWidget(l, 1, 1, 1, 2, Qt::AlignTop); - - l = new QLabel(page1, "nameLabel"); - l->setText(i18n("&Name of new Psion")); - nameEdit = new KLineEdit(page1, "nameEdit"); - nameEdit->setText(i18n("My new Psion")); - nameEdit->selectAll(); - nameEdit->setFocus(); - l->setBuddy(nameEdit); - grid->addWidget(l, 3, 1); - grid->addWidget(nameEdit, 3, 2); - - grid->setColStretch(1, 1); - grid->setRowStretch(1, 1); - - grid->addRowSpacing(2, KDialog::spacingHint()); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(4, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(2, KDialog::marginHint()); - - addPage(page1, i18n("New Psion detected")); - - // Page 2 - page2 = new QWidget(this, "bdrives"); - grid = new QGridLayout(page2); - - l = new QLabel(page2, "bdrivemessage"); - l->setText(i18n( - "" - "Please select the Drive(s), you want to be backed up when " - "running in unattended backup mode." - "" - )); - grid->addMultiCellWidget(l, 1, 1, 1, 3, Qt::AlignTop); - - backupListView = new KListView(page2, "bdriveListView"); - backupListView->addColumn(i18n("Available drives")); - driveMap dlist = psion->getDrives(); - driveMap::Iterator it; - int height = backupListView->header()->height(); - for (it = dlist.begin(); it != dlist.end(); it++) { - QCheckListItem *i = new QCheckListItem(backupListView, it.data(), - QCheckListItem::CheckBox); - height += i->height(); - i->setSelectable(false); - } - backupListView->setMaximumSize(backupListView->columnWidth(0) + 5, height + 5); - grid->addWidget(backupListView, 3, 2); - - grid->setColStretch(1, 1); - grid->setRowStretch(1, 1); - grid->setColStretch(3, 1); - - grid->addRowSpacing(2, KDialog::spacingHint()); - - grid->addRowSpacing(0, KDialog::marginHint()); - grid->addRowSpacing(4, KDialog::marginHint()); - grid->addColSpacing(0, KDialog::marginHint()); - grid->addColSpacing(4, KDialog::marginHint()); - - addPage(page2, i18n("Specify drives to backup")); - - setFinishEnabled(page2, true); -} - -void NewPsionWizard:: -next() { - for (int i = 0; i < pageCount(); i++) - if (currentPage() == page(i)) { - switch (i) { - case 0: - QString tmp(nameEdit->text()); - if (!checkPsionName(tmp)) - return; - } - break; - } - KWizard::next(); -} - -bool NewPsionWizard:: -checkPsionName(QString &name) { - if (name.isEmpty()) { - KMessageBox::sorry(this, i18n("The name cannot be empty.")); - return false; - } - psionMap l = psion->getMachines(); - psionMap::Iterator it; - for (it = l.begin(); it != l.end(); it++) { - if (name == it.data()) { - KMessageBox::sorry(this, i18n("The name %1 is already assigned to another machine.
Please choose a different name.
")); - return false; - } - } - return true; -} - -void NewPsionWizard:: -accept() { - KConfig *config = kapp->config(); - KPsionConfig pcfg; - - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_UIDS)); - QStringList machines = config->readListEntry( - pcfg.getOptionName(KPsionConfig::OPT_UIDS)); - machines += uid; - config->writeEntry(pcfg.getOptionName(KPsionConfig::OPT_UIDS), machines); - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_MACHNAME)); - QString tmp = pcfg.getOptionName(KPsionConfig::OPT_MACHNAME).arg(uid); - config->writeEntry(tmp, nameEdit->text()); - tmp = nameEdit->text(); - psion->setMachineName(tmp); - driveMap dlist = psion->getDrives(); - driveMap::Iterator di; - QStringList drives; - for (di = dlist.begin(); di != dlist.end(); di++) { - QString drv = ""; - drv += di.key(); - drives += drv; - } - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_DRIVES)); - config->writeEntry( - pcfg.getOptionName(KPsionConfig::OPT_DRIVES).arg(uid), drives); - - QListViewItemIterator li(backupListView); - QStringList bdrives; - for (; li.current(); li++) { - QCheckListItem *qcli = (QCheckListItem *)(li.current()); - if (qcli->isOn()) { - tmp = qcli->text(); - for (di = dlist.begin(); di != dlist.end(); di++) - if (di.data() == tmp) { - QString drv = ""; - drv += di.key(); - bdrives += drv; - } - } - } - config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_BACKUPDRIVES)); - config->writeEntry( - pcfg.getOptionName(KPsionConfig::OPT_BACKUPDRIVES).arg(uid), bdrives); - hide(); - setResult(Accepted); -} - -/* - * Local variables: - * c-basic-offset: 4 - * End: - */ diff --git a/kde2/kpsion/wizards.h b/kde2/kpsion/wizards.h deleted file mode 100644 index 6edd8d9..0000000 --- a/kde2/kpsion/wizards.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _WIZARDS_H_ -#define _WIZARDS_H_ - -#include "kpsion.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -class FirstTimeWizard : public KWizard { - Q_OBJECT - public: - FirstTimeWizard(QWidget *parent = 0, const char *name = 0); - - protected: - virtual void closeEvent(QCloseEvent *e); - virtual void reject(); - virtual void accept(); - - protected slots: - virtual void next(); - - private slots: - void slotBdirBrowse(); - - private: - bool checkBackupDir(QString &); - - QWidget *page1; - QWidget *page2; - QWidget *page3; - QWidget *page4; - QWidget *page5; - QLabel *bdirLabel; - KIntSpinBox *genSpin; - KIntSpinBox *rconSpin; - QPushButton *bdirButton; - QCheckBox *remCheck; - KComboBox *iIntCombo; - KComboBox *fIntCombo; - KComboBox *devCombo; - KComboBox *speedCombo; - - QString bdirDefault; - QString bdirCreated; -}; - -class NewPsionWizard : public KWizard { - Q_OBJECT - - public: - NewPsionWizard(QWidget *parent = 0, const char *name = 0); - - protected: - virtual void accept(); - - protected slots: - virtual void next(); - - private: - bool checkPsionName(QString &); - - QWidget *page1; - QWidget *page2; - KPsionMainWindow *psion; - KLineEdit *nameEdit; - KListView *backupListView; - - QString uid; - QString machineName; -}; -#endif -- cgit v1.2.3