Beispiel #1
0
PlanExecutor::PlanExecutor(BackupPlan *pPlan, KupDaemon *pKupDaemon)
   :QObject(pKupDaemon), mState(NOT_AVAILABLE), mPlan(pPlan), mQuestion(nullptr),
     mFailNotification(nullptr), mIntegrityNotification(nullptr), mRepairNotification(nullptr),
     mKupDaemon(pKupDaemon), mSleepCookie(0)
{
	QString lCachePath = QString::fromLocal8Bit(qgetenv("XDG_CACHE_HOME").constData());
	if(lCachePath.isEmpty()) {
		lCachePath = QDir::homePath();
		lCachePath.append(QStringLiteral("/.cache"));
	}
	lCachePath.append(QStringLiteral("/kup"));
	QDir lCacheDir(lCachePath);
	if(!lCacheDir.exists()) {
		if(!lCacheDir.mkpath(lCachePath)) {
			lCachePath = QStringLiteral("/tmp");
		}
	}
	mLogFilePath = lCachePath;
	mLogFilePath.append(QStringLiteral("/kup_plan"));
	mLogFilePath.append(QString::number(mPlan->planNumber()));
	mLogFilePath.append(QStringLiteral(".log"));

	mSchedulingTimer = new QTimer(this);
	mSchedulingTimer->setSingleShot(true);
	connect(mSchedulingTimer, SIGNAL(timeout()), SLOT(enterAvailableState()));
}
Beispiel #2
0
void PlanExecutor::updateAccumulatedUsageTime() {
	if(mState == RUNNING) { //usage time during backup doesn't count...
		return;
	}

	if(mPlan->mScheduleType == BackupPlan::USAGE) {
		mPlan->mAccumulatedUsageTime += KUP_USAGE_MONITOR_INTERVAL_S;
		mPlan->writeConfig();
	}

	// trigger refresh of backup status, potentially changed since some time has passed...
	// this is the reason why this slot is called repeatedly even when
	// not in BackupPlan::USAGE mode
	emit backupStatusChanged();

	//if we're waiting to run backup again, check if it is time now.
	if(mPlan->mScheduleType == BackupPlan::USAGE &&
	      (mState == WAITING_FOR_FIRST_BACKUP || mState == WAITING_FOR_BACKUP_AGAIN)) {
		enterAvailableState();
	}
}
Beispiel #3
0
void PlanExecutor::exitBackupRunningState(bool pWasSuccessful) {
	mRunBackupAction->setEnabled(true);
	if(pWasSuccessful) {
		if(mPlan->mScheduleType == BackupPlan::USAGE) {
			//reset usage time after successful backup
			mPlan->mAccumulatedUsageTime =0;
			mPlan->writeConfig();
		}
		mState = WAITING_FOR_BACKUP_AGAIN;
		emit stateChanged();

		//don't know if status actually changed, potentially did... so trigger a re-read of status
		emit backupStatusChanged();

		// re-enter the main "available" state dispatcher
		enterAvailableState();
	} else {
		mState = WAITING_FOR_MANUAL_BACKUP;
		emit stateChanged();
	}
}
Beispiel #4
0
PlanExecutor::PlanExecutor(BackupPlan *pPlan, QObject *pParent)
   :QObject(pParent), mState(NOT_AVAILABLE), mPlan(pPlan), mBupFuseProcess(NULL), mQuestion(NULL), mOkToShowBackup(false)
{
	mShowFilesAction = new QAction(i18nc("@action:inmenu", "Show Files"), this);
	if(mPlan->mBackupType == BackupPlan::BupType) {
		mShowFilesAction->setCheckable(true);
	}
	mShowFilesAction->setEnabled(false);
	connect(mShowFilesAction, SIGNAL(triggered()), SLOT(showFilesClicked()));

	mRunBackupAction = new QAction(i18nc("@action:inmenu", "Take Backup Now"), this);
	mRunBackupAction->setEnabled(false);
	connect(mRunBackupAction, SIGNAL(triggered()), SLOT(enterBackupRunningState()));

	mActionMenu = new QMenu(mPlan->mDescription);
	mActionMenu->setEnabled(false);
	mActionMenu->addAction(mRunBackupAction);
	mActionMenu->addAction(mShowFilesAction);

	mSchedulingTimer = new QTimer(this);
	mSchedulingTimer->setSingleShot(true);
	connect(mSchedulingTimer, SIGNAL(timeout()), SLOT(enterAvailableState()));
}