You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
gui/src/main.rs

78 lines
2.5 KiB

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// hide console window on Windows in release
#[allow(dead_code)]
pub use crate::player::Player;
pub use crate::app::App;
use libtor::{Tor, TorFlag, Error as libtorError, log as libtorLog};
#[allow(unused_imports)]
use rodio::{Decoder, OutputStream, source::Source, Sink};
mod app;
mod player;
mod irc;
// "http://wowradiod6mhb4ignjqy5ghf5l42yh2yeumgeq3yi7gn7yqy3efhe5ad.onion"
// "http://wowradiof5wx62w4avdk5fwbvcoea2z4ul2q3awffn5vmfaa3vhlgiid.onion"
// "http://radio.poysibicsj73uhw7sjrv3fyopoyulrns4nlr5amyqdtafkqzlocd4qad.onion"
// "http://anonyradixhkgh5myfrkarggfnmdzzhhcgoy2v66uf7sml27to5n2tid.onion"
// "http://u2frppcgwqmoca7h3hu5l72upkwhcf2n6umrkqsnvnpahjynkre6sqyd.onion:8300/radio"
// "https://radio.wownero.com/wow.ogg"
pub const TOR_DATA: &str = &"/tmp/tor-rust";
pub const TOR_LOG: &str = &"/tmp/tor-rust/tor.log";
pub const RADIO_STREAM: &str = &"radio.ogg";
pub const IRC_LOG: &str = &"irc.log";
pub const IRC_CONFIG: &str = &"config.toml";
fn cleanup() {
let _ = std::fs::remove_file(&RADIO_STREAM);
let _ = std::fs::remove_file(&IRC_LOG);
()
}
fn start_tor() -> Result<u8, libtorError> {
let t = Tor::new()
.flag(TorFlag::DataDirectory(TOR_DATA.to_owned()))
.flag(TorFlag::SocksPort(19050))
.flag(TorFlag::LogTo(libtorLog::LogLevel::Info, libtorLog::LogDestination::File(TOR_LOG.to_string())))
.start();
return t
}
fn clear_tor_log() -> std::io::Result<()> {
let r: std::io::Result<()> = std::fs::write(TOR_LOG, "");
return r
}
// fn get_wow_price() -> String {
// let url: &str = "https://tradeogre.com/api/v1/ticker/BTC-WOW";
// let client: reqwest::blocking::Client = reqwest::blocking::ClientBuilder::new()
// .timeout(time::Duration::from_secs(10))
// .build()
// .unwrap();
// let res: String = client.get(url)
// .send()
// .unwrap()
// .text()
// .unwrap();
// return res
// }
#[tokio::main(flavor = "current_thread")]
async fn main() {
let (_stream, stream_handle) = rodio::OutputStream::try_default().unwrap();
let sink: rodio::Sink = rodio::Sink::try_new(&stream_handle).unwrap();
let player: player::Player = player::Player::new(sink, stream_handle);
let mut app: app::App = app::App::default();
app.player = player;
let options: eframe::NativeOptions = eframe::NativeOptions::default();
eframe::run_native(
"lza gui",
options,
Box::new(|_cc| Box::new(app)),
);
let _ = cleanup();
}