SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent) : MacPreferencesWindow(parent) { // do not show minimize button. There is no use, and retoring the // dialog from minimize is broken in MacPreferencesWindow setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint); // Emulate dialog behavior: Escape means close QAction *closeDialogAction = new QAction(this); closeDialogAction->setShortcut(QKeySequence(Qt::Key_Escape)); connect(closeDialogAction, SIGNAL(triggered()), SLOT(close())); addAction(closeDialogAction); // People perceive this as a Window, so also make Ctrl+W work QAction *closeWindowAction = new QAction(this); closeWindowAction->setShortcut(QKeySequence("Ctrl+W")); connect(closeWindowAction, SIGNAL(triggered()), SLOT(close())); addAction(closeWindowAction); setObjectName("SettingsMac"); // required as group for saveGeometry call setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI())); _accountSettings = new AccountSettings; QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Undefined, true); _accountIdx = addPreferencesPanel(icon, tr("Account"), _accountSettings); QIcon protocolIcon(QLatin1String(":/mirall/resources/activity.png")); _protocolWidget = new ProtocolWidget; _protocolIdx = addPreferencesPanel(protocolIcon, tr("Activity"), _protocolWidget); QIcon generalIcon = MacStandardIcon::icon(MacStandardIcon::PreferencesGeneral); GeneralSettings *generalSettings = new GeneralSettings; addPreferencesPanel(generalIcon, tr("General"), generalSettings); QIcon networkIcon = MacStandardIcon::icon(MacStandardIcon::Network); NetworkSettings *networkSettings = new NetworkSettings; addPreferencesPanel(networkIcon, tr("Network"), networkSettings); FolderMan *folderMan = FolderMan::instance(); connect( folderMan, SIGNAL(folderSyncStateChange(QString)), this, SLOT(slotSyncStateChange(QString))); connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)), _accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) ); QAction *showLogWindow = new QAction(this); showLogWindow->setShortcut(QKeySequence("F12")); connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser())); addAction(showLogWindow); MirallConfigFile cfg; cfg.restoreGeometry(this); }
int FolderMan::setupKnownFolders() { qDebug() << "* Setup folders from " << _folderConfigPath; unloadAllFolders(); QDir dir( _folderConfigPath ); dir.setFilter(QDir::Files); QStringList list = dir.entryList(); foreach ( const QString& alias, list ) { Folder *f = setupFolderFromConfigFile( alias ); if( f ) { emit( folderSyncStateChange( f->alias() ) ); } }
int FolderMan::setupFolders() { unloadAndDeleteAllFolders(); auto settings = Account::settingsWithGroup(QLatin1String("Accounts")); const auto accountsWithSettings = settings->childGroups(); if (accountsWithSettings.isEmpty()) { int r = setupFoldersMigration(); if (r > 0) { AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain } return r; } qDebug() << "* Setup folders from settings file"; foreach (const auto& account, AccountManager::instance()->accounts()) { const auto id = account->account()->id(); if (!accountsWithSettings.contains(id)) { continue; } settings->beginGroup(id); settings->beginGroup(QLatin1String("Folders")); foreach (const auto& folderAlias, settings->childGroups()) { FolderDefinition folderDefinition; if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) { Folder* f = addFolderInternal(folderDefinition); if (f) { f->setAccountState( account.data() ); slotScheduleSync(f); emit folderSyncStateChange(f); } } } settings->endGroup(); // Folders settings->endGroup(); // <account> } emit folderListChanged(_folderMap); return _folderMap.size(); }
int FolderMan::setupFoldersMigration() { ConfigFile cfg; QDir storageDir(cfg.configPath()); _folderConfigPath = cfg.configPath() + QLatin1String("folders"); qCInfo(lcFolderMan) << "Setup folders from " << _folderConfigPath << "(migration)"; QDir dir(_folderConfigPath); //We need to include hidden files just in case the alias starts with '.' dir.setFilter(QDir::Files | QDir::Hidden); QStringList list = dir.entryList(); // Normally there should be only one account when migrating. AccountState *accountState = AccountManager::instance()->accounts().value(0).data(); foreach (const QString &alias, list) { Folder *f = setupFolderFromOldConfigFile(alias, accountState); if (f) { scheduleFolder(f); emit folderSyncStateChange(f); } }
void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, bool backwardsCompatible) { foreach (const auto &folderAlias, settings.childGroups()) { FolderDefinition folderDefinition; if (FolderDefinition::load(settings, folderAlias, &folderDefinition)) { auto defaultJournalPath = folderDefinition.defaultJournalPath(account->account()); // Migration: Old settings don't have journalPath if (folderDefinition.journalPath.isEmpty()) { folderDefinition.journalPath = defaultJournalPath; } // Migration: ._ files sometimes don't work // So if the configured journalPath is the default one ("._sync_*.db") // but the current default doesn't have the underscore, switch to the // new default. See SyncJournalDb::makeDbName(). if (folderDefinition.journalPath.startsWith("._sync_") && defaultJournalPath.startsWith(".sync_")) { folderDefinition.journalPath = defaultJournalPath; } // Migration: If an old db is found, move it to the new name. if (backwardsCompatible) { SyncJournalDb::maybeMigrateDb(folderDefinition.localPath, folderDefinition.absoluteJournalPath()); } Folder *f = addFolderInternal(std::move(folderDefinition), account.data()); if (f) { // Migration: Mark folders that shall be saved in a backwards-compatible way if (backwardsCompatible) { f->setSaveBackwardsCompatible(true); } scheduleFolder(f); emit folderSyncStateChange(f); } } } }
Application::Application(int &argc, char **argv) : SharedTools::QtSingleApplication(argc, argv), _tray(0), #if QT_VERSION >= 0x040700 _networkMgr(new QNetworkConfigurationManager(this)), #endif _sslErrorDialog(0), _contextMenu(0), _theme(Theme::instance()), _updateDetector(0), _logBrowser(0), _showLogWindow(false), _logFlush(false), _helpOnly(false), _fileItemDialog(0), _statusDialog(0) { setApplicationName( _theme->appNameGUI() ); setWindowIcon( _theme->applicationIcon() ); parseOptions(arguments()); setupTranslations(); setupLogBrowser(); //no need to waste time; if ( _helpOnly ) return; connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString))); connect( Logger::instance(), SIGNAL(guiLog(QString,QString)), this, SLOT(slotShowTrayMessage(QString,QString))); // create folder manager for sync folder management _folderMan = new FolderMan(this); connect( _folderMan, SIGNAL(folderSyncStateChange(QString)), this,SLOT(slotSyncStateChange(QString))); _folderMan->setSyncEnabled(false); /* use a signal mapper to map the open requests to the alias names */ _folderOpenActionMapper = new QSignalMapper(this); connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)), this, SLOT(slotFolderOpenAction(const QString &))); setQuitOnLastWindowClosed(false); _folderWizard = new FolderWizard; _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this ); connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), this, SLOT(slotownCloudWizardDone(int))); _statusDialog = new StatusDialog( _theme ); connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) ); connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)), SLOT(slotRemoveFolder(const QString&))); connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)), SLOT(slotEnableFolder(QString,bool))); connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)), SLOT(slotInfoFolder( const QString&))); connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)), SLOT(slotFolderOpenAction(QString))); #if 0 #if QT_VERSION >= 0x040700 qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline"); foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) { //qDebug() << "Network:" << netCfg.identifier(); } #endif #endif setupActions(); setupSystemTray(); setupProxy(); int cnt = _folderMan->setupFolders(); _statusDialog->setFolderList( _folderMan->map() ); QObject::connect( this, SIGNAL(messageReceived(QString)), this, SLOT(slotOpenStatus()) ); QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() )); MirallConfigFile cfg; if( !cfg.ownCloudSkipUpdateCheck() ) { QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() )); } connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)), this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>))); qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded(); }
Application::Application(int &argc, char **argv) : SharedTools::QtSingleApplication(argc, argv), _tray(0), #if QT_VERSION >= 0x040700 _networkMgr(new QNetworkConfigurationManager(this)), #endif _sslErrorDialog(0), _contextMenu(0), _theme(Theme::instance()), _updateDetector(0), _logBrowser(0), _showLogWindow(false), _logFlush(false), _helpOnly(false), _fileItemDialog(0) { setApplicationName( _theme->appNameGUI() ); setWindowIcon( _theme->applicationIcon() ); parseOptions(arguments()); setupTranslations(); setupLogBrowser(); //no need to waste time; if ( _helpOnly ) return; #ifdef Q_OS_LINUX // HACK: bump the refcount for libgnutls by calling dlopen() // so gnutls, which is an dependency of libneon on some linux // distros, and does not cleanup it's FDs properly, does // not get unloaded. This works around a FD exhaustion crash // (#154). We are not using gnutls at all and it's fine // if loading fails, so no error handling is performed here. dlopen("libgnutls.so", RTLD_LAZY|RTLD_NODELETE); #endif connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString))); connect( Logger::instance(), SIGNAL(guiLog(QString,QString)), this, SLOT(slotShowTrayMessage(QString,QString))); // create folder manager for sync folder management _folderMan = new FolderMan(this); connect( _folderMan, SIGNAL(folderSyncStateChange(QString)), this,SLOT(slotSyncStateChange(QString))); _folderMan->setSyncEnabled(false); /* use a signal mapper to map the open requests to the alias names */ _folderOpenActionMapper = new QSignalMapper(this); connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)), this, SLOT(slotFolderOpenAction(const QString &))); setQuitOnLastWindowClosed(false); _folderWizard = new FolderWizard; _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this ); connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), this, SLOT(slotownCloudWizardDone(int))); _statusDialog = new StatusDialog( _theme ); connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) ); connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)), SLOT(slotRemoveFolder(const QString&))); connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)), SLOT(slotEnableFolder(QString,bool))); connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)), SLOT(slotInfoFolder( const QString&))); connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)), SLOT(slotFolderOpenAction(QString))); #if 0 #if QT_VERSION >= 0x040700 qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline"); foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) { //qDebug() << "Network:" << netCfg.identifier(); } #endif #endif setupActions(); setupSystemTray(); setupProxy(); int cnt = _folderMan->setupFolders(); _statusDialog->setFolderList( _folderMan->map() ); QObject::connect( this, SIGNAL(messageReceived(QString)), this, SLOT(slotOpenStatus()) ); QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() )); MirallConfigFile cfg; if( !cfg.ownCloudSkipUpdateCheck() ) { QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() )); } connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)), this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>))); qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded(); }
Application::Application(int &argc, char **argv) : SharedTools::QtSingleApplication(argc, argv), _tray(0), _sslErrorDialog(0), #if QT_VERSION >= 0x040700 _networkMgr(new QNetworkConfigurationManager(this)), #endif _contextMenu(0), _theme(Theme::instance()), _updateDetector(0), _showLogWindow(false), _logFlush(false), _helpOnly(false), _logBrowser(0) { setApplicationName( _theme->appName() ); setWindowIcon( _theme->applicationIcon() ); parseOptions(arguments()); setupLogBrowser(); //no need to waste time; if ( _helpOnly ) return; processEvents(); QTranslator *qtTranslator = new QTranslator(this); qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); installTranslator(qtTranslator); QTranslator *mirallTranslator = new QTranslator(this); #ifdef Q_OS_LINUX // FIXME - proper path! mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/")); #endif #ifdef Q_OS_MAC mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir. #endif #ifdef Q_OS_WIN32 mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()); #endif installTranslator(mirallTranslator); connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString))); // create folder manager for sync folder management _folderMan = new FolderMan(this); connect( _folderMan, SIGNAL(folderSyncStateChange(QString)), this,SLOT(slotSyncStateChange(QString))); /* use a signal mapper to map the open requests to the alias names */ _folderOpenActionMapper = new QSignalMapper(this); connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)), this, SLOT(slotFolderOpenAction(const QString &))); setQuitOnLastWindowClosed(false); _folderWizard = new FolderWizard; _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this ); connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), SLOT(slotStartFolderSetup(int))); _statusDialog = new StatusDialog( _theme ); connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) ); connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)), SLOT(slotRemoveFolder(const QString&))); connect( _statusDialog, SIGNAL(openLogBrowser()), this, SLOT(slotOpenLogBrowser())); connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)), SLOT(slotEnableFolder(QString,bool))); connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)), SLOT(slotInfoFolder( const QString&))); connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)), SLOT(slotFolderOpenAction(QString))); #if QT_VERSION >= 0x040700 qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline"); foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) { //qDebug() << "Network:" << netCfg.identifier(); } #endif setupActions(); setupSystemTray(); setupProxy(); processEvents(); QObject::connect( this, SIGNAL(messageReceived(QString)), this, SLOT(slotOpenStatus()) ); QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() )); MirallConfigFile cfg; if( !cfg.ownCloudSkipUpdateCheck() ) { QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() )); } connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)), this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>))); qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded(); }