示例#1
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);
}
示例#2
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();
    }
}
示例#3
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;
    }

}