void KSUpgradeManager::slotCheckDownload(KIO::Job*, const QString &download, const QString &url) { switch(m_downloadState) { case(REMOVE_BACKUP): { KIO::DeleteJob *temp = KIO::del(KURL(download+"~"), false, false); m_localFile = download; m_remoteFile = url; connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = BACKUP; break; } case(BACKUP): { KIO::CopyJob *temp = KIO::move(KURL(m_localFile), KURL(m_localFile+"~"), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = DOWNLOAD; break; } case(DOWNLOAD): { KIO::CopyJob *temp = KIO::copy(KURL(m_remoteFile), KURL(m_localFile), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); connect(temp, SIGNAL(percent(KIO::Job*, unsigned long)), this, SLOT(slotProgress(KIO::Job*, unsigned long))); temp->setInteractive(false); m_downloadState = COMPLETE; break; } case(DELETE_VERSION): { KIO::DeleteJob *temp = KIO::del(KURL(locateLocal("appdata", "version")), false, false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = MOVE_VERSION; break; } case(MOVE_VERSION): { KIO::CopyJob *temp = KIO::move(KURL("/tmp/version"), KURL(locateLocal("appdata", "version")), false); connect(temp, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckDownload(KIO::Job*))); temp->setInteractive(false); m_downloadState = -1; break; } case(COMPLETE): { m_mainWidget->downloadProgress->setProgress(0); m_mainWidget->currentLabel->setText(i18n("nothing")); m_completedDownloads++; m_downloadState = DELETE_VERSION; slotCheckDownload(0); KSlovar::KSInstance()->loadLanguages(); break; } } }
void JobTest::moveFileNoPermissions() { kdDebug() << k_funcinfo << endl; const QString src = "/etc/passwd"; const QString dest = homeTmpDir() + "passwd"; assert(QFile::exists(src)); assert(QFileInfo(src).isFile()); KURL u; u.setPath(src); KURL d; d.setPath(dest); KIO::CopyJob *job = KIO::move(u, d, 0); job->setInteractive(false); // no skip dialog, thanks QMap< QString, QString > metaData; bool ok = KIO::NetAccess::synchronousRun(job, 0, 0, 0, &metaData); assert(!ok); assert(KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED); // OK this is fishy. Just like mv(1), KIO's behavior depends on whether // a direct rename(2) was used, or a full copy+del. In the first case // there is no destination file created, but in the second case the // destination file remains. // In fact we assume /home is a separate partition, in this test, so: assert(QFile::exists(dest)); assert(QFile::exists(src)); }
void KSWizard::slotFinish() { Configuration::setMouseNavigation(m_mouseNavigation->isChecked()); Configuration::setScrollBar(m_scrollBar->isChecked()); Configuration::setSmoothScroll(m_smoothScroll->isChecked()); Configuration::setAutoUpdateLanguage(m_upgradeManager->isChecked()); // Configuration::setAuthorName(m_authorName->text()); // Configuration::setAuthorEmail(m_authorEmail->text()); Configuration::writeConfig(); if(m_remoteLanguages->isChecked()) { m_downloadProgress->setShown(true); m_downloadLabel->setShown(true); KIO::copy(KURL("http://kslovar.berlios.de/version"), KURL(locateLocal("appdata", "version", false)))->setInteractive(false); KIO::CopyJob *download = KIO::copy(KURL("http://kslovar.berlios.de/languages.ldft"), KURL(locateLocal("appdata", "languages.ldft", false)), false); connect(download, SIGNAL(result(KIO::Job*)), this, SLOT(slotCompletedDownload(KIO::Job*))); connect(download, SIGNAL(percent(KIO::Job*, unsigned long)), this, SLOT(slotProgress(KIO::Job*, unsigned long))); download->setInteractive(false); }
void JobTest::moveDirectoryNoPermissions() { kdDebug() << k_funcinfo << endl; const QString src = "/etc/init.d"; const QString dest = homeTmpDir() + "init.d"; assert(QFile::exists(src)); assert(QFileInfo(src).isDir()); KURL u; u.setPath(src); KURL d; d.setPath(dest); KIO::CopyJob *job = KIO::move(u, d, 0); job->setInteractive(false); // no skip dialog, thanks QMap< QString, QString > metaData; bool ok = KIO::NetAccess::synchronousRun(job, 0, 0, 0, &metaData); assert(!ok); assert(KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED); assert(QFile::exists(dest)); // see moveFileNoPermissions assert(QFile::exists(src)); }
KSUpgradeManager::KSUpgradeManager(QWidget *parent, const QString &caption) : KDialogBase(parent, "KSDownloadManager", true, caption, Ok|Cancel), m_completedDownloads(0) { KIO::CopyJob *copy; //Setting up the basics... setButtonText(ButtonCode(Ok), i18n("Upgrade")); setButtonText(ButtonCode(Cancel), i18n("Close")); enableButtonOK(false); m_mainWidget = new KSUpgradeManagerWdt(this); setMainWidget(m_mainWidget); m_mainWidget->downloadList->addColumn(i18n("File")); //Download versioning files... m_mainWidget->currentLabel->setText(i18n("Version files")); copy = KIO::copy(KURL("http://kslovar.berlios.de/version"), KURL("/tmp/version"), false); connect(copy, SIGNAL(result(KIO::Job*)), this, SLOT(slotCheckVersion())); connect(copy, SIGNAL(percent(KIO::Job*, unsigned long)), this, SLOT(slotProgress(KIO::Job*, unsigned long))); copy->setInteractive(false); }