()
| 88 | .execute( |
| 89 | new Runnable() { |
| 90 | public void run() { |
| 91 | int reply; |
| 92 | int port = args.optInt(1); |
| 93 | String host = args.optString(0); |
| 94 | String username = args.optString(2); |
| 95 | String password = args.optString(3); |
| 96 | String defaultPath = args.optString(4); |
| 97 | String securityType = args.optString(5); |
| 98 | String connectionMode = args.optString(6); |
| 99 | String encryption = args.optString(7); |
| 100 | String encoding = args.optString(8); |
| 101 | String ftpId = getFtpId(host, port, username); |
| 102 | FTPClient ftp = null; |
| 103 | |
| 104 | try { |
| 105 | if (ftpProfiles.containsKey(ftpId)) { |
| 106 | ftp = ftpProfiles.get(ftpId); |
| 107 | reply = ftp.getReplyCode(); |
| 108 | if (ftp.isConnected() && FTPReply.isPositiveCompletion(reply)) { |
| 109 | ftp.setControlEncoding("UTF-8"); |
| 110 | ftp.setAutodetectUTF8(true); |
| 111 | System.setProperty("ftp.client.encoding", "UTF-8"); |
| 112 | // test if connection is still valid |
| 113 | ftp.sendNoOp(); |
| 114 | Log.d("FTP", "FTPClient (" + ftpId + ") is connected"); |
| 115 | callback.success(ftpId); |
| 116 | return; |
| 117 | } |
| 118 | Log.d("FTP", "FTPClient (" + ftpId + ") is not connected"); |
| 119 | ftp.disconnect(); |
| 120 | Log.d("FTP", "FTPClient (" + ftpId + ") disconnecting..."); |
| 121 | } else { |
| 122 | Log.d("FTP", "Creating new FTPClient (" + ftpId + ")"); |
| 123 | ftp = new FTPClient(); |
| 124 | ftpProfiles.put(ftpId, ftp); |
| 125 | } |
| 126 | |
| 127 | Log.d("FTP", "FTPClient (" + ftpId + ") connecting..."); |
| 128 | ftp.connect(host, port); |
| 129 | ftp.setControlKeepAliveTimeout(300); |
| 130 | if (connectionMode.equals("active")) { |
| 131 | Log.d("FTP", "Entering Local Active mode"); |
| 132 | ftp.enterLocalActiveMode(); |
| 133 | } else { |
| 134 | Log.d("FTP", "Entering Passive Active mode"); |
| 135 | ftp.enterLocalPassiveMode(); |
| 136 | } |
| 137 | |
| 138 | Log.d("FTP", "FTPClient (" + ftpId + ") logging in..."); |
| 139 | ftp.login(username, password); |
| 140 | |
| 141 | reply = ftp.getReplyCode(); |
| 142 | if (!FTPReply.isPositiveCompletion(reply)) { |
| 143 | ftp.disconnect(); |
| 144 | Log.d( |
| 145 | "FTP", |
| 146 | "FTPClient (" + ftpId + ") server refused connection." |
| 147 | ); |
nothing calls this directly
no test coverage detected