mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
2012-07-05 Santiago Munin <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/OnBootLoader.java: New BroadcastReceiver which starts the search new events service after the phone boot. * src/pandroid_event_viewer/pandorafms/Core.java: Little changes. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: On process_notification it doesn't retrieve count_events anymore. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Now the launched notification has the correct number of new events. * res/values/strings.xml: Added new entries. * res/values-en/*: Deleted, unnecessary files. * AndroidManifest.xml: Added the new BroadcastReceiver git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6743 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
7adba3caed
commit
c5ea8e4da3
@ -79,16 +79,14 @@
|
|||||||
android:label="@string/pandroid_event_viewer_str"
|
android:label="@string/pandroid_event_viewer_str"
|
||||||
android:theme="@android:style/Theme.Dialog" >
|
android:theme="@android:style/Theme.Dialog" >
|
||||||
</activity>
|
</activity>
|
||||||
<!--
|
<activity android:name=".CreateIncidentActivity" />
|
||||||
<activity android:name=".IncidentList"/> -->
|
<service android:name=".PandroidEventviewerService" />
|
||||||
<activity android:name=".CreateIncidentActivity"/>
|
<receiver android:name=".OnBootLoader"
|
||||||
<service android:name=".PandroidEventviewerService" >
|
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
|
||||||
</service>
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
<receiver
|
<category android:name="android.intent.category.HOME" />
|
||||||
android:name=".AlarmReceiver"
|
</intent-filter>
|
||||||
android:process=":remote" >
|
|
||||||
</receiver>
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,3 +1,12 @@
|
|||||||
|
2012-07-05 Santiago Munín <burning1@gmail.com>
|
||||||
|
* src/pandroid_event_viewer/pandorafms/OnBootLoader.java: New BroadcastReceiver which starts the search new events service after the phone boot.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Core.java: Little changes.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: On process_notification it doesn't retrieve count_events anymore.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Now the launched notification has the correct number of new events.
|
||||||
|
* res/values/strings.xml: Added new entries.
|
||||||
|
* res/values-en/*: Deleted, unnecessary files.
|
||||||
|
* AndroidManifest.xml: Added the new BroadcastReceiver
|
||||||
|
|
||||||
2012-07-03 Santiago Munín <burning1@gmail.com>
|
2012-07-03 Santiago Munín <burning1@gmail.com>
|
||||||
* src/pandroid_event_viewer/pandorafms/IncidentListItem.java: Deleted, not necessary class.
|
* src/pandroid_event_viewer/pandorafms/IncidentListItem.java: Deleted, not necessary class.
|
||||||
* src/pandroid_event_viewer/pandorafms/IncidentList.java: Deleted, not necessary class.
|
* src/pandroid_event_viewer/pandorafms/IncidentList.java: Deleted, not necessary class.
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
|
||||||
// ==================================================
|
|
||||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
|
||||||
// as published by the Free Software Foundation; version 2
|
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
-->
|
|
||||||
<resources>
|
|
||||||
<string-array name="severity_array_values">
|
|
||||||
<!-- You must subtract -1 -->
|
|
||||||
<item>All</item>
|
|
||||||
<item>Maintenance</item>
|
|
||||||
<item>Informational</item>
|
|
||||||
<item>Normal</item>
|
|
||||||
<item>Warning</item>
|
|
||||||
<item>Critical</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<!-- Please change the code in the function convertRefreshTimeKeyToTime -->
|
|
||||||
<string-array name="refresh_combo">
|
|
||||||
<item>30 seconds</item>
|
|
||||||
<item>1 minute</item>
|
|
||||||
<item>5 minutes</item>
|
|
||||||
<item>10 minutes</item>
|
|
||||||
<item>15 minutes</item>
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>45 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>1 hour and 30 minutes</item>
|
|
||||||
<item>2 hours</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>4 hours</item>
|
|
||||||
<item>6 hours</item>
|
|
||||||
<item>8 hours</item>
|
|
||||||
<item>10 hours</item>
|
|
||||||
<item>12 hours</item>
|
|
||||||
<item>24 hours</item>
|
|
||||||
<item>36 hours</item>
|
|
||||||
<item>48 hours</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="event_status_values">
|
|
||||||
<!-- You must subtract -1 -->
|
|
||||||
<!--<item>All event</item>//The next version re-add please -->
|
|
||||||
|
|
||||||
<!-- You must subtract 0 -->
|
|
||||||
<item>Only new</item>
|
|
||||||
<item>Only validated</item>
|
|
||||||
<item>Only in process</item>
|
|
||||||
<item>Only not validated</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<!-- Please change the code in the function convertMaxTimeOldEventValuesToTimestamp -->
|
|
||||||
<string-array name="max_time_old_event_values">
|
|
||||||
<item>30 minutes</item>
|
|
||||||
<item>1 hour</item>
|
|
||||||
<item>2 hours</item>
|
|
||||||
<item>3 hours</item>
|
|
||||||
<item>4 hours</item>
|
|
||||||
<item>5 hours</item>
|
|
||||||
<item>8 hours</item>
|
|
||||||
<item>10 hours</item>
|
|
||||||
<item>12 hours</item>
|
|
||||||
<item>1 day</item>
|
|
||||||
<item>2 days</item>
|
|
||||||
<item>3 days</item>
|
|
||||||
<item>4 days</item>
|
|
||||||
<item>5 days</item>
|
|
||||||
<item>1 week</item>
|
|
||||||
<item>2 weeks</item>
|
|
||||||
<item>1 month</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
|
@ -1,97 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
|
||||||
// ==================================================
|
|
||||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
|
||||||
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public License
|
|
||||||
// as published by the Free Software Foundation; version 2
|
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
-->
|
|
||||||
<resources>
|
|
||||||
<string name="item_tab_main_text">Filter</string>
|
|
||||||
<string name="item_tab_event_list_text">Event list</string>
|
|
||||||
|
|
||||||
<string name="main_text">main text (value english)</string>
|
|
||||||
<string name="list_text">list (value english)</string>
|
|
||||||
|
|
||||||
<string name="system_str">System</string>
|
|
||||||
|
|
||||||
<string name="empty_str">- Empty -</string>
|
|
||||||
<string name="all_str">All</string>
|
|
||||||
|
|
||||||
<string name="tags_label_str">Tags</string>
|
|
||||||
<string name="comments_label_str">Comments</string>
|
|
||||||
<string name="group_label_str">Group</string>
|
|
||||||
<string name="agent_label_str">Agent name</string>
|
|
||||||
<string name="type_label_str">Type</string>
|
|
||||||
<string name="severity_label_str">Severity</string>
|
|
||||||
<string name="date_label_str">Date</string>
|
|
||||||
<string name="number_events_label_str">Number Events</string>
|
|
||||||
<string name="reset_button_str">Reset</string>
|
|
||||||
<string name="search_button_str">Search</string>
|
|
||||||
<string name="loading_label_str">Loading</string>
|
|
||||||
<string name="options_label_str">Options</string>
|
|
||||||
<string name="url_label_str">URL</string>
|
|
||||||
<string name="user_label_str">User</string>
|
|
||||||
<string name="password_label_str">Password</string>
|
|
||||||
<string name="update_button_str">Update</string>
|
|
||||||
<string name="option_title_str">Options</string>
|
|
||||||
<string name="refresh_label_str">Refresh</string>
|
|
||||||
<string name="about_label_str">About</string>
|
|
||||||
<string name="load_more_events_button_str">Load more events</string>
|
|
||||||
<string name="empty_label_str">Empty list events</string>
|
|
||||||
<string name="refresh_time_label_str">Refresh time watcher</string>
|
|
||||||
<string name="set_as_filter_watcher_button_str">Filter by default</string>
|
|
||||||
|
|
||||||
<string name="config_update_succesful_str">Update configuration successful.</string>
|
|
||||||
<string name="config_update_fail_str">Update configuration is failed.</string>
|
|
||||||
<string name="please_set_preferences_str">Please set the preferences as the API URL, user and password for your Pandora FMS.</string>
|
|
||||||
<string name="preferences_set_demo_pandora_str">Pandroid Event Viewer is connecting with PandoraFMS public demo, please change the preferences for your Pandora FMS.</string>
|
|
||||||
<string name="filter_update_succesful_str">Update filter sucessful.</string>
|
|
||||||
<string name="filter_update_fail_str">Update filter is failed.</string>
|
|
||||||
<string name="validate_event_button_str">Validate Event</string>
|
|
||||||
|
|
||||||
<string name="notification_criticity_0_str">There are %s events and all in Maintenance state.</string>
|
|
||||||
<string name="notification_criticity_1_str">There are %s events and some are in Informational state.</string>
|
|
||||||
<string name="notification_criticity_2_str">There are %s events and some are in Normal state.</string>
|
|
||||||
<string name="notification_criticity_3_str">There are %s events and some are in Warning state.</string>
|
|
||||||
<string name="notification_criticity_4_str">There are %s events and some are in Critical state.</string>
|
|
||||||
|
|
||||||
<string name="loading_events_criticity_0_str">Loading the %s events and all in Maintenance state.</string>
|
|
||||||
<string name="loading_events_criticity_1_str">Loading the %s events and some are in Informational state.</string>
|
|
||||||
<string name="loading_events_criticity_2_str">Loading the %s events and some are in Normal state.</string>
|
|
||||||
<string name="loading_events_criticity_3_str">Loading the %s events and some are in Warning state.</string>
|
|
||||||
<string name="loading_events_criticity_4_str">Loading the %s events and some are in Critical state.</string>
|
|
||||||
|
|
||||||
<string name="successful_validate_event_str">The event validation is successful.</string>
|
|
||||||
<string name="fail_validate_event_str">The event validation is failed.</string>
|
|
||||||
|
|
||||||
<string name="status_label_str">Status</string>
|
|
||||||
<string name="event_search_label_str">Event search</string>
|
|
||||||
<string name="max_time_old_event_str">Oldest event</string>
|
|
||||||
|
|
||||||
<string name="licensed_under_gpl_str">Licensed under GPLv2</string>
|
|
||||||
<string name="develop_team_str">Developer: Miguel de Dios</string>
|
|
||||||
|
|
||||||
<string name="alert_recovered_str">Alert recovered</string>
|
|
||||||
<string name="alert_manual_validation_str">Alert manually validated</string>
|
|
||||||
<string name="going_up_warning_str">Going from critical to warning</string>
|
|
||||||
<string name="going_down_critical_str">Going to critical status</string>
|
|
||||||
<string name="going_up_normal_str">Going to normal status</string>
|
|
||||||
<string name="going_down_warning_str">Going to warning</string>
|
|
||||||
<string name="alert_fired_str">Alert fired</string>
|
|
||||||
<string name="recon_host_detected_str">Recon server detected a new host</string>
|
|
||||||
<string name="new_agent_str">New agent created</string>
|
|
||||||
<string name="unknown_str">Unknown type:</string>
|
|
||||||
<string name="unknown_event_str">Unknown event</string>
|
|
||||||
|
|
||||||
<string name="validate_event_label_str">Event validated</string>
|
|
||||||
<string name="pandroid_event_viewer_description_str">Realtime event viewer for Pandora FMS.</string>
|
|
||||||
</resources>
|
|
@ -62,11 +62,11 @@
|
|||||||
<string name="notification_criticity_2_str">There are %s events and some are in Normal state.</string>
|
<string name="notification_criticity_2_str">There are %s events and some are in Normal state.</string>
|
||||||
<string name="notification_criticity_3_str">There are %s events and some are in Warning state.</string>
|
<string name="notification_criticity_3_str">There are %s events and some are in Warning state.</string>
|
||||||
<string name="notification_criticity_4_str">There are %s events and some are in Critical state.</string>
|
<string name="notification_criticity_4_str">There are %s events and some are in Critical state.</string>
|
||||||
<string name="loading_events_criticity_0_str">Loading the %s events and all in Maintenance state.</string>
|
<string name="loading_events_criticity_0_str">Loading events (all in Maintenance state).</string>
|
||||||
<string name="loading_events_criticity_1_str">Loading the %s events and some are in Informational state.</string>
|
<string name="loading_events_criticity_1_str">Loading events (some are in Informational state).</string>
|
||||||
<string name="loading_events_criticity_2_str">Loading the %s events and some are in Normal state.</string>
|
<string name="loading_events_criticity_2_str">Loading events (some are in Normal state).</string>
|
||||||
<string name="loading_events_criticity_3_str">Loading the %s events and some are in Warning state.</string>
|
<string name="loading_events_criticity_3_str">Loading events (some are in Warning state).</string>
|
||||||
<string name="loading_events_criticity_4_str">Loading the %s events and some are in Critical state.</string>
|
<string name="loading_events_criticity_4_str">Loading events (some are in Critical state).</string>
|
||||||
<string name="successful_validate_event_str">The event validation is successful.</string>
|
<string name="successful_validate_event_str">The event validation is successful.</string>
|
||||||
<string name="fail_validate_event_str">The event validation is failed.</string>
|
<string name="fail_validate_event_str">The event validation is failed.</string>
|
||||||
<string name="status_label_str">Status</string>
|
<string name="status_label_str">Status</string>
|
||||||
|
@ -74,6 +74,7 @@ import android.widget.Toast;
|
|||||||
*/
|
*/
|
||||||
public class Core {
|
public class Core {
|
||||||
private static String TAG = "Core";
|
private static String TAG = "Core";
|
||||||
|
private static int CONNECTION_TIMEOUT = 10000;
|
||||||
private static Map<String, Bitmap> imgCache = new HashMap<String, Bitmap>();
|
private static Map<String, Bitmap> imgCache = new HashMap<String, Bitmap>();
|
||||||
// Don't use this variable, just call getSocketFactory
|
// Don't use this variable, just call getSocketFactory
|
||||||
private static SSLSocketFactory sslSocketFactory;
|
private static SSLSocketFactory sslSocketFactory;
|
||||||
@ -330,6 +331,7 @@ public class Core {
|
|||||||
parameters.add(new BasicNameValuePair("apipass", apiPassword));
|
parameters.add(new BasicNameValuePair("apipass", apiPassword));
|
||||||
}
|
}
|
||||||
parameters.addAll(additionalParameters);
|
parameters.addAll(additionalParameters);
|
||||||
|
Log.i(TAG, "sent: "+url);
|
||||||
if (url.toLowerCase().contains("https")) {
|
if (url.toLowerCase().contains("https")) {
|
||||||
// Secure connection
|
// Secure connection
|
||||||
return Core.httpsGet(url, parameters);
|
return Core.httpsGet(url, parameters);
|
||||||
@ -347,6 +349,7 @@ public class Core {
|
|||||||
entityResponse = response.getEntity();
|
entityResponse = response.getEntity();
|
||||||
return_api = Core
|
return_api = Core
|
||||||
.convertStreamToString(entityResponse.getContent());
|
.convertStreamToString(entityResponse.getContent());
|
||||||
|
Log.i(TAG, "received: "+ return_api);
|
||||||
return return_api;
|
return return_api;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,6 +387,7 @@ public class Core {
|
|||||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||||
.openConnection();
|
.openConnection();
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
|
conn.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
Bitmap img = BitmapFactory.decodeStream(is);
|
Bitmap img = BitmapFactory.decodeStream(is);
|
||||||
@ -450,6 +454,7 @@ public class Core {
|
|||||||
HttpsURLConnection con;
|
HttpsURLConnection con;
|
||||||
try {
|
try {
|
||||||
con = (HttpsURLConnection) url.openConnection();
|
con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
con.connect();
|
con.connect();
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
return true;
|
return true;
|
||||||
@ -472,6 +477,7 @@ public class Core {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
con.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
con.setSSLSocketFactory(getSocketFactory());
|
con.setSSLSocketFactory(getSocketFactory());
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.getInputStream();
|
con.getInputStream();
|
||||||
@ -506,6 +512,7 @@ public class Core {
|
|||||||
});
|
});
|
||||||
con.setSSLSocketFactory(getSocketFactory());
|
con.setSSLSocketFactory(getSocketFactory());
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
|
con.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
String postData = "";
|
String postData = "";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (NameValuePair nameValuePair : parameters) {
|
for (NameValuePair nameValuePair : parameters) {
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This receiver will start the service on phone boot.
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OnBootLoader extends BroadcastReceiver {
|
||||||
|
private static String TAG = "OnBootLoader";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.i(TAG, "onReceive: starting service");
|
||||||
|
Core.setFetchFrequency(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -32,6 +32,7 @@ import android.media.RingtoneManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -53,8 +54,10 @@ import android.widget.Toast;
|
|||||||
public class Options extends Activity {
|
public class Options extends Activity {
|
||||||
private static String TAG = "Options";
|
private static String TAG = "Options";
|
||||||
private static int RINGTONE_PICK_CODE = 999;
|
private static int RINGTONE_PICK_CODE = 999;
|
||||||
|
private static long DIALOG_TIME = 10000;
|
||||||
private TextView connectionStatus;
|
private TextView connectionStatus;
|
||||||
private ProgressDialog retrievingCertificate;
|
private ProgressDialog retrievingCertificate;
|
||||||
|
private CheckCertificateAsyncTask asyncTask;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
@ -166,8 +169,9 @@ public class Options extends Activity {
|
|||||||
try {
|
try {
|
||||||
retrievingCertificate = ProgressDialog.show(this, "",
|
retrievingCertificate = ProgressDialog.show(this, "",
|
||||||
"Loading...", true);
|
"Loading...", true);
|
||||||
new CheckCertificateAsyncTask()
|
asyncTask = new CheckCertificateAsyncTask();
|
||||||
.execute(new URL[] { new URL(url) });
|
asyncTask.execute(new URL[] { new URL(url) });
|
||||||
|
removeDialog(DIALOG_TIME, retrievingCertificate);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
@ -348,7 +352,7 @@ public class Options extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
retrievingCertificate.dismiss();
|
retrievingCertificate.cancel();
|
||||||
if (!online) {
|
if (!online) {
|
||||||
writeChanges();
|
writeChanges();
|
||||||
} else {
|
} else {
|
||||||
@ -383,4 +387,23 @@ public class Options extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a dialog after a timeout.
|
||||||
|
*
|
||||||
|
* @param time
|
||||||
|
* @param dialog
|
||||||
|
*/
|
||||||
|
public void removeDialog(long time, final ProgressDialog dialog) {
|
||||||
|
Handler handler = new Handler();
|
||||||
|
handler.postDelayed(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
dialog.dismiss();
|
||||||
|
if (asyncTask.cancel(false)) {
|
||||||
|
Toast.makeText(getApplicationContext(),
|
||||||
|
"Connection timeout", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package pandroid_event_viewer.pandorafms;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -196,66 +197,69 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
* @param intent
|
* @param intent
|
||||||
*/
|
*/
|
||||||
private void process_notification(Intent intent) {
|
private void process_notification(Intent intent) {
|
||||||
long count_events = intent.getLongExtra("count_events", 0);
|
|
||||||
int more_criticity = intent.getIntExtra("more_criticity", -1);
|
int more_criticity = intent.getIntExtra("more_criticity", -1);
|
||||||
|
|
||||||
CharSequence text;
|
CharSequence text;
|
||||||
|
|
||||||
if (count_events > 0) {
|
// From the notification
|
||||||
// From the notificy
|
switch (more_criticity) {
|
||||||
switch (more_criticity) {
|
case 0:
|
||||||
case 0:
|
text = getString(R.string.loading_events_criticity_0_str);
|
||||||
text = getString(R.string.loading_events_criticity_0_str)
|
break;
|
||||||
.replace("%s", new Long(count_events).toString());
|
case 1:
|
||||||
break;
|
text = getString(R.string.loading_events_criticity_1_str);
|
||||||
case 1:
|
break;
|
||||||
text = getString(R.string.loading_events_criticity_1_str)
|
case 2:
|
||||||
.replace("%s", new Long(count_events).toString());
|
text = getString(R.string.loading_events_criticity_2_str);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 3:
|
||||||
text = getString(R.string.loading_events_criticity_2_str)
|
text = getString(R.string.loading_events_criticity_3_str);
|
||||||
.replace("%s", new Long(count_events).toString());
|
break;
|
||||||
break;
|
case 4:
|
||||||
case 3:
|
text = getString(R.string.loading_events_criticity_4_str);
|
||||||
text = getString(R.string.loading_events_criticity_3_str)
|
break;
|
||||||
.replace("%s", new Long(count_events).toString());
|
default:
|
||||||
break;
|
text = getString(R.string.loading_events_criticity_2_str);
|
||||||
case 4:
|
break;
|
||||||
text = getString(R.string.loading_events_criticity_4_str)
|
}
|
||||||
.replace("%s", new Long(count_events).toString());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
text = getString(R.string.loading_events_criticity_2_str)
|
|
||||||
.replace("%s", new Long(count_events).toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast toast = Toast.makeText(getApplicationContext(), text,
|
Toast toast = Toast.makeText(getApplicationContext(), text,
|
||||||
Toast.LENGTH_SHORT);
|
Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
|
|
||||||
// Set the same parameters to extract the events of the
|
// Set the same parameters to extract the events of the
|
||||||
// notification.
|
// notification.
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
getString(R.string.const_string_preferences),
|
getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
long timestamp_notification = preferences.getLong(
|
long timestamp_notification = preferences.getLong("filterTimestamp",
|
||||||
"previous_filterTimestamp", (new Date().getTime() / 1000));
|
(new Date().getTime() / 1000));
|
||||||
Log.i(TAG + " process_notification_timestamp", ""
|
Log.i(TAG + " process_notification_timestamp", ""
|
||||||
+ timestamp_notification);
|
+ timestamp_notification);
|
||||||
this.timestamp = timestamp_notification;
|
this.timestamp = timestamp_notification;
|
||||||
this.agentNameStr = preferences.getString("filterAgentName", "");
|
this.agentNameStr = preferences.getString("filterAgentName", "");
|
||||||
this.id_group = preferences.getInt("filterIDGroup", 0);
|
this.id_group = preferences.getInt("filterIDGroup", 0);
|
||||||
this.severity = preferences.getInt("filterSeverity", -1);
|
this.severity = preferences.getInt("filterSeverity", -1);
|
||||||
this.status = preferences.getInt("filterStatus", 3);
|
this.status = preferences.getInt("filterStatus", 3);
|
||||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||||
|
|
||||||
this.getTabHost().setCurrentTab(1);
|
this.getTabHost().setCurrentTab(1);
|
||||||
|
|
||||||
this.loadInProgress = true;
|
this.loadInProgress = true;
|
||||||
this.getNewListEvents = true;
|
this.getNewListEvents = true;
|
||||||
this.eventList = new ArrayList<EventListItem>();
|
this.eventList = new ArrayList<EventListItem>();
|
||||||
executeBackgroundGetEvents(true);
|
executeBackgroundGetEvents(true);
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
long now = (c.getTimeInMillis() / 1000);
|
||||||
|
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||||
|
// Save for the next execution
|
||||||
|
editorPreferences.putLong("filterTimestamp", now);
|
||||||
|
// Save the previous for the list.
|
||||||
|
editorPreferences.putLong("previous_filterTimestamp",
|
||||||
|
timestamp_notification);
|
||||||
|
if (editorPreferences.commit()) {
|
||||||
|
Log.i(TAG + " (filter options)",
|
||||||
|
"Configuration changes commited (timestamp)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +303,7 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
serializeParams2Api(true));
|
serializeParams2Api(true));
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
try {
|
try {
|
||||||
this.count_events = new Long(return_api).longValue();
|
this.count_events = Long.valueOf(return_api);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
return;
|
return;
|
||||||
@ -350,67 +354,67 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
String[] items = lines[i].split(";");
|
String[] items = lines[i].split(";");
|
||||||
|
|
||||||
EventListItem event = new EventListItem();
|
EventListItem event = new EventListItem();
|
||||||
try {
|
try {
|
||||||
if (items[0].length() == 0) {
|
if (items[0].length() == 0) {
|
||||||
event.id_event = 0;
|
event.id_event = 0;
|
||||||
} else {
|
} else {
|
||||||
event.id_event = Integer.parseInt(items[0]);
|
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;
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
event.event = getApplication().getString(
|
|
||||||
R.string.unknown_event_str);
|
|
||||||
launchProblemParsingNotification();
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
event.event = getApplication().getString(
|
||||||
|
R.string.unknown_event_str);
|
||||||
|
launchProblemParsingNotification();
|
||||||
|
}
|
||||||
this.eventList.add(event);
|
this.eventList.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@ -109,13 +110,13 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
Log.i(TAG + " checkNewEvents", return_api);
|
Log.i(TAG + " checkNewEvents", return_api);
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
try {
|
try {
|
||||||
this.count_events = new Long(return_api).longValue();
|
this.count_events = Long.valueOf(return_api);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, e.getMessage());
|
Log.e(TAG, e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the event more critical
|
// Check the more critical level
|
||||||
if (this.count_events != 0) {
|
if (this.count_events != 0) {
|
||||||
Log.i(TAG, "There are new events");
|
Log.i(TAG, "There are new events");
|
||||||
parameters = new ArrayList<NameValuePair>();
|
parameters = new ArrayList<NameValuePair>();
|
||||||
@ -128,8 +129,22 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
serializeParams2Api(context, false, true, true)));
|
serializeParams2Api(context, false, true, true)));
|
||||||
return_api = Core.httpGet(getApplicationContext(), parameters);
|
return_api = Core.httpGet(getApplicationContext(), parameters);
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
this.more_criticity = Integer.valueOf(return_api).intValue();
|
try {
|
||||||
notificationEvent(context);
|
this.more_criticity = Integer.valueOf(return_api)
|
||||||
|
.intValue();
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long lastCountEvents = preferences.getLong("last_count_events", 0);
|
||||||
|
// Does not repeat the same notification
|
||||||
|
if (lastCountEvents != count_events) {
|
||||||
|
notificationEvent(context);
|
||||||
|
Editor editor = preferences.edit();
|
||||||
|
editor.putLong("last_count_events", count_events);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.more_criticity = -1;
|
this.more_criticity = -1;
|
||||||
|
|
||||||
@ -173,21 +188,6 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
long now = (c.getTimeInMillis() / 1000);
|
long now = (c.getTimeInMillis() / 1000);
|
||||||
long filterTimestamp = preferences.getLong("filterTimestamp", now);
|
long filterTimestamp = preferences.getLong("filterTimestamp", now);
|
||||||
if (updateTime) {
|
|
||||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
|
||||||
// Save for the next execution
|
|
||||||
editorPreferences.putLong("filterTimestamp", now);
|
|
||||||
// Save the previous for the list.
|
|
||||||
editorPreferences.putLong("previous_filterTimestamp",
|
|
||||||
filterTimestamp);
|
|
||||||
if (editorPreferences.commit()) {
|
|
||||||
Log.i(TAG + " (filter options)",
|
|
||||||
"Configuration changes commited (timestamp)");
|
|
||||||
} else {
|
|
||||||
Log.e(TAG + " (filter options)",
|
|
||||||
"Configuration changes not commited");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String totalStr = (total) ? "total" : "-1";
|
String totalStr = (total) ? "total" : "-1";
|
||||||
if (more_criticity) {
|
if (more_criticity) {
|
||||||
totalStr = "more_criticity";
|
totalStr = "more_criticity";
|
||||||
@ -231,37 +231,37 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
icon = R.drawable.criticity_0;
|
icon = R.drawable.criticity_0;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_0_str).replace("%s",
|
R.string.notification_criticity_0_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
icon = R.drawable.criticity_1;
|
icon = R.drawable.criticity_1;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_1_str).replace("%s",
|
R.string.notification_criticity_1_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
icon = R.drawable.criticity_2;
|
icon = R.drawable.criticity_2;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_2_str).replace("%s",
|
R.string.notification_criticity_2_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
icon = R.drawable.criticity_3;
|
icon = R.drawable.criticity_3;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_3_str).replace("%s",
|
R.string.notification_criticity_3_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
icon = R.drawable.criticity_4;
|
icon = R.drawable.criticity_4;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_4_str).replace("%s",
|
R.string.notification_criticity_4_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
icon = R.drawable.criticity_default;
|
icon = R.drawable.criticity_default;
|
||||||
tickerText = context.getString(
|
tickerText = context.getString(
|
||||||
R.string.notification_criticity_2_str).replace("%s",
|
R.string.notification_criticity_2_str).replace("%s",
|
||||||
new Long(this.count_events).toString());
|
Long.valueOf(this.count_events).toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,6 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
if (preferences.getBoolean("vibration", true)) {
|
if (preferences.getBoolean("vibration", true)) {
|
||||||
Log.d(TAG, "Vibration");
|
Log.d(TAG, "Vibration");
|
||||||
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "No vibration");
|
Log.d(TAG, "No vibration");
|
||||||
notification.vibrate = new long[] { 0, 0, 0, 0 };
|
notification.vibrate = new long[] { 0, 0, 0, 0 };
|
||||||
@ -300,7 +299,6 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
PandroidEventviewerActivity.class);
|
PandroidEventviewerActivity.class);
|
||||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
notificationIntent.putExtra("count_events", this.count_events);
|
|
||||||
notificationIntent.putExtra("more_criticity", this.more_criticity);
|
notificationIntent.putExtra("more_criticity", this.more_criticity);
|
||||||
|
|
||||||
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
|
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
|
||||||
@ -311,7 +309,7 @@ public class PandroidEventviewerService extends IntentService {
|
|||||||
|
|
||||||
notification.setLatestEventInfo(context, title, tickerText,
|
notification.setLatestEventInfo(context, title, tickerText,
|
||||||
contentIntent);
|
contentIntent);
|
||||||
Log.i(TAG, "Launching notification");
|
Log.i(TAG, "Launching notification, number of events: " + count_events);
|
||||||
mNotificationManager.notify(NOTIFICATION_PANDROID_EVENT_VIEWER,
|
mNotificationManager.notify(NOTIFICATION_PANDROID_EVENT_VIEWER,
|
||||||
notification);
|
notification);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user