forked from signalapp/libsignal
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate chat protobuf code and simplify ffi
- Loading branch information
Showing
35 changed files
with
292 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
java/client/src/main/java/org/signal/libsignal/SignalChatCommunicationFailureException.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.signal.libsignal; | ||
|
||
public class SignalChatCommunicationFailureException extends Exception { | ||
public SignalChatCommunicationFailureException(String msg) { super(msg); } | ||
public SignalChatCommunicationFailureException(Throwable t) { super(t); } | ||
} |
41 changes: 41 additions & 0 deletions
41
java/client/src/main/java/org/signal/libsignal/profile/ProfileClient.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.signal.libsignal.profile; | ||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import org.signal.chat.profile.GetVersionedProfileRequest; | ||
import org.signal.chat.profile.GetVersionedProfileResponse; | ||
import org.signal.libsignal.SignalChatCommunicationFailureException; | ||
import org.signal.libsignal.internal.Native; | ||
import org.signal.libsignal.internal.NativeHandleGuard; | ||
|
||
public class ProfileClient implements NativeHandleGuard.Owner { | ||
|
||
private static final String DEFAULT_TARGET = "https://grpcproxy.gluonhq.net:443"; | ||
|
||
private final long unsafeHandle; | ||
|
||
public ProfileClient() { | ||
this(DEFAULT_TARGET); | ||
} | ||
|
||
public ProfileClient(String target) { | ||
this.unsafeHandle = Native.ProfileClient_New(target); | ||
} | ||
|
||
@Override @SuppressWarnings("deprecation") | ||
protected void finalize() { | ||
Native.ProfileClient_Destroy(this.unsafeHandle); | ||
} | ||
|
||
public long unsafeNativeHandleWithoutGuard() { | ||
return this.unsafeHandle; | ||
} | ||
|
||
public GetVersionedProfileResponse getVersionedProfile(GetVersionedProfileRequest request) throws SignalChatCommunicationFailureException { | ||
try (NativeHandleGuard guard = new NativeHandleGuard(this)) { | ||
byte[] serializedResponse = Native.ProfileClient_GetVersionedProfile(guard.nativeHandle(), request.toByteArray()); | ||
return GetVersionedProfileResponse.parseFrom(serializedResponse); | ||
} catch (InvalidProtocolBufferException e) { | ||
throw new SignalChatCommunicationFailureException(e); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// | ||
// Copyright 2023 Signal Messenger, LLC. | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// | ||
|
||
pub mod profile; |
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,26 @@ | ||
// | ||
// Copyright 2023 Signal Messenger, LLC. | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// | ||
|
||
use libsignal_bridge_macros::*; | ||
use signal_chat::Result; | ||
use signal_chat::profile::ProfileClient; | ||
|
||
use crate::support::*; | ||
use crate::*; | ||
|
||
bridge_handle!(ProfileClient, clone = false, mut = true); | ||
|
||
#[bridge_fn(ffi = false, node = false)] | ||
pub fn ProfileClient_New(target: String) -> Result<ProfileClient> { | ||
ProfileClient::new(target) | ||
} | ||
|
||
#[bridge_fn(ffi = false, node = false)] | ||
pub fn ProfileClient_GetVersionedProfile( | ||
profile_client: &mut ProfileClient, | ||
request: &[u8], | ||
) -> Result<Vec<u8>> { | ||
profile_client.get_versioned_profile(request) | ||
} |
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
Oops, something went wrong.