Added sign-off to quick setup

pull/194/merge
M66B 3 years ago
parent 03dd806c8d
commit a7e508482f

@ -1049,8 +1049,10 @@ public class EmailProvider implements Parcelable {
EntityLog.log(context, "Handshake " + address + ": " + Log.formatThrowable(ex));
} finally {
try {
if (sslSocket != null)
if (sslSocket != null) {
signOff(sslSocket, context);
sslSocket.close();
}
} catch (Throwable ex) {
Log.e(ex);
}
@ -1157,6 +1159,30 @@ public class EmailProvider implements Parcelable {
throw new SocketException("No STARTTLS");
}
private void signOff(Socket socket, Context context) {
try {
String command = (port == 465 || port == 587 ? "QUIT" : "A002 LOGOUT");
EntityLog.log(context, EntityLog.Type.Protocol,
socket.getRemoteSocketAddress() + " >" + command);
socket.getOutputStream().write((command + "\n").getBytes());
LineInputStream lis =
new LineInputStream(
new BufferedInputStream(
socket.getInputStream()));
String response;
do {
response = lis.readLine();
if (response != null)
EntityLog.log(context, EntityLog.Type.Protocol,
socket.getRemoteSocketAddress() + " <" + response);
} while (response != null);
} catch (IOException ex) {
Log.w(ex);
}
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Server) {

Loading…
Cancel
Save