[fractal] Move as much as possible from fractal-matrix-api to fractal-gtk
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Move as much as possible from fractal-matrix-api to fractal-gtk
- Date: Thu, 2 Jul 2020 07:06:24 +0000 (UTC)
commit 2f3532d03d6b0d1430fb7afe87d22eed95a60d95
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Fri Jun 26 05:57:34 2020 +0200
Move as much as possible from fractal-matrix-api to fractal-gtk
Cargo.lock | 69 +-----------
fractal-gtk/Cargo.toml | 6 +-
fractal-gtk/src/actions/global.rs | 2 +-
fractal-gtk/src/actions/message.rs | 2 +-
fractal-gtk/src/app/connect/account.rs | 2 +-
fractal-gtk/src/app/connect/direct.rs | 2 +-
fractal-gtk/src/app/connect/directory.rs | 2 +-
fractal-gtk/src/app/connect/headerbar.rs | 2 +-
fractal-gtk/src/app/connect/invite.rs | 2 +-
fractal-gtk/src/app/connect/join_room.rs | 2 +-
fractal-gtk/src/app/connect/leave_room.rs | 2 +-
fractal-gtk/src/app/connect/new_room.rs | 2 +-
fractal-gtk/src/app/connect/roomlist_search.rs | 2 +-
fractal-gtk/src/app/connect/send.rs | 2 +-
fractal-gtk/src/appop/attach.rs | 2 +-
fractal-gtk/src/appop/member.rs | 2 +-
fractal-gtk/src/appop/message.rs | 2 +-
fractal-gtk/src/appop/mod.rs | 2 +-
fractal-gtk/src/appop/room.rs | 2 +-
fractal-gtk/src/appop/user.rs | 2 +-
.../src/backend/directory.rs | 26 ++---
.../src/backend/media.rs | 18 ++--
.../src/backend/mod.rs | 24 ++---
.../src/backend/register.rs | 30 +++---
.../src/backend/room.rs | 116 ++++++++++-----------
.../src/backend/sync.rs | 26 ++---
.../src/backend/user.rs | 106 +++++++++----------
fractal-gtk/src/cache/mod.rs | 43 +++++++-
fractal-gtk/src/cache/state.rs | 2 +-
{fractal-matrix-api => fractal-gtk}/src/client.rs | 20 ++--
{fractal-matrix-api => fractal-gtk}/src/error.rs | 17 ++-
fractal-gtk/src/globals.rs | 17 +++
fractal-gtk/src/main.rs | 9 +-
fractal-gtk/src/meson.build | 33 ++++--
.../src/model/event.rs | 2 +-
.../src/model/fileinfo.rs | 0
.../src/model/member.rs | 8 +-
.../src/model/message.rs | 2 +-
.../src/model/mod.rs | 0
.../src/model/room.rs | 9 +-
fractal-gtk/src/passwd.rs | 2 +-
{fractal-matrix-api => fractal-gtk}/src/types.rs | 0
fractal-gtk/src/util.rs | 56 +++++++++-
fractal-gtk/src/widgets/autocomplete.rs | 2 +-
fractal-gtk/src/widgets/avatar.rs | 2 +-
fractal-gtk/src/widgets/inline_player.rs | 2 +-
fractal-gtk/src/widgets/media_viewer.rs | 2 +-
fractal-gtk/src/widgets/members_list.rs | 2 +-
fractal-gtk/src/widgets/message.rs | 2 +-
fractal-gtk/src/widgets/room_history.rs | 2 +-
fractal-gtk/src/widgets/room_settings.rs | 2 +-
fractal-gtk/src/widgets/roomlist.rs | 2 +-
fractal-matrix-api/Cargo.toml | 15 +--
fractal-matrix-api/src/cache.rs | 41 --------
fractal-matrix-api/src/globals.rs | 21 ----
fractal-matrix-api/src/lib.rs | 10 +-
fractal-matrix-api/src/meson.build | 39 +++----
fractal-matrix-api/src/util.rs | 48 ---------
58 files changed, 402 insertions(+), 467 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index f95efb55..33f237d5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -343,7 +343,7 @@ dependencies = [
"num-integer",
"num-traits",
"serde",
- "time 0.1.42",
+ "time",
]
[[package]]
@@ -585,6 +585,7 @@ dependencies = [
"chrono",
"clap",
"comrak",
+ "directories",
"dirs",
"failure",
"fractal-matrix-api",
@@ -608,12 +609,12 @@ dependencies = [
"libhandy",
"log",
"loggerv",
+ "md5",
"mdl",
"pango",
"pangocairo",
"rand 0.7.3",
"regex",
- "ruma-identifiers",
"secret-service",
"serde",
"serde_json",
@@ -624,22 +625,13 @@ dependencies = [
name = "fractal-matrix-api"
version = "4.2.2"
dependencies = [
- "chrono",
- "directories",
"gio",
- "glib",
- "lazy_static",
- "log",
- "md5",
- "percent-encoding 2.1.0",
"regex",
"reqwest",
"ruma-identifiers",
"serde",
"serde_json",
- "time 0.2.7",
"url 2.1.1",
- "urlencoding",
]
[[package]]
@@ -1360,7 +1352,7 @@ dependencies = [
"log",
"net2",
"pin-project",
- "time 0.1.42",
+ "time",
"tokio",
"tower-service",
"want",
@@ -2375,7 +2367,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
- "time 0.1.42",
+ "time",
"tokio",
"tokio-socks",
"tokio-tls",
@@ -2414,17 +2406,6 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
-[[package]]
-name = "rustversion"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6"
-dependencies = [
- "proc-macro2 1.0.9",
- "quote 1.0.2",
- "syn 1.0.16",
-]
-
[[package]]
name = "ryu"
version = "1.0.2"
@@ -2761,40 +2742,6 @@ dependencies = [
"winapi 0.3.8",
]
-[[package]]
-name = "time"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3043ac959c44dccc548a57417876c8fe241502aed69d880efc91166c02717a93"
-dependencies = [
- "libc",
- "rustversion",
- "time-macros",
- "winapi 0.3.8",
-]
-
-[[package]]
-name = "time-macros"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ae9b6e9f095bc105e183e3cd493d72579be3181ad4004fceb01adbe9eecab2d"
-dependencies = [
- "proc-macro-hack",
- "time-macros-impl",
-]
-
-[[package]]
-name = "time-macros-impl"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e987cfe0537f575b5fc99909de6185f6c19c3ad8889e2275e686a873d0869ba1"
-dependencies = [
- "proc-macro-hack",
- "proc-macro2 1.0.9",
- "quote 1.0.2",
- "syn 1.0.16",
-]
-
[[package]]
name = "tokio"
version = "0.2.13"
@@ -2976,12 +2923,6 @@ dependencies = [
"serde",
]
-[[package]]
-name = "urlencoding"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3df3561629a8bb4c57e5a2e4c43348d9e29c7c29d9b1c4c1f47166deca8f37ed"
-
[[package]]
name = "utf-8"
version = "0.7.5"
diff --git a/fractal-gtk/Cargo.toml b/fractal-gtk/Cargo.toml
index 2d504c08..415fa712 100644
--- a/fractal-gtk/Cargo.toml
+++ b/fractal-gtk/Cargo.toml
@@ -8,6 +8,7 @@ edition = "2018"
[dependencies]
clap = "2.33.0"
comrak = "0.7.0"
+directories = "2.0.2"
dirs = "2.0.2"
failure = "0.1.6"
fragile = "1.0.0"
@@ -24,6 +25,7 @@ lazy_static = "1.4.0"
letter-avatar = "1.2.1"
log = "0.4.8"
loggerv = "0.7.2"
+md5 = "0.7.0"
mdl = "1.0.4"
pango = "0.8.0"
pangocairo = "0.9.0"
@@ -37,10 +39,6 @@ serde_json = "1.0.48"
git = "https://gitlab.gnome.org/World/Rust/sourceview4-rs.git"
rev = "fa8819fa7ecbe56f44d951656d3825f468915754"
-[dependencies.ruma-identifiers]
-version = "0.16"
-features = ["rand"]
-
[dependencies.gst]
version = "0.15.3"
package = "gstreamer"
diff --git a/fractal-gtk/src/actions/global.rs b/fractal-gtk/src/actions/global.rs
index 2f6fc1d7..1f107619 100644
--- a/fractal-gtk/src/actions/global.rs
+++ b/fractal-gtk/src/actions/global.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use log::{debug, info};
use std::convert::TryInto;
use std::rc::Rc;
diff --git a/fractal-gtk/src/actions/message.rs b/fractal-gtk/src/actions/message.rs
index 8c5f2873..dc6be47e 100644
--- a/fractal-gtk/src/actions/message.rs
+++ b/fractal-gtk/src/actions/message.rs
@@ -1,5 +1,5 @@
use crate::backend::{dw_media, media, room, ContentType, ThreadPool};
-use fractal_api::clone;
+use crate::clone;
use fractal_api::identifiers::RoomId;
use fractal_api::r0::AccessToken;
use log::error;
diff --git a/fractal-gtk/src/app/connect/account.rs b/fractal-gtk/src/app/connect/account.rs
index ecea6087..55032a33 100644
--- a/fractal-gtk/src/app/connect/account.rs
+++ b/fractal-gtk/src/app/connect/account.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gio::ActionMapExt;
use gtk::prelude::*;
diff --git a/fractal-gtk/src/app/connect/direct.rs b/fractal-gtk/src/app/connect/direct.rs
index 21c875f8..7558e33c 100644
--- a/fractal-gtk/src/app/connect/direct.rs
+++ b/fractal-gtk/src/app/connect/direct.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use glib::source::Continue;
diff --git a/fractal-gtk/src/app/connect/directory.rs b/fractal-gtk/src/app/connect/directory.rs
index f97dab19..c55c3374 100644
--- a/fractal-gtk/src/app/connect/directory.rs
+++ b/fractal-gtk/src/app/connect/directory.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use crate::i18n::i18n;
diff --git a/fractal-gtk/src/app/connect/headerbar.rs b/fractal-gtk/src/app/connect/headerbar.rs
index f836c91c..554e3f43 100644
--- a/fractal-gtk/src/app/connect/headerbar.rs
+++ b/fractal-gtk/src/app/connect/headerbar.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use crate::app::App;
diff --git a/fractal-gtk/src/app/connect/invite.rs b/fractal-gtk/src/app/connect/invite.rs
index 13e0aaf5..ba23634b 100644
--- a/fractal-gtk/src/app/connect/invite.rs
+++ b/fractal-gtk/src/app/connect/invite.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use glib::source::Continue;
diff --git a/fractal-gtk/src/app/connect/join_room.rs b/fractal-gtk/src/app/connect/join_room.rs
index 458dfc3d..9a78c9b8 100644
--- a/fractal-gtk/src/app/connect/join_room.rs
+++ b/fractal-gtk/src/app/connect/join_room.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use crate::app::App;
diff --git a/fractal-gtk/src/app/connect/leave_room.rs b/fractal-gtk/src/app/connect/leave_room.rs
index ec77badf..ea6b566c 100644
--- a/fractal-gtk/src/app/connect/leave_room.rs
+++ b/fractal-gtk/src/app/connect/leave_room.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use crate::app::App;
diff --git a/fractal-gtk/src/app/connect/new_room.rs b/fractal-gtk/src/app/connect/new_room.rs
index 144fafd9..96cbd8ea 100644
--- a/fractal-gtk/src/app/connect/new_room.rs
+++ b/fractal-gtk/src/app/connect/new_room.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use crate::app::App;
diff --git a/fractal-gtk/src/app/connect/roomlist_search.rs b/fractal-gtk/src/app/connect/roomlist_search.rs
index fe1222ca..360db019 100644
--- a/fractal-gtk/src/app/connect/roomlist_search.rs
+++ b/fractal-gtk/src/app/connect/roomlist_search.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use crate::app::App;
diff --git a/fractal-gtk/src/app/connect/send.rs b/fractal-gtk/src/app/connect/send.rs
index a50c57a5..6182f301 100644
--- a/fractal-gtk/src/app/connect/send.rs
+++ b/fractal-gtk/src/app/connect/send.rs
@@ -1,5 +1,5 @@
use crate::appop::attach;
-use fractal_api::clone;
+use crate::clone;
use gtk::prelude::*;
use sourceview4::BufferExt;
diff --git a/fractal-gtk/src/appop/attach.rs b/fractal-gtk/src/appop/attach.rs
index 73e43488..0805402f 100644
--- a/fractal-gtk/src/appop/attach.rs
+++ b/fractal-gtk/src/appop/attach.rs
@@ -1,5 +1,5 @@
+use crate::clone;
use crate::i18n::i18n;
-use fractal_api::clone;
use std::fs::File;
use std::io::prelude::*;
diff --git a/fractal-gtk/src/appop/member.rs b/fractal-gtk/src/appop/member.rs
index a2a41a50..51d7bcc6 100644
--- a/fractal-gtk/src/appop/member.rs
+++ b/fractal-gtk/src/appop/member.rs
@@ -1,5 +1,5 @@
use crate::backend::user;
-use fractal_api::clone;
+use crate::clone;
use fractal_api::identifiers::{RoomId, UserId};
use gtk::prelude::*;
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index 72214461..387fd9cb 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -1,7 +1,7 @@
use crate::backend::room;
+use crate::clone;
use crate::types::ExtraContent;
use comrak::{markdown_to_html, ComrakOptions};
-use fractal_api::clone;
use fractal_api::identifiers::{EventId, RoomId};
use fractal_api::r0::AccessToken;
use fractal_api::url::Url;
diff --git a/fractal-gtk/src/appop/mod.rs b/fractal-gtk/src/appop/mod.rs
index 08552ecf..18979a0e 100644
--- a/fractal-gtk/src/appop/mod.rs
+++ b/fractal-gtk/src/appop/mod.rs
@@ -11,7 +11,7 @@ use fractal_api::r0::AccessToken;
use gtk::prelude::*;
use crate::backend::ThreadPool;
-use fractal_api::cache::CacheMap;
+use crate::cache::CacheMap;
use fractal_api::url::Url;
use crate::i18n;
diff --git a/fractal-gtk/src/appop/room.rs b/fractal-gtk/src/appop/room.rs
index 94fc4e1a..6a6f6e6c 100644
--- a/fractal-gtk/src/appop/room.rs
+++ b/fractal-gtk/src/appop/room.rs
@@ -15,7 +15,7 @@ use crate::app::App;
use crate::appop::AppOp;
use crate::error::BKError;
-use fractal_api::util::cache_dir_path;
+use crate::util::cache_dir_path;
use crate::actions;
use crate::actions::AppState;
diff --git a/fractal-gtk/src/appop/user.rs b/fractal-gtk/src/appop/user.rs
index dd83d451..e8281a82 100644
--- a/fractal-gtk/src/appop/user.rs
+++ b/fractal-gtk/src/appop/user.rs
@@ -1,7 +1,7 @@
use gtk::prelude::*;
use crate::backend::user;
-use fractal_api::clone;
+use crate::clone;
use std::path::PathBuf;
use std::thread;
diff --git a/fractal-matrix-api/src/backend/directory.rs b/fractal-gtk/src/backend/directory.rs
similarity index 72%
rename from fractal-matrix-api/src/backend/directory.rs
rename to fractal-gtk/src/backend/directory.rs
index a482cdfc..eaf28f5d 100644
--- a/fractal-matrix-api/src/backend/directory.rs
+++ b/fractal-gtk/src/backend/directory.rs
@@ -1,24 +1,24 @@
-use url::{Host, Url};
+use fractal_api::url::{Host, Url};
use crate::globals;
use crate::error::Error;
+use crate::backend::HTTP_CLIENT;
use crate::util::cache_dir_path;
-use crate::util::HTTP_CLIENT;
-use crate::r0::directory::post_public_rooms::request as post_public_rooms;
-use crate::r0::directory::post_public_rooms::Body as PublicRoomsBody;
-use crate::r0::directory::post_public_rooms::Filter as PublicRoomsFilter;
-use crate::r0::directory::post_public_rooms::Parameters as PublicRoomsParameters;
-use crate::r0::directory::post_public_rooms::Response as PublicRoomsResponse;
-use crate::r0::directory::post_public_rooms::ThirdPartyNetworks;
-use crate::r0::thirdparty::get_supported_protocols::request as get_supported_protocols;
-use crate::r0::thirdparty::get_supported_protocols::Parameters as SupportedProtocolsParameters;
-use crate::r0::thirdparty::get_supported_protocols::ProtocolInstance;
-use crate::r0::thirdparty::get_supported_protocols::Response as SupportedProtocolsResponse;
-use crate::r0::AccessToken;
use crate::types::Room;
+use fractal_api::r0::directory::post_public_rooms::request as post_public_rooms;
+use fractal_api::r0::directory::post_public_rooms::Body as PublicRoomsBody;
+use fractal_api::r0::directory::post_public_rooms::Filter as PublicRoomsFilter;
+use fractal_api::r0::directory::post_public_rooms::Parameters as PublicRoomsParameters;
+use fractal_api::r0::directory::post_public_rooms::Response as PublicRoomsResponse;
+use fractal_api::r0::directory::post_public_rooms::ThirdPartyNetworks;
+use fractal_api::r0::thirdparty::get_supported_protocols::request as get_supported_protocols;
+use fractal_api::r0::thirdparty::get_supported_protocols::Parameters as SupportedProtocolsParameters;
+use fractal_api::r0::thirdparty::get_supported_protocols::ProtocolInstance;
+use fractal_api::r0::thirdparty::get_supported_protocols::Response as SupportedProtocolsResponse;
+use fractal_api::r0::AccessToken;
use super::{dw_media, ContentType};
diff --git a/fractal-matrix-api/src/backend/media.rs b/fractal-gtk/src/backend/media.rs
similarity index 82%
rename from fractal-matrix-api/src/backend/media.rs
rename to fractal-gtk/src/backend/media.rs
index f51f7fff..c29362b5 100644
--- a/fractal-matrix-api/src/backend/media.rs
+++ b/fractal-gtk/src/backend/media.rs
@@ -1,19 +1,19 @@
use crate::error::Error;
use crate::globals;
-use ruma_identifiers::{EventId, RoomId};
+use fractal_api::identifiers::{EventId, RoomId};
+use fractal_api::url::Url;
use std::sync::mpsc::Sender;
-use url::Url;
-use crate::r0::AccessToken;
+use crate::backend::HTTP_CLIENT;
use crate::util::ResultExpectLog;
-use crate::util::HTTP_CLIENT;
+use fractal_api::r0::AccessToken;
-use crate::r0::filter::RoomEventFilter;
-use crate::r0::message::get_message_events::request as get_messages_events_req;
-use crate::r0::message::get_message_events::Direction as GetMessagesEventsDirection;
-use crate::r0::message::get_message_events::Parameters as GetMessagesEventsParams;
-use crate::r0::message::get_message_events::Response as GetMessagesEventsResponse;
use crate::types::Message;
+use fractal_api::r0::filter::RoomEventFilter;
+use fractal_api::r0::message::get_message_events::request as get_messages_events_req;
+use fractal_api::r0::message::get_message_events::Direction as GetMessagesEventsDirection;
+use fractal_api::r0::message::get_message_events::Parameters as GetMessagesEventsParams;
+use fractal_api::r0::message::get_message_events::Response as GetMessagesEventsResponse;
use super::{dw_media, get_prev_batch_from, ContentType, ThreadPool};
diff --git a/fractal-matrix-api/src/backend/mod.rs b/fractal-gtk/src/backend/mod.rs
similarity index 84%
rename from fractal-matrix-api/src/backend/mod.rs
rename to fractal-gtk/src/backend/mod.rs
index 3bcb9540..e9a29830 100644
--- a/fractal-matrix-api/src/backend/mod.rs
+++ b/fractal-gtk/src/backend/mod.rs
@@ -1,24 +1,24 @@
+use fractal_api::identifiers::{EventId, RoomId};
+use fractal_api::url::Url;
use lazy_static::lazy_static;
-use ruma_identifiers::{EventId, RoomId};
use std::fs::write;
use std::io::Read;
use std::path::Path;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
-use url::Url;
use crate::client::Client;
use crate::error::Error;
-use crate::r0::context::get_context::request as get_context;
-use crate::r0::context::get_context::Parameters as GetContextParameters;
-use crate::r0::context::get_context::Response as GetContextResponse;
-use crate::r0::media::get_content::request as get_content;
-use crate::r0::media::get_content::Parameters as GetContentParameters;
-use crate::r0::media::get_content_thumbnail::request as get_content_thumbnail;
-use crate::r0::media::get_content_thumbnail::Method;
-use crate::r0::media::get_content_thumbnail::Parameters as GetContentThumbnailParameters;
-use crate::r0::AccessToken;
-use crate::util::{cache_dir_path, HTTP_CLIENT};
+use crate::util::cache_dir_path;
+use fractal_api::r0::context::get_context::request as get_context;
+use fractal_api::r0::context::get_context::Parameters as GetContextParameters;
+use fractal_api::r0::context::get_context::Response as GetContextResponse;
+use fractal_api::r0::media::get_content::request as get_content;
+use fractal_api::r0::media::get_content::Parameters as GetContentParameters;
+use fractal_api::r0::media::get_content_thumbnail::request as get_content_thumbnail;
+use fractal_api::r0::media::get_content_thumbnail::Method;
+use fractal_api::r0::media::get_content_thumbnail::Parameters as GetContentThumbnailParameters;
+use fractal_api::r0::AccessToken;
pub mod directory;
pub mod media;
diff --git a/fractal-matrix-api/src/backend/register.rs b/fractal-gtk/src/backend/register.rs
similarity index 68%
rename from fractal-matrix-api/src/backend/register.rs
rename to fractal-gtk/src/backend/register.rs
index b2b719ef..c1ca8d4b 100644
--- a/fractal-matrix-api/src/backend/register.rs
+++ b/fractal-gtk/src/backend/register.rs
@@ -1,22 +1,22 @@
-use ruma_identifiers::{DeviceId, UserId};
-use url::Url;
+use fractal_api::identifiers::{DeviceId, UserId};
+use fractal_api::url::Url;
use crate::error::Error;
+use crate::backend::HTTP_CLIENT;
use crate::globals;
-use crate::r0::account::login::request as login_req;
-use crate::r0::account::login::Auth;
-use crate::r0::account::login::Body as LoginBody;
-use crate::r0::account::login::Response as LoginResponse;
-use crate::r0::account::logout::request as logout_req;
-use crate::r0::account::logout::Parameters as LogoutParameters;
-use crate::r0::account::Identifier;
-use crate::r0::account::UserIdentifier;
-use crate::r0::server::domain_info::request as domain_info;
-use crate::r0::server::domain_info::Response as DomainInfoResponse;
-use crate::r0::AccessToken;
-use crate::r0::Medium;
-use crate::util::HTTP_CLIENT;
+use fractal_api::r0::account::login::request as login_req;
+use fractal_api::r0::account::login::Auth;
+use fractal_api::r0::account::login::Body as LoginBody;
+use fractal_api::r0::account::login::Response as LoginResponse;
+use fractal_api::r0::account::logout::request as logout_req;
+use fractal_api::r0::account::logout::Parameters as LogoutParameters;
+use fractal_api::r0::account::Identifier;
+use fractal_api::r0::account::UserIdentifier;
+use fractal_api::r0::server::domain_info::request as domain_info;
+use fractal_api::r0::server::domain_info::Response as DomainInfoResponse;
+use fractal_api::r0::AccessToken;
+use fractal_api::r0::Medium;
pub fn login(
user: String,
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-gtk/src/backend/room.rs
similarity index 77%
rename from fractal-matrix-api/src/backend/room.rs
rename to fractal-gtk/src/backend/room.rs
index f50e05ba..ec9fb996 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-gtk/src/backend/room.rs
@@ -1,9 +1,9 @@
use log::error;
use serde_json::json;
-use ruma_identifiers::{Error as IdError, EventId, RoomId, UserId};
+use fractal_api::identifiers::{Error as IdError, EventId, RoomId, UserId};
+use fractal_api::url::Url;
use std::fs;
-use url::Url;
use std::collections::HashMap;
use std::convert::TryFrom;
@@ -12,66 +12,66 @@ use std::time::Duration;
use crate::error::Error;
use crate::globals;
+use crate::backend::HTTP_CLIENT;
use crate::util::cache_dir_path;
-use crate::util::HTTP_CLIENT;
-
-use crate::r0::config::get_global_account_data::request as get_global_account_data;
-use crate::r0::config::get_global_account_data::Parameters as GetGlobalAccountDataParameters;
-use crate::r0::config::set_global_account_data::request as set_global_account_data;
-use crate::r0::config::set_global_account_data::Parameters as SetGlobalAccountDataParameters;
-use crate::r0::config::set_room_account_data::request as set_room_account_data;
-use crate::r0::config::set_room_account_data::Parameters as SetRoomAccountDataParameters;
-use crate::r0::filter::RoomEventFilter;
-use crate::r0::media::create_content::request as create_content;
-use crate::r0::media::create_content::Parameters as CreateContentParameters;
-use crate::r0::media::create_content::Response as CreateContentResponse;
-use crate::r0::membership::invite_user::request as invite_user;
-use crate::r0::membership::invite_user::Body as InviteUserBody;
-use crate::r0::membership::invite_user::Parameters as InviteUserParameters;
-use crate::r0::membership::join_room_by_id_or_alias::request as join_room_req;
-use crate::r0::membership::join_room_by_id_or_alias::Parameters as JoinRoomParameters;
-use crate::r0::membership::leave_room::request as leave_room_req;
-use crate::r0::membership::leave_room::Parameters as LeaveRoomParameters;
-use crate::r0::message::create_message_event::request as create_message_event;
-use crate::r0::message::create_message_event::Parameters as CreateMessageEventParameters;
-use crate::r0::message::create_message_event::Response as CreateMessageEventResponse;
-use crate::r0::message::get_message_events::request as get_messages_events;
-use crate::r0::message::get_message_events::Direction as GetMessagesEventsDirection;
-use crate::r0::message::get_message_events::Parameters as GetMessagesEventsParams;
-use crate::r0::message::get_message_events::Response as GetMessagesEventsResponse;
-use crate::r0::read_marker::set_read_marker::request as set_read_marker;
-use crate::r0::read_marker::set_read_marker::Body as SetReadMarkerBody;
-use crate::r0::read_marker::set_read_marker::Parameters as SetReadMarkerParameters;
-use crate::r0::redact::redact_event::request as redact_event;
-use crate::r0::redact::redact_event::Body as RedactEventBody;
-use crate::r0::redact::redact_event::Parameters as RedactEventParameters;
-use crate::r0::redact::redact_event::Response as RedactEventResponse;
-use crate::r0::room::create_room::request as create_room;
-use crate::r0::room::create_room::Body as CreateRoomBody;
-use crate::r0::room::create_room::Parameters as CreateRoomParameters;
-use crate::r0::room::create_room::Response as CreateRoomResponse;
-use crate::r0::room::create_room::RoomPreset;
-use crate::r0::room::Visibility;
-use crate::r0::state::create_state_events_for_key::request as create_state_events_for_key;
-use crate::r0::state::create_state_events_for_key::Parameters as CreateStateEventsForKeyParameters;
-use crate::r0::state::get_state_events_for_key::request as get_state_events_for_key;
-use crate::r0::state::get_state_events_for_key::Parameters as GetStateEventsForKeyParameters;
-use crate::r0::sync::get_joined_members::request as get_joined_members;
-use crate::r0::sync::get_joined_members::Parameters as JoinedMembersParameters;
-use crate::r0::sync::get_joined_members::Response as JoinedMembersResponse;
-use crate::r0::sync::sync_events::Language;
-use crate::r0::tag::create_tag::request as create_tag;
-use crate::r0::tag::create_tag::Body as CreateTagBody;
-use crate::r0::tag::create_tag::Parameters as CreateTagParameters;
-use crate::r0::tag::delete_tag::request as delete_tag;
-use crate::r0::tag::delete_tag::Parameters as DeleteTagParameters;
-use crate::r0::typing::request as send_typing_notification;
-use crate::r0::typing::Body as TypingNotificationBody;
-use crate::r0::typing::Parameters as TypingNotificationParameters;
-use crate::r0::AccessToken;
+
use crate::types::Member;
use crate::types::Message;
use crate::types::{Room, RoomMembership, RoomTag};
+use fractal_api::r0::config::get_global_account_data::request as get_global_account_data;
+use fractal_api::r0::config::get_global_account_data::Parameters as GetGlobalAccountDataParameters;
+use fractal_api::r0::config::set_global_account_data::request as set_global_account_data;
+use fractal_api::r0::config::set_global_account_data::Parameters as SetGlobalAccountDataParameters;
+use fractal_api::r0::config::set_room_account_data::request as set_room_account_data;
+use fractal_api::r0::config::set_room_account_data::Parameters as SetRoomAccountDataParameters;
+use fractal_api::r0::filter::RoomEventFilter;
+use fractal_api::r0::media::create_content::request as create_content;
+use fractal_api::r0::media::create_content::Parameters as CreateContentParameters;
+use fractal_api::r0::media::create_content::Response as CreateContentResponse;
+use fractal_api::r0::membership::invite_user::request as invite_user;
+use fractal_api::r0::membership::invite_user::Body as InviteUserBody;
+use fractal_api::r0::membership::invite_user::Parameters as InviteUserParameters;
+use fractal_api::r0::membership::join_room_by_id_or_alias::request as join_room_req;
+use fractal_api::r0::membership::join_room_by_id_or_alias::Parameters as JoinRoomParameters;
+use fractal_api::r0::membership::leave_room::request as leave_room_req;
+use fractal_api::r0::membership::leave_room::Parameters as LeaveRoomParameters;
+use fractal_api::r0::message::create_message_event::request as create_message_event;
+use fractal_api::r0::message::create_message_event::Parameters as CreateMessageEventParameters;
+use fractal_api::r0::message::create_message_event::Response as CreateMessageEventResponse;
+use fractal_api::r0::message::get_message_events::request as get_messages_events;
+use fractal_api::r0::message::get_message_events::Direction as GetMessagesEventsDirection;
+use fractal_api::r0::message::get_message_events::Parameters as GetMessagesEventsParams;
+use fractal_api::r0::message::get_message_events::Response as GetMessagesEventsResponse;
+use fractal_api::r0::read_marker::set_read_marker::request as set_read_marker;
+use fractal_api::r0::read_marker::set_read_marker::Body as SetReadMarkerBody;
+use fractal_api::r0::read_marker::set_read_marker::Parameters as SetReadMarkerParameters;
+use fractal_api::r0::redact::redact_event::request as redact_event;
+use fractal_api::r0::redact::redact_event::Body as RedactEventBody;
+use fractal_api::r0::redact::redact_event::Parameters as RedactEventParameters;
+use fractal_api::r0::redact::redact_event::Response as RedactEventResponse;
+use fractal_api::r0::room::create_room::request as create_room;
+use fractal_api::r0::room::create_room::Body as CreateRoomBody;
+use fractal_api::r0::room::create_room::Parameters as CreateRoomParameters;
+use fractal_api::r0::room::create_room::Response as CreateRoomResponse;
+use fractal_api::r0::room::create_room::RoomPreset;
+use fractal_api::r0::room::Visibility;
+use fractal_api::r0::state::create_state_events_for_key::request as create_state_events_for_key;
+use fractal_api::r0::state::create_state_events_for_key::Parameters as CreateStateEventsForKeyParameters;
+use fractal_api::r0::state::get_state_events_for_key::request as get_state_events_for_key;
+use fractal_api::r0::state::get_state_events_for_key::Parameters as GetStateEventsForKeyParameters;
+use fractal_api::r0::sync::get_joined_members::request as get_joined_members;
+use fractal_api::r0::sync::get_joined_members::Parameters as JoinedMembersParameters;
+use fractal_api::r0::sync::get_joined_members::Response as JoinedMembersResponse;
+use fractal_api::r0::sync::sync_events::Language;
+use fractal_api::r0::tag::create_tag::request as create_tag;
+use fractal_api::r0::tag::create_tag::Body as CreateTagBody;
+use fractal_api::r0::tag::create_tag::Parameters as CreateTagParameters;
+use fractal_api::r0::tag::delete_tag::request as delete_tag;
+use fractal_api::r0::tag::delete_tag::Parameters as DeleteTagParameters;
+use fractal_api::r0::typing::request as send_typing_notification;
+use fractal_api::r0::typing::Body as TypingNotificationBody;
+use fractal_api::r0::typing::Parameters as TypingNotificationParameters;
+use fractal_api::r0::AccessToken;
use serde_json::Value as JsonValue;
diff --git a/fractal-matrix-api/src/backend/sync.rs b/fractal-gtk/src/backend/sync.rs
similarity index 94%
rename from fractal-matrix-api/src/backend/sync.rs
rename to fractal-gtk/src/backend/sync.rs
index 686e6204..9fbe2544 100644
--- a/fractal-matrix-api/src/backend/sync.rs
+++ b/fractal-gtk/src/backend/sync.rs
@@ -1,26 +1,27 @@
use crate::client::ProxySettings;
use crate::error::{Error, StandardErrorResponse};
use crate::globals;
-use crate::r0::filter::EventFilter;
-use crate::r0::filter::Filter;
-use crate::r0::filter::RoomEventFilter;
-use crate::r0::filter::RoomFilter;
-use crate::r0::sync::sync_events::request as sync_events;
-use crate::r0::sync::sync_events::IncludeState;
-use crate::r0::sync::sync_events::Parameters as SyncParameters;
-use crate::r0::sync::sync_events::Response as SyncResponse;
-use crate::r0::sync::sync_events::UnreadNotificationsCount;
-use crate::r0::AccessToken;
use crate::types::Event;
use crate::types::Member;
use crate::types::Message;
use crate::types::Room;
use crate::types::RoomMembership;
use crate::types::RoomTag;
+use fractal_api::r0::filter::EventFilter;
+use fractal_api::r0::filter::Filter;
+use fractal_api::r0::filter::RoomEventFilter;
+use fractal_api::r0::filter::RoomFilter;
+use fractal_api::r0::sync::sync_events::request as sync_events;
+use fractal_api::r0::sync::sync_events::IncludeState;
+use fractal_api::r0::sync::sync_events::Parameters as SyncParameters;
+use fractal_api::r0::sync::sync_events::Response as SyncResponse;
+use fractal_api::r0::sync::sync_events::UnreadNotificationsCount;
+use fractal_api::r0::AccessToken;
+use fractal_api::identifiers::{EventId, RoomId, UserId};
+use fractal_api::reqwest::blocking::{Client, Response};
+use fractal_api::url::Url;
use log::error;
-use reqwest::blocking::{Client, Response};
-use ruma_identifiers::{EventId, RoomId, UserId};
use serde::de::DeserializeOwned;
use serde_json::value::from_value;
use std::{
@@ -29,7 +30,6 @@ use std::{
thread,
time::{self, Duration},
};
-use url::Url;
pub enum RoomElement {
Name(RoomId, String),
diff --git a/fractal-matrix-api/src/backend/user.rs b/fractal-gtk/src/backend/user.rs
similarity index 70%
rename from fractal-matrix-api/src/backend/user.rs
rename to fractal-gtk/src/backend/user.rs
index 1e024ea7..fb5d5ac9 100644
--- a/fractal-matrix-api/src/backend/user.rs
+++ b/fractal-gtk/src/backend/user.rs
@@ -1,70 +1,70 @@
-use ruma_identifiers::UserId;
+use fractal_api::identifiers::UserId;
+use fractal_api::url::Url;
use std::fs;
-use url::Url;
use crate::backend::ThreadPool;
+use crate::backend::HTTP_CLIENT;
use crate::cache::CacheMap;
use crate::error::Error;
use crate::util::cache_dir_path;
use crate::util::ResultExpectLog;
-use crate::util::HTTP_CLIENT;
use std::convert::TryInto;
use std::path::PathBuf;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
use std::thread;
-use crate::identity::r0::association::msisdn::submit_token::request as submit_phone_token_req;
-use crate::identity::r0::association::msisdn::submit_token::Body as SubmitPhoneTokenBody;
-use crate::identity::r0::association::msisdn::submit_token::Response as SubmitPhoneTokenResponse;
-use crate::r0::account::change_password::request as change_password_req;
-use crate::r0::account::change_password::Body as ChangePasswordBody;
-use crate::r0::account::change_password::Parameters as ChangePasswordParameters;
-use crate::r0::account::deactivate::request as deactivate;
-use crate::r0::account::deactivate::Body as DeactivateBody;
-use crate::r0::account::deactivate::Parameters as DeactivateParameters;
-use crate::r0::account::AuthenticationData;
-use crate::r0::account::Identifier;
-use crate::r0::account::UserIdentifier;
-use crate::r0::contact::create::request as create_contact;
-use crate::r0::contact::create::Body as AddThreePIDBody;
-use crate::r0::contact::create::Parameters as AddThreePIDParameters;
-use crate::r0::contact::delete::request as delete_contact;
-use crate::r0::contact::delete::Body as DeleteThreePIDBody;
-use crate::r0::contact::delete::Parameters as DeleteThreePIDParameters;
-use crate::r0::contact::get_identifiers::request as get_identifiers;
-use crate::r0::contact::get_identifiers::Parameters as ThirdPartyIDParameters;
-use crate::r0::contact::get_identifiers::Response as ThirdPartyIDResponse;
-use crate::r0::contact::get_identifiers::ThirdPartyIdentifier;
-use crate::r0::contact::request_verification_token_email::request as
request_contact_verification_token_email;
-use crate::r0::contact::request_verification_token_email::Body as EmailTokenBody;
-use crate::r0::contact::request_verification_token_email::Parameters as EmailTokenParameters;
-use crate::r0::contact::request_verification_token_email::Response as EmailTokenResponse;
-use crate::r0::contact::request_verification_token_msisdn::request as
request_contact_verification_token_msisdn;
-use crate::r0::contact::request_verification_token_msisdn::Body as PhoneTokenBody;
-use crate::r0::contact::request_verification_token_msisdn::Parameters as PhoneTokenParameters;
-use crate::r0::contact::request_verification_token_msisdn::Response as PhoneTokenResponse;
-use crate::r0::media::create_content::request as create_content;
-use crate::r0::media::create_content::Parameters as CreateContentParameters;
-use crate::r0::media::create_content::Response as CreateContentResponse;
-use crate::r0::profile::get_display_name::request as get_display_name;
-use crate::r0::profile::get_display_name::Response as GetDisplayNameResponse;
-use crate::r0::profile::get_profile::request as get_profile;
-use crate::r0::profile::get_profile::Response as GetProfileResponse;
-use crate::r0::profile::set_avatar_url::request as set_avatar_url;
-use crate::r0::profile::set_avatar_url::Body as SetAvatarUrlBody;
-use crate::r0::profile::set_avatar_url::Parameters as SetAvatarUrlParameters;
-use crate::r0::profile::set_display_name::request as set_display_name;
-use crate::r0::profile::set_display_name::Body as SetDisplayNameBody;
-use crate::r0::profile::set_display_name::Parameters as SetDisplayNameParameters;
-use crate::r0::search::user::request as user_directory;
-use crate::r0::search::user::Body as UserDirectoryBody;
-use crate::r0::search::user::Parameters as UserDirectoryParameters;
-use crate::r0::search::user::Response as UserDirectoryResponse;
-use crate::r0::AccessToken;
-use crate::r0::Medium;
-use crate::r0::ThreePIDCredentials;
use crate::types::Member;
+use fractal_api::identity::r0::association::msisdn::submit_token::request as submit_phone_token_req;
+use fractal_api::identity::r0::association::msisdn::submit_token::Body as SubmitPhoneTokenBody;
+use fractal_api::identity::r0::association::msisdn::submit_token::Response as SubmitPhoneTokenResponse;
+use fractal_api::r0::account::change_password::request as change_password_req;
+use fractal_api::r0::account::change_password::Body as ChangePasswordBody;
+use fractal_api::r0::account::change_password::Parameters as ChangePasswordParameters;
+use fractal_api::r0::account::deactivate::request as deactivate;
+use fractal_api::r0::account::deactivate::Body as DeactivateBody;
+use fractal_api::r0::account::deactivate::Parameters as DeactivateParameters;
+use fractal_api::r0::account::AuthenticationData;
+use fractal_api::r0::account::Identifier;
+use fractal_api::r0::account::UserIdentifier;
+use fractal_api::r0::contact::create::request as create_contact;
+use fractal_api::r0::contact::create::Body as AddThreePIDBody;
+use fractal_api::r0::contact::create::Parameters as AddThreePIDParameters;
+use fractal_api::r0::contact::delete::request as delete_contact;
+use fractal_api::r0::contact::delete::Body as DeleteThreePIDBody;
+use fractal_api::r0::contact::delete::Parameters as DeleteThreePIDParameters;
+use fractal_api::r0::contact::get_identifiers::request as get_identifiers;
+use fractal_api::r0::contact::get_identifiers::Parameters as ThirdPartyIDParameters;
+use fractal_api::r0::contact::get_identifiers::Response as ThirdPartyIDResponse;
+use fractal_api::r0::contact::get_identifiers::ThirdPartyIdentifier;
+use fractal_api::r0::contact::request_verification_token_email::request as
request_contact_verification_token_email;
+use fractal_api::r0::contact::request_verification_token_email::Body as EmailTokenBody;
+use fractal_api::r0::contact::request_verification_token_email::Parameters as EmailTokenParameters;
+use fractal_api::r0::contact::request_verification_token_email::Response as EmailTokenResponse;
+use fractal_api::r0::contact::request_verification_token_msisdn::request as
request_contact_verification_token_msisdn;
+use fractal_api::r0::contact::request_verification_token_msisdn::Body as PhoneTokenBody;
+use fractal_api::r0::contact::request_verification_token_msisdn::Parameters as PhoneTokenParameters;
+use fractal_api::r0::contact::request_verification_token_msisdn::Response as PhoneTokenResponse;
+use fractal_api::r0::media::create_content::request as create_content;
+use fractal_api::r0::media::create_content::Parameters as CreateContentParameters;
+use fractal_api::r0::media::create_content::Response as CreateContentResponse;
+use fractal_api::r0::profile::get_display_name::request as get_display_name;
+use fractal_api::r0::profile::get_display_name::Response as GetDisplayNameResponse;
+use fractal_api::r0::profile::get_profile::request as get_profile;
+use fractal_api::r0::profile::get_profile::Response as GetProfileResponse;
+use fractal_api::r0::profile::set_avatar_url::request as set_avatar_url;
+use fractal_api::r0::profile::set_avatar_url::Body as SetAvatarUrlBody;
+use fractal_api::r0::profile::set_avatar_url::Parameters as SetAvatarUrlParameters;
+use fractal_api::r0::profile::set_display_name::request as set_display_name;
+use fractal_api::r0::profile::set_display_name::Body as SetDisplayNameBody;
+use fractal_api::r0::profile::set_display_name::Parameters as SetDisplayNameParameters;
+use fractal_api::r0::search::user::request as user_directory;
+use fractal_api::r0::search::user::Body as UserDirectoryBody;
+use fractal_api::r0::search::user::Parameters as UserDirectoryParameters;
+use fractal_api::r0::search::user::Response as UserDirectoryResponse;
+use fractal_api::r0::AccessToken;
+use fractal_api::r0::Medium;
+use fractal_api::r0::ThreePIDCredentials;
use super::{dw_media, ContentType};
diff --git a/fractal-gtk/src/cache/mod.rs b/fractal-gtk/src/cache/mod.rs
index 2355cbdc..77ccb9f1 100644
--- a/fractal-gtk/src/cache/mod.rs
+++ b/fractal-gtk/src/cache/mod.rs
@@ -1,8 +1,7 @@
use crate::backend::user;
use crate::backend::ThreadPool;
-use fractal_api::cache::CacheMap;
+use crate::util::ResultExpectLog;
use fractal_api::url::Url;
-use fractal_api::util::ResultExpectLog;
use glib::source::Continue;
use gtk::LabelExt;
use serde::{Deserialize, Serialize};
@@ -13,6 +12,8 @@ use crate::types::RoomList;
use failure::Error;
use fractal_api::identifiers::UserId;
use std::collections::HashMap;
+use std::hash::Hash;
+use std::time::{Duration, Instant};
use crate::globals;
@@ -32,6 +33,44 @@ pub use self::state::get;
pub use self::state::AppState;
pub use self::state::FCache;
+// user info cache, uid -> (name, avatar)
+#[derive(Clone, Debug)]
+pub struct CacheMap<K: Clone + Eq + Hash, V: Clone> {
+ map: HashMap<K, (Instant, V)>,
+ timeout: Duration,
+}
+
+impl<K: Clone + Eq + Hash, V: Clone> CacheMap<K, V> {
+ pub fn new() -> Self {
+ CacheMap {
+ map: HashMap::new(),
+ timeout: Duration::from_secs(10),
+ }
+ }
+
+ pub fn timeout(mut self, timeout: Duration) -> Self {
+ self.timeout = timeout;
+ self
+ }
+
+ pub fn get(&self, k: &K) -> Option<&V> {
+ match self.map.get(k) {
+ Some(t) => {
+ if t.0.elapsed() >= self.timeout {
+ return None;
+ }
+ Some(&t.1)
+ }
+ None => None,
+ }
+ }
+
+ pub fn insert(&mut self, k: K, v: V) {
+ let now = Instant::now();
+ self.map.insert(k, (now, v));
+ }
+}
+
// TODO: remove this struct
#[derive(Serialize, Deserialize)]
pub struct CacheData {
diff --git a/fractal-gtk/src/cache/state.rs b/fractal-gtk/src/cache/state.rs
index 69b0adf6..f86dc1fe 100644
--- a/fractal-gtk/src/cache/state.rs
+++ b/fractal-gtk/src/cache/state.rs
@@ -13,8 +13,8 @@ use std::sync::{Arc, Mutex, MutexGuard};
use crate::types::Message;
use crate::types::Room;
+use crate::util::cache_dir_path;
use fractal_api::identifiers::UserId;
-use fractal_api::util::cache_dir_path;
// Models
diff --git a/fractal-matrix-api/src/client.rs b/fractal-gtk/src/client.rs
similarity index 79%
rename from fractal-matrix-api/src/client.rs
rename to fractal-gtk/src/client.rs
index f58ace9c..605032dd 100644
--- a/fractal-matrix-api/src/client.rs
+++ b/fractal-gtk/src/client.rs
@@ -47,16 +47,16 @@ impl ProxySettings {
pub fn apply_to_client_builder(
&self,
- mut builder: reqwest::blocking::ClientBuilder,
- ) -> Result<reqwest::blocking::ClientBuilder, reqwest::Error> {
+ mut builder: fractal_api::reqwest::blocking::ClientBuilder,
+ ) -> Result<fractal_api::reqwest::blocking::ClientBuilder, fractal_api::reqwest::Error> {
// Reqwest only supports one proxy for each type
if !self.http_proxy.is_empty() && self.http_proxy[0] != PROXY_DIRECT_URI {
- let proxy = reqwest::Proxy::http(&self.http_proxy[0])?;
+ let proxy = fractal_api::reqwest::Proxy::http(&self.http_proxy[0])?;
builder = builder.proxy(proxy);
}
if !self.https_proxy.is_empty() && self.https_proxy[0] != PROXY_DIRECT_URI {
- let proxy = reqwest::Proxy::https(&self.https_proxy[0])?;
+ let proxy = fractal_api::reqwest::Proxy::https(&self.https_proxy[0])?;
builder = builder.proxy(proxy);
}
@@ -72,7 +72,7 @@ thread_local! {
#[derive(Debug)]
struct ClientInner {
- client: reqwest::blocking::Client,
+ client: fractal_api::reqwest::blocking::Client,
proxy_settings: ProxySettings,
}
@@ -85,13 +85,13 @@ impl Client {
pub fn new() -> Client {
Client {
inner: Mutex::new(ClientInner {
- client: Self::build(reqwest::blocking::Client::builder()),
+ client: Self::build(fractal_api::reqwest::blocking::Client::builder()),
proxy_settings: ProxySettings::direct(),
}),
}
}
- pub fn get_client(&self) -> Result<reqwest::blocking::Client, Error> {
+ pub fn get_client(&self) -> Result<fractal_api::reqwest::blocking::Client, Error> {
// Lock first so we don't overwrite proxy settings with outdated information
let mut inner = self.inner.lock().unwrap();
@@ -100,7 +100,7 @@ impl Client {
if inner.proxy_settings == new_proxy_settings {
Ok(inner.client.clone())
} else {
- let mut builder = reqwest::blocking::Client::builder();
+ let mut builder = fractal_api::reqwest::blocking::Client::builder();
builder = new_proxy_settings.apply_to_client_builder(builder)?;
let client = Self::build(builder);
@@ -111,7 +111,9 @@ impl Client {
}
}
- fn build(builder: reqwest::blocking::ClientBuilder) -> reqwest::blocking::Client {
+ fn build(
+ builder: fractal_api::reqwest::blocking::ClientBuilder,
+ ) -> fractal_api::reqwest::blocking::Client {
builder
.gzip(true)
.timeout(Duration::from_secs(globals::TIMEOUT))
diff --git a/fractal-matrix-api/src/error.rs b/fractal-gtk/src/error.rs
similarity index 85%
rename from fractal-matrix-api/src/error.rs
rename to fractal-gtk/src/error.rs
index 02086a5a..e0109494 100644
--- a/fractal-matrix-api/src/error.rs
+++ b/fractal-gtk/src/error.rs
@@ -1,4 +1,4 @@
-use ruma_identifiers::{EventId, RoomId};
+use fractal_api::identifiers::{EventId, RoomId};
use std::io;
use std::time::SystemTimeError;
@@ -27,18 +27,17 @@ macro_rules! derror {
pub enum Error {
BackendError,
CacheError,
- ReqwestError(reqwest::Error),
- NetworkError(reqwest::StatusCode),
+ ReqwestError(fractal_api::reqwest::Error),
+ NetworkError(fractal_api::reqwest::StatusCode),
MatrixError(MatrixErrorCode, String),
SendMsgError(String),
SendMsgRedactionError(EventId),
TokenUsed,
Denied,
- NotLoggedIn,
}
-impl From<reqwest::Error> for Error {
- fn from(err: reqwest::Error) -> Error {
+impl From<fractal_api::reqwest::Error> for Error {
+ fn from(err: fractal_api::reqwest::Error) -> Error {
Error::ReqwestError(err)
}
}
@@ -49,11 +48,11 @@ impl From<StandardErrorResponse> for Error {
}
}
-derror!(url::ParseError, Error::BackendError);
+derror!(fractal_api::url::ParseError, Error::BackendError);
derror!(io::Error, Error::BackendError);
derror!(glib::error::Error, Error::BackendError);
derror!(regex::Error, Error::BackendError);
-derror!(ruma_identifiers::Error, Error::BackendError);
+derror!(fractal_api::identifiers::Error, Error::BackendError);
derror!(SystemTimeError, Error::BackendError);
derror!(serde_json::Error, Error::CacheError);
@@ -61,9 +60,7 @@ derror!(serde_json::Error, Error::CacheError);
#[derive(Debug)]
pub enum BKError {
LoginError(Error),
- GuestLoginError(Error),
SendTypingError(Error),
- SetRoomError(Error),
InviteError(Error),
ChangeLanguageError(Error),
NameError(Error),
diff --git a/fractal-gtk/src/globals.rs b/fractal-gtk/src/globals.rs
index 1c8abe49..35b8e5e8 100644
--- a/fractal-gtk/src/globals.rs
+++ b/fractal-gtk/src/globals.rs
@@ -1,5 +1,13 @@
+use directories::ProjectDirs;
use fractal_api::url::Url;
use lazy_static::lazy_static;
+use regex::Regex;
+use std::path::PathBuf;
+
+pub static TIMEOUT: u64 = 80;
+pub static PAGE_LIMIT: i32 = 40;
+pub static ROOM_DIRECTORY_LIMIT: i32 = 20;
+pub static DEVICE_NAME: &str = "Fractal";
pub static CACHE_SIZE: usize = 40;
pub static MSG_ICON_SIZE: i32 = 40;
@@ -17,4 +25,13 @@ lazy_static! {
Url::parse("https://matrix.org").expect("Malformed DEFAULT_HOMESERVER value");
pub static ref DEFAULT_IDENTITYSERVER: Url =
Url::parse("https://vector.im").expect("Malformed DEFAULT_IDENTITYSERVER value");
+ pub static ref EMAIL_RE: Regex = Regex::new(
+ r"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])+@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
+ )
+ .unwrap();
+ pub static ref CACHE_PATH: PathBuf = ProjectDirs::from("org", "GNOME", "Fractal")
+ .as_ref()
+ .map(ProjectDirs::cache_dir)
+ .map(Into::into)
+ .unwrap_or_else(|| std::env::temp_dir().join("fractal"));
}
diff --git a/fractal-gtk/src/main.rs b/fractal-gtk/src/main.rs
index 61382633..db5fe211 100644
--- a/fractal-gtk/src/main.rs
+++ b/fractal-gtk/src/main.rs
@@ -1,13 +1,13 @@
-use fractal_api::backend;
-use fractal_api::error;
-use fractal_api::types;
-
+mod backend;
+mod client;
mod config;
+mod error;
mod globals;
mod i18n;
#[macro_use]
mod util;
mod cache;
+mod model;
mod passwd;
mod static_resources;
mod uibuilder;
@@ -19,6 +19,7 @@ mod widgets;
mod appop;
+mod types;
use std::error::Error;
use crate::app::App;
diff --git a/fractal-gtk/src/meson.build b/fractal-gtk/src/meson.build
index 68d12237..3a60537b 100644
--- a/fractal-gtk/src/meson.build
+++ b/fractal-gtk/src/meson.build
@@ -49,16 +49,17 @@ app_sources = files(
'actions/account_settings.rs',
'actions/global.rs',
'actions/login.rs',
- 'actions/mod.rs',
'actions/message.rs',
+ 'actions/mod.rs',
'actions/room_settings.rs',
'app/connect/account.rs',
'app/connect/autocomplete.rs',
- 'app/connect/direct.rs',
'app/connect/directory.rs',
+ 'app/connect/direct.rs',
'app/connect/headerbar.rs',
'app/connect/invite.rs',
'app/connect/join_room.rs',
+ 'app/connect/language.rs',
'app/connect/leave_room.rs',
'app/connect/markdown.rs',
'app/connect/mod.rs',
@@ -86,8 +87,21 @@ app_sources = files(
'appop/state.rs',
'appop/sync.rs',
'appop/user.rs',
+ 'backend/directory.rs',
+ 'backend/media.rs',
+ 'backend/mod.rs',
+ 'backend/register.rs',
+ 'backend/room.rs',
+ 'backend/sync.rs',
+ 'backend/user.rs',
'cache/mod.rs',
'cache/state.rs',
+ 'model/event.rs',
+ 'model/fileinfo.rs',
+ 'model/member.rs',
+ 'model/message.rs',
+ 'model/mod.rs',
+ 'model/room.rs',
'widgets/address.rs',
'widgets/autocomplete.rs',
'widgets/avatar.rs',
@@ -96,28 +110,33 @@ app_sources = files(
'widgets/file_dialog.rs',
'widgets/image.rs',
'widgets/inline_player.rs',
+ 'widgets/kicked_dialog.rs',
'widgets/login.rs',
'widgets/media_viewer.rs',
'widgets/member.rs',
'widgets/members_list.rs',
- 'widgets/message.rs',
'widgets/message_menu.rs',
+ 'widgets/message.rs',
'widgets/mod.rs',
- 'widgets/room.rs',
- 'widgets/room_history.rs',
- 'widgets/roomlist.rs',
- 'widgets/roomrow.rs',
'widgets/room_history.rs',
'widgets/roomlist.rs',
'widgets/roomrow.rs',
+ 'widgets/room.rs',
'widgets/room_settings.rs',
'widgets/scroll_widget.rs',
'widgets/source_dialog.rs',
'widgets/sourceview_entry.rs',
+ 'client.rs',
+ 'config.rs',
+ 'config.rs.in',
+ 'error.rs',
'globals.rs',
'i18n.rs',
'main.rs',
'passwd.rs',
+ 'static_resources.rs',
+ 'static_resources.rs.in',
+ 'types.rs',
'uibuilder.rs',
'uitypes.rs',
'util.rs'
diff --git a/fractal-matrix-api/src/model/event.rs b/fractal-gtk/src/model/event.rs
similarity index 85%
rename from fractal-matrix-api/src/model/event.rs
rename to fractal-gtk/src/model/event.rs
index 7de9d45f..57caa11d 100644
--- a/fractal-matrix-api/src/model/event.rs
+++ b/fractal-gtk/src/model/event.rs
@@ -1,4 +1,4 @@
-use ruma_identifiers::{EventId, RoomId, UserId};
+use fractal_api::identifiers::{EventId, RoomId, UserId};
use serde_json::Value as JsonValue;
#[derive(Debug, Clone)]
diff --git a/fractal-matrix-api/src/model/fileinfo.rs b/fractal-gtk/src/model/fileinfo.rs
similarity index 100%
rename from fractal-matrix-api/src/model/fileinfo.rs
rename to fractal-gtk/src/model/fileinfo.rs
diff --git a/fractal-matrix-api/src/model/member.rs b/fractal-gtk/src/model/member.rs
similarity index 88%
rename from fractal-matrix-api/src/model/member.rs
rename to fractal-gtk/src/model/member.rs
index 6d9913ab..f8c807f8 100644
--- a/fractal-matrix-api/src/model/member.rs
+++ b/fractal-gtk/src/model/member.rs
@@ -1,9 +1,9 @@
-use crate::r0::search::user::User;
-use crate::r0::sync::get_joined_members::RoomMember;
-use ruma_identifiers::UserId;
+use fractal_api::identifiers::UserId;
+use fractal_api::r0::search::user::User;
+use fractal_api::r0::sync::get_joined_members::RoomMember;
+use fractal_api::url::Url;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
-use url::Url;
// TODO: Make this non-(de)serializable
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/fractal-matrix-api/src/model/message.rs b/fractal-gtk/src/model/message.rs
similarity index 99%
rename from fractal-matrix-api/src/model/message.rs
rename to fractal-gtk/src/model/message.rs
index fb3658e3..06af4ab5 100644
--- a/fractal-matrix-api/src/model/message.rs
+++ b/fractal-gtk/src/model/message.rs
@@ -1,7 +1,7 @@
use chrono::prelude::*;
use chrono::DateTime;
use chrono::TimeZone;
-use ruma_identifiers::{Error as IdError, EventId, RoomId, UserId};
+use fractal_api::identifiers::{Error as IdError, EventId, RoomId, UserId};
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use std::cmp::Ordering;
diff --git a/fractal-matrix-api/src/model/mod.rs b/fractal-gtk/src/model/mod.rs
similarity index 100%
rename from fractal-matrix-api/src/model/mod.rs
rename to fractal-gtk/src/model/mod.rs
diff --git a/fractal-matrix-api/src/model/room.rs b/fractal-gtk/src/model/room.rs
similarity index 98%
rename from fractal-matrix-api/src/model/room.rs
rename to fractal-gtk/src/model/room.rs
index 8ecfb8bd..80856f4e 100644
--- a/fractal-matrix-api/src/model/room.rs
+++ b/fractal-gtk/src/model/room.rs
@@ -4,14 +4,14 @@ use crate::backend::user::get_user_avatar;
use crate::model::member::Member;
use crate::model::member::MemberList;
use crate::model::message::Message;
-use crate::r0::directory::post_public_rooms::Chunk as PublicRoomsChunk;
-use crate::r0::sync::sync_events::Response as SyncResponse;
+use fractal_api::identifiers::{Error as IdError, EventId, RoomId, UserId};
+use fractal_api::r0::directory::post_public_rooms::Chunk as PublicRoomsChunk;
+use fractal_api::r0::sync::sync_events::Response as SyncResponse;
+use fractal_api::url::Url;
use log::{debug, info};
-use ruma_identifiers::{Error as IdError, EventId, RoomId, UserId};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::convert::{TryFrom, TryInto};
-use url::Url;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum RoomMembership {
@@ -23,6 +23,7 @@ pub enum RoomMembership {
Left(Reason),
}
+#[allow(dead_code)]
impl RoomMembership {
pub fn is_joined(&self) -> bool {
if let RoomMembership::Joined(_) = self {
diff --git a/fractal-gtk/src/passwd.rs b/fractal-gtk/src/passwd.rs
index 966ea78a..538136fc 100644
--- a/fractal-gtk/src/passwd.rs
+++ b/fractal-gtk/src/passwd.rs
@@ -1,4 +1,4 @@
-use fractal_api::derror;
+use crate::derror;
use fractal_api::identifiers::{Error as IdError, UserId};
use fractal_api::r0::AccessToken;
use fractal_api::url::ParseError;
diff --git a/fractal-matrix-api/src/types.rs b/fractal-gtk/src/types.rs
similarity index 100%
rename from fractal-matrix-api/src/types.rs
rename to fractal-gtk/src/types.rs
diff --git a/fractal-gtk/src/util.rs b/fractal-gtk/src/util.rs
index 5d2e6b0d..4cc23912 100644
--- a/fractal-gtk/src/util.rs
+++ b/fractal-gtk/src/util.rs
@@ -1,12 +1,14 @@
+use crate::error::Error;
+use crate::globals::CACHE_PATH;
use failure::format_err;
-use failure::Error;
+use failure::Error as FailError;
use gdk::prelude::*;
use gdk_pixbuf::Pixbuf;
use gio::{Settings, SettingsExt, SettingsSchemaSource};
-
-use log::error;
-
use html2pango::{html_escape, markup_links};
+use log::error;
+use std::fs::create_dir_all;
+use std::sync::mpsc::SendError;
pub mod glib_thread_prelude {
pub use crate::error::Error;
@@ -39,7 +41,39 @@ macro_rules! glib_thread {
}};
}
-pub fn get_pixbuf_data(pb: &Pixbuf) -> Result<Vec<u8>, Error> {
+// from https://stackoverflow.com/a/43992218/1592377
+#[macro_export]
+macro_rules! clone {
+ (@param _) => ( _ );
+ (@param $x:ident) => ( $x );
+ ($($n:ident),+ => move || $body:expr) => (
+ {
+ $( let $n = $n.clone(); )+
+ move || $body
+ }
+ );
+ ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
+ {
+ $( let $n = $n.clone(); )+
+ move |$(clone!(@param $p),)+| $body
+ }
+ );
+}
+
+pub fn cache_dir_path(dir: Option<&str>, name: &str) -> Result<String, Error> {
+ let path = CACHE_PATH.join(dir.unwrap_or_default());
+
+ if !path.is_dir() {
+ create_dir_all(&path)?;
+ }
+
+ path.join(name)
+ .to_str()
+ .map(Into::into)
+ .ok_or(Error::CacheError)
+}
+
+pub fn get_pixbuf_data(pb: &Pixbuf) -> Result<Vec<u8>, FailError> {
let image = cairo::ImageSurface::create(cairo::Format::ARgb32, pb.get_width(), pb.get_height())
.or_else(|_| Err(format_err!("Cairo Error")))?;
@@ -101,3 +135,15 @@ macro_rules! unwrap_or_unit_return {
}
};
}
+
+pub trait ResultExpectLog {
+ fn expect_log(&self, log: &str);
+}
+
+impl<T> ResultExpectLog for Result<(), SendError<T>> {
+ fn expect_log(&self, log: &str) {
+ if self.is_err() {
+ error!("{}", log);
+ }
+ }
+}
diff --git a/fractal-gtk/src/widgets/autocomplete.rs b/fractal-gtk/src/widgets/autocomplete.rs
index 7da3c176..212f45cb 100644
--- a/fractal-gtk/src/widgets/autocomplete.rs
+++ b/fractal-gtk/src/widgets/autocomplete.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use log::info;
use std::cell::RefCell;
use std::collections::HashMap;
diff --git a/fractal-gtk/src/widgets/avatar.rs b/fractal-gtk/src/widgets/avatar.rs
index d386179f..fcd1fe34 100644
--- a/fractal-gtk/src/widgets/avatar.rs
+++ b/fractal-gtk/src/widgets/avatar.rs
@@ -1,7 +1,7 @@
use std::cell::RefCell;
use std::rc::Rc;
-use fractal_api::util::cache_dir_path;
+use crate::util::cache_dir_path;
use gdk::prelude::GdkContextExt;
use gdk_pixbuf::Pixbuf;
use gtk::prelude::*;
diff --git a/fractal-gtk/src/widgets/inline_player.rs b/fractal-gtk/src/widgets/inline_player.rs
index 657af9d7..efa9d54d 100644
--- a/fractal-gtk/src/widgets/inline_player.rs
+++ b/fractal-gtk/src/widgets/inline_player.rs
@@ -18,7 +18,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
use crate::backend::{media, ThreadPool};
-use fractal_api::clone;
+use crate::clone;
use gst::prelude::*;
use gst::ClockTime;
diff --git a/fractal-gtk/src/widgets/media_viewer.rs b/fractal-gtk/src/widgets/media_viewer.rs
index 5e450ca2..3c534476 100644
--- a/fractal-gtk/src/widgets/media_viewer.rs
+++ b/fractal-gtk/src/widgets/media_viewer.rs
@@ -1,6 +1,6 @@
use crate::backend::media;
use crate::backend::ThreadPool;
-use fractal_api::clone;
+use crate::clone;
use fractal_api::r0::AccessToken;
use fragile::Fragile;
diff --git a/fractal-gtk/src/widgets/members_list.rs b/fractal-gtk/src/widgets/members_list.rs
index a31d0afc..ca106158 100644
--- a/fractal-gtk/src/widgets/members_list.rs
+++ b/fractal-gtk/src/widgets/members_list.rs
@@ -1,4 +1,4 @@
-use fractal_api::clone;
+use crate::clone;
use fractal_api::identifiers::UserId;
use std::cell::RefCell;
use std::collections::hash_map::HashMap;
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index 8765ff41..172393fb 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -2,8 +2,8 @@ use crate::i18n::i18n;
use itertools::Itertools;
use crate::backend::ThreadPool;
+use crate::cache::CacheMap;
use chrono::prelude::*;
-use fractal_api::cache::CacheMap;
use fractal_api::identifiers::UserId;
use fractal_api::url::Url;
use gtk::{prelude::*, ButtonExt, ContainerExt, LabelExt, Overlay, WidgetExt};
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index d1b364c8..c469095b 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -15,10 +15,10 @@ use crate::uitypes::MessageContent;
use crate::uitypes::RowType;
use crate::backend::ThreadPool;
+use crate::cache::CacheMap;
use crate::globals;
use crate::widgets;
use crate::widgets::{PlayerExt, VideoPlayerWidget};
-use fractal_api::cache::CacheMap;
use fractal_api::identifiers::{RoomId, UserId};
use fractal_api::url::Url;
use gio::ActionMapExt;
diff --git a/fractal-gtk/src/widgets/room_settings.rs b/fractal-gtk/src/widgets/room_settings.rs
index c2964257..dd17fc11 100644
--- a/fractal-gtk/src/widgets/room_settings.rs
+++ b/fractal-gtk/src/widgets/room_settings.rs
@@ -1,5 +1,5 @@
use crate::backend::room;
-use fractal_api::clone;
+use crate::clone;
use fractal_api::identifiers::UserId;
use fractal_api::r0::AccessToken;
use std::cell::RefCell;
diff --git a/fractal-gtk/src/widgets/roomlist.rs b/fractal-gtk/src/widgets/roomlist.rs
index 12972ee2..88dc6ff7 100644
--- a/fractal-gtk/src/widgets/roomlist.rs
+++ b/fractal-gtk/src/widgets/roomlist.rs
@@ -1,5 +1,5 @@
+use crate::clone;
use crate::i18n::i18n;
-use fractal_api::clone;
use fractal_api::identifiers::RoomId;
use fractal_api::url::Url;
diff --git a/fractal-matrix-api/Cargo.toml b/fractal-matrix-api/Cargo.toml
index 74ae20e0..2502c20a 100644
--- a/fractal-matrix-api/Cargo.toml
+++ b/fractal-matrix-api/Cargo.toml
@@ -16,22 +16,13 @@ repository = "https://gitlab.gnome.org/GNOME/fractal"
documentation = "https://gnome.pages.gitlab.gnome.org/fractal/fractal_matrix_api/index.html"
[dependencies]
-directories = "2.0.2"
-lazy_static = "1.4.0"
-log = "0.4.8"
-md5 = "0.7.0"
regex = "1.3.4"
-ruma-identifiers = "0.16"
serde_json = "1.0.48"
-time = "0.2.7"
-urlencoding = "1.0.0"
gio = "0.8.1"
-percent-encoding = "2.1.0"
-glib = "0.9.3"
-[dependencies.chrono]
-version = "0.4.10"
-features = ["serde"]
+[dependencies.ruma-identifiers]
+version = "0.16"
+features = ["rand"]
[dependencies.serde]
version = "1.0.104"
diff --git a/fractal-matrix-api/src/lib.rs b/fractal-matrix-api/src/lib.rs
index 9ec18d40..ad87e5e8 100644
--- a/fractal-matrix-api/src/lib.rs
+++ b/fractal-matrix-api/src/lib.rs
@@ -1,16 +1,8 @@
#[macro_use]
-pub mod util;
-pub mod error;
-pub mod globals;
-
-pub mod backend;
-pub mod cache;
-mod client;
pub mod identity;
-mod model;
pub mod r0;
-pub mod types;
+pub use reqwest;
pub use ruma_identifiers as identifiers;
pub use url;
diff --git a/fractal-matrix-api/src/meson.build b/fractal-matrix-api/src/meson.build
index 29b9bc74..5bdbe0e2 100644
--- a/fractal-matrix-api/src/meson.build
+++ b/fractal-matrix-api/src/meson.build
@@ -1,68 +1,69 @@
api_sources = files(
- 'backend/directory.rs',
- 'backend/media.rs',
- 'backend/mod.rs',
- 'backend/register.rs',
- 'backend/room.rs',
- 'backend/sync.rs',
- 'backend/user.rs',
'identity/r0/association/msisdn/submit_token.rs',
'identity/r0/association/msisdn.rs',
'identity/r0/association.rs',
'identity/r0.rs',
- 'model/event.rs',
- 'model/fileinfo.rs',
- 'model/member.rs',
- 'model/message.rs',
- 'model/mod.rs',
- 'model/room.rs',
'r0/account/change_password.rs',
'r0/account/deactivate.rs',
'r0/account/login.rs',
'r0/account/logout.rs',
'r0/account/register.rs',
+ 'r0/config/get_global_account_data.rs',
+ 'r0/config/set_global_account_data.rs',
+ 'r0/config/set_room_account_data.rs',
'r0/contact/create.rs',
'r0/contact/delete.rs',
'r0/contact/get_identifiers.rs',
'r0/contact/request_verification_token_email.rs',
'r0/contact/request_verification_token_msisdn.rs',
+ 'r0/context/get_context.rs',
'r0/directory/post_public_rooms.rs',
'r0/media/create_content.rs',
+ 'r0/media/get_content.rs',
+ 'r0/media/get_content_thumbnail.rs',
'r0/membership/invite_user.rs',
'r0/membership/join_room_by_id_or_alias.rs',
'r0/membership/leave_room.rs',
+ 'r0/message/create_message_event.rs',
+ 'r0/message/get_message_events.rs',
'r0/profile/get_display_name.rs',
'r0/profile/get_profile.rs',
'r0/profile/set_avatar_url.rs',
'r0/profile/set_display_name.rs',
+ 'r0/read_marker/set_read_marker.rs',
+ 'r0/redact/redact_event.rs',
+ 'r0/room/create_room.rs',
'r0/search/user.rs',
'r0/server/domain_info.rs',
+ 'r0/state/create_state_events_for_key.rs',
+ 'r0/state/get_state_events_for_key.rs',
'r0/sync/get_joined_members.rs',
'r0/sync/sync_events.rs',
'r0/tag/create_tag.rs',
'r0/tag/delete_tag.rs',
'r0/thirdparty/get_supported_protocols.rs',
'r0/account.rs',
+ 'r0/config.rs',
'r0/contact.rs',
+ 'r0/context.rs',
'r0/directory.rs',
'r0/filter.rs',
'r0/media.rs',
'r0/membership.rs',
+ 'r0/message.rs',
'r0/profile.rs',
+ 'r0/read_marker.rs',
+ 'r0/redact.rs',
+ 'r0/room.rs',
'r0/search.rs',
'r0/server.rs',
+ 'r0/state.rs',
'r0/sync.rs',
'r0/tag.rs',
'r0/thirdparty.rs',
'r0/typing.rs',
- 'cache.rs',
- 'client.rs',
- 'error.rs',
- 'globals.rs',
'identity.rs',
'lib.rs',
- 'meson.build',
'r0.rs',
- 'types.rs',
'util.rs'
)
diff --git a/fractal-matrix-api/src/util.rs b/fractal-matrix-api/src/util.rs
index 2095ae6a..fd40910d 100644
--- a/fractal-matrix-api/src/util.rs
+++ b/fractal-matrix-api/src/util.rs
@@ -1,52 +1,4 @@
-use log::error;
-use std::fs::create_dir_all;
-use std::sync::mpsc::SendError;
-use crate::error::Error;
-use crate::globals::CACHE_PATH;
-// from https://stackoverflow.com/a/43992218/1592377
-#[macro_export]
-macro_rules! clone {
- (@param _) => ( _ );
- (@param $x:ident) => ( $x );
- ($($n:ident),+ => move || $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move || $body
- }
- );
- ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move |$(clone!(@param $p),)+| $body
- }
- );
-}
-
-pub fn cache_dir_path(dir: Option<&str>, name: &str) -> Result<String, Error> {
- let path = CACHE_PATH.join(dir.unwrap_or_default());
-
- if !path.is_dir() {
- create_dir_all(&path)?;
- }
-
- path.join(name)
- .to_str()
- .map(Into::into)
- .ok_or(Error::CacheError)
-}
-
-pub trait ResultExpectLog {
- fn expect_log(&self, log: &str);
-}
-
-impl<T> ResultExpectLog for Result<(), SendError<T>> {
- fn expect_log(&self, log: &str) {
- if self.is_err() {
- error!("{}", log);
- }
- }
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]