// Called if the user changes the user- or url field. Adjust the texts and // evtl. warnings on the dialog. void OwncloudSetupPage::slotHandleUserInput() { // if the url has not changed, return. if( ! urlHasChanged() ) { // disable the advanced button as nothing has changed. _ui.cbAdvanced->setEnabled(false); _ui.advancedBox->setEnabled(false); } else { // Enable advanced stuff for new connection configuration. _ui.cbAdvanced->setEnabled(true); _ui.advancedBox->setEnabled(true); } const QString locFolder = localFolder(); // check if the local folder exists. If so, and if its not empty, show a warning. QDir dir( locFolder ); QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot); QString t; if( !urlHasChanged() && _configExists ) { // This is the password change mode: No change to the url and a config // to an ownCloud exists. t = tr("Change the Password for your configured account."); } else { // Complete new setup. _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder)); if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) { t = tr("Your entire account will be synced to the local folder '%1'.") .arg(QDir::toNativeSeparators(locFolder)); } else { t = tr("%1 folder '%2' is synced to local folder '%3'") .arg(Theme::instance()->appName()).arg(_remoteFolder) .arg(QDir::toNativeSeparators(locFolder)); } if ( _multipleFoldersExist ) { t += tr("<p><small><strong>Warning:</strong> You currently have multiple folders " "configured. If you continue with the current settings, the folder configurations " "will be discarded and a single root folder sync will be created!</small></p>"); } if( entries.count() > 0) { // the directory is not empty if (!_ui.cbAdvanced->isChecked()) { t += tr("<p><small><strong>Warning:</strong> The local directory is not empty. " "Pick a resolution in the advanced settings!</small></p>"); } _ui.resolutionWidget->setVisible(true); } else { // the dir is empty, which means that there is no problem. _ui.resolutionWidget->setVisible(false); } } _ui.syncModeLabel->setText(t); _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height()); }
NS_IMETHODIMP nsMsgBrkMBoxStore::IsSummaryFileValid(nsIMsgFolder *aFolder, nsIMsgDatabase *aDB, bool *aResult) { NS_ENSURE_ARG_POINTER(aFolder); NS_ENSURE_ARG_POINTER(aDB); NS_ENSURE_ARG_POINTER(aResult); // We only check local folders for db validity. nsCOMPtr<nsIMsgLocalMailFolder> localFolder(do_QueryInterface(aFolder)); if (!localFolder) { *aResult = true; return NS_OK; } nsCOMPtr<nsIFile> pathFile; nsresult rv = aFolder->GetFilePath(getter_AddRefs(pathFile)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDBFolderInfo> folderInfo; rv = aDB->GetDBFolderInfo(getter_AddRefs(folderInfo)); NS_ENSURE_SUCCESS(rv, rv); uint64_t folderSize; uint32_t folderDate; int32_t numUnreadMessages; *aResult = false; folderInfo->GetNumUnreadMessages(&numUnreadMessages); folderInfo->GetFolderSize(&folderSize); folderInfo->GetFolderDate(&folderDate); int64_t fileSize = 0; uint32_t actualFolderTimeStamp = 0; GetMailboxModProperties(aFolder, &fileSize, &actualFolderTimeStamp); if (folderSize == fileSize && numUnreadMessages >= 0) { if (!folderSize) { *aResult = true; return NS_OK; } if (!gGotGlobalPrefs) { nsCOMPtr<nsIPrefBranch> pPrefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (pPrefBranch) { rv = pPrefBranch->GetIntPref("mail.db_timestamp_leeway", &gTimeStampLeeway); gGotGlobalPrefs = true; } } // if those values are ok, check time stamp if (gTimeStampLeeway == 0) *aResult = folderDate == actualFolderTimeStamp; else *aResult = std::abs((int32_t) (actualFolderTimeStamp - folderDate)) <= gTimeStampLeeway; } return NS_OK; }
void OwncloudAdvancedSetupPage::initializePage() { WizardCommon::initErrorLabel(_ui.errorLabel); _checking = false; _multipleFoldersExist = false; _oldLocalFolder = localFolder(); // call to init label updateStatus(); // TODO: focus _ui.pbSelectLocalFolder->setFocus(); }
void OwncloudAdvancedSetupPage::initializePage() { WizardCommon::initErrorLabel(_ui.errorLabel); _checking = false; _multipleFoldersExist = false; _oldLocalFolder = localFolder(); // call to init label updateStatus(); // ensure "next" gets the focus, not obSelectLocalFolder QTimer::singleShot(0, wizard()->button(QWizard::NextButton), SLOT(setFocus())); }
// Called if the user changes the user- or url field. Adjust the texts and // evtl. warnings on the dialog. void OwncloudSetupPage::slotHandleUserInput() { // if the url has not changed, return. if( ! urlHasChanged() ) { // disable the advanced button as nothing has changed. _ui.cbAdvanced->setEnabled(false); _ui.advancedBox->setEnabled(false); } else { // Enable advanced stuff for new connection configuration. _ui.cbAdvanced->setEnabled(true); _ui.advancedBox->setEnabled(true); } const QString locFolder = localFolder(); // check if the local folder exists. If so, and if its not empty, show a warning. QDir dir( locFolder ); QStringList entries = dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot); QString t; if( !urlHasChanged() && _configExists ) { // This is the password change mode: No change to the url and a config // to an ownCloud exists. t = tr("Change the Password for your configured ownCloud."); } else { // Complete new setup. _ui.pbSelectLocalFolder->setText(locFolder); if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) { t = tr("Your entire account will be synced to the local folder '%1'").arg(locFolder); } else { t = tr("ownCloud folder '%1' is synced to local folder '%2'").arg(_remoteFolder).arg(locFolder); } if( entries.count() > 0 ) { // the directory is not empty // setErrorString( tr("The local directory is not empty! Open advanced settings for detailed settings.") ); t += QLatin1String("<p/>"); t += tr("The local directory is not empty. Check the advanced settings!"); _ui.cbSyncFromScratch->setEnabled(true); } else { // the dir is empty, which means that there is no problem. _ui.cbSyncFromScratch->setEnabled(false); } } _ui.syncModeLabel->setText(t); }
bool OwncloudAdvancedSetupPage::validatePage() { if(!_created) { setErrorString(QString::null); _checking = true; startSpinner(); emit completeChanged(); emit createLocalAndRemoteFolders(localFolder(), _remoteFolder); return false; } else { // connecting is running _checking = false; emit completeChanged(); stopSpinner(); return true; } }
// Called if the user changes the user- or url field. Adjust the texts and // evtl. warnings on the dialog. void OwncloudAdvancedSetupPage::updateStatus() { const QString locFolder = localFolder(); const QString url = static_cast<OwncloudWizard *>(wizard())->ocUrl(); const QString user = static_cast<OwncloudWizard *>(wizard())->getCredentials()->user(); QUrl serverUrl(url); serverUrl.setUserName(user); // check if the local folder exists. If so, and if its not empty, show a warning. QString errorStr = FolderMan::instance()->checkPathValidityForNewFolder(locFolder, serverUrl); _localFolderValid = errorStr.isEmpty(); QString t; _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder)); if (dataChanged()) { if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) { t = ""; } else { t = tr("%1 folder '%2' is synced to local folder '%3'") .arg(Theme::instance()->appName()).arg(_remoteFolder) .arg(QDir::toNativeSeparators(locFolder)); _ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder)); } const bool dirNotEmpty(QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0); if(dirNotEmpty) { t += tr("<p><small><strong>Warning:</strong> The local folder is not empty. " "Pick a resolution!</small></p>"); } _ui.resolutionWidget->setVisible(dirNotEmpty); } else { _ui.resolutionWidget->setVisible(false); } _ui.syncModeLabel->setText(t); _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height()); wizard()->resize(wizard()->sizeHint()); setErrorString(errorStr); emit completeChanged(); }
NS_IMETHODIMP nsMsgBrkMBoxStore::SetSummaryFileValid(nsIMsgFolder *aFolder, nsIMsgDatabase *aDB, bool aValid) { NS_ENSURE_ARG_POINTER(aFolder); NS_ENSURE_ARG_POINTER(aDB); // We only need to do this for local folders. nsCOMPtr<nsIMsgLocalMailFolder> localFolder(do_QueryInterface(aFolder)); if (!localFolder) return NS_OK; nsCOMPtr<nsIFile> pathFile; nsresult rv = aFolder->GetFilePath(getter_AddRefs(pathFile)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIDBFolderInfo> folderInfo; rv = aDB->GetDBFolderInfo(getter_AddRefs(folderInfo)); NS_ENSURE_SUCCESS(rv, rv); bool exists; pathFile->Exists(&exists); if (!exists) return NS_MSG_ERROR_FOLDER_MISSING; if (aValid) { uint32_t actualFolderTimeStamp; int64_t fileSize; GetMailboxModProperties(aFolder, &fileSize, &actualFolderTimeStamp); folderInfo->SetFolderSize(fileSize); folderInfo->SetFolderDate(actualFolderTimeStamp); } else { folderInfo->SetVersion(0); // that ought to do the trick. } aDB->Commit(nsMsgDBCommitType::kLargeCommit); return rv; }
// Called if the user changes the user- or url field. Adjust the texts and // evtl. warnings on the dialog. void OwncloudAdvancedSetupPage::updateStatus() { const QString locFolder = localFolder(); // check if the local folder exists. If so, and if its not empty, show a warning. QString t; _ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder)); if (dataChanged()) { if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) { t = tr("Your entire account will be synced to the local folder '%1'.") .arg(QDir::toNativeSeparators(locFolder)); } else { t = tr("%1 folder '%2' is synced to local folder '%3'") .arg(Theme::instance()->appName()).arg(_remoteFolder) .arg(QDir::toNativeSeparators(locFolder)); } if ( _multipleFoldersExist ) { t += tr("<p><small><strong>Warning:</strong> You currently have multiple folders " "configured. If you continue with the current settings, the folder configurations " "will be discarded and a single root folder sync will be created!</small></p>"); } const bool dirNotEmpty(QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0); if(dirNotEmpty) { t += tr("<p><small><strong>Warning:</strong> The local directory is not empty. " "Pick a resolution!</small></p>"); } _ui.resolutionWidget->setVisible(dirNotEmpty); } else { _ui.resolutionWidget->setVisible(false); } _ui.syncModeLabel->setText(t); _ui.syncModeLabel->setFixedHeight(_ui.syncModeLabel->sizeHint().height()); }