Reconfigure the proxy when needed

This commit is contained in:
Olivier Goffart 2013-08-27 10:02:59 +02:00
parent 8bfb44fd28
commit c15de69156
5 changed files with 13 additions and 2 deletions

View file

@ -519,6 +519,9 @@ void Application::slotSetupProxy()
default: default:
break; break;
} }
FolderMan::instance()->setDirtyProxy(true);
FolderMan::instance()->slotScheduleAllFolders();
} }
void Application::slotRefreshQuotaDisplay( qint64 total, qint64 used ) void Application::slotRefreshQuotaDisplay( qint64 total, qint64 used )

View file

@ -498,6 +498,8 @@ void Folder::setProxy()
csync_set_module_property(_csync_ctx, "proxy_port", &proxyPort ); 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_user", proxy.user().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() ); csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() );
FolderMan::instance()->setDirtyProxy(false);
} }
} }
@ -536,6 +538,8 @@ void Folder::startSync(const QStringList &pathList)
QMetaObject::invokeMethod(this, "slotCSyncFinished", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "slotCSyncFinished", Qt::QueuedConnection);
return; return;
} }
} else if (FolderMan::instance()->isDirtyProxy()) {
setProxy();
} }
if (_thread && _thread->isRunning()) { if (_thread && _thread->isRunning()) {

View file

@ -37,7 +37,8 @@ FolderMan* FolderMan::_instance = 0;
FolderMan::FolderMan(QObject *parent) : FolderMan::FolderMan(QObject *parent) :
QObject(parent), QObject(parent),
_syncEnabled( true ) _syncEnabled( true ),
_dirtyProxy( true )
{ {
// if QDir::mkpath would not be so stupid, I would not need to have this // if QDir::mkpath would not be so stupid, I would not need to have this
// duplication of folderConfigPath() here // duplication of folderConfigPath() here

View file

@ -109,6 +109,9 @@ public slots:
void slotScheduleAllFolders(); void slotScheduleAllFolders();
bool isDirtyProxy() { return _dirtyProxy; }
void setDirtyProxy(bool value = true) { _dirtyProxy = value; }
private slots: private slots:
// slot to add a folder to the syncing queue // slot to add a folder to the syncing queue
void slotScheduleSync( const QString & ); void slotScheduleSync( const QString & );
@ -136,6 +139,7 @@ private:
QString _currentSyncFolder; QString _currentSyncFolder;
bool _syncEnabled; bool _syncEnabled;
QQueue<QString> _scheduleQueue; QQueue<QString> _scheduleQueue;
bool _dirtyProxy; // If the proxy need to be re-configured
explicit FolderMan(QObject *parent = 0); explicit FolderMan(QObject *parent = 0);
static FolderMan *_instance; static FolderMan *_instance;

View file

@ -66,7 +66,6 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent) :
NetworkSettings *networkSettings = new NetworkSettings; NetworkSettings *networkSettings = new NetworkSettings;
_ui->stack->addWidget(networkSettings); _ui->stack->addWidget(networkSettings);
connect(networkSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy())); connect(networkSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy()));
connect(networkSettings, SIGNAL(proxySettingsChanged()), FolderMan::instance(), SLOT(slotScheduleAllFolders()));
//connect(generalSettings, SIGNAL(resizeToSizeHint()), SLOT(resizeToSizeHint())); //connect(generalSettings, SIGNAL(resizeToSizeHint()), SLOT(resizeToSizeHint()));