Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
Draft
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
11 changes: 10 additions & 1 deletion src/login/gdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::ServerType;
use crate::{
gtk_util,
login::{dropbox, login_util, pcloud},
login::{dropbox, login_util, onedrive, pcloud},
mpsc::Sender,
traits::prelude::*,
util,
Expand Down Expand Up @@ -33,6 +33,7 @@ static DEFAULT_CLIENT_SECRET: &str = "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";
pub enum AuthType {
Dropbox,
GDrive,
OneDrive,
PCloud,
}

Expand All @@ -44,6 +45,7 @@ impl fmt::Display for AuthType {
match self {
Self::Dropbox => "Dropbox",
Self::GDrive => "Google Drive",
Self::OneDrive => "OneDrive",
Self::PCloud => "pCloud",
}
)
Expand Down Expand Up @@ -133,6 +135,7 @@ impl GDriveConfig {
args.push(match auth_type {
AuthType::GDrive => "drive",
AuthType::Dropbox => "dropbox",
AuthType::OneDrive => "onedrive",
AuthType::PCloud => "pcloud",
});
args.push(&client_id);
Expand Down Expand Up @@ -261,6 +264,12 @@ impl GDriveConfig {
client_secret,
auth_json: auth_token
}),
AuthType::OneDrive => ServerType::OneDrive(onedrive::OneDriveConfig {
server_name: server_name.text().to_string(),
client_id,
client_secret,
auth_json: auth_token
}),
AuthType::PCloud => ServerType::PCloud(pcloud::PCloudConfig {
server_name: server_name.text().to_string(),
client_id,
Expand Down
19 changes: 19 additions & 0 deletions src/login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
util,
};
mod dropbox;
mod onedrive;
mod gdrive;
pub mod login_util;
mod nextcloud;
Expand All @@ -23,6 +24,7 @@ use adw::{
Application, ApplicationWindow, ComboRow, EntryRow, HeaderBar,
};
use dropbox::DropboxConfig;
use onedrive::OneDriveConfig;
use gdrive::GDriveConfig;
use nextcloud::NextcloudConfig;
use owncloud::OwncloudConfig;
Expand All @@ -48,6 +50,7 @@ pub enum ServerType {
Dropbox(dropbox::DropboxConfig),
GDrive(gdrive::GDriveConfig),
Nextcloud(nextcloud::NextcloudConfig),
OneDrive(onedrive::OneDriveConfig),
Owncloud(owncloud::OwncloudConfig),
PCloud(pcloud::PCloudConfig),
ProtonDrive(proton_drive::ProtonDriveConfig),
Expand All @@ -60,6 +63,7 @@ impl ToString for ServerType {
Self::Dropbox(_) => "Dropbox",
Self::GDrive(_) => "Google Drive",
Self::Nextcloud(_) => "Nextcloud",
Self::OneDrive(_) => "OneDrive",
Self::Owncloud(_) => "Owncloud",
Self::PCloud(_) => "pCloud",
Self::ProtonDrive(_) => "Proton Drive",
Expand Down Expand Up @@ -115,6 +119,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
let dropbox_name = ServerType::Dropbox(Default::default()).to_string();
let gdrive_name = ServerType::GDrive(Default::default()).to_string();
let nextcloud_name = ServerType::Nextcloud(Default::default()).to_string();
let onedrive_name = ServerType::OneDrive(Default::default()).to_string();
let owncloud_name = ServerType::Owncloud(Default::default()).to_string();
let pcloud_name = ServerType::PCloud(Default::default()).to_string();
let proton_drive_name = ServerType::ProtonDrive(Default::default()).to_string();
Expand All @@ -126,6 +131,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
dropbox_name.as_str(),
gdrive_name.as_str(),
nextcloud_name.as_str(),
onedrive_name.as_str(),
owncloud_name.as_str(),
pcloud_name.as_str(),
proton_drive_name.as_str(),
Expand All @@ -152,6 +158,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
let dropbox_items = DropboxConfig::get_sections(&window, sender.clone());
let gdrive_items = GDriveConfig::get_sections(&window, sender.clone());
let nextcloud_items = NextcloudConfig::get_sections(&window, sender.clone());
let onedrive_items = OneDriveConfig::get_sections(&window, sender.clone());
let owncloud_items = OwncloudConfig::get_sections(&window, sender.clone());
let pcloud_items = PCloudConfig::get_sections(&window, sender.clone());
let proton_drive_items = ProtonDriveConfig::get_sections(&window, sender.clone());
Expand All @@ -170,6 +177,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
"dropbox" => dropbox_items.clone(),
"google drive" => gdrive_items.clone(),
"nextcloud" => nextcloud_items.clone(),
"onedrive" => onedrive_items.clone(),
"owncloud" => owncloud_items.clone(),
"pcloud" => pcloud_items.clone(),
"proton drive" => proton_drive_items.clone(),
Expand Down Expand Up @@ -222,6 +230,7 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
ServerType::Dropbox(config) => config.server_name.clone(),
ServerType::GDrive(config) => config.server_name.clone(),
ServerType::Nextcloud(config) => config.server_name.clone(),
ServerType::OneDrive(config) => config.server_name.clone(),
ServerType::Owncloud(config) => config.server_name.clone(),
ServerType::PCloud(config) => config.server_name.clone(),
ServerType::ProtonDrive(config) => config.server_name.clone(),
Expand Down Expand Up @@ -262,6 +271,16 @@ pub fn login(app: &Application, db: &DatabaseConnection) -> Option<RemotesModel>
"obscure": true
}
}),
ServerType::OneDrive(config) => json!({
"name": config_name,
"parameters": {
"client_id": config.client_id,
"client_secret": config.client_secret,
"token": config.auth_json,
"config_refresh_token": false
},
"type": "onedrive"
}),
ServerType::Owncloud(config) => json!({
"name": config_name,
"parameters": {
Expand Down
33 changes: 33 additions & 0 deletions src/login/onedrive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! The data for a OneDrive Rclone config.
use super::ServerType;
use crate::{
login::gdrive::{AuthType, GDriveConfig},
mpsc::Sender,
};
use adw::{gtk::Button, ApplicationWindow, EntryRow};

static DEFAULT_CLIENT_ID: &str = "0914e4da-c4f6-4bf3-ab2a-458d93b39a36";
static DEFAULT_CLIENT_SECRET: &str = "oj18Q~sUrYTSQxQhdbBlXwwTggHKYjKbRES6HcHj";

#[derive(Clone, Debug, Default)]
pub struct OneDriveConfig {
pub server_name: String,
pub client_id: String,
pub client_secret: String,
pub auth_json: String,
}

impl super::LoginTrait for OneDriveConfig {
fn get_sections(
window: &ApplicationWindow,
sender: Sender<Option<ServerType>>,
) -> (Vec<EntryRow>, Button) {
GDriveConfig::auth_sections(
window,
sender,
AuthType::OneDrive,
DEFAULT_CLIENT_ID.to_owned(),
DEFAULT_CLIENT_SECRET.to_owned(),
)
}
}
18 changes: 18 additions & 0 deletions src/rclone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ pub fn get_remote<T: ToString>(remote: T) -> Option<Remote> {
client_id: config["client_id"].clone(),
client_secret: config["client_secret"].clone(),
})),
"onedrive" => Some(Remote::OneDrive(OneDriveRemote {
remote_name: remote,
client_id: config["client_id"].clone(),
client_secret: config["client_secret"].clone(),
})),
"pcloud" => Some(Remote::PCloud(PCloudRemote {
remote_name: remote,
client_id: config["client_id"].clone(),
Expand Down Expand Up @@ -81,6 +86,7 @@ pub fn get_remotes() -> Vec<Remote> {
pub enum Remote {
Dropbox(DropboxRemote),
GDrive(GDriveRemote),
OneDrive(OneDriveRemote),
PCloud(PCloudRemote),
ProtonDrive(ProtonDriveRemote),
WebDav(WebDavRemote),
Expand All @@ -91,6 +97,7 @@ impl Remote {
match self {
Remote::Dropbox(remote) => remote.remote_name.clone(),
Remote::GDrive(remote) => remote.remote_name.clone(),
Remote::OneDrive(remote) => remote.remote_name.clone(),
Remote::PCloud(remote) => remote.remote_name.clone(),
Remote::ProtonDrive(remote) => remote.remote_name.clone(),
Remote::WebDav(remote) => remote.remote_name.clone(),
Expand Down Expand Up @@ -120,6 +127,17 @@ pub struct GDriveRemote {
pub client_secret: String,
}

// The OneDrive remote type.
#[derive(Clone, Debug)]
pub struct OneDriveRemote {
/// The name of the remote.
pub remote_name: String,
/// The client id.
pub client_id: String,
/// The client secret.
pub client_secret: String,
}

// The pCloud remote type.
#[derive(Clone, Debug)]
pub struct PCloudRemote {
Expand Down