123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- package epson.epsonconnectregistration;
- import android.media.ExifInterface;
- import android.net.Uri;
- import com.box.androidsdk.content.BoxConstants;
- import epson.print.BuildConfig;
- public class SoapWEBSETUPDataInfo extends SoapConfigDataParser {
- static final int AVAILABLEWEBMODE_DISABLE = 1;
- static final int AVAILABLEWEBMODE_ENABLE = 16;
- static final int AVAILABLEWEBMODE_ENABLE_PRINT = 8;
- static final int AVAILABLEWEBMODE_ENABLE_REMOVEACCOUNT = 4;
- static final int AVAILABLEWEBMODE_ENABLE_REMOVEACCOUNT_PRINT = 2;
- static final String GROUP_ID = "WEBSETUPDataInfo";
- static final String ID_ADMIN_PASSWORD = "AdminPassword";
- static final String ID_ADMIN_URL = "AdminURL";
- static final String ID_AVAILABLE_MODE = "AvailableWebMode";
- static final String ID_MODE = "WebMode";
- static final String ID_PRINTER_MAILADDRESS = "PrinterMailAddress";
- static final String ID_SERVER_URL = "WebServerURL";
- static final String ID_SETUP_LANGUAGE = "WebSetupLanguage";
- static final String ID_SETUP_RESULT = "WebSetupResult";
- static final String ID_VERSION = "Version";
- static final String ID_WEBSERVER_STATUS = "WebServerStatus";
- static final String ID_XMPPSERVER_STATUS = "XMPPServerStatus";
- static final String RESULT_NOT_WORKING = "0";
- static final String RESULT_SUCCESS = "2";
- static final String RESULT_WORKING = "1";
- static final String SERVER_STATUS_DISABLE = "0";
- static final String SERVER_STATUS_ENABLE = "2";
- private static final String TAG = "SoapWEBSETUPDataInfo";
- public SoapWEBSETUPDataInfo() {
- super(GROUP_ID);
- }
- public boolean isUnregisteredECPrinter() {
- EPLog.i(TAG, "Enter isUnregisteredECPrinter");
- if (!getRetVal()) {
- EPLog.i(TAG, "return = " + getRetVal());
- return false;
- }
- try {
- Integer valueOf = Integer.valueOf(Integer.parseInt(getValue(ID_AVAILABLE_MODE), 16));
- if (ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_WEBSERVER_STATUS)) && ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_XMPPSERVER_STATUS))) {
- return false;
- }
- if ((valueOf.intValue() & 8) == 0 && (valueOf.intValue() & 16) == 0) {
- EPLog.i(TAG, "Cannot enable EC without delete account -> unregistered");
- return true;
- }
- if (BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_WEBSERVER_STATUS)) || BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_XMPPSERVER_STATUS))) {
- Double valueOf2 = Double.valueOf(Double.parseDouble(getValue(ID_VERSION)));
- Integer valueOf3 = Integer.valueOf(valueOf2.intValue());
- Integer valueOf4 = Integer.valueOf(new Double((valueOf2.doubleValue() - (valueOf2.intValue())) * 100.0d).intValue());
- if (valueOf3.intValue() == 1 && valueOf4.intValue() == 0) {
- EPLog.i(TAG, "WebServerStatus:disable or XMPPServerStatus:disable -> unregistered");
- return true;
- }
- }
- return false;
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (Exception e2) {
- e2.printStackTrace();
- }
- }
- public ECStatus checkECPrinterStatus() {
- EPLog.i(TAG, "Enter isUnregisteredECPrinter");
- if (!getRetVal()) {
- EPLog.i(TAG, "return = " + getRetVal());
- return ECStatus.ERROR_CANNOT_ENABLE;
- }
- try {
- Integer valueOf = Integer.valueOf(Integer.parseInt(getValue(ID_AVAILABLE_MODE), 16));
- if (ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_WEBSERVER_STATUS)) && ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_XMPPSERVER_STATUS))) {
- return ECStatus.ERROR_PRINTER_EC_REGISTERED;
- }
- if ((valueOf.intValue() & 8) == 0 && (valueOf.intValue() & 16) == 0) {
- EPLog.i(TAG, "Cannot enable EC without delete account -> unregistered");
- return ECStatus.ERROR_NONE;
- }
- if (BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_WEBSERVER_STATUS)) || BoxConstants.ROOT_FOLDER_ID.equals(getValue(ID_XMPPSERVER_STATUS))) {
- Double valueOf2 = Double.valueOf(Double.parseDouble(getValue(ID_VERSION)));
- Integer valueOf3 = Integer.valueOf(valueOf2.intValue());
- Integer valueOf4 = Integer.valueOf(new Double((valueOf2.doubleValue() - (valueOf2.intValue())) * 100.0d).intValue());
- if (valueOf3.intValue() != 1 || valueOf4.intValue() != 0) {
- return ECStatus.ERROR_PRINTER_NOT_SUPPORT_EC;
- }
- EPLog.i(TAG, "WebServerStatus:disable or XMPPServerStatus:disable -> unregistered");
- return ECStatus.ERROR_NONE;
- }
- return ECStatus.ERROR_CANNOT_ENABLE;
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (Exception e2) {
- e2.printStackTrace();
- }
- }
- public boolean inProgress() {
- EPLog.i(TAG, "Enter inProgress");
- if (!getRetVal()) {
- EPLog.i(TAG, "return = " + getRetVal());
- return false;
- } else if (!RESULT_WORKING.equals(getValue(ID_SETUP_RESULT))) {
- return false;
- } else {
- EPLog.i(TAG, "Working");
- return true;
- }
- }
- public boolean isSucceeded() {
- String value;
- EPLog.i(TAG, "Enter isSucceeded");
- if (!getRetVal()) {
- EPLog.i(TAG, "return = " + getRetVal());
- return false;
- } else if (!ExifInterface.GPS_MEASUREMENT_2D.equals(getValue(ID_SETUP_RESULT)) || (value = getValue(ID_ADMIN_URL)) == null || value.isEmpty()) {
- return false;
- } else {
- EPLog.i(TAG, "Succeeded");
- return true;
- }
- }
- public Uri getRegistrationUri() {
- EPLog.i(TAG, "Enter isSucceeded");
- if (!getRetVal()) {
- EPLog.i(TAG, "return = " + getRetVal());
- return null;
- }
- try {
- Uri parse = Uri.parse(getValue(ID_ADMIN_URL));
- if (parse == null) {
- return null;
- }
- 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();
- EPLog.i(TAG, "rebuildUri = " + build);
- return build;
- } catch (NullPointerException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
|