Skip to content

Commit

Permalink
Add Chat and Ui modes to LogOnDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
LossyDragon committed Jul 29, 2024
1 parent 1aa5e4a commit 3f114fa
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
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.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.UiMode;
import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOffCallback;
import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOnCallback;
import in.dragonbra.javasteam.steam.steamclient.SteamClient;
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(UiMode.DEFAULT);
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
Expand Up @@ -40,6 +40,10 @@ public class LogOnDetails {

private String machineName;

private ChatMode chatMode;

private UiMode uiMode;

public LogOnDetails() {
accountInstance = SteamID.DESKTOP_INSTANCE;
accountID = 0L;
Expand All @@ -52,6 +56,9 @@ public LogOnDetails() {
envName = System.getenv("HOSTNAME");
}
machineName = envName + " (JavaSteam)";

chatMode = ChatMode.DEFAULT;
uiMode = UiMode.DEFAULT;
}

/**
Expand Down Expand Up @@ -324,4 +331,40 @@ 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 UiMode}
*/
public UiMode getUiMode() {
return uiMode;
}

/**
* Sets the ui mode.
*
* @param uiMode the ui mode {@link UiMode}
*/
public void setUiMode(UiMode uiMode) {
this.uiMode = uiMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ 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() != UiMode.DEFAULT) {
logon.getBody().setUiMode(details.getUiMode().getMode());
}

// steam guard
if (!Strings.isNullOrEmpty(details.getAuthCode())) {
logon.getBody().setAuthCode(details.getAuthCode());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package `in`.dragonbra.javasteam.steam.handlers.steamuser

/**
* Represents the ui mode for logging into Steam.
*/
@Suppress("unused")
enum class UiMode(val mode: Int) {
/**
* The default ui mode
*/
DEFAULT(0),

/**
* Big Picture ui mode.
*/
BIG_PICTURE(1),

/**
* Mobile (phone) ui mode.
*/
MOBILE(2),
}

0 comments on commit 3f114fa

Please sign in to comment.