MCPcopy Create free account
hub / github.com/M66B/FairEmail / command

Method command

app/src/main/java/com/sun/mail/iap/Protocol.java:350–411  ·  view source on GitHub ↗

Send a command to the server. Collect all responses until either the corresponding command completion response or a BYE response (indicating server failure). Return all the collected responses. @param command the command @param args the arguments @return array of Response objects returned by the

(String command, Argument args)

Source from the content-addressed store, hash-verified

348 * @return array of Response objects returned by the server
349 */
350 public synchronized Response[] command(String command, Argument args) {
351 if (socket == null)
352 return new Response[]{Response.byeResponse(new SocketException("disconnected"))};
353 if ("LOGOUT".equals(command))
354 try {
355 socket.setSoTimeout(10 * 1000);
356 } catch (SocketException ex) {
357 eu.faircode.email.Log.e(ex);
358 }
359
360 commandStart(command);
361 List<Response> v = new ArrayList<>();
362 boolean done = false;
363 String tag = null;
364
365 // write the command
366 try {
367 tag = writeCommand(command, args);
368 } catch (LiteralException lex) {
369 v.add(lex.getResponse());
370 done = true;
371 } catch (Exception ex) {
372 // Convert this into a BYE response
373 v.add(Response.byeResponse(ex));
374 done = true;
375 }
376
377 Response byeResp = null;
378 while (!done) {
379 Response r = null;
380 try {
381 r = readResponse();
382 } catch (IOException ioex) {
383 if (byeResp == null) // convert this into a BYE response
384 byeResp = Response.byeResponse(ioex);
385 // else, connection closed after BYE was sent
386 break;
387 } catch (ProtocolException pex) {
388 logger.log(Level.FINE, "ignoring bad response", pex);
389 continue; // skip this response
390 }
391
392 if (r.isBYE()) {
393 byeResp = r;
394 continue;
395 }
396
397 v.add(r);
398
399 // If this is a matching command completion response, we are done
400 if (r.isTagged() && r.getTag().equals(tag))
401 done = true;
402 }
403
404 if (byeResp != null)
405 v.add(byeResp); // must be last
406 Response[] responses = new Response[v.size()];
407 v.toArray(responses);

Callers 15

simpleCommandMethod · 0.95
doCommandMethod · 0.80
setFlagsMethod · 0.80
copyMessagesMethod · 0.80
doCommandMethod · 0.80
doCommandMethod · 0.80
searchMethod · 0.80
storeLabelsMethod · 0.80
setFlagsMethod · 0.80
copymoveMessagesMethod · 0.80
setFlagsMethod · 0.80
capabilityMethod · 0.80

Calls 15

byeResponseMethod · 0.95
commandStartMethod · 0.95
writeCommandMethod · 0.95
readResponseMethod · 0.95
isBYEMethod · 0.95
isTaggedMethod · 0.95
getTagMethod · 0.95
commandEndMethod · 0.95
setSoTimeoutMethod · 0.80
eMethod · 0.80
toArrayMethod · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected