aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-03-26 16:00:34 +0000
committerLibravatar cel 🌸 <cel@bunny.garden>2025-03-26 16:00:34 +0000
commit78577fb74949c83e3c8196a7310781c15e73bf64 (patch)
treeb0315db35cda73e16026fa3ee3774187e8df6e33 /src
parenta88a7b0445a20ca57870e4c8a068d9b29ea6e779 (diff)
downloadmacaw-78577fb74949c83e3c8196a7310781c15e73bf64.tar.gz
macaw-78577fb74949c83e3c8196a7310781c15e73bf64.tar.bz2
macaw-78577fb74949c83e3c8196a7310781c15e73bf64.zip
fix: use filamento instead of old luz crateHEADmain
Diffstat (limited to 'src')
-rw-r--r--src/login_modal.rs5
-rw-r--r--src/main.rs59
-rw-r--r--src/message_view.rs2
3 files changed, 33 insertions, 33 deletions
diff --git a/src/login_modal.rs b/src/login_modal.rs
index 5a63158..f61c204 100644
--- a/src/login_modal.rs
+++ b/src/login_modal.rs
@@ -1,3 +1,4 @@
+use filamento::presence::{Offline, Presence};
use iced::{
futures::StreamExt,
widget::{button, checkbox, column, container, text, text_input},
@@ -5,10 +6,6 @@ use iced::{
};
use jid::JID;
use keyring::Entry;
-use luz::{
- presence::{Offline, Presence},
- LuzHandle,
-};
use serde::{Deserialize, Serialize};
use tokio_stream::wrappers::ReceiverStream;
use tracing::info;
diff --git a/src/main.rs b/src/main.rs
index 37551c8..1a979c3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,6 +7,10 @@ use std::str::FromStr;
use std::sync::Arc;
use chrono::{Local, Utc};
+use filamento::chat::{Chat, Message as ChatMessage};
+use filamento::error::CommandError;
+use filamento::presence::{Offline, Presence, PresenceType};
+use filamento::{roster::Contact, user::User, UpdateMessage};
use iced::alignment::Horizontal::Right;
use iced::futures::{SinkExt, Stream, StreamExt};
use iced::keyboard::{on_key_press, on_key_release, Key, Modifiers};
@@ -26,11 +30,6 @@ use indexmap::{indexmap, IndexMap};
use jid::JID;
use keyring::Entry;
use login_modal::{Creds, LoginModal};
-use luz::chat::{Chat, Message as ChatMessage};
-use luz::error::CommandError;
-use luz::presence::{Offline, Presence, PresenceType};
-use luz::CommandMessage;
-use luz::{roster::Contact, user::User, LuzHandle, UpdateMessage};
use message_view::MessageView;
use serde::{Deserialize, Serialize};
use thiserror::Error;
@@ -125,7 +124,7 @@ impl Account {
#[derive(Clone, Debug)]
pub struct Client {
- client: LuzHandle,
+ client: filamento::Client,
jid: JID,
status: Presence,
connection_state: ConnectionState,
@@ -161,32 +160,36 @@ impl DerefMut for Client {
}
impl Deref for Client {
- type Target = LuzHandle;
+ type Target = filamento::Client;
fn deref(&self) -> &Self::Target {
&self.client
}
}
-async fn luz(jid: &JID, creds: &Creds, cfg: &Config) -> (LuzHandle, mpsc::Receiver<UpdateMessage>) {
- let luz;
+async fn filamento(
+ jid: &JID,
+ creds: &Creds,
+ cfg: &Config,
+) -> (filamento::Client, mpsc::Receiver<UpdateMessage>) {
+ let filamento;
if let Some(ref dburl) = cfg.dburl {
// TODO: have some sort of crash popup for this stuff
let db_path = dburl.strip_prefix("sqlite://").unwrap_or(&dburl);
let db_path = PathBuf::from_str(db_path).expect("invalid database path");
- let db = luz::db::Db::create_connect_and_migrate(db_path)
+ let db = filamento::db::Db::create_connect_and_migrate(db_path)
.await
.unwrap();
- luz = LuzHandle::new(jid.clone(), creds.password.to_string(), db);
+ filamento = filamento::Client::new(jid.clone(), creds.password.to_string(), db);
} else if let Some(ref dir) = cfg.storage_dir {
let mut data_dir = PathBuf::from_str(&dir).expect("invalid storage directory path");
data_dir.push(creds.jid.clone());
data_dir.push(creds.jid.clone());
data_dir.set_extension("db");
- let db = luz::db::Db::create_connect_and_migrate(data_dir)
+ let db = filamento::db::Db::create_connect_and_migrate(data_dir)
.await
.unwrap();
- luz = LuzHandle::new(jid.clone(), creds.password.to_string(), db);
+ filamento = filamento::Client::new(jid.clone(), creds.password.to_string(), db);
} else {
let mut data_dir = dirs::data_dir()
.expect("operating system does not support retreiving determining default data dir");
@@ -196,12 +199,12 @@ async fn luz(jid: &JID, creds: &Creds, cfg: &Config) -> (LuzHandle, mpsc::Receiv
// TODO: better lol
data_dir.set_extension("db");
info!("db_path: {:?}", data_dir);
- let db = luz::db::Db::create_connect_and_migrate(data_dir)
+ let db = filamento::db::Db::create_connect_and_migrate(data_dir)
.await
.unwrap();
- luz = LuzHandle::new(jid.clone(), creds.password.to_string(), db);
+ filamento = filamento::Client::new(jid.clone(), creds.password.to_string(), db);
}
- luz
+ filamento
}
#[tokio::main]
@@ -244,12 +247,12 @@ async fn main() -> iced::Result {
}
}
- let mut client: Option<(JID, LuzHandle, mpsc::Receiver<UpdateMessage>)> = None;
+ let mut client: Option<(JID, filamento::Client, mpsc::Receiver<UpdateMessage>)> = None;
if let Some(creds) = creds {
let jid = creds.jid.parse::<JID>();
match jid {
Ok(jid) => {
- let (handle, updates) = luz(&jid, &creds, &cfg).await;
+ let (handle, updates) = filamento(&jid, &creds, &cfg).await;
client = Some((jid, handle, updates));
}
Err(e) => client_creation_error = Some(Error::CredentialsLoad(e.into())),
@@ -394,13 +397,13 @@ pub enum Message {
#[derive(Debug, Error, Clone)]
pub enum Error {
#[error("failed to create Luz client: {0}")]
- ClientCreation(#[from] luz::error::DatabaseError),
+ ClientCreation(#[from] filamento::error::DatabaseError),
#[error("failed to save credentials: {0}")]
CredentialsSave(CredentialsSaveError),
#[error("failed to load credentials: {0}")]
CredentialsLoad(CredentialsLoadError),
#[error("failed to retreive messages for chat {0}")]
- MessageHistory(JID, CommandError<luz::error::DatabaseError>),
+ MessageHistory(JID, CommandError<filamento::error::DatabaseError>),
}
#[derive(Debug, Error, Clone)]
@@ -589,7 +592,7 @@ impl Macaw {
client.connection_state = ConnectionState::Connecting;
let client = client.client.clone();
Task::future(async move {
- client.send(CommandMessage::Connect).await;
+ client.connect().await;
})
.discard()
}
@@ -599,9 +602,7 @@ impl Macaw {
Account::LoggedIn(client) => {
let client = client.client.clone();
Task::future(async move {
- client
- .send(CommandMessage::Disconnect(Offline::default()))
- .await;
+ client.disconnect(Offline::default()).await;
})
.discard()
}
@@ -649,7 +650,7 @@ impl Macaw {
Ok(jid) => {
Task::perform(async move {
let (jid, creds, config) = (jid, creds, config);
- let (handle, recv) = luz(&jid, &creds, &config).await;
+ let (handle, recv) = filamento(&jid, &creds, &config).await;
(handle, recv, jid, creds, config)
}, move |(handle, recv, jid, creds, config)| {
let creds = creds;
@@ -767,9 +768,11 @@ impl Macaw {
return Task::none();
}
};
- Task::future(
- async move { client.send_message(jid, luz::chat::Body { body }).await },
- )
+ Task::future(async move {
+ client
+ .send_message(jid, filamento::chat::Body { body })
+ .await
+ })
.discard()
}
Message::Error(error) => {
diff --git a/src/message_view.rs b/src/message_view.rs
index 16e8ac1..5d27335 100644
--- a/src/message_view.rs
+++ b/src/message_view.rs
@@ -1,6 +1,7 @@
use std::borrow::Cow;
use chrono::NaiveDate;
+use filamento::chat::Message as ChatMessage;
use iced::{
alignment::Horizontal::{self, Right},
border::Radius,
@@ -16,7 +17,6 @@ use iced::{
};
use indexmap::IndexMap;
use jid::JID;
-use luz::chat::Message as ChatMessage;
use serde::{Deserialize, Serialize};
use uuid::Uuid;