1pub mod commands;
13mod constants;
14mod crypto;
15pub mod database;
16mod errors;
17pub mod initialization;
18pub mod models;
19pub mod scrapers;
20mod secrets;
21mod security;
22pub mod services;
23pub mod sources;
24pub mod utils;
25
26use crate::initialization::initialize_app;
27use crate::utils::logger;
28use services::recommendation;
29use tauri::Manager;
30
31#[cfg_attr(mobile, tauri::mobile_entry_point)]
32pub fn run() {
33 tauri::Builder::default()
34 .plugin(tauri_plugin_shell::init())
35 .plugin(tauri_plugin_opener::init())
36 .plugin(tauri_plugin_store::Builder::default().build())
37 .plugin(tauri_plugin_dialog::init())
38 .plugin(tauri_plugin_updater::Builder::new().build())
39 .setup(|app| {
40 let app_handle = app.handle();
41
42 #[cfg(target_os = "linux")]
44 {
45 glib::set_prgname(Some("Playlite"));
46 glib::set_application_name("Playlite");
47 }
48
49 let log_dir = app_handle
52 .path()
53 .app_log_dir()
54 .expect("Falha ao pegar pasta de log");
55
56 std::fs::create_dir_all(&log_dir).expect("Falha ao criar pasta de dev_logs");
57
58 let _guard = logger::init_logging(log_dir.clone());
59 app.manage(_guard);
60
61 security::init_security(app_handle).expect("Falha ao inicializar sistema de segurança");
64
65 let db_state = database::initialize_databases(app_handle)
68 .expect("Falha ao inicializar bancos de dados");
69
70 app.manage(db_state);
71
72 if let Err(e) = initialize_app(app_handle) {
76 tracing::error!("Erro na inicialização pós-update: {}", e);
77 }
79
80 if let Err(e) = recommendation::cf_aggregator::init_cf_index() {
83 tracing::warn!("CF desativado (fallback CB ativo): {}", e);
84 }
85
86 tracing::info!("Playlite iniciado com sucesso");
88
89 Ok(())
90 })
91 .invoke_handler(tauri::generate_handler![
92 database::init_db,
94 database::backup::core::export_database,
96 database::backup::core::import_database,
97 commands::games::add_game,
99 commands::games::get_games,
100 commands::games::get_library_game_details,
101 commands::games::toggle_favorite,
102 commands::games::delete_game,
103 commands::games::update_game,
104 commands::games::update_game_details,
105 commands::wishlist::search_wishlist_game,
107 commands::wishlist::search_wishlist_game_by_features,
108 commands::wishlist::add_to_wishlist,
109 commands::wishlist::get_wishlist,
110 commands::wishlist::remove_from_wishlist,
111 commands::wishlist::check_wishlist_status,
112 commands::wishlist::refresh_prices,
113 commands::wishlist::import_wishlist,
114 commands::wishlist::fetch_wishlist_covers,
115 commands::platforms::scanner::scan_games_folder,
117 commands::platforms::scanner::add_game_from_scan,
118 commands::platforms::scanner::add_games_from_scan,
119 commands::platforms::steam::import_steam_library,
120 commands::platforms::epic::epic_login,
121 commands::platforms::epic::epic_logout,
122 commands::platforms::epic::epic_is_authenticated,
123 commands::platforms::epic::import_epic_games,
124 commands::platforms::ubisoft::import_ubisoft_games,
125 commands::platforms::legacy::import_legacy_games,
126 commands::platforms::gog::gog_login,
127 commands::platforms::gog::gog_logout,
128 commands::platforms::gog::gog_is_authenticated,
129 commands::platforms::gog::import_gog_games,
130 commands::platforms::battle_net::import_battle_net_games,
131 commands::platforms::ea::import_ea_games,
132 commands::platforms::amazon::amazon_login,
133 commands::platforms::amazon::amazon_logout,
134 commands::platforms::amazon::amazon_is_authenticated,
135 commands::platforms::amazon::import_amazon_games,
136 commands::platforms::xbox::import_xbox_games,
137 commands::platforms::indiegala::import_indiegala_games,
138 commands::platforms::itch::import_itch_games,
139 commands::launcher::launch_game,
141 commands::metadata::get_metadata::fill_missing_metadata,
143 commands::metadata::covers::fetch_missing_covers,
144 commands::metadata::refresh::check_and_refresh_background,
145 commands::metadata::search::get_trending_games,
146 commands::metadata::search::get_upcoming_games,
147 commands::metadata::search::fetch_game_details,
148 commands::metadata::search::get_active_giveaways,
149 commands::metadata::search::get_similar_games,
150 commands::metadata::search::get_game_media,
151 commands::metadata::search::get_profile_similar_games,
152 commands::metadata::pcgamingwiki::get_or_fetch_pcgw_data,
153 commands::metadata::pcgamingwiki::refresh_pcgw_data,
154 commands::metadata::pcgamingwiki::search_pcgw_games,
155 commands::metadata::pcgamingwiki::get_pcgw_scraped_data,
156 commands::metadata::protondb::fetch_protondb_data,
157 commands::settings::set_secret,
159 commands::settings::get_secret,
160 commands::settings::delete_secret,
161 commands::settings::list_secrets,
162 commands::settings::get_secrets,
163 commands::settings::set_secrets,
164 commands::debug::debug_populate_nexus_cache,
166 commands::debug::backfill_slug_names,
167 commands::recommendation::core::get_user_profile,
169 commands::recommendation::core::recommend_hybrid_library,
170 commands::recommendation::core::recommend_collaborative_library,
171 commands::recommendation::core::recommend_from_library,
172 commands::recommendation::analysis::generate_recommendation_analysis,
173 commands::ai_translation::translate_description,
175 commands::achievements::get_recent_achievements,
177 commands::caches::cleanup_cache,
179 commands::caches::clear_all_cache,
180 commands::caches::get_detailed_cache_stats,
181 commands::system::open_folder,
183 commands::system::open_file,
184 commands::version::get_app_version,
186 commands::version::get_app_version_info,
187 commands::version::is_updater_enabled,
188 services::images::cache_cover_image,
190 services::images::check_local_cover,
191 services::images::clear_cover_cache,
192 commands::subscriptions::get_amazon_luna_catalog,
194 commands::subscriptions::get_game_pass_catalog,
195 commands::subscriptions::get_ea_play_catalog,
196 commands::subscriptions::get_ubisoft_plus_catalog,
197 commands::subscriptions::get_subscription_settings,
198 commands::subscriptions::save_subscription_settings
199 ])
200 .run(tauri::generate_context!())
201 .expect("error while running tauri application");
202}