/**
 * Copyright (c) 2014 Etherios, a Division of Digi International, Inc.
 * All rights not expressly granted are reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Etherios 11001 Bren Road East, Minnetonka, MN 55343
 * =======================================================================
 */
package com.etherios.connector.filesystem;

import com.etherios.connector.emulator.CloudConnector;
import javax.microedition.midlet.MIDlet;

/**
 * Cloud Connector File System sample application.
 * 
 * <p>This example simulates a book reader. Once the connection is established, 
 * the application waits for upload file events. When this event occurs, the 
 * file is processed by the device and, only if it is included in the 
 * application's library list, the contents are printed line by line.</p>
 * 
 * <p>For a complete description on the example, refer to the 'ReadMe.txt' file
 * included in the root directory.</p>
 */
public class MainApp extends MIDlet {

	/* Variables */

	private static CloudConnector connector;

	private static ConnectorEventsListener connectorEventsListener;
	
	@Override
	public void startApp() {
		connector = new CloudConnector();
		connectorEventsListener = new ConnectorEventsListener(connector);
		// Register the event listener.
		connector.registerEventsListener(connectorEventsListener);
		// Start the connection to Device Cloud.
		connector.start();
	}
	
	@Override
	protected void pauseApp() {
		connector.stop();
	}

	@Override
	protected void destroyApp(boolean unconditional) {
		connector.stop();
	}
}
