Skip to content

Commit

Permalink
Merge pull request #262 from LossyDragon/chat-ui-mode
Browse files Browse the repository at this point in the history
Add ChatMode and UiMode to LogOnDetails
  • Loading branch information
LossyDragon authored Aug 7, 2024
2 parents 1aa5e4a + 139a21d commit 1a4d2f6
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<CMsgClientUIMode.Builder> 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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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),
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -52,6 +59,10 @@ public LogOnDetails() {
envName = System.getenv("HOSTNAME");
}
machineName = envName + " (JavaSteam)";

chatMode = ChatMode.DEFAULT;
uiMode = EUIMode.Unknown;
isSteamDeck = false;
}

/**
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
12 changes: 12 additions & 0 deletions src/main/steamd/in/dragonbra/javasteam/enums.steamd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 1a4d2f6

Please sign in to comment.