diff options
| author | Fritz Elfert <felfert@to.com> | 2001-03-27 01:17:19 +0000 | 
|---|---|---|
| committer | Fritz Elfert <felfert@to.com> | 2001-03-27 01:17:19 +0000 | 
| commit | fb6e57695452dc5265a35532f74e918490880723 (patch) | |
| tree | 1f3f2738ed4466b3505eb0cecfcf9e3ec2a0757f /kde2 | |
| parent | c1c226e16aa579be9e64cba3c4bdca201923096c (diff) | |
| download | plptools-fb6e57695452dc5265a35532f74e918490880723.tar.gz plptools-fb6e57695452dc5265a35532f74e918490880723.tar.bz2 plptools-fb6e57695452dc5265a35532f74e918490880723.zip  | |
plpprops: Changes for recent fixes in KDE-Libs
KPsion: Autobackup now handled correctly
Diffstat (limited to 'kde2')
| -rw-r--r-- | kde2/kioslave/kio_plp.cpp | 29 | ||||
| -rw-r--r-- | kde2/kioslave/kio_plp.h | 5 | ||||
| -rw-r--r-- | kde2/kpsion/kpsion.cpp | 150 | ||||
| -rw-r--r-- | kde2/kpsion/kpsion.h | 5 | ||||
| -rw-r--r-- | kde2/kpsion/kpsionbackuplistview.cpp | 25 | ||||
| -rw-r--r-- | kde2/kpsion/kpsionbackuplistview.h | 1 | ||||
| -rw-r--r-- | kde2/kpsion/kpsionconfig.cpp | 2 | ||||
| -rw-r--r-- | kde2/kpsion/kpsionconfig.h | 2 | ||||
| -rw-r--r-- | kde2/kpsion/main.cpp | 3 | ||||
| -rw-r--r-- | kde2/plugins/plpprops.desktop | 2 | 
10 files changed, 131 insertions, 93 deletions
diff --git a/kde2/kioslave/kio_plp.cpp b/kde2/kioslave/kio_plp.cpp index bfa6d70..2374dc3 100644 --- a/kde2/kioslave/kio_plp.cpp +++ b/kde2/kioslave/kio_plp.cpp @@ -322,6 +322,23 @@ uid2mime(PlpDirent &e) {  }  void PLPProtocol:: +appendUIDmime(PlpDirent &e, UDSEntry &entry) { +    QString tmp; + +    if ((e.getAttr() & rfsv::PSI_A_DIR) == 0) { +	PlpUID u = e.getUID(); +	UidMap::Iterator it = puids.find(u); +	if (it != puids.end()) { +	    UDSAtom atom; + +	    atom.m_uds = KIO::UDS_MIME_TYPE; +	    atom.m_str = it.data(); +	    entry.append(atom); +	} +    } +} + +void PLPProtocol::  listDir(const KURL& _url) {      KURL url(_url);      QString path(QFile::encodeName(url.path(-1))); @@ -371,18 +388,13 @@ listDir(const KURL& _url) {  	UDSAtom atom;  	PlpDirent e = files[i]; -	long attr = e.getAttr();  	entry.clear();  	atom.m_uds = KIO::UDS_NAME;  	atom.m_str = e.getName();  	entry.append(atom); -	if ((attr & rfsv::PSI_A_DIR) == 0) { -	    atom.m_uds = KIO::UDS_MIME_TYPE; -	    atom.m_str = uid2mime(e); -	    entry.append(atom); -	} +	appendUIDmime(e, entry);  	completeUDSEntry(entry, e, rom);  	listEntry(entry, false); @@ -431,18 +443,15 @@ createVirtualDirEntry(UDSEntry & entry, bool rdonly, int type) {  	    atom.m_long = S_IFDIR;  	    entry.append(atom);  	    atom.m_uds = KIO::UDS_GUESSED_MIME_TYPE; -	    atom.m_uds = KIO::UDS_MIME_TYPE;  	    atom.m_str = QString("inode/x-psion-drive");  	    entry.append(atom);  	    break;  	case PLP_FTYPE_DRIVE:  	    atom.m_uds = KIO::UDS_FILE_TYPE; -	    atom.m_long = S_IFDIR; +	    atom.m_long = S_IFREG;  	    entry.append(atom);  	    atom.m_uds = KIO::UDS_GUESSED_MIME_TYPE;  	    atom.m_str = QString("inode/x-psion-drive"); -	    atom.m_uds = KIO::UDS_MIME_TYPE; -	    atom.m_str = QString("inode/x-psion-drive");  	    entry.append(atom);  	    break;  	case PLP_FTYPE_OWNER: diff --git a/kde2/kioslave/kio_plp.h b/kde2/kioslave/kio_plp.h index 9119e6d..c5c0701 100644 --- a/kde2/kioslave/kio_plp.h +++ b/kde2/kioslave/kio_plp.h @@ -38,7 +38,7 @@ class PLPProtocol : public KIO::SlaveBase {  public:      PLPProtocol (const QCString &pool, const QCString &app);      virtual ~PLPProtocol(); -	 +      virtual void openConnection();      virtual void closeConnection(); @@ -74,6 +74,7 @@ private:      QString uid2mime(PlpDirent &e);      int checkSpecial(const QString& path);      void setOwner(KIO::UDSEntry & entry); +    void appendUIDmime(PlpDirent &e, KIO::UDSEntry &entry);      rfsv *plpRfsv;      rpcs *plpRpcs; @@ -81,7 +82,7 @@ private:      ppsocket *plpRpcsSocket;      QStringList drives;      QMap<QString,char> drivechars; -    UidMap puids;  +    UidMap puids;      QString currentHost;      int    currentPort;      time_t t_last; diff --git a/kde2/kpsion/kpsion.cpp b/kde2/kpsion/kpsion.cpp index 9189548..5f9b45e 100644 --- a/kde2/kpsion/kpsion.cpp +++ b/kde2/kpsion/kpsion.cpp @@ -76,6 +76,8 @@ KPsionMainWindow::KPsionMainWindow()      backupRunning = false;      restoreRunning = false;      formatRunning = false; +    doScheduledBackup = false; +    quitImmediately = true;      view = new KIconView(this, "iconview");      view->setSelectionMode(KIconView::Multi); @@ -270,6 +272,11 @@ insertDrive(char letter, const char * const name) {      it->setRenameEnabled(false);  } +bool KPsionMainWindow:: +shouldQuit() { +    return quitImmediately; +} +  void KPsionMainWindow::  queryPsion() {      u_int32_t devbits; @@ -333,6 +340,7 @@ queryPsion() {  		delete rfsvSocket;  	    if (rfsvSocket)  		delete rpcsSocket; +	    quitImmediately = true;  	    return;  	}  	NewPsionWizard *wiz = new NewPsionWizard(this, "newpsionwiz"); @@ -341,74 +349,80 @@ queryPsion() {      statusBar()->changeItem(i18n("Connected to %1").arg(machineName),  			    STID_CONNECTION); -    if (args->isSet("autobackup") || 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() { -    QString uid = getMachineUID(); -    KConfig *config = kapp->config(); -    KPsionConfig pcfg; -      if (args->isSet("autobackup")) { -	bool any = false; +	// 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); -	KPsionBackupListView *bl = new KPsionBackupListView(0, "backups"); -	bl->readBackups(uid); - -	// Full Backups +	// Check for Full Backup +	config->setGroup(pcfg.getSectionName(KPsionConfig::OPT_LASTFULL));  	for (it = backupDrives.begin(); it != backupDrives.end(); ++it) { -	    d = bl->getLastBackup(KPsionBackupListView::FULL, *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 (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { +		for (i = view->firstItem(); i; i = i->nextItem()) {  		    if (i->key() == *it) {  			i->setSelected(true); -			any = true; +			doScheduledBackup = true;  		    }  		}  	    }  	} -	if (any) { -	    delete bl; -	    doBackup(); -	    // If just made a backup, re-read backups -	    bl = new KPsionBackupListView(0, "backups"); -	    bl->readBackups(uid); -	} - -	// Incremental Backups -	any = false; -	fullBackup = false; -	view->clearSelection(); -	for (it = backupDrives.begin(); it != backupDrives.end(); ++it) { -	    d = bl->getLastBackup(KPsionBackupListView::INCREMENTAL, *it); -	    if (ii && d.daysTo(QDateTime::currentDateTime()) >= ii) { -		for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { -		    if (i->key() == *it) { -			i->setSelected(true); -			any = 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; +			}  		    }  		}  	    }  	} -	delete bl; +	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())); +    } +} -	if (any) -	    doBackup(); +void KPsionMainWindow:: +slotAutoAction() { +    QIconViewItem *i; +    if (doScheduledBackup) { +	doBackup(); +	QTimer::singleShot(1000, this, SLOT(close()));  	return;      } @@ -421,7 +435,7 @@ slotAutoAction() {  	for (it = argl.begin(); it != argl.end(); ++it) {  	    QString drv((*it).upper()); -	    for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { +	    for (i = view->firstItem(); i; i = i->nextItem()) {  		if (i->key() == drv) {  		    i->setSelected(true);  		    any = true; @@ -432,6 +446,7 @@ slotAutoAction() {  	    fullBackup = true;  	    doBackup();  	} +	QTimer::singleShot(1000, this, SLOT(close()));  	return;      } @@ -449,7 +464,7 @@ slotAutoAction() {  		    "a <B>ROM</B> drive and therefore cannot be restored.</QT>"));  		continue;  	    } -	    for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { +	    for (i = view->firstItem(); i; i = i->nextItem()) {  		if (i->key() == drv) {  		    i->setSelected(true);  		    any = true; @@ -458,6 +473,7 @@ slotAutoAction() {  	}  	if (any)  	    slotStartRestore(); +	QTimer::singleShot(1000, this, SLOT(close()));  	return;      } @@ -468,7 +484,7 @@ slotAutoAction() {  	for (it = argl.begin(); it != argl.end(); ++it) {  	    QString drv((*it).upper()); -	    for (QIconViewItem *i = view->firstItem(); i; i = i->nextItem()) { +	    for (i = view->firstItem(); i; i = i->nextItem()) {  		if (i->key() == drv) {  		    i->setSelected(true);  		    any = true; @@ -477,8 +493,10 @@ slotAutoAction() {  	}  	if (any)  	    slotStartFormat(); +	QTimer::singleShot(1000, this, SLOT(close()));  	return;      } +    QTimer::singleShot(1000, this, SLOT(close()));  }  QString KPsionMainWindow:: @@ -665,6 +683,22 @@ findTarEntry(const KTarEntry *te, QString path, QString rpath) {  }  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(); @@ -707,7 +741,9 @@ doBackup() {  	emit setProgress(0);  	statusBar()->changeItem(i18n("Connected to %1").arg(machineName),  				STID_CONNECTION); -	KMessageBox::information(this, i18n("No files need backup")); +	updateBackupStamps(); +	if (!args->isSet("autobackup")) +	    KMessageBox::information(this, i18n("No files need backup"));  	backupRunning = false;  	switchActions();  	return; @@ -740,7 +776,7 @@ doBackup() {      archiveName += (fullBackup) ? "/F-" : "/I-";      time_t now = time(0);      char tstr[30]; -    strftime(tstr, sizeof(tstr), "%Y-%m-%d-%H-%M-%S.tar.gz", +    strftime(tstr, sizeof(tstr), "%Y-%m-%d-%H-%M-%S.tmp.gz",  	     localtime(&now));      archiveName += tstr;      backupTgz = new KTarGz(archiveName); @@ -827,6 +863,7 @@ doBackup() {  	    }  	    updateProgress(e.getSize());  	} +	updateBackupStamps();      }      // Restart previously running applications on the Psion      // from saved state info. @@ -835,7 +872,14 @@ doBackup() {      backupTgz->close();      delete backupTgz;      if (badBackup) -	unlink(archiveName.data()); +	::unlink(archiveName.latin1()); +    else { +	// Rename Tarfile to its final name; +	::rename(archiveName.latin1(), +		 archiveName.replace(QRegExp("\\.tmp\\.gz$"), ".tar.gz")); + +    } +      backupRunning = false;      switchActions();      statusBar()->changeItem(i18n("Connected to %1").arg(machineName), diff --git a/kde2/kpsion/kpsion.h b/kde2/kpsion/kpsion.h index 748450e..1ec7715 100644 --- a/kde2/kpsion/kpsion.h +++ b/kde2/kpsion/kpsion.h @@ -54,7 +54,7 @@ public:      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); @@ -100,6 +100,7 @@ private:      bool askOverwrite(PlpDirent e);      void setDriveName(const char dchar, QString dname);      void doFormat(QString drive); +    void updateBackupStamps();      rfsv *plpRfsv;      rpcs *plpRpcs; @@ -130,7 +131,9 @@ private:      bool firstTry;      bool shuttingDown;      bool fullBackup; +    bool doScheduledBackup;      bool overWriteAll; +    bool quitImmediately;      int reconnectTime;      int nextTry;      int ncpdSpeed; diff --git a/kde2/kpsion/kpsionbackuplistview.cpp b/kde2/kpsion/kpsionbackuplistview.cpp index ed4808a..c51c62d 100644 --- a/kde2/kpsion/kpsionbackuplistview.cpp +++ b/kde2/kpsion/kpsionbackuplistview.cpp @@ -391,31 +391,6 @@ getFormatDrives() {      return l;  } -QDateTime KPsionBackupListView:: -getLastBackup(int backupType, QString drive) { -    time_t stamp = 0; - -    drive += ":"; -    // Find latest backup for given drive -    KPsionCheckListItem *i = firstChild(); -    while (i != 0L) { -	if ((backupType >= i->backupType()) && (i->when() > stamp)) { -	    KPsionCheckListItem *c = i->firstChild(); -	    while (c != 0L) { -		if (c->text() == drive) { -		    stamp = i->when(); -		    break; -		} -		c = c->nextSibling(); -	    } -	} -	i = i->nextSibling(); -    } -    QDateTime d; -    d.setTime_t(stamp); -    return d; -} -  bool KPsionBackupListView::  autoSelect(QString drive) {      KPsionCheckListItem *latest = NULL; diff --git a/kde2/kpsion/kpsionbackuplistview.h b/kde2/kpsion/kpsionbackuplistview.h index 7119eb6..1a28ad0 100644 --- a/kde2/kpsion/kpsionbackuplistview.h +++ b/kde2/kpsion/kpsionbackuplistview.h @@ -103,7 +103,6 @@ public:      QStringList getSelectedTars();      QStringList getFormatDrives();      bool autoSelect(QString drive); -    QDateTime getLastBackup(int backupType, QString drive);  signals:      void itemsEnabled(bool); diff --git a/kde2/kpsion/kpsionconfig.cpp b/kde2/kpsion/kpsionconfig.cpp index 976ae69..bd08b6d 100644 --- a/kde2/kpsion/kpsionconfig.cpp +++ b/kde2/kpsion/kpsionconfig.cpp @@ -40,6 +40,8 @@ KPsionConfig::KPsionConfig() {      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"));      defaults.insert(DEF_INCINTERVAL, QString("1"));      defaults.insert(DEF_FULLINTERVAL, QString("7")); diff --git a/kde2/kpsion/kpsionconfig.h b/kde2/kpsion/kpsionconfig.h index f0ae075..1b8de31 100644 --- a/kde2/kpsion/kpsionconfig.h +++ b/kde2/kpsion/kpsionconfig.h @@ -45,6 +45,8 @@ public:  	OPT_MACHNAME = 8,  	OPT_BACKUPDRIVES = 9,  	OPT_DRIVES = 10, +	OPT_LASTFULL = 11, +	OPT_LASTINC = 12,      };      enum cfgDefaults { diff --git a/kde2/kpsion/main.cpp b/kde2/kpsion/main.cpp index d8d1c10..6c2aaf9 100644 --- a/kde2/kpsion/main.cpp +++ b/kde2/kpsion/main.cpp @@ -109,8 +109,9 @@ int main(int argc, char **argv) {      KPsionMainWindow *w = new KPsionMainWindow(); -    if (args->isSet("autobackup") && (!w->isConnected())) +    if (w->shouldQuit())  	return 0; +      w->resize(300, 170);      a.setMainWidget(w);      w->show(); diff --git a/kde2/plugins/plpprops.desktop b/kde2/plugins/plpprops.desktop index 9fc8b2f..55cc87c 100644 --- a/kde2/plugins/plpprops.desktop +++ b/kde2/plugins/plpprops.desktop @@ -38,3 +38,5 @@ Comment[tr]=Özellikler İletişim Kutusu İçin Eklenti  Comment[uk]=Додаток для діалогу властивостей  Comment[zh_CN.GB2312]=属性对话的插件  Comment[zh_TW.Big5]=外掛內容對話框 + +X-KDE-Protocol=psion  | 
