Skip to content

Commit

Permalink
convert encrypted clipboards to base64
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Jan 26, 2025
1 parent c01f6ad commit d7fe531
Show file tree
Hide file tree
Showing 42 changed files with 343 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist
yarn.lock
package-lock.json
pnpm-lock.yamlor.log
bun.lockb
bun.lock*

# Generated by Tauri
# will have schema files for capabilities auto-completion
Expand Down
48 changes: 1 addition & 47 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name = "tauri_app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[workspace]
members = [".", "migration", "entity", "common", "tao"]
members = [".", "migration", "entity", "common"]

[build-dependencies]
tauri-build = { version = "2", features = [] }
Expand All @@ -24,7 +24,6 @@ tauri-build = { version = "2", features = [] }
entity = { path = "entity" }
migration = { path = "migration" }
common = { path = "common" }
tao = { path = "tao" }

tauri = { version = "2", features = [
"macos-private-api",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/clipboard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
20 changes: 10 additions & 10 deletions src-tauri/entity/src/clipboard_file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand All @@ -18,12 +18,12 @@ impl EntityName for Entity {
pub struct Model {
pub id: Uuid,
pub clipboard_id: Uuid,
pub name: Option<String>,
pub name: String,
pub size: i32,
pub extension: Option<String>,
pub size: Option<i32>,
pub mime_type: Option<String>,
pub created_date: Option<DateTime>,
pub modified_date: Option<DateTime>,
pub created_date: DateTime,
pub modified_date: DateTime,
pub data: Vec<u8>,
}

Expand All @@ -32,8 +32,8 @@ pub enum Column {
Id,
ClipboardId,
Name,
Extension,
Size,
Extension,
MimeType,
CreatedDate,
ModifiedDate,
Expand Down Expand Up @@ -63,12 +63,12 @@ impl ColumnTrait for Column {
match self {
Self::Id => ColumnType::Uuid.def(),
Self::ClipboardId => ColumnType::Uuid.def(),
Self::Name => ColumnType::String(StringLen::None).def().null(),
Self::Name => ColumnType::String(StringLen::None).def(),
Self::Size => ColumnType::Integer.def(),
Self::Extension => ColumnType::String(StringLen::None).def().null(),
Self::Size => ColumnType::Integer.def().null(),
Self::MimeType => ColumnType::String(StringLen::None).def().null(),
Self::CreatedDate => ColumnType::DateTime.def().null(),
Self::ModifiedDate => ColumnType::DateTime.def().null(),
Self::CreatedDate => ColumnType::DateTime.def(),
Self::ModifiedDate => ColumnType::DateTime.def(),
Self::Data => ColumnType::Blob.def(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/clipboard_html.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/clipboard_image.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/clipboard_rtf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/clipboard_text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/hotkey.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
pub mod prelude;

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
pub use super::clipboard::Entity as Clipboard;
pub use super::clipboard_file::Entity as ClipboardFile;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/entity/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/migration/src/m000006_create_clipboard_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::m000001_create_clipboard::Clipboard;
use sea_orm_migration::{
prelude::*,
schema::{blob, date_time_null, integer_null, string_null, uuid},
schema::{blob, date_time, integer, string, string_null, uuid},
};

#[derive(Iden)]
Expand Down Expand Up @@ -31,12 +31,12 @@ impl MigrationTrait for Migration {
.if_not_exists()
.col(uuid(ClipboardFile::Id).not_null().primary_key())
.col(uuid(ClipboardFile::ClipboardId))
.col(string_null(ClipboardFile::Name))
.col(string(ClipboardFile::Name))
.col(integer(ClipboardFile::Size).default(0))
.col(string_null(ClipboardFile::Extension))
.col(integer_null(ClipboardFile::Size))
.col(string_null(ClipboardFile::MimeType))
.col(date_time_null(ClipboardFile::CreatedDate))
.col(date_time_null(ClipboardFile::ModifiedDate))
.col(date_time(ClipboardFile::CreatedDate))
.col(date_time(ClipboardFile::ModifiedDate))
.col(blob(ClipboardFile::Data))
.foreign_key(
ForeignKey::create()
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/commands/clipboard.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::prelude::*;
use crate::tao::global::{get_app, get_main_window};
use crate::{
service::clipboard::{
clear_clipboards_db, copy_clipboard_from_id, delete_clipboards_db, get_clipboard_count_db,
Expand All @@ -17,7 +18,6 @@ use common::{
};
use sea_orm::prelude::Uuid;
use std::fs::File;
use tao::global::{get_app, get_main_window};
use tauri::{Emitter, Manager};

#[tauri::command]
Expand Down
3 changes: 1 addition & 2 deletions src-tauri/src/commands/settings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::service::settings::{autostart, get_settings_db, update_settings_db};
use crate::{service::settings::{autostart, get_settings_db, update_settings_db}, tao::config::{change_clipboard_db_location_enable, reset_clipboard_db_location_disable}};
use common::types::types::CommandError;
use entity::settings::Model;
use tao::config::{change_clipboard_db_location_enable, reset_clipboard_db_location_disable};

#[tauri::command]
pub async fn get_settings() -> Result<Model, CommandError> {
Expand Down
5 changes: 2 additions & 3 deletions src-tauri/src/commands/sync.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::service::{
use crate::{service::{
settings::{get_global_settings, init_settings_window, set_global_settings},
sync::{get_sync_provider, sync_toggle, upsert_settings_sync},
};
}, tao::connection::db};
use common::types::types::CommandError;
use entity::settings::{self, ActiveModel};
use sea_orm::{ActiveModelTrait, DatabaseConnection, EntityTrait};
use tao::connection::db;

#[tauri::command]
pub async fn sync_authenticate_toggle() -> Result<bool, CommandError> {
Expand Down
5 changes: 2 additions & 3 deletions src-tauri/src/commands/window.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::service::{
use crate::{service::{
clipboard::count_clipboards_db, window::open_window,
};
}, tao::config::get_data_path};
use common::types::{
enums::{FolderLocation, WebWindow},
types::{CommandError, Config, DatabaseInfo},
};
use tao::config::get_data_path;
use std::{
fs::{self, read_to_string},
path::PathBuf,
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/config/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::{
clipboard_events::init_clipboard_listener, hotkey_events::init_hotkey_listener,
window_events::init_window_event_listener,
},
service::{settings::init_settings, sync::init_sync_interval, window::init_window},
service::{encrypt::set_encryption_key, settings::init_settings, sync::init_sync_interval, window::init_window},
tao::{config::create_config, tao_constants::init_globals},
};
use tao::{config::create_config, tauri_constants::init_globals};

pub fn setup(app: &mut tauri::App) -> Result<(), Box<(dyn std::error::Error + 'static)>> {
init_globals(app);
Expand All @@ -20,6 +20,6 @@ pub fn setup(app: &mut tauri::App) -> Result<(), Box<(dyn std::error::Error + 's
init_hotkey_listener();
init_window_event_listener();
init_sync_interval();

set_encryption_key("asd").expect("Failed to set encryption key");
Ok(())
}
3 changes: 1 addition & 2 deletions src-tauri/src/config/tray.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::service::window::toggle_main_window;
use tao::global::get_app;
use crate::{service::window::toggle_main_window, tao::global::get_app};
use tauri::{
menu::{Menu, MenuItem},
tray::TrayIconBuilder,
Expand Down
3 changes: 1 addition & 2 deletions src-tauri/src/events/clipboard_events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::utils::clipboard_manager::ClipboardManagerExt;
use crate::{tao::global::get_app, utils::clipboard_manager::ClipboardManagerExt};
use common::types::orm_query::FullClipboardDbo;
use tao::global::get_app;
use tauri::{Listener, Manager};
use tauri_plugin_clipboard::Clipboard;

Expand Down
4 changes: 1 addition & 3 deletions src-tauri/src/events/hotkey_events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::commands::sync::sync_authenticate_toggle;
use crate::prelude::*;
use crate::service::window::open_window;
use crate::tao::global::{get_app, get_hotkey_running, get_hotkey_stop_tx, get_hotkey_store, get_main_window};
use crate::{
service::{
clipboard::copy_clipboard_from_index,
Expand All @@ -14,9 +15,6 @@ use common::types::types::Key;
use core::time::Duration;
use global_hotkey::{GlobalHotKeyEvent, HotKeyState};
use regex::Regex;
use tao::global::{
get_app, get_hotkey_running, get_hotkey_stop_tx, get_hotkey_store, get_main_window,
};
use tauri::Emitter;
use tokio::sync::oneshot;

Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/events/window_events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;
use crate::tao::global::{get_hotkey_running, get_window_stop_tx};
use crate::{prelude::*, tao::global::get_main_window};
use crate::utils::hotkey_manager::unregister_hotkeys;
use common::types::enums::ListenEvent;
use tao::global::{get_hotkey_running, get_main_window, get_window_stop_tx};
use tauri::{Emitter, WindowEvent};
use tokio::sync::oneshot;

Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod events;
mod prelude;
mod service;
mod utils;
mod tao;

use commands::{cipher, clipboard, hotkey, settings, sync, window};
use config::setup;
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/src/service/clipboard.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::settings::get_global_settings;
use super::sync::{get_sync_manager, get_sync_provider};
use crate::prelude::*;
use crate::tao::connection::db;
use crate::tao::global::{get_app, get_app_window, get_main_window};
use chrono::NaiveDateTime;
use common::builder::keyword::KeywordBuilder;
use common::io::clipboard::trim_clipboard_data;
Expand All @@ -19,8 +21,6 @@ use sea_orm::{
};
use std::collections::HashMap;
use std::sync::Mutex;
use tao::connection::db;
use tao::global::{get_app, get_app_window, get_main_window};
use tauri::{Emitter, Manager};
use tauri_plugin_clipboard::Clipboard;
use tokio::try_join;
Expand Down Expand Up @@ -456,7 +456,7 @@ pub async fn delete_clipboards_db(
.emit(ListenEvent::InitClipboards.to_string().as_str(), ())
.expect("Failed to emit event");
}

for clippy in clipboards {
printlog!(
"deleting remote clipboard: {:?} command: {:?}",
Expand Down Expand Up @@ -668,7 +668,7 @@ pub async fn copy_clipboard_from_id(
.filter_map(|f| {
let path = std::env::temp_dir().join(format!(
"{}.{}",
f.name.as_ref().expect("Failed to get file name"),
&f.name,
f.extension.as_ref().expect("Failed to get file extension")
));
std::fs::write(&path, &f.data).ok()?;
Expand Down
Loading

0 comments on commit d7fe531

Please sign in to comment.