Search in sources :

Example 1 with InventoryTask

use of org.flyve.inventory.InventoryTask in project android-mdm-agent by flyve-mdm.

the class PoliciesController method createInventory.

/**
 * Create Device Inventory
 * Example {"query": "inventory"}
 */
public void createInventory() {
    InventoryTask inventoryTask = new InventoryTask(this.context, "FlyveMDM-Agent_v1.0");
    inventoryTask.getXML(new InventoryTask.OnTaskCompleted() {

        @Override
        public void onTaskSuccess(String data) {
            FlyveLog.xml(data);
            // send inventory to MQTT
            sendInventory(data);
            broadcastReceivedLog(Helpers.broadCastMessage(MQTT_SEND, "Inventory", "Inventory Send"));
        }

        @Override
        public void onTaskError(Throwable error) {
            FlyveLog.e(error.getMessage());
            // send broadcast
            broadcastReceivedLog(Helpers.broadCastMessage(ERROR, "Error on createInventory", error.getMessage()));
        }
    });
}
Also used : InventoryTask(org.flyve.inventory.InventoryTask)

Example 2 with InventoryTask

use of org.flyve.inventory.InventoryTask in project android-mdm-agent by flyve-mdm.

the class EnrollmentModel method createInventory.

@Override
public void createInventory(Context context) {
    InventoryTask inventoryTask = new InventoryTask(context, "FlyveMDM-Agent");
    inventoryTask.getXML(new InventoryTask.OnTaskCompleted() {

        @Override
        public void onTaskSuccess(String s) {
            // String str = s.replaceAll("<\\?xml version='1.0' encoding='utf-8' standalone='yes' \\?>", "");
            // String str = s.replaceAll("\\n|\\r", "");
            // str = str.replaceAll(" ", "");
            presenter.inventorySuccess(s);
        }

        @Override
        public void onTaskError(Throwable throwable) {
            presenter.showSnackError("Inventory fail");
        }
    });
}
Also used : InventoryTask(org.flyve.inventory.InventoryTask)

Example 3 with InventoryTask

use of org.flyve.inventory.InventoryTask in project android-mdm-agent by flyve-mdm.

the class Inventory method getJSONInventory.

public void getJSONInventory(Context context, InventoryTask.OnTaskCompleted callback) {
    InventoryTask inventoryTask = new InventoryTask(context, APP_VERSION, true);
    MqttData cache = new MqttData(context);
    String invitationToken = cache.getInvitationToken();
    if (!invitationToken.isEmpty()) {
        String tag = "invitation_" + invitationToken;
        FlyveLog.i(tag);
        inventoryTask.setTag(tag);
    }
    inventoryTask.getJSON(callback);
}
Also used : MqttData(org.flyve.mdm.agent.data.database.MqttData) InventoryTask(org.flyve.inventory.InventoryTask)

Example 4 with InventoryTask

use of org.flyve.inventory.InventoryTask in project android-mdm-agent by flyve-mdm.

the class Inventory method getXMLInventory.

public void getXMLInventory(Context context, InventoryTask.OnTaskCompleted callback) {
    InventoryTask inventoryTask = new InventoryTask(context, APP_VERSION, true);
    MqttData cache = new MqttData(context);
    String invitationToken = cache.getInvitationToken();
    if (!invitationToken.isEmpty()) {
        String tag = "invitation_" + invitationToken;
        FlyveLog.i(tag);
        inventoryTask.setTag(tag);
    }
    inventoryTask.getXML(callback);
}
Also used : MqttData(org.flyve.mdm.agent.data.database.MqttData) InventoryTask(org.flyve.inventory.InventoryTask)

Example 5 with InventoryTask

use of org.flyve.inventory.InventoryTask in project android-mdm-agent by flyve-mdm.

the class PermissionModel method showDialogShare.

@Override
public void showDialogShare(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.dialog_share_title);
    final int[] type = new int[1];
    // list of items
    String[] items = context.getResources().getStringArray(R.array.export_list);
    builder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            type[0] = which;
        }
    });
    String positiveText = context.getString(android.R.string.ok);
    builder.setPositiveButton(positiveText, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // positive button logic
            new InventoryTask(context, Inventory.APP_VERSION, false).shareInventory(type[0]);
        }
    });
    String negativeText = context.getString(android.R.string.cancel);
    builder.setNegativeButton(negativeText, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        // negative button logic
        }
    });
    AlertDialog dialog = builder.create();
    // display dialog
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) InventoryTask(org.flyve.inventory.InventoryTask) DialogInterface(android.content.DialogInterface)

Aggregations

InventoryTask (org.flyve.inventory.InventoryTask)5 MqttData (org.flyve.mdm.agent.data.database.MqttData)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1