diff --git a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java index c6befcc0..3fd10f00 100644 --- a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java +++ b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_8UnifiedMessages/SampleUnifiedMessages.java @@ -1,16 +1,14 @@ package in.dragonbra.javasteamsamples._8UnifiedMessages; - -import in.dragonbra.javasteam.base.ClientMsgProtobuf; -import in.dragonbra.javasteam.enums.EMsg; import in.dragonbra.javasteam.enums.EResult; -import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserver2.CMsgClientUIMode; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesFriendmessagesSteamclient.CFriendMessages_IncomingMessage_Notification; import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesPlayerSteamclient.*; import in.dragonbra.javasteam.rpc.service.Player; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.SteamUnifiedMessages; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.callback.ServiceMethodNotification; import in.dragonbra.javasteam.steam.handlers.steamunifiedmessages.callback.ServiceMethodResponse; +import in.dragonbra.javasteam.steam.handlers.steamuser.ChatMode; import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails; import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser; import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOffCallback; @@ -127,6 +125,8 @@ private void onConnected(ConnectedCallback callback) { LogOnDetails details = new LogOnDetails(); details.setUsername(user); details.setPassword(pass); + details.setUiMode(EUIMode.Unknown); + details.setChatMode(ChatMode.NEW_STEAM_CHAT); // Set LoginID to a non-zero value if you have another client connected using the same account, // the same private ip, and same public ip. @@ -164,14 +164,6 @@ private void onLoggedOn(LoggedOnCallback callback) { // at this point, we'd be able to perform actions on Steam - // Set our chat mode in order to use unified chat features - ClientMsgProtobuf uiMode = new ClientMsgProtobuf<>(CMsgClientUIMode.class, EMsg.ClientCurrentUIMode); - uiMode.getBody().setUimode(0); - uiMode.getBody().setChatMode(2); - - // Send our ClientCurrentUIMode request - steamClient.send(uiMode); - // first, build our request object, these are autogenerated and can normally be found in the in.dragonbra.javasteam.protobufs.steamclient package CPlayer_GetFavoriteBadge_Request.Builder favoriteBadgeRequest = CPlayer_GetFavoriteBadge_Request.newBuilder(); favoriteBadgeRequest.setSteamid(steamClient.getSteamID().convertToUInt64()); diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt new file mode 100644 index 00000000..23dc48cd --- /dev/null +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/ChatMode.kt @@ -0,0 +1,17 @@ +package `in`.dragonbra.javasteam.steam.handlers.steamuser + +/** + * Represents the chat mode for logging into Steam. + */ +@Suppress("unused") +enum class ChatMode(val mode: Int) { + /** + * The default chat mode. + */ + DEFAULT(0), + + /** + * The chat mode for new Steam group chat. + */ + NEW_STEAM_CHAT(1), +} diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java index 1cc11b09..efbb5ba5 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/LogOnDetails.java @@ -1,6 +1,7 @@ package in.dragonbra.javasteam.steam.handlers.steamuser; import in.dragonbra.javasteam.enums.EOSType; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.steam.authentication.AuthPollResult; import in.dragonbra.javasteam.steam.authentication.SteamAuthentication; import in.dragonbra.javasteam.types.SteamID; @@ -40,6 +41,12 @@ public class LogOnDetails { private String machineName; + private ChatMode chatMode; + + private EUIMode uiMode; + + private boolean isSteamDeck; + public LogOnDetails() { accountInstance = SteamID.DESKTOP_INSTANCE; accountID = 0L; @@ -52,6 +59,10 @@ public LogOnDetails() { envName = System.getenv("HOSTNAME"); } machineName = envName + " (JavaSteam)"; + + chatMode = ChatMode.DEFAULT; + uiMode = EUIMode.Unknown; + isSteamDeck = false; } /** @@ -324,4 +335,58 @@ public String getMachineName() { public void setMachineName(String machineName) { this.machineName = machineName; } + + /** + * Gets the chat mode. + * + * @return the {@link ChatMode} + */ + public ChatMode getChatMode() { + return chatMode; + } + + /** + * Sets the chat mode. + * + * @param chatMode the chat mode {@link ChatMode} + */ + public void setChatMode(ChatMode chatMode) { + this.chatMode = chatMode; + } + + /** + * Gets the ui mode. + * + * @return the {@link EUIMode} + */ + public EUIMode getUiMode() { + return uiMode; + } + + /** + * Sets the ui mode. + * + * @param uiMode the ui mode {@link EUIMode} + */ + public void setUiMode(EUIMode uiMode) { + this.uiMode = uiMode; + } + + /** + * Gets whether this is Steam Deck login. + * + * @return The Steam Deck login value. + */ + public boolean isSteamDeck() { + return isSteamDeck; + } + + /** + * Sets whether this is Steam Deck login. + * + * @param steamDeck The Steam Deck login value. + */ + public void setSteamDeck(boolean steamDeck) { + isSteamDeck = steamDeck; + } } diff --git a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java index 05ddae91..c5d8ad88 100644 --- a/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java +++ b/src/main/java/in/dragonbra/javasteam/steam/handlers/steamuser/SteamUser.java @@ -7,6 +7,7 @@ import in.dragonbra.javasteam.enums.EAccountType; import in.dragonbra.javasteam.enums.EMsg; import in.dragonbra.javasteam.enums.EResult; +import in.dragonbra.javasteam.enums.EUIMode; import in.dragonbra.javasteam.generated.MsgClientLogOnResponse; import in.dragonbra.javasteam.generated.MsgClientLoggedOff; import in.dragonbra.javasteam.generated.MsgClientLogon; @@ -128,6 +129,18 @@ public void logOn(LogOnDetails details) { logon.getBody().setMachineName(details.getMachineName()); logon.getBody().setMachineId(ByteString.copyFrom(HardwareUtils.getMachineID())); + if (details.getChatMode() != ChatMode.DEFAULT) { + logon.getBody().setChatMode(details.getChatMode().getMode()); + } + + if (details.getUiMode() != EUIMode.Unknown) { + logon.getBody().setUiMode(details.getUiMode().code()); + } + + if (details.isSteamDeck()) { + logon.getBody().setIsSteamDeck(true); + } + // steam guard if (!Strings.isNullOrEmpty(details.getAuthCode())) { logon.getBody().setAuthCode(details.getAuthCode()); diff --git a/src/main/steamd/in/dragonbra/javasteam/enums.steamd b/src/main/steamd/in/dragonbra/javasteam/enums.steamd index 746d13d9..26245299 100644 --- a/src/main/steamd/in/dragonbra/javasteam/enums.steamd +++ b/src/main/steamd/in/dragonbra/javasteam/enums.steamd @@ -1661,3 +1661,15 @@ enum ELauncherType SingleApp = 8; GameServer = 9; } + +public enum EUIMode +{ + Unknown = -1; + VGUI = 0; + Tenfoot = 1; + Mobile = 2; + Web = 3; + ClientUI = 4; + MobileChat = 5; + EmbeddedClient = 6; +}