Skip to content

Commit

Permalink
Revert "chore: update deps and change edition to 2021"
Browse files Browse the repository at this point in the history
This reverts commit 61d07d4.
  • Loading branch information
elpiel committed Aug 4, 2023
1 parent 61d07d4 commit 48e43cb
Show file tree
Hide file tree
Showing 10 changed files with 1,130 additions and 769 deletions.
1,700 changes: 1,055 additions & 645 deletions Cargo.lock

Large diffs are not rendered by default.

78 changes: 36 additions & 42 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
name = "stremio-core-android"
version = "1.1.0"
authors = ["Smart Code OOD"]
edition = "2021"
resolver = "2"
edition = "2018"

[lib]
crate_type = ["staticlib", "dylib"]
Expand All @@ -14,50 +13,45 @@ lto = true
opt-level = 3

[dependencies]
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "development", features = [
"derive",
"analytics",
"env-future-send",
] }
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "development", features = ["env-future-send"] }
stremio-derive = { git = "https://github.com/Stremio/stremio-core", branch = "development" }
stremio-analytics = { git = "https://github.com/Stremio/stremio-core", branch = "development" }
stremio-watched-bitfield = { git = "https://github.com/Stremio/stremio-core", branch = "development" }
serde = "1.0"
serde_json = "1.0"
futures = "0.3"
http = "0.2"
url = { version = "2.4", features = ["serde"] }
percent-encoding = "2.1"
serde = "1.0.*"
serde_json = "1.0.*"
futures = "0.3.*"
http = "0.2.*"
url = { version = "2.2.*", features = ["serde"] }
percent-encoding = "2.1.*"
chrono = "0.4.*"
semver = { version = "1", features = ["serde"] }
hex = "0.4"
flate2 = "1.0"
either = "1.6"
lazy_static = "1.4"
enclose = "1.1"
itertools = "0.11"
strum = { version = "0.25", features = ["derive"] }
boolinator = "2.4"
Inflector = "0.11"
getrandom = "0.2"
cfg-if = "1"
serde_path_to_error = "0.1"
# TODO: Updating the dependency requires changes to jni_ext
jni = "0.19"
base64 = "0.13.*"
hex = "0.4.*"
flate2 = "1.0.*"
either = "1.6.*"
lazy_static = "1.4.*"
enclose = "1.1.*"
itertools = "0.10.*"
strum = "0.22.*"
strum_macros = "0.22.*"
boolinator = "2.4.*"
Inflector = "0.11.*"
getrandom = "0.2.*"
cfg-if = "0.1.*"
auto_impl = "0.5.*"
serde_path_to_error = "0.1.*"
jni = "0.19.*"
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "sync"] }
openssl = { version = "0.10", features = ["vendored"] }
# bytes = "1.1"
prost = "0.11"
prost-types = "0.11"
http-cache-reqwest = "0.11"
reqwest-middleware = "0.2"
once_cell = "1"
tokio = { version = "1.12.*", features = ["rt", "rt-multi-thread"] }
openssl = { version = "0.10.*", features = ["vendored"] }
bytes = "1.1.0"
prost = "0.10.4"
prost-types = "0.11.9"
http-cache-reqwest = "0.4.5"
reqwest-middleware = "0.1.6"
once_cell = "1.12.0"

[build-dependencies]
prost-build = "0.11"
protox = "0.4"
prost-build = "0.11.9"
protox = "0.3.3"
glob = "0.3.0"

# [patch.'https://github.com/Stremio/stremio-core']

# stremio-core = { path = "../core" }
# stremio-watched-bitfield = { path = "../core/stremio-watched-bitfield" }
6 changes: 0 additions & 6 deletions src/commonMain/rust/bridge/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ impl ToProtobuf<runtime::Event, ()> for Event {
runtime::event::LibraryItemsPushedToStorage { ids: ids.clone() },
)
}
Event::StreamsPushedToStorage { uid } => {
todo!()
}
Event::NotificationsPushedToStorage { ids } => {
todo!()
}
Event::UserPulledFromAPI { uid } => {
runtime::event::Type::UserPulledFromApi(runtime::event::UserPulledFromApi {
uid: uid.clone(),
Expand Down
34 changes: 10 additions & 24 deletions src/commonMain/rust/bridge/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,18 @@ impl
Option<&ResourceRequest>,
),
) -> types::Stream {
// in calls that have None for ctx this would panic if we don't set it to default.
let settings = ctx
.map(|ctx| ctx.profile.settings.to_owned())
.unwrap_or_default();

let deep_links = match (stream_request, meta_request) {
(Some(stream_request), Some(meta_request)) => {
// when https://github.com/Stremio/stremio-core/pull/490 is merged:
// StreamDeepLinks::from((self, *stream_request, *meta_request, &settings))
StreamDeepLinks::from((
self,
*stream_request,
*meta_request,
&ctx.map(|ctx| ctx.profile.settings.streaming_server_url.clone()),
&settings,
))
}
// when https://github.com/Stremio/stremio-core/pull/490 is merged:
// _ => StreamDeepLinks::from((self, &settings)),
_ => StreamDeepLinks::from((
let streaming_server_url =
ctx.map(|ctx| ctx.profile.settings.streaming_server_url.to_owned());
let deep_links = if stream_request.is_some() && meta_request.is_some() {
StreamDeepLinks::from((
self,
&ctx.map(|ctx| ctx.profile.settings.streaming_server_url.clone()),
&settings,
)),
stream_request.unwrap(),
meta_request.unwrap(),
&streaming_server_url,
))
} else {
StreamDeepLinks::from((self, &streaming_server_url))
};

types::Stream {
name: self.name.to_owned().or_else(|| addon_name.cloned()),
description: self.description.clone(),
Expand Down
35 changes: 14 additions & 21 deletions src/commonMain/rust/env/env.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::{
collections::HashMap,
os::raw::{c_char, c_int},
sync::{LockResult, RwLock, RwLockReadGuard},
};

use crate::env::{fetch, AndroidEvent, KotlinClassName, Storage};
use crate::model::AndroidModel;
use chrono::{DateTime, Utc};
use futures::{Future, TryFutureExt};
use http::Request;
Expand All @@ -12,19 +8,18 @@ use jni::JNIEnv;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::HashMap;
#[cfg(debug_assertions)]
use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::sync::{LockResult, RwLock, RwLockReadGuard};
use stremio_analytics::Analytics;
use stremio_core::models::ctx::Ctx;
use stremio_core::models::streaming_server::StreamingServer;
use stremio_core::runtime::msg::Event;
use stremio_core::runtime::{Env, EnvError, EnvFuture, EnvFutureExt, TryEnvFuture};
use strum::IntoEnumIterator;

use stremio_core::{
analytics::Analytics,
models::{ctx::Ctx, streaming_server::StreamingServer},
runtime::{msg::Event, Env, EnvError, EnvFuture, EnvFutureExt, TryEnvFuture},
};

use crate::{
env::{fetch, AndroidEvent, KotlinClassName, Storage},
model::AndroidModel,
};

const INSTALLATION_ID_STORAGE_KEY: &str = "installation_id";
#[cfg(debug_assertions)]
const LOG_DEBUG_PRIORITY: i32 = 3;
Expand Down Expand Up @@ -213,11 +208,9 @@ impl Env for AndroidEnv {
}
#[cfg(debug_assertions)]
fn log(message: String) {
use std::ffi::CString;
let tag = CString::new(LOG_TAG).unwrap();
let message = CString::new(message).unwrap();

unsafe {
let tag = CString::new(LOG_TAG).unwrap();
let message = CString::new(message).unwrap();
__android_log_write(LOG_DEBUG_PRIORITY as c_int, tag.as_ptr(), message.as_ptr());
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/commonMain/rust/env/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::time::Duration;
use futures::future::Either;
use futures::{future, TryFutureExt};
use http::{Method, Request};
use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache, HttpCacheOptions};
use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache};
use once_cell::sync::OnceCell;
use reqwest::{Body, Client};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
Expand Down Expand Up @@ -42,12 +42,9 @@ pub fn fetch<IN: Serialize + Send + 'static, OUT: for<'de> Deserialize<'de> + Se
.with(Cache(HttpCache::<CACacheManager> {
mode: CacheMode::Default,
manager: CACacheManager {
path: env::temp_dir().join("http-cacache"),
},
options: HttpCacheOptions {
cache_options: None,
cache_key: None,
path: env::temp_dir().display().to_string() + "/http-cacache",
},
options: None,
}))
.build()
})
Expand Down
3 changes: 2 additions & 1 deletion src/commonMain/rust/env/kotlin_class_name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::TryFrom;
use std::hash::Hash;
use strum::{IntoEnumIterator, EnumIter};
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[derive(Clone, PartialEq, Eq, Hash, EnumIter)]
#[allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/commonMain/rust/model/addons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use stremio_core::runtime::{Effects, Env, UpdateWithCtx};
use stremio_core::types::addon::DescriptorPreview;
use stremio_core::types::profile::Profile;

#[derive(Default, Clone)]
#[derive(Default)]
pub struct AddonsWithFilters {
pub remote_addons: CatalogWithFilters<DescriptorPreview>,
pub installed_addons: InstalledAddonsWithFilters,
Expand Down
14 changes: 5 additions & 9 deletions src/commonMain/rust/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ use stremio_core::models::streaming_server::StreamingServer;
use stremio_core::runtime::Effects;
use stremio_core::types::api::LinkAuthKey;
use stremio_core::types::library::LibraryBucket;
use stremio_core::types::notifications::NotificationsBucket;
use stremio_core::types::profile::Profile;
use stremio_core::types::resource::MetaItemPreview;
use stremio_core::types::streams::StreamsBucket;
use stremio_core::Model;
use stremio_derive::Model;

use crate::bridge::ToProtobuf;
use crate::env::AndroidEnv;
use crate::model::AddonsWithFilters;

#[derive(Model, Clone)]
#[derive(Model)]
#[model(AndroidEnv)]
pub struct AndroidModel {
pub ctx: Ctx,
Expand All @@ -42,12 +40,10 @@ pub struct AndroidModel {
}

impl AndroidModel {
pub fn new(profile: Profile, library: LibraryBucket, streams: StreamsBucket, notifications: NotificationsBucket) -> (AndroidModel, Effects) {
pub fn new(profile: Profile, library: LibraryBucket) -> (AndroidModel, Effects) {
let ctx = Ctx::new(profile, library);
let (continue_watching_preview, continue_watching_preview_effects) =
ContinueWatchingPreview::new(&library, &notifications);

let ctx = Ctx::new(profile, library, streams, notifications);

ContinueWatchingPreview::new(&ctx.library);
let (discover, discover_effects) = CatalogWithFilters::<MetaItemPreview>::new(&ctx.profile);
let (library_, library_effects) = LibraryWithFilters::<NotRemovedFilter>::new(&ctx.library);
let (library_by_type, library_by_type_effects) = LibraryByType::<NotRemovedFilter>::new();
Expand Down
18 changes: 4 additions & 14 deletions src/commonMain/rust/stremio_core_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ use jni::{JNIEnv, JavaVM};
use lazy_static::lazy_static;
use prost::Message;
use stremio_core::constants::{
LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, NOTIFICATIONS_STORAGE_KEY,
PROFILE_STORAGE_KEY, STREAMS_STORAGE_KEY,
LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, PROFILE_STORAGE_KEY,
};
use stremio_core::models::common::Loadable;
use stremio_core::runtime::{Env, EnvError, Runtime, RuntimeEvent};
use stremio_core::types::library::LibraryBucket;
use stremio_core::types::notifications::NotificationsBucket;
use stremio_core::types::profile::Profile;
use stremio_core::types::resource::Stream;
use stremio_core::types::streams::StreamsBucket;

use crate::bridge::{FromProtobuf, ToJNIByteArray, ToProtobuf};
use crate::env::{AndroidEnv, AndroidEvent, KotlinClassName};
Expand Down Expand Up @@ -58,15 +55,13 @@ 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_join5(
let storage_result = AndroidEnv::exec_sync(future::try_join3(
AndroidEnv::get_storage::<Profile>(PROFILE_STORAGE_KEY),
AndroidEnv::get_storage::<LibraryBucket>(LIBRARY_RECENT_STORAGE_KEY),
AndroidEnv::get_storage::<LibraryBucket>(LIBRARY_STORAGE_KEY),
AndroidEnv::get_storage::<StreamsBucket>(STREAMS_STORAGE_KEY),
AndroidEnv::get_storage::<NotificationsBucket>(NOTIFICATIONS_STORAGE_KEY),
));
match storage_result {
Ok((profile, recent_bucket, other_bucket, streams, notifications)) => {
Ok((profile, recent_bucket, other_bucket)) => {
let profile = profile.unwrap_or_default();
let mut library = LibraryBucket::new(profile.uid(), vec![]);
if let Some(recent_bucket) = recent_bucket {
Expand All @@ -75,12 +70,7 @@ pub unsafe extern "C" fn Java_com_stremio_core_Core_initializeNative(
if let Some(other_bucket) = other_bucket {
library.merge_bucket(other_bucket);
};
let streams = streams.unwrap_or(StreamsBucket::new(profile.uid()));
let notifications = notifications.unwrap_or(
NotificationsBucket::new::<AndroidEnv>(profile.uid(), vec![]),
);
let (model, effects) =
AndroidModel::new(profile, library, streams, notifications);
let (model, effects) = AndroidModel::new(profile, library);
let (runtime, rx) = Runtime::<AndroidEnv, _>::new(
model,
effects.into_iter().collect::<Vec<_>>(),
Expand Down

0 comments on commit 48e43cb

Please sign in to comment.