Skip to content

Commit

Permalink
Show error when rust runtime finishes unexpectedly.
Browse files Browse the repository at this point in the history
  • Loading branch information
hoehermann committed Sep 28, 2024
1 parent 4a6c80a commit ea55c4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/c/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ rust_main(void* account) {
const char *username = purple_account_get_username(account);
char *store_path = g_strdup_printf("%s/presage/%s", user_dir, username);
presage_rust_main(rust_runtime, account, store_path);
printf("presage_rust_main has finished.\n");
PurpleConnection *connection = purple_account_get_connection(account);
if (PURPLE_CONNECTION_STATE_DISCONNECTED == purple_connection_get_state(connection)) {
purple_debug_info(PLUGIN_NAME, "rust runtime has finished while not connected.\n");
} else {
purple_connection_error(connection, PURPLE_CONNECTION_ERROR_OTHER_ERROR, "rust runtime has finished unexpectedly.");
}
g_free(store_path);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,5 @@ pub unsafe extern "C" fn presage_rust_main(
let local = tokio::task::LocalSet::new();
local.run_until(crate::core::main(store_path, None, rx, account)).await;
});
crate::core::purple_debug(account, 2, String::from("runtime finished.\n"));
crate::core::purple_debug(account, 2, String::from("rust runtime finishes now…\n"));
}
3 changes: 1 addition & 2 deletions src/rust/src/receive.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// TODO: rename to receive since it does also receive attachments

use futures::StreamExt; // for Stream.next()

/*
Expand Down Expand Up @@ -121,6 +119,7 @@ fn print_message<C: presage::store::Store>(
// TODO: forward these properly
presage::libsignal_service::content::ContentBody::TypingMessage(_) => None, //Some(Msg::Received(&thread, "is typing...".into())), // too annyoing for now. also does not differentiate between "started typing" and "stopped typing"
presage::libsignal_service::content::ContentBody::ReceiptMessage(_) => None, //Some(Msg::Received(&thread, "received a message.".into())), // works, but too annyoing for now
// TODO: explicitly ignore SynchronizeMessage(SyncMessage { sent: None, contacts: None, request: None, read: [], blocked: None, verified: None, configuration: None, padding: Some([…]), …, delete_for_me: Some(DeleteForMe { message_deletes: [MessageDeletes { conversation: Some(ConversationIdentifier { identifier: Some(ThreadServiceId("REDACTED")) }), messages: [AddressableMessage { sent_timestamp: Some(1674147919685), author: Some(AuthorServiceId("REDACTED")) }] }], conversation_deletes: [], local_only_conversation_deletes: [], attachment_deletes: [] }) })
c => {
crate::core::purple_debug(account, 2, format!("Unsupported message {c:?}\n"));
None
Expand Down

0 comments on commit ea55c4d

Please sign in to comment.