summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-jni/src/into_java.rs24
-rw-r--r--mullvad-jni/src/lib.rs1
2 files changed, 25 insertions, 0 deletions
diff --git a/mullvad-jni/src/into_java.rs b/mullvad-jni/src/into_java.rs
index 06116d8c3b..c49ec4a2c8 100644
--- a/mullvad-jni/src/into_java.rs
+++ b/mullvad-jni/src/into_java.rs
@@ -8,6 +8,7 @@ use jni::{
};
use mullvad_types::{
account::AccountData,
+ location::GeoIpLocation,
relay_constraints::{Constraint, LocationConstraint, RelayConstraints, RelaySettings},
relay_list::{Relay, RelayList, RelayListCity, RelayListCountry},
settings::Settings,
@@ -215,6 +216,29 @@ impl<'env> IntoJava<'env> for TunConfig {
}
}
+impl<'env> IntoJava<'env> for GeoIpLocation {
+ type JavaType = JObject<'env>;
+
+ fn into_java(self, env: &JNIEnv<'env>) -> Self::JavaType {
+ let class = get_class("net/mullvad/mullvadvpn/model/GeoIpLocation");
+ let country = env.auto_local(JObject::from(self.country.into_java(env)));
+ let city = env.auto_local(JObject::from(self.city.into_java(env)));
+ let hostname = env.auto_local(JObject::from(self.hostname.into_java(env)));
+ let parameters = [
+ JValue::Object(country.as_obj()),
+ JValue::Object(city.as_obj()),
+ JValue::Object(hostname.as_obj()),
+ ];
+
+ env.new_object(
+ &class,
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
+ &parameters,
+ )
+ .expect("Failed to create GeoIpLocation Java object")
+ }
+}
+
impl<'env> IntoJava<'env> for RelayList {
type JavaType = JObject<'env>;
diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs
index 62a6dbe277..be695cea5e 100644
--- a/mullvad-jni/src/lib.rs
+++ b/mullvad-jni/src/lib.rs
@@ -30,6 +30,7 @@ const CLASSES_TO_LOAD: &[&str] = &[
"net/mullvad/mullvadvpn/model/AccountData",
"net/mullvad/mullvadvpn/model/Constraint$Any",
"net/mullvad/mullvadvpn/model/Constraint$Only",
+ "net/mullvad/mullvadvpn/model/GeoIpLocation",
"net/mullvad/mullvadvpn/model/InetNetwork",
"net/mullvad/mullvadvpn/model/LocationConstraint$City",
"net/mullvad/mullvadvpn/model/LocationConstraint$Country",