diff --git a/Cargo.toml b/Cargo.toml index eca3aa0f..0b3ecba1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Daniel Garcia "] -name = "guillotine" +name = "fractal" version = "0.1.0" [dependencies] diff --git a/README.md b/README.md index 1662cf25..8629de8e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -Guillotine -========== +Fractal +======= This project is based on ruma-gtk https://github.com/jplatte/ruma-gtk -Instead of using RUMA Client, Guillotine calls directly to the matrix.org +Instead of using RUMA Client, Fractal calls directly to the matrix.org REST API. ![screenshot](https://raw.githubusercontent.com/danigm/guillotine/master/screenshots/guillotine.png) diff --git a/guillotine.doap b/fractal.doap similarity index 93% rename from guillotine.doap rename to fractal.doap index 10d0e11c..869990f5 100644 --- a/guillotine.doap +++ b/fractal.doap @@ -4,7 +4,7 @@ xmlns:gnome="http://api.gnome.org/doap-extensions#" xmlns="http://usefulinc.com/ns/doap#"> - Guillotine + Fractal Matrix.org Gtk+ client Matrix.org Gtk+ client Rust diff --git a/src/app.rs b/src/app.rs index d40e5d11..406f9d47 100644 --- a/src/app.rs +++ b/src/app.rs @@ -46,7 +46,7 @@ derror!(secret_service::SsError, Error::SecretServiceError); // TODO: Is this the correct format for GApplication IDs? -const APP_ID: &'static str = "org.gnome.guillotine"; +const APP_ID: &'static str = "org.gnome.Fractal"; struct TmpMsg { @@ -257,14 +257,14 @@ impl AppOp { // deleting previous items let allpass = collection.get_all_items()?; let passwds = allpass.iter() - .filter(|x| x.get_label().unwrap_or(String::from("")) == "guillotine"); + .filter(|x| x.get_label().unwrap_or(strn!("")) == "fractal"); for p in passwds { p.delete()?; } // create new item collection.create_item( - "guillotine", // label + "fractal", // label vec![ ("username", &username), ("server", &server), @@ -277,13 +277,52 @@ impl AppOp { Ok(()) } + pub fn migrate_old_passwd(&self) -> Result<(), Error> { + let ss = SecretService::new(EncryptionType::Dh)?; + let collection = ss.get_default_collection()?; + let allpass = collection.get_all_items()?; + + // old name password + let passwd = allpass.iter() + .find(|x| x.get_label().unwrap_or(strn!("")) == "guillotine"); + + if passwd.is_none() { + return Ok(()); + } + + let p = passwd.unwrap(); + let attrs = p.get_attributes()?; + let secret = p.get_secret()?; + + let mut attr = attrs.iter() + .find(|&ref x| x.0 == "username") + .ok_or(Error::SecretServiceError)?; + let username = attr.1.clone(); + attr = attrs.iter() + .find(|&ref x| x.0 == "server") + .ok_or(Error::SecretServiceError)?; + let server = attr.1.clone(); + let pwd = String::from_utf8(secret).unwrap(); + + // removing old + for p in passwd { + p.delete()?; + } + + self.store_pass(username, pwd, server)?; + + Ok(()) + } + pub fn get_pass(&self) -> Result<(String, String, String), Error> { + self.migrate_old_passwd()?; + let ss = SecretService::new(EncryptionType::Dh)?; let collection = ss.get_default_collection()?; let allpass = collection.get_all_items()?; let passwd = allpass.iter() - .find(|x| x.get_label().unwrap_or(String::from("")) == "guillotine"); + .find(|x| x.get_label().unwrap_or(strn!("")) == "fractal"); if passwd.is_none() { return Err(Error::SecretServiceError); @@ -1248,7 +1287,7 @@ impl App { .get_object("main_window") .expect("Couldn't find main_window in ui file."); - window.set_title("Guillotine"); + window.set_title("Fractal"); let _ = window.set_icon_from_file("res/icon.svg"); window.show_all(); @@ -1549,12 +1588,12 @@ impl App { pub fn run(self) { self.op.lock().unwrap().init(); - if let Err(err) = libnotify::init("guillotine") { + if let Err(err) = libnotify::init("fractal") { println!("Error: can't init notifications: {}", err); }; - glib::set_application_name("guillotine"); - glib::set_prgname(Some("guillotine")); + glib::set_application_name("fractal"); + glib::set_prgname(Some("fractal")); let provider = gtk::CssProvider::new(); let uri = "res/app.css"; diff --git a/src/util.rs b/src/util.rs index 944fd892..dd53c1ab 100644 --- a/src/util.rs +++ b/src/util.rs @@ -304,7 +304,7 @@ pub fn dw_media(base: &Url, w: i32, h: i32) -> Result { - let xdg_dirs = xdg::BaseDirectories::with_prefix("guillotine").unwrap(); + let xdg_dirs = xdg::BaseDirectories::with_prefix("fractal").unwrap(); let re = Regex::new(r"mxc://(?P[^/]+)/(?P.+)")?; let caps = re.captures(url).ok_or(Error::BackendError)?; @@ -457,7 +457,7 @@ pub fn draw_identicon(fname: &str, name: String) -> Result { Color { r: 241, g: 185, b: 29, }, ]; - let xdg_dirs = xdg::BaseDirectories::with_prefix("guillotine").unwrap(); + let xdg_dirs = xdg::BaseDirectories::with_prefix("fractal").unwrap(); let fname = String::from(xdg_dirs.place_cache_file(fname)?.to_str().ok_or(Error::BackendError)?);