Compare commits
1 commit
main
...
ruma-updat
Author | SHA1 | Date | |
---|---|---|---|
Amanda Graven | f0f828eb9e |
1925
Cargo.lock
generated
1925
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,15 +8,15 @@ resolver = "2"
|
|||
|
||||
[dependencies]
|
||||
crossbeam-channel = "0.5"
|
||||
eframe = { version = "0.16", features = ["persistence"] }
|
||||
eframe = { version = "0.17", features = ["persistence"] }
|
||||
futures = "0.3"
|
||||
ron = "0.6"
|
||||
ron = "0.7"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.15", features = ["full"] }
|
||||
url = { version = "2.2", features = ["serde"] }
|
||||
|
||||
[dependencies.matrix-sdk]
|
||||
git = "https://github.com/matrix-org/matrix-rust-sdk/"
|
||||
rev = "2e04a37"
|
||||
rev = "6dff065"
|
||||
default-features = false
|
||||
features = ["encryption", "qrcode", "sled_cryptostore", "sled_state_store", "rustls-tls"]
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
use matrix_sdk::{
|
||||
config::ClientConfig,
|
||||
reqwest::Url,
|
||||
ruma::{DeviceIdBox, UserId},
|
||||
ruma::{UserId, DeviceId},
|
||||
Client,
|
||||
};
|
||||
use ron::ser::PrettyConfig;
|
||||
|
@ -21,9 +21,9 @@ pub struct Session {
|
|||
/// Access token for authentication
|
||||
pub access_token: String,
|
||||
/// The user's mxid.
|
||||
pub user_id: UserId,
|
||||
pub user_id: Box<UserId>,
|
||||
/// The user's device ID.
|
||||
pub device_id: DeviceIdBox,
|
||||
pub device_id: Box<DeviceId>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
|
@ -42,7 +42,7 @@ impl Session {
|
|||
user_id: self.user_id,
|
||||
device_id: self.device_id,
|
||||
};
|
||||
let client = Client::new(self.homeserver)?;
|
||||
let client = Client::builder().homeserver_url(self.homeserver)?;
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
runtime.block_on(client.restore_login(session))?;
|
||||
Ok(client)
|
||||
|
|
14
src/sync.rs
14
src/sync.rs
|
@ -26,19 +26,19 @@ pub enum Request {
|
|||
/// Restore session
|
||||
Restore(matrix_sdk::Session),
|
||||
/// Get the calculated name for a room.
|
||||
RoomName(RoomId),
|
||||
RoomName(Box<RoomId>),
|
||||
/// Send a message to a room.
|
||||
Message(Joined, String),
|
||||
/// Get a member from a joined room
|
||||
JoinedMember(Joined, UserId),
|
||||
JoinedMember(Joined, Box<UserId>),
|
||||
/// Get the verification request with the flow id.
|
||||
VerifyRequest(UserId, String),
|
||||
VerifyRequest(Box<UserId>, String),
|
||||
/// Cancel a verification attempt.
|
||||
VerifyCancel(VerificationRequest),
|
||||
/// Accept a verification request.
|
||||
VerifyAccept(VerificationRequest),
|
||||
/// Find an active verification with the flow id.
|
||||
VerifyStart(UserId, String),
|
||||
VerifyStart(Box<UserId>, String),
|
||||
/// Start SAS verification flow.
|
||||
VerifyStartSas(VerificationRequest),
|
||||
VerifySasConfirm(SasVerification),
|
||||
|
@ -53,9 +53,9 @@ pub enum Response {
|
|||
/// Response from the synchronization loop
|
||||
Sync(matrix_sdk::deserialized_responses::SyncResponse),
|
||||
/// Calculated the name for a room
|
||||
RoomName(RoomId, String),
|
||||
RoomName(Box<RoomId>, String),
|
||||
/// Retrived a member frmo a joined room.
|
||||
JoinedMember(RoomId, RoomMember),
|
||||
JoinedMember(Box<RoomId>, RoomMember),
|
||||
/// Got a verification request.
|
||||
VerifyRequest(VerificationRequest),
|
||||
/// Started SAS verification.
|
||||
|
@ -123,7 +123,7 @@ async fn handle_request(
|
|||
},
|
||||
Request::JoinedMember(room, user) => {
|
||||
if let Some(member) = room.get_member(&user).await? {
|
||||
response.send(Response::JoinedMember(room.room_id().clone(), member))?;
|
||||
response.send(Response::JoinedMember(room.room_id().to_owned(), member))?;
|
||||
}
|
||||
}
|
||||
Request::Message(room, message) => {
|
||||
|
|
|
@ -21,7 +21,7 @@ impl epi::App for App {
|
|||
|
||||
fn setup(
|
||||
&mut self,
|
||||
_ctx: &egui::CtxRef,
|
||||
_ctx: &egui::Context,
|
||||
_frame: &epi::Frame,
|
||||
storage: Option<&dyn epi::Storage>,
|
||||
) {
|
||||
|
@ -70,7 +70,7 @@ impl epi::App for App {
|
|||
};
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
|
||||
match self.view {
|
||||
View::Login(ref mut login) => {
|
||||
if login.update(ctx) {
|
||||
|
@ -107,7 +107,7 @@ impl View {
|
|||
});
|
||||
let view = session::App::new(client, req_tx, res_rx, handle);
|
||||
for room in view.client.rooms() {
|
||||
view.request.room_name(room.room_id().clone());
|
||||
view.request.room_name(room.room_id().to_owned());
|
||||
}
|
||||
|
||||
*self = View::Main(view);
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct Login {
|
|||
}
|
||||
|
||||
impl Login {
|
||||
pub fn update(&mut self, ctx: &egui::CtxRef) -> bool {
|
||||
pub fn update(&mut self, ctx: &egui::Context) -> bool {
|
||||
let mut update = false;
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.add_space(ui.available_height() / 3.0);
|
||||
|
|
|
@ -46,34 +46,34 @@ pub struct App {
|
|||
/// Data for the room list
|
||||
pub room_list: RoomList,
|
||||
/// Data for storing a timeline
|
||||
pub timelines: HashMap<RoomId, Timeline>,
|
||||
pub timelines: HashMap<Box<RoomId>, Timeline>,
|
||||
/// Message entry
|
||||
pub entry: MessageEntry,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||
pub struct RoomList {
|
||||
pub selected_room: Option<matrix_sdk::ruma::identifiers::RoomId>,
|
||||
pub room_name: HashMap<RoomId, String>,
|
||||
pub selected_room: Option<Box<RoomId>>,
|
||||
pub room_name: HashMap<Box<RoomId>, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||
pub struct Timeline {
|
||||
messages: Vec<AnyRoomEvent>,
|
||||
#[serde(skip)]
|
||||
member: HashMap<UserId, RoomMember>,
|
||||
member: HashMap<Box<UserId>, RoomMember>,
|
||||
#[serde(skip)]
|
||||
member_pending: HashSet<UserId>,
|
||||
member_pending: HashSet<Box<UserId>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||
pub struct MessageEntry {
|
||||
text: HashMap<RoomId, String>,
|
||||
text: HashMap<Box<RoomId>, String>,
|
||||
}
|
||||
|
||||
impl MessageEntry {
|
||||
pub fn get(&mut self, room: &RoomId) -> &mut String {
|
||||
self.text.entry(room.clone()).or_default()
|
||||
self.text.entry(room.to_owned()).or_default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self, ctx: &egui::CtxRef) {
|
||||
pub fn update(&mut self, ctx: &egui::Context) {
|
||||
if let Ok(response) = self.response.try_recv() {
|
||||
self.handle_response(response);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ impl App {
|
|||
ui.add(Label::new(RichText::new("Joined").strong()));
|
||||
|
||||
let mut joined = self.client.joined_rooms();
|
||||
joined.sort_by_key(|room| self.room_list.room_name(&room).to_uppercase());
|
||||
joined.sort_by_key(|room| self.room_list.room_name(room).to_uppercase());
|
||||
joined.retain(|room| {
|
||||
room.create_content()
|
||||
.and_then(|c| c.room_type)
|
||||
|
@ -158,7 +158,7 @@ impl App {
|
|||
});
|
||||
let response = response.response.interact(Sense::click());
|
||||
if response.clicked() {
|
||||
self.room_list.selected_room = Some(room.room_id().clone());
|
||||
self.room_list.selected_room = Some(room.room_id().to_owned());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -184,7 +184,7 @@ impl App {
|
|||
|
||||
egui::SidePanel::right(Id::MemberList).show(ctx, |ui| {
|
||||
ui.heading("Members");
|
||||
let timeline = self.timelines.entry(room.room_id().clone()).or_default();
|
||||
let timeline = self.timelines.entry(room.room_id().to_owned()).or_default();
|
||||
for member in timeline.member.values() {
|
||||
ui.group(|ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
|
@ -216,18 +216,14 @@ impl App {
|
|||
}
|
||||
if verify_req.we_started() {
|
||||
ui.label("Waiting for other user to accept verification.");
|
||||
} else {
|
||||
if ui.button("Accept").clicked() {
|
||||
self.request.verify_accept(verify_req.clone())
|
||||
}
|
||||
} else if ui.button("Accept").clicked() {
|
||||
self.request.verify_accept(verify_req.clone())
|
||||
}
|
||||
if verify_req.is_ready() {
|
||||
let methods = verify_req.their_supported_methods().unwrap();
|
||||
for method in methods {
|
||||
if method == VerificationMethod::SasV1 {
|
||||
if ui.button("Verify with emoji").clicked() {
|
||||
self.request.verify_start_sas(verify_req.clone());
|
||||
}
|
||||
if method == VerificationMethod::SasV1 && ui.button("Verify with emoji").clicked() {
|
||||
self.request.verify_start_sas(verify_req.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,18 +284,19 @@ impl App {
|
|||
// Main panel with the timeline
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ScrollArea::vertical().show(ui, |ui| {
|
||||
let timeline = self.timelines.entry(room.room_id().clone()).or_default();
|
||||
let timeline = self.timelines.entry(room.room_id().to_owned()).or_default();
|
||||
for event in timeline.messages.iter() {
|
||||
let sender = event.sender();
|
||||
let name = match timeline.member.get(sender) {
|
||||
Some(member) => member.name(),
|
||||
None => {
|
||||
if !timeline.member_pending.contains(sender) {
|
||||
self.request.joined_member(joined.clone(), sender.clone());
|
||||
self.request.joined_member(joined.clone(), sender.to_owned());
|
||||
}
|
||||
sender.localpart()
|
||||
}
|
||||
};
|
||||
#[allow(clippy::single_match)]
|
||||
match event {
|
||||
AnyRoomEvent::Message(AnyMessageEvent::RoomMessage(msg)) => {
|
||||
match &msg.content.msgtype {
|
||||
|
@ -363,7 +360,7 @@ impl App {
|
|||
.entry(room)
|
||||
.or_default()
|
||||
.member
|
||||
.insert(member.user_id().clone(), member);
|
||||
.insert(member.user_id().to_owned(), member);
|
||||
}
|
||||
Response::VerifyRequest(verification) => {
|
||||
self.verify_req = Some(verification);
|
||||
|
@ -402,12 +399,12 @@ impl App {
|
|||
match to_device {
|
||||
AnyToDeviceEvent::KeyVerificationRequest(req) => {
|
||||
self.request
|
||||
.verify_request(req.sender, req.content.transaction_id);
|
||||
.verify_request(req.sender, req.content.transaction_id.to_string());
|
||||
}
|
||||
AnyToDeviceEvent::KeyVerificationStart(start) => {
|
||||
if self.verify_req.is_none() {
|
||||
self.request
|
||||
.verify_start(start.sender, start.content.transaction_id)
|
||||
.verify_start(start.sender, start.content.transaction_id.to_string())
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
@ -420,11 +417,11 @@ impl App {
|
|||
pub struct RequestSender(UnboundedSender<sync::Request>);
|
||||
|
||||
impl RequestSender {
|
||||
pub fn room_name(&self, name: RoomId) {
|
||||
pub fn room_name(&self, name: Box<RoomId>) {
|
||||
self.0.send(sync::Request::RoomName(name)).ok();
|
||||
}
|
||||
|
||||
pub fn joined_member(&self, room: Joined, id: UserId) {
|
||||
pub fn joined_member(&self, room: Joined, id: Box<UserId>) {
|
||||
self.0.send(sync::Request::JoinedMember(room, id)).ok();
|
||||
}
|
||||
|
||||
|
@ -432,7 +429,7 @@ impl RequestSender {
|
|||
self.0.send(sync::Request::Message(room, message)).ok();
|
||||
}
|
||||
|
||||
pub fn verify_request(&self, user: UserId, flow_id: String) {
|
||||
pub fn verify_request(&self, user: Box<UserId>, flow_id: String) {
|
||||
self.0
|
||||
.send(sync::Request::VerifyRequest(user, flow_id))
|
||||
.ok();
|
||||
|
@ -446,7 +443,7 @@ impl RequestSender {
|
|||
self.0.send(sync::Request::VerifyAccept(verify)).ok();
|
||||
}
|
||||
|
||||
pub fn verify_start(&self, user: UserId, flow_id: String) {
|
||||
pub fn verify_start(&self, user: Box<UserId>, flow_id: String) {
|
||||
self.0.send(sync::Request::VerifyStart(user, flow_id)).ok();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue