예제 #1
0
void AccountSettings::slotFolderWizardRejected()
{
    qDebug() << "* Folder wizard cancelled";
    FolderMan *folderMan = FolderMan::instance();
    folderMan->setSyncEnabled(true);
    folderMan->slotScheduleAllFolders();
}
예제 #2
0
void Application::slotConnectionValidatorResult(ConnectionValidator::Status status)
{
    qDebug() << "Connection Validator Result: " << _conValidator->statusString(status);
    QStringList startupFails;

    if( status == ConnectionValidator::Connected ) {
        FolderMan *folderMan = FolderMan::instance();
        qDebug() << "######## Connection and Credentials are ok!";
        folderMan->setSyncEnabled(true);
        // queue up the sync for all folders.
        folderMan->slotScheduleAllFolders();
    } else {
        // if we have problems here, it's unlikely that syncing will work.
        FolderMan::instance()->setSyncEnabled(false);

        startupFails = _conValidator->errors();
        _startupNetworkError = _conValidator->networkError();
        if (_userTriggeredConnect) {
            _userTriggeredConnect = false;
        }
        QTimer::singleShot(30*1000, this, SLOT(slotCheckConnection()));
    }
    _gui->startupConnected( (status == ConnectionValidator::Connected), startupFails);

    _conValidator->deleteLater();
}
예제 #3
0
void AccountSettings::slotRemoveCurrentFolder()
{
    QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
    if( selected.isValid() ) {
        QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
        qDebug() << "Remove Folder alias " << alias;
        if( !alias.isEmpty() ) {
            // remove from file system through folder man
            // _model->removeRow( selected.row() );
            int ret = QMessageBox::question( this, tr("Confirm Folder Remove"),
                                             tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
                                                "<p><b>Note:</b> This will not remove the files from your client.</p>").arg(alias),
                                             QMessageBox::Yes|QMessageBox::No );

            if( ret == QMessageBox::No ) {
                return;
            }
            FolderMan *folderMan = FolderMan::instance();
            folderMan->slotRemoveFolder( alias );
            setFolderList(folderMan->map());
            emit folderChanged();
            slotCheckConnection();
        }
    }
}
예제 #4
0
void Application::slotAccountStateChanged(int state)
{
    FolderMan* folderMan = FolderMan::instance();
    switch (state) {
    case AccountState::Connected:
        qDebug() << "Enabling sync scheduler, scheduling all folders";
        folderMan->setSyncEnabled(true);
        folderMan->slotScheduleAllFolders();
        break;
    case AccountState::ServiceUnavailable:
    case AccountState::SignedOut:
    case AccountState::ConfigurationError:
    case AccountState::NetworkError:
    case AccountState::Disconnected:
        qDebug() << "Disabling sync scheduler, terminating sync";
        folderMan->setSyncEnabled(false);
        folderMan->terminateSyncProcess();
        break;
    }

    // Stop checking the connection if we're manually signed out or
    // when the error is permanent.
    if (state == AccountState::SignedOut
            || state == AccountState::ConfigurationError) {
        _checkConnectionTimer.stop();
    } else if (! _checkConnectionTimer.isActive()) {
        _checkConnectionTimer.start();
    }

    slotUpdateConnectionErrors(state);
}
void OwncloudSetupWizard::startWizard()
{
    FolderMan *folderMan = FolderMan::instance();
    bool multiFolderSetup = folderMan->map().count() > 1;
    // ###
    Account *account = Account::restore();
    if (!account) {
        _ocWizard->setConfigExists(false);
        account = new Account;
        account->setCredentials(CredentialsFactory::create("dummy"));
    } else {
        _ocWizard->setConfigExists(true);
    }
    account->setSslErrorHandler(new SslDialogErrorHandler);
    _ocWizard->setAccount(account);
    _ocWizard->setOCUrl(account->url().toString());

    _remoteFolder = Theme::instance()->defaultServerFolder();
    // remoteFolder may be empty, which means /
    QString localFolder = Theme::instance()->defaultClientFolder();

    // if its a relative path, prepend with users home dir, otherwise use as absolute path

    if( !QDir(localFolder).isAbsolute() ) {
        localFolder = QDir::homePath() + QDir::separator() + localFolder;
    }

    if (!multiFolderSetup) {
        QList<Folder*> folders = folderMan->map().values();
        if (!folders.isEmpty()) {
            Folder* folder = folders.first();
            localFolder = QDir(folder->path()).absolutePath();
        }
    }

    _ocWizard->setProperty("localFolder", localFolder);

    // remember the local folder to compare later if it changed, but clean first
    QString lf = QDir::fromNativeSeparators(localFolder);
    if( !lf.endsWith(QLatin1Char('/'))) {
        lf.append(QLatin1Char('/'));
    }

    _initLocalFolder = lf;

    _ocWizard->setRemoteFolder(_remoteFolder);

    _ocWizard->setStartId(WizardCommon::Page_ServerSetup);

    _ocWizard->restart();

    // settings re-initialized in initPage must be set here after restart
    _ocWizard->setMultipleFoldersExist( multiFolderSetup );

    _ocWizard->open();
    _ocWizard->raise();
}
예제 #6
0
void ProtocolWidget::slotClearBlacklist()
{
    FolderMan *folderMan = FolderMan::instance();

    Folder::Map folders = folderMan->map();

    foreach( Folder *f, folders ) {
        int num = f->slotWipeBlacklist();
        qDebug() << num << "entries were removed from"<< f->alias() << "blacklist";
    }
예제 #7
0
// Method executed when the user ends has finished the basic setup.
void OwncloudSetupWizard::slotAssistantFinished( int result )
{
    FolderMan *folderMan = FolderMan::instance();

    if( result == QDialog::Rejected ) {
        // the old config remains valid. Remove the temporary one.
        _ocWizard->account()->deleteLater();
        qDebug() << "Rejected the new config, use the old!";
    } else if( result == QDialog::Accepted ) {

        Account *newAccount = _ocWizard->account();
        Account *origAccount = AccountManager::instance()->account();
        const QString localFolder = _ocWizard->localFolder();

        bool isInitialSetup = (origAccount == 0);
        bool reinitRequired = newAccount->changed(origAccount, true /* ignoreProtocol, allows http->https */);
        bool startFromScratch = _ocWizard->field("OCSyncFromScratch").toBool();

        // This distinguishes three possibilities:
        // 1. Initial setup, no prior account exists
        if (isInitialSetup) {
            folderMan->addFolderDefinition(Theme::instance()->appName(),
                                           localFolder, _remoteFolder );
            replaceDefaultAccountWith(newAccount);
        }
        // 2. Server URL or user changed, requires reinit of folders
        else if (reinitRequired) {
            // 2.1: startFromScratch: (Re)move local data, clean slate sync
            if (startFromScratch) {
                if (ensureStartFromScratch(localFolder)) {
                    folderMan->addFolderDefinition(Theme::instance()->appName(),
                                                   localFolder, _remoteFolder );
                    _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
                    replaceDefaultAccountWith(newAccount);
                }
            }
            // 2.2: Reinit: Remove journal and start a sync
            else {
                folderMan->removeAllFolderDefinitions();
                folderMan->addFolderDefinition(Theme::instance()->appName(),
                                               localFolder, _remoteFolder );
                _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
                replaceDefaultAccountWith(newAccount);
            }
        }
        // 3. Existing setup, http -> https or password changed
        else {
            replaceDefaultAccountWith(newAccount);
            qDebug() << "Only password was changed, no changes to folder configuration.";
        }
    }

    // notify others.
    emit ownCloudWizardDone( result );
}
예제 #8
0
void AccountSettings::slotAddFolder()
{
    FolderMan *folderMan = FolderMan::instance();
    folderMan->setSyncEnabled(false); // do not start more syncs.

    FolderWizard *folderWizard = new FolderWizard(this);

    connect(folderWizard, SIGNAL(accepted()), SLOT(slotFolderWizardAccepted()));
    connect(folderWizard, SIGNAL(rejected()), SLOT(slotFolderWizardRejected()));
    folderWizard->open();
}
예제 #9
0
void SettingsDialogMac::slotSyncStateChange(const QString& alias)
{
    FolderMan *folderMan = FolderMan::instance();
    SyncResult state = folderMan->accountStatus(folderMan->map().values());
    QIcon accountIcon = Theme::instance()->syncStateIcon(state.status());
    setPreferencesPanelIcon(_accountIdx, accountIcon);

    Folder *folder = folderMan->folder(alias);
    if( folder ) {
        _accountSettings->slotUpdateFolderState(folder);
    }
}
예제 #10
0
void ProtocolWidget::slotRetrySync()
{
    FolderMan *folderMan = FolderMan::instance();

    Folder::Map folders = folderMan->map();

    foreach( Folder *f, folders ) {
        int num = f->slotWipeErrorBlacklist();
        qDebug() << num << "entries were removed from"
                 << f->alias() << "blacklist";

        num = f->slotDiscardDownloadProgress();
        qDebug() << num << "temporary files with partial downloads"
                 << "were removed from" << f->alias();
    }
예제 #11
0
void Application::slotownCloudWizardDone( int res )
{
    FolderMan *folderMan = FolderMan::instance();
    if( res == QDialog::Accepted ) {
        int cnt = folderMan->setupFolders();
        qDebug() << "Set up " << cnt << " folders.";
        // We have some sort of configuration. Enable autostart
        Utility::setLaunchOnStartup(_theme->appName(), _theme->appNameGUI(), true);
    }
    folderMan->setSyncEnabled( true );
    if( res == QDialog::Accepted ) {
        slotCheckConnection();
    }

}
예제 #12
0
void Application::slotLogout()
{
    Account *a = AccountManager::instance()->account();
    if (a) {
        // invalidate & forget token/password
        a->credentials()->invalidateToken(a);
        // terminate all syncs and unload folders
        FolderMan *folderMan = FolderMan::instance();
        folderMan->setSyncEnabled(false);
        folderMan->terminateSyncProcess();
        folderMan->unloadAllFolders();
        a->setState(Account::SignedOut);
        // show result
        _gui->slotComputeOverallSyncStatus();
    }
}
예제 #13
0
void Application::slotToggleFolderman(int state)
{
    FolderMan* folderMan = FolderMan::instance();
    switch (state) {
    case Account::Connected:
        folderMan->setSyncEnabled(true);
        folderMan->slotScheduleAllFolders();
        break;
    case Account::Disconnected:
    case Account::SignedOut:
    case Account::InvalidCredidential:
        folderMan->setSyncEnabled(false);
        folderMan->terminateSyncProcess();
        break;
    }

}
예제 #14
0
// Method executed when the user ends has finished the basic setup.
void OwncloudSetupWizard::slotAssistantFinished( int result )
{
    FolderMan *folderMan = FolderMan::instance();

    if( result == QDialog::Rejected ) {
        qDebug() << "Rejected the new config, use the old!";

    } else if( result == QDialog::Accepted ) {
        // This may or may not wipe all folder definitions, depending
        // on whether a new account is activated or the existing one
        // is changed.
        auto account = applyAccountChanges();

        QString localFolder = QDir::fromNativeSeparators(_ocWizard->localFolder());
        if( !localFolder.endsWith(QLatin1Char('/'))) {
            localFolder.append(QLatin1Char('/'));
        }

        bool startFromScratch = _ocWizard->field("OCSyncFromScratch").toBool();
        if (!startFromScratch || ensureStartFromScratch(localFolder)) {
            qDebug() << "Adding folder definition for" << localFolder << _remoteFolder;
            FolderDefinition folderDefinition;
            auto alias = Theme::instance()->appName();
            int count = 0;
            folderDefinition.alias = alias;
            while (folderMan->folder(folderDefinition.alias)) {
                // There is already a folder configured with this name and folder names need to be unique
                folderDefinition.alias = alias + QString::number(++count);
            }
            folderDefinition.localPath = localFolder;
            folderDefinition.targetPath = _remoteFolder;
            auto f = folderMan->addFolder(account, folderDefinition);
            if (f) {
                f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
                                                     _ocWizard->selectiveSyncBlacklist());
            }
            _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder));
        }
    }

    // notify others.
    emit ownCloudWizardDone( result );
}
예제 #15
0
void AccountSettings::slotResetCurrentFolder()
{
    QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
    if( selected.isValid() ) {
        QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
        int ret = QMessageBox::question( 0, tr("Confirm Folder Reset"),
                                         tr("<p>Do you really want to reset folder <i>%1</i> and rebuild your client database?</p>"
                                            "<p><b>Note:</b> While no files will be removed, this can cause significant data "
                                            "traffic and take several minutes to hours, depending on the size of the folder.</p>").arg(alias),
                                         QMessageBox::Yes|QMessageBox::No );
        if( ret == QMessageBox::Yes ) {
            FolderMan *folderMan = FolderMan::instance();
            Folder *f = folderMan->folder(alias);
            f->slotTerminateSync();
            f->wipe();
            folderMan->slotScheduleAllFolders();
        }
    }
}
예제 #16
0
void AccountSettings::slotRemoveCurrentFolder()
{
    QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
    if( selected.isValid() ) {
        int row = selected.row();

        QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
        qDebug() << "Remove Folder alias " << alias;
        if( !alias.isEmpty() ) {
            // remove from file system through folder man
            // _model->removeRow( selected.row() );
            int ret = QMessageBox::question( this, tr("Confirm Folder Remove"),
                                             tr("<p>Do you really want to stop syncing the folder <i>%1</i>?</p>"
                                                "<p><b>Note:</b> This will not remove the files from your client.</p>").arg(alias),
                                             QMessageBox::Yes|QMessageBox::No );

            if( ret == QMessageBox::No ) {
                return;
            }
            /* Remove the selected item from the timer hash. */
            QStandardItem *item = NULL;
            if( selected.isValid() )
                item = _model->itemFromIndex(selected);

            if( selected.isValid() && item && _hideProgressTimers.contains(item) ) {
                QTimer *t = _hideProgressTimers[item];
                t->stop();
                _hideProgressTimers.remove(item);
                delete(t);
            }

            FolderMan *folderMan = FolderMan::instance();
            folderMan->slotRemoveFolder( alias );
            _model->removeRow(row);

            // single folder fix to show add-button and hide remove-button
            slotButtonsSetEnabled();

            emit folderChanged();
        }
    }
}
예제 #17
0
void AccountSettings::slotResetCurrentFolder()
{
    QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
    if( selected.isValid() ) {
        QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
        int ret = QMessageBox::question( 0, tr("Confirm Folder Reset"),
                                         tr("<p>Do you really want to reset folder <i>%1</i> and rebuild your client database?</p>"
                                            "<p><b>Note:</b> This function is designed for maintenance purposes only. "
                                            "No files will be removed, but this can cause significant data traffic and "
                                            "take several minutes or hours to complete, depending on the size of the folder. "
                                            "Only use this option if advised by your administrator.</p>").arg(alias),
                                         QMessageBox::Yes|QMessageBox::No );
        if( ret == QMessageBox::Yes ) {
            FolderMan *folderMan = FolderMan::instance();
            Folder *f = folderMan->folder(alias);
            f->slotTerminateSync(true);
            f->wipe();
            folderMan->slotScheduleAllFolders();
        }
    }
}
예제 #18
0
void AccountSettings::slotFolderWizardAccepted()
{
    FolderWizard *folderWizard = qobject_cast<FolderWizard*>(sender());
    FolderMan *folderMan = FolderMan::instance();

    qDebug() << "* Folder wizard completed";

    QString alias        = folderWizard->field(QLatin1String("alias")).toString();
    QString sourceFolder = folderWizard->field(QLatin1String("sourceFolder")).toString();
    QString targetPath   = folderWizard->property("targetPath").toString();

    if (!FolderMan::ensureJournalGone( sourceFolder ))
        return;
    folderMan->addFolderDefinition(alias, sourceFolder, targetPath );
    Folder *f = folderMan->setupFolderFromConfigFile( alias );
    slotAddFolder( f );
    folderMan->setSyncEnabled(true);
    if( f ) {
        folderMan->slotScheduleAllFolders();
        emit folderChanged();
    }
}
예제 #19
0
void Application::slotConnectionValidatorResult(ConnectionValidator::Status status)
{
    qDebug() << "Connection Validator Result: " << _conValidator->statusString(status);
    QStringList startupFails;

    if( status == ConnectionValidator::Connected ) {
        FolderMan *folderMan = FolderMan::instance();
        qDebug() << "######## Connection and Credentials are ok!";
        folderMan->setSyncEnabled(true);
        // queue up the sync for all folders.
        folderMan->slotScheduleAllFolders();
        if(!_connectionMsgBox.isNull()) {
            _connectionMsgBox->close();
        }

    } else {
        // if we have problems here, it's unlikely that syncing will work.
        FolderMan::instance()->setSyncEnabled(false);

        startupFails = _conValidator->errors();
        _startupNetworkError = _conValidator->networkError();
        if (_userTriggeredConnect) {
            if(_connectionMsgBox.isNull()) {
                _connectionMsgBox = new QMessageBox(QMessageBox::Warning, tr("Connection failed"),
                                      _conValidator->errors().join(". ").append('.'), QMessageBox::Ok, 0);
                _connectionMsgBox->setAttribute(Qt::WA_DeleteOnClose);
                _connectionMsgBox->open();
                _userTriggeredConnect = false;
            }
        }
        QTimer::singleShot(30*1000, this, SLOT(slotCheckConnection()));
    }
    _gui->startupConnected( (status == ConnectionValidator::Connected), startupFails);

    _conValidator->deleteLater();
}
예제 #20
0
void SettingsDialog::slotUpdateAccountState()
{
    FolderMan *folderMan = FolderMan::instance();
    SyncResult state = folderMan->accountStatus(folderMan->map().values());
    _accountItem->setIcon(Theme::instance()->syncStateIcon(state.status()));
}