Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 184 additions & 113 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.8.3"
edition = "2021"

[dependencies]
adw = { package = "libadwaita", version = "0.2.1", features = ["v1_2"] }
adw = { package = "libadwaita", version = "0.4.4", features = ["v1_4"] }
base64 = "0.20.0"
blocking = "1.6.1"
clap = { version = "4.5.7", features = ["derive", "env"] }
Expand Down
4 changes: 2 additions & 2 deletions src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ pub fn launch(app: &Application, background: bool) {
update_error_list();
sections.set_visible_child_name(&stack_child_name);
}));
sync_status_sections.add_controller(&gesture);
sync_status_sections.add_controller(gesture);

// Add the items to the directory map.
let sync_status_sections_container = ListBoxRow::builder().child(&sync_status_sections).build();
Expand Down Expand Up @@ -1547,7 +1547,7 @@ pub fn launch(app: &Application, background: bool) {
}
}
}));
ui_item.add_controller(&gesture);
ui_item.add_controller(gesture);

// If we have zero errors now, remove the warning icon.
if sync_errors_count() == 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/login/dropbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
login::gdrive::{AuthType, GDriveConfig},
mpsc::Sender,
};
use adw::{gtk::Button, ApplicationWindow, EntryRow};
use adw::{gtk::{Button, Widget}, ApplicationWindow};

static DEFAULT_CLIENT_ID: &str = "hke0fgr43viaq03";
static DEFAULT_CLIENT_SECRET: &str = "o4cpx8trcnneq7a";
Expand All @@ -21,7 +21,7 @@ impl super::LoginTrait for DropboxConfig {
fn get_sections(
window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
GDriveConfig::auth_sections(
window,
sender,
Expand Down
31 changes: 18 additions & 13 deletions src/login/gdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
traits::prelude::*,
util,
};
use adw::{glib, gtk::Button, prelude::*, ApplicationWindow, EntryRow, MessageDialog};
use adw::{glib, gtk::Button, gtk::Widget, prelude::*, ApplicationWindow, MessageDialog, SwitchRow};
use nix::{
sys::signal::{self, Signal},
unistd::Pid,
Expand Down Expand Up @@ -96,7 +96,7 @@ impl super::LoginTrait for GDriveConfig {
fn get_sections(
window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
Self::auth_sections(
window,
sender,
Expand All @@ -113,15 +113,19 @@ impl GDriveConfig {
sender: Sender<Option<ServerType>>,
auth_type: AuthType,
client_id: String,
client_secret: String,
) -> (Vec<EntryRow>, Button) {
let mut sections: Vec<EntryRow> = vec![];
client_secret: String
) -> (Vec<Widget>, Button) {
let mut sections: Vec<Widget> = vec![];
let server_name = login_util::server_name_input();
let in_europe = SwitchRow::builder().title(&tr::tr!("European server")).active(false).build();
if matches!(auth_type, AuthType::PCloud) {
sections.push(in_europe.clone().into());
}
let submit_button = login_util::submit_button();

sections.push(server_name.clone());
sections.push(server_name.clone().into());

submit_button.connect_clicked(glib::clone!(@weak window, @weak server_name, @strong client_id, @strong client_secret => move |_| {
submit_button.connect_clicked(glib::clone!(@weak window, @weak server_name, @weak in_europe, @strong client_id, @strong client_secret => move |_| {
window.set_sensitive(false);

// For some reason we get compiler errors without these two lines :P.
Expand Down Expand Up @@ -249,10 +253,8 @@ impl GDriveConfig {
window.set_sensitive(true);
break;
} else {
let auth_token = {
let lines: Vec<String> = process_stdout.lock().unwrap().lines().map(|string| string.to_owned()).collect();
lines.get(lines.len() - 2).unwrap().to_owned()
};
let lines: Vec<String> = process_stdout.lock().unwrap().lines().map(|string| string.to_owned()).collect();
let auth_token = lines.get(lines.len() - 2).unwrap().to_owned();

let server_type = match auth_type {
AuthType::GDrive => ServerType::GDrive(GDriveConfig {
Expand All @@ -267,12 +269,15 @@ impl GDriveConfig {
client_secret,
auth_json: auth_token
}),
AuthType::PCloud => ServerType::PCloud(pcloud::PCloudConfig {
AuthType::PCloud => {
ServerType::PCloud(pcloud::PCloudConfig {
server_name: server_name.text().to_string(),
// hostname: ,
hostname: if in_europe.is_active() {"eapi.pcloud.com".to_string()} else {"api.pcloud.com".to_string()},
client_id,
client_secret,
auth_json: auth_token
}),
})},
};
sender.send(Some(server_type));
window.set_sensitive(true);
Expand Down
11 changes: 6 additions & 5 deletions src/login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ mod webdav;

use adw::{
glib,
gtk::{Box, Button, Inhibit, ListBox, Orientation, SelectionMode, StringList},
gtk::{Box, Button, Inhibit, ListBox, Orientation, SelectionMode, StringList, Widget},
prelude::*,
Application, ApplicationWindow, ComboRow, EntryRow, HeaderBar,
Application, ApplicationWindow, ComboRow, HeaderBar,
};
use dropbox::DropboxConfig;
use gdrive::GDriveConfig;
Expand All @@ -39,7 +39,7 @@ trait LoginTrait {
fn get_sections(
window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button);
) -> (Vec<Widget>, Button);
}

/// An enum representing valid storage types.
Expand Down Expand Up @@ -158,7 +158,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
let webdav_items = WebDavConfig::get_sections(&window, sender);

// Store the active items.
let active_items: Rc<RefCell<(Vec<EntryRow>, Button)>> =
let active_items: Rc<RefCell<(Vec<Widget>, Button)>> =
Rc::new(RefCell::new((vec![], submit_button)));

// Configure the window to change the widgets when the selected server type
Expand All @@ -184,7 +184,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
// Now remove the current listbox items.
for row in ptr.0.clone() {
// Reset the row to default styling and text so that when the user goes back it looks like a fresh page.
row.set_text("");
// row.set_text("");
row.remove_css_class("error");

// Actually remove the item.
Expand Down Expand Up @@ -278,6 +278,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
ServerType::PCloud(config) => json!({
"name": config_name,
"parameters": {
"hostname": config.hostname,
"client_id": config.client_id,
"client_secret": config.client_secret,
"token": config.auth_json,
Expand Down
4 changes: 2 additions & 2 deletions src/login/nextcloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
ServerType,
};
use crate::mpsc::Sender;
use adw::{gtk::Button, ApplicationWindow, EntryRow};
use adw::{gtk::{Button, Widget}, ApplicationWindow};

#[derive(Clone, Debug, Default)]
pub struct NextcloudConfig {
Expand All @@ -18,7 +18,7 @@ impl super::LoginTrait for NextcloudConfig {
fn get_sections(
_window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
WebDavConfig::webdav_sections(sender, WebDavType::Nextcloud)
}
}
4 changes: 2 additions & 2 deletions src/login/owncloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
ServerType,
};
use crate::mpsc::Sender;
use adw::{gtk::Button, ApplicationWindow, EntryRow};
use adw::{gtk::{Button, Widget}, ApplicationWindow};

#[derive(Clone, Debug, Default)]
pub struct OwncloudConfig {
Expand All @@ -18,7 +18,7 @@ impl super::LoginTrait for OwncloudConfig {
fn get_sections(
_window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
WebDavConfig::webdav_sections(sender, WebDavType::Owncloud)
}
}
5 changes: 3 additions & 2 deletions src/login/pcloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
login::gdrive::{AuthType, GDriveConfig},
mpsc::Sender,
};
use adw::{gtk::Button, ApplicationWindow, EntryRow};
use adw::{gtk::{Button, Widget}, ApplicationWindow};

static DEFAULT_CLIENT_ID: &str = "KRzpo46NKb7";
static DEFAULT_CLIENT_SECRET: &str = "g10qvqgWR85lSvEQWlIqCmPYIhwX";
Expand All @@ -14,14 +14,15 @@ pub struct PCloudConfig {
pub server_name: String,
pub client_id: String,
pub client_secret: String,
pub hostname: String,
pub auth_json: String,
}

impl super::LoginTrait for PCloudConfig {
fn get_sections(
window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
GDriveConfig::auth_sections(
window,
sender,
Expand Down
10 changes: 5 additions & 5 deletions src/login/proton_drive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The data for a Proton Drive Rclone config.
use super::ServerType;
use crate::{login::login_util, mpsc::Sender};
use adw::{glib, gtk::Button, prelude::*, ApplicationWindow, EntryRow};
use adw::{glib, gtk::{Button, Widget}, prelude::*, ApplicationWindow};

#[derive(Clone, Debug, Default)]
pub struct ProtonDriveConfig {
Expand All @@ -15,18 +15,18 @@ impl super::LoginTrait for ProtonDriveConfig {
fn get_sections(
_window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
let mut sections = vec![];
let server_name = login_util::server_name_input();
let username = login_util::username_input();
let password = login_util::password_input();
let totp = login_util::totp_input();
let submit_button = login_util::submit_button();

sections.push(server_name.clone());
sections.push(username.clone());
sections.push(server_name.clone().into());
sections.push(username.clone().into());
sections.push(password.clone().into());
sections.push(totp.clone());
sections.push(totp.clone().into());

submit_button.connect_clicked(
glib::clone!(@weak server_name, @weak username, @weak password, @weak totp => move |_| {
Expand Down
16 changes: 8 additions & 8 deletions src/login/webdav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use super::{login_util, nextcloud::NextcloudConfig, owncloud::OwncloudConfig, ServerType};
use crate::mpsc::Sender;
use adw::{
gtk::{glib, Button},
gtk::{glib, Button, Widget},
prelude::*,
ApplicationWindow, EntryRow,
ApplicationWindow,
};

pub enum WebDavType {
Expand All @@ -25,7 +25,7 @@ impl super::LoginTrait for WebDavConfig {
fn get_sections(
_window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
) -> (Vec<Widget>, Button) {
Self::webdav_sections(sender, WebDavType::WebDav)
}
}
Expand All @@ -34,8 +34,8 @@ impl WebDavConfig {
pub fn webdav_sections(
sender: Sender<Option<ServerType>>,
webdav_type: WebDavType,
) -> (Vec<EntryRow>, Button) {
let mut sections: Vec<EntryRow> = vec![];
) -> (Vec<Widget>, Button) {
let mut sections: Vec<Widget> = vec![];

let server_name = login_util::server_name_input();
let server_url = login_util::server_url_input(match webdav_type {
Expand All @@ -46,9 +46,9 @@ impl WebDavConfig {
let password = login_util::password_input();
let submit_button = login_util::submit_button();

sections.push(server_name.clone());
sections.push(server_url.clone());
sections.push(username.clone());
sections.push(server_name.clone().into());
sections.push(server_url.clone().into());
sections.push(username.clone().into());
sections.push(password.clone().into());

submit_button.connect_clicked(
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![feature(let_chains)]
#![feature(arc_unwrap_or_clone)]
#![feature(panic_info_message)]
#![feature(async_closure)]
#![feature(trait_alias)]
#![feature(exit_status_error)]

Expand Down Expand Up @@ -63,7 +60,7 @@ fn main() {

// Load our CSS.
let provider = CssProvider::new();
provider.load_from_data(include_bytes!(concat!(env!("OUT_DIR"), "/style.css")));
provider.load_from_path(concat!(env!("OUT_DIR"), "/style.css"));

StyleContext::add_provider_for_display(
&Display::default().unwrap(),
Expand Down
3 changes: 3 additions & 0 deletions src/rclone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn get_remote<T: ToString>(remote: T) -> Option<Remote> {
})),
"pcloud" => Some(Remote::PCloud(PCloudRemote {
remote_name: remote,
hostname: config["hostname"].clone(),
client_id: config["client_id"].clone(),
client_secret: config["client_secret"].clone(),
})),
Expand Down Expand Up @@ -125,6 +126,8 @@ pub struct GDriveRemote {
pub struct PCloudRemote {
/// The name of the remote.
pub remote_name: String,
/// The API server to connect to (NA or EU)
pub hostname: String,
/// The client id.
pub client_id: String,
/// The client secret.
Expand Down