implement certificate check settings for imap/smtp (#1047)

This commit is contained in:
cyberta
2019-10-30 12:40:14 +01:00
committed by B. Petersen
parent 8a6b9e7f62
commit c7e7d00512
4 changed files with 37 additions and 2 deletions
+21 -2
View File
@@ -90,7 +90,7 @@
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="inbox, imap_login, imap_server, imap_port, imap_security_label, imap_security, outbox_view_spacer_top,
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, view_log_button" />
outbox, smtp_login, smtp_password, smtp_server, smtp_port, smtp_security_label, smtp_security, auth_method_label, auth_method, cert_check_label, cert_check, view_log_button" />
<ImageView
android:id="@+id/advanced_icon"
@@ -323,6 +323,25 @@
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method_label" />
<TextView
android:id="@+id/cert_check_label"
style="@style/TextAppearance.AppCompat.Caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/login_certificate_checks"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method" />
<Spinner
android:id="@+id/cert_check"
android:layout_width="0dp"
android:layout_height="48dp"
android:entries="@array/pref_dc_certck_entries"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/cert_check_label" />
<TextView
android:id="@+id/view_log_button"
android:layout_width="0dp"
@@ -335,7 +354,7 @@
android:paddingBottom="32dp"
app:layout_constraintEnd_toEndOf="@id/guideline_root_end"
app:layout_constraintStart_toStartOf="@id/guideline_root_start"
app:layout_constraintTop_toBottomOf="@id/auth_method" />
app:layout_constraintTop_toBottomOf="@id/cert_check" />
<TextView
android:id="@+id/sub_header"
+7
View File
@@ -178,6 +178,13 @@
<item>1</item>
</string-array>
<string-array name="pref_dc_certck_entries">
<item>@string/automatic</item>
<item>@string/strict</item>
<item>@string/accept_invalid_hostnames</item>
<item>@string/accept_invalid_certificates</item>
</string-array>
<!-- discrete MIME type (the part before the "/") -->
+1
View File
@@ -339,6 +339,7 @@
<string name="login_error_cannot_login">Cannot login as \"%1$s\". Please check if the email-address and the password are correct.</string>
<!-- Translators: %1$s will be replaced by the server name (eg. imap.somewhere.org) and %2$s will be replaced by the human-readable response from the server. this response may be a single word or some sentences and may or may not be localized. -->
<string name="login_error_server_response">Response from %1$s: %2$s\n\nSome providers place additional information in your inbox; you can check them it eg. in the web frontend. Consult your provider or friends if you run into problems.</string>
<string name="login_certificate_checks">IMAP/SMTP certificate checks</string>
<!-- TLS certificate checks -->
<string name="accept_invalid_hostnames">Accept invalid hostnames</string>
@@ -67,6 +67,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
Spinner imapSecurity;
Spinner smtpSecurity;
Spinner authMethod;
Spinner certCheck;
@Override
public void onCreate(Bundle bundle) {
@@ -89,6 +90,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
imapSecurity = findViewById(R.id.imap_security);
smtpSecurity = findViewById(R.id.smtp_security);
authMethod = findViewById(R.id.auth_method);
certCheck = findViewById(R.id.cert_check);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
@@ -149,6 +151,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
sel = 0;
if((server_flags&DcContext.DC_LP_AUTH_OAUTH2)!=0) sel = 1;
authMethod.setSelection(sel);
int certCheckFlags = DcHelper.getInt(this, "imap_certificate_checks");
certCheck.setSelection(certCheckFlags);
}
DcHelper.getContext(this).eventCenter.addObserver(this, DcContext.DC_EVENT_CONFIGURE_PROGRESS);
@@ -434,6 +439,9 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
if(authMethod.getSelectedItemPosition()==1) server_flags |= DcContext.DC_LP_AUTH_OAUTH2;
DcHelper.getContext(this).setConfigInt("server_flags", server_flags);
DcHelper.getContext(this).setConfigInt("smtp_certificate_checks", certCheck.getSelectedItemPosition());
DcHelper.getContext(this).setConfigInt("imap_certificate_checks", certCheck.getSelectedItemPosition());
// calling configure() results in
// receiving multiple DC_EVENT_CONFIGURE_PROGRESS events
DcHelper.getContext(this).captureNextError();