android: Add field for server port to data model
This commit is contained in:
parent
4d02c49ead
commit
5b11855f26
|
@ -20,7 +20,7 @@ package org.strongswan.android.data;
|
|||
public class VpnProfile implements Cloneable
|
||||
{
|
||||
private String mName, mGateway, mUsername, mPassword, mCertificate, mUserCertificate;
|
||||
private Integer mMTU;
|
||||
private Integer mMTU, mPort;
|
||||
private VpnType mVpnType;
|
||||
private long mId = -1;
|
||||
|
||||
|
@ -114,6 +114,16 @@ public class VpnProfile implements Cloneable
|
|||
this.mMTU = mtu;
|
||||
}
|
||||
|
||||
public Integer getPort()
|
||||
{
|
||||
return mPort;
|
||||
}
|
||||
|
||||
public void setPort(Integer port)
|
||||
{
|
||||
this.mPort = port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ public class VpnProfileDataSource
|
|||
public static final String KEY_CERTIFICATE = "certificate";
|
||||
public static final String KEY_USER_CERTIFICATE = "user_certificate";
|
||||
public static final String KEY_MTU = "mtu";
|
||||
public static final String KEY_PORT = "port";
|
||||
|
||||
private DatabaseHelper mDbHelper;
|
||||
private SQLiteDatabase mDatabase;
|
||||
|
@ -49,7 +50,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 = 5;
|
||||
private static final int DATABASE_VERSION = 6;
|
||||
|
||||
public static final String DATABASE_CREATE =
|
||||
"CREATE TABLE " + TABLE_VPNPROFILE + " (" +
|
||||
|
@ -61,7 +62,8 @@ public class VpnProfileDataSource
|
|||
KEY_PASSWORD + " TEXT," +
|
||||
KEY_CERTIFICATE + " TEXT," +
|
||||
KEY_USER_CERTIFICATE + " TEXT," +
|
||||
KEY_MTU + " INTEGER" +
|
||||
KEY_MTU + " INTEGER," +
|
||||
KEY_PORT + " INTEGER" +
|
||||
");";
|
||||
private static final String[] ALL_COLUMNS = new String[] {
|
||||
KEY_ID,
|
||||
|
@ -73,6 +75,7 @@ public class VpnProfileDataSource
|
|||
KEY_CERTIFICATE,
|
||||
KEY_USER_CERTIFICATE,
|
||||
KEY_MTU,
|
||||
KEY_PORT,
|
||||
};
|
||||
|
||||
private static class DatabaseHelper extends SQLiteOpenHelper
|
||||
|
@ -112,6 +115,11 @@ public class VpnProfileDataSource
|
|||
db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_MTU +
|
||||
" INTEGER;");
|
||||
}
|
||||
if (oldVersion < 6)
|
||||
{
|
||||
db.execSQL("ALTER TABLE " + TABLE_VPNPROFILE + " ADD " + KEY_PORT +
|
||||
" INTEGER;");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateColumns(SQLiteDatabase db)
|
||||
|
@ -264,6 +272,7 @@ public class VpnProfileDataSource
|
|||
profile.setCertificateAlias(cursor.getString(cursor.getColumnIndex(KEY_CERTIFICATE)));
|
||||
profile.setUserCertificateAlias(cursor.getString(cursor.getColumnIndex(KEY_USER_CERTIFICATE)));
|
||||
profile.setMTU(getInt(cursor, cursor.getColumnIndex(KEY_MTU)));
|
||||
profile.setPort(getInt(cursor, cursor.getColumnIndex(KEY_PORT)));
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
@ -278,6 +287,7 @@ public class VpnProfileDataSource
|
|||
values.put(KEY_CERTIFICATE, profile.getCertificateAlias());
|
||||
values.put(KEY_USER_CERTIFICATE, profile.getUserCertificateAlias());
|
||||
values.put(KEY_MTU, profile.getMTU());
|
||||
values.put(KEY_PORT, profile.getPort());
|
||||
return values;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue