SoapWEBSETUPDataInfo.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package epson.epsonconnectregistration;
  2. import android.media.ExifInterface;
  3. import android.net.Uri;
  4. import com.box.androidsdk.content.BoxConstants;
  5. import epson.print.BuildConfig;
  6. public class SoapWEBSETUPDataInfo extends SoapConfigDataParser {
  7. static final int AVAILABLEWEBMODE_DISABLE = 1;
  8. static final int AVAILABLEWEBMODE_ENABLE = 16;
  9. static final int AVAILABLEWEBMODE_ENABLE_PRINT = 8;
  10. static final int AVAILABLEWEBMODE_ENABLE_REMOVEACCOUNT = 4;
  11. static final int AVAILABLEWEBMODE_ENABLE_REMOVEACCOUNT_PRINT = 2;
  12. static final String GROUP_ID = "WEBSETUPDataInfo";
  13. static final String ID_ADMIN_PASSWORD = "AdminPassword";
  14. static final String ID_ADMIN_URL = "AdminURL";
  15. static final String ID_AVAILABLE_MODE = "AvailableWebMode";
  16. static final String ID_MODE = "WebMode";
  17. static final String ID_PRINTER_MAILADDRESS = "PrinterMailAddress";
  18. static final String ID_SERVER_URL = "WebServerURL";
  19. static final String ID_SETUP_LANGUAGE = "WebSetupLanguage";
  20. static final String ID_SETUP_RESULT = "WebSetupResult";
  21. static final String ID_VERSION = "Version";
  22. static final String ID_WEBSERVER_STATUS = "WebServerStatus";
  23. static final String ID_XMPPSERVER_STATUS = "XMPPServerStatus";
  24. static final String RESULT_NOT_WORKING = "0";
  25. static final String RESULT_SUCCESS = "2";
  26. static final String RESULT_WORKING = "1";
  27. static final String SERVER_STATUS_DISABLE = "0";
  28. static final String SERVER_STATUS_ENABLE = "2";
  29. private static final String TAG = "SoapWEBSETUPDataInfo";
  30. public SoapWEBSETUPDataInfo() {
  31. super(GROUP_ID);
  32. }
  33. public boolean isUnregisteredECPrinter() {
  34. EPLog.i(TAG, "Enter isUnregisteredECPrinter");
  35. if (!getRetVal()) {
  36. EPLog.i(TAG, "return = " + getRetVal());
  37. return false;
  38. }
  39. try {
  40. Integer valueOf = Integer.valueOf(Integer.parseInt(getValue(ID_AVAILABLE_MODE), 16));
  41. if (ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_WEBSERVER_STATUS)) && ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_XMPPSERVER_STATUS))) {
  42. return false;
  43. }
  44. if ((valueOf.intValue() & 8) == 0 && (valueOf.intValue() & 16) == 0) {
  45. EPLog.i(TAG, "Cannot enable EC without delete account -> unregistered");
  46. return true;
  47. }
  48. if (BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_WEBSERVER_STATUS)) || BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_XMPPSERVER_STATUS))) {
  49. Double valueOf2 = Double.valueOf(Double.parseDouble(getValue(ID_VERSION)));
  50. Integer valueOf3 = Integer.valueOf(valueOf2.intValue());
  51. Integer valueOf4 = Integer.valueOf(new Double((valueOf2.doubleValue() - (valueOf2.intValue())) * 100.0d).intValue());
  52. if (valueOf3.intValue() == 1 && valueOf4.intValue() == 0) {
  53. EPLog.i(TAG, "WebServerStatus:disable or XMPPServerStatus:disable -> unregistered");
  54. return true;
  55. }
  56. }
  57. return false;
  58. } catch (NumberFormatException e) {
  59. e.printStackTrace();
  60. } catch (Exception e2) {
  61. e2.printStackTrace();
  62. }
  63. }
  64. public ECStatus checkECPrinterStatus() {
  65. EPLog.i(TAG, "Enter isUnregisteredECPrinter");
  66. if (!getRetVal()) {
  67. EPLog.i(TAG, "return = " + getRetVal());
  68. return ECStatus.ERROR_CANNOT_ENABLE;
  69. }
  70. try {
  71. Integer valueOf = Integer.valueOf(Integer.parseInt(getValue(ID_AVAILABLE_MODE), 16));
  72. if (ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_WEBSERVER_STATUS)) && ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_XMPPSERVER_STATUS))) {
  73. return ECStatus.ERROR_PRINTER_EC_REGISTERED;
  74. }
  75. if ((valueOf.intValue() & 8) == 0 && (valueOf.intValue() & 16) == 0) {
  76. EPLog.i(TAG, "Cannot enable EC without delete account -> unregistered");
  77. return ECStatus.ERROR_NONE;
  78. }
  79. if (BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_WEBSERVER_STATUS)) || BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_XMPPSERVER_STATUS))) {
  80. Double valueOf2 = Double.valueOf(Double.parseDouble(getValue(ID_VERSION)));
  81. Integer valueOf3 = Integer.valueOf(valueOf2.intValue());
  82. Integer valueOf4 = Integer.valueOf(new Double((valueOf2.doubleValue() - (valueOf2.intValue())) * 100.0d).intValue());
  83. if (valueOf3.intValue() != 1 || valueOf4.intValue() != 0) {
  84. return ECStatus.ERROR_PRINTER_NOT_SUPPORT_EC;
  85. }
  86. EPLog.i(TAG, "WebServerStatus:disable or XMPPServerStatus:disable -> unregistered");
  87. return ECStatus.ERROR_NONE;
  88. }
  89. return ECStatus.ERROR_CANNOT_ENABLE;
  90. } catch (NumberFormatException e) {
  91. e.printStackTrace();
  92. } catch (Exception e2) {
  93. e2.printStackTrace();
  94. }
  95. }
  96. public boolean inProgress() {
  97. EPLog.i(TAG, "Enter inProgress");
  98. if (!getRetVal()) {
  99. EPLog.i(TAG, "return = " + getRetVal());
  100. return false;
  101. } else if (!RESULT_WORKING.equals(getValue(ID_SETUP_RESULT))) {
  102. return false;
  103. } else {
  104. EPLog.i(TAG, "Working");
  105. return true;
  106. }
  107. }
  108. public boolean isSucceeded() {
  109. String value;
  110. EPLog.i(TAG, "Enter isSucceeded");
  111. if (!getRetVal()) {
  112. EPLog.i(TAG, "return = " + getRetVal());
  113. return false;
  114. } else if (!ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_SETUP_RESULT)) || (value = getValue(ID_ADMIN_URL)) == null || value.isEmpty()) {
  115. return false;
  116. } else {
  117. EPLog.i(TAG, "Succeeded");
  118. return true;
  119. }
  120. }
  121. public Uri getRegistrationUri() {
  122. EPLog.i(TAG, "Enter isSucceeded");
  123. if (!getRetVal()) {
  124. EPLog.i(TAG, "return = " + getRetVal());
  125. return null;
  126. }
  127. try {
  128. Uri parse = Uri.parse(getValue(ID_ADMIN_URL));
  129. if (parse == null) {
  130. return null;
  131. }
  132. Uri build = new Uri.Builder().scheme(parse.getScheme()).authority(parse.getAuthority()).path(parse.getPath().replace("/setup/", "/nsetup/")).encodedQuery(parse.getQuery()).appendQueryParameter("from", "Alpha".equals(BuildConfig.FLAVOR) ? "setuptool" : "printerfinder").build();
  133. EPLog.i(TAG, "rebuildUri = " + build);
  134. return build;
  135. } catch (NullPointerException e) {
  136. e.printStackTrace();
  137. return null;
  138. }
  139. }
  140. }