Skip to content

Commit

Permalink
Merge pull request #118 from solaoi/main
Browse files Browse the repository at this point in the history
release 0.9.8
  • Loading branch information
solaoi authored Apr 5, 2024
2 parents cc4a797 + 54a5a40 commit 8002f46
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lycoris",
"private": true,
"version": "0.9.7",
"version": "0.9.8",
"type": "module",
"license": "MIT",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lycoris"
version = "0.9.7"
version = "0.9.8"
description = "Lycoris is an offline voice memo"
authors = ["solaoi"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions src-tauri/migrations/001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ INSERT INTO settings(setting_name, setting_status) VALUES("settingHook", "");
INSERT INTO settings(setting_name, setting_status) VALUES("settingResource", "");
INSERT INTO settings(setting_name, setting_status) VALUES("settingModel", "gpt-3.5-turbo");
INSERT INTO settings(setting_name, setting_status) VALUES("settingAILanguage", "None");
INSERT INTO settings(setting_name, setting_status) VALUES("settingHasAccessedScreenCapturePermission", "never");
CREATE TABLE models (
id INTEGER PRIMARY KEY AUTOINCREMENT,
model_name TEXT,
Expand Down
41 changes: 27 additions & 14 deletions src-tauri/src/module/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use objc_id::Id;
use core_graphics::access::ScreenCaptureAccess;
use tauri::{api::dialog::confirm, Window};

use super::sqlite::Sqlite;

pub fn has_accessibility_permission() -> bool {
let trusted = macos_accessibility_client::accessibility::application_is_trusted_with_prompt();
return trusted;
Expand Down Expand Up @@ -42,20 +44,31 @@ pub fn has_microphone_permission(window: Window) -> bool {
}

pub fn has_screen_capture_permission(window: Window) -> bool {
let sqlite = Sqlite::new();
let has_accessed_screen_capture_permission = sqlite
.select_has_accessed_screen_capture_permission()
.unwrap();
let access = ScreenCaptureAccess::default();
let trusted = access.preflight();
if !trusted {
let func = |ok: bool| {
if ok {
std::process::Command::new("open")
.arg(
"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",
)
.spawn()
.expect("failed to open system preferences");
}
};
confirm(Some(&window),"システム設定の\"セキュリティとプライバシー\"設定で、このアプリケーションへのアクセスを許可してください。", "\"Lycoris.app\"から画面収録にアクセスしようとしています。",func);
if has_accessed_screen_capture_permission == "has_accessed" {
let trusted = access.preflight();
if !trusted {
let func = |ok: bool| {
if ok {
std::process::Command::new("open")
.arg(
"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture",
)
.spawn()
.expect("failed to open system preferences");
}
};
confirm(Some(&window),"システム設定の\"セキュリティとプライバシー\"設定で、このアプリケーションへのアクセスを許可してください。", "\"Lycoris.app\"から画面収録にアクセスしようとしています。",func);
}
return trusted;
} else {
sqlite
.update_has_accessed_screen_capture_permission()
.unwrap();
return access.request();
}
return trusted;
}
15 changes: 15 additions & 0 deletions src-tauri/src/module/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ impl Sqlite {
);
}

pub fn select_has_accessed_screen_capture_permission(&self) -> Result<String, rusqlite::Error> {
return self.conn.query_row(
"SELECT setting_status FROM settings WHERE setting_name = \"settingHasAccessedScreenCapturePermission\"",
params![],
|row| Ok(row.get_unwrap(0)),
);
}

pub fn update_has_accessed_screen_capture_permission(&self) -> Result<usize, rusqlite::Error> {
self.conn.execute(
"UPDATE settings SET setting_status = \"has_accessed\" WHERE setting_name = \"settingHasAccessedScreenCapturePermission\"",
params![],
)
}

pub fn update_model_vosk_to_whisper(
&self,
id: u16,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Lycoris",
"version": "0.9.7"
"version": "0.9.8"
},
"tauri": {
"allowlist": {
Expand Down

0 comments on commit 8002f46

Please sign in to comment.