From b5afc7a0cbb695181781ef534c599005ebb871af Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Fri, 6 Dec 2024 10:39:40 +0200 Subject: [PATCH] fix: build after core update with new features: - add new events and handle them - add new StreamingServer Urls bucket - add Subtitle id field Signed-off-by: Lachezar Lechev --- .../src/commonMain/rust/model/model.rs | 6 +++--- .../src/commonMain/rust/stremio_core_kotlin.rs | 15 ++++++++++----- .../proto/stremio/core/runtime/event.proto | 8 ++++++++ .../proto/stremio/core/types/subtitle.proto | 7 ++++--- stremio-core-protobuf/src/bridge/event.rs | 14 ++++++++++++++ stremio-core-protobuf/src/bridge/subtitle.rs | 2 ++ 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/stremio-core-kotlin/src/commonMain/rust/model/model.rs b/stremio-core-kotlin/src/commonMain/rust/model/model.rs index 855a49e..ac549e4 100644 --- a/stremio-core-kotlin/src/commonMain/rust/model/model.rs +++ b/stremio-core-kotlin/src/commonMain/rust/model/model.rs @@ -18,9 +18,7 @@ use stremio_core::{ }, runtime::Effects, types::{ - api::LinkAuthKey, events::DismissedEventsBucket, library::LibraryBucket, - notifications::NotificationsBucket, profile::Profile, resource::MetaItemPreview, - search_history::SearchHistoryBucket, streams::StreamsBucket, + api::LinkAuthKey, events::DismissedEventsBucket, library::LibraryBucket, notifications::NotificationsBucket, profile::Profile, resource::MetaItemPreview, search_history::SearchHistoryBucket, server_urls::ServerUrlsBucket, streams::StreamsBucket }, Model, }; @@ -56,6 +54,7 @@ impl AndroidModel { profile: Profile, library: LibraryBucket, streams: StreamsBucket, + server_urls: ServerUrlsBucket, notifications: NotificationsBucket, search_history: SearchHistoryBucket, dismissed_events: DismissedEventsBucket, @@ -79,6 +78,7 @@ impl AndroidModel { profile, library, streams, + server_urls, notifications, search_history, dismissed_events, diff --git a/stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs b/stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs index 9c48764..25d3b0e 100644 --- a/stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs +++ b/stremio-core-kotlin/src/commonMain/rust/stremio_core_kotlin.rs @@ -20,14 +20,14 @@ use stremio_core::{ constants::{ DISMISSED_EVENTS_STORAGE_KEY, LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, NOTIFICATIONS_STORAGE_KEY, PROFILE_STORAGE_KEY, SEARCH_HISTORY_STORAGE_KEY, - STREAMS_STORAGE_KEY, + STREAMING_SERVER_URLS_STORAGE_KEY, STREAMS_STORAGE_KEY, }, models::common::Loadable, runtime::{Env, EnvError, Runtime, RuntimeEvent}, types::{ events::DismissedEventsBucket, library::LibraryBucket, notifications::NotificationsBucket, profile::Profile, resource::Stream, search_history::SearchHistoryBucket, - streams::StreamsBucket, + server_urls::ServerUrlsBucket, streams::StreamsBucket, }, }; use stremio_core_protobuf::{FromProtobuf, ToProtobuf}; @@ -67,20 +67,22 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative( let init_result = AndroidEnv::exec_sync(AndroidEnv::init(&env, storage)); match init_result { Ok(_) => { - let storage_result = AndroidEnv::exec_sync(future::try_join3( + let storage_result = AndroidEnv::exec_sync(future::try_join4( future::try_join5( AndroidEnv::get_storage::(PROFILE_STORAGE_KEY), AndroidEnv::get_storage::(LIBRARY_RECENT_STORAGE_KEY), AndroidEnv::get_storage::(LIBRARY_STORAGE_KEY), AndroidEnv::get_storage::(STREAMS_STORAGE_KEY), - AndroidEnv::get_storage::(NOTIFICATIONS_STORAGE_KEY), + AndroidEnv::get_storage::(STREAMING_SERVER_URLS_STORAGE_KEY), ), + AndroidEnv::get_storage::(NOTIFICATIONS_STORAGE_KEY), AndroidEnv::get_storage::(SEARCH_HISTORY_STORAGE_KEY), AndroidEnv::get_storage::(DISMISSED_EVENTS_STORAGE_KEY), )); match storage_result { Ok(( - (profile, recent_bucket, other_bucket, streams, notifications), + (profile, recent_bucket, other_bucket, streams, server_urls_bucket), + notifications, search_history, dismissed_events, )) => { @@ -93,6 +95,8 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative( library.merge_bucket(other_bucket); }; let streams = streams.unwrap_or(StreamsBucket::new(profile.uid())); + let server_urls_bucket = + server_urls_bucket.unwrap_or(ServerUrlsBucket::new::(profile.uid())); let notifications = notifications.unwrap_or(NotificationsBucket::new::< AndroidEnv, >( @@ -106,6 +110,7 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative( profile, library, streams, + server_urls_bucket, notifications, search_history, dismissed_events, diff --git a/stremio-core-protobuf/proto/stremio/core/runtime/event.proto b/stremio-core-protobuf/proto/stremio/core/runtime/event.proto index 06053c2..0349d51 100644 --- a/stremio-core-protobuf/proto/stremio/core/runtime/event.proto +++ b/stremio-core-protobuf/proto/stremio/core/runtime/event.proto @@ -48,6 +48,8 @@ message Event { MagnetParsed magnet_parsed = 37; TorrentParsed torrent_parsed = 38; PlayingOnDevice playing_on_device = 39; + StreamingServerUrlsBucketChanged streaming_server_urls_bucket_changed = 40; + StreamingServerUrlsPushedToStorage streaming_server_urls_pushed_to_storage = 41; Error error = 100; } @@ -173,6 +175,12 @@ message Event { message PlayingOnDevice { required string device = 1; } + message StreamingServerUrlsBucketChanged { + optional string uid = 1; + } + message StreamingServerUrlsPushedToStorage { + optional string uid = 1; + } message Error { required string error = 1; required Event source = 2; diff --git a/stremio-core-protobuf/proto/stremio/core/types/subtitle.proto b/stremio-core-protobuf/proto/stremio/core/types/subtitle.proto index 594684c..ecc25b2 100644 --- a/stremio-core-protobuf/proto/stremio/core/types/subtitle.proto +++ b/stremio-core-protobuf/proto/stremio/core/types/subtitle.proto @@ -5,7 +5,8 @@ package stremio.core.types; option java_package = "com.stremio.core.types.subtitle"; message Subtitle { - required string lang = 1; - required string url = 2; - optional string name = 3; + required string id = 1; + required string lang = 2; + required string url = 3; + optional string name = 4; } diff --git a/stremio-core-protobuf/src/bridge/event.rs b/stremio-core-protobuf/src/bridge/event.rs index 6f55c87..48f8480 100644 --- a/stremio-core-protobuf/src/bridge/event.rs +++ b/stremio-core-protobuf/src/bridge/event.rs @@ -197,6 +197,20 @@ impl ToProtobuf for Event { device: device.to_owned(), }) } + Event::StreamingServerUrlsBucketChanged { uid } => { + runtime::event::Type::StreamingServerUrlsBucketChanged( + runtime::event::StreamingServerUrlsBucketChanged { + uid: uid.to_owned(), + }, + ) + } + Event::StreamingServerUrlsPushedToStorage { uid } => { + runtime::event::Type::StreamingServerUrlsPushedToStorage( + runtime::event::StreamingServerUrlsPushedToStorage { + uid: uid.to_owned(), + }, + ) + } Event::Error { error, source } => { let error = match error { CtxError::API(error) => error.message.to_owned(), diff --git a/stremio-core-protobuf/src/bridge/subtitle.rs b/stremio-core-protobuf/src/bridge/subtitle.rs index f422621..c641e58 100644 --- a/stremio-core-protobuf/src/bridge/subtitle.rs +++ b/stremio-core-protobuf/src/bridge/subtitle.rs @@ -6,6 +6,7 @@ use crate::protobuf::stremio::core::types; impl FromProtobuf for types::Subtitle { fn from_protobuf(&self) -> Subtitles { Subtitles { + id: self.id.clone(), lang: self.lang.to_string(), url: self.url.from_protobuf(), } @@ -18,6 +19,7 @@ impl ToProtobuf> for Subtitles { addon_name: &Option<&String>, ) -> types::Subtitle { types::Subtitle { + id: self.id.clone(), lang: self.lang.to_string(), url: self.url.to_string(), name: addon_name.cloned(),