Skip to content

Commit

Permalink
Use additional starttls return info from autoconfig library
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed May 21, 2014
1 parent 670f2dc commit 753b899
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
2 changes: 1 addition & 1 deletion imp/js/remoteprefs.js
Expand Up @@ -28,7 +28,7 @@ var ImpRemotePrefs = {
$('remote_server').setValue(r.mconfig.host);
$('remote_user').setValue(r.mconfig.username);
$('remote_port').setValue(r.mconfig.port);
$('remote_secure_autoconfig').setValue(~~(!!r.mconfig.tls));
$('remote_secure_autoconfig').setValue(r.mconfig.tls);

if ($F('remote_label').blank()) {
$('remote_label').setValue(r.mconfig.label);
Expand Down
54 changes: 31 additions & 23 deletions imp/lib/Prefs/Special/Remote.php
Expand Up @@ -89,38 +89,46 @@ public function update(Horde_Core_Prefs_Ui $ui)
$ob->type = $ob::POP3;
}

if ($ui->vars->remote_secure_autoconfig) {
$ob->secure = 'ssl';
if (isset($ui->vars->remote_secure_autoconfig)) {
switch ($ui->vars->remote_secure_autoconfig) {
case 'starttls':
$ob->secure = 'tls';
break;

case 'tls':
$ob->secure = 'ssl';
break;

default:
$ob->secure = true;
break;
}
} else {
switch ($ui->vars->remote_secure) {
case 'auto':
$ob->secure = true;
break;

case 'yes':
if (isset($ui->vars->remote_secure_autoconfig)) {
$ob->secure = 'tls';
} else {
switch ($ob->type) {
case $ob::IMAP:
$tmp = new Horde_Mail_Autoconfig_Server_Imap();
break;

case $ob::POP3:
$tmp = new Horde_Mail_Autoconfig_Server_Pop3();
break;
}

$tmp->host = $ob->hostspec;
$tmp->port = $ob->port;
$tmp->tls = true;

$ob->secure = $tmp->valid()
? 'ssl'
: 'tls';
switch ($ob->type) {
case $ob::IMAP:
$tmp = new Horde_Mail_Autoconfig_Server_Imap();
break;

case $ob::POP3:
$tmp = new Horde_Mail_Autoconfig_Server_Pop3();
break;
}
break;

$tmp->host = $ob->hostspec;
$tmp->port = $ob->port;
$tmp->tls = true;

$ob->secure = $tmp->valid()
? 'ssl'
: 'tls';
}
break;
}

$remote[strval($ob)] = $ob;
Expand Down

0 comments on commit 753b899

Please sign in to comment.