diff --git a/Cargo.lock b/Cargo.lock index 0894e0ff..7fdf55d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,9 +559,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.40" +version = "1.2.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" +checksum = "ac9fe6cdbb24b6ade63616c0a0688e45bb56732262c158df3c0c4bea4ca47cb7" dependencies = [ "find-msvc-tools", "jobserver", @@ -1071,9 +1071,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" dependencies = [ "log", ] @@ -1214,9 +1214,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" [[package]] name = "flate2" @@ -1555,9 +1555,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ "typenum", "version_check", @@ -1608,9 +1608,9 @@ dependencies = [ [[package]] name = "gettext-rs" -version = "0.7.2" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44e92f7dc08430aca7ed55de161253a22276dfd69c5526e5c5e95d1f7cf338a" +checksum = "5d5857dc1b7f0fee86961de833f434e29494d72af102ce5355738c0664222bdf" dependencies = [ "gettext-sys", "locale_config", @@ -1618,9 +1618,9 @@ dependencies = [ [[package]] name = "gettext-sys" -version = "0.22.5" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb45773f5b8945f12aecd04558f545964f943dacda1b1155b3d738f5469ef661" +checksum = "4ea859ab0dd7e70ff823032b3e077d03d39c965d68c6c10775add60e999d8ee9" dependencies = [ "cc", "temp-dir", @@ -1739,9 +1739,9 @@ dependencies = [ [[package]] name = "glycin" -version = "3.0.1" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "676771412bd09ca3b7a4205303d5c0f66c1799056f2c0d0360840ac9aa7f28cc" +checksum = "04fbbe8670e734650c5a96e6107ab52dd14e25b339067e6e6bc1f0e919a3aea4" dependencies = [ "futures-channel", "futures-util", @@ -1770,9 +1770,9 @@ dependencies = [ [[package]] name = "glycin-common" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2382f0d91d42f750486e7c8316cba4781404e574458b5f28d91daff1656e73b" +checksum = "6e9b31c7fa5ccb9d91317c956e767daef59be9fee3ae9df30468470368678482" dependencies = [ "bitflags", "gufo-common", @@ -1789,9 +1789,9 @@ dependencies = [ [[package]] name = "glycin-utils" -version = "4.0.2" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba1a5de693aca0e846f0f62a302d3eacac855eb148e47398e30670c508cc525" +checksum = "c1653ce5042ac6ebee1130347ef2f820a965c0cdd849be60fba492c0117eb131" dependencies = [ "async-lock", "bitflags", @@ -2197,9 +2197,9 @@ dependencies = [ [[package]] name = "half" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" dependencies = [ "cfg-if", "crunchy", @@ -2896,9 +2896,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.176" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libloading" @@ -3188,7 +3188,7 @@ dependencies = [ [[package]] name = "matrix-sdk" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "anymap2", "aquamarine", @@ -3246,7 +3246,7 @@ dependencies = [ [[package]] name = "matrix-sdk-base" version = "0.14.1" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "as_variant", "async-trait", @@ -3273,7 +3273,7 @@ dependencies = [ [[package]] name = "matrix-sdk-common" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "eyeball-im", "futures-core", @@ -3296,7 +3296,7 @@ dependencies = [ [[package]] name = "matrix-sdk-crypto" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "aes", "aquamarine", @@ -3337,10 +3337,11 @@ dependencies = [ [[package]] name = "matrix-sdk-indexeddb" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "async-trait", "base64", + "futures-util", "getrandom 0.2.16", "gloo-utils", "hkdf", @@ -3365,7 +3366,7 @@ dependencies = [ [[package]] name = "matrix-sdk-qrcode" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "byteorder", "qrcode", @@ -3377,7 +3378,7 @@ dependencies = [ [[package]] name = "matrix-sdk-sqlite" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "as_variant", "async-trait", @@ -3403,7 +3404,7 @@ dependencies = [ [[package]] name = "matrix-sdk-store-encryption" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "base64", "blake3", @@ -3422,7 +3423,7 @@ dependencies = [ [[package]] name = "matrix-sdk-ui" version = "0.14.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=6191e2c24e3d01e6f52ad931d0bddbb1ae85b368#6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +source = "git+https://github.com/matrix-org/matrix-rust-sdk.git?rev=c1bc814ac2c306da704c5e10b7feda2e207beb19#c1bc814ac2c306da704c5e10b7feda2e207beb19" dependencies = [ "as_variant", "async-rx", @@ -3578,11 +3579,11 @@ dependencies = [ [[package]] name = "nu-ansi-term" -version = "0.50.1" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4092,7 +4093,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit 0.23.6", + "toml_edit 0.23.7", ] [[package]] @@ -4302,9 +4303,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.3" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", @@ -4314,9 +4315,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -4325,15 +4326,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "reqwest" -version = "0.12.23" +version = "0.12.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" dependencies = [ "async-compression", "base64", @@ -4420,7 +4421,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.13.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "assign", "js_int", @@ -4437,7 +4438,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.21.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "as_variant", "assign", @@ -4460,7 +4461,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.16.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "as_variant", "base64", @@ -4493,7 +4494,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.31.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "as_variant", "indexmap", @@ -4519,7 +4520,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.12.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "headers", "http", @@ -4539,7 +4540,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.5.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "as_variant", "html5ever", @@ -4551,7 +4552,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "js_int", "thiserror 2.0.17", @@ -4560,7 +4561,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.16.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "cfg-if", "proc-macro-crate", @@ -4569,13 +4570,13 @@ dependencies = [ "ruma-identifiers-validation", "serde", "syn 2.0.106", - "toml 0.9.7", + "toml 0.9.8", ] [[package]] name = "ruma-signatures" version = "0.18.0" -source = "git+https://github.com/ruma/ruma.git?rev=8544b61f249c42ba58108f1cae4179ddbd312378#8544b61f249c42ba58108f1cae4179ddbd312378" +source = "git+https://github.com/ruma/ruma.git?rev=c441eccb92a36467217ff929cd71462fbeeeaf1a#c441eccb92a36467217ff929cd71462fbeeeaf1a" dependencies = [ "base64", "ed25519-dalek", @@ -4854,9 +4855,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" dependencies = [ "serde_core", ] @@ -4957,12 +4958,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -5018,9 +5019,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "static_assertions" @@ -5376,13 +5377,13 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" dependencies = [ "serde_core", - "serde_spanned 1.0.2", - "toml_datetime 0.7.2", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] @@ -5398,9 +5399,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] @@ -5420,21 +5421,21 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.23.6" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3effe7c0e86fdff4f69cdd2ccc1b96f933e24811c5441d44904e8683e27184b" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ "indexmap", - "toml_datetime 0.7.2", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] [[package]] name = "toml_parser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow", ] diff --git a/Cargo.toml b/Cargo.toml index c2c01d08..834a3fc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ sourceview = { package = "sourceview5", version = "0.10" } [dependencies.matrix-sdk] # version = "0.14" git = "https://github.com/matrix-org/matrix-rust-sdk.git" -rev = "6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +rev = "c1bc814ac2c306da704c5e10b7feda2e207beb19" default-features = false features = [ "e2e-encryption", @@ -91,17 +91,17 @@ features = [ [dependencies.matrix-sdk-store-encryption] # version = "0.14" git = "https://github.com/matrix-org/matrix-rust-sdk.git" -rev = "6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +rev = "c1bc814ac2c306da704c5e10b7feda2e207beb19" [dependencies.matrix-sdk-ui] # version = "0.14" git = "https://github.com/matrix-org/matrix-rust-sdk.git" -rev = "6191e2c24e3d01e6f52ad931d0bddbb1ae85b368" +rev = "c1bc814ac2c306da704c5e10b7feda2e207beb19" [dependencies.ruma] # version = "0.13" git = "https://github.com/ruma/ruma.git" -rev = "8544b61f249c42ba58108f1cae4179ddbd312378" +rev = "c441eccb92a36467217ff929cd71462fbeeeaf1a" features = [ "client-api-c", "markdown", diff --git a/src/account_settings/general_page/mod.rs b/src/account_settings/general_page/mod.rs index 846f5781..97b5c895 100644 --- a/src/account_settings/general_page/mod.rs +++ b/src/account_settings/general_page/mod.rs @@ -2,7 +2,16 @@ use adw::{prelude::*, subclass::prelude::*}; use gettextrs::gettext; use gtk::{gio, glib, glib::clone}; use matrix_sdk::authentication::oauth::{AccountManagementActionFull, AccountManagementUrlBuilder}; -use ruma::{OwnedMxcUri, api::client::discovery::get_capabilities::v3::Capabilities}; +use ruma::{ + OwnedMxcUri, + api::{ + OutgoingRequest, SupportedVersions, + client::{ + discovery::get_capabilities::v3::Capabilities, + profile::{ProfileFieldName, delete_profile_field}, + }, + }, +}; use tracing::error; mod change_password_subpage; @@ -59,8 +68,7 @@ mod imp { /// The ancestor [`AccountSettings`]. #[property(get, set = Self::set_account_settings, nullable)] account_settings: glib::WeakRef, - /// The possible changes on the homeserver. - capabilities: RefCell, + capabilities_data: RefCell, changing_avatar: RefCell>>, changing_display_name: RefCell>>, avatar_uri_handler: RefCell>, @@ -208,18 +216,34 @@ mod imp { let Some(session) = self.session.upgrade() else { return; }; + + let mut capabilities_data = CapabilitiesData::default(); + let client = session.client(); + let handle = spawn_tokio!(async move { + ( + client.get_capabilities().await, + client.supported_versions().await, + ) + }); + let (capabilities_result, supported_versions_result) = + handle.await.expect("task was not aborted"); - let handle = spawn_tokio!(async move { client.get_capabilities().await }); - let capabilities = match handle.await.expect("task was not aborted") { - Ok(capabilities) => capabilities, + match capabilities_result { + Ok(capabilities) => capabilities_data.capabilities = capabilities, Err(error) => { error!("Could not get server capabilities: {error}"); - Capabilities::default() } - }; + } - self.capabilities.replace(capabilities); + match supported_versions_result { + Ok(supported_versions) => capabilities_data.supported_versions = supported_versions, + Err(error) => { + error!("Could not get server supported versions: {error}"); + } + } + + self.capabilities_data.replace(capabilities_data); self.update_capabilities(); } @@ -232,14 +256,17 @@ mod imp { let uses_oauth_api = session.uses_oauth_api(); let has_account_management_url = self.account_management_url_builder().is_some(); - let capabilities = self.capabilities.borrow(); - - self.avatar - .set_editable(capabilities.set_avatar_url.enabled); - self.display_name - .set_editable(capabilities.set_displayname.enabled); - self.change_password_row - .set_visible(!has_account_management_url && capabilities.change_password.enabled); + let capabilities_data = self.capabilities_data.borrow(); + + self.avatar.set_editable( + capabilities_data.can_set_profile_field(&ProfileFieldName::AvatarUrl), + ); + self.display_name.set_editable( + capabilities_data.can_set_profile_field(&ProfileFieldName::DisplayName), + ); + self.change_password_row.set_visible( + !has_account_management_url && capabilities_data.can_change_password(), + ); self.manage_account_row .set_visible(has_account_management_url); self.deactivate_account_button @@ -543,3 +570,55 @@ impl GeneralPage { glib::Object::builder().property("session", session).build() } } + +/// The data necessary to compute the capabilities of the server. +#[derive(Debug, Clone)] +struct CapabilitiesData { + /// The capabilities advertised by the homeserver. + capabilities: Capabilities, + /// The Matrix versions supported by the homeserver. + supported_versions: SupportedVersions, +} + +impl CapabilitiesData { + /// Whether the user can set the given profile field according to these + /// capabilities. + fn can_set_profile_field(&self, field: &ProfileFieldName) -> bool { + // According to the Matrix spec about the `m.profile_fields` capability: + // > When this capability is not listed, clients SHOULD assume the user is able + // > to change profile fields without any restrictions, provided the homeserver + // > advertises a specification version that includes the m.profile_fields + // > capability in the /versions response. + if let Some(profile_fields) = &self.capabilities.profile_fields { + profile_fields.can_set_field(field) + } else if delete_profile_field::v3::Request::is_supported(&self.supported_versions) { + true + } else { + #[allow(deprecated)] + match field { + ProfileFieldName::AvatarUrl => self.capabilities.set_avatar_url.enabled, + ProfileFieldName::DisplayName => self.capabilities.set_displayname.enabled, + // Extended profile fields are not supported by the homeserver. + _ => false, + } + } + } + + /// Whether the user can change their account password according to these + /// capabilities. + fn can_change_password(&self) -> bool { + self.capabilities.change_password.enabled + } +} + +impl Default for CapabilitiesData { + fn default() -> Self { + Self { + capabilities: Default::default(), + supported_versions: SupportedVersions { + versions: Default::default(), + features: Default::default(), + }, + } + } +}