mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
* res/layout/main.xml: removed the typo bug. * src/pandroid_event_viewer/pandorafms/Core.java, src/pandroid_event_viewer/pandorafms/API.java, src/pandroid_event_viewer/pandorafms/About.java, src/pandroid_event_viewer/pandorafms/EventList.java: fixed the code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8942 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
1a9d58e3af
commit
dfa8f6f840
@ -1,3 +1,13 @@
|
|||||||
|
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* res/layout/main.xml: removed the typo bug.
|
||||||
|
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Core.java,
|
||||||
|
src/pandroid_event_viewer/pandorafms/API.java,
|
||||||
|
src/pandroid_event_viewer/pandorafms/About.java,
|
||||||
|
src/pandroid_event_viewer/pandorafms/EventList.java: fixed the code
|
||||||
|
style.
|
||||||
|
|
||||||
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* .classpath: removed the entry for ".svn" folder
|
* .classpath: removed the entry for ".svn" folder
|
||||||
|
@ -232,7 +232,6 @@
|
|||||||
android:stretchColumns="0,1" >
|
android:stretchColumns="0,1" >
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
@ -250,7 +249,6 @@
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ public class API {
|
|||||||
String[] groups = lines[i].split(";", 21);
|
String[] groups = lines[i].split(";", 21);
|
||||||
result.put(Integer.valueOf(groups[0]), groups[1]);
|
result.put(Integer.valueOf(groups[0]), groups[1]);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "Problem parsing number in response");
|
Log.e(TAG, "Problem parsing number in response");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -61,6 +62,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
public static Map<Integer, String> getAgents(Context context)
|
public static Map<Integer, String> getAgents(Context context)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
Map<Integer, String> result = new HashMap<Integer, String>();
|
Map<Integer, String> result = new HashMap<Integer, String>();
|
||||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||||
parameters.add(new BasicNameValuePair("op", "get"));
|
parameters.add(new BasicNameValuePair("op", "get"));
|
||||||
@ -96,10 +98,12 @@ public class API {
|
|||||||
String[] lines = return_api.split(",");
|
String[] lines = return_api.split(",");
|
||||||
if (lines.length == 3) {
|
if (lines.length == 3) {
|
||||||
return lines[1];
|
return lines[1];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return context.getString(R.string.unknown_version);
|
return context.getString(R.string.unknown_version);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,8 +153,8 @@ public class API {
|
|||||||
parameters.add(new BasicNameValuePair("other",
|
parameters.add(new BasicNameValuePair("other",
|
||||||
serializeEventsParamsToAPI(filterAgentName, idGroup,
|
serializeEventsParamsToAPI(filterAgentName, idGroup,
|
||||||
filterSeverity, filterStatus, filterEventSearch,
|
filterSeverity, filterStatus, filterEventSearch,
|
||||||
filterTag, filterTimestamp, itemsPerPage, offset,
|
filterTag, filterTimestamp, itemsPerPage, offset, total,
|
||||||
total, more_criticity)));
|
more_criticity)));
|
||||||
return Core.httpGet(context, parameters);
|
return Core.httpGet(context, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +180,8 @@ public class API {
|
|||||||
String[] tags = lines[i].split(";", 2);
|
String[] tags = lines[i].split(";", 2);
|
||||||
array.add(tags[1]);
|
array.add(tags[1]);
|
||||||
}
|
}
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
}
|
||||||
|
catch (ArrayIndexOutOfBoundsException e) {
|
||||||
Log.e(TAG, "There was a problem getting tags: " + e.getMessage());
|
Log.e(TAG, "There was a problem getting tags: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
@ -195,6 +200,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
public static void createNewIncident(Context context,
|
public static void createNewIncident(Context context,
|
||||||
String[] incidentParameters) throws IOException {
|
String[] incidentParameters) throws IOException {
|
||||||
|
|
||||||
Log.i(TAG, "Sending new incident");
|
Log.i(TAG, "Sending new incident");
|
||||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||||
parameters.add(new BasicNameValuePair("op", "set"));
|
parameters.add(new BasicNameValuePair("op", "set"));
|
||||||
@ -221,6 +227,7 @@ public class API {
|
|||||||
*/
|
*/
|
||||||
public static boolean validateEvent(Context context, int idEvent,
|
public static boolean validateEvent(Context context, int idEvent,
|
||||||
String comment) throws IOException {
|
String comment) throws IOException {
|
||||||
|
|
||||||
List<NameValuePair> parameters;
|
List<NameValuePair> parameters;
|
||||||
// Set event validation.
|
// Set event validation.
|
||||||
parameters = new ArrayList<NameValuePair>();
|
parameters = new ArrayList<NameValuePair>();
|
||||||
@ -233,7 +240,8 @@ public class API {
|
|||||||
|
|
||||||
if (return_api.startsWith("Correct validation")) {
|
if (return_api.startsWith("Correct validation")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,8 +283,8 @@ public class API {
|
|||||||
if (more_criticity) {
|
if (more_criticity) {
|
||||||
totalStr = "more_criticity";
|
totalStr = "more_criticity";
|
||||||
}
|
}
|
||||||
return Core.serializeParams2Api(new String[] { ";", // Separator for the
|
return Core.serializeParams2Api(new String[] {
|
||||||
// csv
|
";", // Separator for the csv
|
||||||
Integer.toString(filterSeverity), // criticity or severity
|
Integer.toString(filterSeverity), // criticity or severity
|
||||||
filterAgentName, // The agent name
|
filterAgentName, // The agent name
|
||||||
"", // Name of module
|
"", // Name of module
|
||||||
|
@ -57,7 +57,8 @@ public class About extends Activity {
|
|||||||
.edit();
|
.edit();
|
||||||
editorPreferences.putBoolean("show_popup_info", false);
|
editorPreferences.putBoolean("show_popup_info", false);
|
||||||
editorPreferences.commit();
|
editorPreferences.commit();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
getString(R.string.const_string_preferences),
|
getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
|
@ -89,8 +89,8 @@ public class Core {
|
|||||||
* @return A string with all data read.
|
* @return A string with all data read.
|
||||||
*/
|
*/
|
||||||
private static String convertStreamToString(InputStream is) {
|
private static String convertStreamToString(InputStream is) {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is),
|
BufferedReader reader = new BufferedReader(
|
||||||
8 * 1024);
|
new InputStreamReader(is), 8 * 1024);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
String line = null;
|
String line = null;
|
||||||
@ -98,12 +98,15 @@ public class Core {
|
|||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
sb.append(line + "\n");
|
sb.append(line + "\n");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +141,8 @@ public class Core {
|
|||||||
|
|
||||||
alarmM.setRepeating(AlarmManager.RTC_WAKEUP,
|
alarmM.setRepeating(AlarmManager.RTC_WAKEUP,
|
||||||
System.currentTimeMillis(), sleepTimeAlarm, pandroidService);
|
System.currentTimeMillis(), sleepTimeAlarm, pandroidService);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Log.i(TAG,
|
Log.i(TAG,
|
||||||
"Service wasn't started because the options aren't configured yet");
|
"Service wasn't started because the options aren't configured yet");
|
||||||
}
|
}
|
||||||
@ -163,6 +167,7 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static long convertMaxTimeOldEventValuesToTimestamp(long time,
|
public static long convertMaxTimeOldEventValuesToTimestamp(long time,
|
||||||
int arrayKey) {
|
int arrayKey) {
|
||||||
|
|
||||||
long return_var = 0;
|
long return_var = 0;
|
||||||
|
|
||||||
if (time == 0) {
|
if (time == 0) {
|
||||||
@ -317,7 +322,9 @@ public class Core {
|
|||||||
for (int i = 1; i < params.length; i++) {
|
for (int i = 1; i < params.length; i++) {
|
||||||
return_var += "|" + params[i];
|
return_var += "|" + params[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG + " serializeParams2Api", return_var);
|
Log.i(TAG + " serializeParams2Api", return_var);
|
||||||
|
|
||||||
return return_var;
|
return return_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,6 +341,7 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static String httpGet(Context context,
|
public static String httpGet(Context context,
|
||||||
List<NameValuePair> additionalParameters) throws IOException {
|
List<NameValuePair> additionalParameters) throws IOException {
|
||||||
|
|
||||||
SharedPreferences preferences = context.getSharedPreferences(
|
SharedPreferences preferences = context.getSharedPreferences(
|
||||||
context.getString(R.string.const_string_preferences),
|
context.getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
@ -356,7 +364,8 @@ public class Core {
|
|||||||
if (url.toLowerCase().contains("https")) {
|
if (url.toLowerCase().contains("https")) {
|
||||||
// Secure connection
|
// Secure connection
|
||||||
return Core.httpsGet(url, parameters);
|
return Core.httpsGet(url, parameters);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
HttpParams params = new BasicHttpParams();
|
HttpParams params = new BasicHttpParams();
|
||||||
HttpConnectionParams.setConnectionTimeout(params,
|
HttpConnectionParams.setConnectionTimeout(params,
|
||||||
CONNECTION_TIMEOUT);
|
CONNECTION_TIMEOUT);
|
||||||
@ -408,7 +417,8 @@ public class Core {
|
|||||||
Bitmap img = BitmapFactory.decodeStream(con.getInputStream());
|
Bitmap img = BitmapFactory.decodeStream(con.getInputStream());
|
||||||
imgCache.put(fileUrl, img);
|
imgCache.put(fileUrl, img);
|
||||||
return img;
|
return img;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
HttpURLConnection conn = (HttpURLConnection) myFileUrl
|
||||||
.openConnection();
|
.openConnection();
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
@ -419,7 +429,8 @@ public class Core {
|
|||||||
imgCache.put(fileUrl, img);
|
imgCache.put(fileUrl, img);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
Log.e(TAG, "Downloading image " + fileUrl + ": error");
|
Log.e(TAG, "Downloading image " + fileUrl + ": error");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -463,6 +474,7 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static void setTextViewLeftImage(TextView view, Drawable image,
|
public static void setTextViewLeftImage(TextView view, Drawable image,
|
||||||
int size) {
|
int size) {
|
||||||
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
image.setBounds(0, 0, size, size);
|
image.setBounds(0, 0, size, size);
|
||||||
view.setCompoundDrawables(image, null, null, null);
|
view.setCompoundDrawables(image, null, null, null);
|
||||||
@ -479,13 +491,16 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static boolean isValidCertificate(URL url) {
|
public static boolean isValidCertificate(URL url) {
|
||||||
HttpsURLConnection con;
|
HttpsURLConnection con;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
con = (HttpsURLConnection) url.openConnection();
|
con = (HttpsURLConnection) url.openConnection();
|
||||||
con.setConnectTimeout(CONNECTION_TIMEOUT);
|
con.setConnectTimeout(CONNECTION_TIMEOUT);
|
||||||
con.connect();
|
con.connect();
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -508,8 +523,10 @@ public class Core {
|
|||||||
con.setSSLSocketFactory(getSocketFactory());
|
con.setSSLSocketFactory(getSocketFactory());
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
con.getInputStream();
|
con.getInputStream();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,6 +545,7 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
private static String httpsGet(String url, List<NameValuePair> parameters)
|
private static String httpsGet(String url, List<NameValuePair> parameters)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
String result = "";
|
String result = "";
|
||||||
HttpsURLConnection con;
|
HttpsURLConnection con;
|
||||||
try {
|
try {
|
||||||
@ -545,8 +563,8 @@ public class Core {
|
|||||||
for (NameValuePair nameValuePair : parameters) {
|
for (NameValuePair nameValuePair : parameters) {
|
||||||
postData = first ? postData : postData + "&";
|
postData = first ? postData : postData + "&";
|
||||||
first = false;
|
first = false;
|
||||||
postData += URLEncoder.encode(nameValuePair.getName()) + "="
|
postData += URLEncoder.encode(nameValuePair.getName())
|
||||||
+ URLEncoder.encode(nameValuePair.getValue());
|
+ "=" + URLEncoder.encode(nameValuePair.getValue());
|
||||||
}
|
}
|
||||||
if (postData.length() > 0) {
|
if (postData.length() > 0) {
|
||||||
OutputStreamWriter wr = new OutputStreamWriter(
|
OutputStreamWriter wr = new OutputStreamWriter(
|
||||||
@ -564,10 +582,12 @@ public class Core {
|
|||||||
Log.d("CONTENT", temp);
|
Log.d("CONTENT", temp);
|
||||||
result += temp + "\n";
|
result += temp + "\n";
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
}
|
||||||
|
catch (MalformedURLException e) {
|
||||||
// Can't reach here because the given url is checked when is
|
// Can't reach here because the given url is checked when is
|
||||||
// inserted in Options activity.
|
// inserted in Options activity.
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,14 +606,17 @@ public class Core {
|
|||||||
sslSocketFactory = (SSLSocketFactory) context
|
sslSocketFactory = (SSLSocketFactory) context
|
||||||
.getSocketFactory();
|
.getSocketFactory();
|
||||||
|
|
||||||
} catch (KeyManagementException e) {
|
}
|
||||||
|
catch (KeyManagementException e) {
|
||||||
Log.e("No SSL algorithm support: " + e.getMessage(),
|
Log.e("No SSL algorithm support: " + e.getMessage(),
|
||||||
e.toString());
|
e.toString());
|
||||||
} catch (NoSuchAlgorithmException e) {
|
}
|
||||||
|
catch (NoSuchAlgorithmException e) {
|
||||||
Log.e("Exception when setting up the Naive key management.",
|
Log.e("Exception when setting up the Naive key management.",
|
||||||
e.toString());
|
e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sslSocketFactory;
|
return sslSocketFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,15 +632,18 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static void showConnectionProblemToast(Context context,
|
public static void showConnectionProblemToast(Context context,
|
||||||
boolean ignoreConnectionCheck) {
|
boolean ignoreConnectionCheck) {
|
||||||
|
|
||||||
SharedPreferences preferences = context.getSharedPreferences(
|
SharedPreferences preferences = context.getSharedPreferences(
|
||||||
context.getString(R.string.const_string_preferences),
|
context.getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
if (preferences.getBoolean("online", false)) {
|
if (preferences.getBoolean("online", false)) {
|
||||||
Toast.makeText(context, R.string.connection_problem,
|
Toast.makeText(context, R.string.connection_problem,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (ignoreConnectionCheck) {
|
if (ignoreConnectionCheck) {
|
||||||
Toast.makeText(context, R.string.connection_settings_problem,
|
Toast.makeText(context,
|
||||||
|
R.string.connection_settings_problem,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -703,7 +729,8 @@ public class Core {
|
|||||||
Integer code = images.get(eventType.toLowerCase());
|
Integer code = images.get(eventType.toLowerCase());
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
return context.getResources().getDrawable(code);
|
return context.getResources().getDrawable(code);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,11 +392,11 @@ public class EventList extends ListActivity {
|
|||||||
content_event_item.setVisibility(RelativeLayout.GONE);
|
content_event_item.setVisibility(RelativeLayout.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final EventListItem item = this.object.eventList.get(position);
|
final EventListItem item = this.object.eventList.get(position);
|
||||||
|
|
||||||
switch (item.criticity) {
|
switch (item.criticity) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
view.setBackgroundColor(getResources().getColor(
|
view.setBackgroundColor(getResources().getColor(
|
||||||
R.color.Blue));
|
R.color.Blue));
|
||||||
@ -427,7 +427,8 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
if (item.event_type.equals("system")) {
|
if (item.event_type.equals("system")) {
|
||||||
titulo.setText(R.string.system_str);
|
titulo.setText(R.string.system_str);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
titulo.setText(item.agent_name);
|
titulo.setText(item.agent_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user