|
@@ -1,5 +1,6 @@
|
|
|
use cli_clipboard::ClipboardProvider as _;
|
|
use cli_clipboard::ClipboardProvider as _;
|
|
|
use client_shared::message::{self, MessageSanitized};
|
|
use client_shared::message::{self, MessageSanitized};
|
|
|
|
|
+use client_shared::utils::ConnectionError;
|
|
|
use client_shared::{DEFAULT_PASSWORD, MAX_MESSAGE_LENGTH, MAX_USERNAME_LENGTH};
|
|
use client_shared::{DEFAULT_PASSWORD, MAX_MESSAGE_LENGTH, MAX_USERNAME_LENGTH};
|
|
|
use client_shared::ui::Language;
|
|
use client_shared::ui::Language;
|
|
|
use cursive::view::{Nameable as _, Resizable as _};
|
|
use cursive::view::{Nameable as _, Resizable as _};
|
|
@@ -10,7 +11,7 @@ use cursive::views::{
|
|
|
use cursive::{event, Cursive};
|
|
use cursive::{event, Cursive};
|
|
|
use utils::hash::Hashable as _;
|
|
use utils::hash::Hashable as _;
|
|
|
|
|
|
|
|
-use crate::actions::{self, NetworkError};
|
|
|
|
|
|
|
+use crate::actions;
|
|
|
use crate::{
|
|
use crate::{
|
|
|
get_appdata, save_appdata, Appdata
|
|
get_appdata, save_appdata, Appdata
|
|
|
};
|
|
};
|
|
@@ -69,8 +70,8 @@ pub enum Labels {
|
|
|
InvalidMessage,
|
|
InvalidMessage,
|
|
|
Success,
|
|
Success,
|
|
|
SuccessfullySentMessage,
|
|
SuccessfullySentMessage,
|
|
|
- FailedToSendMessage(NetworkError),
|
|
|
|
|
- FailedToLoadMessages(NetworkError),
|
|
|
|
|
|
|
+ FailedToSendMessage(ConnectionError),
|
|
|
|
|
+ FailedToLoadMessages(ConnectionError),
|
|
|
RefreshButton,
|
|
RefreshButton,
|
|
|
BlockedWords,
|
|
BlockedWords,
|
|
|
ServerSettings,
|
|
ServerSettings,
|
|
@@ -117,14 +118,14 @@ impl Labels {
|
|
|
let reason_buf: [String; 3];
|
|
let reason_buf: [String; 3];
|
|
|
|
|
|
|
|
match e {
|
|
match e {
|
|
|
- NetworkError::ReqwestError(_) => {
|
|
|
|
|
|
|
+ ConnectionError::ReqwestError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Connection error.".to_string(),
|
|
"Connection error.".to_string(),
|
|
|
"Verbindingsfout.".to_string(),
|
|
"Verbindingsfout.".to_string(),
|
|
|
"接続エラー。".to_string(),
|
|
"接続エラー。".to_string(),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::StatusCodeError(code) => {
|
|
|
|
|
|
|
+ ConnectionError::StatusCodeError(code) => {
|
|
|
// NOTE: Needs to match the server
|
|
// NOTE: Needs to match the server
|
|
|
if *code == 400 {
|
|
if *code == 400 {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
@@ -140,20 +141,21 @@ impl Labels {
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- NetworkError::UrlError(_) => {
|
|
|
|
|
|
|
+ ConnectionError::UrlError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Invalid URL.".to_string(),
|
|
"Invalid URL.".to_string(),
|
|
|
"Ongeldig URL.".to_string(),
|
|
"Ongeldig URL.".to_string(),
|
|
|
"無効なURL。".to_string(),
|
|
"無効なURL。".to_string(),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::EncryptionError(_) => {
|
|
|
|
|
- reason_buf = [
|
|
|
|
|
- "Encryption error.".to_string(),
|
|
|
|
|
- "Encryptiefout.".to_string(),
|
|
|
|
|
- "暗号化エラー。".to_string(),
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // TODO: Check if it's safe to remove this.
|
|
|
|
|
+ // ConnectionError::EncryptionError(_) => {
|
|
|
|
|
+ // reason_buf = [
|
|
|
|
|
+ // "Encryption error.".to_string(),
|
|
|
|
|
+ // "Encryptiefout.".to_string(),
|
|
|
|
|
+ // "暗号化エラー。".to_string(),
|
|
|
|
|
+ // ];
|
|
|
|
|
+ // }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
buf = [
|
|
buf = [
|
|
@@ -168,34 +170,35 @@ impl Labels {
|
|
|
let reason_buf: [String; 3];
|
|
let reason_buf: [String; 3];
|
|
|
|
|
|
|
|
match error {
|
|
match error {
|
|
|
- NetworkError::ReqwestError(_) => {
|
|
|
|
|
|
|
+ ConnectionError::ReqwestError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Connection error.".to_string(),
|
|
"Connection error.".to_string(),
|
|
|
"Verbindingsfout.".to_string(),
|
|
"Verbindingsfout.".to_string(),
|
|
|
"接続エラー。".to_string(),
|
|
"接続エラー。".to_string(),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::StatusCodeError(code) => {
|
|
|
|
|
|
|
+ ConnectionError::StatusCodeError(code) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
format!("Status code: {code}"),
|
|
format!("Status code: {code}"),
|
|
|
format!("Statuscode: {code}"),
|
|
format!("Statuscode: {code}"),
|
|
|
format!("ステータスコード: {code}"),
|
|
format!("ステータスコード: {code}"),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::UrlError(_) => {
|
|
|
|
|
|
|
+ ConnectionError::UrlError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Invalid URL.".to_string(),
|
|
"Invalid URL.".to_string(),
|
|
|
"Ongeldig URL.".to_string(),
|
|
"Ongeldig URL.".to_string(),
|
|
|
"無効なURL。".to_string(),
|
|
"無効なURL。".to_string(),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::EncryptionError(_) => {
|
|
|
|
|
- reason_buf = [
|
|
|
|
|
- "Decryption error.".to_string(),
|
|
|
|
|
- "Fout bij het ontcijferen.".to_string(),
|
|
|
|
|
- "復号エラー".to_string(),
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // TODO: Check if it's safe to remove this.
|
|
|
|
|
+ // ConnectionError::EncryptionError(_) => {
|
|
|
|
|
+ // reason_buf = [
|
|
|
|
|
+ // "Decryption error.".to_string(),
|
|
|
|
|
+ // "Fout bij het ontcijferen.".to_string(),
|
|
|
|
|
+ // "復号エラー".to_string(),
|
|
|
|
|
+ // ];
|
|
|
|
|
+ // }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
buf = [
|
|
buf = [
|