From d9a7369df8cfb7a29dd6a68359e66056337945d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Fri, 11 Aug 2017 21:46:50 +0200 Subject: [PATCH] Connecting as guess in the first run --- src/app.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index ab937dc6..2395aa86 100644 --- a/src/app.rs +++ b/src/app.rs @@ -57,6 +57,24 @@ impl AppLogic { Err(error) => println!("{:?}", error) } } + + pub fn connect_guest(&mut self, server: Option) { + let server_url = match server { + Some(s) => s, + None => String::from("https://matrix.org") + }; + + let res = self.command_chan_tx + .send(Command::Connect { + homeserver_url: Url::parse(&server_url).unwrap(), + connection_method: ConnectionMethod::Guest + }); + + match res { + Ok(_) => {}, + Err(error) => println!("{:?}", error) + } + } } /// State for the main thread. @@ -155,8 +173,9 @@ impl App { let args = env::args().collect::>(); let args_refs = args.iter().map(|x| &x[..]).collect::>(); - // TODO: connect as guess user or use stored data - //self.logic.lock().unwrap().connect(String::from("TODO"), String::from("TODO"), None); + // connecting as guest + // TODO: Use stored user if exists + self.logic.lock().unwrap().connect_guest(None); // Poll the matrix communication thread channel and run the closures to allow // the threads to run actions in the main loop.