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