// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java
// public class PomodroidException extends Exception {
// 
//     /**
//      * Required by the compiler
//      */
//     private static final long serialVersionUID = 1L;
//     /**
//      * A Custom title for an Exception when displayed to User
//      */
//     private String title = null;
// 
// 
//     /**
//      * Default constructor
//      */
//     public PomodroidException(Exception e) {
//         // call superclass constructor
//         super();
//     }
// 
//     /**
//      * Default constructor
//      */
//     public PomodroidException() {
//         // call superclass constructor
//         super();
//     }
// 
//     /**
//      * Constructor for displaying a custom message
//      */
//     public PomodroidException(String message) {
//         // Call super class constructor
//         super(message);
//     }
// 
//     /**
//      * Constructor for displaying a custom message and title
//      */
//     public PomodroidException(String message, String title) {
//         super(message);
//         this.title = title;
//     }
// 
//     /**
//      * @return title
//      */
//     public String getTitle() {
//         return title;
//     }
// 
//     /**
//      * the title to set
//      *
//      * @param title
//      */
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
// 
//     /**
//      * This method shows an exception to user, with a Toast
//      *
//      * @param context
//      */
//     public void alertUser(Context context) {
//         Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show();
//     }
// 
//     /**
//      * This method shows a simply message (information)
//      *
//      * @param context
//      * @param title
//      */
//     public void alertUser(Context context, String title) {
//         Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show();
//     }
// 
//     /**
//      * This method shows a simply message (information)
//      *
//      * @param context
//      * @param title
//      */
//     public static void createAlert(Context context, String title, String message) {
//         Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show();
//     }
// 
// }


import it.unibz.pomodroid.models.*;
import it.unibz.pomodroid.exceptions.PomodroidException;
import java.util.Date;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
package it.unibz.pomodroid;




/**
 * this is the service that is hooked by the main activity - File Scanner this
 * will read the params and do something
 *
 * @author sschauhan
 */

public class PomodoroService extends android.app.Service {

    /**
     * How many seconds are in a minute
     */
    private final static int SECONDS_PER_MINUTE = 60;
    /**
     * How many milliseconds are in a second
     */
    public final static int MILLISECONDS_PER_SECOND = 1000;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_REGISTER_CLIENT = -1;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_POMODORO_TICK = 1;
    /**
     * Sent when Pomodoro finishes
     */
    public final static int MSG_POMODORO_FINISHED = 2;
    /**
     * Sent when Pomodoro starts
     */
    public final static int MSG_POMODORO_START = 3;
    /**
     * Sent when Pomodoro is stopped
     */
    public final static int MSG_POMODORO_STOP = 4;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_UNREGISTER_CLIENT = -2;
    /**
     * Holds remaining time in seconds
     */
    private int pomodoroSecondsValue = -1;

    /**
     * The Database container for db4o
     */
    private DBHelper dbHelper;
    /**
     * The actual User
     */
    private User user;
    /**
     * For communication with the Service
     */
    private Messenger messenger;

    /**
     * @return dbHelper object
     */
    public DBHelper getDbHelper() {
        return dbHelper;
    }

    /**
     * @return user object
     */
    public User getUser() {
        try {
            return User.retrieve(dbHelper);
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java
// public class PomodroidException extends Exception {
// 
//     /**
//      * Required by the compiler
//      */
//     private static final long serialVersionUID = 1L;
//     /**
//      * A Custom title for an Exception when displayed to User
//      */
//     private String title = null;
// 
// 
//     /**
//      * Default constructor
//      */
//     public PomodroidException(Exception e) {
//         // call superclass constructor
//         super();
//     }
// 
//     /**
//      * Default constructor
//      */
//     public PomodroidException() {
//         // call superclass constructor
//         super();
//     }
// 
//     /**
//      * Constructor for displaying a custom message
//      */
//     public PomodroidException(String message) {
//         // Call super class constructor
//         super(message);
//     }
// 
//     /**
//      * Constructor for displaying a custom message and title
//      */
//     public PomodroidException(String message, String title) {
//         super(message);
//         this.title = title;
//     }
// 
//     /**
//      * @return title
//      */
//     public String getTitle() {
//         return title;
//     }
// 
//     /**
//      * the title to set
//      *
//      * @param title
//      */
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
// 
//     /**
//      * This method shows an exception to user, with a Toast
//      *
//      * @param context
//      */
//     public void alertUser(Context context) {
//         Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show();
//     }
// 
//     /**
//      * This method shows a simply message (information)
//      *
//      * @param context
//      * @param title
//      */
//     public void alertUser(Context context, String title) {
//         Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show();
//     }
// 
//     /**
//      * This method shows a simply message (information)
//      *
//      * @param context
//      * @param title
//      */
//     public static void createAlert(Context context, String title, String message) {
//         Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show();
//     }
// 
// }


// Path: src/it/unibz/pomodroid/PomodoroService.java
import it.unibz.pomodroid.models.*;
import it.unibz.pomodroid.exceptions.PomodroidException;
import java.util.Date;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;

package it.unibz.pomodroid;




/**
 * this is the service that is hooked by the main activity - File Scanner this
 * will read the params and do something
 *
 * @author sschauhan
 */

public class PomodoroService extends android.app.Service {

    /**
     * How many seconds are in a minute
     */
    private final static int SECONDS_PER_MINUTE = 60;
    /**
     * How many milliseconds are in a second
     */
    public final static int MILLISECONDS_PER_SECOND = 1000;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_REGISTER_CLIENT = -1;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_POMODORO_TICK = 1;
    /**
     * Sent when Pomodoro finishes
     */
    public final static int MSG_POMODORO_FINISHED = 2;
    /**
     * Sent when Pomodoro starts
     */
    public final static int MSG_POMODORO_START = 3;
    /**
     * Sent when Pomodoro is stopped
     */
    public final static int MSG_POMODORO_STOP = 4;
    /**
     * Sent when Pomodoro ticks a second
     */
    public final static int MSG_UNREGISTER_CLIENT = -2;
    /**
     * Holds remaining time in seconds
     */
    private int pomodoroSecondsValue = -1;

    /**
     * The Database container for db4o
     */
    private DBHelper dbHelper;
    /**
     * The actual User
     */
    private User user;
    /**
     * For communication with the Service
     */
    private Messenger messenger;

    /**
     * @return dbHelper object
     */
    public DBHelper getDbHelper() {
        return dbHelper;
    }

    /**
     * @return user object
     */
    public User getUser() {
        try {
            return User.retrieve(dbHelper);
        } catch (PomodroidException e) {