// Path: app/src/main/java/de/mygrades/main/events/ErrorEvent.java
// public class ErrorEvent {
//     private ErrorType type;
//     private String msg;
// 
//     public ErrorEvent() {
//     }
// 
//     public ErrorEvent(ErrorType type, String msg) {
//         this.type = type;
//         this.msg = msg;
//     }
// 
//     public ErrorType getType() {
//         return type;
//     }
// 
//     public void setType(ErrorType type) {
//         this.type = type;
//     }
// 
//     public String getMsg() {
//         return msg;
//     }
// 
//     public void setMsg(String msg) {
//         this.msg = msg;
//     }
// 
//     public enum ErrorType {
//         GENERAL, TIMEOUT, NO_NETWORK
//     }
// }
// 
// Path: app/src/main/java/de/mygrades/main/events/ErrorReportDoneEvent.java
// public class ErrorReportDoneEvent {
// }
// 
// Path: app/src/main/java/de/mygrades/util/Constants.java
// public class Constants {
// 
//     // secure preferences constants
//     public static final String NOT_SO_SECURE_PREF_FILE = "userdata";
//     public static final String PREF_KEY_USERNAME = "username";
//     public static final String PREF_KEY_PASSWORD = "password";
// 
//     // normal preferences constants
//     public static final String PREF_KEY_UNIVERSITY_ID = "university_id";
//     public static final String PREF_KEY_RULE_ID = "rule_id";
//     public static final String PREF_KEY_INITIAL_LOADING_DONE = "initial_loading_done";
//     public static final String PREF_KEY_LAST_UPDATED_AT = "last_updated_at";
//     public static final String PREF_KEY_SCRAPING_FAILS_INTERVAL = "scraping_fails_interval";
//     public static final String PREF_KEY_ALARM_ERROR_SCRAPING_COUNT = "alarm_error_scraping_count";
//     public static final String PREF_KEY_DISMISSED_NOTIFICATION_INFO = "dismissed_notification_info";
//     public static final String PREF_KEY_DISMISSED_DONATION_INFO = "dismissed_donation_info";
//     public static final String PREF_KEY_DISMISSED_RATING_INFO = "dismissed_rating_info";
//     public static final String PREF_KEY_DISMISSED_EDIT_MODE_INFO = "dismissed_edit_mode_info";
//     public static final String PREF_KEY_APPLICATION_LAUNCHES_COUNTER = "application_launches_counter";
// 
//     // Scraping status instance state
//     public static final String INSTANCE_IS_SCRAPING_STATE = "is_scraping_state";
//     public static final String INSTANCE_PROGRESS_STATE = "progress_state";
// 
//     // grade entry 'seen' state
//     public static final int GRADE_ENTRY_SEEN = 0;
//     public static final int GRADE_ENTRY_NEW = 1;
//     public static final int GRADE_ENTRY_UPDATED = 2;
// }


import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import de.greenrobot.event.EventBus;
import de.mygrades.BuildConfig;
import de.mygrades.main.events.ErrorEvent;
import de.mygrades.main.events.ErrorReportDoneEvent;
import de.mygrades.util.Constants;
import retrofit.RetrofitError;
package de.mygrades.main.processor;



/**
 * ErrorProcessor is responsible to send error reports from users to the server.
 */
public class ErrorProcessor extends BaseProcessor {
    private static final String TAG = ErrorProcessor.class.getSimpleName();

    public ErrorProcessor(Context context) {
        super(context);
    }

    /**
     * Posts an error to the server.
     *
     * @param name - name
     * @param email - email address
     * @param errorMessage - error message
     */
    public void postErrorReport(String name, String email, String errorMessage) {
        // No Connection -> event no Connection, abort
        if (!isOnline()) {
            postErrorEvent(ErrorEvent.ErrorType.NO_NETWORK, "No Internet Connection!");
            return;
        }

        try {
            // get university id
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// Path: app/src/main/java/de/mygrades/main/events/ErrorEvent.java
// public class ErrorEvent {
//     private ErrorType type;
//     private String msg;
// 
//     public ErrorEvent() {
//     }
// 
//     public ErrorEvent(ErrorType type, String msg) {
//         this.type = type;
//         this.msg = msg;
//     }
// 
//     public ErrorType getType() {
//         return type;
//     }
// 
//     public void setType(ErrorType type) {
//         this.type = type;
//     }
// 
//     public String getMsg() {
//         return msg;
//     }
// 
//     public void setMsg(String msg) {
//         this.msg = msg;
//     }
// 
//     public enum ErrorType {
//         GENERAL, TIMEOUT, NO_NETWORK
//     }
// }
// 
// Path: app/src/main/java/de/mygrades/main/events/ErrorReportDoneEvent.java
// public class ErrorReportDoneEvent {
// }
// 
// Path: app/src/main/java/de/mygrades/util/Constants.java
// public class Constants {
// 
//     // secure preferences constants
//     public static final String NOT_SO_SECURE_PREF_FILE = "userdata";
//     public static final String PREF_KEY_USERNAME = "username";
//     public static final String PREF_KEY_PASSWORD = "password";
// 
//     // normal preferences constants
//     public static final String PREF_KEY_UNIVERSITY_ID = "university_id";
//     public static final String PREF_KEY_RULE_ID = "rule_id";
//     public static final String PREF_KEY_INITIAL_LOADING_DONE = "initial_loading_done";
//     public static final String PREF_KEY_LAST_UPDATED_AT = "last_updated_at";
//     public static final String PREF_KEY_SCRAPING_FAILS_INTERVAL = "scraping_fails_interval";
//     public static final String PREF_KEY_ALARM_ERROR_SCRAPING_COUNT = "alarm_error_scraping_count";
//     public static final String PREF_KEY_DISMISSED_NOTIFICATION_INFO = "dismissed_notification_info";
//     public static final String PREF_KEY_DISMISSED_DONATION_INFO = "dismissed_donation_info";
//     public static final String PREF_KEY_DISMISSED_RATING_INFO = "dismissed_rating_info";
//     public static final String PREF_KEY_DISMISSED_EDIT_MODE_INFO = "dismissed_edit_mode_info";
//     public static final String PREF_KEY_APPLICATION_LAUNCHES_COUNTER = "application_launches_counter";
// 
//     // Scraping status instance state
//     public static final String INSTANCE_IS_SCRAPING_STATE = "is_scraping_state";
//     public static final String INSTANCE_PROGRESS_STATE = "progress_state";
// 
//     // grade entry 'seen' state
//     public static final int GRADE_ENTRY_SEEN = 0;
//     public static final int GRADE_ENTRY_NEW = 1;
//     public static final int GRADE_ENTRY_UPDATED = 2;
// }


// Path: app/src/main/java/de/mygrades/main/processor/ErrorProcessor.java
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager;
import de.greenrobot.event.EventBus;
import de.mygrades.BuildConfig;
import de.mygrades.main.events.ErrorEvent;
import de.mygrades.main.events.ErrorReportDoneEvent;
import de.mygrades.util.Constants;
import retrofit.RetrofitError;

package de.mygrades.main.processor;



/**
 * ErrorProcessor is responsible to send error reports from users to the server.
 */
public class ErrorProcessor extends BaseProcessor {
    private static final String TAG = ErrorProcessor.class.getSimpleName();

    public ErrorProcessor(Context context) {
        super(context);
    }

    /**
     * Posts an error to the server.
     *
     * @param name - name
     * @param email - email address
     * @param errorMessage - error message
     */
    public void postErrorReport(String name, String email, String errorMessage) {
        // No Connection -> event no Connection, abort
        if (!isOnline()) {
            postErrorEvent(ErrorEvent.ErrorType.NO_NETWORK, "No Internet Connection!");
            return;
        }

        try {
            // get university id
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            long universityId = prefs.getLong(Constants.PREF_KEY_UNIVERSITY_ID, -1);