diff options
| author | 2025-01-29 23:16:45 -0600 | |
|---|---|---|
| committer | 2025-01-29 23:16:45 -0600 | |
| commit | 35235e4a7ac90f4cdcdf753befb1aff516320eb4 (patch) | |
| tree | af53499a61bb41a8705073d30acdf8dbde2c120a /ozone-ui/src | |
| parent | do device code auth (diff) | |
wip: use an actual oauth library
Diffstat (limited to 'ozone-ui/src')
| -rw-r--r-- | ozone-ui/src/main.rs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/ozone-ui/src/main.rs b/ozone-ui/src/main.rs index 43a9c42..25ba7f3 100644 --- a/ozone-ui/src/main.rs +++ b/ozone-ui/src/main.rs @@ -1,13 +1,4 @@ -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 { @@ -15,60 +6,8 @@ slint::slint! { } } -struct Application { - window: Option<Window> -} - -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<dyn Error>> { 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(()) } |
