2011-04-06 13:48:02 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2012-06-15 15:36:38 +04:00
|
|
|
#include <iostream>
|
2012-06-05 17:11:29 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
#include "mirall/application.h"
|
2013-03-20 13:03:49 +04:00
|
|
|
#include "mirall/systray.h"
|
2011-02-17 02:21:45 +03:00
|
|
|
#include "mirall/folder.h"
|
2011-09-30 13:49:19 +04:00
|
|
|
#include "mirall/folderwatcher.h"
|
2011-04-05 20:31:14 +04:00
|
|
|
#include "mirall/folderwizard.h"
|
2011-04-06 17:22:40 +04:00
|
|
|
#include "mirall/networklocation.h"
|
2012-02-15 17:44:09 +04:00
|
|
|
#include "mirall/owncloudfolder.h"
|
2011-09-26 17:00:12 +04:00
|
|
|
#include "mirall/statusdialog.h"
|
2012-02-17 14:11:18 +04:00
|
|
|
#include "mirall/owncloudsetupwizard.h"
|
2012-03-29 11:41:30 +04:00
|
|
|
#include "mirall/owncloudinfo.h"
|
2012-08-15 20:01:32 +04:00
|
|
|
#include "mirall/sslerrordialog.h"
|
2012-02-16 13:42:44 +04:00
|
|
|
#include "mirall/theme.h"
|
2012-02-17 14:11:18 +04:00
|
|
|
#include "mirall/mirallconfigfile.h"
|
2012-04-02 22:10:29 +04:00
|
|
|
#include "mirall/updatedetector.h"
|
2012-07-31 12:17:52 +04:00
|
|
|
#include "mirall/proxydialog.h"
|
2012-09-17 23:06:20 +04:00
|
|
|
#include "mirall/version.h"
|
2012-11-13 14:15:25 +04:00
|
|
|
#include "mirall/credentialstore.h"
|
2012-12-05 19:45:28 +04:00
|
|
|
#include "mirall/logger.h"
|
2012-02-16 13:42:44 +04:00
|
|
|
|
2011-03-16 16:50:34 +03:00
|
|
|
#include "mirall/inotify.h"
|
2011-02-17 02:21:45 +03:00
|
|
|
|
2012-05-21 18:48:49 +04:00
|
|
|
#include <QtCore>
|
|
|
|
#include <QtGui>
|
|
|
|
#include <QHash>
|
|
|
|
#include <QHashIterator>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QTranslator>
|
2012-07-31 12:17:52 +04:00
|
|
|
#include <QNetworkProxy>
|
|
|
|
#include <QNetworkProxyFactory>
|
2012-05-21 18:48:49 +04:00
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
namespace Mirall {
|
|
|
|
|
2012-06-05 17:11:29 +04:00
|
|
|
// application logging handler.
|
|
|
|
void mirallLogCatcher(QtMsgType type, const char *msg)
|
|
|
|
{
|
|
|
|
Q_UNUSED(type)
|
2012-08-17 19:13:17 +04:00
|
|
|
Logger::instance()->mirallLog( QString::fromUtf8(msg) );
|
2012-06-05 17:11:29 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 21:27:44 +04:00
|
|
|
namespace {
|
|
|
|
QString applicationTrPath()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
// FIXME - proper path!
|
|
|
|
return QLatin1String("/usr/share/mirall/i18n/");
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
return QApplication::applicationDirPath()+QLatin1String("/../Resources/Translations"); // path defaults to app dir.
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
return QApplication::applicationDirPath();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 17:11:29 +04:00
|
|
|
// ----------------------------------------------------------------------------------
|
|
|
|
|
2012-04-20 15:17:48 +04:00
|
|
|
Application::Application(int &argc, char **argv) :
|
2012-07-30 18:10:48 +04:00
|
|
|
SharedTools::QtSingleApplication(argc, argv),
|
2012-03-31 13:31:28 +04:00
|
|
|
_tray(0),
|
2012-04-21 23:03:29 +04:00
|
|
|
#if QT_VERSION >= 0x040700
|
2011-04-04 14:23:30 +04:00
|
|
|
_networkMgr(new QNetworkConfigurationManager(this)),
|
2012-04-21 23:03:29 +04:00
|
|
|
#endif
|
2012-11-28 22:24:29 +04:00
|
|
|
_sslErrorDialog(0),
|
2012-03-29 11:41:30 +04:00
|
|
|
_contextMenu(0),
|
2012-09-24 19:55:10 +04:00
|
|
|
_theme(Theme::instance()),
|
2012-06-15 15:36:38 +04:00
|
|
|
_updateDetector(0),
|
2012-11-28 22:24:29 +04:00
|
|
|
_logBrowser(0),
|
2012-10-16 21:05:28 +04:00
|
|
|
_showLogWindow(false),
|
|
|
|
_logFlush(false),
|
2013-01-15 23:41:52 +04:00
|
|
|
_helpOnly(false),
|
2013-04-18 22:27:07 +04:00
|
|
|
_fileItemDialog(0),
|
|
|
|
_statusDialog(0)
|
2011-02-17 02:21:45 +03:00
|
|
|
{
|
2013-02-21 15:21:42 +04:00
|
|
|
setApplicationName( _theme->appNameGUI() );
|
2012-03-31 13:31:28 +04:00
|
|
|
setWindowIcon( _theme->applicationIcon() );
|
2012-02-23 14:44:44 +04:00
|
|
|
|
2012-10-16 21:05:28 +04:00
|
|
|
parseOptions(arguments());
|
2013-02-14 21:27:44 +04:00
|
|
|
setupTranslations();
|
2012-06-05 17:49:53 +04:00
|
|
|
setupLogBrowser();
|
2012-10-16 21:05:28 +04:00
|
|
|
//no need to waste time;
|
|
|
|
if ( _helpOnly ) return;
|
2012-04-18 14:10:14 +04:00
|
|
|
|
2012-10-16 21:05:28 +04:00
|
|
|
connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString)));
|
2012-12-11 15:49:48 +04:00
|
|
|
connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
|
|
|
|
this, SLOT(slotShowTrayMessage(QString,QString)));
|
2012-04-18 15:59:03 +04:00
|
|
|
// create folder manager for sync folder management
|
2012-08-02 13:08:27 +04:00
|
|
|
_folderMan = new FolderMan(this);
|
2012-02-19 00:21:58 +04:00
|
|
|
connect( _folderMan, SIGNAL(folderSyncStateChange(QString)),
|
|
|
|
this,SLOT(slotSyncStateChange(QString)));
|
2013-02-18 20:31:29 +04:00
|
|
|
_folderMan->setSyncEnabled(false);
|
2012-02-19 00:21:58 +04:00
|
|
|
|
2012-02-21 14:50:19 +04:00
|
|
|
/* 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 &)));
|
|
|
|
|
2011-04-05 20:31:14 +04:00
|
|
|
setQuitOnLastWindowClosed(false);
|
|
|
|
|
2012-09-24 19:55:10 +04:00
|
|
|
_folderWizard = new FolderWizard;
|
2012-03-30 15:57:02 +04:00
|
|
|
|
2012-07-26 12:16:18 +04:00
|
|
|
_owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this );
|
2012-11-28 22:25:12 +04:00
|
|
|
connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)),
|
|
|
|
this, SLOT(slotownCloudWizardDone(int)));
|
2012-02-21 16:26:39 +04:00
|
|
|
|
2012-02-20 19:45:27 +04:00
|
|
|
_statusDialog = new StatusDialog( _theme );
|
2012-02-21 16:26:39 +04:00
|
|
|
connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) );
|
2011-04-04 13:36:44 +04:00
|
|
|
|
2011-10-13 15:55:52 +04:00
|
|
|
connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
|
|
|
|
SLOT(slotRemoveFolder(const QString&)));
|
2011-12-12 20:47:30 +04:00
|
|
|
connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
|
|
|
|
SLOT(slotEnableFolder(QString,bool)));
|
2012-01-24 01:10:01 +04:00
|
|
|
connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
|
|
|
|
SLOT(slotInfoFolder( const QString&)));
|
2012-03-08 15:08:53 +04:00
|
|
|
connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)),
|
|
|
|
SLOT(slotFolderOpenAction(QString)));
|
2011-12-12 20:47:30 +04:00
|
|
|
|
2012-11-28 22:24:29 +04:00
|
|
|
#if 0
|
2012-04-21 23:03:29 +04:00
|
|
|
#if QT_VERSION >= 0x040700
|
2011-04-04 13:36:44 +04:00
|
|
|
qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline");
|
2012-05-21 18:48:49 +04:00
|
|
|
foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) {
|
2011-04-04 13:36:44 +04:00
|
|
|
//qDebug() << "Network:" << netCfg.identifier();
|
|
|
|
}
|
2012-04-21 23:03:29 +04:00
|
|
|
#endif
|
2012-11-28 22:24:29 +04:00
|
|
|
#endif
|
2012-02-21 14:50:19 +04:00
|
|
|
setupActions();
|
2012-03-31 13:31:28 +04:00
|
|
|
setupSystemTray();
|
2012-07-31 12:17:52 +04:00
|
|
|
setupProxy();
|
2011-04-04 13:36:44 +04:00
|
|
|
|
2013-02-18 20:31:29 +04:00
|
|
|
|
|
|
|
int cnt = _folderMan->setupFolders();
|
|
|
|
_statusDialog->setFolderList( _folderMan->map() );
|
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
QObject::connect( this, SIGNAL(messageReceived(QString)),
|
|
|
|
this, SLOT(slotOpenStatus()) );
|
|
|
|
|
2012-03-29 11:41:30 +04:00
|
|
|
QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));
|
2012-02-23 14:44:44 +04:00
|
|
|
|
2012-04-02 22:10:29 +04:00
|
|
|
MirallConfigFile cfg;
|
|
|
|
if( !cfg.ownCloudSkipUpdateCheck() ) {
|
|
|
|
QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
|
|
|
|
}
|
|
|
|
|
2012-10-14 23:50:14 +04:00
|
|
|
connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
|
|
|
|
this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));
|
|
|
|
|
2011-11-04 14:41:49 +04:00
|
|
|
qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Application::~Application()
|
|
|
|
{
|
2012-09-20 13:08:42 +04:00
|
|
|
delete _tray; // needed, see ctor
|
2013-04-18 22:27:07 +04:00
|
|
|
delete _fileItemDialog;
|
|
|
|
delete _statusDialog;
|
2011-04-05 20:31:19 +04:00
|
|
|
qDebug() << "* Mirall shutdown";
|
2012-03-29 11:41:30 +04:00
|
|
|
}
|
|
|
|
|
2012-04-02 22:10:29 +04:00
|
|
|
void Application::slotStartUpdateDetector()
|
|
|
|
{
|
|
|
|
_updateDetector = new UpdateDetector(this);
|
|
|
|
_updateDetector->versionCheck(_theme);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-12 14:28:58 +04:00
|
|
|
void Application::slotStartFolderSetup( int result )
|
2012-03-29 11:41:30 +04:00
|
|
|
{
|
2012-06-12 14:28:58 +04:00
|
|
|
if( result == QDialog::Accepted ) {
|
2012-07-26 12:16:18 +04:00
|
|
|
if( ownCloudInfo::instance()->isConfigured() ) {
|
2012-08-06 16:00:22 +04:00
|
|
|
connect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
|
|
|
SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
2013-02-10 17:57:57 +04:00
|
|
|
|
2012-08-06 16:00:22 +04:00
|
|
|
connect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
|
|
|
SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
|
|
|
|
2012-07-26 12:16:18 +04:00
|
|
|
ownCloudInfo::instance()->checkInstallation();
|
2012-06-12 14:28:58 +04:00
|
|
|
} else {
|
2013-04-28 00:24:32 +04:00
|
|
|
_owncloudSetupWizard->startWizard();
|
2012-06-12 14:28:58 +04:00
|
|
|
}
|
2012-03-29 11:41:30 +04:00
|
|
|
} else {
|
2012-06-12 14:28:58 +04:00
|
|
|
qDebug() << "Setup Wizard was canceled. No reparsing of config.";
|
2012-03-29 11:41:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 18:22:30 +04:00
|
|
|
void Application::slotOwnCloudFound( const QString& url, const QString& versionStr, const QString& version, const QString& edition)
|
2012-03-29 11:41:30 +04:00
|
|
|
{
|
2012-05-14 18:22:30 +04:00
|
|
|
qDebug() << "** Application: ownCloud found: " << url << " with version " << versionStr << "(" << version << ")";
|
|
|
|
// now check the authentication
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
cfgFile.setOwnCloudVersion( version );
|
2012-07-30 18:10:48 +04:00
|
|
|
// disconnect from ownCloudInfo
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
|
|
|
this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
|
|
|
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
|
|
|
this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
|
|
|
|
2012-08-30 19:52:50 +04:00
|
|
|
if( version.startsWith("4.0") ) {
|
2013-02-21 15:21:42 +04:00
|
|
|
QMessageBox::warning(0, tr("%1 Server Mismatch").arg(_theme->appNameGUI()),
|
2012-08-30 19:52:50 +04:00
|
|
|
tr("<p>The configured server for this client is too old.</p>"
|
2013-02-21 15:21:42 +04:00
|
|
|
"<p>Please update to the latest %1 server and restart the client.</p>").arg(_theme->appNameGUI()));
|
2012-08-30 19:52:50 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-13 14:15:25 +04:00
|
|
|
QTimer::singleShot( 0, this, SLOT( slotFetchCredentials() ));
|
2012-03-29 11:41:30 +04:00
|
|
|
}
|
|
|
|
|
2012-04-10 16:51:45 +04:00
|
|
|
void Application::slotNoOwnCloudFound( QNetworkReply* reply )
|
2012-03-29 11:41:30 +04:00
|
|
|
{
|
2013-02-18 17:56:21 +04:00
|
|
|
Q_UNUSED(reply)
|
|
|
|
|
|
|
|
qDebug() << "** Application: NO ownCloud found! Going offline";
|
2012-04-10 16:51:45 +04:00
|
|
|
|
2012-03-30 15:57:02 +04:00
|
|
|
_actionAddFolder->setEnabled( false );
|
2012-08-06 16:00:22 +04:00
|
|
|
|
|
|
|
// Disconnect.
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudInfoFound(QString,QString,QString,QString)),
|
|
|
|
this, SLOT(slotOwnCloudFound(QString,QString,QString,QString)));
|
|
|
|
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(noOwncloudFound(QNetworkReply*)),
|
|
|
|
this, SLOT(slotNoOwnCloudFound(QNetworkReply*)));
|
|
|
|
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
|
|
|
this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
|
|
|
|
|
2012-03-30 15:57:02 +04:00
|
|
|
setupContextMenu();
|
2013-02-18 17:56:21 +04:00
|
|
|
QTimer::singleShot( 30*1000, this, SLOT( slotStartFolderSetup() ));
|
2011-04-04 13:36:44 +04:00
|
|
|
}
|
2012-04-02 15:21:13 +04:00
|
|
|
|
2012-11-13 14:15:25 +04:00
|
|
|
void Application::slotFetchCredentials()
|
|
|
|
{
|
2012-11-28 12:18:28 +04:00
|
|
|
QString trayMessage;
|
|
|
|
|
|
|
|
if( CredentialStore::instance()->canTryAgain() ) {
|
|
|
|
connect( CredentialStore::instance(), SIGNAL(fetchCredentialsFinished(bool)),
|
|
|
|
this, SLOT(slotCredentialsFetched(bool)) );
|
|
|
|
CredentialStore::instance()->fetchCredentials();
|
|
|
|
if( CredentialStore::instance()->state() == CredentialStore::TooManyAttempts ) {
|
2013-04-16 16:28:00 +04:00
|
|
|
trayMessage = tr("Too many incorrect password attempts.");
|
2012-11-28 12:18:28 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qDebug() << "Can not try again to fetch Credentials.";
|
2013-01-23 16:44:25 +04:00
|
|
|
trayMessage = tr("%1 user credentials are wrong. Please check configuration.")
|
2013-02-21 15:21:42 +04:00
|
|
|
.arg(Theme::instance()->appNameGUI());
|
2012-11-28 12:18:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !trayMessage.isEmpty() ) {
|
2012-11-13 14:15:25 +04:00
|
|
|
_tray->showMessage(tr("Credentials"), trayMessage);
|
|
|
|
_actionOpenStatus->setEnabled( false );
|
|
|
|
_actionAddFolder->setEnabled( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::slotCredentialsFetched(bool ok)
|
|
|
|
{
|
|
|
|
qDebug() << "Credentials successfully fetched: " << ok;
|
|
|
|
if( ! ok ) {
|
|
|
|
QString trayMessage;
|
|
|
|
trayMessage = tr("Error: Could not retrieve the password!");
|
|
|
|
if( CredentialStore::instance()->state() == CredentialStore::UserCanceled ) {
|
|
|
|
trayMessage = tr("Password dialog was canceled!");
|
2012-12-11 18:07:44 +04:00
|
|
|
} else {
|
|
|
|
trayMessage = CredentialStore::instance()->errorMessage();
|
2012-11-13 14:15:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !trayMessage.isEmpty() ) {
|
|
|
|
_tray->showMessage(tr("Credentials"), trayMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "Could not fetch credentials";
|
|
|
|
_actionAddFolder->setEnabled( false );
|
|
|
|
_actionOpenStatus->setEnabled( false );
|
|
|
|
} else {
|
2013-02-06 12:07:58 +04:00
|
|
|
ownCloudInfo::instance()->setCredentials( CredentialStore::instance()->user(),
|
|
|
|
CredentialStore::instance()->password() );
|
2012-11-13 14:15:25 +04:00
|
|
|
// Credential fetched ok.
|
|
|
|
QTimer::singleShot( 0, this, SLOT( slotCheckAuthentication() ));
|
|
|
|
}
|
|
|
|
disconnect( CredentialStore::instance(), SIGNAL(fetchCredentialsFinished(bool)) );
|
|
|
|
}
|
|
|
|
|
2012-03-30 22:42:40 +04:00
|
|
|
void Application::slotCheckAuthentication()
|
|
|
|
{
|
2012-11-13 14:15:25 +04:00
|
|
|
connect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
|
|
|
this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
|
|
|
|
|
2012-04-06 10:53:57 +04:00
|
|
|
qDebug() << "# checking for authentication settings.";
|
2012-08-17 19:13:17 +04:00
|
|
|
ownCloudInfo::instance()->getRequest(QLatin1String("/"), true ); // this call needs to be authenticated.
|
2012-03-30 22:42:40 +04:00
|
|
|
// simply GET the webdav root, will fail if credentials are wrong.
|
|
|
|
// continue in slotAuthCheck here :-)
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::slotAuthCheck( const QString& ,QNetworkReply *reply )
|
|
|
|
{
|
2012-11-13 14:15:25 +04:00
|
|
|
bool ok = true;
|
|
|
|
|
2012-04-17 15:06:25 +04:00
|
|
|
if( reply->error() == QNetworkReply::AuthenticationRequiredError ) { // returned if the user is wrong.
|
|
|
|
qDebug() << "******** Password is wrong!";
|
2013-02-21 15:21:42 +04:00
|
|
|
QMessageBox::warning(0, tr("No %1 Connection").arg(_theme->appNameGUI()),
|
2012-09-24 19:55:10 +04:00
|
|
|
tr("<p>Your %1 credentials are not correct.</p>"
|
|
|
|
"<p>Please correct them by starting the configuration dialog from the tray!</p>")
|
2013-02-21 15:21:42 +04:00
|
|
|
.arg(_theme->appNameGUI()));
|
2012-03-30 22:42:40 +04:00
|
|
|
_actionAddFolder->setEnabled( false );
|
2012-11-13 14:15:25 +04:00
|
|
|
ok = false;
|
2012-04-17 15:06:25 +04:00
|
|
|
} else if( reply->error() == QNetworkReply::OperationCanceledError ) {
|
|
|
|
// the username was wrong and ownCloudInfo was closing the request after a couple of auth tries.
|
2012-04-18 13:59:56 +04:00
|
|
|
qDebug() << "******** Username or password is wrong!";
|
2013-02-21 15:21:42 +04:00
|
|
|
QMessageBox::warning(0, tr("No %1 Connection").arg(_theme->appNameGUI()),
|
2012-09-24 19:55:10 +04:00
|
|
|
tr("<p>Either your user name or your password are not correct.</p>"
|
2012-04-17 15:06:25 +04:00
|
|
|
"<p>Please correct it by starting the configuration dialog from the tray!</p>"));
|
|
|
|
_actionAddFolder->setEnabled( false );
|
2012-11-13 14:15:25 +04:00
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// disconnect from ownCloud Info signals
|
|
|
|
disconnect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
|
|
|
|
this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
|
|
|
|
|
|
|
|
if( ok ) {
|
2012-03-30 22:42:40 +04:00
|
|
|
qDebug() << "######## Credentials are ok!";
|
2013-02-18 20:31:29 +04:00
|
|
|
_folderMan->setSyncEnabled(true);
|
|
|
|
QMetaObject::invokeMethod(_folderMan, "slotScheduleFolderSync");
|
2012-03-31 13:31:28 +04:00
|
|
|
|
2013-02-18 20:31:29 +04:00
|
|
|
_tray->setIcon( _theme->syncStateIcon( SyncResult::NotYetStarted, true ) );
|
|
|
|
_tray->show();
|
2012-08-09 16:13:20 +04:00
|
|
|
|
2013-02-18 20:31:29 +04:00
|
|
|
int cnt = _folderMan->map().size();
|
|
|
|
if( _tray )
|
2013-02-21 15:21:42 +04:00
|
|
|
_tray->showMessage(tr("%1 Sync Started").arg(_theme->appNameGUI()),
|
2013-02-18 20:31:29 +04:00
|
|
|
tr("Sync started for %1 configured sync folder(s).").arg(cnt));
|
2013-02-19 20:24:10 +04:00
|
|
|
|
|
|
|
// queue up the sync for all folders.
|
|
|
|
_folderMan->slotScheduleAllFolders();
|
|
|
|
|
2013-02-18 20:31:29 +04:00
|
|
|
computeOverallSyncStatus();
|
2012-12-11 18:07:44 +04:00
|
|
|
|
2012-03-30 22:42:40 +04:00
|
|
|
_actionAddFolder->setEnabled( true );
|
2012-12-11 18:07:44 +04:00
|
|
|
_actionOpenStatus->setEnabled( true );
|
2012-11-13 14:15:25 +04:00
|
|
|
setupContextMenu();
|
|
|
|
} else {
|
|
|
|
slotFetchCredentials();
|
2012-03-30 22:42:40 +04:00
|
|
|
}
|
|
|
|
}
|
2011-04-04 13:36:44 +04:00
|
|
|
|
2012-08-15 20:01:32 +04:00
|
|
|
void Application::slotSSLFailed( QNetworkReply *reply, QList<QSslError> errors )
|
|
|
|
{
|
|
|
|
qDebug() << "SSL-Warnings happened for url " << reply->url().toString();
|
|
|
|
|
|
|
|
if( ownCloudInfo::instance()->certsUntrusted() ) {
|
|
|
|
// User decided once to untrust. Honor this decision.
|
|
|
|
qDebug() << "Untrusted by user decision, returning.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString configHandle = ownCloudInfo::instance()->configHandle(reply);
|
|
|
|
|
|
|
|
// make the ssl dialog aware of the custom config. It loads known certs.
|
2012-10-02 19:42:37 +04:00
|
|
|
if( ! _sslErrorDialog ) {
|
|
|
|
_sslErrorDialog = new SslErrorDialog;
|
|
|
|
}
|
2012-08-15 20:01:32 +04:00
|
|
|
_sslErrorDialog->setCustomConfigHandle( configHandle );
|
|
|
|
|
2013-04-02 17:14:56 +04:00
|
|
|
if( _sslErrorDialog->setErrorList( errors ) ) {
|
2012-08-15 20:01:32 +04:00
|
|
|
// all ssl certs are known and accepted. We can ignore the problems right away.
|
|
|
|
qDebug() << "Certs are already known and trusted, Warnings are not valid.";
|
|
|
|
reply->ignoreSslErrors();
|
|
|
|
} else {
|
|
|
|
if( _sslErrorDialog->exec() == QDialog::Accepted ) {
|
|
|
|
if( _sslErrorDialog->trustConnection() ) {
|
|
|
|
reply->ignoreSslErrors();
|
|
|
|
} else {
|
|
|
|
// User does not want to trust.
|
|
|
|
ownCloudInfo::instance()->setCertsUntrusted(true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ownCloudInfo::instance()->setCertsUntrusted(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 22:25:12 +04:00
|
|
|
void Application::slotownCloudWizardDone( int res )
|
|
|
|
{
|
|
|
|
if( res == QDialog::Accepted ) {
|
2013-02-19 15:04:36 +04:00
|
|
|
int cnt = _folderMan->setupFolders();
|
|
|
|
qDebug() << "Set up " << cnt << " folders.";
|
|
|
|
_statusDialog->setFolderList( _folderMan->map() );
|
2012-11-28 22:25:12 +04:00
|
|
|
}
|
2013-02-10 14:01:24 +04:00
|
|
|
_folderMan->setSyncEnabled( true );
|
2012-11-28 22:25:12 +04:00
|
|
|
slotStartFolderSetup( res );
|
|
|
|
}
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
void Application::setupActions()
|
|
|
|
{
|
2013-02-21 15:21:42 +04:00
|
|
|
_actionOpenoC = new QAction(tr("Open %1 in browser...").arg(_theme->appNameGUI()), this);
|
2012-05-15 20:29:12 +04:00
|
|
|
QObject::connect(_actionOpenoC, SIGNAL(triggered(bool)), SLOT(slotOpenOwnCloud()));
|
2012-04-30 18:38:00 +04:00
|
|
|
_actionOpenStatus = new QAction(tr("Open status..."), this);
|
|
|
|
QObject::connect(_actionOpenStatus, SIGNAL(triggered(bool)), SLOT(slotOpenStatus()));
|
2012-12-11 18:07:44 +04:00
|
|
|
_actionOpenStatus->setEnabled( false );
|
2011-10-14 18:39:53 +04:00
|
|
|
_actionAddFolder = new QAction(tr("Add folder..."), this);
|
2011-02-17 02:21:45 +03:00
|
|
|
QObject::connect(_actionAddFolder, SIGNAL(triggered(bool)), SLOT(slotAddFolder()));
|
2011-10-14 18:39:53 +04:00
|
|
|
_actionConfigure = new QAction(tr("Configure..."), this);
|
|
|
|
QObject::connect(_actionConfigure, SIGNAL(triggered(bool)), SLOT(slotConfigure()));
|
2012-07-31 12:17:52 +04:00
|
|
|
_actionConfigureProxy = new QAction(tr("Configure proxy..."), this);
|
|
|
|
QObject::connect(_actionConfigureProxy, SIGNAL(triggered(bool)), SLOT(slotConfigureProxy()));
|
2012-09-24 19:55:10 +04:00
|
|
|
_actionAbout = new QAction(tr("About..."), this);
|
2012-09-17 23:06:20 +04:00
|
|
|
QObject::connect(_actionAbout, SIGNAL(triggered(bool)), SLOT(slotAbout()));
|
2011-02-17 02:21:45 +03:00
|
|
|
_actionQuit = new QAction(tr("Quit"), this);
|
|
|
|
QObject::connect(_actionQuit, SIGNAL(triggered(bool)), SLOT(quit()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setupSystemTray()
|
|
|
|
{
|
2012-09-20 13:08:42 +04:00
|
|
|
// Setting a parent heres will crash on X11 since by the time qapp runs
|
|
|
|
// its childrens dtors, the X11->screen variable queried for is gone -> crash
|
2013-03-20 13:03:49 +04:00
|
|
|
_tray = new Systray();
|
2012-12-20 19:31:24 +04:00
|
|
|
_tray->setIcon( _theme->syncStateIcon( SyncResult::NotYetStarted, true ) );
|
2011-09-26 17:00:12 +04:00
|
|
|
|
|
|
|
connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
|
|
|
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
|
|
|
|
|
2012-04-10 16:51:45 +04:00
|
|
|
setupContextMenu();
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
_tray->show();
|
|
|
|
}
|
|
|
|
|
2012-02-21 14:50:19 +04:00
|
|
|
void Application::setupContextMenu()
|
|
|
|
{
|
2012-10-20 15:48:03 +04:00
|
|
|
bool isConfigured = ownCloudInfo::instance()->isConfigured();
|
|
|
|
|
|
|
|
_actionOpenStatus->setEnabled(isConfigured);
|
|
|
|
_actionOpenoC->setEnabled(isConfigured);
|
|
|
|
_actionAddFolder->setEnabled(isConfigured);
|
|
|
|
|
2012-03-31 13:31:28 +04:00
|
|
|
if( _contextMenu ) {
|
|
|
|
_contextMenu->clear();
|
|
|
|
} else {
|
|
|
|
_contextMenu = new QMenu();
|
2012-10-18 01:13:14 +04:00
|
|
|
// this must be called only once after creating the context menu, or
|
|
|
|
// it will trigger a bug in Ubuntu's SNI bridge patch (11.10, 12.04).
|
|
|
|
_tray->setContextMenu(_contextMenu);
|
2012-03-31 13:31:28 +04:00
|
|
|
}
|
2013-02-21 15:21:42 +04:00
|
|
|
_contextMenu->setTitle(_theme->appNameGUI() );
|
2012-04-30 18:38:00 +04:00
|
|
|
_contextMenu->addAction(_actionOpenStatus);
|
2012-05-15 20:29:12 +04:00
|
|
|
_contextMenu->addAction(_actionOpenoC);
|
2012-08-02 13:15:57 +04:00
|
|
|
|
2012-09-26 20:24:07 +04:00
|
|
|
_contextMenu->addSeparator();
|
|
|
|
|
2012-09-19 13:58:34 +04:00
|
|
|
int folderCnt = _folderMan->map().size();
|
|
|
|
// add open actions for all sync folders to the tray menu
|
|
|
|
if( _theme->singleSyncFolder() ) {
|
|
|
|
if( folderCnt == 0 ) {
|
|
|
|
// if there is no folder configured yet, show the add action.
|
|
|
|
_contextMenu->addAction(_actionAddFolder);
|
|
|
|
} else {
|
|
|
|
// there should be exactly one folder. No sync-folder add action will be shown.
|
|
|
|
QStringList li = _folderMan->map().keys();
|
|
|
|
if( li.size() == 1 ) {
|
|
|
|
Folder *folder = _folderMan->map().value(li.first());
|
|
|
|
if( folder ) {
|
|
|
|
// if there is singleFolder mode, a generic open action is displayed.
|
2013-02-21 15:21:42 +04:00
|
|
|
QAction *action = new QAction( tr("Open %1 folder").arg(_theme->appNameGUI()), this);
|
2012-09-19 13:58:34 +04:00
|
|
|
action->setIcon( _theme->trayFolderIcon( folder->backend()) );
|
|
|
|
|
|
|
|
connect( action, SIGNAL(triggered()),_folderOpenActionMapper,SLOT(map()));
|
|
|
|
_folderOpenActionMapper->setMapping( action, folder->alias() );
|
|
|
|
|
|
|
|
_contextMenu->addAction(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// show a grouping with more than one folder.
|
|
|
|
if ( folderCnt ) {
|
|
|
|
_contextMenu->addAction(tr("Managed Folders:"))->setDisabled(true);
|
|
|
|
}
|
|
|
|
foreach (Folder *folder, _folderMan->map() ) {
|
|
|
|
QAction *action = new QAction( folder->alias(), this );
|
|
|
|
action->setIcon( _theme->trayFolderIcon( folder->backend()) );
|
2012-02-21 14:50:19 +04:00
|
|
|
|
2012-09-19 13:58:34 +04:00
|
|
|
connect( action, SIGNAL(triggered()),_folderOpenActionMapper,SLOT(map()));
|
|
|
|
_folderOpenActionMapper->setMapping( action, folder->alias() );
|
2012-02-21 14:50:19 +04:00
|
|
|
|
2012-09-19 13:58:34 +04:00
|
|
|
_contextMenu->addAction(action);
|
|
|
|
}
|
|
|
|
_contextMenu->addAction(_actionAddFolder);
|
2012-02-21 14:50:19 +04:00
|
|
|
}
|
|
|
|
|
2012-08-02 13:15:57 +04:00
|
|
|
_contextMenu->addSeparator();
|
|
|
|
_contextMenu->addAction(_actionConfigure);
|
|
|
|
_contextMenu->addAction(_actionConfigureProxy);
|
2012-02-21 14:50:19 +04:00
|
|
|
_contextMenu->addSeparator();
|
2013-01-23 16:45:31 +04:00
|
|
|
|
|
|
|
if (!Theme::instance()->about().isEmpty()) {
|
|
|
|
_contextMenu->addAction(_actionAbout);
|
|
|
|
_contextMenu->addSeparator();
|
|
|
|
}
|
2012-02-21 14:50:19 +04:00
|
|
|
|
|
|
|
_contextMenu->addAction(_actionQuit);
|
|
|
|
}
|
|
|
|
|
2012-06-05 17:49:53 +04:00
|
|
|
void Application::setupLogBrowser()
|
|
|
|
{
|
2012-10-16 21:05:28 +04:00
|
|
|
// might be called from second instance
|
|
|
|
if (!_logBrowser) {
|
|
|
|
// init the log browser.
|
|
|
|
_logBrowser = new LogBrowser;
|
|
|
|
qInstallMsgHandler( mirallLogCatcher );
|
|
|
|
// ## TODO: allow new log name maybe?
|
|
|
|
if (!_logFile.isEmpty()) {
|
|
|
|
qDebug() << "Logging into logfile: " << _logFile << " with flush " << _logFlush;
|
|
|
|
_logBrowser->setLogFile( _logFile, _logFlush );
|
|
|
|
}
|
2012-06-05 17:49:53 +04:00
|
|
|
}
|
|
|
|
|
2012-10-16 21:05:28 +04:00
|
|
|
if (_showLogWindow)
|
|
|
|
slotOpenLogBrowser();
|
2012-06-15 15:04:23 +04:00
|
|
|
|
2013-02-14 21:27:44 +04:00
|
|
|
qDebug() << QString::fromLatin1( "################## %1 %2 (%3) %4").arg(_theme->appName())
|
2012-06-05 17:49:53 +04:00
|
|
|
.arg( QLocale::system().name() )
|
2013-02-14 21:27:44 +04:00
|
|
|
.arg(property("ui_lang").toString())
|
2012-06-05 17:49:53 +04:00
|
|
|
.arg(_theme->version());
|
2012-10-16 21:05:28 +04:00
|
|
|
|
2012-06-05 17:49:53 +04:00
|
|
|
}
|
2012-07-31 12:17:52 +04:00
|
|
|
|
|
|
|
void Application::setupProxy()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
Mirall::MirallConfigFile cfg;
|
2012-08-08 17:47:25 +04:00
|
|
|
int proxy = cfg.proxyType();
|
|
|
|
|
|
|
|
switch(proxy) {
|
|
|
|
case QNetworkProxy::NoProxy: {
|
2012-10-09 12:10:41 +04:00
|
|
|
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
2012-07-31 12:17:52 +04:00
|
|
|
break;
|
|
|
|
}
|
2012-08-08 17:47:25 +04:00
|
|
|
case QNetworkProxy::DefaultProxy: {
|
2012-07-31 12:17:52 +04:00
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
|
|
break;
|
|
|
|
}
|
2012-10-08 13:03:15 +04:00
|
|
|
|
2012-08-08 17:47:25 +04:00
|
|
|
case QNetworkProxy::Socks5Proxy: {
|
2012-10-08 13:03:15 +04:00
|
|
|
proxy = QNetworkProxy::HttpProxy;
|
|
|
|
cfg.setProxyType(proxy);
|
|
|
|
// fall through
|
|
|
|
}
|
|
|
|
case QNetworkProxy::HttpProxy:{
|
2012-07-31 12:17:52 +04:00
|
|
|
QNetworkProxy proxy;
|
2012-10-08 13:03:15 +04:00
|
|
|
proxy.setType(QNetworkProxy::HttpProxy);
|
2012-07-31 12:17:52 +04:00
|
|
|
proxy.setHostName(cfg.proxyHostName());
|
|
|
|
proxy.setPort(cfg.proxyPort());
|
|
|
|
proxy.setUser(cfg.proxyUser());
|
|
|
|
proxy.setPassword(cfg.proxyPassword());
|
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-21 14:50:19 +04:00
|
|
|
/*
|
|
|
|
* open the folder with the given Alais
|
|
|
|
*/
|
|
|
|
void Application::slotFolderOpenAction( const QString& alias )
|
|
|
|
{
|
|
|
|
Folder *f = _folderMan->folder(alias);
|
2012-04-02 14:13:55 +04:00
|
|
|
qDebug() << "opening local url " << f->path();
|
2012-02-21 14:50:19 +04:00
|
|
|
if( f ) {
|
2012-04-02 14:13:55 +04:00
|
|
|
QUrl url(f->path(), QUrl::TolerantMode);
|
2012-08-17 19:13:17 +04:00
|
|
|
url.setScheme( QLatin1String("file") );
|
2012-05-16 13:42:47 +04:00
|
|
|
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// work around a bug in QDesktopServices on Win32, see i-net
|
|
|
|
QString filePath = f->path();
|
|
|
|
|
2012-08-17 19:13:17 +04:00
|
|
|
if (filePath.startsWith(QLatin1String("\\\\")) || filePath.startsWith(QLatin1String("//")))
|
2012-05-16 13:42:47 +04:00
|
|
|
url.setUrl(QDir::toNativeSeparators(filePath));
|
|
|
|
else
|
|
|
|
url = QUrl::fromLocalFile(filePath);
|
|
|
|
#endif
|
2012-04-02 14:13:55 +04:00
|
|
|
QDesktopServices::openUrl(url);
|
2012-02-21 14:50:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-15 20:29:12 +04:00
|
|
|
void Application::slotOpenOwnCloud()
|
|
|
|
{
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
|
|
|
|
QString url = cfgFile.ownCloudUrl();
|
|
|
|
QDesktopServices::openUrl( url );
|
|
|
|
}
|
|
|
|
|
2011-09-26 17:00:12 +04:00
|
|
|
void Application::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
|
|
|
|
{
|
2012-11-13 14:15:25 +04:00
|
|
|
// A click on the tray icon should only open the status window on Win and
|
|
|
|
// Linux, not on Mac. They want a menu entry.
|
|
|
|
// If the user canceled login, rather open the login window.
|
2012-12-11 18:07:44 +04:00
|
|
|
if( CredentialStore::instance()->state() == CredentialStore::UserCanceled ||
|
|
|
|
CredentialStore::instance()->state() == CredentialStore::Error ) {
|
2012-11-13 14:15:25 +04:00
|
|
|
slotFetchCredentials();
|
|
|
|
}
|
2012-04-30 18:38:00 +04:00
|
|
|
#if defined Q_WS_WIN || defined Q_WS_X11
|
2012-11-13 14:15:25 +04:00
|
|
|
if( reason == QSystemTrayIcon::Trigger && _actionOpenStatus->isEnabled() ) {
|
|
|
|
slotOpenStatus();
|
|
|
|
}
|
2012-05-15 19:52:30 +04:00
|
|
|
#endif
|
2011-09-26 17:00:12 +04:00
|
|
|
}
|
|
|
|
|
2011-02-17 02:21:45 +03:00
|
|
|
void Application::slotAddFolder()
|
|
|
|
{
|
2013-02-10 14:01:24 +04:00
|
|
|
_folderMan->setSyncEnabled(false); // do not start more syncs.
|
2011-11-03 19:06:40 +04:00
|
|
|
|
2012-02-17 12:48:31 +04:00
|
|
|
Folder::Map folderMap = _folderMan->map();
|
|
|
|
|
|
|
|
_folderWizard->setFolderMap( &folderMap );
|
2011-10-11 16:23:32 +04:00
|
|
|
|
2011-10-14 20:13:34 +04:00
|
|
|
_folderWizard->restart();
|
|
|
|
|
2011-10-11 16:23:32 +04:00
|
|
|
if (_folderWizard->exec() == QDialog::Accepted) {
|
|
|
|
qDebug() << "* Folder wizard completed";
|
|
|
|
|
2012-02-17 12:48:31 +04:00
|
|
|
bool goodData = true;
|
2011-10-11 16:23:32 +04:00
|
|
|
|
2012-08-17 19:13:17 +04:00
|
|
|
QString alias = _folderWizard->field(QLatin1String("alias")).toString();
|
|
|
|
QString sourceFolder = _folderWizard->field(QLatin1String("sourceFolder")).toString();
|
2013-05-24 10:11:17 +04:00
|
|
|
QString backend = QLatin1String("owncloud");
|
2012-02-17 12:48:31 +04:00
|
|
|
QString targetPath;
|
|
|
|
bool onlyThisLAN = false;
|
2013-05-24 10:11:17 +04:00
|
|
|
|
|
|
|
targetPath = _folderWizard->field(QLatin1String("OCFolderLineEdit")).toString();
|
2011-10-11 16:23:32 +04:00
|
|
|
|
2013-02-11 17:18:16 +04:00
|
|
|
_folderMan->setSyncEnabled(true); // do start sync again.
|
2013-02-10 14:01:24 +04:00
|
|
|
|
2012-02-17 12:48:31 +04:00
|
|
|
if( goodData ) {
|
|
|
|
_folderMan->addFolderDefinition( backend, alias, sourceFolder, targetPath, onlyThisLAN );
|
2012-04-20 16:41:40 +04:00
|
|
|
Folder *f = _folderMan->setupFolderFromConfigFile( alias );
|
|
|
|
if( f ) {
|
|
|
|
_statusDialog->slotAddFolder( f );
|
2012-09-19 13:58:34 +04:00
|
|
|
_statusDialog->buttonsSetEnabled();
|
2012-04-20 16:41:40 +04:00
|
|
|
setupContextMenu();
|
|
|
|
}
|
2012-02-17 12:48:31 +04:00
|
|
|
}
|
|
|
|
|
2011-12-12 20:47:30 +04:00
|
|
|
} else {
|
2011-10-11 16:23:32 +04:00
|
|
|
qDebug() << "* Folder wizard cancelled";
|
2011-12-12 20:47:30 +04:00
|
|
|
}
|
2013-02-11 17:18:16 +04:00
|
|
|
_folderMan->setSyncEnabled(true);
|
2013-02-20 19:06:46 +04:00
|
|
|
_folderMan->slotScheduleAllFolders();
|
2011-02-17 02:21:45 +03:00
|
|
|
}
|
|
|
|
|
2012-04-30 18:38:00 +04:00
|
|
|
void Application::slotOpenStatus()
|
|
|
|
{
|
|
|
|
if( ! _statusDialog ) return;
|
2012-05-15 19:52:30 +04:00
|
|
|
|
|
|
|
QWidget *raiseWidget = 0;
|
|
|
|
|
|
|
|
// check if there is a mirall.cfg already.
|
|
|
|
if( _owncloudSetupWizard->wizard()->isVisible() ) {
|
|
|
|
raiseWidget = _owncloudSetupWizard->wizard();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if no config file is there, start the configuration wizard.
|
|
|
|
if( ! raiseWidget ) {
|
|
|
|
MirallConfigFile cfgFile;
|
|
|
|
|
|
|
|
if( !cfgFile.exists() ) {
|
|
|
|
qDebug() << "No configured folders yet, start the Owncloud integration dialog.";
|
2013-02-10 14:01:24 +04:00
|
|
|
_folderMan->setSyncEnabled(false);
|
2013-03-02 00:30:22 +04:00
|
|
|
_owncloudSetupWizard->startWizard();
|
2012-05-15 19:52:30 +04:00
|
|
|
} else {
|
|
|
|
qDebug() << "#============# Status dialog starting #=============#";
|
|
|
|
raiseWidget = _statusDialog;
|
|
|
|
_statusDialog->setFolderList( _folderMan->map() );
|
|
|
|
}
|
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
raiseDialog( raiseWidget );
|
|
|
|
}
|
2012-05-15 19:52:30 +04:00
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
void Application::raiseDialog( QWidget *raiseWidget )
|
|
|
|
{
|
2012-05-15 19:52:30 +04:00
|
|
|
// viel hilft viel ;-)
|
|
|
|
if( raiseWidget ) {
|
2012-07-31 03:57:02 +04:00
|
|
|
#if defined(Q_WS_WIN) || defined (Q_OS_MAC)
|
2012-05-15 19:52:30 +04:00
|
|
|
Qt::WindowFlags eFlags = raiseWidget->windowFlags();
|
|
|
|
eFlags |= Qt::WindowStaysOnTopHint;
|
|
|
|
raiseWidget->setWindowFlags(eFlags);
|
|
|
|
raiseWidget->show();
|
|
|
|
eFlags &= ~Qt::WindowStaysOnTopHint;
|
|
|
|
raiseWidget->setWindowFlags(eFlags);
|
|
|
|
#endif
|
|
|
|
raiseWidget->show();
|
|
|
|
raiseWidget->raise();
|
|
|
|
raiseWidget->activateWindow();
|
|
|
|
}
|
2012-04-30 18:38:00 +04:00
|
|
|
}
|
|
|
|
|
2012-06-05 17:11:29 +04:00
|
|
|
void Application::slotOpenLogBrowser()
|
|
|
|
{
|
|
|
|
_logBrowser->show();
|
|
|
|
_logBrowser->raise();
|
|
|
|
}
|
|
|
|
|
2012-09-17 23:06:20 +04:00
|
|
|
void Application::slotAbout()
|
|
|
|
{
|
2013-02-21 15:21:42 +04:00
|
|
|
QMessageBox::about(0, tr("About %1").arg(_theme->appNameGUI()),
|
2013-01-23 16:45:31 +04:00
|
|
|
Theme::instance()->about());
|
2012-09-17 23:06:20 +04:00
|
|
|
}
|
|
|
|
|
2012-03-16 13:39:20 +04:00
|
|
|
/*
|
|
|
|
* the folder is to be removed. The slot is called from a signal emitted by
|
|
|
|
* the status dialog, which removes the folder from its list by itself.
|
|
|
|
*/
|
2011-10-13 15:55:52 +04:00
|
|
|
void Application::slotRemoveFolder( const QString& alias )
|
|
|
|
{
|
2012-08-17 19:13:17 +04:00
|
|
|
int ret = QMessageBox::question( 0, tr("Confirm Folder Remove"),
|
|
|
|
tr("Do you really want to remove upload folder <i>%1</i>?").arg(alias),
|
2012-03-16 13:39:20 +04:00
|
|
|
QMessageBox::Yes|QMessageBox::No );
|
2011-10-13 15:55:52 +04:00
|
|
|
|
2012-03-16 13:39:20 +04:00
|
|
|
if( ret == QMessageBox::No ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-05-14 15:23:04 +04:00
|
|
|
Folder *f = _folderMan->folder(alias);
|
2012-07-30 18:10:48 +04:00
|
|
|
if( f && _overallStatusStrings.contains( f->alias() )) {
|
|
|
|
_overallStatusStrings.remove( f->alias() );
|
2012-05-14 15:23:04 +04:00
|
|
|
}
|
2011-10-13 15:55:52 +04:00
|
|
|
|
2012-03-16 13:39:20 +04:00
|
|
|
_folderMan->slotRemoveFolder( alias );
|
2012-03-29 11:41:30 +04:00
|
|
|
_statusDialog->slotRemoveSelectedFolder( );
|
2012-05-14 15:23:04 +04:00
|
|
|
computeOverallSyncStatus();
|
2012-04-20 16:41:40 +04:00
|
|
|
setupContextMenu();
|
2011-10-13 15:55:52 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
// Open the File list info dialog.
|
2012-01-24 01:10:01 +04:00
|
|
|
void Application::slotInfoFolder( const QString& alias )
|
|
|
|
{
|
|
|
|
qDebug() << "details of folder with alias " << alias;
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
if( !_fileItemDialog ) {
|
|
|
|
_fileItemDialog = new FileItemDialog(_theme);
|
2012-03-22 19:22:08 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
SyncResult folderResult = _folderMan->syncResult( alias );
|
2012-07-31 12:17:52 +04:00
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
_fileItemDialog->setSyncResult( folderResult );
|
|
|
|
raiseDialog( _fileItemDialog );
|
2012-01-24 01:10:01 +04:00
|
|
|
}
|
|
|
|
|
2011-12-12 20:47:30 +04:00
|
|
|
void Application::slotEnableFolder(const QString& alias, const bool enable)
|
|
|
|
{
|
2012-10-04 16:07:29 +04:00
|
|
|
qDebug() << "Application: enable folder with alias " << alias;
|
|
|
|
bool terminate = false;
|
|
|
|
|
|
|
|
// this sets the folder status to disabled but does not interrupt it.
|
|
|
|
Folder *f = _folderMan->folder( alias );
|
|
|
|
if( f && !enable ) {
|
|
|
|
// check if a sync is still running and if so, ask if we should terminate.
|
|
|
|
if( f->isBusy() ) { // its still running
|
|
|
|
int reply = QMessageBox::question( 0, tr("Sync Running"),
|
|
|
|
tr("The syncing operation is running.<br/>Do you want to terminate it?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
|
2012-10-05 14:59:58 +04:00
|
|
|
if ( reply == QMessageBox::Yes )
|
|
|
|
terminate = true;
|
|
|
|
else
|
|
|
|
return; // do nothing
|
2012-10-04 16:07:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// message box can return at any time while the thread keeps running,
|
|
|
|
// so better check again after the user has responded.
|
|
|
|
if ( f->isBusy() && terminate )
|
|
|
|
_folderMan->terminateSyncProcess( alias );
|
2012-04-30 10:56:56 +04:00
|
|
|
|
2012-10-04 16:07:29 +04:00
|
|
|
_folderMan->slotEnableFolder( alias, enable );
|
|
|
|
_statusDialog->slotUpdateFolderState( f );
|
2011-12-12 20:47:30 +04:00
|
|
|
}
|
|
|
|
|
2011-10-14 18:39:53 +04:00
|
|
|
void Application::slotConfigure()
|
|
|
|
{
|
2013-02-10 14:01:24 +04:00
|
|
|
_folderMan->setSyncEnabled(false); // do not start more syncs.
|
2013-04-28 00:24:32 +04:00
|
|
|
_owncloudSetupWizard->startWizard();
|
2011-04-04 14:23:30 +04:00
|
|
|
}
|
|
|
|
|
2012-07-31 12:17:52 +04:00
|
|
|
void Application::slotConfigureProxy()
|
|
|
|
{
|
2012-10-08 13:03:15 +04:00
|
|
|
ProxyDialog dlg;
|
|
|
|
if (dlg.exec() == QDialog::Accepted)
|
2012-07-31 12:17:52 +04:00
|
|
|
{
|
|
|
|
setupProxy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-16 21:05:28 +04:00
|
|
|
void Application::slotParseOptions(const QString &opts)
|
|
|
|
{
|
|
|
|
QStringList options = opts.split(QLatin1Char('|'));
|
|
|
|
parseOptions(options);
|
|
|
|
setupLogBrowser();
|
|
|
|
}
|
|
|
|
|
2012-12-11 15:49:48 +04:00
|
|
|
void Application::slotShowTrayMessage(const QString &title, const QString &msg)
|
|
|
|
{
|
|
|
|
_tray->showMessage(title, msg);
|
|
|
|
}
|
|
|
|
|
2012-02-19 00:21:58 +04:00
|
|
|
void Application::slotSyncStateChange( const QString& alias )
|
2011-04-04 14:23:30 +04:00
|
|
|
{
|
2012-02-20 19:45:27 +04:00
|
|
|
SyncResult result = _folderMan->syncResult( alias );
|
2011-04-04 14:23:30 +04:00
|
|
|
|
2013-05-04 17:16:53 +04:00
|
|
|
_statusDialog->slotUpdateFolderState( _folderMan->folder(alias) );
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2013-05-04 17:16:53 +04:00
|
|
|
if( _fileItemDialog && _fileItemDialog->isVisible() ) {
|
|
|
|
_fileItemDialog->setSyncResult( _folderMan->syncResult(alias) );
|
2012-04-17 15:16:48 +04:00
|
|
|
}
|
2012-04-17 17:02:18 +04:00
|
|
|
computeOverallSyncStatus();
|
2012-02-19 00:21:58 +04:00
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
qDebug() << "Sync state changed for folder " << alias << ": " << result.statusString();
|
2012-01-24 01:10:01 +04:00
|
|
|
}
|
|
|
|
|
2012-10-16 21:05:28 +04:00
|
|
|
void Application::parseOptions(const QStringList &options)
|
|
|
|
{
|
|
|
|
QStringListIterator it(options);
|
|
|
|
// skip file name;
|
|
|
|
if (it.hasNext()) it.next();
|
|
|
|
|
2013-01-29 08:19:14 +04:00
|
|
|
//parse options; if help or bad option exit
|
2012-10-16 21:05:28 +04:00
|
|
|
while (it.hasNext()) {
|
|
|
|
QString option = it.next();
|
2013-01-29 08:19:14 +04:00
|
|
|
if (option == QLatin1String("--help") || option == QLatin1String("-h")) {
|
|
|
|
setHelp();
|
|
|
|
break;
|
2012-10-16 21:05:28 +04:00
|
|
|
} else if (option == QLatin1String("--logwindow") ||
|
|
|
|
option == QLatin1String("-l")) {
|
|
|
|
_showLogWindow = true;
|
|
|
|
} else if (option == QLatin1String("--logfile")) {
|
|
|
|
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
|
|
|
|
_logFile = it.next();
|
|
|
|
} else {
|
2013-01-29 08:19:14 +04:00
|
|
|
setHelp();
|
2012-10-16 21:05:28 +04:00
|
|
|
}
|
|
|
|
} else if (option == QLatin1String("--logflush")) {
|
|
|
|
_logFlush = true;
|
2012-12-20 19:31:24 +04:00
|
|
|
} else if (option == QLatin1String("--monoicons")) {
|
|
|
|
_theme->setSystrayUseMonoIcons(true);
|
2013-01-02 21:43:40 +04:00
|
|
|
} else if (option == QLatin1String("--confdir")) {
|
|
|
|
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
|
2013-04-03 16:42:13 +04:00
|
|
|
QString confDir = it.next();
|
|
|
|
MirallConfigFile::setConfDir( confDir );
|
2013-01-02 21:43:40 +04:00
|
|
|
} else {
|
|
|
|
showHelp();
|
|
|
|
}
|
2013-04-03 16:42:13 +04:00
|
|
|
} else {
|
|
|
|
setHelp();
|
|
|
|
break;
|
2012-10-16 21:05:28 +04:00
|
|
|
}
|
2013-01-29 08:19:14 +04:00
|
|
|
}
|
2012-10-16 21:05:28 +04:00
|
|
|
}
|
|
|
|
|
2012-01-24 01:10:01 +04:00
|
|
|
void Application::computeOverallSyncStatus()
|
|
|
|
{
|
|
|
|
|
2012-05-21 18:48:49 +04:00
|
|
|
// display the info of the least successful sync (eg. not just display the result of the latest sync
|
2012-07-18 19:28:30 +04:00
|
|
|
SyncResult overallResult(SyncResult::Undefined );
|
2012-04-17 17:02:18 +04:00
|
|
|
QString trayMessage;
|
|
|
|
Folder::Map map = _folderMan->map();
|
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
foreach ( Folder *syncedFolder, map.values() ) {
|
|
|
|
QString folderMessage = _overallStatusStrings[syncedFolder->alias()];
|
2012-04-17 17:02:18 +04:00
|
|
|
|
|
|
|
SyncResult folderResult = syncedFolder->syncResult();
|
|
|
|
SyncResult::Status syncStatus = folderResult.status();
|
|
|
|
|
2013-05-04 17:16:53 +04:00
|
|
|
switch( syncStatus ) {
|
|
|
|
case SyncResult::Undefined:
|
|
|
|
if ( overallResult.status() != SyncResult::Error ) {
|
|
|
|
overallResult.setStatus(SyncResult::Error);
|
|
|
|
}
|
|
|
|
folderMessage = tr( "Undefined State." );
|
|
|
|
break;
|
|
|
|
case SyncResult::NotYetStarted:
|
|
|
|
folderMessage = tr( "Waits to start syncing." );
|
|
|
|
overallResult.setStatus( SyncResult::NotYetStarted );
|
|
|
|
break;
|
|
|
|
case SyncResult::SyncPrepare:
|
|
|
|
folderMessage = tr( "Preparing for sync." );
|
|
|
|
overallResult.setStatus( SyncResult::SyncPrepare );
|
|
|
|
break;
|
|
|
|
case SyncResult::SyncRunning:
|
|
|
|
folderMessage = tr( "Sync is running." );
|
|
|
|
overallResult.setStatus( SyncResult::SyncRunning );
|
|
|
|
break;
|
|
|
|
case SyncResult::Unavailable:
|
|
|
|
folderMessage = tr( "Server is currently not available." );
|
|
|
|
overallResult.setStatus( SyncResult::Unavailable );
|
|
|
|
break;
|
|
|
|
case SyncResult::Success:
|
|
|
|
if( overallResult.status() == SyncResult::Undefined ) {
|
|
|
|
folderMessage = tr( "Last Sync was successful." );
|
|
|
|
overallResult.setStatus( SyncResult::Success );
|
2012-10-30 15:41:47 +04:00
|
|
|
}
|
2013-05-04 17:16:53 +04:00
|
|
|
break;
|
|
|
|
case SyncResult::Error:
|
|
|
|
overallResult.setStatus( SyncResult::Error );
|
|
|
|
folderMessage = tr( "Syncing Error." );
|
|
|
|
break;
|
|
|
|
case SyncResult::SetupError:
|
|
|
|
if ( overallResult.status() != SyncResult::Error ) {
|
|
|
|
overallResult.setStatus( SyncResult::SetupError );
|
2012-04-17 17:02:18 +04:00
|
|
|
}
|
2013-05-04 17:16:53 +04:00
|
|
|
folderMessage = tr( "Setup Error." );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
folderMessage = tr( "Undefined Error State." );
|
|
|
|
overallResult.setStatus( SyncResult::Error );
|
|
|
|
}
|
|
|
|
if( !syncedFolder->syncEnabled() ) {
|
|
|
|
// sync is disabled.
|
|
|
|
folderMessage += tr( " (Sync is paused)" );
|
2012-04-17 17:02:18 +04:00
|
|
|
}
|
2012-10-30 15:41:47 +04:00
|
|
|
|
2012-07-30 18:10:48 +04:00
|
|
|
qDebug() << "Folder in overallStatus Message: " << syncedFolder << " with name " << syncedFolder->alias();
|
2012-08-17 19:13:17 +04:00
|
|
|
QString msg = QString::fromLatin1("Folder %1: %2").arg(syncedFolder->alias()).arg(folderMessage);
|
2012-07-30 18:10:48 +04:00
|
|
|
if( msg != _overallStatusStrings[syncedFolder->alias()] ) {
|
|
|
|
_overallStatusStrings[syncedFolder->alias()] = msg;
|
2012-05-14 13:51:47 +04:00
|
|
|
}
|
2011-10-13 18:41:24 +04:00
|
|
|
}
|
2012-03-23 18:31:46 +04:00
|
|
|
|
2012-07-18 19:28:30 +04:00
|
|
|
// create the tray blob message, check if we have an defined state
|
|
|
|
if( overallResult.status() != SyncResult::Undefined ) {
|
|
|
|
QStringList allStatusStrings = _overallStatusStrings.values();
|
|
|
|
if( ! allStatusStrings.isEmpty() )
|
2012-08-17 19:13:17 +04:00
|
|
|
trayMessage = allStatusStrings.join(QLatin1String("\n"));
|
2012-07-18 19:28:30 +04:00
|
|
|
else
|
|
|
|
trayMessage = tr("No sync folders configured.");
|
2012-04-17 17:02:18 +04:00
|
|
|
|
2012-12-20 19:31:24 +04:00
|
|
|
QIcon statusIcon = _theme->syncStateIcon( overallResult.status(), true); // size 48 before
|
2012-03-03 13:51:06 +04:00
|
|
|
|
2012-07-18 19:28:30 +04:00
|
|
|
_tray->setIcon( statusIcon );
|
|
|
|
_tray->setToolTip(trayMessage);
|
2012-04-17 17:02:18 +04:00
|
|
|
}
|
2011-12-12 20:47:30 +04:00
|
|
|
}
|
|
|
|
|
2012-06-15 15:36:38 +04:00
|
|
|
void Application::showHelp()
|
|
|
|
{
|
2013-01-29 08:19:14 +04:00
|
|
|
setHelp();
|
2012-06-15 15:36:38 +04:00
|
|
|
std::cout << _theme->appName().toLatin1().constData() << " version " <<
|
|
|
|
_theme->version().toLatin1().constData() << std::endl << std::endl;
|
|
|
|
std::cout << "File synchronisation desktop utility." << std::endl << std::endl;
|
|
|
|
std::cout << "Options:" << std::endl;
|
2013-01-29 08:19:14 +04:00
|
|
|
std::cout << " -h --help : show this help screen." << std::endl;
|
2012-06-15 15:36:38 +04:00
|
|
|
std::cout << " --logwindow : open a window to show log output." << std::endl;
|
|
|
|
std::cout << " --logfile <filename> : write log output to file <filename>." << std::endl;
|
2012-12-20 19:31:24 +04:00
|
|
|
std::cout << " --logflush : flush the log file after every write." << std::endl;
|
|
|
|
std::cout << " --monoicons : Use black/white pictograms for systray." << std::endl;
|
2013-01-02 21:43:40 +04:00
|
|
|
std::cout << " --confdir <dirname> : Use the given configuration directory." << std::endl;
|
2012-06-15 15:36:38 +04:00
|
|
|
std::cout << std::endl;
|
2012-09-24 19:55:10 +04:00
|
|
|
if (_theme->appName() == QLatin1String("ownCloud"))
|
|
|
|
std::cout << "For more information, see http://www.owncloud.org" << std::endl;
|
2013-01-29 08:19:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Application::setHelp()
|
|
|
|
{
|
2012-06-15 15:36:38 +04:00
|
|
|
_helpOnly = true;
|
|
|
|
}
|
|
|
|
|
2013-02-24 18:22:21 +04:00
|
|
|
QString substLang(const QString &lang)
|
|
|
|
{
|
|
|
|
// Map the more apropriate script codes
|
|
|
|
// to country codes as used by Qt and
|
|
|
|
// transifex translation conventions.
|
|
|
|
|
|
|
|
// Simplified Chinese
|
|
|
|
if (lang == QLatin1String("zh_Hans"))
|
|
|
|
return QLatin1String("zh_CN");
|
|
|
|
// Traditional Chinese
|
|
|
|
if (lang == QLatin1String("zh_Hant"))
|
|
|
|
return QLatin1String("zh_TW");
|
|
|
|
return lang;
|
|
|
|
}
|
|
|
|
|
2013-02-14 21:27:44 +04:00
|
|
|
void Application::setupTranslations()
|
|
|
|
{
|
|
|
|
QStringList uiLanguages;
|
|
|
|
// uiLanguages crashes on Windows with 4.8.0 release builds
|
|
|
|
#if (QT_VERSION >= 0x040801) || (QT_VERSION >= 0x040800 && !defined(Q_OS_WIN))
|
|
|
|
uiLanguages = QLocale::system().uiLanguages();
|
|
|
|
#else
|
|
|
|
// older versions need to fall back to the systems locale
|
|
|
|
uiLanguages << QLocale::system().name();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QString enforcedLocale = Theme::instance()->enforcedLocale();
|
|
|
|
if (!enforcedLocale.isEmpty())
|
|
|
|
uiLanguages.prepend(enforcedLocale);
|
|
|
|
|
|
|
|
QTranslator *translator = new QTranslator(this);
|
|
|
|
QTranslator *qtTranslator = new QTranslator(this);
|
|
|
|
QTranslator *qtkeychainTranslator = new QTranslator(this);
|
|
|
|
|
|
|
|
foreach(QString lang, uiLanguages) {
|
|
|
|
lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
|
2013-02-24 18:22:21 +04:00
|
|
|
lang = substLang(lang);
|
2013-02-14 21:27:44 +04:00
|
|
|
const QString trPath = applicationTrPath();
|
|
|
|
const QString trFile = QLatin1String("mirall_") + lang;
|
2013-02-24 18:20:59 +04:00
|
|
|
if (translator->load(trFile, trPath) ||
|
|
|
|
lang.startsWith(QLatin1String("en"))) {
|
|
|
|
// Permissive approach: Qt and keychain translations
|
|
|
|
// may be missing, but Qt translations must be there in order
|
|
|
|
// for us to accept the language. Otherwise, we try with the next.
|
|
|
|
// "en" is an exeption as it is the default language and may not
|
|
|
|
// have a translation file provided.
|
|
|
|
qDebug() << Q_FUNC_INFO << "Using" << lang << "translation";
|
|
|
|
setProperty("ui_lang", lang);
|
2013-02-14 21:27:44 +04:00
|
|
|
const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
|
|
|
const QString qtTrFile = QLatin1String("qt_") + lang;
|
2013-02-24 18:20:59 +04:00
|
|
|
if (qtTranslator->load(qtTrFile, qtTrPath)) {
|
|
|
|
qtTranslator->load(qtTrFile, trPath);
|
|
|
|
}
|
2013-02-14 21:27:44 +04:00
|
|
|
const QString qtkeychainFile = QLatin1String("qt_") + lang;
|
2013-02-24 18:20:59 +04:00
|
|
|
if (!qtkeychainTranslator->load(qtkeychainFile, qtTrPath)) {
|
|
|
|
qtkeychainTranslator->load(qtkeychainFile, trPath);
|
|
|
|
}
|
|
|
|
if (!translator->isEmpty())
|
2013-02-14 21:27:44 +04:00
|
|
|
installTranslator(translator);
|
2013-02-24 18:20:59 +04:00
|
|
|
if (!qtTranslator->isEmpty())
|
2013-02-14 21:27:44 +04:00
|
|
|
installTranslator(qtTranslator);
|
2013-02-24 18:20:59 +04:00
|
|
|
if (!qtkeychainTranslator->isEmpty())
|
|
|
|
installTranslator(qtkeychainTranslator);
|
2013-02-21 18:16:02 +04:00
|
|
|
break;
|
2013-02-14 21:27:44 +04:00
|
|
|
}
|
|
|
|
if (property("ui_lang").isNull())
|
|
|
|
setProperty("ui_lang", "C");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 15:36:38 +04:00
|
|
|
bool Application::giveHelp()
|
|
|
|
{
|
|
|
|
return _helpOnly;
|
|
|
|
}
|
2011-02-17 02:21:45 +03:00
|
|
|
} // namespace Mirall
|
|
|
|
|