package epson.print.screen;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;

import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import epson.common.Constants;
import epson.print.ActivityIACommon;
import epson.print.EPImage;
import epson.print.EPPrinterInfo;
import epson.print.EPPrinterManager;
import epson.print.IprintApplication;
import epson.print.MyPrinter;
import epson.print.R;
import epson.print.Util.EPLog;
import epson.print.ecclient.EccErrorInfo;
import epson.print.ecclient.EpsonConnectAccess;
import epson.print.widgets.CustomTitleAlertDialogBuilder;

public class ActivityPrinterSetting extends ActivityIACommon implements View.OnClickListener, StringListSelectDialog.OnItemSelectedListener {
    private static final String DIALOG_TAG_DOMAIN_SELECT = "domain-select-dialog";
    public static final String KEY_MYPRINTER = "my_printer";
    private static final String MAIL_DOMAIN_CHINA = "print.rpt.epson.com.cn";
    private static final int REQUEST_CODE_PRINTER = 0;
    private final int ACCESS_KEY_MAX_SIZE = 32;
    private final int ACCESS_KEY_MIN_SIZE = 6;
    private final int CLEAR_ACCESS_KEY = 3;
    private final int CLEAR_EMAIL_ADDRESS = 2;
    private final int CLEAR_PRINTER_NAME = 1;
    private final int EMAIL_ADDRESS_MAX_SIZE = EPImage.EPS_ROTATE_180;
    private final int ERROR_GET_INFO_FROM_PRINTER = -1;
    private final int ERROR_PRINTER_ALREADY_REGISTERED = -5;
    private final int ERROR_PRINTER_EMAIL_ADDRESS_EMPTY = -4;
    private final int ERROR_PRINTER_NAME_EMPTY = -2;
    private final int ERROR_PRINTER_NAME_OVER_MAX_LENGTH = -3;
    private final int FINISH = 7;
    private final String MAIL_DOMAIN_NAME;
    private final int NOT_SUPPORTED_REMOTE_PRINT = 2;
    private final int PRINTER_NAME_MAX_SIZE = 63;
    private final int SAVE_DONE = 5;
    private final int SHOW_ERROR_MESSAGE = 6;
    private final int SUPPORTED_REMOTE_PRINT = 1;
    private final int UPDATE_ACCESSKEY_LAYOUT = 4;
    private EditText accessKeyEdit = null;
    private FrameLayout accessKeyLayout = null;
    private TextView accessKeyText = null;
    private Bundle bundle = null;
    private Button clearAccessKeyButton = null;
    private Button clearPrinterEmailAddressButton = null;
    private Button clearPrinterNameButton = null;
    private Context context = null;
    private LinearLayout getprinterAdress = null;
    private LinearLayout getprinterAdressLink = null;
    Handler mHandler;
    private LocalTextWatcher mLocalTextWatcher;
    MyPrinter mMyPrinter;
    private String oldPrinterEmailAddress = "";
    private String printerAccessKey = "";
    private String printerEmailAddress = "";
    private EditText printerEmailAddressEdit = null;
    private TextView printerEmailText = null;
    private String printerName = "";
    private EditText printerNameEdit = null;
    private FrameLayout printerNameLayout = null;
    private TextView printerNameText = null;

    public ActivityPrinterSetting() {
        if (IprintApplication.isConnectStaging()) {
            MAIL_DOMAIN_NAME = "stg-print.epsonconnect.com";
        } else {
            MAIL_DOMAIN_NAME = "print.epsonconnect.com";
        }
        mHandler = new Handler(new Handler.Callback() {
            public boolean handleMessage(Message message) {
                switch (message.what) {
                    case 1:
                        ActivityPrinterSetting.this.printerNameEdit.setText("");
                        return true;
                    case 2:
                        ActivityPrinterSetting.this.printerEmailAddressEdit.setText("");
                        return true;
                    case 3:
                        ActivityPrinterSetting.this.accessKeyEdit.setText("");
                        return true;
                    case 4:
                        ActivityPrinterSetting.this.accessKeyText.setVisibility(message.arg1);
                        ActivityPrinterSetting.this.accessKeyLayout.setVisibility(message.arg1);
                        ActivityPrinterSetting.this.accessKeyEdit.requestFocus();
                        return true;
                    case 5:
                        new setRemotePrintTask().execute(new Void[0]);
                        return true;
                    case 6:
                        if (message.arg1 == 0) {
                            return true;
                        }
                        ActivityPrinterSetting.this.showErrorMessage(message.arg1);
                        return true;
                    case 7:
                        Intent intent = new Intent();
                        intent.putExtra(ActivityPrinterSetting.KEY_MYPRINTER, ActivityPrinterSetting.this.mMyPrinter);
                        ActivityPrinterSetting.this.setResult(-1, intent);
                        ActivityPrinterSetting.this.finish();
                        return true;
                    default:
                        return true;
                }
            }
        });
    }

    public void onCreate(Bundle bundle2) {
        super.onCreate(bundle2);
        getWindow().setSoftInputMode(3);
        setContentView((int) R.layout.epsonconnect_printer_setting_layout);
        context = this;
        setActionBar((int) R.string.epsonconnect_str_regist_printer, true);
        printerNameText = (TextView) findViewById(R.id.printer_name_text);
        printerNameEdit = (EditText) findViewById(R.id.printer_name_edit);
        clearPrinterNameButton = (Button) findViewById(R.id.clear_printer_name_btn);
        printerNameLayout = (FrameLayout) findViewById(R.id.printer_name_layout);
        printerEmailText = (TextView) findViewById(R.id.printer_email_text);
        printerEmailAddressEdit = (EditText) findViewById(R.id.printer_email_address_edit);
        clearPrinterEmailAddressButton = (Button) findViewById(R.id.clear_printer_email_address_btn);
        accessKeyText = (TextView) findViewById(R.id.access_key_text);
        accessKeyLayout = (FrameLayout) findViewById(R.id.access_key_layout);
        accessKeyEdit = (EditText) findViewById(R.id.access_key_edit);
        clearAccessKeyButton = (Button) findViewById(R.id.clear_access_key_btn);
        getprinterAdress = (LinearLayout) findViewById(R.id.get_mailadress);
        getprinterAdressLink = (LinearLayout) findViewById(R.id.rlPrinterSettings);
        clearPrinterNameButton.setOnClickListener(this);
        clearPrinterEmailAddressButton.setOnClickListener(this);
        clearAccessKeyButton.setOnClickListener(this);
        getprinterAdressLink.setOnClickListener(this);
        mLocalTextWatcher = new LocalTextWatcher();
        printerEmailAddressEdit.addTextChangedListener(this.mLocalTextWatcher);
        printerNameText.setVisibility(8);
        printerNameLayout.setVisibility(8);
        accessKeyText.setVisibility(8);
        accessKeyLayout.setVisibility(8);
        Intent intent = getIntent();
        if (intent != null) {
            bundle = intent.getExtras();
            Bundle bundle3 = bundle;
            if (bundle3 != null) {
                printerEmailAddress = bundle3.getString(Constants.PRINTER_EMAIL_ADDRESS);
                String str = printerEmailAddress;
                if (str == null || str.equals("")) {
                    printerEmailAddress = "";
                    printerEmailText.setText(R.string.epsonconnect_str_remote_print_email_address_warning);
                }
                printerEmailAddressEdit.setText(this.printerEmailAddress);
                String str2 = printerEmailAddress;
                oldPrinterEmailAddress = str2;
                if (!str2.equals("")) {
                    EPPrinterInfo loadRemotePrinterInfo = new EPPrinterManager(this).loadRemotePrinterInfo(this.printerEmailAddress);
                    if (loadRemotePrinterInfo != null) {
                        printerName = loadRemotePrinterInfo.userDefName;
                        if (this.printerName == null) {
                            printerName = loadRemotePrinterInfo.printerName;
                        }
                        printerNameEdit.setText(this.printerName);
                        printerNameText.setVisibility(0);
                        printerNameLayout.setVisibility(0);
                        printerAccessKey = loadRemotePrinterInfo.printerAccessKey;
                        if (!this.printerAccessKey.equals("")) {
                            accessKeyEdit.setText(this.printerAccessKey);
                            accessKeyText.setVisibility(0);
                            accessKeyLayout.setVisibility(0);
                        }
                        getprinterAdress.setVisibility(8);
                    }
                    printerEmailText.setText(R.string.epsonconnect_str_print_email);
                    setTitle(getString(R.string.epsonconnect_str_edit_printer));
                }
            }
        }
    }

    private void showMailDomainSelectDialog() {
        StringListSelectDialog.newInstance(new String[]{this.MAIL_DOMAIN_NAME, MAIL_DOMAIN_CHINA}).show(getSupportFragmentManager(), DIALOG_TAG_DOMAIN_SELECT);
    }

    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.clear_printer_name_btn) {
            mHandler.sendEmptyMessage(1);
        } else if (id == R.id.clear_printer_email_address_btn) {
            mHandler.sendEmptyMessage(2);
        } else if (id == R.id.clear_access_key_btn) {
            mHandler.sendEmptyMessage(3);
        } else if (id == R.id.save_button) {
            if (this.printerNameLayout.getVisibility() == 0) {
                printerName = printerNameEdit.getText().toString();
                if (this.printerName.length() <= 0) {
                    Message message = new Message();
                    message.what = 6;
                    message.arg1 = -2;
                    mHandler.sendMessage(message);
                    return;
                } else if (this.printerName.length() > 63) {
                    Message message2 = new Message();
                    message2.what = 6;
                    message2.arg1 = -3;
                    mHandler.sendMessage(message2);
                    return;
                }
            }
            printerEmailAddress = printerEmailAddressEdit.getText().toString();
            if (this.printerEmailAddress.length() <= 0) {
                Message message3 = new Message();
                message3.what = 6;
                message3.arg1 = -4;
                mHandler.sendMessage(message3);
            } else if (this.printerEmailAddress.length() > 180) {
                Message message4 = new Message();
                message4.what = 6;
                message4.arg1 = -1203;
                mHandler.sendMessage(message4);
            } else if (this.oldPrinterEmailAddress.equals(this.printerEmailAddress) || isEnableRegistPrinter(this.printerEmailAddress)) {
                printerAccessKey = accessKeyEdit.getText().toString();
                if (((this.accessKeyLayout.getVisibility() != 0 || printerAccessKey.length() >= 6) && printerAccessKey.length() <= 32) || printerAccessKey.length() == 0) {
                    mHandler.sendEmptyMessage(5);
                    return;
                }
                Message message5 = new Message();
                message5.what = 6;
                message5.arg1 = -1203;
                mHandler.sendMessage(message5);
            } else {
                Message message6 = new Message();
                message6.what = 6;
                message6.arg1 = -5;
                mHandler.sendMessage(message6);
            }
        } else if (id == R.id.rlPrinterSettings) {
            Intent intent = new Intent(this, PrinterFinder.class);
            Bundle bundle2 = new Bundle();
            bundle2.putString(Constants.PRINTER_NAME, "");
            intent.putExtras(bundle2);
            startActivityForResult(intent, 0);
        }
    }

    private void onDone() {
        if (this.printerNameLayout.getVisibility() == 0) {
            printerName = printerNameEdit.getText().toString();
            if (this.printerName.length() <= 0) {
                Message message = new Message();
                message.what = 6;
                message.arg1 = -2;
                mHandler.sendMessage(message);
                return;
            } else if (this.printerName.length() > 63) {
                Message message2 = new Message();
                message2.what = 6;
                message2.arg1 = -3;
                mHandler.sendMessage(message2);
                return;
            }
        }
        printerEmailAddress = printerEmailAddressEdit.getText().toString();
        if (this.printerEmailAddress.length() <= 0) {
            Message message3 = new Message();
            message3.what = 6;
            message3.arg1 = -4;
            mHandler.sendMessage(message3);
        } else if (this.printerEmailAddress.length() > 180) {
            Message message4 = new Message();
            message4.what = 6;
            message4.arg1 = -1203;
            mHandler.sendMessage(message4);
        } else if (this.oldPrinterEmailAddress.equals(this.printerEmailAddress) || isEnableRegistPrinter(this.printerEmailAddress)) {
            printerAccessKey = accessKeyEdit.getText().toString();
            if (((this.accessKeyLayout.getVisibility() != 0 || printerAccessKey.length() >= 6) && printerAccessKey.length() <= 32) || printerAccessKey.length() == 0) {
                mHandler.sendEmptyMessage(5);
                return;
            }
            Message message5 = new Message();
            message5.what = 6;
            message5.arg1 = -1203;
            mHandler.sendMessage(message5);
        } else {
            Message message6 = new Message();
            message6.what = 6;
            message6.arg1 = -5;
            mHandler.sendMessage(message6);
        }
    }

    public void onBackPressed() {
        setResult(18);
        finish();
    }

    public void showErrorMessage(int i) {
        String str;
        String str2;
        if (i == -1100) {
            str = getString(R.string.EC_ERR_COMM_ERROR_TITLE);
            str2 = getString(R.string.EC_ERR_COMM_ERROR);
        } else if (i != 2) {
            switch (i) {
                case EccErrorInfo.ECC_ERR_SVR_HTTP_NOT_FOUND:
                case EccErrorInfo.ECC_ERR_SVR_BUSY:
                    String string = getString(R.string.ECC_ERR_SVR_BUSY_TITLE);
                    str2 = getString(R.string.ECC_ERR_SVR_BUSY) + "0X" + Integer.toHexString(i).toUpperCase() + getString(R.string.ECC_ERR_SVR_BUSY2);
                    str = string;
                    break;
                default:
                    switch (i) {
                        case -1203:
                            str = getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY_TITLE);
                            str2 = getString(R.string.ECC_ERR_SVR_INVALID_ACCESSKEY);
                            break;
                        case -1202:
                            str = getString(R.string.ECC_ERR_SVR_REMOTE_INVALID_TITLE);
                            str2 = getString(R.string.ECC_ERR_SVR_REMOTE_INVALID);
                            break;
                        case -1201:
                            str = getString(R.string.ECC_ERR_SVR_NOT_REGISTERED_TITLE);
                            str2 = getString(R.string.ECC_ERR_SVR_NOT_REGISTERED);
                            break;
                        default:
                            switch (i) {
                                case -5:
                                    str = "";
                                    str2 = getString(R.string.epsonconnect_str_remote_print_email_address_already_registered);
                                    break;
                                case -4:
                                    str = "";
                                    str2 = getString(R.string.epsonconnect_str_remote_print_email_address_warning);
                                    break;
                                case -3:
                                    str = "";
                                    str2 = getString(R.string.epsonconnect_str_printer_name_error_over_max_length);
                                    break;
                                case -2:
                                    str = "";
                                    str2 = getString(R.string.epsonconnect_str_printer_name_error_empty);
                                    break;
                                case -1:
                                    str = getString(R.string.epsonconnect_str_error_get_info_from_printer_title);
                                    str2 = getString(R.string.epsonconnect_str_error_get_info_from_printer);
                                    break;
                                default:
                                    str = getString(R.string.ECC_ERR_SVR_GENERAL_TITLE);
                                    str2 = getString(R.string.ECC_ERR_SVR_GENERAL4);
                                    break;
                            }
                    }
            }
        } else {
            str = "";
            str2 = getString(R.string.epsonconnect_str_not_supported_remote_print);
        }
        if (str.length() > 0) {
            new CustomTitleAlertDialogBuilder(this.context).setCancelable(false).setTitle(str).setMessage(str2).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            }).show();
        } else {
            new AlertDialog.Builder(this.context).setCancelable(false).setMessage(str2).setPositiveButton(getString(R.string.str_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            }).show();
        }
    }

    private boolean isEnableRegistPrinter(String str) {
        return new EPPrinterManager(this).loadRemotePrinterInfo(str) == null;
    }

    public void savePrinterInfo(EpsonConnectAccess.RemotePrinterInfo remotePrinterInfo) {
        EPPrinterManager ePPrinterManager = new EPPrinterManager(this);
        EPPrinterInfo loadRemotePrinterInfo = ePPrinterManager.loadRemotePrinterInfo(this.printerEmailAddress);
        if (loadRemotePrinterInfo == null) {
            loadRemotePrinterInfo = new EPPrinterInfo();
        }
        if (this.printerName.length() <= 0) {
            printerName = remotePrinterInfo.mPrinterName;
            if (this.printerName == null) {
                printerName = "";
            }
        }
        loadRemotePrinterInfo.printerName = remotePrinterInfo.mDeviceId;
        loadRemotePrinterInfo.printerID = "";
        loadRemotePrinterInfo.printerIP = "";
        loadRemotePrinterInfo.printerSerialNo = remotePrinterInfo.mSerialNumber;
        loadRemotePrinterInfo.printerLocation = 2;
        loadRemotePrinterInfo.printerEmailAddress = printerEmailAddress;
        loadRemotePrinterInfo.printerAccessKey = printerAccessKey;
        loadRemotePrinterInfo.userDefName = printerName;
        ePPrinterManager.saveRemotePrinterInfo(loadRemotePrinterInfo);
        mMyPrinter = new MyPrinter(remotePrinterInfo.mDeviceId, "", "", remotePrinterInfo.mSerialNumber, printerEmailAddress);
    }

    public boolean deletePrinterInfo(String str) {
        return new EPPrinterManager(this).deleteRemotePrinterInfo(str);
    }

    public void onItemSelected(@NonNull String str) {
        mLocalTextWatcher.skipNextInputConversion();
        replaceMailDomainEditText(deleteFirstAtMark(str));
    }

    private String getDefaultMailDomain() {
        return guessIfMainlandChina() ? MAIL_DOMAIN_CHINA : MAIL_DOMAIN_NAME;
    }

    private boolean guessIfMainlandChina() {
        return "Hans".equals(Locale.getDefault().getScript());
    }

    private void replaceMailDomainEditText(@NonNull String str) {
        String replaceMailDomain = replaceMailDomain(str, printerEmailAddressEdit.getText().toString());
        printerEmailAddressEdit.setText(replaceMailDomain);
        printerEmailAddress = replaceMailDomain;
    }

    @VisibleForTesting
    static String replaceMailDomain(@NonNull String str, @NonNull String str2) {
        Matcher matcher = Pattern.compile("@(.*)$").matcher(str2);
        if (!matcher.find()) {
            return str2 + "@" + str;
        }
        return matcher.replaceFirst("") + "@" + str;
    }

    @VisibleForTesting
    static String deleteFirstAtMark(@NonNull String str) {
        return Pattern.compile("^@?").matcher(str).replaceFirst("");
    }

    private class setRemotePrintTask extends AsyncTask<Void, Void, Boolean> {
        WorkingDialog progress;

        private setRemotePrintTask() {
            progress = null;
        }

        protected void onPreExecute() {
            progress = new WorkingDialog(ActivityPrinterSetting.this.context);
            progress.show();
        }

        protected Boolean doInBackground(Void... voidArr) {
            WiFiDirectManager.setPriorityToSimpleAP(ActivityPrinterSetting.this, false);
            ActivityPrinterSetting activityPrinterSetting = ActivityPrinterSetting.this;
            int registRemotePrinter = EpsonConnectAccess.registRemotePrinter(activityPrinterSetting, activityPrinterSetting.printerEmailAddress, ActivityPrinterSetting.this.printerAccessKey);
            if (registRemotePrinter == -1203) {
                Message message = new Message();
                if (ActivityPrinterSetting.this.accessKeyLayout.getVisibility() != 0) {
                    Message message2 = new Message();
                    message2.what = 4;
                    message2.arg1 = 0;
                    ActivityPrinterSetting.this.mHandler.sendMessage(message2);
                } else {
                    message.what = 6;
                    message.arg1 = registRemotePrinter;
                    ActivityPrinterSetting.this.mHandler.sendMessage(message);
                }
                return false;
            } else if (registRemotePrinter != 0) {
                Message message3 = new Message();
                message3.what = 6;
                message3.arg1 = registRemotePrinter;
                ActivityPrinterSetting.this.mHandler.sendMessage(message3);
                return false;
            } else {
                ActivityPrinterSetting activityPrinterSetting2 = ActivityPrinterSetting.this;
                EpsonConnectAccess.RemotePrinterInfo printerInfo = EpsonConnectAccess.getPrinterInfo(activityPrinterSetting2, activityPrinterSetting2.printerEmailAddress, ActivityPrinterSetting.this.printerAccessKey);
                if (printerInfo != null) {
                    if (!ActivityPrinterSetting.this.oldPrinterEmailAddress.equals("") && !ActivityPrinterSetting.this.oldPrinterEmailAddress.equals(ActivityPrinterSetting.this.printerEmailAddress)) {
                        ActivityPrinterSetting activityPrinterSetting3 = ActivityPrinterSetting.this;
                        activityPrinterSetting3.deletePrinterInfo(activityPrinterSetting3.oldPrinterEmailAddress);
                    }
                    ActivityPrinterSetting.this.savePrinterInfo(printerInfo);
                }
                return true;
            }
        }

        protected void onPostExecute(Boolean bool) {
            if (this.progress.isShowing()) {
                progress.dismiss();
            }
            if (bool.booleanValue()) {
                ActivityPrinterSetting.this.mHandler.sendEmptyMessage(7);
            }
        }
    }

    protected void onResume() {
        super.onResume();
        EPLog.e("ActiviyPrinterSettings", "onResume()");
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.C2138menu.menu_done, menu);
        return super.onCreateOptionsMenu(menu);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != R.id.menuSettingsDone) {
            return super.onOptionsItemSelected(menuItem);
        }
        onDone();
        return true;
    }

    private class LocalTextWatcher implements TextWatcher {
        private final int INPUT_STATUS_IGNORE;
        private final int INPUT_STATUS_NORMAL;
        private final int INPUT_STATUS_SKIP;
        private int inputStatus;

        public void afterTextChanged(Editable editable) {
        }

        private LocalTextWatcher() {
            INPUT_STATUS_NORMAL = 0;
            INPUT_STATUS_SKIP = 1;
            INPUT_STATUS_IGNORE = 2;
            inputStatus = 0;
        }

        private void skipNextInputConversion() {
            inputStatus = 1;
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            String charSequence2 = charSequence.toString();
            if (this.inputStatus == 0 && charSequence2.contains("@")) {
                inputStatus = 2;
            }
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            String charSequence2 = charSequence.toString();
            if (this.inputStatus == 1) {
                inputStatus = 0;
            } else if (i >= charSequence2.length() || charSequence2.charAt(i) != '@') {
                inputStatus = 0;
            } else {
                int i4 = inputStatus;
                if (i4 == 2) {
                    inputStatus = 1;
                    ActivityPrinterSetting activityPrinterSetting = ActivityPrinterSetting.this;
                    String unused = activityPrinterSetting.printerEmailAddress = charSequence2.substring(0, i) + charSequence2.substring(i + 1);
                    ActivityPrinterSetting.this.printerEmailAddressEdit.setText(ActivityPrinterSetting.this.printerEmailAddress);
                    ActivityPrinterSetting.this.printerEmailAddressEdit.setSelection(i);
                } else if (i4 == 0) {
                    inputStatus = 1;
                    ActivityPrinterSetting activityPrinterSetting2 = ActivityPrinterSetting.this;
                    String unused2 = activityPrinterSetting2.printerEmailAddress = charSequence2.substring(0, i + 1) + ActivityPrinterSetting.this.getDefaultMailDomain();
                    ActivityPrinterSetting.this.printerEmailAddressEdit.setText(ActivityPrinterSetting.this.printerEmailAddress);
                    ActivityPrinterSetting.this.showMailDomainSelectDialog();
                } else {
                    inputStatus = 0;
                }
            }
        }
    }
}
