Merge branch 'develop' into fixed-graphs-styles
|
@ -0,0 +1,56 @@
|
|||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# Intellij
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Freeline
|
||||
freeline.py
|
||||
freeline/
|
||||
freeline_project_description.json
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/android-event-viewer.iml" filepath="$PROJECT_DIR$/android-event-viewer.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 8
|
||||
buildToolsVersion "25.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "pandroid_event_viewer.pandorafms"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 8
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<lint>
|
||||
<issue id="ParserError" severity="ignore" />
|
||||
</lint>
|
|
@ -16,8 +16,8 @@
|
|||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="pandroid_event_viewer.pandorafms"
|
||||
android:versionCode="5"
|
||||
android:versionName="1.4" >
|
||||
android:versionCode="6"
|
||||
android:versionName="1.5" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
|
@ -136,22 +136,25 @@ public class API {
|
|||
* Retrieve number of events instead of events info.
|
||||
* @param more_criticity
|
||||
* Retrieve maximum criticity instead of events info.
|
||||
* @param returnType
|
||||
* To chose the type of the returned data (csv, json...).
|
||||
*
|
||||
* @return API call result.
|
||||
* @throws IOException
|
||||
* if there was any problem.
|
||||
*/
|
||||
public static String getEvents(Context context, String filterAgentName,
|
||||
public static String getEvents (Context context, String filterAgentName,
|
||||
int idGroup, int filterSeverity, int filterStatus,
|
||||
String filterEventSearch, String filterTag, long filterTimestamp,
|
||||
long itemsPerPage, long offset, boolean total,
|
||||
boolean more_criticity) throws IOException {
|
||||
boolean more_criticity, String returnType) throws IOException {
|
||||
|
||||
ArrayList<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("op", "get"));
|
||||
parameters.add(new BasicNameValuePair("op2", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("return_type", returnType));
|
||||
parameters.add(new BasicNameValuePair("other",
|
||||
serializeEventsParamsToAPI(filterAgentName, idGroup,
|
||||
filterSeverity, filterStatus, filterEventSearch,
|
||||
|
@ -160,6 +163,88 @@ public class API {
|
|||
return Core.httpGet(context, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a get_events API call.
|
||||
*
|
||||
* @param context
|
||||
* Application context.
|
||||
* @param filterAgentName
|
||||
* Agent name.
|
||||
* @param idGroup
|
||||
* Group id.
|
||||
* @param filterSeverity
|
||||
* Severity.
|
||||
* @param filterStatus
|
||||
* Status.
|
||||
* @param filterEventSearch
|
||||
* Text in event title.
|
||||
* @param filterTag
|
||||
* Tag.
|
||||
* @param filterTimestamp
|
||||
* Events after this time.
|
||||
* @param itemsPerPage
|
||||
* Number of items retrieved per list in each call.
|
||||
* @param offset
|
||||
* List offset.
|
||||
* @param total
|
||||
* Retrieve number of events instead of events info.
|
||||
* @param more_criticity
|
||||
* Retrieve maximum criticity instead of events info.
|
||||
*
|
||||
* @return API call result.
|
||||
* @throws IOException
|
||||
* if there was any problem.
|
||||
*/
|
||||
public static String getEvents (Context context, String filterAgentName,
|
||||
int idGroup, int filterSeverity, int filterStatus,
|
||||
String filterEventSearch, String filterTag,
|
||||
long filterTimestamp, long itemsPerPage, long offset,
|
||||
boolean total, boolean more_criticity) throws IOException {
|
||||
return API.getEvents(context,
|
||||
filterAgentName, idGroup, filterSeverity, filterStatus, filterEventSearch,
|
||||
filterTag, filterTimestamp, itemsPerPage, offset, total, more_criticity, "csv");
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a get_events API call.
|
||||
*
|
||||
* @param context
|
||||
* Application context.
|
||||
* @param filterAgentName
|
||||
* Agent name.
|
||||
* @param idGroup
|
||||
* Group id.
|
||||
* @param filterSeverity
|
||||
* Severity.
|
||||
* @param filterStatus
|
||||
* Status.
|
||||
* @param filterEventSearch
|
||||
* Text in event title.
|
||||
* @param filterTag
|
||||
* Tag.
|
||||
* @param filterTimestamp
|
||||
* Events after this time.
|
||||
* @param itemsPerPage
|
||||
* Number of items retrieved per list in each call.
|
||||
* @param offset
|
||||
* List offset.
|
||||
* @param returnType
|
||||
* To chose the type of the returned data (csv, json...).
|
||||
*
|
||||
* @return API call result.
|
||||
* @throws IOException
|
||||
* if there was any problem.
|
||||
*/
|
||||
public static String getEvents (Context context, String filterAgentName,
|
||||
int idGroup, int filterSeverity, int filterStatus,
|
||||
String filterEventSearch, String filterTag,
|
||||
long filterTimestamp, long itemsPerPage, long offset,
|
||||
String returnType) throws IOException {
|
||||
return API.getEvents(context,
|
||||
filterAgentName, idGroup, filterSeverity, filterStatus, filterEventSearch,
|
||||
filterTag, filterTimestamp, itemsPerPage, offset, false, false, returnType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags through an api call.
|
||||
*
|
|
@ -34,6 +34,8 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
@ -755,4 +757,32 @@ public class Core {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the major version by extracting it from the api_version token from the preferences.
|
||||
*
|
||||
* @param context Application context.
|
||||
* @return int Major API version
|
||||
*
|
||||
* @throws Exception If the major version cannot be extracted.
|
||||
* @throws NumberFormatException If the major version cannot be casted to integer.
|
||||
*/
|
||||
public static int getMajorVersion (Context context) throws Exception {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
// It is something like v5.0SP1
|
||||
String api_version = preferences.getString("api_version", "");
|
||||
|
||||
// Try to get the version number
|
||||
Matcher apiVerMatcher = Pattern.compile("^v(\\d)+\\.\\d+.*$").matcher(api_version);
|
||||
|
||||
if (apiVerMatcher.find()) {
|
||||
String apiVerString = apiVerMatcher.group(1);
|
||||
int apiVerNumber = Integer.parseInt(apiVerString);
|
||||
|
||||
return apiVerNumber;
|
||||
}
|
||||
throw new Exception("The version number cannot be extracted from the version string");
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
|
@ -39,9 +41,12 @@ import android.widget.BaseAdapter;
|
|||
import android.widget.TabHost;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class PandroidEventviewerActivity extends TabActivity implements
|
||||
Serializable {
|
||||
|
||||
public class PandroidEventviewerActivity extends TabActivity implements Serializable {
|
||||
private static String TAG = "PandroidEventviewerActivity";
|
||||
private static final int PROBLEM_NOTIFICATION_ID = 1;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -261,248 +266,218 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Get events from pandora console. For only Pandora 5.0 version
|
||||
* Parses a JSON object and returns a valid event list item.
|
||||
* For >= v7.
|
||||
*
|
||||
* @throws IOException
|
||||
* If there is any connection problem.
|
||||
* @param item Object with the event columns.
|
||||
*
|
||||
* @return EventListItem
|
||||
* @throws JSONException, NumberFormatException
|
||||
*/
|
||||
private void getEvents_v50(String[] lines) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] items = lines[i].split(";");
|
||||
|
||||
private EventListItem parseEvent (JSONObject item) throws JSONException, NumberFormatException {
|
||||
EventListItem event = new EventListItem();
|
||||
boolean extract = true;
|
||||
try {
|
||||
if (items.length < 14) {
|
||||
extract = false;
|
||||
continue;
|
||||
}
|
||||
//Get id event
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
}
|
||||
else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
|
||||
//Get id agent
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
|
||||
//Get id user
|
||||
event.id_user = items[2];
|
||||
|
||||
//Get id group
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
}
|
||||
else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
|
||||
//Get status
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
}
|
||||
else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
|
||||
//Get timestamp (format Y-M-d H:m:s)
|
||||
event.timestamp = items[5];
|
||||
|
||||
//Get event as text
|
||||
event.event = items[6];
|
||||
|
||||
//Get unix timestamp
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
}
|
||||
else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
|
||||
//Get event type
|
||||
event.event_type = items[8];
|
||||
|
||||
//Get id module
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
|
||||
//Get id alert
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
}
|
||||
else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
|
||||
//Get criticity
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
}
|
||||
else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
|
||||
//Get user comment
|
||||
event.user_comment = items[12];
|
||||
|
||||
//Get tags
|
||||
event.tags = items[13];
|
||||
|
||||
/* This fields are not used in the Pandroid event
|
||||
|
||||
event.source = item[14];
|
||||
event.id_extra = item[15];
|
||||
event.critical_instructions = item[16];
|
||||
event.warning_instructions = item[17];
|
||||
event.unknown_instructions = item[18];
|
||||
event.owner_user = item[19];
|
||||
event.ack_utimestamp = item[20];
|
||||
event.custom_data = item[21]
|
||||
|
||||
*/
|
||||
|
||||
event.agent_name = "";
|
||||
event.group_name = "";
|
||||
event.group_icon = "";
|
||||
event.description_event = "";
|
||||
event.description_image = "";
|
||||
event.criticity_name = "";
|
||||
event.criticity_image = "";
|
||||
|
||||
if (items.length >= 23)
|
||||
event.agent_name = items[22];
|
||||
if (items.length >= 24)
|
||||
event.group_name = items[23];
|
||||
if (items.length >= 25)
|
||||
event.group_icon = items[24];
|
||||
if (items.length >= 26)
|
||||
event.description_event = items[25];
|
||||
if (items.length >= 27)
|
||||
event.description_image = items[26];
|
||||
if (items.length >= 28)
|
||||
event.criticity_name = items[28];
|
||||
if (items.length >= 27)
|
||||
event.criticity_image = items[27];
|
||||
// Event id
|
||||
event.id_event = item.optInt("id_evento");
|
||||
// Agent id
|
||||
event.id_agent = item.optInt("id_agente");
|
||||
// User id
|
||||
event.id_user = item.getString("id_usuario");
|
||||
// Group id
|
||||
event.id_group = item.optInt("id_grupo");
|
||||
// Status
|
||||
event.status = item.optInt("estado");
|
||||
// Timestamp (Y-M-d H:m:s)
|
||||
event.timestamp = item.getString("timestamp");
|
||||
// Event text
|
||||
event.event = item.getString("evento");
|
||||
// Unix timestamp
|
||||
event.utimestamp = item.optInt("utimestamp");
|
||||
// Event type
|
||||
event.event_type = item.getString("event_type");
|
||||
// Module id
|
||||
event.id_agentmodule = item.optInt("id_agentmodule");
|
||||
// Alert id
|
||||
event.id_alert_am = item.optInt("id_alert_am");
|
||||
// Event priority
|
||||
event.criticity = item.optInt("criticity");
|
||||
// User comments
|
||||
event.user_comment = item.getString("user_comment");
|
||||
// Tags
|
||||
event.tags = item.getString("tags");
|
||||
// Agent name (try to use the alias)
|
||||
event.agent_name = item.optString("agent_alias", item.optString("agent_name"));
|
||||
// Group name
|
||||
event.group_name = item.optString("group_name");
|
||||
// Group icon
|
||||
event.group_icon = item.optString("group_icon");
|
||||
// Event description
|
||||
event.description_event = item.optString("description_event");
|
||||
// Event description image
|
||||
event.description_image = item.optString("img_description");
|
||||
// Event priority name
|
||||
event.criticity_name = item.optString("criticity_name");
|
||||
// Event priority image
|
||||
event.criticity_image = item.optString("img_criticy");
|
||||
|
||||
event.opened = false;
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string array and returns a valid event list item.
|
||||
*
|
||||
* THIS IS AN HORRIBLE WAY TO DO THIS.
|
||||
* Any change on the columns order on the tevento's table from the database
|
||||
* or any change to the public API can break this in multiple ways.
|
||||
* CSV is bad for a maintainable and scalable APIs, but someone could almost map the
|
||||
* head (nonexistent) with the line columns indexes... /rage
|
||||
*
|
||||
* For <= v6.
|
||||
*
|
||||
* @param columns String array with the event columns.
|
||||
* @param old Whether to use the csv parsing for the <=v4 or the >=v5 && <= v6.
|
||||
*
|
||||
* @return EventListItem
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
private EventListItem parseEvent (String[] columns, boolean old) throws NumberFormatException {
|
||||
EventListItem event = new EventListItem();
|
||||
|
||||
// Event id
|
||||
event.id_event = (columns[0].length() > 0) ? Integer.parseInt(columns[0]) : 0;
|
||||
// Agent id
|
||||
event.id_agent = (columns[1].length() > 0) ? Integer.parseInt(columns[1]) : 0;
|
||||
// User id
|
||||
event.id_user = columns[2];
|
||||
//Get id group
|
||||
event.id_group = (columns[3].length() > 0) ? Integer.parseInt(columns[3]) : 0;
|
||||
// Status
|
||||
event.status = (columns[4].length() > 0) ? Integer.parseInt(columns[4]) : 0;
|
||||
// Timestamp (format Y-M-d H:m:s)
|
||||
event.timestamp = columns[5];
|
||||
//Get event as text
|
||||
event.event = columns[6];
|
||||
// Unix timestamp
|
||||
event.utimestamp = (columns[7].length() > 0) ? Integer.parseInt(columns[7]) : 0;
|
||||
// Event type
|
||||
event.event_type = columns[8];
|
||||
// Module id
|
||||
event.id_agentmodule = (columns[9].length() > 0) ? Integer.parseInt(columns[9]) : 0;
|
||||
// Alert id
|
||||
event.id_alert_am = (columns[10].length() > 0) ? Integer.parseInt(columns[10]) : 0;
|
||||
// Priority
|
||||
event.criticity = (columns[11].length() > 0) ? Integer.parseInt(columns[11]) : 0;
|
||||
// User comment
|
||||
event.user_comment = columns[12];
|
||||
// Tags
|
||||
event.tags = columns[13];
|
||||
|
||||
// For <= v4
|
||||
if (old) {
|
||||
// Agent name
|
||||
event.agent_name = (columns.length >= 15) ? columns[14] : "";
|
||||
// Group name
|
||||
event.group_name = (columns.length >= 16) ? columns[15] : "";
|
||||
// Group icon
|
||||
event.group_icon = (columns.length >= 17) ? columns[16] : "";
|
||||
// Event description
|
||||
event.description_event = (columns.length >= 18) ? columns[17] : "";
|
||||
// Event description image
|
||||
event.description_image = (columns.length >= 19) ? columns[18] : "";
|
||||
// Priority image
|
||||
event.criticity_image = (columns.length >= 20) ? columns[19] : "";
|
||||
// Priority name
|
||||
event.criticity_name = (columns.length >= 21) ? columns[20] : "";
|
||||
}
|
||||
// For v5 and v6
|
||||
else {
|
||||
// Agent name
|
||||
event.agent_name = (columns.length >= 23) ? columns[22] : "";
|
||||
// Group name
|
||||
event.group_name = (columns.length >= 24) ? columns[23] : "";
|
||||
// Group icon
|
||||
event.group_icon = (columns.length >= 25) ? columns[24] : "";
|
||||
// Event description
|
||||
event.description_event = (columns.length >= 26) ? columns[25] : "";
|
||||
// Event description image
|
||||
event.description_image = (columns.length >= 27) ? columns[26] : "";
|
||||
// Priority image
|
||||
event.criticity_image = (columns.length >= 28) ? columns[27] : "";
|
||||
// Priority name
|
||||
event.criticity_name = (columns.length >= 29) ? columns[28] : "";
|
||||
}
|
||||
|
||||
event.opened = false;
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a JSON response from the api and save the new events.
|
||||
* For >= v7.
|
||||
*
|
||||
* @param items JSONObject array with the event rows.
|
||||
*/
|
||||
private void saveEvents (JSONArray items) {
|
||||
if (items.length() == 0) {
|
||||
Log.d("WORKS?", "NEWEVENTS = FALSE");
|
||||
this.newEvents = false;
|
||||
return;
|
||||
}
|
||||
this.newEvents = true;
|
||||
|
||||
// Iterate the JSON Objects
|
||||
for (int i = 0; i < items.length(); i++) {
|
||||
try {
|
||||
JSONObject item = items.getJSONObject(i);
|
||||
EventListItem event = this.parseEvent(item);
|
||||
this.eventList.add(event);
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
event.event = getApplication().getString(
|
||||
R.string.unknown_event_str);
|
||||
launchProblemParsingNotification();
|
||||
}
|
||||
if (extract)
|
||||
this.eventList.add(event);
|
||||
catch (JSONException e) {
|
||||
launchProblemParsingNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events from pandora console. For old versions of Pandora (v4 <)
|
||||
*
|
||||
* @throws IOException
|
||||
* If there is any connection problem.
|
||||
* Process a CSV response from the api and save the new events.
|
||||
* For <= v6.
|
||||
*
|
||||
* @param lines String array with the event lines in CSV format.
|
||||
* @param old Whether to use the csv parsing for the <=v4 or the >=v5 && <= v6.
|
||||
*/
|
||||
private void getEvents_old(String[] lines) {
|
||||
private void saveEvents (String[] lines, boolean old) {
|
||||
if (lines.length == 0) {
|
||||
Log.d("WORKS?", "NEWEVENTS = FALSE");
|
||||
this.newEvents = false;
|
||||
return;
|
||||
}
|
||||
this.newEvents = true;
|
||||
|
||||
// Iterate the CSV lines
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] items = lines[i].split(";");
|
||||
|
||||
EventListItem event = new EventListItem();
|
||||
try {
|
||||
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
}
|
||||
else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
event.id_user = items[2];
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
}
|
||||
else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
}
|
||||
else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
event.timestamp = items[5];
|
||||
event.event = items[6];
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
}
|
||||
else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
event.event_type = items[8];
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
}
|
||||
else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
}
|
||||
else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
event.user_comment = items[12];
|
||||
event.tags = items[13];
|
||||
event.agent_name = items[14];
|
||||
event.group_name = items[15];
|
||||
event.group_icon = items[16];
|
||||
event.description_event = items[17];
|
||||
event.description_image = items[18];
|
||||
event.criticity_name = items[19];
|
||||
event.criticity_image = items[20];
|
||||
|
||||
event.opened = false;
|
||||
String[] columns = lines[i].split(";");
|
||||
EventListItem event = this.parseEvent(columns, old);
|
||||
this.eventList.add(event);
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
event.event = getApplication().getString(
|
||||
R.string.unknown_event_str);
|
||||
launchProblemParsingNotification();
|
||||
}
|
||||
this.eventList.add(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events from pandora console.
|
||||
*
|
||||
* @throws IOException
|
||||
* If there is any connection problem.
|
||||
*
|
||||
* @throws IOException If there is any connection problem.
|
||||
*/
|
||||
private void getEvents() throws IOException {
|
||||
private void getEvents () throws IOException {
|
||||
// Get total count.
|
||||
String return_api = API.getEvents(getApplicationContext(),
|
||||
agentNameStr, id_group, severity, status, eventSearch,
|
||||
|
@ -521,35 +496,42 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||
return;
|
||||
}
|
||||
|
||||
// Get the list of events.
|
||||
return_api = API.getEvents(getApplicationContext(), agentNameStr,
|
||||
id_group, severity, status, eventSearch, eventTag, timestamp,
|
||||
pagination, offset, false, false);
|
||||
Log.d(TAG, "List of events: " + return_api);
|
||||
// Try to get the API version number
|
||||
int apiVerNumber = 0;
|
||||
try {
|
||||
apiVerNumber = Core.getMajorVersion(getApplicationContext());
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
// Get the list of events.
|
||||
String returnType = (apiVerNumber < 7) ? "csv" : "json";
|
||||
return_api = API.getEvents(getApplicationContext(),
|
||||
agentNameStr, id_group, severity, status, eventSearch,
|
||||
eventTag, timestamp, pagination, offset, returnType);
|
||||
|
||||
Log.d(TAG, "List of events: " + return_api);
|
||||
Log.i(TAG + " getEvents - return_api", return_api);
|
||||
|
||||
String[] lines = return_api.split("\n");
|
||||
newEvents = true;
|
||||
if (return_api.length() == 0) {
|
||||
Log.d("WORKS?", "NEWEVENTS = FALSE");
|
||||
newEvents = false;
|
||||
return;
|
||||
try {
|
||||
if (apiVerNumber >= 7) {
|
||||
JSONObject response = new JSONObject(return_api);
|
||||
if (!response.optString("type").equals("array")) {
|
||||
throw new Exception("Invalid API return type");
|
||||
}
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
String api_version = preferences.getString("api_version", "");
|
||||
|
||||
// Get the short form of the version. I.E. "v5" for "v5.0SP1"
|
||||
String[] api_version_short = api_version.split("\\.");
|
||||
|
||||
if (api_version_short[0].equals("v5")) {
|
||||
this.getEvents_v50(lines);
|
||||
JSONArray rows = response.getJSONArray("data");
|
||||
this.saveEvents(rows);
|
||||
}
|
||||
else {
|
||||
this.getEvents_old(lines);
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
// The Console API changed in the v5
|
||||
boolean old = apiVerNumber < 5;
|
||||
this.saveEvents(lines, old);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.newEvents = false;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 859 B |
Before Width: | Height: | Size: 849 B After Width: | Height: | Size: 849 B |
Before Width: | Height: | Size: 685 B After Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 789 B After Width: | Height: | Size: 789 B |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 930 B After Width: | Height: | Size: 930 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 543 B |
Before Width: | Height: | Size: 728 B After Width: | Height: | Size: 728 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 637 B After Width: | Height: | Size: 637 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 912 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 799 B After Width: | Height: | Size: 799 B |
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 321 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 736 B |
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_window_focused="false" android:state_enabled="true"
|
||||
android:drawable="@drawable/combobox_normal" />
|
Before Width: | Height: | Size: 267 B After Width: | Height: | Size: 267 B |
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 405 B |
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/delete"
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/icon_filter"
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/button_normal"
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/icon_refresh"
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#4CA8E0"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#7eb628"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#999999"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#ff4040"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#f2d400"/>
|
||||
<stroke android:width="3dip" android:color="#242424" />
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/save"
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
|
@ -25,25 +25,24 @@
|
|||
android:id="@+id/content_event_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:background="#242424"
|
||||
>
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/event_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:drawablePadding="5dp"
|
||||
android:textColor="#000"
|
||||
android:textColorHighlight="#000"
|
||||
android:layout_margin="5dp" />
|
||||
android:textColorHighlight="#000" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/event_name"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="5dp" >
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/agent_name"
|
||||
|
@ -61,10 +60,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:drawablePadding="10dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textColor="#000"
|
||||
android:textColorHighlight="#000"
|
||||
android:textSize="10sp"
|
||||
android:paddingRight="5dp" />
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|