Comparar commits

...

7 Commits

Autor SHA1 Mensagem Data
Daniel Molkentin 685ffb8f2e Add .gitattributes, needed for clean git export 2012-10-18 13:40:50 +04:00
Daniel Molkentin 581b5026cc ChangeLog updates for 1.1.1 2012-10-18 10:12:28 +02:00
Daniel Molkentin e7c95ee5b0 Proper workaround for bug in Ubuntu's Qt SNI bridge. 2012-10-17 23:13:14 +02:00
Klaas Freitag 51163d8a29 Escape the folder alias as used in QSetting and as file name. 2012-10-17 15:13:55 +02:00
Klaas Freitag d501d46948 Push version to 1.1.1 2012-10-17 10:00:27 +02:00
Daniel Molkentin c71d71ddde Clean up argument handling
- Allow to retrospectively open log window
- Don't waste init time if only help is requested.
2012-10-16 19:05:28 +02:00
Daniel Molkentin 514744a1ee Make sure SSL errors are always handled 2012-10-15 13:23:25 +02:00
8 arquivos alterados com 180 adições e 51 exclusões
+4
Ver Arquivo
@@ -0,0 +1,4 @@
.tag export-subst
.gitignore export-ignore
.gitattributes export-ignore
.commit-template export-ignore
+16 -2
Ver Arquivo
@@ -1,7 +1,21 @@
ChangeLog
=========
version 1.1.0 (release ), csync 0.60.0 required
*
version 1.1.1 (release 2012-10-18), csync 0.60.1 required
* [GUI] Allow changing folder name in single folder mode
* [GUI] Windows: Add license to installer
* [GUI] owncloud --logwindow will bring up the log window
in an already running instance
* [Fixes] Make sure SSL errors are always handled
* [Fixes] Allow special characters in folder alias
* [Fixes] Proper workaround for Menu bug in Ubuntu
* [Fixes] csync: Fix improper memory cleanup which could
cause memory leaks and crashes
* [Fixes] csync: Fix memory leak
* [Fixes] csync: Allow single quote (') in file names
* [Fixes] csync: Remove stray temporary files
version 1.1.0 (release 2012-10-10), csync 0.60.0 required
* [GUI] Added an about dialog
* [GUI] Improved themeing capabilities of the client.
* [GUI] Minor fixes in folder assistant.
+1 -1
Ver Arquivo
@@ -1,5 +1,5 @@
set( VERSION_MAJOR 1 )
set( VERSION_MINOR 1 )
set( VERSION_PATCH 0 )
set( VERSION_PATCH 1 )
set( VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} )
+7 -4
Ver Arquivo
@@ -21,12 +21,15 @@ int main(int argc, char **argv)
Mirall::Application app(argc, argv);
app.initialize();
qint64 pid = -1;
// if the application is already running, notify it.
if( app.isRunning() ) {
if( app.sendMessage( QLatin1String("A message to the master"), 5000, pid ))
return 0;
QStringList args = app.arguments();
if ( args.size() > 1 && ! app.giveHelp() ) {
QString msg = args.join( QLatin1String("|") );
if( ! app.sendMessage( msg ) )
return -1;
}
return 0;
}
// if help requested, show on command line and exit.
if( ! app.giveHelp() )
+61 -29
Ver Arquivo
@@ -75,15 +75,18 @@ Application::Application(int &argc, char **argv) :
_contextMenu(0),
_theme(Theme::instance()),
_updateDetector(0),
_helpOnly(false)
_showLogWindow(false),
_logFlush(false),
_helpOnly(false),
_logBrowser(0)
{
setApplicationName( _theme->appName() );
setWindowIcon( _theme->applicationIcon() );
if( arguments().contains(QLatin1String("--help"))) {
showHelp();
}
parseOptions(arguments());
setupLogBrowser();
//no need to waste time;
if ( _helpOnly ) return;
processEvents();
QTranslator *qtTranslator = new QTranslator(this);
@@ -105,6 +108,8 @@ Application::Application(int &argc, char **argv) :
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)),
@@ -159,6 +164,9 @@ Application::Application(int &argc, char **argv) :
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();
}
@@ -188,10 +196,6 @@ void Application::slotStartFolderSetup( int result )
connect( ownCloudInfo::instance(),SIGNAL(ownCloudDirExists(QString,QNetworkReply*)),
this,SLOT(slotAuthCheck(QString,QNetworkReply*)));
connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));
ownCloudInfo::instance()->checkInstallation();
} else {
QMessageBox::warning(0, tr("No %1 Configuration").arg(_theme->appName()),
@@ -380,6 +384,9 @@ void Application::setupContextMenu()
_contextMenu->clear();
} else {
_contextMenu = new QMenu();
// 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);
}
_contextMenu->setTitle(_theme->appName() );
_contextMenu->addAction(_actionOpenStatus);
@@ -435,37 +442,30 @@ void Application::setupContextMenu()
_contextMenu->addSeparator();
_contextMenu->addAction(_actionQuit);
_tray->setContextMenu(_contextMenu);
}
void Application::setupLogBrowser()
{
// init the log browser.
_logBrowser = new LogBrowser;
qInstallMsgHandler( mirallLogCatcher );
csync_set_log_callback( csyncLogCatcher );
// might be called from second instance
if (!_logBrowser) {
// init the log browser.
_logBrowser = new LogBrowser;
qInstallMsgHandler( mirallLogCatcher );
csync_set_log_callback( csyncLogCatcher );
// ## TODO: allow new log name maybe?
if (!_logFile.isEmpty()) {
qDebug() << "Logging into logfile: " << _logFile << " with flush " << _logFlush;
_logBrowser->setLogFile( _logFile, _logFlush );
}
}
if( arguments().contains(QLatin1String("--logwindow"))
|| arguments().contains(QLatin1String("-l"))) {
if (_showLogWindow)
slotOpenLogBrowser();
}
// check for command line option for a log file.
int lf = arguments().indexOf(QLatin1String("--logfile"));
if( lf > -1 && lf+1 < arguments().count() ) {
QString logfile = arguments().at( lf+1 );
bool flush = false;
if( arguments().contains(QLatin1String("--logflush"))) flush = true;
qDebug() << "Logging into logfile: " << logfile << " with flush " << flush;
_logBrowser->setLogFile( logfile, flush );
}
qDebug() << QString::fromLatin1( "################## %1 %2 %3 ").arg(_theme->appName())
.arg( QLocale::system().name() )
.arg(_theme->version());
}
void Application::setupProxy()
@@ -802,6 +802,13 @@ void Application::slotConfigureProxy()
}
}
void Application::slotParseOptions(const QString &opts)
{
QStringList options = opts.split(QLatin1Char('|'));
parseOptions(options);
setupLogBrowser();
}
void Application::slotSyncStateChange( const QString& alias )
{
SyncResult result = _folderMan->syncResult( alias );
@@ -815,6 +822,31 @@ void Application::slotSyncStateChange( const QString& alias )
qDebug() << "Sync state changed for folder " << alias << ": " << result.statusString();
}
void Application::parseOptions(const QStringList &options)
{
QStringListIterator it(options);
// skip file name;
if (it.hasNext()) it.next();
while (it.hasNext()) {
QString option = it.next();
if (option == QLatin1String("--help")) {
showHelp();
} 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 {
showHelp();
}
} else if (option == QLatin1String("--logflush")) {
_logFlush = true;
}
}
}
void Application::computeOverallSyncStatus()
{
+5
Ver Arquivo
@@ -63,10 +63,12 @@ protected slots:
void slotInfoFolder( const QString& );
void slotConfigure();
void slotConfigureProxy();
void slotParseOptions( const QString& );
void slotSyncStateChange( const QString& );
protected:
void parseOptions(const QStringList& );
void setupActions();
void setupSystemTray();
void setupContextMenu();
@@ -122,6 +124,9 @@ private:
UpdateDetector *_updateDetector;
QMap<QString, QString> _overallStatusStrings;
LogBrowser *_logBrowser;
QString _logFile;
bool _showLogWindow;
bool _logFlush;
bool _helpOnly;
};
+81 -15
Ver Arquivo
@@ -93,16 +93,80 @@ int FolderMan::setupKnownFolders()
return _folderMap.size();
}
#define SLASH_TAG QLatin1String("__SLASH__")
#define BSLASH_TAG QLatin1String("__BSLASH__")
#define QMARK_TAG QLatin1String("__QMARK__")
#define PERCENT_TAG QLatin1String("__PERCENT__")
#define STAR_TAG QLatin1String("__STAR__")
#define COLON_TAG QLatin1String("__COLON__")
#define PIPE_TAG QLatin1String("__PIPE__")
#define QUOTE_TAG QLatin1String("__QUOTE__")
#define LT_TAG QLatin1String("__LESS_THAN__")
#define GT_TAG QLatin1String("__GREATER_THAN__")
QString FolderMan::escapeAlias( const QString& alias ) const
{
QString a(alias);
a.replace( QLatin1Char('/'), SLASH_TAG );
a.replace( QLatin1Char('\\'), BSLASH_TAG );
a.replace( QLatin1Char('?'), QMARK_TAG );
a.replace( QLatin1Char('%'), PERCENT_TAG );
a.replace( QLatin1Char('*'), STAR_TAG );
a.replace( QLatin1Char(':'), COLON_TAG );
a.replace( QLatin1Char('|'), PIPE_TAG );
a.replace( QLatin1Char('"'), QUOTE_TAG );
a.replace( QLatin1Char('<'), LT_TAG );
a.replace( QLatin1Char('>'), GT_TAG );
return a;
}
QString FolderMan::unescapeAlias( const QString& alias ) const
{
QString a(alias);
a.replace( SLASH_TAG, QLatin1String("/") );
a.replace( BSLASH_TAG, QLatin1String("\\") );
a.replace( QMARK_TAG, QLatin1String("?") );
a.replace( PERCENT_TAG, QLatin1String("%") );
a.replace( STAR_TAG, QLatin1String("*") );
a.replace( COLON_TAG, QLatin1String(":") );
a.replace( PIPE_TAG, QLatin1String("|") );
a.replace( QUOTE_TAG, QLatin1String("\"") );
a.replace( LT_TAG, QLatin1String("<") );
a.replace( GT_TAG, QLatin1String(">") );
return a;
}
// filename is the name of the file only, it does not include
// the configuration directory path
Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
Folder *folder = 0L;
Folder *folder = 0;
qDebug() << " ` -> setting up:" << file;
QSettings settings( _folderConfigPath + QLatin1Char('/') + file, QSettings::IniFormat);
QString escapedAlias(file);
// check the unescaped variant (for the case the filename comes out
// of the directory listing. If the file is not existing, escape the
// file and try again.
QFileInfo cfgFile( _folderConfigPath, file);
if( !cfgFile.exists() ) {
// try the escaped variant.
escapedAlias = escapeAlias(file);
cfgFile.setFile( _folderConfigPath, escapedAlias );
}
if( !cfgFile.isReadable() ) {
qDebug() << "Can not read folder definition for alias " << cfgFile.filePath();
return folder;
}
QSettings settings( cfgFile.filePath(), QSettings::IniFormat);
qDebug() << " -> file path: " << settings.fileName();
settings.beginGroup( file ); // read the group with the same name as the file which is the folder alias
settings.beginGroup( escapedAlias ); // read the group with the same name as the file which is the folder alias
QString path = settings.value(QLatin1String("localpath")).toString();
if ( path.isNull() || !QFileInfo( path ).isDir() ) {
@@ -115,15 +179,16 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
QString backend = settings.value(QLatin1String("backend")).toString();
QString targetPath = settings.value( QLatin1String("targetPath") ).toString();
QString connection = settings.value( QLatin1String("connection") ).toString();
// QString connection = settings.value( QLatin1String("connection") ).toString();
QString alias = unescapeAlias( file );
if (!backend.isEmpty()) {
if (backend == QLatin1String("unison")) {
folder = new UnisonFolder(file, path, targetPath, this );
folder = new UnisonFolder(alias, path, targetPath, this );
} else if (backend == QLatin1String("csync")) {
#ifdef WITH_CSYNC
folder = new CSyncFolder(file, path, targetPath, this );
folder = new CSyncFolder(alias, path, targetPath, this );
#else
qCritical() << "* csync support not enabled!! ignoring:" << file;
#endif
@@ -141,7 +206,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
targetPath.remove(0,1);
}
folder = new ownCloudFolder( file, path, oCUrl + targetPath, this );
folder = new ownCloudFolder( alias, path, oCUrl + targetPath, this );
#else
qCritical() << "* owncloud support not enabled!! ignoring:" << file;
#endif
@@ -154,7 +219,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
// folder->setOnlyOnlineEnabled(settings.value("folder/onlyOnline", false).toBool());
folder->setOnlyThisLANEnabled(settings.value(QLatin1String("folder/onlyThisLAN"), false).toBool());
_folderMap[file] = folder;
_folderMap[alias] = folder;
qDebug() << "Adding folder to Folder Map " << folder;
/* Use a signal mapper to connect the signals to the alias */
@@ -306,14 +371,15 @@ void FolderMan::addFolderDefinition( const QString& backend, const QString& alia
const QString& sourceFolder, const QString& targetPath,
bool onlyThisLAN )
{
QString escapedAlias = escapeAlias(alias);
// Create a settings file named after the alias
QSettings settings( _folderConfigPath + QLatin1Char('/') + alias, QSettings::IniFormat);
QSettings settings( _folderConfigPath + QLatin1Char('/') + escapedAlias, QSettings::IniFormat);
settings.setValue(QString::fromLatin1("%1/localPath").arg(alias), sourceFolder );
settings.setValue(QString::fromLatin1("%1/targetPath").arg(alias), targetPath );
settings.setValue(QString::fromLatin1("%1/backend").arg(alias), backend );
settings.setValue(QString::fromLatin1("%1/connection").arg(alias), Theme::instance()->appName());
settings.setValue(QString::fromLatin1("%1/onlyThisLAN").arg(alias), onlyThisLAN );
settings.setValue(QString::fromLatin1("%1/localPath").arg(escapedAlias), sourceFolder );
settings.setValue(QString::fromLatin1("%1/targetPath").arg(escapedAlias), targetPath );
settings.setValue(QString::fromLatin1("%1/backend").arg(escapedAlias), backend );
settings.setValue(QString::fromLatin1("%1/connection").arg(escapedAlias), Theme::instance()->appName());
settings.setValue(QString::fromLatin1("%1/onlyThisLAN").arg(escapedAlias), onlyThisLAN );
settings.sync();
}
@@ -351,7 +417,7 @@ void FolderMan::removeFolder( const QString& alias )
qDebug() << "!! Can not remove " << alias << ", not in folderMap.";
}
QFile file( _folderConfigPath + QLatin1Char('/') + alias );
QFile file( _folderConfigPath + QLatin1Char('/') + escapeAlias(alias) );
if( file.exists() ) {
qDebug() << "Remove folder config file " << file.fileName();
file.remove();
+5
Ver Arquivo
@@ -102,6 +102,11 @@ private:
// and create the folders
int setupKnownFolders();
// Escaping of the alias which is used in QSettings AND the file
// system, thus need to be escaped.
QString escapeAlias( const QString& ) const;
QString unescapeAlias( const QString& ) const;
void removeFolder( const QString& );
FolderWatcher *_configFolderWatcher;