use std::borrow::Cow; use std::error::Error; use reqwest::Url; use slint::run_event_loop; use winit::application::ApplicationHandler; use winit::event::WindowEvent; use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop}; use winit::window::{Window, WindowAttributes, WindowId}; use wry::http::{Response, StatusCode}; use wry::WebViewBuilder; slint::slint! { export component HelloWorld inherits Window { } } struct Application { window: Option } impl ApplicationHandler for Application { fn resumed(&mut self, event_loop: &ActiveEventLoop) { let win = event_loop.create_window(WindowAttributes::default()).unwrap(); win.set_visible(true); self.window = Some(win); } fn window_event(&mut self, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent) { match event { WindowEvent::CloseRequested => { event_loop.exit(); } WindowEvent::RedrawRequested => { if let Some(ref window) = self.window { window.request_redraw(); } } _ => { } } } } fn main() -> Result<(), Box> { simple_logger::SimpleLogger::new().env().init().unwrap(); gtk::init()?; let hw = HelloWorld::new().unwrap(); let wv = WebViewBuilder::new() .with_url("https://login.live.com/oauth20_authorize.srf?client_id=00000000402b5328&redirect_uri=ms-xal-00000000402b5328://auth&response_type=token&display=touch&scope=service::user.auth.xboxlive.com::MBI_SSL%20offline_access&prompt=select_account") .with_navigation_handler(|url| { let mut url = match reqwest::Url::parse(url.as_str()) { Ok(url) => url, Err(_) => return true }; if url.scheme() == "ms-xal-00000000402b5328" { let fragment = url.fragment().map(|s| s.to_owned()); url.set_query(fragment.as_ref().map(|s| s.as_str())); url.query_pairs().inspect(|p| println!("{:?}", p)).for_each(drop); dbg!(url); return false; } true }).build_as_child(&hw.window().window_handle()).unwrap(); wv.set_visible(true).unwrap(); hw.run().unwrap(); Ok(()) }