summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/de/blinkt/openvpn/LogWindow.java49
-rw-r--r--src/de/blinkt/openvpn/core/OpenVpnManagementThread.java39
-rw-r--r--src/de/blinkt/openvpn/core/VpnStatus.java10
3 files changed, 85 insertions, 13 deletions
diff --git a/src/de/blinkt/openvpn/LogWindow.java b/src/de/blinkt/openvpn/LogWindow.java
index f19e53d4..ba6e79a1 100644
--- a/src/de/blinkt/openvpn/LogWindow.java
+++ b/src/de/blinkt/openvpn/LogWindow.java
@@ -4,12 +4,16 @@ import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.*;
import android.database.DataSetObserver;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.IBinder;
import android.os.Message;
+import android.text.SpannableString;
+import android.text.Spanned;
import android.text.format.DateFormat;
+import android.text.style.ImageSpan;
import android.view.*;
import android.widget.*;
import android.widget.AdapterView.OnItemLongClickListener;
@@ -72,7 +76,6 @@ public class LogWindow extends ListActivity implements StateListener {
public LogWindowListAdapter() {
initLogBuffer();
-
if (mHandler == null) {
mHandler = new Handler(this);
}
@@ -145,6 +148,7 @@ public class LogWindow extends ListActivity implements StateListener {
LogItem le = myEntries.get(position);
String msg = le.getString(LogWindow.this);
+ String time ="";
if (mTimeFormat != 0) {
Date d = new Date(le.getLogtime());
java.text.DateFormat timeformat;
@@ -152,14 +156,49 @@ public class LogWindow extends ListActivity implements StateListener {
timeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.getDefault());
else
timeformat = DateFormat.getTimeFormat(LogWindow.this);
- String time = timeformat.format(d);
- msg = time + " " + msg;
+ time = timeformat.format(d);
+
}
- v.setText(msg);
+ msg = time + " " + msg;
+
+ int spanStart = time.length();
+
+ SpannableString t = new SpannableString(msg);
+
+ //t.setSpan(getSpanImage(le,(int)v.getTextSize()),spanStart,spanStart+1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ v.setText(t);
return v;
}
- @Override
+ private ImageSpan getSpanImage(LogItem li, int imageSize) {
+ int imageRes = android.R.drawable.ic_menu_call;
+
+ switch (li.getLogLevel()) {
+ case ERROR:
+ imageRes = android.R.drawable.ic_notification_clear_all;
+ break;
+ case INFO:
+ imageRes = android.R.drawable.ic_menu_compass;
+ break;
+ case VERBOSE:
+ imageRes = android.R.drawable.ic_menu_info_details;
+ break;
+ case WARNING:
+ imageRes = android.R.drawable.ic_menu_camera;
+ break;
+ }
+
+ Drawable d = getResources().getDrawable(imageRes);
+
+
+ //d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
+ d.setBounds(0, 0, imageSize, imageSize);
+ ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
+
+ return span;
+ }
+
+ @Override
public int getItemViewType(int position) {
return 0;
}
diff --git a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
index ffa192b5..23c6cff6 100644
--- a/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
+++ b/src/de/blinkt/openvpn/core/OpenVpnManagementThread.java
@@ -224,11 +224,7 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
} else if (cmd.equals("PROXY")) {
processProxyCMD(argument);
} else if (cmd.equals("LOG")) {
- String[] args = argument.split(",",3);
- // 0 unix time stamp
- // 1 log level N,I,E etc.
- // 2 log message
- VpnStatus.logWarning( args[2]);
+ processLogMessage(argument);
} else if (cmd.equals("RSA_SIGN")) {
processSignCommand(argument);
} else {
@@ -243,7 +239,38 @@ public class OpenVpnManagementThread implements Runnable, OpenVPNManagement {
VpnStatus.logWarning("MGMT: Got unrecognized line from management:" + command);
}
}
- private void handleHold() {
+
+ private void processLogMessage(String argument) {
+ String[] args = argument.split(",",3);
+ // 0 unix time stamp
+ // 1 log level N,I,E etc.
+ /*
+ (b) zero or more message flags in a single string:
+ I -- informational
+ F -- fatal error
+ N -- non-fatal error
+ W -- warning
+ D -- debug, and
+ */
+ // 2 log message
+
+ VpnStatus.LogLevel level;
+ if (args[1].equals("I")) {
+ level = VpnStatus.LogLevel.INFO;
+ } else if (args[1].equals("W")) {
+ level = VpnStatus.LogLevel.WARNING;
+ } else if (args[1].equals("D")) {
+ level = VpnStatus.LogLevel.VERBOSE;
+ } else if (args[1].equals("F")) {
+ level = VpnStatus.LogLevel.ERROR;
+ } else {
+ level = VpnStatus.LogLevel.INFO;
+ }
+
+ VpnStatus.logMessage(level,"P:", args[2]);
+ }
+
+ private void handleHold() {
if(mReleaseHold) {
releaseHoldCmd();
} else {
diff --git a/src/de/blinkt/openvpn/core/VpnStatus.java b/src/de/blinkt/openvpn/core/VpnStatus.java
index a83714a4..c8e5a8b1 100644
--- a/src/de/blinkt/openvpn/core/VpnStatus.java
+++ b/src/de/blinkt/openvpn/core/VpnStatus.java
@@ -193,9 +193,15 @@ public class VpnStatus {
else
throw e;
}
+
}
-
- // The lint is wrong here
+
+ public LogLevel getLogLevel()
+ {
+ return mLevel;
+ }
+
+ // The lint is wrong here
@SuppressLint("StringFormatMatches")
private String getMobileInfoString(Context c) {
c.getPackageManager();