Skip to content

Commit b888c4e

Browse files
committed
Add Signal protobuf files and compile them to Rust.
It would be cleaner to yield the compiled files OUT_DIR, but that gets ugly very fast because of rust-lang/rust#48250.
1 parent 02476a6 commit b888c4e

File tree

9 files changed

+556
-0
lines changed

9 files changed

+556
-0
lines changed

libsignal-service/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/proto/*.rs

libsignal-service/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ failure = "0.1.5"
1212
async-trait = "0.1.30"
1313
url = "2.1.1"
1414
thiserror = "1.0"
15+
serde = {version = "1.0", features=["derive"]}
16+
serde_json = "1.0"
17+
prost = "0.6"
1518

1619
[dev-dependencies]
1720
structopt = "0.2.17"
1821
tokio = { version = "0.2", features=["macros"] }
22+
23+
[build-dependencies]
24+
prost-build = "0.6"

libsignal-service/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use std::path::Path;
2+
3+
fn main() {
4+
let protobuf = Path::new(env!("CARGO_MANIFEST_DIR")).join("protobuf");
5+
6+
let input: Vec<_> = protobuf
7+
.read_dir()
8+
.expect("protobuf directory")
9+
.filter_map(|entry| {
10+
let entry = entry.expect("readable protobuf directory");
11+
let path = entry.path();
12+
if Some("proto")
13+
== path.extension().and_then(std::ffi::OsStr::to_str)
14+
{
15+
assert!(path.is_file());
16+
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
17+
Some(path)
18+
} else {
19+
None
20+
}
21+
})
22+
.collect();
23+
24+
prost_build::compile_protos(&input, &[protobuf]).unwrap();
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (C) 2014-2016 Open Whisper Systems
3+
*
4+
* Licensed according to the LICENSE file in this repository.
5+
*/
6+
syntax = "proto2";
7+
8+
package signalservice;
9+
10+
option java_package = "org.whispersystems.signalservice.internal.push";
11+
option java_outer_classname = "ProvisioningProtos";
12+
13+
message ProvisionEnvelope {
14+
optional bytes publicKey = 1;
15+
optional bytes body = 2; // Encrypted ProvisionMessage
16+
}
17+
18+
message ProvisionMessage {
19+
optional bytes identityKeyPublic = 1;
20+
optional bytes identityKeyPrivate = 2;
21+
optional string number = 3;
22+
optional string uuid = 8;
23+
optional string provisioningCode = 4;
24+
optional string userAgent = 5;
25+
optional bytes profileKey = 6;
26+
optional bool readReceipts = 7;
27+
optional uint32 provisioningVersion = 9;
28+
}
29+
30+
enum ProvisioningVersion {
31+
option allow_alias = true;
32+
33+
INITIAL = 0;
34+
TABLET_SUPPORT = 1;
35+
CURRENT = 1;
36+
}

0 commit comments

Comments
 (0)