//! GoingsOn - Tauri application library. //! //! This library exposes the core modules for testing purposes. //! The main application entry point is in `main.rs` (desktop) //! or via `mobile_entry_point` (iOS/Android). pub mod backup_scheduler; pub mod commands; pub mod email; pub mod email_sync_scheduler; pub mod export; pub mod external_sync; pub mod jmap; pub mod oauth; pub mod state; pub mod sync_scheduler; pub mod sync_service; // Desktop-only: file watching for external DB changes #[cfg(not(any(target_os = "ios", target_os = "android")))] pub mod db_watcher; // Desktop-only: OS notifications for snooze expiry #[cfg(not(any(target_os = "ios", target_os = "android")))] pub mod notifications; #[cfg(test)] pub mod test_utils; /// Build the Tauri app with all commands registered. /// Shared between desktop `main()` and mobile entry point. pub fn build_mobile_app() -> tauri::Builder { use commands::PluginState; use goingson_plugin_runtime::PluginRegistry; use state::AppState; use std::sync::Arc; use tauri::Manager; use tokio_util::sync::CancellationToken; let mut builder = tauri::Builder::default(); // Desktop-only plugins #[cfg(not(any(target_os = "ios", target_os = "android")))] { builder = builder .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_notification::init()) .plugin(tauri_plugin_window_state::Builder::new().build()); } builder .plugin(tauri_plugin_dialog::init()) .setup(|app| { // Initialize database let app_handle = app.handle().clone(); tauri::async_runtime::block_on(async move { let state = AppState::new(&app_handle).await .expect("Failed to initialize app state"); app_handle.manage(Arc::new(state)); }); // Initialize plugin system let config_dir = app.path().app_config_dir() .expect("Failed to get config dir"); let plugins_dir = config_dir.join("plugins"); let mut plugin_registry = PluginRegistry::new(&plugins_dir) .expect("Failed to initialize plugin registry"); if let Err(e) = plugin_registry.initialize() { tracing::warn!("Failed to load some plugins: {}", e); } app.manage(PluginState::new(plugin_registry)); // Background services that work on all platforms let cancel_token = CancellationToken::new(); app.manage(cancel_token.clone()); let backup_handle = app.handle().clone(); let backup_cancel = cancel_token.clone(); tauri::async_runtime::spawn(async move { backup_scheduler::start_backup_scheduler(backup_handle, backup_cancel).await; }); let sync_handle = app.handle().clone(); let email_cancel = cancel_token.clone(); tauri::async_runtime::spawn(async move { email_sync_scheduler::start_email_sync_scheduler(sync_handle, email_cancel).await; }); let cloud_sync_handle = app.handle().clone(); let cloud_cancel = cancel_token; tauri::async_runtime::spawn(async move { sync_scheduler::start_sync_scheduler(cloud_sync_handle, cloud_cancel).await; }); // Clean up stale email preview temp files from previous sessions tauri::async_runtime::spawn(async { commands::email::cleanup_stale_temp_files().await; }); Ok(()) }) .invoke_handler(tauri::generate_handler![ commands::add_attachment, commands::list_attachments, commands::delete_attachment, commands::open_attachment, commands::save_attachment, commands::convert_email_attachments, commands::open_email_blob, commands::save_email_blob, commands::get_file_size, commands::list_projects, commands::get_project, commands::create_project, commands::update_project, commands::delete_project, commands::list_tasks, commands::list_tasks_filtered, commands::get_task, commands::create_task, commands::quick_add_task, commands::update_task, commands::delete_task, commands::start_task, commands::complete_task, commands::list_snoozed_tasks, commands::snooze_task, commands::unsnooze_task, commands::list_waiting_tasks, commands::mark_task_waiting, commands::clear_task_waiting, commands::list_annotations, commands::add_annotation, commands::delete_annotation, commands::list_subtasks, commands::add_subtask, commands::add_subtask_link, commands::toggle_subtask, commands::update_subtask, commands::delete_subtask, commands::list_milestones, commands::create_milestone, commands::update_milestone, commands::delete_milestone, commands::reorder_milestones, commands::list_events, commands::get_event, commands::create_event, commands::update_event, commands::delete_event, commands::list_upcoming_events, commands::get_event_status_indicator, commands::list_snoozed_events, commands::snooze_event, commands::unsnooze_event, commands::list_emails, commands::list_emails_threaded, commands::get_email, commands::open_email_in_browser, commands::create_email, commands::send_email, commands::save_email_draft, commands::list_email_drafts, commands::send_email_draft, commands::set_email_labels, commands::list_email_folders, commands::list_email_labels, commands::move_email_to_folder, commands::delete_email, commands::mark_email_read, commands::mark_email_unread, commands::archive_email, commands::unarchive_email, commands::mark_all_emails_read, commands::link_email_to_project, commands::get_unread_email_count, commands::list_snoozed_emails, commands::snooze_email, commands::unsnooze_email, commands::list_waiting_emails, commands::mark_email_waiting, commands::clear_email_waiting, commands::list_contacts, commands::get_contact, commands::create_contact, commands::update_contact, commands::delete_contact, commands::add_contact_email, commands::remove_contact_email, commands::add_contact_phone, commands::remove_contact_phone, commands::add_contact_social_handle, commands::remove_contact_social_handle, commands::add_contact_custom_field, commands::remove_contact_custom_field, commands::update_contact_email, commands::update_contact_phone, commands::update_contact_social_handle, commands::update_contact_custom_field, commands::find_contact_by_email, commands::list_contacts_filtered, commands::get_snooze_options, commands::list_email_accounts, commands::get_email_account, commands::create_email_account, commands::update_email_account, commands::update_email_sync_interval, commands::update_email_signature, commands::update_email_notify, commands::delete_email_account, commands::test_email_account, commands::sync_email_account, commands::list_tasks_for_project, commands::list_events_for_project, commands::list_emails_for_project, commands::list_unlinked_emails, commands::list_emails_by_thread, commands::get_dashboard_stats, commands::get_changelog, commands::open_compose_window, commands::set_window_title, commands::search, commands::get_day_planning, commands::schedule_task, commands::unschedule_task, commands::list_saved_views, commands::list_pinned_views, commands::get_saved_view, commands::create_saved_view, commands::update_saved_view, commands::delete_saved_view, commands::toggle_view_pinned, commands::list_oauth_providers, commands::start_oauth, commands::complete_oauth, commands::refresh_oauth_tokens, commands::disconnect_oauth, commands::reconnect_oauth, commands::get_export_summary, commands::export_json, commands::export_tasks_csv, commands::export_events_ics, commands::create_backup, commands::list_backups, commands::restore_backup, commands::delete_backup, commands::get_backup_settings, commands::save_backup_settings, commands::get_weekly_review, commands::complete_weekly_review, commands::set_task_focus, commands::clear_all_focus, commands::set_vacation_days, commands::check_weekly_review_nudge, commands::get_monthly_review, commands::upsert_monthly_goal, commands::update_monthly_goal_status, commands::delete_monthly_goal, commands::save_monthly_reflection, commands::sync_get_tiers, commands::sync_status, commands::sync_start_auth, commands::sync_complete_auth, commands::sync_disconnect, commands::sync_now, commands::sync_setup_encryption_new, commands::sync_setup_encryption_existing, commands::sync_update_settings, commands::sync_account_info, commands::sync_subscription_status, commands::sync_subscribe, commands::list_themes, commands::get_theme, commands::get_custom_themes_dir, commands::import_theme, commands::export_theme, commands::list_import_plugins, commands::list_enabled_import_plugins, commands::get_plugins_for_extension, commands::preview_import, commands::execute_import, commands::enable_plugin, commands::disable_plugin, commands::reload_plugin, commands::preview_vcf, commands::import_vcf, commands::preview_ics, commands::import_ics, commands::start_timer, commands::stop_timer, commands::discard_timer, commands::get_active_timer, commands::list_time_sessions, commands::log_manual_time, commands::get_time_summary, ]) } /// Mobile entry point for iOS/Android. #[cfg(mobile)] #[tauri::mobile_entry_point] fn main() { tracing_subscriber::fmt::init(); build_mobile_app() .run(tauri::generate_context!()) .expect("error while running tauri application"); }