Example usage for org.apache.cordova.api CallbackContext error

List of usage examples for org.apache.cordova.api CallbackContext error

Introduction

In this page you can find the example usage for org.apache.cordova.api CallbackContext error.

Prototype

public void error(int message) 

Source Link

Document

Helper for error callbacks that just returns the Status.ERROR by default

Usage

From source file:br.edu.ufcg.supervisor.SupervisorInterface.java

License:Open Source License

/**
 * Executes the model with some data and extracts recommendations.
 * @param args Passed from Javascript interface.
 * @param callbackContext Used to return the result of processing.
 * @throws JSONException//from   w ww.  ja v  a  2s .c  o m
 */
private void executeModel(JSONArray args, CallbackContext callbackContext) throws JSONException {
    JSONObject r = new JSONObject();
    String name = args.get(0).toString();
    Float value = Float.valueOf((String) args.get(1));
    map.put(name, value);
    map2.put(Integer.valueOf((String) args.get(2)), value);
    String recommendation = "";
    String currentState = "";
    try {
        Simulation.executeModel(r, model, map, map2, currentState, recommendation, logString);
    } catch (Exception e) {
        recommendation = "Value not monitored.";
        logString = logString + "(" + recommendation + ")\n";
        r.put("error", recommendation);
        r.put("rec", "Stop and verify your devices. If this appears again, call your healthcare professional.");
        callbackContext.error(r);
    }
    callbackContext.success(r);
}

From source file:br.edu.ufcg.supervisor.SupervisorInterface.java

License:Open Source License

/**
 * Starts the process of executing the chosen model.
 * @param callbackContext Used to return the result of processing.
 * @throws JSONException// w ww.ja va  2  s .co m
 */
private void start(CallbackContext callbackContext) throws JSONException {
    JSONObject r = new JSONObject();
    if (model == null) {
        r.put("msg", "At first, you have to load a training.");
        callbackContext.error(r);
    } else {
        model.setNome(model.getNome());
        LoadedModel.setModel(model);
        int[] arrayIds = LoadedModel.getIdVariaveisMonitoradas();
        ArrayList<String> arrayNames = LoadedModel.getNomesVariaveisMonitoradas();
        String ids = "";
        String names = "";
        map.clear();//zera o map para limpar modelos carregados anteriormente.
        map2.clear();
        logString = "";
        for (int i = 0; i < arrayNames.size(); i++) {
            ids = ids + "," + arrayIds[i];
            names = names + "," + arrayNames.get(i);
            map.put(arrayNames.get(i), 0.f);
            //map2.put(Integer.valueOf(arrayIds[i]), 0.f);
        }
        r.put("ids", ids.replaceFirst(",", ""));
        r.put("names", names.replaceFirst(",", ""));
        r.put("msg", model.getNome());
        callbackContext.success(r);
    }
}

From source file:br.edu.ufcg.supervisor.SupervisorInterface.java

License:Open Source License

/**
 * Loads model from a given name of a file. If it does not exist, loads a pre-defined simple one.
 * @param args Passed from Javascript interface.
 * @param callbackContext Used to return the result of processing.
 * @throws JSONException/*ww w .  j  a  va  2 s  . c  o  m*/
 */
private void loadModelFromFile(JSONArray args, CallbackContext callbackContext) throws JSONException {
    JSONObject r = new JSONObject();
    String fileName = args.get(0).toString() + ".sup";
    pathToFile = Environment.getExternalStorageDirectory().toString() + "/Download/" + fileName;
    File file = new File(pathToFile);
    if (!file.exists()) {
        model = null;
        //model = TrainingLoader.getDefaultModel();
        r.put("msg", "File not found.");
        callbackContext.error(r);
    } else {
        String automatoJson = "";
        try {
            automatoJson = TrainingLoader.readFile(pathToFile);
        } catch (IOException e) {
            r.put("msg", "erro ao ler arquivo1.");
            callbackContext.error(r);
        }
        model = new Automaton(automatoJson);
        r.put("msg", "File found. Model loaded.");
        callbackContext.success(r);
    }
}

From source file:com.baroq.pico.google.PlayServices.java

@Override
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {

    try {/*from ww  w  . j a va2 s . c  om*/
        if (!ACTION_SETUP.equals(action) && !ACTION_SIGNIN.equals(action)
                && (null == mHelper || !mHelper.isConnected())) {
            callbackContext.error("Please setup and signin to use PlayServices plugin");
            return false;
        }
        if (ACTION_SETUP.equals(action)) {
            int l = data.length();
            if (0 == l) {
                callbackContext.error("Expecting at least 1 parameter for action: " + action);
                return false;
            }
            clientTypes = data.getInt(0);
            String[] extraScopes = new String[l - 1];
            for (int i = 1; i < l; i++) {
                extraScopes[i - 1] = data.getString(i);
            }
            setup(clientTypes, extraScopes, callbackContext);
            PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
            pluginResult.setKeepCallback(true);
            callbackContext.sendPluginResult(pluginResult);
        } else if (ACTION_SIGNIN.equals(action)) {
            mHelper.beginUserInitiatedSignIn();
            callbackContext.success();
        } else if (ACTION_SIGNOUT.equals(action)) {
            signout();
            callbackContext.success();
        } else if (ACTION_AS_MAX_KEYS.equals(action)) {
            PluginResult pluginResult = new PluginResult(PluginResult.Status.OK,
                    mHelper.getAppStateClient().getMaxNumKeys());
            pluginResult.setKeepCallback(false);
            callbackContext.sendPluginResult(pluginResult);
        } else if (ACTION_AS_MAX_SIZE.equals(action)) {
            PluginResult pluginResult = new PluginResult(PluginResult.Status.OK,
                    mHelper.getAppStateClient().getMaxStateSize());
            pluginResult.setKeepCallback(false);
            callbackContext.sendPluginResult(pluginResult);
        } else if (ACTION_AS_DEL.equals(action)) {
            int key = data.getInt(0);
            mHelper.getAppStateClient().deleteState(this, key);
            callbackContext.success();
        } else if (ACTION_AS_LIST.equals(action)) {
            mHelper.getAppStateClient().listStates(this);
            callbackContext.success();
        } else if (ACTION_AS_LOAD.equals(action)) {
            int key = data.getInt(0);
            mHelper.getAppStateClient().loadState(this, key);
            callbackContext.success();
        } else if (ACTION_AS_RESOLVE.equals(action)) {
            int key = data.getInt(0);
            String resolvedVersion = data.getString(1);
            String value = data.getString(2);
            mHelper.getAppStateClient().resolveState(this, key, resolvedVersion, value.getBytes());
            callbackContext.success();
        } else if (ACTION_AS_UPDATE.equals(action)) {
            int key = data.getInt(0);
            String value = data.getString(1);
            mHelper.getAppStateClient().updateState(key, value.getBytes());
            callbackContext.success();
        } else if (ACTION_AS_UPDATE_NOW.equals(action)) {
            int key = data.getInt(0);
            String value = data.getString(1);
            mHelper.getAppStateClient().updateStateImmediate(this, key, value.getBytes());
            callbackContext.success();
        } else if (ACTION_GAME_SHOW_ACHIEVEMENTS.equals(action)) {
            cordova.startActivityForResult((CordovaPlugin) this,
                    mHelper.getGamesClient().getAchievementsIntent(), RC_UNUSED);
            callbackContext.success();
        } else if (ACTION_GAME_SHOW_LEADERBOARDS.equals(action)) {
            cordova.startActivityForResult((CordovaPlugin) this,
                    mHelper.getGamesClient().getAllLeaderboardsIntent(), RC_UNUSED);
            callbackContext.success();
        } else if (ACTION_GAME_SHOW_LEADERBOARD.equals(action)) {
            String id = data.getString(0);
            cordova.startActivityForResult((CordovaPlugin) this,
                    mHelper.getGamesClient().getLeaderboardIntent(id), RC_UNUSED);
            callbackContext.success();
        } else if (ACTION_GAME_INCR_ACHIEVEMENT.equals(action)) {
            String id = data.getString(0);
            int numSteps = data.getInt(1);
            mHelper.getGamesClient().incrementAchievement(id, numSteps);
            callbackContext.success();
        } else if (ACTION_GAME_INCR_ACHIEVEMENT_NOW.equals(action)) {
            String id = data.getString(0);
            int numSteps = data.getInt(1);
            mHelper.getGamesClient().incrementAchievementImmediate(this, id, numSteps);
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_ACHIEVEMENTS.equals(action)) {
            boolean forceReload = data.getBoolean(0);
            mHelper.getGamesClient().loadAchievements(this, forceReload);
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_GAME.equals(action)) {
            mHelper.getGamesClient().loadGame(this);
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_LEADERBOARD_METADATA.equals(action)) {
            if (1 == data.length()) {
                mHelper.getGamesClient().loadLeaderboardMetadata(this, data.getBoolean(0));
            } else {
                mHelper.getGamesClient().loadLeaderboardMetadata(this, data.getString(0), data.getBoolean(1));
            }
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_MORE_SCORES.equals(action)) {
            if (null == scoreBuffer) {
                callbackContext.error("Get a leaderboard fist before calling: " + action);
                return false;
            }
            int maxResults = data.getInt(0);
            int pageDirection = data.getInt(0);
            mHelper.getGamesClient().loadMoreScores(this, scoreBuffer, maxResults, pageDirection);
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_PLAYER.equals(action)) {
            String playerId = data.getString(0);
            mHelper.getGamesClient().loadPlayer(this, playerId);
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_PLAYER_CENTERED_SCORES.equals(action)) {
            String leaderboardId = data.getString(0);
            int span = data.getInt(1);
            int leaderboardCollection = data.getInt(2);
            int maxResults = data.getInt(3);
            if (data.isNull(4)) {
                mHelper.getGamesClient().loadPlayerCenteredScores(this, leaderboardId, span,
                        leaderboardCollection, maxResults);
            } else {
                boolean forceReload = data.getBoolean(4);
                mHelper.getGamesClient().loadPlayerCenteredScores(this, leaderboardId, span,
                        leaderboardCollection, maxResults, forceReload);
            }
            callbackContext.success();
        } else if (ACTION_GAME_LOAD_TOP_SCORES.equals(action)) {
            String leaderboardId = data.getString(0);
            int span = data.getInt(1);
            int leaderboardCollection = data.getInt(2);
            int maxResults = data.getInt(3);
            if (data.isNull(4)) {
                mHelper.getGamesClient().loadTopScores(this, leaderboardId, span, leaderboardCollection,
                        maxResults);
            } else {
                boolean forceReload = data.getBoolean(4);
                mHelper.getGamesClient().loadTopScores(this, leaderboardId, span, leaderboardCollection,
                        maxResults, forceReload);
            }
            callbackContext.success();
        } else if (ACTION_GAME_REVEAL_ACHIEVEMENT.equals(action)) {
            String id = data.getString(0);
            mHelper.getGamesClient().revealAchievement(id);
            callbackContext.success();
        } else if (ACTION_GAME_REVEAL_ACHIEVEMENT_NOW.equals(action)) {
            String id = data.getString(0);
            mHelper.getGamesClient().revealAchievementImmediate(this, id);
            callbackContext.success();
        } else if (ACTION_GAME_SUBMIT_SCORE.equals(action)) {
            String leaderboardId = data.getString(0);
            int score = data.getInt(1);
            mHelper.getGamesClient().submitScore(leaderboardId, score);
            callbackContext.success();
        } else if (ACTION_GAME_SUBMIT_SCORE_NOW.equals(action)) {
            String leaderboardId = data.getString(0);
            int score = data.getInt(1);
            mHelper.getGamesClient().submitScoreImmediate(this, leaderboardId, score);
            callbackContext.success();
        } else if (ACTION_GAME_UNLOCK_ACHIEVEMENT.equals(action)) {
            String id = data.getString(0);
            mHelper.getGamesClient().unlockAchievement(id);
            callbackContext.success();
        } else if (ACTION_GAME_UNLOCK_ACHIEVEMENT_NOW.equals(action)) {
            String id = data.getString(0);
            mHelper.getGamesClient().unlockAchievementImmediate(this, id);
            callbackContext.success();
        } else {
            callbackContext.error("Unknown action: " + action);
            return false;
        }
    } catch (JSONException ex) {
        callbackContext.error(ex.getMessage());
        return false;
    }

    return true;
}

From source file:com.cbtec.eliademy.BillingPlugin.java

License:Open Source License

private void getPurchasedItems(CallbackContext callbackContext) {
    try {//from  w ww  .j  a v  a 2  s .c om
        JSONArray products = new JSONArray();

        Bundle ownedItems = Eliademy.sBillingService.getPurchases(3, Eliademy.sInstance.getPackageName(),
                "inapp", null);

        if (ownedItems.getInt("RESPONSE_CODE") == 0) {
            final ArrayList<String> items = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

            for (int i = 0; i < items.size(); i++) {
                products.put(items.get(i));
            }
        }

        callbackContext.success(products);
    } catch (RemoteException e) {
        callbackContext.error(e.getMessage());
    }
}

From source file:com.cbtec.eliademy.EliademyLms.java

License:Open Source License

/**
 * Executes the request./* w  w  w  . j  a  v  a2 s .c om*/
 * 
 * This method is called from the WebView thread. To do a non-trivial amount
 * of work, use: cordova.getThreadPool().execute(runnable);
 * 
 * To run on the UI thread, use:
 * cordova.getActivity().runOnUiThread(runnable);
 * 
 * @param action
 *            The action to execute.
 * @param rawArgs
 *            The exec() arguments in JSON form.
 * @param callbackContext
 *            The callback context used when calling back into JavaScript.
 * @return Whether the action was valid.
 * @throws JSONException
 */
@Override
public boolean execute(String action, JSONArray data, final CallbackContext callbackContext)
        throws JSONException {

    // Log.i("HLMS", action);

    if ((action.compareTo("openfilesrv") == 0)) {
        try {
            Uri fileuri = Uri.parse(data.getString(0));
            Intent intent = new Intent(Intent.ACTION_VIEW);
            String mimeextn = android.webkit.MimeTypeMap.getFileExtensionFromUrl(data.getString(0));
            if (mimeextn.isEmpty()) {
                mimeextn = data.getString(0).substring(data.getString(0).indexOf(".") + 1);
                ;
            }
            String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(mimeextn);
            // Log.i("HLMS", fileuri + "  " + mimetype);
            intent.setDataAndType(fileuri, mimetype);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            cordova.getActivity().getApplicationContext().startActivity(intent);
            callbackContext.success();
        } catch (Exception e) {
            // Log.e("HLMS", "exception", e);
            callbackContext.error(0);
        }
        return true;
    } else if ((action.compareTo("getfilesrv") == 0)) {
        this.mCallbackContext = callbackContext;
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                try {
                    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                    intent.setType("*/*");// TODO: Restrict file types
                    cordova.startActivityForResult(EliademyLms.this, intent, submitFileCode);
                } catch (Exception e) {
                    // Log.e("HLMS", "exception", e);
                    callbackContext.error(0);
                }
                return;
            }
        });
    } else if ((action.compareTo("initservice") == 0)) {
        if (!mIsBound) {
            this.mCallbackContext = callbackContext;
            JSONObject tmp = new JSONObject(data.getString(0));
            String sname = tmp.getString("servicename");
            if (sname.contains("eliademy")) {
                mServiceName = "com.cbtec.serviceeliademy";
            } else {
                // From url determine version 2.2, 2.3, 2.4 and change
                mServiceName = "com.cbtec.service" + sname;
            }
            // Log.i("HLMS", "Connecting to service: " + mServiceName);
            doBindService();
        } else {
            callbackContext.success();
        }
        return true;
    } else {
        final String aAction = action;
        final JSONArray aData = data;
        String mappedCmd = null;
        try {
            mappedCmd = mapExecCommand(aData.getString(0));
        } catch (JSONException e) {
            // Log.e("HLMS", "exception", e);
        }
        if (mappedCmd == null) {
            // Log.i("HLMS", "LMS service call failed " + mappedCmd);
            callbackContext.error(0);// TODO : error enum
            return false;
        }

        final String execCmd = mappedCmd;
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            @SuppressLint("NewApi")
            public void run() {
                // Log.i("HLMS","Runner execute " + aAction + aData.toString());
                if (aAction.compareTo("lmsservice") == 0) {
                    try {
                        String retval = null;
                        // Log.i("HLMS", "Execute cmd: " + execCmd);
                        if (execCmd.compareTo("initialize") == 0) {
                            if (mIBinder.initializeService(aData.getString(1))) {
                                String token = mIBinder.eliademyGetWebServiceToken();
                                callbackContext.success(token);
                                return;
                            }
                        } else if (execCmd.compareTo("deinitialize") == 0) {
                            if (mIBinder.deInitializeService(aData.getString(1))) {
                                doUnbindService();
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("pushregister") == 0) {
                            // Log.i("pushdata", aData.getString(1));
                            if (mIBinder.registerPushNotifications(aData.getString(1))) {
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("pushunregister") == 0) {
                            // Log.i("pushdata", aData.getString(1));
                            if (mIBinder.unregisterPushNotifications(aData.getString(1))) {
                                callbackContext.success();
                                return;
                            }
                        } else if (execCmd.compareTo("servicetoken") == 0) {
                            retval = mIBinder.eliademyGetWebServiceToken();
                        } else if (execCmd.compareTo("siteinfo") == 0) {
                            retval = mIBinder.eliademyGetSiteInformation(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_courses") == 0) {
                            retval = mIBinder.eliademyGetUsersCourses(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_forums") == 0) {
                            retval = mIBinder.eliademyGetUserForums(aData.getString(1));
                        } else if (execCmd.compareTo("get_user_info") == 0) {
                            retval = mIBinder.eliademyGetUserInformation(aData.getString(1));
                        } else if (execCmd.compareTo("exec_webservice") == 0) {
                            // Log.i("HLMS", "Execute webservice");
                            retval = mIBinder.eliademyExecWebService(aData.getString(0), aData.getString(1));
                        } else if (execCmd.compareTo("course_get_contents") == 0) {
                            retval = mIBinder.eliademyGetCourseContents(aData.getString(1));
                        } else if (execCmd.compareTo("course_get_enrolled_users") == 0) {
                            retval = mIBinder.eliademyGetEnrolledUsers(aData.getString(1));
                        } else {
                            // Log.i("HLMS", "LMS service failed " + execCmd);
                            callbackContext.error(0);// TODO : error enum
                        }
                        if (!retval.isEmpty()) {
                            // Log.i("HLMS", "LMS service call success");
                            callbackContext.success(retval);
                        } else {
                            // Log.i("HLMS", "LMS service call failed");
                            callbackContext.error(0);// TODO : error enum
                        }
                    } catch (Exception e) {
                        // Log.e("HLMS", "exception", e);
                        callbackContext.error(e.getMessage());
                        return;
                    }
                } else {
                    // Log.i("LMS", "Unsupported action call !!");
                    callbackContext.error(0);
                    return;
                }
            }
        });
    }
    return true;
}

From source file:com.clearbon.cordova.netswipe.NetSwipePlugin.java

License:Apache License

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;
    PluginResult result = null;/*from   ww w .ja v  a2s . c o  m*/

    if (action.equals(Init)) {
        init(args);
        result = new PluginResult(Status.NO_RESULT);
        result.setKeepCallback(false);
        return true;
    } else if (action.equals(ScanCard)) {
        scanCard(args);
        result = new PluginResult(Status.NO_RESULT);
        result.setKeepCallback(true);
        return true;
    } else {
        result = new PluginResult(Status.INVALID_ACTION);
        callbackContext.error("Invalid Action");
        return false;
    }
}

From source file:com.cloudstudio.BarcodeScanner.java

License:BSD License

/**
 * Executes the request./*ww  w  . j a v a2 s.c om*/
 *
 * This method is called from the WebView thread. To do a non-trivial amount of work, use:
 *     cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 *     cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action          The action to execute.
 * @param args            The exec() arguments.
 * @param callbackContext The callback context used when calling back into JavaScript.
 * @return                Whether the action was valid.
 *
 * @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;

    if (action.equals(ENCODE)) {
        JSONObject obj = args.optJSONObject(0);
        if (obj != null) {
            String type = obj.optString(TYPE);
            String data = obj.optString(DATA);

            // If the type is null then force the type to text
            if (type == null) {
                type = TEXT_TYPE;
            }

            if (data == null) {
                callbackContext.error("User did not specify data to encode");
                return true;
            }

            encode(type, data);
        } else {
            callbackContext.error("User did not specify data to encode");
            return true;
        }
    } else if (action.equals(SCAN)) {
        scan();
    } else {
        return false;
    }
    return true;
}

From source file:com.cloudstudio.camera.ForegroundCameraLauncher.java

License:Apache License

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    // TODO Auto-generated method stub
    this.callbackContext = callbackContext;
    PluginResult.Status status = PluginResult.Status.OK;
    String result = "";
    try {/*from  www .  jav a  2s .c o m*/
        if (action.equals("takePicture")) {
            this.targetHeight = 0;
            this.targetWidth = 0;
            this.mQuality = 80;

            JSONObject options = args.optJSONObject(0);
            if (options != null) {
                this.targetHeight = options.getInt("targetHeight");
                this.targetWidth = options.getInt("targetWidth");
                this.mQuality = options.getInt("quality");
            }

            this.takePicture();

            PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
            r.setKeepCallback(true);
            return true;
        }
        return false;
    } catch (JSONException e) {
        e.printStackTrace();
        callbackContext.error("JSON_EXCEPTION");
        return false;
    }
}

From source file:com.example.qrcode.BarcodeScanner.java

License:BSD License

/**
 * Executes the request.//w  ww  . j  a va 2  s .  c om
 *
 * This method is called from the WebView thread. To do a non-trivial amount of work, use:
 *     cordova.getThreadPool().execute(runnable);
 *
 * To run on the UI thread, use:
 *     cordova.getActivity().runOnUiThread(runnable);
 *
 * @param action          The action to execute.
 * @param args            The exec() arguments.
 * @param callbackContext The callback context used when calling back into JavaScript.
 * @return                Whether the action was valid.
 *
 * @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
 */
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;

    if (action.equals(ENCODE)) {
        JSONObject obj = args.optJSONObject(0);
        if (obj != null) {
            String type = obj.optString(TYPE);
            String data = obj.optString(DATA);

            // If the type is null then force the type to text
            if (type == null) {
                type = TEXT_TYPE;
            }

            if (data == null) {
                callbackContext.error("User did not specify data to encode");
                return true;
            }

            encode(type, data);
        } else {
            callbackContext.error("User did not specify data to encode");
            return true;
        }
    } else if (action.equals(SCAN)) {
        scan(args);
    } else {
        return false;
    }
    return true;
}