]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Add data source to VpnProfile
authorMarkus Pfeiffer <markus.pfeiffer@relution.io>
Tue, 21 Nov 2023 14:37:21 +0000 (15:37 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2024 11:24:53 +0000 (12:24 +0100)
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfile.java
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfileSource.java
src/frontends/android/app/src/main/java/org/strongswan/android/data/VpnProfileSqlDataSource.java

index 9219b1001c8eeea8d8dbb61e081d4bf88e8bb7f4..e3ce9d4b845ef188fbaea7fff00dee9327fe2714 100644 (file)
@@ -49,6 +49,7 @@ public class VpnProfile implements Cloneable
        private UUID mUUID;
        private long mId = -1;
        private boolean mReadOnly;
+       private VpnProfileDataSource mDataSource;
 
        public enum SelectedAppsHandling
        {
@@ -342,6 +343,16 @@ public class VpnProfile implements Cloneable
                this.mReadOnly = readOnly;
        }
 
+       public VpnProfileDataSource getDataSource()
+       {
+               return mDataSource;
+       }
+
+       public void setDataSource(VpnProfileDataSource mDataSource)
+       {
+               this.mDataSource = mDataSource;
+       }
+
        @Override
        public String toString()
        {
index 4a709989ac095a9371de01c34b6d51c589eaa051..2ae0872cc9798c06410141c9cb469b2546ba9e96 100644 (file)
@@ -62,13 +62,13 @@ public class VpnProfileSource implements VpnProfileDataSource
        @Override
        public boolean updateVpnProfile(VpnProfile profile)
        {
-               return vpnProfileSqlDataSource.updateVpnProfile(profile);
+               return profile.getDataSource().updateVpnProfile(profile);
        }
 
        @Override
        public boolean deleteVpnProfile(VpnProfile profile)
        {
-               return vpnProfileSqlDataSource.deleteVpnProfile(profile);
+               return profile.getDataSource().deleteVpnProfile(profile);
        }
 
        @Override
index 0934edc3921e7e105693ab15e4639a7fa34e451f..5b1f9ad269d87acb15d28d776318f146f71744a3 100644 (file)
@@ -291,6 +291,7 @@ public class VpnProfileSqlDataSource implements VpnProfileDataSource
                {
                        return null;
                }
+               profile.setDataSource(this);
                profile.setId(insertId);
                return profile;
        }
@@ -319,6 +320,7 @@ public class VpnProfileSqlDataSource implements VpnProfileDataSource
                if (cursor.moveToFirst())
                {
                        profile = VpnProfileFromCursor(cursor);
+                       profile.setDataSource(this);
                }
                cursor.close();
                return profile;
@@ -334,6 +336,7 @@ public class VpnProfileSqlDataSource implements VpnProfileDataSource
                while (!cursor.isAfterLast())
                {
                        VpnProfile vpnProfile = VpnProfileFromCursor(cursor);
+                       vpnProfile.setDataSource(this);
                        vpnProfiles.add(vpnProfile);
                        cursor.moveToNext();
                }