Commit 1fec2e5a authored by Julian Sparber's avatar Julian Sparber

login: use global constant for homeserver and identity server

parent ee1ad9c4
Pipeline #13082 passed with stages
in 18 minutes and 2 seconds
......@@ -825,7 +825,7 @@
<property name="width_request">330</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text">https://matrix.org</property>
<property name="text"></property>
<property name="placeholder_text" translatable="yes">Matrix Server</property>
<property name="input_purpose">url</property>
<accessibility>
......@@ -844,7 +844,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">6</property>
<property name="text">https://vector.im</property>
<property name="text"></property>
<property name="placeholder_text" translatable="yes">Identity server</property>
<property name="input_purpose">url</property>
<accessibility>
......
extern crate gtk;
extern crate gettextrs;
use globals;
use self::gtk::prelude::*;
use self::gettextrs::gettext;
......@@ -82,8 +83,8 @@ impl AppOp {
user_entry.set_text("");
pass_entry.set_text("");
server_entry.set_text("https://matrix.org");
idp_entry.set_text("https://vector.im");
server_entry.set_text(globals::DEFAULT_HOMESERVER);
idp_entry.set_text(globals::DEFAULT_IDENTITYSERVER);
}
pub fn login(&mut self) {
......@@ -183,7 +184,7 @@ impl AppOp {
self.server_url = match server_entry.get_text() {
Some(s) => s,
None => String::from("https://matrix.org"),
None => String::from(globals::DEFAULT_HOMESERVER),
};
/* FIXME ask also for the identity server */
......@@ -202,12 +203,12 @@ impl AppOp {
pub fn connect(&mut self, username: Option<String>, password: Option<String>, server: Option<String>, identity: Option<String>) -> Option<()> {
self.server_url = match server {
Some(s) => s,
None => String::from("https://matrix.org"),
None => String::from(globals::DEFAULT_HOMESERVER),
};
self.identity_url = match identity {
Some(u) => u,
None => String::from("https://vector.im"),
None => String::from(globals::DEFAULT_IDENTITYSERVER),
};
self.store_pass(username.clone()?, password.clone()?, self.server_url.clone(), self.identity_url.clone())
......@@ -226,7 +227,7 @@ impl AppOp {
pub fn set_token(&mut self, token: Option<String>, uid: Option<String>, server: Option<String>) -> Option<()> {
self.server_url = match server {
Some(s) => s,
None => String::from("https://matrix.org"),
None => String::from(globals::DEFAULT_HOMESERVER),
};
let ser = self.server_url.clone();
......@@ -238,7 +239,7 @@ impl AppOp {
pub fn connect_guest(&mut self, server: Option<String>) {
self.server_url = match server {
Some(s) => s,
None => String::from("https://matrix.org"),
None => String::from(globals::DEFAULT_HOMESERVER),
};
self.backend.send(BKCommand::Guest(self.server_url.clone())).unwrap();
......
......@@ -8,6 +8,7 @@ use gio::ApplicationExt;
use self::gtk::prelude::*;
use self::gettextrs::gettext;
use globals;
use backend::BKCommand;
use backend;
......@@ -115,8 +116,8 @@ impl AppOp {
username: None,
uid: None,
avatar: None,
server_url: String::from("https://matrix.org"),
identity_url: String::from("https://vector.im"),
server_url: String::from(globals::DEFAULT_HOMESERVER),
identity_url: String::from(globals::DEFAULT_IDENTITYSERVER),
syncing: false,
tmp_msgs: vec![],
shown_messages: 0,
......
......@@ -20,7 +20,10 @@ impl AppOp {
self.state = state;
let widget_name = match self.state {
AppState::Login => "login",
AppState::Login => {
self.clean_login();
"login"
},
AppState::Chat => "chat",
AppState::Directory => "directory",
AppState::Loading => "loading",
......
......@@ -4,6 +4,8 @@ pub static MSG_ICON_SIZE: i32 = 40;
pub static USERLIST_ICON_SIZE: i32 = 30;
pub static MINUTES_TO_SPLIT_MSGS: i64 = 30;
pub static APP_ID: &'static str = "org.gnome.Fractal";
pub static DEFAULT_HOMESERVER: &'static str = "https://matrix.org";
pub static DEFAULT_IDENTITYSERVER: &'static str = "https://vector.im";
include!(concat!(env!("OUT_DIR"), "/build_globals.rs"));
......@@ -6,7 +6,6 @@ use gio::SettingsExt;
use std;
#[derive(Debug)]
pub enum Error {
SecretServiceError,
......@@ -82,6 +81,8 @@ mod ss_storage {
use super::secret_service::SecretService;
use super::secret_service::EncryptionType;
use globals;
pub fn delete_pass(key: &str) -> Result<(), Error> {
let ss = SecretService::new(EncryptionType::Dh)?;
let collection = ss.get_default_collection()?;
......@@ -205,9 +206,8 @@ mod ss_storage {
for p in passwd {
p.delete()?;
}
/* It wasn't possibile to have a different identity server therefore set it always to
* vector.im */
let identity = String::from("https://vector.im");
/* Fallback to default identity server if there is none */
let identity = String::from(globals::DEFAULT_IDENTITYSERVER);
store_pass(username, pwd, server, identity)?;
......@@ -254,7 +254,7 @@ mod ss_storage {
let identity = match attr {
Some(a) => a.1.clone(),
None => {
String::from("https://vector.im")
String::from(globals::DEFAULT_IDENTITYSERVER)
},
};
......
......@@ -13,6 +13,7 @@ use std::collections::HashMap;
use self::gtk::prelude::*;
use self::gettextrs::gettext;
use globals;
use widgets::roomrow::RoomRow;
use types::Room;
use types::Message;
......@@ -22,7 +23,7 @@ use self::chrono::prelude::*;
fn get_url(url: Option<String>) -> Url {
let defurl = Url::parse("https://matrix.org").unwrap();
let defurl = Url::parse(globals::DEFAULT_HOMESERVER).unwrap();
match url {
Some(u) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment