summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/LaunchVPN.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-12-27 19:47:35 +0100
committerArne Schwabe <arne@rfc2549.org>2012-12-27 19:47:35 +0100
commitbbbefe26e6c160bca867dce3188b3679f0fcf2fc (patch)
tree8fd78a979459a78c9fad50043366e1d1d890dd68 /src/de/blinkt/openvpn/LaunchVPN.java
parent501b58833bd95950e871e83ca21b34fd72991228 (diff)
Make changes needed to provide an external API
Diffstat (limited to 'src/de/blinkt/openvpn/LaunchVPN.java')
-rw-r--r--src/de/blinkt/openvpn/LaunchVPN.java65
1 files changed, 3 insertions, 62 deletions
diff --git a/src/de/blinkt/openvpn/LaunchVPN.java b/src/de/blinkt/openvpn/LaunchVPN.java
index bc0a4cf2..e45bee3b 100644
--- a/src/de/blinkt/openvpn/LaunchVPN.java
+++ b/src/de/blinkt/openvpn/LaunchVPN.java
@@ -218,55 +218,7 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
- private boolean writeMiniVPN() {
- File mvpnout = new File(getCacheDir(),VpnProfile.MINIVPN);
- if (mvpnout.exists() && mvpnout.canExecute())
- return true;
-
- IOException e2 = null;
-
- try {
-
-
- InputStream mvpn;
-
- try {
- mvpn = getAssets().open("minivpn." + Build.CPU_ABI);
- }
- catch (IOException errabi) {
- OpenVPN.logInfo("Failed getting assets for archicture " + Build.CPU_ABI);
- e2=errabi;
- mvpn = getAssets().open("minivpn." + Build.CPU_ABI2);
-
- }
-
-
- FileOutputStream fout = new FileOutputStream(mvpnout);
-
- byte buf[]= new byte[4096];
-
- int lenread = mvpn.read(buf);
- while(lenread> 0) {
- fout.write(buf, 0, lenread);
- lenread = mvpn.read(buf);
- }
- fout.close();
-
- if(!mvpnout.setExecutable(true)) {
- OpenVPN.logMessage(0, "","Failed to set minivpn executable");
- return false;
- }
-
-
- return true;
- } catch (IOException e) {
- if(e2!=null)
- OpenVPN.logMessage(0, "",e2.getLocalizedMessage());
- OpenVPN.logMessage(0, "",e.getLocalizedMessage());
- e.printStackTrace();
- return false;
- }
- }
+
private void askForPW(final int type) {
@@ -407,22 +359,11 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
@Override
public void run() {
- startOpenVpn();
- }
-
- void startOpenVpn() {
- if(!writeMiniVPN()) {
- OpenVPN.logMessage(0, "", "Error writing minivpn binary");
- return;
- }
- OpenVPN.logMessage(0, "", getString(R.string.building_configration));
-
- Intent startVPN = mSelectedProfile.prepareIntent(getBaseContext());
- if(startVPN!=null)
- startService(startVPN);
+ VPNLaunchHelper.startOpenVpn(mSelectedProfile, getBaseContext());
finish();
}
+
}