-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
244 additions
and
3,798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 58 additions & 46 deletions
104
...va/io/github/xsocks/database/Profile.java → .../java/io/github/xsocks/model/Profile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,117 @@ | ||
package io.github.xsocks.database; | ||
package io.github.xsocks.model; | ||
|
||
import io.realm.RealmObject; | ||
import io.realm.annotations.PrimaryKey; | ||
import io.realm.annotations.RealmClass; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
@RealmClass | ||
public class Profile extends RealmObject { | ||
@PrimaryKey | ||
public class Profile { | ||
@SerializedName("id") | ||
private int id = 0; | ||
@SerializedName("name") | ||
private String name = "Untitled"; | ||
@SerializedName("host") | ||
private String host = ""; | ||
@SerializedName("localPort") | ||
private int localPort = 1080; | ||
@SerializedName("remotePort") | ||
private int remotePort = 1073; | ||
@SerializedName("password") | ||
private String password = ""; | ||
@SerializedName("route") | ||
private String route = "all"; | ||
@SerializedName("global") | ||
private boolean global = true; | ||
@SerializedName("bypass") | ||
private boolean bypass = false; | ||
@SerializedName("udpdns") | ||
private boolean udpdns = false; | ||
private String individual = ""; | ||
|
||
public int getId() { return this.id; } | ||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public void setId(final int id) { this.id = id; } | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
public void setHost(String host) { | ||
this.host = host; | ||
} | ||
|
||
public void setName(final String name) { | ||
this.name = name; | ||
public void setLocalPort(int localPort) { | ||
this.localPort = localPort; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
public void setRemotePort(int remotePort) { | ||
this.remotePort = remotePort; | ||
} | ||
|
||
public void setHost(String host) { | ||
this.host = host; | ||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public int getLocalPort() { | ||
return localPort; | ||
public void setRoute(String route) { | ||
this.route = route; | ||
} | ||
|
||
public void setLocalPort(int localPort) { | ||
this.localPort = localPort; | ||
public void setGlobal(boolean global) { | ||
this.global = global; | ||
} | ||
|
||
public int getRemotePort() { | ||
return remotePort; | ||
public void setBypass(boolean bypass) { | ||
this.bypass = bypass; | ||
} | ||
|
||
public void setRemotePort(int remotePort) { | ||
this.remotePort = remotePort; | ||
public void setUdpdns(boolean udpdns) { | ||
this.udpdns = udpdns; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
public int getId() { | ||
return this.id; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public String getRoute() { | ||
return route; | ||
public String getHost() { | ||
return this.host; | ||
} | ||
|
||
public void setRoute(String route) { | ||
this.route = route; | ||
public int getLocalPort() { | ||
return localPort; | ||
} | ||
|
||
public boolean isGlobal() { | ||
return global; | ||
public int getRemotePort() { | ||
return remotePort; | ||
} | ||
|
||
public void setGlobal(boolean global) { | ||
this.global = global; | ||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public boolean isBypass() { | ||
return bypass; | ||
public String getRoute() { | ||
return route; | ||
} | ||
|
||
public void setBypass(boolean bypass) { | ||
this.bypass = bypass; | ||
public boolean isGlobal() { | ||
return global; | ||
} | ||
|
||
public boolean isBypass() { | ||
return bypass; | ||
} | ||
|
||
public boolean isUdpdns() { | ||
return udpdns; | ||
} | ||
|
||
public void setUdpdns(boolean udpdns) { | ||
this.udpdns = udpdns; | ||
public void setIndividual(String individual) { | ||
this.individual = individual; | ||
} | ||
|
||
public String getIndividual() { | ||
|
||
return individual; | ||
} | ||
|
||
public void setIndividual(String individual) { | ||
this.individual = individual; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.github.xsocks.model; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Profiles { | ||
@SerializedName("profiles") | ||
private List<Profile> profiles; | ||
|
||
public List<Profile> getProfiles() { | ||
return profiles; | ||
} | ||
|
||
public Profiles() { | ||
profiles = new ArrayList<>(); | ||
} | ||
|
||
public void remove(int id) { | ||
for (Profile p : profiles) { | ||
if (p.getId() == id) { | ||
profiles.remove(p); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public Profile getProfile(int id) { | ||
for (Profile p : profiles) { | ||
if (p.getId() == id) { | ||
return p; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public int getMaxId() { | ||
int max = 0; | ||
for (Profile p : profiles) { | ||
if (p.getId() > max) { | ||
max = p.getId(); | ||
} | ||
} | ||
return max; | ||
} | ||
|
||
public void addProfile(Profile profile) { | ||
profiles.add(profile); | ||
} | ||
} |
Oops, something went wrong.