Page MenuHomePhabricator

D8816.id30339.diff
No OneTemporary

D8816.id30339.diff

diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt
--- a/native/android/app/CMakeLists.txt
+++ b/native/android/app/CMakeLists.txt
@@ -61,7 +61,11 @@
include(../../../shared/cmake/corrosion-cxx.cmake)
-add_library_rust(PATH ../../native_rust_library NAMESPACE comm)
+add_library_rust(
+ PATH ../../native_rust_library
+ FEATURES android
+ NAMESPACE comm
+)
# We're updating parameters below for Cmake's find_OpenSSL() function
set(OPENSSL_ROOT_DIR
diff --git a/native/android/app/build.gradle b/native/android/app/build.gradle
--- a/native/android/app/build.gradle
+++ b/native/android/app/build.gradle
@@ -384,7 +384,7 @@
def cxxBridgeCommonDir = "${nativeRustLibraryDir}/target/cxxbridge/rust"
task buildNativeRustLibrary(type: Exec) {
- commandLine "cargo", "build", "--manifest-path", nativeRustLibraryManifestPath
+ commandLine "cargo", "build", "--features", "android", "--manifest-path", nativeRustLibraryManifestPath
}
task copyNativeRustLibraryFiles(dependsOn: buildNativeRustLibrary, type: Copy) {
diff --git a/native/native_rust_library/Cargo.toml b/native/native_rust_library/Cargo.toml
--- a/native/native_rust_library/Cargo.toml
+++ b/native/native_rust_library/Cargo.toml
@@ -28,3 +28,6 @@
[lib]
crate-type = ["staticlib"]
+
+[features]
+android = []
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -23,6 +23,11 @@
RegistrationStartRequest, WalletLoginRequest,
};
+#[cfg(not(feature = "android"))]
+pub const DEVICE_TYPE: DeviceType = DeviceType::Ios;
+#[cfg(feature = "android")]
+pub const DEVICE_TYPE: DeviceType = DeviceType::Android;
+
lazy_static! {
pub static ref RUNTIME: Arc<Runtime> = Arc::new(
Builder::new_multi_thread()
@@ -231,7 +236,7 @@
}),
onetime_content_prekeys: password_user_info.content_onetime_keys,
onetime_notif_prekeys: password_user_info.notif_onetime_keys,
- device_type: DeviceType::Native.into(),
+ device_type: DEVICE_TYPE.into(),
}),
};
@@ -322,7 +327,7 @@
}),
onetime_content_prekeys: password_user_info.content_onetime_keys,
onetime_notif_prekeys: password_user_info.notif_onetime_keys,
- device_type: DeviceType::Native.into(),
+ device_type: DEVICE_TYPE.into(),
}),
};
@@ -422,7 +427,7 @@
}),
onetime_content_prekeys: wallet_user_info.content_onetime_keys,
onetime_notif_prekeys: wallet_user_info.notif_onetime_keys,
- device_type: DeviceType::Native.into(),
+ device_type: DEVICE_TYPE.into(),
}),
};
diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs
--- a/services/identity/src/database.rs
+++ b/services/identity/src/database.rs
@@ -70,11 +70,15 @@
}
#[derive(Clone, Copy)]
+#[allow(non_camel_case_types)]
pub enum Device {
// Numeric values should match the protobuf definition
Keyserver = 0,
- Native,
Web,
+ Ios,
+ Android,
+ Windows,
+ MacOS,
}
impl TryFrom<i32> for Device {
@@ -83,8 +87,11 @@
fn try_from(value: i32) -> Result<Self, Self::Error> {
match value {
0 => Ok(Device::Keyserver),
- 1 => Ok(Device::Native),
- 2 => Ok(Device::Web),
+ 1 => Ok(Device::Web),
+ 2 => Ok(Device::Ios),
+ 3 => Ok(Device::Android),
+ 4 => Ok(Device::Windows),
+ 5 => Ok(Device::MacOS),
_ => Err(Error::Attribute(DBItemError {
attribute_name: USERS_TABLE_DEVICES_MAP_DEVICE_TYPE_ATTRIBUTE_NAME
.to_string(),
@@ -99,8 +106,11 @@
fn fmt(&self, f: &mut Formatter) -> FmtResult {
match self {
Device::Keyserver => write!(f, "keyserver"),
- Device::Native => write!(f, "native"),
Device::Web => write!(f, "web"),
+ Device::Ios => write!(f, "ios"),
+ Device::Android => write!(f, "android"),
+ Device::Windows => write!(f, "windows"),
+ Device::MacOS => write!(f, "macos"),
}
}
}
diff --git a/shared/cmake/corrosion-cxx.cmake b/shared/cmake/corrosion-cxx.cmake
--- a/shared/cmake/corrosion-cxx.cmake
+++ b/shared/cmake/corrosion-cxx.cmake
@@ -3,7 +3,7 @@
# <_LIB_PATH_STEM> must match the crate name:
# "path/to/myrustcrate" -> "libmyrustcrate.a"
function(add_library_rust)
- set(value_keywords PATH NAMESPACE CXX_BRIDGE_SOURCE_FILE)
+ set(value_keywords PATH NAMESPACE FEATURES CXX_BRIDGE_SOURCE_FILE)
cmake_parse_arguments(
rust_lib
"${OPTIONS}"
@@ -42,7 +42,10 @@
set(namespace ${rust_lib_NAMESPACE})
set(cxx_bridge_source_file "${rust_lib_SOURCE_FOLDER}/lib.rs")
- corrosion_import_crate(MANIFEST_PATH "${lib_path}/Cargo.toml")
+ corrosion_import_crate(
+ MANIFEST_PATH "${lib_path}/Cargo.toml"
+ FEATURES "${rust_lib_FEATURES}"
+ )
get_filename_component(_LIB_PATH_STEM ${lib_path} NAME)
message(STATUS "Library stem path: ${_LIB_PATH_STEM}")
diff --git a/shared/protos/identity_client.proto b/shared/protos/identity_client.proto
--- a/shared/protos/identity_client.proto
+++ b/shared/protos/identity_client.proto
@@ -108,8 +108,12 @@
enum DeviceType {
Keyserver = 0;
- Native = 1;
- Web = 2;
+ Web = 1;
+ // iOS doesn't leave a good option for title to camel case renaming
+ Ios = 2;
+ Android = 3;
+ Windows = 4;
+ MacOS = 5;
}
// Bundle of information needed for creating an initial message using X3DH

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 5:17 AM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569073
Default Alt Text
D8816.id30339.diff (5 KB)

Event Timeline