Skip to content

Commit

Permalink
Merge pull request #194 from oxters168/steam-family-group
Browse files Browse the repository at this point in the history
Fix family shared games
  • Loading branch information
oxters168 authored Mar 2, 2025
2 parents ac7985a + 92a24a1 commit be22570
Show file tree
Hide file tree
Showing 26 changed files with 634 additions and 656 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/app-release-signed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
distribution: 'temurin'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pluvia-pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build APK release variant, unsigned.
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
minSdk = 29
targetSdk = 34

versionCode = 6
versionCode = 7
versionName = "1.3.2"

buildConfigField("boolean", "GOLD", "false")
Expand Down Expand Up @@ -159,7 +159,7 @@ dependencies {
// JavaSteam
val localBuild = false // Change to 'true' needed when building JavaSteam manually
if (localBuild) {
implementation(files("../../../IntelliJ/JavaSteam/build/libs/javasteam-1.6.0-SNAPSHOT.jar"))
implementation(files("../../../IntelliJ/JavaSteam/build/libs/javasteam-1.6.1-SNAPSHOT.jar"))
implementation(libs.bundles.steamkit.dev)
} else {
implementation(libs.steamkit) {
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/OxGames/Pluvia/data/LibraryItem.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.OxGames.Pluvia.data

import com.OxGames.Pluvia.Constants

/**
* Data class for the Library list
*/
Expand All @@ -8,7 +10,8 @@ data class LibraryItem(
val appId: Int = 0,
val name: String = "",
val iconHash: String = "",
val isShared: Boolean = false,
) {
val clientIconUrl: String
get() = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/$appId/$iconHash.ico"
get() = Constants.Library.ICON_URL + "$appId/$iconHash.ico"
}
17 changes: 9 additions & 8 deletions app/src/main/java/com/OxGames/Pluvia/data/SteamApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import com.OxGames.Pluvia.enums.ControllerSupport
import com.OxGames.Pluvia.enums.Language
import com.OxGames.Pluvia.enums.OS
import com.OxGames.Pluvia.enums.ReleaseState
import com.OxGames.Pluvia.service.SteamService.Companion.INVALID_APP_ID
import com.OxGames.Pluvia.service.SteamService.Companion.INVALID_PKG_ID
import com.OxGames.Pluvia.service.SteamService
import `in`.dragonbra.javasteam.enums.ELicenseFlags
import java.util.EnumSet

@Entity("steam_app")
data class SteamApp(
@PrimaryKey val id: Int,
// val receiveIndex: Int,
@ColumnInfo("package_id")
val packageId: Int = INVALID_PKG_ID,
val packageId: Int = SteamService.INVALID_PKG_ID,
@ColumnInfo("owner_account_id")
val ownerAccountId: Int = -1,
val ownerAccountId: List<Int> = emptyList(),
@ColumnInfo("license_flags")
val licenseFlags: EnumSet<ELicenseFlags> = EnumSet.noneOf(ELicenseFlags::class.java),
@ColumnInfo("received_pics")
val receivedPICS: Boolean = false,
@ColumnInfo("last_change_number")
Expand Down Expand Up @@ -73,7 +74,7 @@ data class SteamApp(

// Extended
@ColumnInfo("demo_of_app_id")
val demoOfAppId: Int = INVALID_APP_ID,
val demoOfAppId: Int = SteamService.INVALID_APP_ID,
@ColumnInfo("developer")
val developer: String = "",
@ColumnInfo("publisher")
Expand All @@ -89,9 +90,9 @@ data class SteamApp(
@ColumnInfo("is_free_app")
val isFreeApp: Boolean = false,
@ColumnInfo("dlc_for_app_id")
val dlcForAppId: Int = INVALID_APP_ID,
val dlcForAppId: Int = SteamService.INVALID_APP_ID,
@ColumnInfo("must_own_app_to_purchase")
val mustOwnAppToPurchase: Int = INVALID_APP_ID,
val mustOwnAppToPurchase: Int = SteamService.INVALID_APP_ID,
@ColumnInfo("dlc_available_on_store")
val dlcAvailableOnStore: Boolean = false,
@ColumnInfo("optional_dlc")
Expand Down
42 changes: 23 additions & 19 deletions app/src/main/java/com/OxGames/Pluvia/data/SteamLicense.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,19 @@ import androidx.room.PrimaryKey
import `in`.dragonbra.javasteam.enums.ELicenseFlags
import `in`.dragonbra.javasteam.enums.ELicenseType
import `in`.dragonbra.javasteam.enums.EPaymentMethod
import `in`.dragonbra.javasteam.steam.handlers.steamapps.License
import java.util.Date
import java.util.EnumSet

/**
* Data class to store [License] to room database,
* with the addition of [appIds] and [depotIds] that the license pertains to.
*/
@Entity("steam_license")
data class SteamLicense(
@PrimaryKey val id: Int,
@ColumnInfo("owner_account_id")
val ownerAccountId: Int,
@PrimaryKey val packageId: Int,
@ColumnInfo("last_change_number")
val lastChangeNumber: Int,
@ColumnInfo("access_token")
val accessToken: Long,
@ColumnInfo("territory_code")
val territoryCode: Int,
@ColumnInfo("license_flags")
val licenseFlags: EnumSet<ELicenseFlags>,
@ColumnInfo("license_type")
val licenseType: ELicenseType,
@ColumnInfo("payment_method")
val paymentMethod: EPaymentMethod,
@ColumnInfo("purchase_country_code")
val purchaseCountryCode: String,
@ColumnInfo("app_ids")
var appIds: List<Int> = emptyList(),
@ColumnInfo("depot_ids")
var depotIds: List<Int> = emptyList(),
@ColumnInfo("time_created")
val timeCreated: Date,
@ColumnInfo("time_next_process")
Expand All @@ -40,8 +27,25 @@ data class SteamLicense(
val minuteLimit: Int,
@ColumnInfo("minutes_used")
val minutesUsed: Int,
@ColumnInfo("payment_method")
val paymentMethod: EPaymentMethod,
@ColumnInfo("license_flags")
val licenseFlags: EnumSet<ELicenseFlags>,
@ColumnInfo("purchase_code")
val purchaseCode: String,
@ColumnInfo("license_type")
val licenseType: ELicenseType,
@ColumnInfo("territory_code")
val territoryCode: Int,
@ColumnInfo("access_token")
val accessToken: Long,
@ColumnInfo("owner_account_id")
val ownerAccountId: List<Int>,
@ColumnInfo("master_package_id")
val masterPackageID: Int,

@ColumnInfo("app_ids")
var appIds: List<Int> = emptyList(),
@ColumnInfo("depot_ids")
var depotIds: List<Int> = emptyList(),
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/OxGames/Pluvia/db/PluviaDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const val DATABASE_NAME = "pluvia.db"
FriendMessage::class,
Emoticon::class,
],
version = 2,
version = 3,
exportSchema = false, // Should export once stable.
)
@TypeConverters(
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/com/OxGames/Pluvia/db/dao/SteamAppDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,36 @@ import kotlinx.coroutines.flow.Flow
interface SteamAppDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(vararg app: SteamApp)
suspend fun insert(apps: SteamApp)

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(apps: List<SteamApp>)

@Update
suspend fun update(app: SteamApp)

@Query(
"SELECT * FROM steam_app " +
"WHERE id != 480 " + // Actively filter out Spacewar
"AND owner_account_id = :ownerId " +
// "AND (owner_account_id IN (:ownerIds) OR license_flags & :borrowedCode = :borrowedCode) " +
"AND package_id != :invalidPkgId " +
"AND type != 0 " +
"ORDER BY LOWER(name)",
)
fun getAllOwnedApps(
ownerId: Int,
// ownerIds: List<Int>,
invalidPkgId: Int = INVALID_PKG_ID,
// borrowedCode: Int = ELicenseFlags.Borrowed.code(),
): Flow<List<SteamApp>>

@Query("SELECT * FROM steam_app WHERE received_pics = 0 AND package_id != :invalidPkgId AND owner_account_id = :ownerId")
fun getAllOwnedAppsWithoutPICS(
ownerId: Int,
invalidPkgId: Int = INVALID_PKG_ID,
): Flow<List<SteamApp>>
): List<SteamApp>

@Query("SELECT * FROM steam_app WHERE id = :appId")
fun findApp(appId: Int): Flow<SteamApp?>
suspend fun findApp(appId: Int): SteamApp?

@Query("DELETE from steam_app")
suspend fun deleteAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ interface SteamFriendDao {
@Query("SELECT * FROM steam_friend ORDER BY name ASC")
fun getAllFriendsFlow(): Flow<List<SteamFriend>>

@Query("SELECT * FROM steam_friend WHERE game_app_id > 0")
suspend fun findFriendsInGame(): List<SteamFriend>

@Query("SELECT * FROM steam_friend WHERE id = :id")
fun findFriendFlow(id: Long): Flow<SteamFriend?>

@Query("SELECT * FROM steam_friend WHERE id = :id")
fun findFriend(id: Long): SteamFriend?
suspend fun findFriend(id: Long): SteamFriend?

@Query("SELECT * FROM steam_friend WHERE name LIKE '%' || :name || '%' OR nickname LIKE '%' || :name || '%'")
fun findFriendFlow(name: String): Flow<List<SteamFriend>>
Expand Down
19 changes: 12 additions & 7 deletions app/src/main/java/com/OxGames/Pluvia/db/dao/SteamLicenseDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@ import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.OxGames.Pluvia.data.SteamLicense
import kotlinx.coroutines.flow.Flow

@Dao
interface SteamLicenseDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(vararg license: SteamLicense)
suspend fun insert(license: List<SteamLicense>)

@Update
suspend fun update(license: SteamLicense)

@Query("UPDATE steam_license SET app_ids = :appIds WHERE id = :packageId")
@Query("UPDATE steam_license SET app_ids = :appIds WHERE packageId = :packageId")
suspend fun updateApps(packageId: Int, appIds: List<Int>)

@Query("UPDATE steam_license SET depot_ids = :depotIds WHERE id = :packageId")
@Query("UPDATE steam_license SET depot_ids = :depotIds WHERE packageId = :packageId")
suspend fun updateDepots(packageId: Int, depotIds: List<Int>)

@Query("SELECT * FROM steam_license")
fun getAllLicenses(): Flow<List<SteamLicense>>
suspend fun getAllLicenses(): List<SteamLicense>

@Query("SELECT * FROM steam_license WHERE id = :packageId")
fun findLicense(packageId: Int): Flow<SteamLicense?>
@Query("SELECT * FROM steam_license WHERE packageId = :packageId")
suspend fun findLicense(packageId: Int): SteamLicense?

@Query("SELECT * FROM steam_license WHERE packageId NOT IN (:packageIds)")
suspend fun findStaleLicences(packageIds: List<Int>): List<SteamLicense>

@Query("DELETE FROM steam_license WHERE packageId IN (:packageIds)")
suspend fun deleteStaleLicenses(packageIds: List<Int>)

@Query("DELETE from steam_license")
suspend fun deleteAll()
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/OxGames/Pluvia/events/SteamEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ sealed interface SteamEvent<T> : Event<T> {
data class PersonaStateReceived(val persona: SteamFriend) : SteamEvent<Unit>
data class QrAuthEnded(val success: Boolean, val message: String? = null) : SteamEvent<Unit>
data class QrChallengeReceived(val challengeUrl: String) : SteamEvent<Unit>
data object AppInfoReceived : SteamEvent<Unit>

// data object AppInfoReceived : SteamEvent<Unit>
data object ForceCloseApp : SteamEvent<Unit>
data object Disconnected : SteamEvent<Unit>
data object RemotelyDisconnected : SteamEvent<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ object SteamAutoCloud {
}
}

withTimeout(SteamService.responseBodyTimeout) {
withTimeout(SteamService.responseTimeout) {
if (fileDownloadInfo.fileSize != fileDownloadInfo.rawFileSize) {
response.body?.byteStream()?.use { inputStream ->
ZipInputStream(inputStream).use { zipInput ->
Expand Down
Loading

0 comments on commit be22570

Please sign in to comment.