31 #include <QHostAddress>
47 ui.lineControlPort->setValidator(
new QIntValidator(1, 65535,
this));
57 connect(
ui.btnBrowseTorDataDirectory, SIGNAL(clicked()),
59 connect(
ui.cmbAuthMethod, SIGNAL(currentIndexChanged(
int)),
61 connect(
ui.chkRandomPassword, SIGNAL(toggled(
bool)),
62 ui.linePassword, SLOT(setDisabled(
bool)));
63 connect(
ui.chkRandomPassword, SIGNAL(toggled(
bool)),
65 connect(
ui.btnEditTorConfig, SIGNAL(clicked()),
77 ui.rdoControlSocket->setEnabled(
false);
91 ui.retranslateUi(
this);
123 QHostAddress controlAddress(
ui.lineControlAddress->text());
124 QString path(
ui.lineSocketPath->text());
126 if(
ui.chkAuto->isChecked()) {
127 if(
ui.lineTorDataDirectory->text().isEmpty()) {
128 errmsg = tr(
"You've checked the autoconfiguration option for the ControlPort, but"
129 " provided no Data Directory. Please add one, or uncheck the"
130 " \"Configure ControlPort automatically\" option.");
137 if(
ui.rdoControlPort->isChecked()) {
138 if (controlAddress.isNull()) {
139 errmsg = tr(
"'%1' is not a valid IP address.")
140 .arg(
ui.lineControlAddress->text());
145 QFileInfo finfo(path);
146 if(!finfo.exists()) {
147 errmsg = tr(
"ControlSocket path doesn't exist.");
157 &&
ui.linePassword->text().isEmpty()
158 && !
ui.chkRandomPassword->isChecked()) {
159 errmsg = tr(
"You selected 'Password' authentication, but did not "
160 "specify a password.");
167 errmsg = tr(
"The specified Tor configuration file location contains "
168 "characters that cannot be represented in your system's "
169 "current 8-bit character encoding.");
173 errmsg = tr(
"The specified Tor data directory location contains "
174 "characters that cannot be represented in your system's "
175 "current 8-bit character encoding.");
183 QString torrc =
ui.lineTorConfig->text();
187 QMessageBox::StandardButtons res = QMessageBox::question(
this, tr(
"Warning"),
188 tr(
"You changed torrc path, would you like to restart Tor?"),
189 QMessageBox::Yes | QMessageBox::No);
190 if(res == QMessageBox::Yes)
195 QString dataDir =
ui.lineTorDataDirectory->text();
200 if(!
ui.chkAuto->isChecked()) {
210 && !
ui.chkRandomPassword->isChecked())
214 #if defined(Q_WS_WIN)
216 setupService(
ui.chkUseService->isChecked());
233 ui.cmbAuthMethod->setCurrentIndex(
236 if (!
ui.chkRandomPassword->isChecked())
243 #if defined(Q_WS_WIN)
249 ui.chkAuto->setChecked(
false);
250 ui.chkAuto->setVisible(
false);
260 ui.linePassword->setEnabled(usePassword && !
ui.chkRandomPassword->isChecked());
261 ui.chkRandomPassword->setEnabled(usePassword);
262 ui.lblWarn->setVisible((
ui.chkRandomPassword->checkState() == Qt::Unchecked) and usePassword);
296 QString filename = QFileDialog::getOpenFileName(
this,
297 tr(
"Select Tor Configuration File"),
298 QFileInfo(
ui.lineTorConfig->text()).filePath(),
299 tr(
"Tor Configuration File (torrc);;All Files (*)"));
302 if (filename.isEmpty()) {
307 QFile torrcFile(filename);
308 if (!QFileInfo(filename).exists()) {
311 tr(
"File Not Found"),
312 tr(
"%1 does not exist. Would you like to create it?")
324 tr(
"Failed to Create File"),
325 tr(
"Unable to create %1 [%2]").arg(filename)
331 ui.lineTorConfig->setText(filename);
339 QString dataDir = QFileDialog::getExistingDirectory(
this,
340 tr(
"Select a Directory to Use for Tor Data"),
341 ui.lineTorDataDirectory->text());
343 if (!dataDir.isEmpty())
344 ui.lineTorDataDirectory->setText(dataDir);
352 QString start = QDir::currentPath();
353 if(!
ui.lineSocketPath->text().isEmpty())
354 start =
ui.lineSocketPath->text();
355 QString socketPath = QFileDialog::getOpenFileName(
this,
356 tr(
"Select a file to use for Tor socket path"),
359 if (!socketPath.isEmpty())
360 ui.lineSocketPath->setText(socketPath);
364 #if defined(Q_WS_WIN)
367 AdvancedPage::setupService(
bool useService)
372 if (!useService && isInstalled) {
378 tr(
"Unable to remove Tor Service"),
379 tr(
"Vidalia was unable to remove the Tor service.\n\n"
380 "You may need to remove it manually."),
383 }
else if (useService && !isInstalled) {
389 tr(
"Unable to install Tor Service"),
390 tr(
"Vidalia was unable to install the Tor service."),
409 if(
ui.rdoControlPort->isChecked()) {
410 ui.lblAddress->setEnabled(
true);
411 ui.lineControlAddress->setEnabled(
true);
412 ui.lineControlPort->setEnabled(
true);
413 ui.lblPath->setEnabled(
false);
414 ui.lineSocketPath->setEnabled(
false);
415 ui.btnBrowseSocketPath->setEnabled(
false);
416 ui.chkAuto->setEnabled(
true);
418 #if !defined(Q_OS_WIN32)
419 ui.lblAddress->setEnabled(
false);
420 ui.lineControlAddress->setEnabled(
false);
421 ui.lineControlPort->setEnabled(
false);
422 ui.lblPath->setEnabled(
true);
423 ui.lineSocketPath->setEnabled(
true);
424 ui.btnBrowseSocketPath->setEnabled(
true);
425 ui.chkAuto->setEnabled(
false);
433 ui.lblAddress->setVisible(!
ui.chkAuto->isChecked());
434 ui.lineControlAddress->setVisible(!
ui.chkAuto->isChecked());
435 ui.label->setVisible(!
ui.chkAuto->isChecked());
436 ui.lineControlPort->setVisible(!
ui.chkAuto->isChecked());
442 ui.lblWarn->setVisible(!checked and
void setControlPort(quint16 port)
bool touch_file(const QString &filename, bool createdir, QString *errmsg)
bool stop(QString *errmsg=0)
void browseTorDataDirectory()
void setControlMethod(ControlMethod::Method method)
TorSettings::AuthenticationMethod indexToAuthMethod(int index)
bool install(const QString &torPath, const QString &torrc, quint16 controlPort)
QString getControlPassword() const
bool useRandomPassword() const
void authMethodChanged(int index)
int authMethodToIndex(TorSettings::AuthenticationMethod method)
bool save(QString &errmsg)
QString getDataDirectory() const
void setControlPassword(const QString &password)
void displayTorrcDialog()
static bool isSupported()
void setControlAddress(const QHostAddress &addr)
static TorControl * torControl()
virtual bool changedSinceLastApply() const
stop errmsg connect(const QHostAddress &address, quint16 port)
stop errmsg isVidaliaRunningTor()
AdvancedPage(QWidget *parent=0)
static int critical(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
AuthenticationMethod getAuthenticationMethod() const
void setSocketPath(const QString &path)
void setAuthenticationMethod(AuthenticationMethod method)
ControlMethod::Method getControlMethod() const
void setDataDirectory(const QString &dataDir)
static int warning(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton)
void setAutoControlPort(const bool auto)
void setUseRandomPassword(bool useRandomPassword)
QString getExecutable() const
void setTorrc(const QString &torrc)
static int question(QWidget *parent, QString caption, QString text, int button0, int button1=NoButton, int button2=NoButton, QString remember=QString(), VSettings *settings=0, QString key=QString())
void displayWarning(bool)
bool apply(QString *errmsg=0)
bool apply(QString &errmsg)
QString getSocketPath() const
bool changedSinceLastApply()
QHostAddress getControlAddress() const
static bool canEncode(const QString &input)
virtual void retranslateUi()
quint16 getControlPort() const
bool autoControlPort() const
stop errmsg isConnected()