commit ed2887ee31d01abe91289206251b05ac1df00772 Merge: 5883f5d 97685a6 Author: Tomás Touceda chiiph@torproject.org Date: Mon Jan 23 12:33:38 2012 -0300
Merge branch 'bug4031_rememberports' into alpha
Conflicts: src/vidalia/MainWindow.cpp
changes/bug4031 | 2 + src/vidalia/MainWindow.cpp | 52 +++++++++++++++++++++++++++++++++++++++++-- src/vidalia/MainWindow.h | 4 +++ 3 files changed, 55 insertions(+), 3 deletions(-)
diff --cc src/vidalia/MainWindow.cpp index 03f62a4,28786fc..89387c0 --- a/src/vidalia/MainWindow.cpp +++ b/src/vidalia/MainWindow.cpp @@@ -617,13 -594,21 +619,25 @@@ MainWindow::start(
if(settings.getControlMethod() == ControlMethod::Port) { if(settings.autoControlPort()) { + QString portconf = QString("%1/port.conf").arg(expDataDirectory); + if(!QFile::remove(portconf)) + vWarn(QString("Unable to remove %s, may be it didn't existed.").arg(portconf)); + - args << "ControlPort" << "auto"; - args << "SocksPort" << "auto"; - args << "ControlPortWriteToFile" << portconf; + QString control_str = "auto"; + QString socks_str = "auto"; + + if(!_previousControlPort.isEmpty()) { + control_str = _previousControlPort; + _startedWithPrevious = true; + } + if(!_previousSocksPort.isEmpty()) { + socks_str = _previousSocksPort; + _startedWithPrevious = true; + } + + args << "ControlPort" << control_str; + args << "SocksPort" << socks_str; + args << "ControlPortWriteToFile" << QString("%1/port.conf").arg(expDataDirectory); } else { /* Add the intended control port value */ quint16 controlPort = settings.getControlPort(); @@@ -869,11 -856,29 +892,34 @@@ voi MainWindow::connected() { authenticate(); + if(!_torControl->isVidaliaRunningTor()) { + QString err; + if(!_torControl->takeOwnership(&err)) + vWarn(err); + } + + TorSettings settings; + if(settings.autoControlPort()) { + // We want to remember the ports if it's on auto + QString control_str = "", socks_str = ""; + if(_torControl->getInfo("net/listeners/control", control_str)) { + QStringList control_parts = control_str.split(":"); + if(control_parts.size() > 1) + control_str = control_parts[1]; + } + if(_torControl->getInfo("net/listeners/socks", socks_str)) { + QStringList socks_parts = socks_str.split(":"); + if(socks_parts.size() > 1) + socks_str = socks_parts[1]; + } + + _previousControlPort = control_str; + _previousSocksPort = socks_str; + } else { + // Otherwise we want to clear the remembered ports + _previousControlPort = ""; + _previousSocksPort = ""; + } }
/** Called when the connection to the control socket fails. The reason will be