void ProtocolWidget::copyToClipboard() { QString text; QTextStream ts(&text); int topLevelItems = _ui->_treeWidget->topLevelItemCount(); for (int i = 0; i < topLevelItems; i++) { QTreeWidgetItem *child = _ui->_treeWidget->topLevelItem(i); ts << left // time stamp << qSetFieldWidth(10) << child->data(0,Qt::DisplayRole).toString() // file name << qSetFieldWidth(64) << child->data(1,Qt::DisplayRole).toString() // folder << qSetFieldWidth(15) << child->data(2, Qt::DisplayRole).toString() // action << qSetFieldWidth(15) << child->data(3, Qt::DisplayRole).toString() // size << qSetFieldWidth(10) << child->data(4, Qt::DisplayRole).toString() << qSetFieldWidth(0) << endl; } QApplication::clipboard()->setText(text); emit guiLog(tr("Copied to clipboard"), tr("The sync status has been copied to the clipboard.")); }
ownCloudFolder::ownCloudFolder(const QString &alias, const QString &mpath, const QString &secondPath, QObject *parent) : Folder(alias, mpath, secondPath, parent) , _thread(0) , _csync(0) , _csyncError(false) , _csyncUnavail(false) , _csync_ctx(0) { ServerActionNotifier *notifier = new ServerActionNotifier(this); connect(notifier, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString))); connect(this, SIGNAL(syncFinished(SyncResult)), notifier, SLOT(slotSyncFinished(SyncResult))); qDebug() << "****** ownCloud folder using watcher *******"; // The folder interval is set in the folder parent class. }
ProtocolWidget::ProtocolWidget(QWidget *parent) : QWidget(parent), IgnoredIndicatorRole( Qt::UserRole +1 ), _ui(new Ui::ProtocolWidget) { _ui->setupUi(this); connect(ProgressDispatcher::instance(), SIGNAL(progressInfo(QString,Progress::Info)), this, SLOT(slotProgressInfo(QString,Progress::Info))); connect(_ui->_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), SLOT(slotOpenFile(QTreeWidgetItem*,int))); // Adjust copyToClipboard() when making changes here! QStringList header; header << tr("Time"); header << tr("File"); header << tr("Folder"); header << tr("Action"); header << tr("Size"); _ui->_treeWidget->setHeaderLabels( header ); _ui->_treeWidget->setColumnWidth(1, 180); _ui->_treeWidget->setColumnCount(5); _ui->_treeWidget->setRootIsDecorated(false); _ui->_treeWidget->setTextElideMode(Qt::ElideMiddle); _ui->_treeWidget->header()->setObjectName("ActivityListHeader"); #if defined(Q_OS_MAC) _ui->_treeWidget->setMinimumWidth(400); #endif connect(this, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString))); _retrySyncBtn = _ui->_dialogButtonBox->addButton(tr("Retry Sync"), QDialogButtonBox::ActionRole); _retrySyncBtn->setEnabled(false); connect(_retrySyncBtn, SIGNAL(clicked()), SLOT(slotRetrySync())); _copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); _copyBtn->setToolTip( tr("Copy the activity list to the clipboard.")); _copyBtn->setEnabled(false); connect(_copyBtn, SIGNAL(clicked()), SLOT(copyToClipboard())); ConfigFile cfg; cfg.restoreGeometryHeader(_ui->_treeWidget->header()); }
// // Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp ! // SettingsDialogMac::SettingsDialogMac(ownCloudGui *gui, QWidget *parent) : MacPreferencesWindow(parent), _gui(gui) { // do not show minimize button. There is no use, and restoring 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, &QAction::triggered, this, &SettingsDialogMac::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, &QAction::triggered, this, &SettingsDialogMac::close); addAction(closeWindowAction); // People perceive this as a Window, so also make Ctrl+H work QAction *hideWindowAction = new QAction(this); hideWindowAction->setShortcut(QKeySequence("Ctrl+H")); connect(hideWindowAction, &QAction::triggered, this, &SettingsDialogMac::hide); addAction(hideWindowAction); setObjectName("SettingsMac"); // required as group for saveGeometry call setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI())); QIcon activityIcon(QLatin1String(":/client/resources/activity.png")); _activitySettings = new ActivitySettings; addPreferencesPanel(activityIcon, tr("Activity"), _activitySettings); connect( _activitySettings, SIGNAL(guiLog(QString,QString)), _gui, SLOT(slotShowOptionalTrayMessage(QString,QString)) ); connect(AccountManager::instance(), &AccountManager::accountAdded, this, &SettingsDialogMac::accountAdded); connect(AccountManager::instance(), &AccountManager::accountRemoved, this, &SettingsDialogMac::accountRemoved); foreach (auto ai , AccountManager::instance()->accounts()) { accountAdded(ai.data()); }
Folder::Folder(const QString &alias, const QString &path, const QString& secondPath, QObject *parent) : QObject(parent) , _path(path) , _secondPath(secondPath) , _alias(alias) , _enabled(true) , _thread(0) , _csync(0) , _csyncError(false) , _csyncUnavail(false) , _csync_ctx(0) { qsrand(QTime::currentTime().msec()); _watcher = new FolderWatcher(path, this); MirallConfigFile cfg; _watcher->addIgnoreListFile( cfg.excludeFile(MirallConfigFile::SystemScope) ); _watcher->addIgnoreListFile( cfg.excludeFile(MirallConfigFile::UserScope) ); QObject::connect(_watcher, SIGNAL(folderChanged(const QStringList &)), SLOT(slotChanged(const QStringList &))); _syncResult.setStatus( SyncResult::NotYetStarted ); ServerActionNotifier *notifier = new ServerActionNotifier(this); connect(notifier, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(optionalGuiLog(QString,QString))); connect(this, SIGNAL(syncFinished(SyncResult)), this, SLOT(slotSyncFinished(SyncResult))); connect(this, SIGNAL(syncFinished(SyncResult)), notifier, SLOT(slotSyncFinished(SyncResult))); // check if the local path exists checkLocalPath(); int polltime = cfg.remotePollInterval(); qDebug() << "setting remote poll timer interval to" << polltime << "msec"; _pollTimer.setInterval( polltime ); QObject::connect(&_pollTimer, SIGNAL(timeout()), this, SLOT(slotPollTimerTimeout())); _pollTimer.start(); _syncResult.setFolder(alias); }
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(); }
void ServerActionNotifier::slotSyncFinished(const SyncResult &result) { SyncFileItemVector items = result.syncFileItemVector(); if (items.count() == 0) return; int newItems = 0; int removedItems = 0; int updatedItems = 0; SyncFileItem firstItemNew; SyncFileItem firstItemDeleted; SyncFileItem firstItemUpdated; foreach (const SyncFileItem &item, items) { if (item._dir == SyncFileItem::Down) { switch (item._instruction) { case CSYNC_INSTRUCTION_NEW: newItems++; if (firstItemNew.isEmpty()) firstItemNew = item; break; case CSYNC_INSTRUCTION_REMOVE: removedItems++; if (firstItemDeleted.isEmpty()) firstItemDeleted = item; break; case CSYNC_INSTRUCTION_UPDATED: updatedItems++; if (firstItemUpdated.isEmpty()) firstItemUpdated = item; break; default: // nothing. break; } } } if (newItems > 0) { QString file = QDir::toNativeSeparators(firstItemNew._file); if (newItems == 1) emit guiLog(tr("New file available"), tr("'%1' has been synced to this machine.").arg(file)); else emit guiLog(tr("New files available"), tr("'%1' and %n other file(s) have been synced to this machine.", "", newItems-1).arg(file)); } if (removedItems > 0) { QString file = QDir::toNativeSeparators(firstItemDeleted._file); if (removedItems == 1) emit guiLog(tr("File removed"), tr("'%1' has been removed.").arg(file)); else emit guiLog(tr("New files available"), tr("'%1' and %n other file(s) have been removed.", "", removedItems-1).arg(file)); } if (updatedItems > 0) { QString file = QDir::toNativeSeparators(firstItemUpdated._file); if (updatedItems == 1) emit guiLog(tr("File removed"), tr("'%1' has been updated.").arg(file)); else emit guiLog(tr("New files available"), tr("'%1' and %n other file(s) have been updated.", "", updatedItems-1).arg(file)); } }
void Logger::postGuiLog(const QString &title, const QString &message) { emit guiLog(title, message); }
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(); }
ownCloudFolder::ownCloudFolder(const QString &alias, const QString &mpath, const QString &secondPath, QObject *parent) : Folder(alias, mpath, secondPath, parent) , _thread(0) , _csync(0) , _csyncError(false) , _csyncUnavail(false) , _wipeDb(false) { ServerActionNotifier *notifier = new ServerActionNotifier(this); connect(notifier, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString))); connect(this, SIGNAL(syncFinished(SyncResult)), notifier, SLOT(slotSyncFinished(SyncResult))); qDebug() << "****** ownCloud folder using watcher *******"; // The folder interval is set in the folder parent class. QString url = replaceScheme(secondPath); QString localpath = path(); if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url.toUtf8().data() ) < 0 ) { qDebug() << "Unable to create csync-context!"; _csync_ctx = 0; } else { csync_set_log_callback( _csync_ctx, csyncLogCatcher ); csync_set_log_verbosity(_csync_ctx, 11); MirallConfigFile cfgFile; csync_set_config_dir( _csync_ctx, cfgFile.configPath().toUtf8() ); csync_enable_conflictcopys(_csync_ctx); QString excludeList = cfgFile.excludeFile(); if( !excludeList.isEmpty() ) { qDebug() << "==== added CSync exclude List: " << excludeList.toUtf8(); csync_add_exclude_list( _csync_ctx, excludeList.toUtf8() ); } csync_set_auth_callback( _csync_ctx, getauth ); if( csync_init( _csync_ctx ) < 0 ) { qDebug() << "Could not initialize csync!"; _csync_ctx = 0; } if( _csync_ctx ) { /* Store proxy */ QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(QUrl(cfgFile.ownCloudUrl())); // We set at least one in Application Q_ASSERT(proxies.count() > 0); QNetworkProxy proxy = proxies.first(); int proxyPort = proxy.port(); csync_set_module_property(_csync_ctx, "proxy_type", (char*) proxyTypeToCStr(proxy.type()) ); csync_set_module_property(_csync_ctx, "proxy_host", proxy.hostName().toUtf8().data() ); csync_set_module_property(_csync_ctx, "proxy_port", &proxyPort ); csync_set_module_property(_csync_ctx, "proxy_user", proxy.user().toUtf8().data() ); csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() ); csync_set_module_property(_csync_ctx, "csync_context", _csync_ctx); } } }
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->appName() ); setWindowIcon( _theme->applicationIcon() ); parseOptions(arguments()); setupLogBrowser(); //no need to waste time; if ( _helpOnly ) return; QString locale = Theme::instance()->enforcedLocale(); if (locale.isEmpty()) locale = QLocale::system().name(); QTranslator *qtTranslator = new QTranslator(this); #if defined(Q_OS_MAC) qtTranslator->load(QLatin1String("qt_") + locale, applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir. #elif defined(Q_OS_WIN32) qtTranslator->load(QLatin1String("qt_") + locale, applicationDirPath()); #endif if (qtTranslator->isEmpty()) { 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_") + locale, QLatin1String("/usr/share/mirall/i18n/")); #endif #ifdef Q_OS_MAC mirallTranslator->load(QLatin1String("mirall_") + locale, applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir. #endif #ifdef Q_OS_WIN32 mirallTranslator->load(QLatin1String("mirall_") + locale, applicationDirPath()); #endif installTranslator(mirallTranslator); 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))); /* 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(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 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(); 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(); }