diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5912915..cdbf11b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] agp = "8.13.1" kotlin = "2.2.21" +protobufVersion = "4.33.1" [libraries] junit = { module = "junit:junit", version = "4.13.2" } @@ -9,8 +10,11 @@ androidx-test-rules = { module = "androidx.test:rules", version = "1.7.0" } androidx-test-ext = { module = "androidx.test.ext:junit", version = "1.3.0" } androidx-annotations = { module = "androidx.annotation:annotation", version = "1.9.1" } kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version = "1.9.0" } +protoc = { module = "com.google.protobuf:protoc", version.ref = "protobufVersion" } +protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobufVersion" } [plugins] android-library = { id = "com.android.library", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +protobuf-compiler = { id = "com.google.protobuf", version = "0.9.5" } \ No newline at end of file diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 1ebac53..42eb3bb 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -1,3 +1,4 @@ +import com.google.protobuf.gradle.id import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { @@ -5,6 +6,8 @@ plugins { alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlinx.serialization) id("maven-publish") + + alias(libs.plugins.protobuf.compiler) } group = "org.sessionfoundation" @@ -20,10 +23,10 @@ android { testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { - cmake { - arguments += listOf("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") - targets("session_util") - } + cmake { + arguments += listOf("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") + targets("session_util") + } } } @@ -76,6 +79,22 @@ kotlin { } } +protobuf { + protoc { + artifact = libs.protoc.get().toString() + } + + plugins { + generateProtoTasks { + all().forEach { task -> + task.builtins { + create("java") {} + } + } + } + } +} + publishing { publications { create("release") { @@ -121,4 +140,8 @@ dependencies { implementation(libs.androidx.annotations) implementation(libs.kotlinx.serialization.core) + + api(libs.protobuf.java) + + protobuf(files("../libsession-util/proto/SessionProtos.proto")) } diff --git a/library/src/main/proto/Utils.proto b/library/src/main/proto/Utils.proto new file mode 100644 index 0000000..7d67940 --- /dev/null +++ b/library/src/main/proto/Utils.proto @@ -0,0 +1,10 @@ +syntax = "proto2"; + +package signalservice; + +option java_package = "org.session.libsignal.protos"; +option java_outer_classname = "UtilProtos"; + +message ByteArrayList { + repeated bytes content = 1; +} diff --git a/library/src/main/proto/WebSocketResources.proto b/library/src/main/proto/WebSocketResources.proto new file mode 100644 index 0000000..8f82d98 --- /dev/null +++ b/library/src/main/proto/WebSocketResources.proto @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2014-2016 Open Whisper Systems + * + * Licensed according to the LICENSE file in this repository. + */ + +syntax = "proto2"; + +package signalservice; + +option java_package = "org.session.libsignal.protos"; +option java_outer_classname = "WebSocketProtos"; + +message WebSocketRequestMessage { + optional string verb = 1; + optional string path = 2; + optional bytes body = 3; + repeated string headers = 5; + optional uint64 id = 4; +} + +message WebSocketResponseMessage { + optional uint64 id = 1; + optional uint32 status = 2; + optional string message = 3; + repeated string headers = 5; + optional bytes body = 4; +} + +message WebSocketMessage { + enum Type { + UNKNOWN = 0; + REQUEST = 1; + RESPONSE = 2; + } + + optional Type type = 1; + optional WebSocketRequestMessage request = 2; + optional WebSocketResponseMessage response = 3; +} \ No newline at end of file diff --git a/library/src/main/proto/deprecated_notice.md b/library/src/main/proto/deprecated_notice.md new file mode 100644 index 0000000..aaa2b37 --- /dev/null +++ b/library/src/main/proto/deprecated_notice.md @@ -0,0 +1 @@ +The proto files under this folder are deprecated and will be removed in future releases. diff --git a/libsession-util b/libsession-util index 3d79bb2..dc3fc6b 160000 --- a/libsession-util +++ b/libsession-util @@ -1 +1 @@ -Subproject commit 3d79bb2d2b5b62d5240fa3307e0901a2e217192a +Subproject commit dc3fc6b9c1a734afd0c81b8cd177f2673e3632c6