mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
add after_login_hint, refine ffi
This commit is contained in:
@@ -3708,7 +3708,9 @@ dc_provider_t* dc_provider_new_from_email (const dc_context_t*, cons
|
|||||||
*
|
*
|
||||||
* @memberof dc_provider_t
|
* @memberof dc_provider_t
|
||||||
* @param provider The dc_provider_t struct.
|
* @param provider The dc_provider_t struct.
|
||||||
* @return A string which must be released using dc_str_unref().
|
* @return String with a fully-qualified URL,
|
||||||
|
* if there is no such URL, an empty string is returned, NULL is never returned.
|
||||||
|
* The returned value must be released using dc_str_unref().
|
||||||
*/
|
*/
|
||||||
char* dc_provider_get_overview_page (const dc_provider_t* provider);
|
char* dc_provider_get_overview_page (const dc_provider_t* provider);
|
||||||
|
|
||||||
@@ -3723,7 +3725,9 @@ char* dc_provider_get_overview_page (const dc_provider_t* prov
|
|||||||
*
|
*
|
||||||
* @memberof dc_provider_t
|
* @memberof dc_provider_t
|
||||||
* @param provider The dc_provider_t struct.
|
* @param provider The dc_provider_t struct.
|
||||||
* @return A string which must be released using dc_str_unref().
|
* @return A string with the hint to show to the user, may contain multiple lines,
|
||||||
|
* if there is no such hint, an empty string is returned, NULL is never returned.
|
||||||
|
* The returned value must be released using dc_str_unref().
|
||||||
*/
|
*/
|
||||||
char* dc_provider_get_before_login_hint (const dc_provider_t* provider);
|
char* dc_provider_get_before_login_hint (const dc_provider_t* provider);
|
||||||
|
|
||||||
|
|||||||
@@ -46,17 +46,18 @@ pub struct Provider {
|
|||||||
pub domains: &'static str,
|
pub domains: &'static str,
|
||||||
pub status: Status,
|
pub status: Status,
|
||||||
pub before_login_hint: &'static str,
|
pub before_login_hint: &'static str,
|
||||||
|
pub after_login_hint: &'static str,
|
||||||
pub overview_page: &'static str,
|
pub overview_page: &'static str,
|
||||||
pub server: Vec<Server>, // this seems to be okay
|
pub server: Vec<Server>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: the database will be auto-generated from the provider-db
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref DATABASE: Vec<Provider> = vec![
|
static ref DATABASE: Vec<Provider> = vec![
|
||||||
Provider {
|
Provider {
|
||||||
domains: "nauta.cu",
|
domains: "nauta.cu",
|
||||||
status: Status::OK,
|
status: Status::OK,
|
||||||
before_login_hint: "",
|
before_login_hint: "",
|
||||||
|
after_login_hint: "",
|
||||||
overview_page: "",
|
overview_page: "",
|
||||||
server: vec![
|
server: vec![
|
||||||
Server { protocol: IMAP, socket: STARTTLS, server: "imap.nauta.cu", port: 143, username_pattern: EMAIL },
|
Server { protocol: IMAP, socket: STARTTLS, server: "imap.nauta.cu", port: 143, username_pattern: EMAIL },
|
||||||
@@ -71,6 +72,7 @@ lazy_static::lazy_static! {
|
|||||||
Hopefully sooner or later there will be a fix; \
|
Hopefully sooner or later there will be a fix; \
|
||||||
for now, we suggest to use another e-mail-address \
|
for now, we suggest to use another e-mail-address \
|
||||||
or try Delta Chat again when the issue is fixed.",
|
or try Delta Chat again when the issue is fixed.",
|
||||||
|
after_login_hint: "",
|
||||||
overview_page: "https://provider.delta.chat/outlook.com",
|
overview_page: "https://provider.delta.chat/outlook.com",
|
||||||
server: vec![
|
server: vec![
|
||||||
],
|
],
|
||||||
@@ -82,6 +84,7 @@ lazy_static::lazy_static! {
|
|||||||
if you have \"2-Step Verification\" enabled. \
|
if you have \"2-Step Verification\" enabled. \
|
||||||
If this setting is not available, \
|
If this setting is not available, \
|
||||||
you need to enable \"Less secure apps\".",
|
you need to enable \"Less secure apps\".",
|
||||||
|
after_login_hint: "",
|
||||||
overview_page: "https://provider.delta.chat/gmail.com",
|
overview_page: "https://provider.delta.chat/gmail.com",
|
||||||
server: vec![
|
server: vec![
|
||||||
],
|
],
|
||||||
@@ -106,3 +109,28 @@ pub fn get_provider_info(addr: &str) -> Option<&Provider> {
|
|||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_provider_info() {
|
||||||
|
let provider = get_provider_info("user@unexistant.org");
|
||||||
|
assert!(provider.is_none());
|
||||||
|
|
||||||
|
let provider = get_provider_info("nauta.cu"); // this is no email address
|
||||||
|
assert!(provider.is_none());
|
||||||
|
|
||||||
|
let provider = get_provider_info("user@nauta.cu").unwrap();
|
||||||
|
assert!(provider.status == Status::OK);
|
||||||
|
|
||||||
|
let provider = get_provider_info("user@gmail.com").unwrap();
|
||||||
|
assert!(provider.status == Status::PREPARATION);
|
||||||
|
assert!(!provider.before_login_hint.is_empty());
|
||||||
|
assert!(!provider.overview_page.is_empty());
|
||||||
|
|
||||||
|
let provider = get_provider_info("user@googlemail.com").unwrap();
|
||||||
|
assert!(provider.status == Status::PREPARATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user