android: Add fields for local and remote identities to data model
authorTobias Brunner <tobias@strongswan.org>
Fri, 29 Apr 2016 10:27:38 +0000 (12:27 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 May 2016 16:38:15 +0000 (18:38 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfile.java
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfileDataSource.java

index 5c64ad0..8a9d319 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (C) 2012-2015 Tobias Brunner
+ * Copyright (C) 2012-2016 Tobias Brunner
  * Copyright (C) 2012 Giuliano Grassi
  * Copyright (C) 2012 Ralf Sager
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -25,6 +25,7 @@ public class VpnProfile implements Cloneable
        public static final int SPLIT_TUNNELING_BLOCK_IPV6 = 2;
 
        private String mName, mGateway, mUsername, mPassword, mCertificate, mUserCertificate;
+       private String mRemoteId, mLocalId;
        private Integer mMTU, mPort, mSplitTunneling;
        private VpnType mVpnType;
        private long mId = -1;
@@ -109,6 +110,26 @@ public class VpnProfile implements Cloneable
                this.mUserCertificate = alias;
        }
 
+       public String getLocalId()
+       {
+               return mLocalId;
+       }
+
+       public void setLocalId(String localId)
+       {
+               this.mLocalId = localId;
+       }
+
+       public String getRemoteId()
+       {
+               return mRemoteId;
+       }
+
+       public void setRemoteId(String remoteId)
+       {
+               this.mRemoteId = remoteId;
+       }
+
        public Integer getMTU()
        {
                return mMTU;
index 45e9b86..1702653 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (C) 2012-2015 Tobias Brunner
+ * Copyright (C) 2012-2016 Tobias Brunner
  * Copyright (C) 2012 Giuliano Grassi
  * Copyright (C) 2012 Ralf Sager
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -43,6 +43,8 @@ public class VpnProfileDataSource
        public static final String KEY_MTU = "mtu";
        public static final String KEY_PORT = "port";
        public static final String KEY_SPLIT_TUNNELING = "split_tunneling";
+       public static final String KEY_LOCAL_ID = "local_id";
+       public static final String KEY_REMOTE_ID = "remote_id";
 
        private DatabaseHelper mDbHelper;
        private SQLiteDatabase mDatabase;
@@ -51,7 +53,7 @@ public class VpnProfileDataSource
        private static final String DATABASE_NAME = "strongswan.db";
        private static final String TABLE_VPNPROFILE = "vpnprofile";
 
-       private static final int DATABASE_VERSION = 7;
+       private static final int DATABASE_VERSION = 8;
 
        public static final String DATABASE_CREATE =
                                                        "CREATE TABLE " + TABLE_VPNPROFILE + " (" +
@@ -65,7 +67,9 @@ public class VpnProfileDataSource
                                                                KEY_USER_CERTIFICATE + " TEXT," +
                                                                KEY_MTU + " INTEGER," +
                                                                KEY_PORT + " INTEGER," +
-                                                               KEY_SPLIT_TUNNELING + " INTEGER" +
+                                                               KEY_SPLIT_TUNNELING + " INTEGER," +
+                                                               KEY_LOCAL_ID + " TEXT," +
+                                                               KEY_REMOTE_ID + " TEXT" +
                                                        ");";
        private static final String[] ALL_COLUMNS = new String[] {
                                                                KEY_ID,
@@ -79,6 +83,8 @@ public class VpnProfileDataSource
                                                                KEY_MTU,
                                                                KEY_PORT,
                                                                KEY_SPLIT_TUNNELING,
+                                                               KEY_LOCAL_ID,
+                                                               KEY_REMOTE_ID,
                                                        };
 
        private static class DatabaseHelper extends SQLiteOpenHelper
@@ -128,6 +134,13 @@ public class VpnProfileDataSource
                                db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_SPLIT_TUNNELING +
                                                   " INTEGER;");
                        }
+                       if (oldVersion < 8)
+                       {
+                               db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_LOCAL_ID +
+                                                  " TEXT;");
+                               db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_REMOTE_ID +
+                                                  " TEXT;");
+                       }
                }
 
                private void updateColumns(SQLiteDatabase db)
@@ -282,6 +295,8 @@ public class VpnProfileDataSource
                profile.setMTU(getInt(cursor, cursor.getColumnIndex(KEY_MTU)));
                profile.setPort(getInt(cursor, cursor.getColumnIndex(KEY_PORT)));
                profile.setSplitTunneling(getInt(cursor, cursor.getColumnIndex(KEY_SPLIT_TUNNELING)));
+               profile.setLocalId(cursor.getString(cursor.getColumnIndex(KEY_LOCAL_ID)));
+               profile.setRemoteId(cursor.getString(cursor.getColumnIndex(KEY_REMOTE_ID)));
                return profile;
        }
 
@@ -298,6 +313,8 @@ public class VpnProfileDataSource
                values.put(KEY_MTU, profile.getMTU());
                values.put(KEY_PORT, profile.getPort());
                values.put(KEY_SPLIT_TUNNELING, profile.getSplitTunneling());
+               values.put(KEY_LOCAL_ID, profile.getLocalId());
+               values.put(KEY_REMOTE_ID, profile.getRemoteId());
                return values;
        }