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 tauri::Manager;
29
30#[cfg_attr(mobile, tauri::mobile_entry_point)]
31pub fn run() {
32 tauri::Builder::default()
33 .plugin(tauri_plugin_shell::init())
34 .plugin(tauri_plugin_opener::init())
35 .plugin(tauri_plugin_store::Builder::default().build())
36 .plugin(tauri_plugin_dialog::init())
37 .plugin(tauri_plugin_updater::Builder::new().build())
38 .setup(|app| {
39 let app_handle = app.handle();
40
41 #[cfg(target_os = "linux")]
43 {
44 glib::set_prgname(Some("Playlite"));
45 glib::set_application_name("Playlite");
46 }
47
48 let log_dir = app_handle
51 .path()
52 .app_log_dir()
53 .expect("Falha ao pegar pasta de log");
54
55 std::fs::create_dir_all(&log_dir).expect("Falha ao criar pasta de dev_logs");
56
57 let _guard = logger::init_logging(log_dir.clone());
58 app.manage(_guard);
59
60 security::init_security(app_handle).expect("Falha ao inicializar sistema de segurança");
63
64 let db_state = database::initialize_databases(app_handle)
67 .expect("Falha ao inicializar bancos de dados");
68
69 app.manage(db_state);
70
71 if let Err(e) = initialize_app(app_handle) {
75 tracing::error!("Erro na inicialização pós-update: {}", e);
76 }
78
79 if let Err(e) = services::cf_aggregator::init_cf_index() {
82 tracing::warn!("CF desativado (fallback CB ativo): {}", e);
83 }
84
85 tracing::info!("Playlite iniciado com sucesso");
87
88 Ok(())
89 })
90 .invoke_handler(tauri::generate_handler![
91 database::init_db,
93 database::backup::export_database,
95 database::backup::import_database,
96 commands::games::add_game,
98 commands::games::get_games,
99 commands::games::get_library_game_details,
100 commands::games::toggle_favorite,
101 commands::games::delete_game,
102 commands::games::update_game,
103 commands::games::update_game_details,
104 commands::wishlist::search_wishlist_game,
106 commands::wishlist::search_wishlist_game_by_features,
107 commands::wishlist::add_to_wishlist,
108 commands::wishlist::get_wishlist,
109 commands::wishlist::remove_from_wishlist,
110 commands::wishlist::check_wishlist_status,
111 commands::wishlist::refresh_prices,
112 commands::wishlist::import_wishlist,
113 commands::wishlist::fetch_wishlist_covers,
114 commands::platforms::scanner::scan_games_folder,
116 commands::platforms::scanner::add_game_from_scan,
117 commands::platforms::scanner::add_games_from_scan,
118 commands::platforms::steam::import_steam_library,
119 commands::platforms::epic::epic_login,
120 commands::platforms::epic::epic_logout,
121 commands::platforms::epic::epic_is_authenticated,
122 commands::platforms::epic::import_epic_games,
123 commands::platforms::heroic::import_heroic_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::enrichment::update_metadata,
143 commands::metadata::get_metadata::fill_missing_metadata,
144 commands::metadata::covers::fetch_missing_covers,
145 commands::metadata::refresh::check_and_refresh_background,
146 commands::metadata::search::get_trending_games,
147 commands::metadata::search::get_upcoming_games,
148 commands::metadata::search::fetch_game_details,
149 commands::metadata::search::get_active_giveaways,
150 commands::metadata::search::get_similar_games,
151 commands::metadata::search::get_game_media,
152 commands::metadata::search::get_profile_similar_games,
153 commands::metadata::pcgamingwiki::get_or_fetch_pcgw_data,
154 commands::metadata::pcgamingwiki::refresh_pcgw_data,
155 commands::metadata::pcgamingwiki::search_pcgw_games,
156 commands::metadata::pcgamingwiki::get_pcgw_scraped_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::recommendation::core::get_user_profile,
166 commands::recommendation::core::recommend_hybrid_library,
167 commands::recommendation::core::recommend_collaborative_library,
168 commands::recommendation::core::recommend_from_library,
169 commands::recommendation::analysis::generate_recommendation_analysis,
170 commands::ai_translation::translate_description,
172 commands::achievements::get_recent_achievements,
174 commands::caches::cleanup_cache,
176 commands::caches::clear_all_cache,
177 commands::caches::get_detailed_cache_stats,
178 commands::system::open_folder,
180 commands::system::open_file,
181 commands::version::get_app_version,
183 commands::version::get_app_version_info,
184 commands::version::is_updater_enabled,
185 services::images::cache_cover_image,
187 services::images::check_local_cover,
188 services::images::clear_cover_cache,
189 commands::subscriptions::get_amazon_luna_catalog,
191 commands::subscriptions::get_game_pass_catalog,
192 commands::subscriptions::get_ea_play_catalog,
193 commands::subscriptions::get_ubisoft_plus_catalog,
194 commands::subscriptions::get_subscription_settings,
195 commands::subscriptions::save_subscription_settings
196 ])
197 .run(tauri::generate_context!())
198 .expect("error while running tauri application");
199}