diff --git a/CHANGES.md b/CHANGES.md
index 47e57c76e4..b666cf2712 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,16 +3,25 @@ Changes in Element 1.0.14 (2020-XX-XX)
Features ✨:
- Enable url previews for notices (#2562)
+ - Edit room permissions (#2471)
Improvements 🙌:
- - Add System theme option and set as default (#904) (#2387)
- - Store megolm outbound session to improve send time of first message after app launch.
+ - Add System theme option and set as default (#904, #2387)
+ - Store megolm outbound session to improve send time of first message after app launch.
+ - Warn user when they are leaving a not public room (#1460)
+ - Option to disable emoji keyboard (#2563)
Bugfix 🐛:
- Unspecced msgType field in m.sticker (#2580)
- Wait for all room members to be known before sending a message to a e2e room (#2518)
- Url previews sometimes attached to wrong message (#2561)
+ - Room Topic not displayed correctly after visiting a link (#2551)
- Hiding membership events works the exact opposite (#2603)
+ - Tapping drawer having more than 1 room in notifications gives "malformed link" error (#2605)
+ - Sent image not displayed when opened immediately after sending (#409)
+ - Initial sync is not retried correctly when there is some network error. (#2632)
+ - Fix switch theme issue, and white field issue (#2599, #2528)
+ - Fix request too large Uri error when joining a room
Translations 🗣:
-
@@ -21,7 +30,7 @@ SDK API changes ⚠️:
-
Build 🧱:
- -
+ - Remove dependency to org.greenrobot.eventbus library
Test:
-
diff --git a/docs/ui-tests.md b/docs/ui-tests.md
index ff01da0b31..6ebb52abe8 100644
--- a/docs/ui-tests.md
+++ b/docs/ui-tests.md
@@ -27,7 +27,6 @@ $ source env/bin/activate
Every time you want to launch these test homeservers, type:
```shell script
-$ virtualenv -p python3 env
$ source env/bin/activate
(env) $ demo/start.sh --no-rate-limit
```
diff --git a/fastlane/metadata/android/de/changelogs/40100100.txt b/fastlane/metadata/android/de/changelogs/40100100.txt
index 70b786d12e..2faf4b5d39 100644
--- a/fastlane/metadata/android/de/changelogs/40100100.txt
+++ b/fastlane/metadata/android/de/changelogs/40100100.txt
@@ -1 +1,2 @@
-// TODO
+Diese neue Version enthält hauptsächlich Fehlerkorrekturen und Verbesserungen. Nachrichten verschicken geht jetzt viel schneller.
+Vollständige Versionshinweise: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/de/changelogs/40100110.txt b/fastlane/metadata/android/de/changelogs/40100110.txt
new file mode 100644
index 0000000000..e70007b5d7
--- /dev/null
+++ b/fastlane/metadata/android/de/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Diese neue Version enthält hauptsächlich Verbesserungen der Benutzer*innenoberfläche und der Handhabung. Du kannst jetzt ganz schnell Freund*innen einladen und DMs erstellen, indem du schlicht einen QR-Code scannst.
+Vollständige Versionshinweise: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/et/changelogs/40100100.txt b/fastlane/metadata/android/et/changelogs/40100100.txt
new file mode 100644
index 0000000000..11a040ceb0
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Selles uues versioonis leidub põhiliselt veaparandusi ja pisikohendusi. Sõnumite saatmine on nüüd märkatavalt kiirem.
+Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/et/changelogs/40100110.txt b/fastlane/metadata/android/et/changelogs/40100110.txt
new file mode 100644
index 0000000000..019a84a2be
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Uues versioonis leidub põhiliselt kasutajaliidese ning kasutajakogemuse parandusi. Nüüd saad sõpradele kutseid saata ning otsevestlusi alustada QR-koodi lugemise abil.
+Kõik muudatused: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/fa/changelogs/40100100.txt b/fastlane/metadata/android/fa/changelogs/40100100.txt
index 6123bfc7fc..080d80a3ad 100644
--- a/fastlane/metadata/android/fa/changelogs/40100100.txt
+++ b/fastlane/metadata/android/fa/changelogs/40100100.txt
@@ -1 +1,2 @@
-// برای انجام
+این نگارش جدید به طور عمده شامل رفع اشکالها و بهبودها است. ارسال پیام اکنون بسیار سریعتر است.
+گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/fa/changelogs/40100110.txt b/fastlane/metadata/android/fa/changelogs/40100110.txt
new file mode 100644
index 0000000000..c95922e2d7
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+این نگارش جدید به طور عمده شامل رابط کاربری و بهبود تجربه کاربر است. اکنون میتوانید با پویش کدهای QR دوستانتان را دعوت کرده و بسیار سریع پیام مستقیم ایجاد کنید.
+گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/fa/short_description.txt b/fastlane/metadata/android/fa/short_description.txt
index 4cfa767649..aba229f959 100644
--- a/fastlane/metadata/android/fa/short_description.txt
+++ b/fastlane/metadata/android/fa/short_description.txt
@@ -1 +1 @@
-گپ و تماس نامتمرکز امن. دادههایتان را از شرکتها امن نگه دارید.
+گپ و تماس نامتمرکز امن. دادههایتان را از اشخاص سوم امن نگه دارید.
diff --git a/fastlane/metadata/android/fa/title.txt b/fastlane/metadata/android/fa/title.txt
index fb4ea4125e..899b3d6adb 100644
--- a/fastlane/metadata/android/fa/title.txt
+++ b/fastlane/metadata/android/fa/title.txt
@@ -1 +1 @@
-المنت (ریوت سابق)
+Element (پیشتر Riot.im)
diff --git a/fastlane/metadata/android/fi/changelogs/40100110.txt b/fastlane/metadata/android/fi/changelogs/40100110.txt
new file mode 100644
index 0000000000..356eabd29b
--- /dev/null
+++ b/fastlane/metadata/android/fi/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Tämä versio sisältää pääosin käyttöliittymä- ja käyttökokemusparannuksia. Voit nyt kutsua kavereita ja luoda yksityisviestejä nopeasti QR-koodeja lukemalla.
+Täysi muutosloki: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/fi/full_description.txt b/fastlane/metadata/android/fi/full_description.txt
index 70def518da..947d19ce3d 100644
--- a/fastlane/metadata/android/fi/full_description.txt
+++ b/fastlane/metadata/android/fi/full_description.txt
@@ -1,30 +1,30 @@
Element on uudenlainen viestinsovellus, joka:
-1. Antaa sinun päättää yksityisyydestäsi.
+1. Antaa sinun päättää yksityisyydestäsi
2. Antaa sinun kommunikoida kenen tahansa kanssa Matrix-verkossa ja jopa sen ulkopuolella siltaamalla sovelluksiin, kuten Slack
3. Suojaa sinua mainonnalta, tietojen keräämiseltä ja suljetuilta alustoilta
4. Suojaa sinut päästä päähän -salauksella sekä ristiin varmentamisella muiden todentamiseksi
Element eroaa täysin muista viestintäsovelluksista, koska se on hajautettu ja avointa lähdekoodia.
-Element antaa sinun isännöidä itse - valita isännän - jotta sinulla on yksityisyys ja voit hallita tietojasi sekä keskustelujasi. Se antaa sinulle pääsyn avoimeen verkkoon; joten et ole jumissa Elementin käyttäjissä.
+Element antaa sinun isännöidä itse - tai valita palveluntarjoajan - jotta sinulla on yksityisyys ja voit hallita tietojasi sekä keskustelujasi. Se antaa sinulle pääsyn avoimeen verkkoon, joten et jää juttelemaan vain toisten Elementin käyttäjien kanssa. Se on myös hyvin turvallinen.
Element pystyy tekemään kaiken tämän, koska se toimii Matrixilla - avoimella, hajautetun viestinnän standardilla.
-Element antaa sinulle hallinnan antamalla sinun valita, kuka isännöi keskustelujasi. Element-sovelluksessa voit valita isännän eri tavoin:
+Element antaa sinulle päätösvallan antamalla sinun valita, kuka isännöi keskustelujasi. Element-sovelluksessa voit valita isännän eri tavoin:
1. Hanki ilmainen tili Matrix-kehittäjien ylläpitämällä matrix.org-palvelimella tai valitse tuhansista vapaaehtoisten ylläpitämistä julkisista palvelimista.
-2. Isännöi tiliäsi itse suorittamalla palvelinta omalla laitteellasi
-3. Luo tili mukautetulla palvelimella yksinkertaisesti tilaamalla Element Matrix Services -palvelu
+2. Isännöi tiliäsi itse ylläpitämällä palvelinta omalla laitteellasi
+3. Luo tili sinua varten tehdyllä palvelimella tilaamalla Element Matrix Services -palvelu
Miksi valita Element?
-OMAT TIEDOT: Sinä päätät, missä tietosi ja viestisi säilytetään. Hallitset sitä itse, eikä jokin MEGAYHTIÖ, joka tutkii tietojasi tai antaa niitä kolmansille osapuolille.
+OMAT TIEDOT: Sinä päätät, missä tietosi ja viestisi säilytetään. Sinä määräät, ei jokin jättiyhtiö, joka tutkii tietojasi tai antaa niitä kolmansille osapuolille.
-AVOIN KOMMUNIKOINYI JA YHTEISTYÖ: Voit keskustella kaikkien muiden Matrix-verkon käyttäjien kanssa, riippumatta siitä käyttävätkö he Elementiä tai muuta Matrix-sovellusta, ja vaikka he käyttäisivät eri viestijärjestelmiä, kuten Slack, IRC tai XMPP.
+AVOINTA VIESTINTÄÄ JA YHTEISTYÖTÄ: Voit keskustella kaikkien muiden Matrix-verkon käyttäjien kanssa, riippumatta siitä käyttävätkö he Elementiä tai muuta Matrix-sovellusta, ja vaikka he käyttäisivät eri viestijärjestelmiä, kuten Slack, IRC tai XMPP.
ERITTÄIN TURVALLINEN: Vahva päästä päähän -salaus (vain keskustelussa olevat voivat purkaa viestien salauksen), ja ristiin varmentaminen keskustelun osallistujien laitteiden tarkistamiseksi.
-TÄYDELLISTÄ VIESTINTÄÄ: Viestit, ääni- ja videopuhelut, tiedostojen jakaminen, näytön jakaminen ja koko joukko integraatioita, botteja ja widgettejä. Rakenna huoneita, yhteisöjä, pidä yhteyttä ja tee asioita.
+KATTAVAA VIESTINTÄÄ: Viestit, ääni- ja videopuhelut, tiedostojen jakaminen, näytön jakaminen ja koko joukko integraatioita, botteja ja sovelmia. Rakenna huoneita ja yhteisöjä, pidä yhteyttä ja hoida asiasi.
MISSÄ TAHANSA OLETKIN: Pidä yhteyttä missä tahansa, täysin synkronoidun viestihistorian kautta kaikilla laitteillasi ja verkossa osoitteessa https://app.element.io.
diff --git a/fastlane/metadata/android/fi/short_description.txt b/fastlane/metadata/android/fi/short_description.txt
index 5573ac1cb9..64f35a7dff 100644
--- a/fastlane/metadata/android/fi/short_description.txt
+++ b/fastlane/metadata/android/fi/short_description.txt
@@ -1 +1 @@
-Turvallista, hajautettua, keskusteluja ja VoIP-puheluita. Pidä tietosi turvassa.
+Turvallista, hajautettua keskustelua ja VoIP-puheluita. Pidä tietosi turvassa.
diff --git a/fastlane/metadata/android/fr/changelogs/40100100.txt b/fastlane/metadata/android/fr/changelogs/40100100.txt
new file mode 100644
index 0000000000..36ca3016b6
--- /dev/null
+++ b/fastlane/metadata/android/fr/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Cette nouvelle version contient principalement des corrections de bogues et des améliorations. Envoyer un message est maintenant plus rapide.
+Liste complète des changements : https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/hu/changelogs/40100100.txt b/fastlane/metadata/android/hu/changelogs/40100100.txt
new file mode 100644
index 0000000000..87a00efded
--- /dev/null
+++ b/fastlane/metadata/android/hu/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Ez az új verzió főképp hibajavításokat, és teljesítménybeli fejlesztéseket tartalmaz. Most már sokkal gyorsabb az üzenetek elküldése.
+A változtatások teljes listája itt található: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/hu/changelogs/40100110.txt b/fastlane/metadata/android/hu/changelogs/40100110.txt
new file mode 100644
index 0000000000..c14ed73aeb
--- /dev/null
+++ b/fastlane/metadata/android/hu/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Ez az új verzió főleg a felhasználói felülettel és a felhasználói élménnyel kapcsolatos javításokat tartalmaz. Mostantól már sokkal gyorsabban hívhatsz meg új ismerősöket a QR kód beolvasás által.
+A változtatások teljes listája itt található: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/hu/full_description.txt b/fastlane/metadata/android/hu/full_description.txt
index dfc842594d..b75f259d02 100644
--- a/fastlane/metadata/android/hu/full_description.txt
+++ b/fastlane/metadata/android/hu/full_description.txt
@@ -17,7 +17,7 @@ Az Element a te kezedbe adja az irányítást azáltal, hogy eldöntheted, ki t
2. A saját számítógépeden is futtathatsz szervert
3. Előfizethetsz egy saját szerverre az Element Matrix Szolgáltatások platformon
-Miért válaszd az Element-et?
+Miért jó az Element-et választani?
ADATAID MEGVÉDÉSE: Eldöntheted, hol tárold az adataid és üzeneteid. A te tulajdonodban van, nem valami megacégnél, ami bányássza az adataid, vagy továbbadja másoknak.
diff --git a/fastlane/metadata/android/it/changelogs/40100110.txt b/fastlane/metadata/android/it/changelogs/40100110.txt
new file mode 100644
index 0000000000..897dda36d2
--- /dev/null
+++ b/fastlane/metadata/android/it/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Questa nuova versione contiene principalmente miglioramenti di interfaccia ed esperienza utente. Ora puoi invitare amici e iniziare messaggi diretti rapidamente tramite codici QR.
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/nb_NO/changelogs/40100100.txt b/fastlane/metadata/android/nb_NO/changelogs/40100100.txt
new file mode 100644
index 0000000000..7ef80a2532
--- /dev/null
+++ b/fastlane/metadata/android/nb_NO/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Denne nye versjonen inneholder hovedsakelig feilrettinger og forbedringer. Å sende en melding er nå mye raskere.
+Full endringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/nb_NO/changelogs/40100110.txt b/fastlane/metadata/android/nb_NO/changelogs/40100110.txt
new file mode 100644
index 0000000000..c2f5e03845
--- /dev/null
+++ b/fastlane/metadata/android/nb_NO/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Denne nye versjonen inneholder hovedsakelig forbedringer av brukergrensesnittet og brukeropplevelsen. Nå kan du invitere venner og opprette DM veldig raskt ved å skanne QR-koder.
+Full endringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/nb_NO/short_description.txt b/fastlane/metadata/android/nb_NO/short_description.txt
new file mode 100644
index 0000000000..b7cad4c849
--- /dev/null
+++ b/fastlane/metadata/android/nb_NO/short_description.txt
@@ -0,0 +1 @@
+Sikker desentralisert chat & VoIP. Beskytt dataene dine fra tredjeparter.
diff --git a/fastlane/metadata/android/nb_NO/title.txt b/fastlane/metadata/android/nb_NO/title.txt
new file mode 100644
index 0000000000..aacee5be54
--- /dev/null
+++ b/fastlane/metadata/android/nb_NO/title.txt
@@ -0,0 +1 @@
+Element (tidligere Riot.im)
diff --git a/fastlane/metadata/android/pt_BR/changelogs/40100110.txt b/fastlane/metadata/android/pt_BR/changelogs/40100110.txt
new file mode 100644
index 0000000000..2e9aef1c4a
--- /dev/null
+++ b/fastlane/metadata/android/pt_BR/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Esta nova versão contém principalmente melhorias na interface do usuário e na experiência do usuário. Agora você pode convidar amigos e criar conversas rapidamente, digitalizando códigos QR.
+Registro completo de alterações: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/ru/changelogs/40100100.txt b/fastlane/metadata/android/ru/changelogs/40100100.txt
new file mode 100644
index 0000000000..326562fb32
--- /dev/null
+++ b/fastlane/metadata/android/ru/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Эта новая версия в основном содержит исправления ошибок и улучшения. Отправка сообщения стала намного быстрее.
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/ru/changelogs/40100110.txt b/fastlane/metadata/android/ru/changelogs/40100110.txt
new file mode 100644
index 0000000000..166e5b701c
--- /dev/null
+++ b/fastlane/metadata/android/ru/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Эта новая версия в основном содержит улучшения пользовательского интерфейса и взаимодействия с пользователем. Теперь вы можете приглашать друзей и очень быстро создавать чаты, сканируя QR-коды.
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/sk/changelogs/40100100.txt b/fastlane/metadata/android/sk/changelogs/40100100.txt
new file mode 100644
index 0000000000..b5fe2085ca
--- /dev/null
+++ b/fastlane/metadata/android/sk/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Táto verzia obsahuje predovšetkým opravy chýb. Odosielanie správ je odteraz omnoho rýchlejšie.
+Kompletný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/sk/changelogs/40100110.txt b/fastlane/metadata/android/sk/changelogs/40100110.txt
new file mode 100644
index 0000000000..ae68eee15e
--- /dev/null
+++ b/fastlane/metadata/android/sk/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Táto verzia obsahuje najmä vylepšenia používateľského rozhrania. Pozývať priateľov alebo vytvárať priame konverzácie môžete veľmi rýchlo naskenovaním QR kódov.
+Kompletný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/sv/changelogs/40100110.txt b/fastlane/metadata/android/sv/changelogs/40100110.txt
new file mode 100644
index 0000000000..e3ed460f17
--- /dev/null
+++ b/fastlane/metadata/android/sv/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Den här nya versionen innehåller mest förbättringar för användargränssnittet och användarupplevelsen. Du kan nu bjuda in vänner och skapa direktmeddelanden väldigt snabbt genom att skanna QR-koder.
+Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/uk/changelogs/40100110.txt b/fastlane/metadata/android/uk/changelogs/40100110.txt
new file mode 100644
index 0000000000..32f220e75d
--- /dev/null
+++ b/fastlane/metadata/android/uk/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Ця нова версія містить переважно поліпшення інтерфейсу та зручності користування. Тепер ви можете запросити друзів і створити прямі повідомлення дуже швидко, скануючи QR-коди.
+Повний перелік змін: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/vi/changelogs/40100100.txt b/fastlane/metadata/android/vi/changelogs/40100100.txt
new file mode 100644
index 0000000000..7125bbde9a
--- /dev/null
+++ b/fastlane/metadata/android/vi/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Phiên bản mới này chủ yếu bao gồm sửa lỗi và một số cải thiện. Gửi tin nhắn trở nên nhanh chóng hơn trước.
+Danh sách đầy đủ các thay đổi: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/vi/changelogs/40100110.txt b/fastlane/metadata/android/vi/changelogs/40100110.txt
new file mode 100644
index 0000000000..fce5eff648
--- /dev/null
+++ b/fastlane/metadata/android/vi/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Phiên bản mới này chủ yếu bao gồm các cải thiện về giao diện và trải nghiệm người dùng. Bây giờ bạn có thể mời bạn bè và bắt đầu nói chuyện nhanh chóng bằng cách quét mã QR.
+Danh sách đầy đủ các thay đổi: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/vi/short_description.txt b/fastlane/metadata/android/vi/short_description.txt
new file mode 100644
index 0000000000..b41ac0ce82
--- /dev/null
+++ b/fastlane/metadata/android/vi/short_description.txt
@@ -0,0 +1 @@
+Ứng dụng chat và gọi phân tán bảo mật. Bảo vệ dữ liệu của bạn khỏi bên thứ ba.
diff --git a/fastlane/metadata/android/vi/title.txt b/fastlane/metadata/android/vi/title.txt
new file mode 100644
index 0000000000..2a3bef31df
--- /dev/null
+++ b/fastlane/metadata/android/vi/title.txt
@@ -0,0 +1 @@
+Element (trước là Riot.im)
diff --git a/fastlane/metadata/android/zh_Hant/changelogs/40100110.txt b/fastlane/metadata/android/zh_Hant/changelogs/40100110.txt
new file mode 100644
index 0000000000..22dfe07097
--- /dev/null
+++ b/fastlane/metadata/android/zh_Hant/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+這個新版本主要包含使用者介面與使用者體驗改善。現在您可以邀請朋友,並透過掃描 QR code 來快速建立直接訊息了。
+完整變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index cdc95ef6eb..f1577bddaa 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionSha256Sum=22449f5231796abd892c98b2a07c9ceebe4688d192cd2d6763f8e3bf8acbedeb
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
+distributionSha256Sum=a7ca23b3ccf265680f2bfd35f1f00b1424f4466292c7337c85d46c9641b3f053
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index d72e5bda41..6a2f7575e5 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -167,9 +167,6 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
- // Bus
- implementation 'org.greenrobot:eventbus:3.1.1'
-
// Phone number https://github.com/google/libphonenumber
implementation 'com.googlecode.libphonenumber:libphonenumber:8.10.23'
diff --git a/matrix-sdk-android/proguard-rules.pro b/matrix-sdk-android/proguard-rules.pro
index fa860d8049..182f9473e8 100644
--- a/matrix-sdk-android/proguard-rules.pro
+++ b/matrix-sdk-android/proguard-rules.pro
@@ -20,14 +20,8 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-
-### EVENT BUS ###
-
+# BMA: Not sure I can delete this one without side effect
-keepattributes *Annotation*
--keepclassmembers class * {
- @org.greenrobot.eventbus.Subscribe ;
-}
--keep enum org.greenrobot.eventbus.ThreadMode { *; }
### MOSHI ###
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/SenderNotificationPermissionCondition.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/SenderNotificationPermissionCondition.kt
index 4f9c84a47c..6675fb0ff5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/SenderNotificationPermissionCondition.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/pushrules/SenderNotificationPermissionCondition.kt
@@ -37,6 +37,6 @@ class SenderNotificationPermissionCondition(
fun isSatisfied(event: Event, powerLevels: PowerLevelsContent): Boolean {
val powerLevelsHelper = PowerLevelsHelper(powerLevels)
- return event.senderId != null && powerLevelsHelper.getUserPowerLevelValue(event.senderId) >= powerLevelsHelper.notificationLevel(key)
+ return event.senderId != null && powerLevelsHelper.getUserPowerLevelValue(event.senderId) >= powerLevels.notificationLevel(key)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
index aefc086b43..ac1d726d03 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
@@ -25,7 +25,6 @@ interface PermalinkService {
companion object {
const val MATRIX_TO_URL_BASE = "https://matrix.to/#/"
- const val MATRIX_TO_CUSTOM_SCHEME_URL_BASE = "element://"
}
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt
index 696b612389..e778f5740d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt
@@ -25,28 +25,85 @@ import org.matrix.android.sdk.api.session.room.powerlevels.Role
*/
@JsonClass(generateAdapter = true)
data class PowerLevelsContent(
+ /**
+ * The level required to ban a user. Defaults to 50 if unspecified.
+ */
@Json(name = "ban") val ban: Int = Role.Moderator.value,
+ /**
+ * The level required to kick a user. Defaults to 50 if unspecified.
+ */
@Json(name = "kick") val kick: Int = Role.Moderator.value,
+ /**
+ * The level required to invite a user. Defaults to 50 if unspecified.
+ */
@Json(name = "invite") val invite: Int = Role.Moderator.value,
+ /**
+ * The level required to redact an event. Defaults to 50 if unspecified.
+ */
@Json(name = "redact") val redact: Int = Role.Moderator.value,
+ /**
+ * The default level required to send message events. Can be overridden by the events key. Defaults to 0 if unspecified.
+ */
@Json(name = "events_default") val eventsDefault: Int = Role.Default.value,
- @Json(name = "events") val events: MutableMap = HashMap(),
+ /**
+ * The level required to send specific event types. This is a mapping from event type to power level required.
+ */
+ @Json(name = "events") val events: Map = emptyMap(),
+ /**
+ * The default power level for every user in the room, unless their user_id is mentioned in the users key. Defaults to 0 if unspecified.
+ */
@Json(name = "users_default") val usersDefault: Int = Role.Default.value,
- @Json(name = "users") val users: MutableMap = HashMap(),
+ /**
+ * The power levels for specific users. This is a mapping from user_id to power level for that user.
+ */
+ @Json(name = "users") val users: Map = emptyMap(),
+ /**
+ * The default level required to send state events. Can be overridden by the events key. Defaults to 50 if unspecified.
+ */
@Json(name = "state_default") val stateDefault: Int = Role.Moderator.value,
- @Json(name = "notifications") val notifications: Map = HashMap()
+ /**
+ * The power level requirements for specific notification types. This is a mapping from key to power level for that notifications key.
+ */
+ @Json(name = "notifications") val notifications: Map = emptyMap()
) {
/**
- * Alter this content with a new power level for the specified user
+ * Return a copy of this content with a new power level for the specified user
*
* @param userId the userId to alter the power level of
* @param powerLevel the new power level, or null to set the default value.
*/
- fun setUserPowerLevel(userId: String, powerLevel: Int?) {
- if (powerLevel == null || powerLevel == usersDefault) {
- users.remove(userId)
- } else {
- users[userId] = powerLevel
+ fun setUserPowerLevel(userId: String, powerLevel: Int?): PowerLevelsContent {
+ return copy(
+ users = users.toMutableMap().apply {
+ if (powerLevel == null || powerLevel == usersDefault) {
+ remove(userId)
+ } else {
+ put(userId, powerLevel)
+ }
+ }
+ )
+ }
+
+ /**
+ * Get the notification level for a dedicated key.
+ *
+ * @param key the notification key
+ * @return the level, default to Moderator if the key is not found
+ */
+ fun notificationLevel(key: String): Int {
+ return when (val value = notifications[key]) {
+ // the first implementation was a string value
+ is String -> value.toInt()
+ is Double -> value.toInt()
+ is Int -> value
+ else -> Role.Moderator.value
}
}
+
+ companion object {
+ /**
+ * Key to use for content.notifications and get the level required to trigger an @room notification. Defaults to 50 if unspecified.
+ */
+ const val NOTIFICATIONS_ROOM_KEY = "room"
+ }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/PowerLevelsHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/PowerLevelsHelper.kt
index 47922f6968..4f1253c6df 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/PowerLevelsHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/PowerLevelsHelper.kt
@@ -108,19 +108,4 @@ class PowerLevelsHelper(private val powerLevelsContent: PowerLevelsContent) {
val powerLevel = getUserPowerLevelValue(userId)
return powerLevel >= powerLevelsContent.redact
}
-
- /**
- * Get the notification level for a dedicated key.
- *
- * @param key the notification key
- * @return the level
- */
- fun notificationLevel(key: String): Int {
- return when (val value = powerLevelsContent.notifications[key]) {
- // the first implementation was a string value
- is String -> value.toInt()
- is Int -> value
- else -> Role.Moderator.value
- }
- }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/state/StateServiceExtension.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/state/StateServiceExtension.kt
new file mode 100644
index 0000000000..c625a7f088
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/state/StateServiceExtension.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2020 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.api.session.room.state
+
+import org.matrix.android.sdk.api.query.QueryStringValue
+import org.matrix.android.sdk.api.session.events.model.EventType
+import org.matrix.android.sdk.api.session.events.model.toModel
+import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
+import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
+
+/**
+ * Return true if a room can be joined by anyone (RoomJoinRules.PUBLIC)
+ */
+fun StateService.isPublic(): Boolean {
+ return getStateEvent(EventType.STATE_ROOM_JOIN_RULES, QueryStringValue.NoCondition)
+ ?.content
+ ?.toModel()
+ ?.joinRules == RoomJoinRules.PUBLIC
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
index c2c81894fb..7e92ff3e88 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.api.session.events.model.Event
@@ -60,7 +59,6 @@ internal class CancelGossipRequestWorker(context: Context,
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
@Inject lateinit var cryptoStore: IMXCryptoStore
- @Inject lateinit var eventBus: EventBus
@Inject lateinit var credentials: Credentials
override fun injectWith(injector: SessionComponent) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
index 085469e9d9..e8d567b944 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.api.session.events.model.Event
@@ -52,7 +51,6 @@ internal class SendGossipRequestWorker(context: Context,
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
@Inject lateinit var cryptoStore: IMXCryptoStore
- @Inject lateinit var eventBus: EventBus
@Inject lateinit var credentials: Credentials
override fun injectWith(injector: SessionComponent) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
index bcaa16f356..8c68057056 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.api.session.events.model.Event
@@ -54,7 +53,6 @@ internal class SendGossipWorker(context: Context,
@Inject lateinit var sendToDeviceTask: SendToDeviceTask
@Inject lateinit var cryptoStore: IMXCryptoStore
- @Inject lateinit var eventBus: EventBus
@Inject lateinit var credentials: Credentials
@Inject lateinit var messageEncrypter: MessageEncrypter
@Inject lateinit var ensureOlmSessionsForDevicesAction: EnsureOlmSessionsForDevicesAction
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
index 36b667911d..5c59cfd80e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/CreateKeysBackupVersionTask.kt
@@ -19,20 +19,20 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface CreateKeysBackupVersionTask : Task
internal class DefaultCreateKeysBackupVersionTask @Inject constructor(
private val roomKeysApi: RoomKeysApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : CreateKeysBackupVersionTask {
override suspend fun execute(params: CreateKeysBackupVersionBody): KeysVersion {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomKeysApi.createKeysBackupVersion(params)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
index d174be20a2..ec09da7240 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteBackupTask.kt
@@ -17,9 +17,9 @@
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface DeleteBackupTask : Task {
@@ -30,11 +30,11 @@ internal interface DeleteBackupTask : Task {
internal class DefaultDeleteBackupTask @Inject constructor(
private val roomKeysApi: RoomKeysApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : DeleteBackupTask {
override suspend fun execute(params: DeleteBackupTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomKeysApi.deleteBackup(params.version)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
index 6826596ba4..9c477efb78 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/DeleteRoomSessionDataTask.kt
@@ -17,9 +17,9 @@
package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface DeleteRoomSessionDataTask : Task {
@@ -32,11 +32,11 @@ internal interface DeleteRoomSessionDataTask : Task {
@@ -31,11 +31,11 @@ internal interface DeleteRoomSessionsDataTask : Task {
@@ -30,11 +30,11 @@ internal interface DeleteSessionsDataTask : Task
internal class DefaultGetKeysBackupLastVersionTask @Inject constructor(
private val roomKeysApi: RoomKeysApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetKeysBackupLastVersionTask {
override suspend fun execute(params: Unit): KeysVersionResult {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomKeysApi.getKeysBackupLastVersion()
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
index dd2dd70e4d..13c99fb0f4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetKeysBackupVersionTask.kt
@@ -18,20 +18,20 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetKeysBackupVersionTask : Task
internal class DefaultGetKeysBackupVersionTask @Inject constructor(
private val roomKeysApi: RoomKeysApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetKeysBackupVersionTask {
override suspend fun execute(params: String): KeysVersionResult {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomKeysApi.getKeysBackupVersion(params)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
index 8ca03491a1..168020d9cd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/tasks/GetRoomSessionDataTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.keysbackup.tasks
import org.matrix.android.sdk.internal.crypto.keysbackup.api.RoomKeysApi
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetRoomSessionDataTask : Task {
@@ -33,11 +33,11 @@ internal interface GetRoomSessionDataTask : Task {
@@ -32,11 +32,11 @@ internal interface GetRoomSessionsDataTask : Task {
@@ -31,11 +31,11 @@ internal interface GetSessionsDataTask : Task {
@@ -35,11 +35,11 @@ internal interface StoreRoomSessionDataTask : Task {
@@ -34,11 +34,11 @@ internal interface StoreRoomSessionsDataTask : Task {
@@ -33,11 +33,11 @@ internal interface StoreSessionsDataTask : Task {
@@ -32,11 +32,11 @@ internal interface UpdateKeysBackupVersionTask : Task {
val body = KeysClaimBody(oneTimeKeys = params.usersDevicesKeyTypesMap.map)
- val keysClaimResponse = executeRequest(eventBus) {
+ val keysClaimResponse = executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.claimOneTimeKeysForUsersDevices(body)
}
val map = MXUsersDevicesMap()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
index e5078d5b4e..8f1569a037 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
@@ -20,9 +20,9 @@ import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.DeleteDeviceParams
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface DeleteDeviceTask : Task {
@@ -33,12 +33,12 @@ internal interface DeleteDeviceTask : Task {
internal class DefaultDeleteDeviceTask @Inject constructor(
private val cryptoApi: CryptoApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : DeleteDeviceTask {
override suspend fun execute(params: DeleteDeviceTask.Params) {
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams())
}
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceWithUserPasswordTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceWithUserPasswordTask.kt
index 38eee7f932..b4c1e6d27c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceWithUserPasswordTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceWithUserPasswordTask.kt
@@ -21,9 +21,9 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.DeleteDeviceParams
import org.matrix.android.sdk.internal.crypto.model.rest.UserPasswordAuth
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface DeleteDeviceWithUserPasswordTask : Task {
@@ -37,11 +37,11 @@ internal interface DeleteDeviceWithUserPasswordTask : Task {
@@ -35,7 +35,7 @@ internal interface DownloadKeysForUsersTask : Task {
@@ -29,11 +29,11 @@ internal interface GetDeviceInfoTask : Task
internal class DefaultGetDevicesTask @Inject constructor(
private val cryptoApi: CryptoApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetDevicesTask {
override suspend fun execute(params: Unit): DevicesListResponse {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.getDevices()
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
index 289a5226f5..4cc9ab2fcb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/GetKeyChangesTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.KeyChangesResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetKeyChangesTask : Task {
@@ -34,11 +34,11 @@ internal interface GetKeyChangesTask : Task {
internal class DefaultRedactEventTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus) : RedactEventTask {
+ private val globalErrorReceiver: GlobalErrorReceiver) : RedactEventTask {
override suspend fun execute(params: RedactEventTask.Params): String {
- val executeRequest = executeRequest(eventBus) {
+ val executeRequest = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.redactEvent(
txId = params.txID,
roomId = params.roomId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
index 5c8c7dfb25..b772bfbce2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendEventTask.kt
@@ -15,9 +15,9 @@
*/
package org.matrix.android.sdk.internal.crypto.tasks
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.send.SendState
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
@@ -38,7 +38,7 @@ internal class DefaultSendEventTask @Inject constructor(
private val encryptEventTask: DefaultEncryptEventTask,
private val loadRoomMembersTask: LoadRoomMembersTask,
private val roomAPI: RoomAPI,
- private val eventBus: EventBus) : SendEventTask {
+ private val globalErrorReceiver: GlobalErrorReceiver) : SendEventTask {
override suspend fun execute(params: SendEventTask.Params): String {
try {
@@ -53,7 +53,7 @@ internal class DefaultSendEventTask @Inject constructor(
val localId = event.eventId!!
localEchoRepository.updateSendState(localId, params.event.roomId, SendState.SENDING)
- val executeRequest = executeRequest(eventBus) {
+ val executeRequest = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.send(
localId,
roomId = event.roomId ?: "",
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
index 37e0bbc887..d2af91601b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt
@@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.model.rest.SendToDeviceBody
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
import kotlin.random.Random
@@ -38,7 +38,7 @@ internal interface SendToDeviceTask : Task {
internal class DefaultSendToDeviceTask @Inject constructor(
private val cryptoApi: CryptoApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SendToDeviceTask {
override suspend fun execute(params: SendToDeviceTask.Params) {
@@ -46,7 +46,7 @@ internal class DefaultSendToDeviceTask @Inject constructor(
messages = params.contentMap.map
)
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.sendToDevice(
params.eventType,
params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(),
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
index cedb7a6618..c39dfb1016 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendVerificationMessageTask.kt
@@ -15,10 +15,10 @@
*/
package org.matrix.android.sdk.internal.crypto.tasks
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.internal.crypto.CryptoSessionInfoProvider
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
@@ -37,7 +37,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
private val encryptEventTask: DefaultEncryptEventTask,
private val roomAPI: RoomAPI,
private val cryptoSessionInfoProvider: CryptoSessionInfoProvider,
- private val eventBus: EventBus) : SendVerificationMessageTask {
+ private val globalErrorReceiver: GlobalErrorReceiver) : SendVerificationMessageTask {
override suspend fun execute(params: SendVerificationMessageTask.Params): String {
val event = handleEncryption(params)
@@ -45,7 +45,7 @@ internal class DefaultSendVerificationMessageTask @Inject constructor(
try {
localEchoRepository.updateSendState(localId, event.roomId, SendState.SENDING)
- val executeRequest = executeRequest(eventBus) {
+ val executeRequest = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.send(
localId,
roomId = event.roomId ?: "",
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
index 51b9624554..b835d46236 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SetDeviceNameTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface SetDeviceNameTask : Task {
@@ -34,14 +34,14 @@ internal interface SetDeviceNameTask : Task {
internal class DefaultSetDeviceNameTask @Inject constructor(
private val cryptoApi: CryptoApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SetDeviceNameTask {
override suspend fun execute(params: SetDeviceNameTask.Params) {
val body = UpdateDeviceInfoBody(
displayName = params.deviceName
)
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.updateDeviceInfo(params.deviceId, body)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
index 6216a3a305..eb53bbbf8d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadKeysTask.kt
@@ -21,9 +21,9 @@ import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceKeys
import org.matrix.android.sdk.internal.crypto.model.rest.KeysUploadBody
import org.matrix.android.sdk.internal.crypto.model.rest.KeysUploadResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import timber.log.Timber
import javax.inject.Inject
@@ -38,7 +38,7 @@ internal interface UploadKeysTask : Task $body")
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.uploadKeys(body)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
index a4e10ddbfc..c50faf37b1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSignaturesTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.crypto.tasks
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.SignatureUploadResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface UploadSignaturesTask : Task {
@@ -31,12 +31,12 @@ internal interface UploadSignaturesTask : Task(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
this.isRetryable = true
this.maxRetryCount = 10
this.apiCall = cryptoApi.uploadSignatures(params.signatures)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
index 038ef9dbd3..cceff355bb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
@@ -25,9 +25,9 @@ import org.matrix.android.sdk.internal.crypto.model.rest.KeysQueryResponse
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
import org.matrix.android.sdk.internal.crypto.model.rest.UserPasswordAuth
import org.matrix.android.sdk.internal.crypto.model.toRest
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface UploadSigningKeysTask : Task {
@@ -55,7 +55,7 @@ data class UploadSigningKeys(val failures: Map?) : Failure.FeatureF
internal class DefaultUploadSigningKeysTask @Inject constructor(
private val cryptoApi: CryptoApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : UploadSigningKeysTask {
override suspend fun execute(params: UploadSigningKeysTask.Params) {
@@ -87,7 +87,7 @@ internal class DefaultUploadSigningKeysTask @Inject constructor(
}
private suspend fun doRequest(uploadQuery: UploadSigningKeysBody) {
- val keysQueryResponse = executeRequest(eventBus) {
+ val keysQueryResponse = executeRequest(globalErrorReceiver) {
apiCall = cryptoApi.uploadSigningKeys(uploadQuery)
}
if (keysQueryResponse.failures?.isNotEmpty() == true) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorHandler.kt
new file mode 100644
index 0000000000..9afdb40ed1
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorHandler.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.network
+
+import org.matrix.android.sdk.api.failure.GlobalError
+import org.matrix.android.sdk.internal.auth.SessionParamsStore
+import org.matrix.android.sdk.internal.di.SessionId
+import org.matrix.android.sdk.internal.session.SessionScope
+import org.matrix.android.sdk.internal.task.TaskExecutor
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import timber.log.Timber
+import javax.inject.Inject
+
+@SessionScope
+internal class GlobalErrorHandler @Inject constructor(
+ private val taskExecutor: TaskExecutor,
+ private val sessionParamsStore: SessionParamsStore,
+ @SessionId private val sessionId: String
+) : GlobalErrorReceiver {
+
+ var listener: Listener? = null
+
+ override fun handleGlobalError(globalError: GlobalError) {
+ Timber.e("Global error received: $globalError")
+
+ if (globalError is GlobalError.InvalidToken && globalError.softLogout) {
+ // Mark the token has invalid
+ taskExecutor.executorScope.launch(Dispatchers.IO) {
+ sessionParamsStore.setTokenInvalid(sessionId)
+ }
+ }
+
+ listener?.onGlobalError(globalError)
+ }
+
+ internal interface Listener {
+ fun onGlobalError(globalError: GlobalError)
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/eventbus/EventBusTimberLogger.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorReceiver.kt
similarity index 58%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/eventbus/EventBusTimberLogger.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorReceiver.kt
index 2cbd7ba7f0..47607ba893 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/eventbus/EventBusTimberLogger.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/GlobalErrorReceiver.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 The Matrix.org Foundation C.I.C.
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,18 +14,10 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.eventbus
+package org.matrix.android.sdk.internal.network
-import org.greenrobot.eventbus.Logger
-import timber.log.Timber
-import java.util.logging.Level
+import org.matrix.android.sdk.api.failure.GlobalError
-class EventBusTimberLogger : Logger {
- override fun log(level: Level, msg: String) {
- Timber.d(msg)
- }
-
- override fun log(level: Level, msg: String, th: Throwable) {
- Timber.e(th, msg)
- }
+internal interface GlobalErrorReceiver {
+ fun handleGlobalError(globalError: GlobalError)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
index 2535a5347a..442029127d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.network
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.delay
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.internal.network.ssl.CertUtil
@@ -27,10 +26,10 @@ import retrofit2.awaitResponse
import timber.log.Timber
import java.io.IOException
-internal suspend inline fun executeRequest(eventBus: EventBus?,
- block: Request.() -> Unit) = Request(eventBus).apply(block).execute()
+internal suspend inline fun executeRequest(globalErrorReceiver: GlobalErrorReceiver?,
+ block: Request.() -> Unit) = Request(globalErrorReceiver).apply(block).execute()
-internal class Request(private val eventBus: EventBus?) {
+internal class Request(private val globalErrorReceiver: GlobalErrorReceiver?) {
var isRetryable = false
var initialDelay: Long = 100L
@@ -47,7 +46,7 @@ internal class Request(private val eventBus: EventBus?) {
response.body()
?: throw IllegalStateException("The request returned a null body")
} else {
- throw response.toFailure(eventBus)
+ throw response.toFailure(globalErrorReceiver)
}
} catch (exception: Throwable) {
// Log some details about the request which has failed
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
index c54af571d8..dd5a69dd3c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
@@ -25,7 +25,6 @@ import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.internal.di.MoshiProvider
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.ResponseBody
-import org.greenrobot.eventbus.EventBus
import retrofit2.Response
import timber.log.Timber
import java.io.IOException
@@ -54,18 +53,18 @@ internal suspend fun okhttp3.Call.awaitResponse(): okhttp3.Response {
/**
* Convert a retrofit Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
*/
-internal fun Response.toFailure(eventBus: EventBus?): Failure {
- return toFailure(errorBody(), code(), eventBus)
+internal fun Response.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
+ return toFailure(errorBody(), code(), globalErrorReceiver)
}
/**
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
*/
-internal fun okhttp3.Response.toFailure(eventBus: EventBus?): Failure {
- return toFailure(body, code, eventBus)
+internal fun okhttp3.Response.toFailure(globalErrorReceiver: GlobalErrorReceiver?): Failure {
+ return toFailure(body, code, globalErrorReceiver)
}
-private fun toFailure(errorBody: ResponseBody?, httpCode: Int, eventBus: EventBus?): Failure {
+private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiver: GlobalErrorReceiver?): Failure {
if (errorBody == null) {
return Failure.Unknown(RuntimeException("errorBody should not be null"))
}
@@ -79,12 +78,12 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, eventBus: EventBu
if (matrixError != null) {
if (matrixError.code == MatrixError.M_CONSENT_NOT_GIVEN && !matrixError.consentUri.isNullOrBlank()) {
- // Also send this error to the bus, for a global management
- eventBus?.post(GlobalError.ConsentNotGivenError(matrixError.consentUri))
+ // Also send this error to the globalErrorReceiver, for a global management
+ globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
} else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
&& matrixError.code == MatrixError.M_UNKNOWN_TOKEN) {
- // Also send this error to the bus, for a global management
- eventBus?.post(GlobalError.InvalidToken(matrixError.isSoftLogout))
+ // Also send this error to the globalErrorReceiver, for a global management
+ globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout))
}
return Failure.ServerError(matrixError, httpCode)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
index c5f3f65a34..fa07b16c32 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
@@ -19,12 +19,7 @@ package org.matrix.android.sdk.internal.session
import androidx.annotation.MainThread
import dagger.Lazy
import io.realm.RealmConfiguration
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
-import org.greenrobot.eventbus.EventBus
-import org.greenrobot.eventbus.Subscribe
-import org.greenrobot.eventbus.ThreadMode
import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.failure.GlobalError
@@ -65,13 +60,12 @@ import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
import org.matrix.android.sdk.internal.di.WorkManagerProvider
+import org.matrix.android.sdk.internal.network.GlobalErrorHandler
import org.matrix.android.sdk.internal.session.identity.DefaultIdentityService
import org.matrix.android.sdk.internal.session.room.send.queue.EventSenderProcessor
import org.matrix.android.sdk.internal.session.sync.SyncTokenStore
import org.matrix.android.sdk.internal.session.sync.job.SyncThread
import org.matrix.android.sdk.internal.session.sync.job.SyncWorker
-import org.matrix.android.sdk.internal.task.TaskExecutor
-import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.util.createUIHandler
import timber.log.Timber
import javax.inject.Inject
@@ -81,7 +75,7 @@ import javax.inject.Provider
internal class DefaultSession @Inject constructor(
override val sessionParams: SessionParams,
private val workManagerProvider: WorkManagerProvider,
- private val eventBus: EventBus,
+ private val globalErrorHandler: GlobalErrorHandler,
@SessionId
override val sessionId: String,
@SessionDatabase private val realmConfiguration: RealmConfiguration,
@@ -117,10 +111,8 @@ internal class DefaultSession @Inject constructor(
private val accountDataService: Lazy,
private val _sharedSecretStorageService: Lazy,
private val accountService: Lazy,
- private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val defaultIdentityService: DefaultIdentityService,
private val integrationManagerService: IntegrationManagerService,
- private val taskExecutor: TaskExecutor,
private val callSignalingService: Lazy,
@UnauthenticatedWithCertificate
private val unauthenticatedWithCertificateOkHttpClient: Lazy,
@@ -140,7 +132,8 @@ internal class DefaultSession @Inject constructor(
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
ProfileService by profileService.get(),
AccountDataService by accountDataService.get(),
- AccountService by accountService.get() {
+ AccountService by accountService.get(),
+ GlobalErrorHandler.Listener {
override val sharedSecretStorageService: SharedSecretStorageService
get() = _sharedSecretStorageService.get()
@@ -162,7 +155,7 @@ internal class DefaultSession @Inject constructor(
uiHandler.post {
lifecycleObservers.forEach { it.onStart() }
}
- eventBus.register(this)
+ globalErrorHandler.listener = this
eventSenderProcessor.start()
}
@@ -206,7 +199,7 @@ internal class DefaultSession @Inject constructor(
}
cryptoService.get().close()
isOpen = false
- eventBus.unregister(this)
+ globalErrorHandler.listener = null
eventSenderProcessor.interrupt()
}
@@ -234,16 +227,7 @@ internal class DefaultSession @Inject constructor(
workManagerProvider.cancelAllWorks()
}
- @Subscribe(threadMode = ThreadMode.MAIN)
- fun onGlobalError(globalError: GlobalError) {
- if (globalError is GlobalError.InvalidToken
- && globalError.softLogout) {
- // Mark the token has invalid
- taskExecutor.executorScope.launch(Dispatchers.IO) {
- sessionParamsStore.setTokenInvalid(sessionId)
- }
- }
-
+ override fun onGlobalError(globalError: GlobalError) {
sessionListeners.dispatchGlobalError(globalError)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
index 96b44917bd..468c193ad3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
@@ -26,7 +26,6 @@ import dagger.Provides
import dagger.multibindings.IntoSet
import io.realm.RealmConfiguration
import okhttp3.OkHttpClient
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.MatrixConfiguration
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
@@ -61,9 +60,10 @@ import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificateWithProgress
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.di.UserMd5
-import org.matrix.android.sdk.internal.eventbus.EventBusTimberLogger
import org.matrix.android.sdk.internal.network.DefaultNetworkConnectivityChecker
import org.matrix.android.sdk.internal.network.FallbackNetworkCallbackStrategy
+import org.matrix.android.sdk.internal.network.GlobalErrorHandler
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.NetworkCallbackStrategy
import org.matrix.android.sdk.internal.network.NetworkConnectivityChecker
import org.matrix.android.sdk.internal.network.PreferredNetworkCallbackStrategy
@@ -256,16 +256,6 @@ internal abstract class SessionModule {
.create(okHttpClient, sessionParams.homeServerConnectionConfig.homeServerUri.toString())
}
- @JvmStatic
- @Provides
- @SessionScope
- fun providesEventBus(): EventBus {
- return EventBus
- .builder()
- .logger(EventBusTimberLogger())
- .build()
- }
-
@JvmStatic
@Provides
@SessionScope
@@ -294,6 +284,9 @@ internal abstract class SessionModule {
@Binds
abstract fun bindSession(session: DefaultSession): Session
+ @Binds
+ abstract fun bindGlobalErrorReceiver(handler: GlobalErrorHandler): GlobalErrorReceiver
+
@Binds
abstract fun bindNetworkConnectivityChecker(checker: DefaultNetworkConnectivityChecker): NetworkConnectivityChecker
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
index 869d3f516c..1f043b0a9d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.account
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface ChangePasswordTask : Task {
@@ -32,14 +32,14 @@ internal interface ChangePasswordTask : Task {
internal class DefaultChangePasswordTask @Inject constructor(
private val accountAPI: AccountAPI,
- private val eventBus: EventBus,
+ private val globalErrorReceiver: GlobalErrorReceiver,
@UserId private val userId: String
) : ChangePasswordTask {
override suspend fun execute(params: ChangePasswordTask.Params) {
val changePasswordParams = ChangePasswordParams.create(userId, params.password, params.newPassword)
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = accountAPI.changePassword(changePasswordParams)
}
} catch (throwable: Throwable) {
@@ -49,7 +49,7 @@ internal class DefaultChangePasswordTask @Inject constructor(
/* Avoid infinite loop */
&& changePasswordParams.auth?.session == null) {
// Retry with authentication
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = accountAPI.changePassword(
changePasswordParams.copy(auth = changePasswordParams.auth?.copy(session = registrationFlowResponse.session))
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
index ac5febcdae..9fb1cbb7d7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/DeactivateAccountTask.kt
@@ -17,11 +17,11 @@
package org.matrix.android.sdk.internal.session.account
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.cleanup.CleanupSession
import org.matrix.android.sdk.internal.session.identity.IdentityDisconnectTask
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import timber.log.Timber
import javax.inject.Inject
@@ -34,7 +34,7 @@ internal interface DeactivateAccountTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = accountAPI.deactivate(deactivateAccountParams)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
index 1cedee3374..b21ec1113a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/GetTurnServerTask.kt
@@ -17,9 +17,9 @@
package org.matrix.android.sdk.internal.session.call
import org.matrix.android.sdk.api.session.call.TurnServerResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal abstract class GetTurnServerTask : Task {
@@ -27,10 +27,10 @@ internal abstract class GetTurnServerTask : Task
if (!response.isSuccessful) {
- throw response.toFailure(eventBus)
+ throw response.toFailure(globalErrorReceiver)
} else {
response.body?.source()?.let {
responseAdapter.fromJson(it)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
index 69ced92fe5..da747934e2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.filter
import org.matrix.android.sdk.api.session.sync.FilterService
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
/**
@@ -37,7 +37,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
@UserId private val userId: String,
private val filterAPI: FilterApi,
private val filterRepository: FilterRepository,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SaveFilterTask {
override suspend fun execute(params: SaveFilterTask.Params) {
@@ -59,7 +59,7 @@ internal class DefaultSaveFilterTask @Inject constructor(
}
val updated = filterRepository.storeFilter(filterBody, roomFilter)
if (updated) {
- val filterResponse = executeRequest(eventBus) {
+ val filterResponse = executeRequest(globalErrorReceiver) {
// TODO auto retry
apiCall = filterAPI.uploadFilter(userId, filterBody)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
index dd703a5e93..9836164aec 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt
@@ -23,13 +23,13 @@ import org.matrix.android.sdk.internal.database.model.GroupSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.group.model.GroupRooms
import org.matrix.android.sdk.internal.session.group.model.GroupSummaryResponse
import org.matrix.android.sdk.internal.session.group.model.GroupUsers
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
-import org.greenrobot.eventbus.EventBus
import timber.log.Timber
import javax.inject.Inject
@@ -43,7 +43,7 @@ internal interface GetGroupDataTask : Task {
internal class DefaultGetGroupDataTask @Inject constructor(
private val groupAPI: GroupAPI,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetGroupDataTask {
private data class GroupData(
@@ -64,13 +64,13 @@ internal class DefaultGetGroupDataTask @Inject constructor(
}
Timber.v("Fetch data for group with ids: ${groupIds.joinToString(";")}")
val data = groupIds.map { groupId ->
- val groupSummary = executeRequest(eventBus) {
+ val groupSummary = executeRequest(globalErrorReceiver) {
apiCall = groupAPI.getSummary(groupId)
}
- val groupRooms = executeRequest(eventBus) {
+ val groupRooms = executeRequest(globalErrorReceiver) {
apiCall = groupAPI.getRooms(groupId)
}
- val groupUsers = executeRequest(eventBus) {
+ val groupUsers = executeRequest(globalErrorReceiver) {
apiCall = groupAPI.getUsers(groupId)
}
GroupData(groupId, groupSummary, groupRooms, groupUsers)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
index f3686b02d3..845cfb392e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/GetHomeServerCapabilitiesTask.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.session.homeserver
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
@@ -27,6 +26,7 @@ import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEnti
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManagerConfigExtractor
import org.matrix.android.sdk.internal.session.media.GetMediaConfigResult
@@ -44,7 +44,7 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
private val capabilitiesAPI: CapabilitiesAPI,
private val mediaAPI: MediaAPI,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus,
+ private val globalErrorReceiver: GlobalErrorReceiver,
private val getWellknownTask: GetWellknownTask,
private val configExtractor: IntegrationManagerConfigExtractor,
private val homeServerConnectionConfig: HomeServerConnectionConfig,
@@ -65,13 +65,13 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
}
val capabilities = runCatching {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = capabilitiesAPI.getCapabilities()
}
}.getOrNull()
val mediaConfig = runCatching {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = mediaAPI.getMediaConfig()
}
}.getOrNull()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
index 69cdfa8faa..a218f3f93c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.session.media
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.cache.CacheStrategy
import org.matrix.android.sdk.api.session.media.PreviewUrlData
import org.matrix.android.sdk.api.util.JsonDict
@@ -25,6 +24,7 @@ import org.matrix.android.sdk.internal.database.model.PreviewUrlCacheEntity
import org.matrix.android.sdk.internal.database.query.get
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
@@ -41,7 +41,7 @@ internal interface GetPreviewUrlTask : Task(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = mediaAPI.getPreviewUrlData(url, timestamp)
}
.toPreviewUrlData(url)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
index 6c5dad2422..32305cd4e4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetRawPreviewUrlTask.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.internal.session.media
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.util.JsonDict
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -31,11 +31,11 @@ internal interface GetRawPreviewUrlTask : Task
@@ -27,10 +27,10 @@ internal interface GetOpenIdTokenTask : Task
internal class DefaultGetOpenIdTokenTask @Inject constructor(
@UserId private val userId: String,
private val openIdAPI: OpenIdAPI,
- private val eventBus: EventBus) : GetOpenIdTokenTask {
+ private val globalErrorReceiver: GlobalErrorReceiver) : GetOpenIdTokenTask {
override suspend fun execute(params: Unit): RequestOpenIdTokenResponse {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = openIdAPI.openIdToken(userId)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
index 2e8a0b3884..6d6d70bb0d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.profile
import com.google.i18n.phonenumbers.PhoneNumberUtil
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
@@ -37,7 +37,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
private val profileAPI: ProfileAPI,
@SessionDatabase private val monarchy: Monarchy,
private val pendingThreePidMapper: PendingThreePidMapper,
- private val eventBus: EventBus) : AddThreePidTask() {
+ private val globalErrorReceiver: GlobalErrorReceiver) : AddThreePidTask() {
override suspend fun execute(params: Params) {
when (params.threePid) {
@@ -50,7 +50,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
val clientSecret = UUID.randomUUID().toString()
val sendAttempt = 1
- val result = executeRequest(eventBus) {
+ val result = executeRequest(globalErrorReceiver) {
val body = AddEmailBody(
clientSecret = clientSecret,
email = threePid.email,
@@ -84,7 +84,7 @@ internal class DefaultAddThreePidTask @Inject constructor(
val countryCode = parsedNumber.countryCode
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
- val result = executeRequest(eventBus) {
+ val result = executeRequest(globalErrorReceiver) {
val body = AddMsisdnBody(
clientSecret = clientSecret,
country = country,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
index dbe6bff508..a37e5380bc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidsTask.kt
@@ -19,12 +19,12 @@ package org.matrix.android.sdk.internal.session.profile
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.internal.di.AuthenticatedIdentity
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal abstract class BindThreePidsTask : Task {
@@ -37,13 +37,13 @@ internal class DefaultBindThreePidsTask @Inject constructor(private val profileA
private val identityStore: IdentityStore,
@AuthenticatedIdentity
private val accessTokenProvider: AccessTokenProvider,
- private val eventBus: EventBus) : BindThreePidsTask() {
+ private val globalErrorReceiver: GlobalErrorReceiver) : BindThreePidsTask() {
override suspend fun execute(params: Params) {
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol() ?: throw IdentityServiceError.NoIdentityServerConfigured
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
val identityPendingBinding = identityStore.getPendingBinding(params.threePid) ?: throw IdentityServiceError.NoCurrentBindingError
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = profileAPI.bindThreePid(
BindThreePidBody(
clientSecret = identityPendingBinding.clientSecret,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
index 3f43cbe599..3549f3613f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/DeleteThreePidTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.profile
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.api.session.identity.toMedium
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -31,10 +31,10 @@ internal abstract class DeleteThreePidTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
val body = DeleteThreePidBody(
medium = params.threePid.toMedium(),
address = params.threePid.value
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
index 0b1bf88280..1e3a2cb501 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
@@ -17,7 +17,6 @@
package org.matrix.android.sdk.internal.session.profile
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
import org.matrix.android.sdk.api.session.identity.ThreePid
@@ -26,6 +25,7 @@ import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntityFields
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
@@ -45,7 +45,7 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
@SessionDatabase private val monarchy: Monarchy,
private val pendingThreePidMapper: PendingThreePidMapper,
@UserId private val userId: String,
- private val eventBus: EventBus) : FinalizeAddingThreePidTask() {
+ private val globalErrorReceiver: GlobalErrorReceiver) : FinalizeAddingThreePidTask() {
override suspend fun execute(params: Params) {
if (params.userWantsToCancel.not()) {
@@ -58,7 +58,7 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
?: throw IllegalArgumentException("unknown threepid")
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
val body = FinalizeAddThreePidBody(
clientSecret = pendingThreePids.clientSecret,
sid = pendingThreePids.sid,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
index 5f1f621ddb..ed60c4a368 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/GetProfileInfoTask.kt
@@ -18,9 +18,9 @@
package org.matrix.android.sdk.internal.session.profile
import org.matrix.android.sdk.api.util.JsonDict
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal abstract class GetProfileInfoTask : Task {
@@ -30,10 +30,10 @@ internal abstract class GetProfileInfoTask : Task
internal class DefaultRefreshUserThreePidsTask @Inject constructor(private val profileAPI: ProfileAPI,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus) : RefreshUserThreePidsTask() {
+ private val globalErrorReceiver: GlobalErrorReceiver) : RefreshUserThreePidsTask() {
override suspend fun execute(params: Unit) {
- val accountThreePidsResponse = executeRequest(eventBus) {
+ val accountThreePidsResponse = executeRequest(globalErrorReceiver) {
apiCall = profileAPI.getThreePIDs()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
index 4b863c2098..b29153d665 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetAvatarUrlTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.profile
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal abstract class SetAvatarUrlTask : Task {
@@ -30,10 +30,10 @@ internal abstract class SetAvatarUrlTask : Task {
internal class DefaultSetAvatarUrlTask @Inject constructor(
private val profileAPI: ProfileAPI,
- private val eventBus: EventBus) : SetAvatarUrlTask() {
+ private val globalErrorReceiver: GlobalErrorReceiver) : SetAvatarUrlTask() {
override suspend fun execute(params: Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
val body = SetAvatarUrlBody(
avatarUrl = params.newAvatarUrl
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
index 1fa84f98c1..3f236bc589 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/SetDisplayNameTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.profile
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal abstract class SetDisplayNameTask : Task {
@@ -30,10 +30,10 @@ internal abstract class SetDisplayNameTask : Task {
@@ -34,12 +34,12 @@ internal abstract class UnbindThreePidsTask : Task(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = profileAPI.unbindThreePid(
UnbindThreePidBody(
identityServerUrlWithoutProtocol,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
index 36804e06fe..efb6c6e836 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/ValidateSmsCodeTask.kt
@@ -17,13 +17,13 @@
package org.matrix.android.sdk.internal.session.profile
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.internal.auth.registration.SuccessResult
import org.matrix.android.sdk.internal.auth.registration.ValidationCodeBody
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
@@ -40,7 +40,7 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
@SessionDatabase
private val monarchy: Monarchy,
private val pendingThreePidMapper: PendingThreePidMapper,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : ValidateSmsCodeTask {
override suspend fun execute(params: ValidateSmsCodeTask.Params) {
@@ -58,7 +58,7 @@ internal class DefaultValidateSmsCodeTask @Inject constructor(
sid = pendingThreePids.sid,
code = params.code
)
- val result = executeRequest(eventBus) {
+ val result = executeRequest(globalErrorReceiver) {
apiCall = profileAPI.validateMsisdn(url, body)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
index 31c5cda5ec..d0f7cbfca3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
@@ -19,13 +19,13 @@ import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.pushers.PusherState
import org.matrix.android.sdk.internal.database.mapper.toEntity
import org.matrix.android.sdk.internal.database.model.PusherEntity
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.SessionComponent
import org.matrix.android.sdk.internal.util.awaitTransaction
@@ -45,7 +45,7 @@ internal class AddHttpPusherWorker(context: Context, params: WorkerParameters)
@Inject lateinit var pushersAPI: PushersAPI
@Inject @SessionDatabase lateinit var monarchy: Monarchy
- @Inject lateinit var eventBus: EventBus
+ @Inject lateinit var globalErrorReceiver: GlobalErrorReceiver
override fun injectWith(injector: SessionComponent) {
injector.inject(this)
@@ -81,7 +81,7 @@ internal class AddHttpPusherWorker(context: Context, params: WorkerParameters)
}
private suspend fun setPusher(pusher: JsonPusher) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = pushersAPI.setPusher(pusher)
}
monarchy.awaitTransaction { realm ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
index 28ac5db52e..03748b1528 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPushRuleTask.kt
@@ -17,9 +17,9 @@ package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface AddPushRuleTask : Task {
@@ -31,11 +31,11 @@ internal interface AddPushRuleTask : Task {
internal class DefaultAddPushRuleTask @Inject constructor(
private val pushRulesApi: PushRulesApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : AddPushRuleTask {
override suspend fun execute(params: AddPushRuleTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = pushRulesApi.addRule(params.kind.value, params.pushRule.ruleId, params.pushRule)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
index 0c532cedbc..9fb2d51664 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushRulesTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.rest.GetPushRulesResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetPushRulesTask : Task {
@@ -31,11 +31,11 @@ internal interface GetPushRulesTask : Task {
internal class DefaultGetPushRulesTask @Inject constructor(
private val pushRulesApi: PushRulesApi,
private val savePushRulesTask: SavePushRulesTask,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetPushRulesTask {
override suspend fun execute(params: GetPushRulesTask.Params) {
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = pushRulesApi.getAllRules()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
index 39e970f4a8..4c7d370446 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/GetPushersTask.kt
@@ -20,10 +20,10 @@ import org.matrix.android.sdk.api.session.pushers.PusherState
import org.matrix.android.sdk.internal.database.mapper.toEntity
import org.matrix.android.sdk.internal.database.model.PusherEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetPushersTask : Task
@@ -31,11 +31,11 @@ internal interface GetPushersTask : Task
internal class DefaultGetPushersTask @Inject constructor(
private val pushersAPI: PushersAPI,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetPushersTask {
override suspend fun execute(params: Unit) {
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = pushersAPI.getPushers()
}
monarchy.awaitTransaction { realm ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
index 2fc97cf023..ff3122f566 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePushRuleTask.kt
@@ -17,9 +17,9 @@ package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface RemovePushRuleTask : Task {
@@ -31,11 +31,11 @@ internal interface RemovePushRuleTask : Task {
internal class DefaultRemovePushRuleTask @Inject constructor(
private val pushRulesApi: PushRulesApi,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : RemovePushRuleTask {
override suspend fun execute(params: RemovePushRuleTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = pushRulesApi.deleteRule(params.kind.value, params.pushRule.ruleId)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
index 1f10863799..e3f4fdb789 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
@@ -26,7 +26,7 @@ import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
import io.realm.Realm
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import javax.inject.Inject
internal interface RemovePusherTask : Task {
@@ -37,7 +37,7 @@ internal interface RemovePusherTask : Task {
internal class DefaultRemovePusherTask @Inject constructor(
private val pushersAPI: PushersAPI,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : RemovePusherTask {
override suspend fun execute(params: RemovePusherTask.Params) {
@@ -62,7 +62,7 @@ internal class DefaultRemovePusherTask @Inject constructor(
data = JsonPusherData(existing.data.url, existing.data.format),
append = false
)
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = pushersAPI.setPusher(deleteBody)
}
monarchy.awaitTransaction {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
index c2dca8a9a5..a5c220e662 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleActionsTask.kt
@@ -17,9 +17,9 @@ package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface UpdatePushRuleActionsTask : Task {
@@ -32,13 +32,13 @@ internal interface UpdatePushRuleActionsTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = pushRulesApi.updateEnableRuleStatus(params.kind.value, params.newPushRule.ruleId, params.newPushRule.enabled)
}
}
@@ -47,7 +47,7 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
// Also ensure the actions are up to date
val body = mapOf("actions" to params.newPushRule.actions)
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = pushRulesApi.updateRuleActions(params.kind.value, params.newPushRule.ruleId, body)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
index 4100071c90..f36b5c55fb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/UpdatePushRuleEnableStatusTask.kt
@@ -17,9 +17,9 @@ package org.matrix.android.sdk.internal.session.pushers
import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface UpdatePushRuleEnableStatusTask : Task {
@@ -30,11 +30,11 @@ internal interface UpdatePushRuleEnableStatusTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.addRoomAlias(
roomAlias = params.aliasLocalPart.toFullLocalAlias(userId),
body = AddRoomAliasBody(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
index 3400fd994c..6ad3db90a9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DeleteRoomAliasTask.kt
@@ -16,7 +16,7 @@
package org.matrix.android.sdk.internal.session.room.alias
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.directory.DirectoryAPI
import org.matrix.android.sdk.internal.task.Task
@@ -30,11 +30,11 @@ internal interface DeleteRoomAliasTask : Task
internal class DefaultDeleteRoomAliasTask @Inject constructor(
private val directoryAPI: DirectoryAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : DeleteRoomAliasTask {
override suspend fun execute(params: DeleteRoomAliasTask.Params) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.deleteRoomAlias(
roomAlias = params.roomAlias
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
index 543d605707..a53ffc4fcd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomIdByAliasTask.kt
@@ -18,12 +18,12 @@ package org.matrix.android.sdk.internal.session.room.alias
import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.findByAlias
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.directory.DirectoryAPI
import org.matrix.android.sdk.internal.task.Task
@@ -39,7 +39,7 @@ internal interface GetRoomIdByAliasTask : Task {
@@ -52,7 +52,7 @@ internal class DefaultGetRoomIdByAliasTask @Inject constructor(
Optional.from(null)
} else {
val description = tryOrNull("## Failed to get roomId from alias") {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.getRoomIdByAlias(params.roomAlias)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
index 7cfce4ecdc..202cb1f6de 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/GetRoomLocalAliasesTask.kt
@@ -16,7 +16,7 @@
package org.matrix.android.sdk.internal.session.room.alias
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
@@ -30,12 +30,12 @@ internal interface GetRoomLocalAliasesTask : Task {
// We do not check for "org.matrix.msc2432", so the API may be missing
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getAliases(roomId = params.roomId)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
index 25ba493891..51a849a35e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/RoomAliasAvailabilityChecker.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.room.alias
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.directory.DirectoryAPI
import javax.inject.Inject
@@ -27,7 +27,7 @@ import javax.inject.Inject
internal class RoomAliasAvailabilityChecker @Inject constructor(
@UserId private val userId: String,
private val directoryAPI: DirectoryAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) {
/**
* @param aliasLocalPart the local part of the alias.
@@ -41,7 +41,7 @@ internal class RoomAliasAvailabilityChecker @Inject constructor(
// Check alias availability
val fullAlias = aliasLocalPart.toFullLocalAlias(userId)
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.getRoomIdByAlias(fullAlias)
}
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
index ef792ab98e..9c16bd1b0f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
@@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.room.create
import com.zhuinden.monarchy.Monarchy
import io.realm.RealmConfiguration
import kotlinx.coroutines.TimeoutCancellationException
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
@@ -32,6 +31,7 @@ import org.matrix.android.sdk.internal.database.model.RoomEntityFields
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.alias.RoomAliasAvailabilityChecker
@@ -55,7 +55,7 @@ internal class DefaultCreateRoomTask @Inject constructor(
@SessionDatabase
private val realmConfiguration: RealmConfiguration,
private val createRoomBodyBuilder: CreateRoomBodyBuilder,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : CreateRoomTask {
override suspend fun execute(params: CreateRoomParams): String {
@@ -75,7 +75,7 @@ internal class DefaultCreateRoomTask @Inject constructor(
val createRoomBody = createRoomBodyBuilder.build(params)
val createRoomResponse = try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.createRoom(createRoomBody)
}
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
index f2bd0c5f69..edd8ae9b0d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetPublicRoomTask.kt
@@ -18,10 +18,10 @@ package org.matrix.android.sdk.internal.session.room.directory
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsParams
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsResponse
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetPublicRoomTask : Task {
@@ -33,11 +33,11 @@ internal interface GetPublicRoomTask : Task(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.getRoomDirectoryVisibility(params.roomId)
}
.visibility
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetThirdPartyProtocolsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetThirdPartyProtocolsTask.kt
index 5e08284706..3477aa671e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetThirdPartyProtocolsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/GetThirdPartyProtocolsTask.kt
@@ -17,21 +17,21 @@
package org.matrix.android.sdk.internal.session.room.directory
import org.matrix.android.sdk.api.session.room.model.thirdparty.ThirdPartyProtocol
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetThirdPartyProtocolsTask : Task>
internal class DefaultGetThirdPartyProtocolsTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetThirdPartyProtocolsTask {
override suspend fun execute(params: Unit): Map {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomAPI.thirdPartyProtocols()
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
index 33b12aa1ca..cbb0b6d5d1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/directory/SetRoomDirectoryVisibilityTask.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.internal.session.room.directory
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.directory.DirectoryAPI
import org.matrix.android.sdk.internal.session.directory.RoomDirectoryVisibilityJson
@@ -33,11 +33,11 @@ internal interface SetRoomDirectoryVisibilityTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = directoryAPI.setRoomDirectoryVisibility(
params.roomId,
RoomDirectoryVisibilityJson(visibility = params.roomDirectoryVisibility)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
index 53fa73c624..2be90bf8e3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt
@@ -20,7 +20,6 @@ import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
import io.realm.kotlin.createObject
import kotlinx.coroutines.TimeoutCancellationException
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
@@ -34,6 +33,7 @@ import org.matrix.android.sdk.internal.database.query.copyToRealmOrIgnore
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryUpdater
@@ -57,7 +57,7 @@ internal class DefaultLoadRoomMembersTask @Inject constructor(
private val syncTokenStore: SyncTokenStore,
private val roomSummaryUpdater: RoomSummaryUpdater,
private val roomMemberEventHandler: RoomMemberEventHandler,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : LoadRoomMembersTask {
override suspend fun execute(params: LoadRoomMembersTask.Params) {
@@ -86,7 +86,7 @@ internal class DefaultLoadRoomMembersTask @Inject constructor(
val lastToken = syncTokenStore.getLastToken()
val response = try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getMembers(params.roomId, lastToken, null, params.excludeMembership?.value)
}
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
index 854a332679..05503bd643 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/InviteTask.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.room.membership.joining
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface InviteTask : Task {
@@ -32,11 +32,11 @@ internal interface InviteTask : Task {
internal class DefaultInviteTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : InviteTask {
override suspend fun execute(params: InviteTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
val body = InviteBody(params.userId, params.reason)
apiCall = roomAPI.invite(params.roomId, body)
isRetryable = true
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
index dd1dc5fa8a..3b7639d42f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
@@ -30,7 +30,7 @@ import org.matrix.android.sdk.internal.session.room.read.SetReadMarkersTask
import org.matrix.android.sdk.internal.task.Task
import io.realm.RealmConfiguration
import kotlinx.coroutines.TimeoutCancellationException
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@@ -48,14 +48,18 @@ internal class DefaultJoinRoomTask @Inject constructor(
@SessionDatabase
private val realmConfiguration: RealmConfiguration,
private val roomChangeMembershipStateDataSource: RoomChangeMembershipStateDataSource,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : JoinRoomTask {
override suspend fun execute(params: JoinRoomTask.Params) {
roomChangeMembershipStateDataSource.updateState(params.roomIdOrAlias, ChangeMembershipState.Joining)
val joinRoomResponse = try {
- executeRequest(eventBus) {
- apiCall = roomAPI.join(params.roomIdOrAlias, params.viaServers, mapOf("reason" to params.reason))
+ executeRequest(globalErrorReceiver) {
+ apiCall = roomAPI.join(
+ roomIdOrAlias = params.roomIdOrAlias,
+ viaServers = params.viaServers.take(3),
+ params = mapOf("reason" to params.reason)
+ )
}
} catch (failure: Throwable) {
roomChangeMembershipStateDataSource.updateState(params.roomIdOrAlias, ChangeMembershipState.FailedJoining(failure))
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
index 58e34a15ec..37bb7570d1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/leaving/LeaveRoomTask.kt
@@ -21,13 +21,13 @@ import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.session.room.membership.RoomChangeMembershipStateDataSource
import org.matrix.android.sdk.internal.session.room.state.StateEventDataSource
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import timber.log.Timber
import javax.inject.Inject
@@ -40,7 +40,7 @@ internal interface LeaveRoomTask : Task {
internal class DefaultLeaveRoomTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus,
+ private val globalErrorReceiver: GlobalErrorReceiver,
private val stateEventDataSource: StateEventDataSource,
private val roomSummaryDataSource: RoomSummaryDataSource,
private val roomChangeMembershipStateDataSource: RoomChangeMembershipStateDataSource
@@ -68,7 +68,7 @@ internal class DefaultLeaveRoomTask @Inject constructor(
leaveRoom(predecessorRoomId, reason)
}
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.leave(roomId, mapOf("reason" to reason))
}
} catch (failure: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
index 80af00fc78..d237ec795e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/threepid/InviteThreePidTask.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.room.membership.threepid
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.api.session.identity.toMedium
import org.matrix.android.sdk.internal.di.AuthenticatedIdentity
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
import org.matrix.android.sdk.internal.session.identity.EnsureIdentityTokenTask
@@ -39,7 +39,7 @@ internal interface InviteThreePidTask : Task {
internal class DefaultInviteThreePidTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus,
+ private val globalErrorReceiver: GlobalErrorReceiver,
private val identityStore: IdentityStore,
private val ensureIdentityTokenTask: EnsureIdentityTokenTask,
@AuthenticatedIdentity
@@ -52,7 +52,7 @@ internal class DefaultInviteThreePidTask @Inject constructor(
val identityServerUrlWithoutProtocol = identityStore.getIdentityServerUrlWithoutProtocol() ?: throw IdentityServiceError.NoIdentityServerConfigured
val identityServerAccessToken = accessTokenProvider.getToken() ?: throw IdentityServiceError.NoIdentityServerConfigured
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
val body = ThreePidInviteBody(
idServer = identityServerUrlWithoutProtocol,
idAccessToken = identityServerAccessToken,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
index 03ea2408f0..dbec6b555c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/ResolveRoomStateTask.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.internal.session.room.peeking
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.events.model.Event
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
@@ -31,11 +31,11 @@ internal interface ResolveRoomStateTask : Task {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getRoomState(params.roomId)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
index a98bb02c83..c7f962a699 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/read/SetReadMarkersTask.kt
@@ -33,7 +33,7 @@ import org.matrix.android.sdk.internal.session.sync.RoomFullyReadHandler
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
import io.realm.Realm
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import timber.log.Timber
import javax.inject.Inject
import kotlin.collections.set
@@ -58,7 +58,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
private val roomFullyReadHandler: RoomFullyReadHandler,
private val readReceiptHandler: ReadReceiptHandler,
@UserId private val userId: String,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SetReadMarkersTask {
override suspend fun execute(params: SetReadMarkersTask.Params) {
@@ -96,7 +96,7 @@ internal class DefaultSetReadMarkersTask @Inject constructor(
updateDatabase(params.roomId, markers, shouldUpdateRoomSummary)
}
if (markers.isNotEmpty()) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
isRetryable = true
apiCall = roomAPI.sendReadMarker(params.roomId, markers)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
index 51eecb8c2a..99d02b50da 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/FetchEditHistoryTask.kt
@@ -18,10 +18,10 @@ package org.matrix.android.sdk.internal.session.room.relation
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.RelationType
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface FetchEditHistoryTask : Task> {
@@ -35,11 +35,11 @@ internal interface FetchEditHistoryTask : Task {
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getRelations(params.roomId,
params.eventId,
RelationType.REPLACE,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt
index 25dfe32cbb..c12597bea0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt
@@ -18,12 +18,12 @@ package org.matrix.android.sdk.internal.session.room.relation
import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.relation.ReactionContent
import org.matrix.android.sdk.api.session.room.model.relation.ReactionInfo
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.SessionComponent
import org.matrix.android.sdk.internal.session.room.RoomAPI
@@ -47,7 +47,7 @@ internal class SendRelationWorker(context: Context, params: WorkerParameters)
) : SessionWorkerParams
@Inject lateinit var roomAPI: RoomAPI
- @Inject lateinit var eventBus: EventBus
+ @Inject lateinit var globalErrorReceiver: GlobalErrorReceiver
@Inject lateinit var localEchoRepository: LocalEchoRepository
override fun injectWith(injector: SessionComponent) {
@@ -84,7 +84,7 @@ internal class SendRelationWorker(context: Context, params: WorkerParameters)
}
private suspend fun sendRelation(roomId: String, relationType: String, relatedEventId: String, localEvent: Event) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.sendRelation(
roomId = roomId,
parentId = relatedEventId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/ReportContentTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/ReportContentTask.kt
index bd11937676..9c6e9907a4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/ReportContentTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/ReportContentTask.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.room.reporting
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface ReportContentTask : Task {
@@ -33,11 +33,11 @@ internal interface ReportContentTask : Task {
internal class DefaultReportContentTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : ReportContentTask {
override suspend fun execute(params: ReportContentTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomAPI.reportContent(params.roomId, params.eventId, ReportContentBody(params.score, params.reason))
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt
index f4871ab35d..f742271fa7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.room.send
import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
@@ -42,7 +41,7 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryUpdater
-import org.matrix.android.sdk.internal.session.room.timeline.DefaultTimeline
+import org.matrix.android.sdk.internal.session.room.timeline.TimelineInput
import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.util.awaitTransaction
import timber.log.Timber
@@ -52,7 +51,7 @@ internal class LocalEchoRepository @Inject constructor(@SessionDatabase private
private val taskExecutor: TaskExecutor,
private val realmSessionProvider: RealmSessionProvider,
private val roomSummaryUpdater: RoomSummaryUpdater,
- private val eventBus: EventBus,
+ private val timelineInput: TimelineInput,
private val timelineEventMapper: TimelineEventMapper) {
fun createLocalEcho(event: Event) {
@@ -76,7 +75,7 @@ internal class LocalEchoRepository @Inject constructor(@SessionDatabase private
}
}
val timelineEvent = timelineEventMapper.map(timelineEventEntity)
- eventBus.post(DefaultTimeline.OnLocalEchoCreated(roomId = roomId, timelineEvent = timelineEvent))
+ timelineInput.onLocalEchoCreated(roomId = roomId, timelineEvent = timelineEvent)
taskExecutor.executorScope.asyncTransaction(monarchy) { realm ->
val eventInsertEntity = EventInsertEntity(event.eventId, event.type).apply {
this.insertType = EventInsertType.LOCAL_ECHO
@@ -90,7 +89,7 @@ internal class LocalEchoRepository @Inject constructor(@SessionDatabase private
fun updateSendState(eventId: String, roomId: String?, sendState: SendState) {
Timber.v("## SendEvent: [${System.currentTimeMillis()}] Update local state of $eventId to ${sendState.name}")
- eventBus.post(DefaultTimeline.OnLocalEchoUpdated(roomId ?: "", eventId, sendState))
+ timelineInput.onLocalEchoUpdated(roomId = roomId ?: "", eventId = eventId, sendState = sendState)
updateEchoAsync(eventId) { realm, sendingEventEntity ->
if (sendState == SendState.SENT && sendingEventEntity.sendState == SendState.SYNCED) {
// If already synced, do not put as sent
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
index 682865eaee..c901c7e18e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
@@ -18,8 +18,8 @@ package org.matrix.android.sdk.internal.session.room.send
import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.Failure
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.SessionComponent
import org.matrix.android.sdk.internal.session.room.RoomAPI
@@ -46,7 +46,7 @@ internal class RedactEventWorker(context: Context, params: WorkerParameters)
) : SessionWorkerParams
@Inject lateinit var roomAPI: RoomAPI
- @Inject lateinit var eventBus: EventBus
+ @Inject lateinit var globalErrorReceiver: GlobalErrorReceiver
override fun injectWith(injector: SessionComponent) {
injector.inject(this)
@@ -55,7 +55,7 @@ internal class RedactEventWorker(context: Context, params: WorkerParameters)
override suspend fun doSafeWork(params: Params): Result {
val eventId = params.eventId
return runCatching {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.redactEvent(
params.txID,
params.roomId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
index 37a429d242..c1fc2fd9fe 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
@@ -20,7 +20,6 @@ import android.content.Context
import androidx.work.WorkerParameters
import com.squareup.moshi.JsonClass
import io.realm.RealmConfiguration
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.failure.shouldBeRetried
import org.matrix.android.sdk.api.session.crypto.CryptoService
import org.matrix.android.sdk.api.session.room.send.SendState
@@ -54,7 +53,6 @@ internal class SendEventWorker(context: Context,
@Inject lateinit var localEchoRepository: LocalEchoRepository
@Inject lateinit var sendEventTask: SendEventTask
@Inject lateinit var cryptoService: CryptoService
- @Inject lateinit var eventBus: EventBus
@Inject lateinit var cancelSendTracker: CancelSendTracker
@SessionDatabase @Inject lateinit var realmConfiguration: RealmConfiguration
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt
index b546584450..804968bac0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt
@@ -35,13 +35,11 @@ import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.api.util.MimeTypes
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.session.content.FileUploader
-import org.matrix.android.sdk.internal.session.room.alias.AddRoomAliasTask
internal class DefaultStateService @AssistedInject constructor(@Assisted private val roomId: String,
private val stateEventDataSource: StateEventDataSource,
private val sendStateTask: SendStateTask,
- private val fileUploader: FileUploader,
- private val addRoomAliasTask: AddRoomAliasTask
+ private val fileUploader: FileUploader
) : StateService {
@AssistedInject.Factory
@@ -74,11 +72,19 @@ internal class DefaultStateService @AssistedInject constructor(@Assisted private
roomId = roomId,
stateKey = stateKey,
eventType = eventType,
- body = body
+ body = body.toSafeJson(eventType)
)
sendStateTask.execute(params)
}
+ private fun JsonDict.toSafeJson(eventType: String): JsonDict {
+ // Safe treatment for PowerLevelContent
+ return when (eventType) {
+ EventType.STATE_ROOM_POWER_LEVELS -> toSafePowerLevelsContentDict()
+ else -> this
+ }
+ }
+
override suspend fun updateTopic(topic: String) {
sendStateEvent(
eventType = EventType.STATE_ROOM_TOPIC,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SafePowerLevelContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SafePowerLevelContent.kt
new file mode 100644
index 0000000000..a97709e38b
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SafePowerLevelContent.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.session.room.state
+
+import com.squareup.moshi.Json
+import com.squareup.moshi.JsonClass
+import org.matrix.android.sdk.api.session.events.model.toContent
+import org.matrix.android.sdk.api.session.events.model.toModel
+import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
+import org.matrix.android.sdk.api.session.room.powerlevels.Role
+import org.matrix.android.sdk.api.util.JsonDict
+
+@JsonClass(generateAdapter = true)
+internal data class SerializablePowerLevelsContent(
+ @Json(name = "ban") val ban: Int = Role.Moderator.value,
+ @Json(name = "kick") val kick: Int = Role.Moderator.value,
+ @Json(name = "invite") val invite: Int = Role.Moderator.value,
+ @Json(name = "redact") val redact: Int = Role.Moderator.value,
+ @Json(name = "events_default") val eventsDefault: Int = Role.Default.value,
+ @Json(name = "events") val events: Map = emptyMap(),
+ @Json(name = "users_default") val usersDefault: Int = Role.Default.value,
+ @Json(name = "users") val users: Map = emptyMap(),
+ @Json(name = "state_default") val stateDefault: Int = Role.Moderator.value,
+ // `Int` is the diff here (instead of `Any`)
+ @Json(name = "notifications") val notifications: Map = emptyMap()
+)
+
+internal fun JsonDict.toSafePowerLevelsContentDict(): JsonDict {
+ return toModel()
+ ?.let { content ->
+ SerializablePowerLevelsContent(
+ ban = content.ban,
+ kick = content.kick,
+ invite = content.invite,
+ redact = content.redact,
+ eventsDefault = content.eventsDefault,
+ events = content.events,
+ usersDefault = content.usersDefault,
+ users = content.users,
+ stateDefault = content.stateDefault,
+ notifications = content.notifications.mapValues { content.notificationLevel(it.key) }
+ )
+ }
+ ?.toContent()
+ ?: emptyMap()
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SendStateTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SendStateTask.kt
index 642f68c15b..63691d9207 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SendStateTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/SendStateTask.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.session.room.state
import org.matrix.android.sdk.api.util.JsonDict
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface SendStateTask : Task {
@@ -34,11 +34,11 @@ internal interface SendStateTask : Task {
internal class DefaultSendStateTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SendStateTask {
override suspend fun execute(params: SendStateTask.Params) {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = if (params.stateKey == null) {
roomAPI.sendStateEvent(
roomId = params.roomId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/AddTagToRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/AddTagToRoomTask.kt
index 013fc86d5c..c3b5c3f78f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/AddTagToRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/AddTagToRoomTask.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.session.room.tags
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface AddTagToRoomTask : Task {
@@ -35,11 +35,11 @@ internal interface AddTagToRoomTask : Task {
internal class DefaultAddTagToRoomTask @Inject constructor(
private val roomAPI: RoomAPI,
@UserId private val userId: String,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : AddTagToRoomTask {
override suspend fun execute(params: AddTagToRoomTask.Params) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.putTag(
userId = userId,
roomId = params.roomId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DeleteTagFromRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DeleteTagFromRoomTask.kt
index b22355d431..d578d21fde 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DeleteTagFromRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DeleteTagFromRoomTask.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.session.room.tags
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface DeleteTagFromRoomTask : Task {
@@ -34,11 +34,11 @@ internal interface DeleteTagFromRoomTask : Task(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.deleteTag(
userId = userId,
roomId = params.roomId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt
index dd58529412..ae90282d52 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt
@@ -23,9 +23,6 @@ import io.realm.RealmConfiguration
import io.realm.RealmQuery
import io.realm.RealmResults
import io.realm.Sort
-import org.greenrobot.eventbus.EventBus
-import org.greenrobot.eventbus.Subscribe
-import org.greenrobot.eventbus.ThreadMode
import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.NoOpMatrixCallback
import org.matrix.android.sdk.api.extensions.orFalse
@@ -81,15 +78,13 @@ internal class DefaultTimeline(
private val timelineEventMapper: TimelineEventMapper,
private val settings: TimelineSettings,
private val hiddenReadReceipts: TimelineHiddenReadReceipts,
- private val eventBus: EventBus,
+ private val timelineInput: TimelineInput,
private val eventDecryptor: TimelineEventDecryptor,
private val realmSessionProvider: RealmSessionProvider,
private val loadRoomMembersTask: LoadRoomMembersTask
-) : Timeline, TimelineHiddenReadReceipts.Delegate {
-
- data class OnNewTimelineEvents(val roomId: String, val eventIds: List)
- data class OnLocalEchoCreated(val roomId: String, val timelineEvent: TimelineEvent)
- data class OnLocalEchoUpdated(val roomId: String, val eventId: String, val sendState: SendState)
+) : Timeline,
+ TimelineHiddenReadReceipts.Delegate,
+ TimelineInput.Listener {
companion object {
val BACKGROUND_HANDLER = createBackgroundHandler("TIMELINE_DB_THREAD")
@@ -161,7 +156,7 @@ internal class DefaultTimeline(
override fun start() {
if (isStarted.compareAndSet(false, true)) {
Timber.v("Start timeline for roomId: $roomId and eventId: $initialEventId")
- eventBus.register(this)
+ timelineInput.listeners.add(this)
BACKGROUND_HANDLER.post {
eventDecryptor.start()
val realm = Realm.getInstance(realmConfiguration)
@@ -206,7 +201,7 @@ internal class DefaultTimeline(
override fun dispose() {
if (isStarted.compareAndSet(true, false)) {
isReady.set(false)
- eventBus.unregister(this)
+ timelineInput.listeners.remove(this)
Timber.v("Dispose timeline for roomId: $roomId and eventId: $initialEventId")
cancelableBag.cancel()
BACKGROUND_HANDLER.removeCallbacksAndMessages(null)
@@ -323,25 +318,22 @@ internal class DefaultTimeline(
postSnapshot()
}
- @Subscribe(threadMode = ThreadMode.MAIN)
- fun onNewTimelineEvents(onNewTimelineEvents: OnNewTimelineEvents) {
- if (isLive && onNewTimelineEvents.roomId == roomId) {
+ override fun onNewTimelineEvents(roomId: String, eventIds: List) {
+ if (isLive && this.roomId == roomId) {
listeners.forEach {
- it.onNewTimelineEvents(onNewTimelineEvents.eventIds)
+ it.onNewTimelineEvents(eventIds)
}
}
}
- @Subscribe(threadMode = ThreadMode.MAIN)
- fun onLocalEchoCreated(onLocalEchoCreated: OnLocalEchoCreated) {
- if (uiEchoManager.onLocalEchoCreated(onLocalEchoCreated)) {
+ override fun onLocalEchoCreated(roomId: String, timelineEvent: TimelineEvent) {
+ if (uiEchoManager.onLocalEchoCreated(roomId, timelineEvent)) {
postSnapshot()
}
}
- @Subscribe(threadMode = ThreadMode.MAIN)
- fun onLocalEchoUpdated(onLocalEchoUpdated: OnLocalEchoUpdated) {
- if (uiEchoManager.onLocalEchoUpdated(onLocalEchoUpdated)) {
+ override fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState) {
+ if (uiEchoManager.onLocalEchoUpdated(roomId, eventId, sendState)) {
postSnapshot()
}
}
@@ -858,11 +850,11 @@ internal class DefaultTimeline(
}
}
- fun onLocalEchoUpdated(onLocalEchoUpdated: OnLocalEchoUpdated): Boolean {
- if (isLive && onLocalEchoUpdated.roomId == roomId) {
- val existingState = inMemorySendingStates[onLocalEchoUpdated.eventId]
- inMemorySendingStates[onLocalEchoUpdated.eventId] = onLocalEchoUpdated.sendState
- if (existingState != onLocalEchoUpdated.sendState) {
+ fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState): Boolean {
+ if (isLive && roomId == this@DefaultTimeline.roomId) {
+ val existingState = inMemorySendingStates[eventId]
+ inMemorySendingStates[eventId] = sendState
+ if (existingState != sendState) {
return true
}
}
@@ -870,22 +862,22 @@ internal class DefaultTimeline(
}
// return true if should update
- fun onLocalEchoCreated(onLocalEchoCreated: OnLocalEchoCreated): Boolean {
+ fun onLocalEchoCreated(roomId: String, timelineEvent: TimelineEvent): Boolean {
var postSnapshot = false
- if (isLive && onLocalEchoCreated.roomId == roomId) {
+ if (isLive && roomId == this@DefaultTimeline.roomId) {
// Manage some ui echos (do it before filter because actual event could be filtered out)
- when (onLocalEchoCreated.timelineEvent.root.getClearType()) {
+ when (timelineEvent.root.getClearType()) {
EventType.REDACTION -> {
}
EventType.REACTION -> {
- val content = onLocalEchoCreated.timelineEvent.root.content?.toModel()
+ val content = timelineEvent.root.content?.toModel()
if (RelationType.ANNOTATION == content?.relatesTo?.type) {
val reaction = content.relatesTo.key
val relatedEventID = content.relatesTo.eventId
inMemoryReactions.getOrPut(relatedEventID) { mutableListOf() }
.add(
ReactionUiEchoData(
- localEchoId = onLocalEchoCreated.timelineEvent.eventId,
+ localEchoId = timelineEvent.eventId,
reactedOnEventId = relatedEventID,
reaction = reaction
)
@@ -898,12 +890,12 @@ internal class DefaultTimeline(
}
// do not add events that would have been filtered
- if (listOf(onLocalEchoCreated.timelineEvent).filterEventsWithSettings().isNotEmpty()) {
+ if (listOf(timelineEvent).filterEventsWithSettings().isNotEmpty()) {
listeners.forEach {
- it.onNewTimelineEvents(listOf(onLocalEchoCreated.timelineEvent.eventId))
+ it.onNewTimelineEvents(listOf(timelineEvent.eventId))
}
- Timber.v("On local echo created: ${onLocalEchoCreated.timelineEvent.eventId}")
- inMemorySendingEvents.add(0, onLocalEchoCreated.timelineEvent)
+ Timber.v("On local echo created: ${timelineEvent.eventId}")
+ inMemorySendingEvents.add(0, timelineEvent)
postSnapshot = true
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimelineService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimelineService.kt
index d02e906d00..fce09cc97c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimelineService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimelineService.kt
@@ -23,7 +23,6 @@ import com.squareup.inject.assisted.AssistedInject
import com.zhuinden.monarchy.Monarchy
import io.realm.Sort
import io.realm.kotlin.where
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.events.model.isImageMessage
import org.matrix.android.sdk.api.session.events.model.isVideoMessage
import org.matrix.android.sdk.api.session.room.timeline.Timeline
@@ -45,7 +44,7 @@ import org.matrix.android.sdk.internal.task.TaskExecutor
internal class DefaultTimelineService @AssistedInject constructor(@Assisted private val roomId: String,
@SessionDatabase private val monarchy: Monarchy,
private val realmSessionProvider: RealmSessionProvider,
- private val eventBus: EventBus,
+ private val timelineInput: TimelineInput,
private val taskExecutor: TaskExecutor,
private val contextOfEventTask: GetContextOfEventTask,
private val eventDecryptor: TimelineEventDecryptor,
@@ -72,7 +71,7 @@ internal class DefaultTimelineService @AssistedInject constructor(@Assisted priv
timelineEventMapper = timelineEventMapper,
settings = settings,
hiddenReadReceipts = TimelineHiddenReadReceipts(readReceiptsSummaryMapper, roomId, settings),
- eventBus = eventBus,
+ timelineInput = timelineInput,
eventDecryptor = eventDecryptor,
fetchTokenAndPaginateTask = fetchTokenAndPaginateTask,
realmSessionProvider = realmSessionProvider,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/FetchTokenAndPaginateTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/FetchTokenAndPaginateTask.kt
index d1bfa1adcb..76c4b3812c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/FetchTokenAndPaginateTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/FetchTokenAndPaginateTask.kt
@@ -20,12 +20,12 @@ import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.internal.database.model.ChunkEntity
import org.matrix.android.sdk.internal.database.query.findIncludingEvent
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.filter.FilterRepository
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface FetchTokenAndPaginateTask : Task {
@@ -43,12 +43,12 @@ internal class DefaultFetchTokenAndPaginateTask @Inject constructor(
@SessionDatabase private val monarchy: Monarchy,
private val filterRepository: FilterRepository,
private val paginationTask: PaginationTask,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : FetchTokenAndPaginateTask {
override suspend fun execute(params: FetchTokenAndPaginateTask.Params): TokenChunkEventPersistor.Result {
val filter = filterRepository.getRoomFilter()
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getContextOfEvent(params.roomId, params.lastKnownEventId, 0, filter)
}
val fromToken = if (params.direction == PaginationDirection.FORWARDS) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetContextOfEventTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetContextOfEventTask.kt
index 7a611dd350..d02a7bafe9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetContextOfEventTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetContextOfEventTask.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.room.timeline
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.filter.FilterRepository
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetContextOfEventTask : Task {
@@ -35,12 +35,12 @@ internal class DefaultGetContextOfEventTask @Inject constructor(
private val roomAPI: RoomAPI,
private val filterRepository: FilterRepository,
private val tokenChunkEventPersistor: TokenChunkEventPersistor,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : GetContextOfEventTask {
override suspend fun execute(params: GetContextOfEventTask.Params): TokenChunkEventPersistor.Result {
val filter = filterRepository.getRoomFilter()
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
// We are limiting the response to the event with eventId to be sure we don't have any issue with potential merging process.
apiCall = roomAPI.getContextOfEvent(params.roomId, params.eventId, 0, filter)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetEventTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetEventTask.kt
index acac3929ae..b8585b1e74 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetEventTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/GetEventTask.kt
@@ -17,17 +17,17 @@
package org.matrix.android.sdk.internal.session.room.timeline
import org.matrix.android.sdk.api.session.events.model.Event
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
// TODO Add parent task
internal class GetEventTask @Inject constructor(
private val roomAPI: RoomAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : Task {
internal data class Params(
@@ -36,7 +36,7 @@ internal class GetEventTask @Inject constructor(
)
override suspend fun execute(params: Params): Event {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getEvent(params.roomId, params.eventId)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationTask.kt
index b663d03bd7..1f99893e17 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationTask.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.room.timeline
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.filter.FilterRepository
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface PaginationTask : Task {
@@ -37,12 +37,12 @@ internal class DefaultPaginationTask @Inject constructor(
private val roomAPI: RoomAPI,
private val filterRepository: FilterRepository,
private val tokenChunkEventPersistor: TokenChunkEventPersistor,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : PaginationTask {
override suspend fun execute(params: PaginationTask.Params): TokenChunkEventPersistor.Result {
val filter = filterRepository.getRoomFilter()
- val chunk = executeRequest(eventBus) {
+ val chunk = executeRequest(globalErrorReceiver) {
isRetryable = true
apiCall = roomAPI.getRoomMessagesFrom(params.roomId, params.from, params.direction.value, params.limit, filter)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineInput.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineInput.kt
new file mode 100644
index 0000000000..002ab1dd8a
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineInput.kt
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.matrix.android.sdk.internal.session.room.timeline
+
+import org.matrix.android.sdk.api.session.room.send.SendState
+import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
+import org.matrix.android.sdk.internal.session.SessionScope
+import javax.inject.Inject
+
+@SessionScope
+internal class TimelineInput @Inject constructor() {
+ fun onLocalEchoCreated(roomId: String, timelineEvent: TimelineEvent) {
+ listeners.toSet().forEach { it.onLocalEchoCreated(roomId, timelineEvent) }
+ }
+
+ fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState) {
+ listeners.toSet().forEach { it.onLocalEchoUpdated(roomId, eventId, sendState) }
+ }
+
+ fun onNewTimelineEvents(roomId: String, eventIds: List) {
+ listeners.toSet().forEach { it.onNewTimelineEvents(roomId, eventIds) }
+ }
+
+ val listeners = mutableSetOf()
+
+ internal interface Listener {
+ fun onLocalEchoCreated(roomId: String, timelineEvent: TimelineEvent)
+ fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState)
+ fun onNewTimelineEvents(roomId: String, eventIds: List)
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/typing/SendTypingTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/typing/SendTypingTask.kt
index c8cbb08e2c..3b56d04872 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/typing/SendTypingTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/typing/SendTypingTask.kt
@@ -21,7 +21,7 @@ import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
import kotlinx.coroutines.delay
-import org.greenrobot.eventbus.EventBus
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import javax.inject.Inject
internal interface SendTypingTask : Task {
@@ -38,13 +38,13 @@ internal interface SendTypingTask : Task {
internal class DefaultSendTypingTask @Inject constructor(
private val roomAPI: RoomAPI,
@UserId private val userId: String,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SendTypingTask {
override suspend fun execute(params: SendTypingTask.Params) {
delay(params.delay ?: -1)
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.sendTypingState(
params.roomId,
userId,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/GetUploadsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/GetUploadsTask.kt
index d0439ce7f9..0c0e6a8ed0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/GetUploadsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/GetUploadsTask.kt
@@ -31,6 +31,7 @@ import org.matrix.android.sdk.internal.database.model.EventEntityFields
import org.matrix.android.sdk.internal.database.query.TimelineEventFilter
import org.matrix.android.sdk.internal.database.query.whereType
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.filter.FilterFactory
import org.matrix.android.sdk.internal.session.room.RoomAPI
@@ -39,7 +40,6 @@ import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection
import org.matrix.android.sdk.internal.session.room.timeline.PaginationResponse
import org.matrix.android.sdk.internal.session.sync.SyncTokenStore
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface GetUploadsTask : Task {
@@ -56,7 +56,7 @@ internal class DefaultGetUploadsTask @Inject constructor(
private val roomAPI: RoomAPI,
private val tokenStore: SyncTokenStore,
@SessionDatabase private val monarchy: Monarchy,
- private val eventBus: EventBus)
+ private val globalErrorReceiver: GlobalErrorReceiver)
: GetUploadsTask {
override suspend fun execute(params: GetUploadsTask.Params): GetUploadsResult {
@@ -86,7 +86,7 @@ internal class DefaultGetUploadsTask @Inject constructor(
val since = params.since ?: tokenStore.getLastToken() ?: throw IllegalStateException("No token available")
val filter = FilterFactory.createUploadsFilter(params.numberOfEvents).toJSONString()
- val chunk = executeRequest(eventBus) {
+ val chunk = executeRequest(globalErrorReceiver) {
apiCall = roomAPI.getRoomMessagesFrom(params.roomId, since, PaginationDirection.BACKWARDS.value, params.numberOfEvents, filter)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/search/SearchTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/search/SearchTask.kt
index 4f574e5ead..402602e4d5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/search/SearchTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/search/SearchTask.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.search
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.search.EventAndSender
import org.matrix.android.sdk.api.session.search.SearchResult
import org.matrix.android.sdk.api.util.MatrixItem
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.search.request.SearchRequestBody
import org.matrix.android.sdk.internal.session.search.request.SearchRequestCategories
@@ -47,11 +47,11 @@ internal interface SearchTask : Task {
internal class DefaultSearchTask @Inject constructor(
private val searchAPI: SearchAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SearchTask {
override suspend fun execute(params: SearchTask.Params): SearchResult {
- return executeRequest(eventBus) {
+ return executeRequest(globalErrorReceiver) {
val searchRequestBody = SearchRequestBody(
searchCategories = SearchRequestCategories(
roomEvents = SearchRequestRoomEvents(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignInAgainTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignInAgainTask.kt
index 3bed0bdbff..2c3cd5d270 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignInAgainTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignInAgainTask.kt
@@ -20,9 +20,9 @@ import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.internal.auth.SessionParamsStore
import org.matrix.android.sdk.internal.auth.data.PasswordLoginParams
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface SignInAgainTask : Task {
@@ -35,11 +35,11 @@ internal class DefaultSignInAgainTask @Inject constructor(
private val signOutAPI: SignOutAPI,
private val sessionParams: SessionParams,
private val sessionParamsStore: SessionParamsStore,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SignInAgainTask {
override suspend fun execute(params: SignInAgainTask.Params) {
- val newCredentials = executeRequest(eventBus) {
+ val newCredentials = executeRequest(globalErrorReceiver) {
apiCall = signOutAPI.loginAgain(
PasswordLoginParams.userIdentifier(
// Reuse the same userId
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
index 153ea5a6fd..0cb8704782 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
@@ -18,11 +18,11 @@ package org.matrix.android.sdk.internal.session.signout
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.cleanup.CleanupSession
import org.matrix.android.sdk.internal.session.identity.IdentityDisconnectTask
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import timber.log.Timber
import java.net.HttpURLConnection
import javax.inject.Inject
@@ -35,7 +35,7 @@ internal interface SignOutTask : Task {
internal class DefaultSignOutTask @Inject constructor(
private val signOutAPI: SignOutAPI,
- private val eventBus: EventBus,
+ private val globalErrorReceiver: GlobalErrorReceiver,
private val identityDisconnectTask: IdentityDisconnectTask,
private val cleanupSession: CleanupSession
) : SignOutTask {
@@ -45,7 +45,7 @@ internal class DefaultSignOutTask @Inject constructor(
if (params.signOutFromHomeserver) {
Timber.d("SignOut: send request...")
try {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = signOutAPI.signOut()
}
} catch (throwable: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
index b1b2f65dc2..456b0f9c26 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.session.sync
import io.realm.Realm
import io.realm.kotlin.createObject
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.R
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.Event
@@ -55,8 +54,8 @@ import org.matrix.android.sdk.internal.session.room.membership.RoomChangeMembers
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberEventHandler
import org.matrix.android.sdk.internal.session.room.read.FullyReadContent
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryUpdater
-import org.matrix.android.sdk.internal.session.room.timeline.DefaultTimeline
import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection
+import org.matrix.android.sdk.internal.session.room.timeline.TimelineInput
import org.matrix.android.sdk.internal.session.room.typing.TypingEventContent
import org.matrix.android.sdk.internal.session.sync.model.InvitedRoomSync
import org.matrix.android.sdk.internal.session.sync.model.RoomSync
@@ -75,7 +74,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
private val roomTypingUsersHandler: RoomTypingUsersHandler,
private val roomChangeMembershipStateDataSource: RoomChangeMembershipStateDataSource,
@UserId private val userId: String,
- private val eventBus: EventBus) {
+ private val timelineInput: TimelineInput) {
sealed class HandlingStrategy {
data class JOINED(val data: Map) : HandlingStrategy()
@@ -348,7 +347,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
}
}
// posting new events to timeline if any is registered
- eventBus.post(DefaultTimeline.OnNewTimelineEvents(roomId = roomId, eventIds = eventIds))
+ timelineInput.onNewTimelineEvents(roomId = roomId, eventIds = eventIds)
return chunkEntity
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
index b4fd6e7386..7c38230065 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.sync
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.R
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.TimeOutInterceptor
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.DefaultInitialSyncProgressService
@@ -48,7 +48,7 @@ internal class DefaultSyncTask @Inject constructor(
private val getHomeServerCapabilitiesTask: GetHomeServerCapabilitiesTask,
private val userStore: UserStore,
private val syncTaskSequencer: SyncTaskSequencer,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SyncTask {
override suspend fun execute(params: SyncTask.Params) = syncTaskSequencer.post {
@@ -81,7 +81,7 @@ internal class DefaultSyncTask @Inject constructor(
val readTimeOut = (params.timeout + TIMEOUT_MARGIN).coerceAtLeast(TimeOutInterceptor.DEFAULT_LONG_TIMEOUT)
- val syncResponse = executeRequest(eventBus) {
+ val syncResponse = executeRequest(globalErrorReceiver) {
apiCall = syncAPI.sync(
params = requestParams,
readTimeOut = readTimeOut
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt
index 6d100a71f9..cce169c246 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncService.kt
@@ -36,6 +36,7 @@ import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.util.BackgroundDetectionObserver
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import timber.log.Timber
+import java.net.SocketTimeoutException
import java.util.concurrent.atomic.AtomicBoolean
/**
@@ -49,8 +50,9 @@ abstract class SyncService : Service() {
private var sessionId: String? = null
private var mIsSelfDestroyed: Boolean = false
- private var syncTimeoutSeconds: Int = 6
- private var syncDelaySeconds: Int = 60
+ private var syncTimeoutSeconds: Int = getDefaultSyncTimeoutSeconds()
+ private var syncDelaySeconds: Int = getDefaultSyncDelaySeconds()
+
private var periodic: Boolean = false
private var preventReschedule: Boolean = false
@@ -68,14 +70,12 @@ abstract class SyncService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Timber.i("## Sync: onStartCommand [$this] $intent with action: ${intent?.action}")
-
- // We should start we have to ensure we fulfill contract to show notification
- // for foreground service (as per design for this service)
- // TODO can we check if it's really in foreground
- onStart(isInitialSync)
when (intent?.action) {
ACTION_STOP -> {
Timber.i("## Sync: stop command received")
+ // We should start we have to ensure we fulfill contract to show notification
+ // for foreground service (as per design for this service)
+ onStart(isInitialSync)
// If it was periodic we ensure that it will not reschedule itself
preventReschedule = true
// we don't want to cancel initial syncs, let it finish
@@ -85,11 +85,12 @@ abstract class SyncService : Service() {
}
else -> {
val isInit = initialize(intent)
+ onStart(isInitialSync)
if (isInit) {
periodic = intent?.getBooleanExtra(EXTRA_PERIODIC, false) ?: false
val onNetworkBack = intent?.getBooleanExtra(EXTRA_NETWORK_BACK_RESTART, false) ?: false
Timber.d("## Sync: command received, periodic: $periodic networkBack: $onNetworkBack")
- if (onNetworkBack && !backgroundDetectionObserver.isInBackground) {
+ if (!isInitialSync && onNetworkBack && !backgroundDetectionObserver.isInBackground) {
// the restart after network occurs while the app is in foreground
// so just stop. It will be restarted when entering background
preventReschedule = true
@@ -119,7 +120,11 @@ abstract class SyncService : Service() {
serviceScope.coroutineContext.cancelChildren()
if (!preventReschedule && periodic && sessionId != null && backgroundDetectionObserver.isInBackground) {
Timber.d("## Sync: Reschedule service in $syncDelaySeconds sec")
- onRescheduleAsked(sessionId ?: "", false, syncTimeoutSeconds, syncDelaySeconds)
+ onRescheduleAsked(
+ sessionId = sessionId ?: "",
+ syncTimeoutSeconds = syncTimeoutSeconds,
+ syncDelaySeconds = syncDelaySeconds
+ )
}
super.onDestroy()
}
@@ -165,10 +170,23 @@ abstract class SyncService : Service() {
preventReschedule = true
}
if (throwable is Failure.NetworkConnection) {
- // Network is off, no need to reschedule endless alarms :/
+ // Timeout is not critical, so retry as soon as possible.
+ if (throwable.cause is SocketTimeoutException) {
+ // For big accounts, computing sync response can take time, but Synapse will cache the
+ // result for the next request. So keep retrying in loop
+ Timber.w("Timeout during sync, retry in loop")
+ doSync()
+ return
+ }
+ // Network might be off, no need to reschedule endless alarms :/
preventReschedule = true
- // Instead start a work to restart background sync when network is back
- onNetworkError(sessionId ?: "", isInitialSync, syncTimeoutSeconds, syncDelaySeconds)
+ // Instead start a work to restart background sync when network is on
+ onNetworkError(
+ sessionId = sessionId ?: "",
+ syncTimeoutSeconds = syncTimeoutSeconds,
+ syncDelaySeconds = syncDelaySeconds,
+ isPeriodic = periodic
+ )
}
// JobCancellation could be caught here when onDestroy cancels the coroutine context
if (isRunning.get()) stopMe()
@@ -182,8 +200,8 @@ abstract class SyncService : Service() {
}
val matrix = Matrix.getInstance(applicationContext)
val safeSessionId = intent.getStringExtra(EXTRA_SESSION_ID) ?: return false
- syncTimeoutSeconds = intent.getIntExtra(EXTRA_TIMEOUT_SECONDS, 6)
- syncDelaySeconds = intent.getIntExtra(EXTRA_DELAY_SECONDS, 60)
+ syncTimeoutSeconds = intent.getIntExtra(EXTRA_TIMEOUT_SECONDS, getDefaultSyncTimeoutSeconds())
+ syncDelaySeconds = intent.getIntExtra(EXTRA_DELAY_SECONDS, getDefaultSyncDelaySeconds())
try {
val sessionComponent = matrix.sessionManager.getSessionComponent(safeSessionId)
?: throw IllegalStateException("## Sync: You should have a session to make it work")
@@ -202,11 +220,15 @@ abstract class SyncService : Service() {
}
}
+ abstract fun getDefaultSyncTimeoutSeconds(): Int
+
+ abstract fun getDefaultSyncDelaySeconds(): Int
+
abstract fun onStart(isInitialSync: Boolean)
- abstract fun onRescheduleAsked(sessionId: String, isInitialSync: Boolean, timeout: Int, delay: Int)
+ abstract fun onRescheduleAsked(sessionId: String, syncTimeoutSeconds: Int, syncDelaySeconds: Int)
- abstract fun onNetworkError(sessionId: String, isInitialSync: Boolean, timeout: Int, delay: Int)
+ abstract fun onNetworkError(sessionId: String, syncTimeoutSeconds: Int, syncDelaySeconds: Int, isPeriodic: Boolean)
override fun onBind(intent: Intent?): IBinder? {
return null
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateIgnoredUserIdsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateIgnoredUserIdsTask.kt
index d1393c8b37..26e8d3380a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateIgnoredUserIdsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateIgnoredUserIdsTask.kt
@@ -17,11 +17,11 @@
package org.matrix.android.sdk.internal.session.user.accountdata
import com.zhuinden.monarchy.Monarchy
-import org.greenrobot.eventbus.EventBus
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
import org.matrix.android.sdk.internal.database.model.IgnoredUserEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.sync.model.accountdata.IgnoredUsersContent
import org.matrix.android.sdk.internal.task.Task
@@ -40,7 +40,7 @@ internal class DefaultUpdateIgnoredUserIdsTask @Inject constructor(
@SessionDatabase private val monarchy: Monarchy,
private val saveIgnoredUsersTask: SaveIgnoredUsersTask,
@UserId private val userId: String,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : UpdateIgnoredUserIdsTask {
override suspend fun execute(params: UpdateIgnoredUserIdsTask.Params) {
@@ -63,7 +63,7 @@ internal class DefaultUpdateIgnoredUserIdsTask @Inject constructor(
val list = ignoredUserIds.toList()
val body = IgnoredUsersContent.createWithUserIds(list)
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = accountDataApi.setAccountData(userId, UserAccountDataTypes.TYPE_IGNORED_USER_LIST, body)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
index 80ab79b228..dba28253a7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
@@ -24,8 +24,8 @@ import org.matrix.android.sdk.internal.session.sync.model.accountdata.AcceptedTe
import org.matrix.android.sdk.internal.session.sync.model.accountdata.BreadcrumbsContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.IdentityServerContent
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface UpdateUserAccountDataTask : Task {
@@ -100,11 +100,11 @@ internal interface UpdateUserAccountDataTask : Task> {
@@ -34,11 +34,11 @@ internal interface SearchUserTask : Task> {
internal class DefaultSearchUserTask @Inject constructor(
private val searchUserAPI: SearchUserAPI,
- private val eventBus: EventBus
+ private val globalErrorReceiver: GlobalErrorReceiver
) : SearchUserTask {
override suspend fun execute(params: SearchUserTask.Params): List {
- val response = executeRequest(eventBus) {
+ val response = executeRequest(globalErrorReceiver) {
apiCall = searchUserAPI.searchUsers(SearchUsersParams(params.search, params.limit))
}
return response.users.map {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/CreateWidgetTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/CreateWidgetTask.kt
index 422615af2d..ae807ce30f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/CreateWidgetTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/CreateWidgetTask.kt
@@ -25,10 +25,10 @@ import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFie
import org.matrix.android.sdk.internal.database.query.whereStateKey
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.room.RoomAPI
import org.matrix.android.sdk.internal.task.Task
-import org.greenrobot.eventbus.EventBus
import javax.inject.Inject
internal interface CreateWidgetTask : Task {
@@ -43,10 +43,10 @@ internal interface CreateWidgetTask : Task {
internal class DefaultCreateWidgetTask @Inject constructor(@SessionDatabase private val monarchy: Monarchy,
private val roomAPI: RoomAPI,
@UserId private val userId: String,
- private val eventBus: EventBus) : CreateWidgetTask {
+ private val globalErrorReceiver: GlobalErrorReceiver) : CreateWidgetTask {
override suspend fun execute(params: CreateWidgetTask.Params) {
- executeRequest(eventBus) {
+ executeRequest(globalErrorReceiver) {
apiCall = roomAPI.sendStateEvent(
roomId = params.roomId,
stateEventType = EventType.STATE_ROOM_WIDGET_LEGACY,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt
index c6647f7572..b58cab99b5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt
@@ -20,6 +20,7 @@ import android.content.Context
import androidx.work.ListenableWorker
import androidx.work.WorkerFactory
import androidx.work.WorkerParameters
+import timber.log.Timber
import javax.inject.Inject
import javax.inject.Provider
@@ -32,6 +33,8 @@ class MatrixWorkerFactory @Inject constructor(
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker? {
+ Timber.d("MatrixWorkerFactory.createWorker for $workerClassName")
+
val foundEntry =
workerFactories.entries.find { Class.forName(workerClassName).isAssignableFrom(it.key) }
val factoryProvider = foundEntry?.value
diff --git a/matrix-sdk-android/src/main/res/values-cs/strings.xml b/matrix-sdk-android/src/main/res/values-cs/strings.xml
index 50dea12b09..adb3517927 100644
--- a/matrix-sdk-android/src/main/res/values-cs/strings.xml
+++ b/matrix-sdk-android/src/main/res/values-cs/strings.xml
@@ -242,4 +242,30 @@
• Server shodující se s %s je zakázán.
Nastavili jste ACL serveru pro tuto místnost.
%s nastavili ACL serveru pro tuto místnost.
+ Změnili jste adresy pro tuto místnost.
+ %1$s změnili adresy pro tuto místnost.
+ Změnili jste hlavní a alternativní adresu pro tuto místnost.
+ %1$s změnili hlavní a alternativní adresu pro tuto místnost.
+ Změnili jste alternativní adresu pro tuto místnost.
+ %1$s změnili alternativní adresu pro tuto místnost.
+
+ - Odstranili jste alternativní adresu %1$s pro tuto místnost.
+ - Odstranili jste alternativní adresy %1$s pro tuto místnost.
+ - Odstranili jste alternativní adresy %1$s pro tuto místnost.
+
+
+ - %1$s odstranili alternativní adresu %2$s pro tuto místnost.
+ - %1$s odstranili alternativní adresy %2$s pro tuto místnost.
+ - %1$s odstranili alternativní adresy %2$s pro tuto místnost.
+
+
+ - Přidali jste alternativní adresu %1$s pro tuto místnost.
+ - Přidali jste alternativní adresy %1$s pro tuto místnost.
+ - Přidali jste alternativní adresy %1$s pro tuto místnost.
+
+
+ - %1$s přidali alternativní adresu %2$s pro tuto místnost.
+ - %1$s přidali alternativní adresy %2$s pro tuto místnost.
+ - %1$s přidali alternativní adresy %2$s pro tuto místnost.
+
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/res/values-et/strings.xml b/matrix-sdk-android/src/main/res/values-et/strings.xml
index 957c0b9955..af2cc33b99 100644
--- a/matrix-sdk-android/src/main/res/values-et/strings.xml
+++ b/matrix-sdk-android/src/main/res/values-et/strings.xml
@@ -47,7 +47,7 @@
Sõnumi saatja seade ei ole selle sõnumi jaoks saatnud dekrüptimisvõtmeid.
Ei saanud muuta sõnumit
Sõnumi saatmine ei õnnestunud
- Faili üles laadimine ei õnnestunud
+ Pildi üleslaadimine ei õnnestunud
Võrguühenduse viga
Matrix\'i viga
Hetkel ei ole võimalik uuesti liituda tühja jututoaga.
@@ -236,4 +236,26 @@
• Lubatud on serverid, mille ip-aadress vastab mustrile.
• Lubatud on serverid, mille nimes leidub %s.
• Keelatud on serverid, mille nimes leidub %s.
+ %1$s muutis selle jututoa aadresse.
+ Sa muutsid selle jututoa põhiaadressi ja täiendavaid aadresse.
+ %1$s muutis selle jututoa täiendavaid aadresse.
+ Sa muutsid selle jututoa täiendavaid aadresse.
+ %1$s muutis selle jututoa põhiaadressi ja täiendavaid aadresse.
+
+ - Sa eemaldasid selle jututoa täiendava aadressi %1$s.
+ - Sa eemaldasid selle jututoa täiendavad aadressid %1$s.
+
+
+ - %1$s eemaldas selle jututoa täiendava aadressi %2$s.
+ - %1$s eemaldas selle jututoa täiendavad aadressid %2$s.
+
+
+ - Sa lisasid sellele jututoale täiendava aadressi %1$s.
+ - Sa lisasid sellele jututoale täiendavad aadressid %1$s.
+
+
+ - %1$s lisas sellele jututoale täiendava aadressi %2$s.
+ - %1$s lisas sellele jututoale täiendavad aadressid %2$s.
+
+ Sa muutsid selle jututoa aadresse.
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/res/values-fa/strings.xml b/matrix-sdk-android/src/main/res/values-fa/strings.xml
index 8f8059067e..50446b9708 100644
--- a/matrix-sdk-android/src/main/res/values-fa/strings.xml
+++ b/matrix-sdk-android/src/main/res/values-fa/strings.xml
@@ -218,4 +218,5 @@
- %1$s، %2$s، %3$s و %4$d نفر دیگر
%1$s، %2$s و %3$s
+ %1$s، %2$s، %3$s و %4$s
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/res/values-it/strings.xml b/matrix-sdk-android/src/main/res/values-it/strings.xml
index c1a5cf85cb..ec19cd5c17 100644
--- a/matrix-sdk-android/src/main/res/values-it/strings.xml
+++ b/matrix-sdk-android/src/main/res/values-it/strings.xml
@@ -102,7 +102,7 @@
- %1$s ha rimosso %2$s come indirizzo per questa stanza.
- - %1$s ha rimosso %3$s come indirizzi per questa stanza.
+ - %1$s ha rimosso %2$s come indirizzi per questa stanza.
%1$s ha aggiunto %2$s e rimosso %3$s come indirizzi per questa stanza.
%1$s ha impostato l\'indirizzo principale per questa stanza a %2$s.
@@ -237,4 +237,26 @@
• I server che corrispondono a %s sono banditi.
Hai impostato le ACL del server per questa stanza.
%s ha impostato le ACL del server per questa stanza.
+ Hai cambiato gli indirizzi per questa stanza.
+ %1$s ha cambiato gli indirizzi per questa stanza.
+ Hai cambiato gli indirizzi principali ed alternativi per questa stanza.
+ %1$s ha cambiato gli indirizzi principali ed alternativi per questa stanza.
+ Hai cambiato gli indirizzi alternativi per questa stanza.
+ %1$s ha cambiato gli indirizzi alternativi per questa stanza.
+
+ - Hai rimosso l\'indirizzo alternativo %1$s per questa stanza.
+ - Hai rimosso gli indirizzi alternativi %1$s per questa stanza.
+
+
+ - %1$s ha rimosso l\'indirizzo alternativo %2$s per questa stanza.
+ - %1$s ha rimosso gli indirizzi alternativi %2$s per questa stanza.
+
+
+ - Hai aggiunto l\'indirizzo alternativo %1$s per questa stanza.
+ - Hai aggiunto gli indirizzi alternativi %1$s per questa stanza.
+
+
+ - %1$s ha aggiunto l\'indirizzo alternativo %2$s per questa stanza.
+ - %1$s ha aggiunto gli indirizzi alternativi %2$s per questa stanza.
+
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/res/values-lv/strings.xml b/matrix-sdk-android/src/main/res/values-lv/strings.xml
index b14cbb4b00..b4478be9be 100644
--- a/matrix-sdk-android/src/main/res/values-lv/strings.xml
+++ b/matrix-sdk-android/src/main/res/values-lv/strings.xml
@@ -1,8 +1,7 @@
-
+
%1$s: %2$s
%1$s nosūtīja attēlu.
-
%s\'s uzaicinājums
%1$s uzaicināja %2$s
%1$s uzaicināja tevi
@@ -30,46 +29,56 @@
ikviens.
nezināms (%s).
%1$s ieslēdza ierīce-ierīce šifrēšanu (%2$s)
-
%1$s vēlas VoIP konferenci
VoIP konference sākusies
VoIP konference ir beigusies
-
(arī profila attēls mainījās)
%1$s dzēsa istabas nosaukumu
%1$s dzēsa istabas tēmas nosaukumu
%1$s atjaunoja profila informāciju %2$s
%1$s nosūtīja uzaicinājumu %2$s pievienoties istabai
%1$s apstiprināja uzaicinājumu priekš %2$s
-
** Nav iespējams atkodēt: %s **
Sūtītāja ierīce mums nenosūtīja atslēgas priekš šīs ziņas.
-
Nevarēja rediģēt
Nav iespējams nosūtīt ziņu
-
Neizdevās augšuplādēt attēlu
-
Tīkla kļūda
Matrix kļūda
-
Šobrīd nav iespējams atkārtoti pievienoties tukšai istabai.
-
Šifrēta ziņa
-
Epasta adrese
Telefona numurs
-
Uzaicinājums no %s
Uzaicinājums uz istabu
%1$s un %2$s
Tukša istaba
-