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.btnEditTorConfig, SIGNAL(clicked()),
65 connect(
ui.rdoControlPort, SIGNAL(toggled(
bool)),
this, SLOT(
toggleControl(
bool)));
67 connect(
ui.chkAuto, SIGNAL(toggled(
bool)),
this, SLOT(
toggleAuto(
bool)));
75 ui.rdoControlSocket->setEnabled(
false);
89 ui.retranslateUi(
this);
121 QHostAddress controlAddress(
ui.lineControlAddress->text());
122 QString path(
ui.lineSocketPath->text());
124 if(
ui.chkAuto->isChecked()) {
125 if(
ui.lineTorDataDirectory->text().isEmpty()) {
126 errmsg = tr(
"You've checked the autoconfiguration option for the ControlPort, but"
127 " provided no Data Directory. Please add one, or uncheck the"
128 " \"Configure ControlPort automatically\" option.");
135 if(
ui.rdoControlPort->isChecked()) {
136 if (controlAddress.isNull()) {
137 errmsg = tr(
"'%1' is not a valid IP address.")
138 .arg(
ui.lineControlAddress->text());
143 QFileInfo finfo(path);
144 if(!finfo.exists()) {
145 errmsg = tr(
"ControlSocket path doesn't exist.");
155 &&
ui.linePassword->text().isEmpty()
156 && !
ui.chkRandomPassword->isChecked()) {
157 errmsg = tr(
"You selected 'Password' authentication, but did not "
158 "specify a password.");
165 errmsg = tr(
"The specified Tor configuration file location contains "
166 "characters that cannot be represented in your system's "
167 "current 8-bit character encoding.");
171 errmsg = tr(
"The specified Tor data directory location contains "
172 "characters that cannot be represented in your system's "
173 "current 8-bit character encoding.");
181 QString torrc =
ui.lineTorConfig->text();
185 QMessageBox::StandardButtons res = QMessageBox::question(
this, tr(
"Warning"),
186 tr(
"You changed torrc path, would you like to restart Tor?"),
187 QMessageBox::Yes | QMessageBox::No);
188 if(res == QMessageBox::Yes)
193 QString dataDir =
ui.lineTorDataDirectory->text();
198 if(!
ui.chkAuto->isChecked()) {
208 && !
ui.chkRandomPassword->isChecked())
212 #if defined(Q_WS_WIN)
214 setupService(
ui.chkUseService->isChecked());
231 ui.cmbAuthMethod->setCurrentIndex(
234 if (!
ui.chkRandomPassword->isChecked())
241 #if defined(Q_WS_WIN)
248 ui.chkAuto->setChecked(
false);
249 ui.chkAuto->setVisible(
false);
259 ui.linePassword->setEnabled(usePassword && !
ui.chkRandomPassword->isChecked());
260 ui.chkRandomPassword->setEnabled(usePassword);
294 QString filename = QFileDialog::getOpenFileName(
this,
295 tr(
"Select Tor Configuration File"),
296 QFileInfo(
ui.lineTorConfig->text()).filePath(),
297 tr(
"Tor Configuration File (torrc);;All Files (*)"));
300 if (filename.isEmpty()) {
305 QFile torrcFile(filename);
306 if (!QFileInfo(filename).exists()) {
309 tr(
"File Not Found"),
310 tr(
"%1 does not exist. Would you like to create it?")
322 tr(
"Failed to Create File"),
323 tr(
"Unable to create %1 [%2]").arg(filename)
329 ui.lineTorConfig->setText(QDir::toNativeSeparators(filename));
337 QString dataDir = QFileDialog::getExistingDirectory(
this,
338 tr(
"Select a Directory to Use for Tor Data"),
339 ui.lineTorDataDirectory->text());
341 if (!dataDir.isEmpty())
342 ui.lineTorDataDirectory->setText(QDir::toNativeSeparators(dataDir));
350 QString start = QDir::currentPath();
351 if(!
ui.lineSocketPath->text().isEmpty())
352 start =
ui.lineSocketPath->text();
353 QString socketPath = QFileDialog::getOpenFileName(
this,
354 tr(
"Select a file to use for Tor socket path"),
357 if (!socketPath.isEmpty())
358 ui.lineSocketPath->setText(socketPath);
362 #if defined(Q_WS_WIN)
365 AdvancedPage::setupService(
bool useService)
370 if (!useService && isInstalled) {
376 tr(
"Unable to remove Tor Service"),
377 tr(
"Vidalia was unable to remove the Tor service.\n\n"
378 "You may need to remove it manually."),
381 }
else if (useService && !isInstalled) {
387 tr(
"Unable to install Tor Service"),
388 tr(
"Vidalia was unable to install the Tor service."),
407 if(
ui.rdoControlPort->isChecked()) {
408 ui.lblAddress->setEnabled(
true);
409 ui.lineControlAddress->setEnabled(
true);
410 ui.lineControlPort->setEnabled(
true);
411 ui.lblPath->setEnabled(
false);
412 ui.lineSocketPath->setEnabled(
false);
413 ui.btnBrowseSocketPath->setEnabled(
false);
414 ui.chkAuto->setEnabled(
true);
416 #if !defined(Q_OS_WIN32)
417 ui.lblAddress->setEnabled(
false);
418 ui.lineControlAddress->setEnabled(
false);
419 ui.lineControlPort->setEnabled(
false);
420 ui.lblPath->setEnabled(
true);
421 ui.lineSocketPath->setEnabled(
true);
422 ui.btnBrowseSocketPath->setEnabled(
true);
423 ui.chkAuto->setEnabled(
false);
431 ui.lblAddress->setVisible(!
ui.chkAuto->isChecked());
432 ui.lineControlAddress->setVisible(!
ui.chkAuto->isChecked());
433 ui.label->setVisible(!
ui.chkAuto->isChecked());
434 ui.lineControlPort->setVisible(!
ui.chkAuto->isChecked());