(
InetAddress address, int port, boolean require_id, String user,
SSLSocketFactoryService factory)
| 869 | } |
| 870 | |
| 871 | private void _connect( |
| 872 | InetAddress address, int port, boolean require_id, String user, |
| 873 | SSLSocketFactoryService factory) throws MessagingException { |
| 874 | EntityLog.log(context, EntityLog.Type.Network, "Connecting to " + address + ":" + port); |
| 875 | |
| 876 | isession = Session.getInstance(properties, authenticator); |
| 877 | |
| 878 | breadcrumbs = new RingBuffer<>(BREADCRUMBS_SIZE); |
| 879 | |
| 880 | boolean trace = (debug || log); |
| 881 | |
| 882 | isession.setDebug(trace); |
| 883 | if (trace) |
| 884 | isession.setDebugOut(new PrintStream(new OutputStream() { |
| 885 | private ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| 886 | |
| 887 | @Override |
| 888 | public void write(int b) { |
| 889 | try { |
| 890 | if (((char) b) == '\n') { |
| 891 | String line = bos.toString(); |
| 892 | if (log) |
| 893 | if (line.endsWith("ignoring socket timeout")) |
| 894 | Log.d("javamail", user + " " + line); |
| 895 | else |
| 896 | Log.w("javamail", user + " " + line); |
| 897 | bos.reset(); |
| 898 | } else |
| 899 | bos.write(b); |
| 900 | } catch (Throwable ex) { |
| 901 | Log.e(ex); |
| 902 | } |
| 903 | } |
| 904 | }, true)); |
| 905 | |
| 906 | //System.setProperty("mail.socket.debug", Boolean.toString(debug)); |
| 907 | isession.addProvider(new GmailSSLProvider()); |
| 908 | |
| 909 | if ("pop3".equals(protocol) || "pop3s".equals(protocol)) { |
| 910 | iservice = isession.getStore(protocol); |
| 911 | iservice.connect(address.getHostAddress(), port, user, null); |
| 912 | |
| 913 | } else if ("imap".equals(protocol) || "imaps".equals(protocol) || "gimaps".equals(protocol)) { |
| 914 | iservice = isession.getStore(protocol); |
| 915 | if (listener != null) |
| 916 | ((IMAPStore) iservice).addStoreListener(listener); |
| 917 | iservice.connect(address.getHostAddress(), port, user, null); |
| 918 | |
| 919 | // https://www.ietf.org/rfc/rfc2971.txt |
| 920 | IMAPStore istore = (IMAPStore) getStore(); |
| 921 | if (istore.hasCapability("ID")) |
| 922 | try { |
| 923 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 924 | boolean client_id = prefs.getBoolean("client_id", true); |
| 925 | Map<String, String> sid = istore.id(client_id ? getId(context) : null); |
| 926 | if (sid != null) { |
| 927 | Map<String, String> crumb = new HashMap<>(); |
| 928 | for (String key : sid.keySet()) { |
no test coverage detected