| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
pub mod backup_scheduler; |
| 8 |
pub mod commands; |
| 9 |
pub mod email; |
| 10 |
pub mod email_sync_scheduler; |
| 11 |
pub mod export; |
| 12 |
pub mod external_sync; |
| 13 |
pub mod jmap; |
| 14 |
pub mod oauth; |
| 15 |
pub mod state; |
| 16 |
pub mod sync_scheduler; |
| 17 |
pub mod sync_service; |
| 18 |
|
| 19 |
|
| 20 |
#[cfg(not(any(target_os = "ios", target_os = "android")))] |
| 21 |
pub mod db_watcher; |
| 22 |
|
| 23 |
|
| 24 |
#[cfg(not(any(target_os = "ios", target_os = "android")))] |
| 25 |
pub mod notifications; |
| 26 |
|
| 27 |
#[cfg(test)] |
| 28 |
pub mod test_utils; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
pub fn build_mobile_app() -> tauri::Builder<tauri::Wry> { |
| 33 |
use commands::PluginState; |
| 34 |
use goingson_plugin_runtime::PluginRegistry; |
| 35 |
use state::AppState; |
| 36 |
use std::sync::Arc; |
| 37 |
use tauri::Manager; |
| 38 |
use tokio_util::sync::CancellationToken; |
| 39 |
|
| 40 |
let mut builder = tauri::Builder::default(); |
| 41 |
|
| 42 |
|
| 43 |
#[cfg(not(any(target_os = "ios", target_os = "android")))] |
| 44 |
{ |
| 45 |
builder = builder |
| 46 |
.plugin(tauri_plugin_shell::init()) |
| 47 |
.plugin(tauri_plugin_notification::init()) |
| 48 |
.plugin(tauri_plugin_window_state::Builder::new().build()); |
| 49 |
} |
| 50 |
|
| 51 |
builder |
| 52 |
.plugin(tauri_plugin_dialog::init()) |
| 53 |
.setup(|app| { |
| 54 |
|
| 55 |
let app_handle = app.handle().clone(); |
| 56 |
tauri::async_runtime::block_on(async move { |
| 57 |
let state = AppState::new(&app_handle).await |
| 58 |
.expect("Failed to initialize app state"); |
| 59 |
app_handle.manage(Arc::new(state)); |
| 60 |
}); |
| 61 |
|
| 62 |
|
| 63 |
let config_dir = app.path().app_config_dir() |
| 64 |
.expect("Failed to get config dir"); |
| 65 |
let plugins_dir = config_dir.join("plugins"); |
| 66 |
let mut plugin_registry = PluginRegistry::new(&plugins_dir) |
| 67 |
.expect("Failed to initialize plugin registry"); |
| 68 |
if let Err(e) = plugin_registry.initialize() { |
| 69 |
tracing::warn!("Failed to load some plugins: {}", e); |
| 70 |
} |
| 71 |
app.manage(PluginState::new(plugin_registry)); |
| 72 |
|
| 73 |
|
| 74 |
let cancel_token = CancellationToken::new(); |
| 75 |
app.manage(cancel_token.clone()); |
| 76 |
|
| 77 |
let backup_handle = app.handle().clone(); |
| 78 |
let backup_cancel = cancel_token.clone(); |
| 79 |
tauri::async_runtime::spawn(async move { |
| 80 |
backup_scheduler::start_backup_scheduler(backup_handle, backup_cancel).await; |
| 81 |
}); |
| 82 |
|
| 83 |
let sync_handle = app.handle().clone(); |
| 84 |
let email_cancel = cancel_token.clone(); |
| 85 |
tauri::async_runtime::spawn(async move { |
| 86 |
email_sync_scheduler::start_email_sync_scheduler(sync_handle, email_cancel).await; |
| 87 |
}); |
| 88 |
|
| 89 |
let cloud_sync_handle = app.handle().clone(); |
| 90 |
let cloud_cancel = cancel_token; |
| 91 |
tauri::async_runtime::spawn(async move { |
| 92 |
sync_scheduler::start_sync_scheduler(cloud_sync_handle, cloud_cancel).await; |
| 93 |
}); |
| 94 |
|
| 95 |
|
| 96 |
tauri::async_runtime::spawn(async { |
| 97 |
commands::email::cleanup_stale_temp_files().await; |
| 98 |
}); |
| 99 |
|
| 100 |
Ok(()) |
| 101 |
}) |
| 102 |
.invoke_handler(tauri::generate_handler![ |
| 103 |
commands::add_attachment, |
| 104 |
commands::list_attachments, |
| 105 |
commands::delete_attachment, |
| 106 |
commands::open_attachment, |
| 107 |
commands::save_attachment, |
| 108 |
commands::convert_email_attachments, |
| 109 |
commands::open_email_blob, |
| 110 |
commands::save_email_blob, |
| 111 |
commands::get_file_size, |
| 112 |
commands::list_projects, |
| 113 |
commands::get_project, |
| 114 |
commands::create_project, |
| 115 |
commands::update_project, |
| 116 |
commands::delete_project, |
| 117 |
commands::list_tasks, |
| 118 |
commands::list_tasks_filtered, |
| 119 |
commands::get_task, |
| 120 |
commands::create_task, |
| 121 |
commands::quick_add_task, |
| 122 |
commands::update_task, |
| 123 |
commands::delete_task, |
| 124 |
commands::start_task, |
| 125 |
commands::complete_task, |
| 126 |
commands::list_snoozed_tasks, |
| 127 |
commands::snooze_task, |
| 128 |
commands::unsnooze_task, |
| 129 |
commands::list_waiting_tasks, |
| 130 |
commands::mark_task_waiting, |
| 131 |
commands::clear_task_waiting, |
| 132 |
commands::list_annotations, |
| 133 |
commands::add_annotation, |
| 134 |
commands::delete_annotation, |
| 135 |
commands::list_subtasks, |
| 136 |
commands::add_subtask, |
| 137 |
commands::add_subtask_link, |
| 138 |
commands::toggle_subtask, |
| 139 |
commands::update_subtask, |
| 140 |
commands::delete_subtask, |
| 141 |
commands::list_milestones, |
| 142 |
commands::create_milestone, |
| 143 |
commands::update_milestone, |
| 144 |
commands::delete_milestone, |
| 145 |
commands::reorder_milestones, |
| 146 |
commands::list_events, |
| 147 |
commands::get_event, |
| 148 |
commands::create_event, |
| 149 |
commands::update_event, |
| 150 |
commands::delete_event, |
| 151 |
commands::list_upcoming_events, |
| 152 |
commands::get_event_status_indicator, |
| 153 |
commands::list_snoozed_events, |
| 154 |
commands::snooze_event, |
| 155 |
commands::unsnooze_event, |
| 156 |
commands::list_emails, |
| 157 |
commands::list_emails_threaded, |
| 158 |
commands::get_email, |
| 159 |
commands::open_email_in_browser, |
| 160 |
commands::create_email, |
| 161 |
commands::send_email, |
| 162 |
commands::save_email_draft, |
| 163 |
commands::list_email_drafts, |
| 164 |
commands::send_email_draft, |
| 165 |
commands::set_email_labels, |
| 166 |
commands::list_email_folders, |
| 167 |
commands::list_email_labels, |
| 168 |
commands::move_email_to_folder, |
| 169 |
commands::delete_email, |
| 170 |
commands::mark_email_read, |
| 171 |
commands::mark_email_unread, |
| 172 |
commands::archive_email, |
| 173 |
commands::unarchive_email, |
| 174 |
commands::mark_all_emails_read, |
| 175 |
commands::link_email_to_project, |
| 176 |
commands::get_unread_email_count, |
| 177 |
commands::list_snoozed_emails, |
| 178 |
commands::snooze_email, |
| 179 |
commands::unsnooze_email, |
| 180 |
commands::list_waiting_emails, |
| 181 |
commands::mark_email_waiting, |
| 182 |
commands::clear_email_waiting, |
| 183 |
commands::list_contacts, |
| 184 |
commands::get_contact, |
| 185 |
commands::create_contact, |
| 186 |
commands::update_contact, |
| 187 |
commands::delete_contact, |
| 188 |
commands::add_contact_email, |
| 189 |
commands::remove_contact_email, |
| 190 |
commands::add_contact_phone, |
| 191 |
commands::remove_contact_phone, |
| 192 |
commands::add_contact_social_handle, |
| 193 |
commands::remove_contact_social_handle, |
| 194 |
commands::add_contact_custom_field, |
| 195 |
commands::remove_contact_custom_field, |
| 196 |
commands::update_contact_email, |
| 197 |
commands::update_contact_phone, |
| 198 |
commands::update_contact_social_handle, |
| 199 |
commands::update_contact_custom_field, |
| 200 |
commands::find_contact_by_email, |
| 201 |
commands::list_contacts_filtered, |
| 202 |
commands::get_snooze_options, |
| 203 |
commands::list_email_accounts, |
| 204 |
commands::get_email_account, |
| 205 |
commands::create_email_account, |
| 206 |
commands::update_email_account, |
| 207 |
commands::update_email_sync_interval, |
| 208 |
commands::update_email_signature, |
| 209 |
commands::update_email_notify, |
| 210 |
commands::delete_email_account, |
| 211 |
commands::test_email_account, |
| 212 |
commands::sync_email_account, |
| 213 |
commands::list_tasks_for_project, |
| 214 |
commands::list_events_for_project, |
| 215 |
commands::list_emails_for_project, |
| 216 |
commands::list_unlinked_emails, |
| 217 |
commands::list_emails_by_thread, |
| 218 |
commands::get_dashboard_stats, |
| 219 |
commands::get_changelog, |
| 220 |
commands::open_compose_window, |
| 221 |
commands::set_window_title, |
| 222 |
commands::search, |
| 223 |
commands::get_day_planning, |
| 224 |
commands::schedule_task, |
| 225 |
commands::unschedule_task, |
| 226 |
commands::list_saved_views, |
| 227 |
commands::list_pinned_views, |
| 228 |
commands::get_saved_view, |
| 229 |
commands::create_saved_view, |
| 230 |
commands::update_saved_view, |
| 231 |
commands::delete_saved_view, |
| 232 |
commands::toggle_view_pinned, |
| 233 |
commands::list_oauth_providers, |
| 234 |
commands::start_oauth, |
| 235 |
commands::complete_oauth, |
| 236 |
commands::refresh_oauth_tokens, |
| 237 |
commands::disconnect_oauth, |
| 238 |
commands::reconnect_oauth, |
| 239 |
commands::get_export_summary, |
| 240 |
commands::export_json, |
| 241 |
commands::export_tasks_csv, |
| 242 |
commands::export_events_ics, |
| 243 |
commands::create_backup, |
| 244 |
commands::list_backups, |
| 245 |
commands::restore_backup, |
| 246 |
commands::delete_backup, |
| 247 |
commands::get_backup_settings, |
| 248 |
commands::save_backup_settings, |
| 249 |
commands::get_weekly_review, |
| 250 |
commands::complete_weekly_review, |
| 251 |
commands::set_task_focus, |
| 252 |
commands::clear_all_focus, |
| 253 |
commands::set_vacation_days, |
| 254 |
commands::check_weekly_review_nudge, |
| 255 |
commands::get_monthly_review, |
| 256 |
commands::upsert_monthly_goal, |
| 257 |
commands::update_monthly_goal_status, |
| 258 |
commands::delete_monthly_goal, |
| 259 |
commands::save_monthly_reflection, |
| 260 |
commands::sync_get_tiers, |
| 261 |
commands::sync_status, |
| 262 |
commands::sync_start_auth, |
| 263 |
commands::sync_complete_auth, |
| 264 |
commands::sync_disconnect, |
| 265 |
commands::sync_now, |
| 266 |
commands::sync_setup_encryption_new, |
| 267 |
commands::sync_setup_encryption_existing, |
| 268 |
commands::sync_update_settings, |
| 269 |
commands::sync_account_info, |
| 270 |
commands::sync_subscription_status, |
| 271 |
commands::sync_subscribe, |
| 272 |
commands::list_themes, |
| 273 |
commands::get_theme, |
| 274 |
commands::get_custom_themes_dir, |
| 275 |
commands::import_theme, |
| 276 |
commands::export_theme, |
| 277 |
commands::list_import_plugins, |
| 278 |
commands::list_enabled_import_plugins, |
| 279 |
commands::get_plugins_for_extension, |
| 280 |
commands::preview_import, |
| 281 |
commands::execute_import, |
| 282 |
commands::enable_plugin, |
| 283 |
commands::disable_plugin, |
| 284 |
commands::reload_plugin, |
| 285 |
commands::preview_vcf, |
| 286 |
commands::import_vcf, |
| 287 |
commands::preview_ics, |
| 288 |
commands::import_ics, |
| 289 |
commands::start_timer, |
| 290 |
commands::stop_timer, |
| 291 |
commands::discard_timer, |
| 292 |
commands::get_active_timer, |
| 293 |
commands::list_time_sessions, |
| 294 |
commands::log_manual_time, |
| 295 |
commands::get_time_summary, |
| 296 |
]) |
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
#[cfg(mobile)] |
| 301 |
#[tauri::mobile_entry_point] |
| 302 |
fn main() { |
| 303 |
tracing_subscriber::fmt::init(); |
| 304 |
|
| 305 |
build_mobile_app() |
| 306 |
.run(tauri::generate_context!()) |
| 307 |
.expect("error while running tauri application"); |
| 308 |
} |
| 309 |
|