- ltr = ledgerTransactions[0];
-
- if (!sendOK()) {
- int tried = 0;
- while (!legacySendOK()) {
- tried++;
- if (tried >= 2)
- throw new IOException(String.format("aborting after %d tries", tried));
- sleep(100);
- }
+ transaction = ledgerTransactions[0];
+
+ final API profileApiVersion = API.valueOf(mProfile.getApiVersion());
+ switch (profileApiVersion) {
+ case auto:
+ boolean sendOK = false;
+ for (API ver : API.allVersions) {
+ Logger.debug("network", "Trying version " + ver);
+ try {
+ sendOK(ver);
+ sendOK = true;
+ Logger.debug("network", "Version " + ver + " request succeeded");
+
+ break;
+ }
+ catch (ApiNotSupportedException e) {
+ Logger.debug("network", "Version " + ver + " seems not supported");
+ }
+ }
+
+ if (!sendOK) {
+ Logger.debug("network", "Trying HTML form emulation");
+ legacySendOkWithRetry();
+ }
+ break;
+ case html:
+ legacySendOkWithRetry();
+ break;
+ case v1_14:
+ case v1_15:
+ case v1_19_1:
+ sendOK(profileApiVersion);
+ break;
+ default:
+ throw new IllegalStateException("Unexpected API version: " + profileApiVersion);