protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.Main); Button buttonConnect = FindViewById <Button>(Resource.Id.ButtonConnect); buttonConnect.Click += ClickConnect; Button buttonFriends = FindViewById <Button>(Resource.Id.ButtonFriends); buttonFriends.Click += ClickFriends; SteamAlerts.Initialize(this); if (!SteamService.IsRunning()) { Intent steamService = new Intent(this, typeof(SteamService)); StartService(steamService); } UpdateButtons(); SteamService.GetClient().AddHandler(this); }
private void RequestAuthKey(String message) { SteamAlerts.DisableAlerts(); inputAuthKey = new EditText(this); SteamAlerts.ShowInputDialog("Auth key", message, inputAuthKey, ClickSendAuthKey, this); }
public Friend(SteamID steamId) { this.steamId = steamId; this.name = Unknown; this.avatar = Unknown; adapter = new ChatAdapter(this, SteamAlerts.GetContext()); SteamService.GetClient().AddHandler(this); }
public void HandleCallback(CallbackMsg msg) { if (msg.IsType <SteamUser.LoginKeyCallback>()) { GetClient().Friends.SetPersonaState(EPersonaState.Online); Friend.Me = new Friend(GetClient().User.GetSteamID()); Friend.Me.Name = "me"; SteamAlerts.ShowToast("Connected to Steam"); } else if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.OK) { EnableAutoReconnect(); } else { DisableAutoReconnect(); } } else if (msg.IsType <SteamFriends.FriendMsgCallback>()) { SteamFriends.FriendMsgCallback callback = (SteamFriends.FriendMsgCallback)msg; if (callback.EntryType == EChatEntryType.ChatMsg) { Friend friend = Friend.GetFriendBySteamId(callback.Sender.ToString()); if (friend != activeChat) { Intent intent = new Intent(SteamAlerts.GetContext(), typeof(Chat)); intent.SetAction("chat_notification_" + DateTime.Now.Ticks); intent.PutExtra("steam_id", friend.SteamId.ToString()); SteamAlerts.Notification("Message from " + friend.Name, friend.Name + ": " + callback.Message, callback.Message, intent, "steam_id", friend.SteamId.ToString()); SteamAlerts.PlaySound(); SteamAlerts.Vibrate(400); } } } else if (msg.IsType <SteamClient.ConnectCallback>()) { SteamAlerts.Notification("Steam Droid", "Connected to Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null); } else if (msg.IsType <SteamClient.DisconnectCallback>()) { SteamAlerts.Notification("Steam Droid", "Disconnected from Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null); SteamAlerts.ShowToast("Disconnected from Steam"); } }
private void ClickSendAuthKey(object sender, DialogClickEventArgs e) { SteamAlerts.HideInputDialog(); if (inputAuthKey.Text.Length > 0) { Connect(inputAuthKey.Text); } else { RequestAuthKey(); SteamAlerts.ShowAlertDialog("Invalid key", "Please enter a valid auth key", this); } SteamAlerts.EnableAlerts(); }
private void Connect(String authCode) { ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(this); String username = pref.GetString("prefUsername", ""); String password = pref.GetString("prefPassword", ""); if (username.Length > 0 && password.Length > 0) { SteamService.GetClient().Connect(username, password, authCode); SteamAlerts.ShowProgressDialog("Connecting", "Connecting to the Steam servers...", this); } else { SteamAlerts.ShowAlertDialog("Warning", "No valid username or password entered", this); } }
public void HandleCallback(CallbackMsg msg) { if (msg.IsType <SteamClient.ConnectCallback>()) { int retryCount = SteamService.GetClient().GetRetryCount(); String retries = (retryCount > 0) ? " (retry " + retryCount + ")" : ""; SteamAlerts.ShowProgressDialog("Connecting", "Logging in..." + retries, this); } else if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.AccountLogonDenied) { RequestAuthKey(); } else if (callback.Result == EResult.InvalidLoginAuthCode) { InvalidAuthKey(); } else if (callback.Result == EResult.InvalidPassword) { SteamAlerts.ShowAlertDialog("Invalid credentials", "Invalid username or password", this); } else if (callback.Result == EResult.AlreadyLoggedInElsewhere) { SteamAlerts.ShowAlertDialog("Already logged in", "This Steam account is already logged in elsewhere", this); } } else if (msg.IsType <SteamUser.LoggedOffCallback>()) { SteamUser.LoggedOffCallback callback = (SteamUser.LoggedOffCallback)msg; if (callback.Result == EResult.InvalidProtocolVer) { SteamAlerts.ShowAlertDialog("Error", "Invalid protocol version", this); } } UpdateButtons(); }
protected override void OnListItemClick(ListView l, View v, int position, long id) { base.OnListItemClick(l, v, position, id); FriendsAdapter adapter = SteamAdapters.GetFriendsAdapter(); Friend friend = adapter.GetFriendAt(position); if (SteamService.GetClient().Friends.GetPersonaState() == SteamKit2.EPersonaState.Offline) { SteamAlerts.ShowToast("Your state is set to offline"); } else if (friend.State == SteamKit2.EPersonaState.Offline) { SteamAlerts.ShowToast(friend.Name + " is offline"); } else { Intent chatIntent = new Intent(this, typeof(Chat)); chatIntent.PutExtra("steam_id", friend.SteamId.ToString()); StartActivity(chatIntent); } }
/// <summary> /// Processes the callbacks received from the callback thread /// </summary> /// <param name='msg'> /// Message. /// </param> public void ProcessCallback(CallbackMsg msg) { if (msg.IsType <SteamClient.ConnectCallback>()) { user.LogOn(new SteamUser.LogOnDetails() { Username = username, Password = password, AuthCode = authcode }); /* * timeout = TimeoutHandler.Start(10000, () => * { * Disconnect(); * * if (retry < 2) * { * Connect(); * * retry++; * } * else * { * retry = 0; * } * * return null; * });*/ } if (msg.IsType <SteamClient.DisconnectCallback>() || msg.IsType <SteamUser.LoggedOffCallback>()) { loggedIn = false; } if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.OK) { loggedIn = true; authcode = null; retry = 0; /* * if (timeout != null) * { * timeout.Cancel(true); * }*/ /* * Friends.SetPersonaState(EPersonaState.Online); * * Friend.Me = new Friend(User.GetSteamID()); * Friend.Me.Name = "me"; * * SteamAlerts.ShowToast("Connected to Steam"); * SteamAlerts.Notification("SteamDroid", "Connected to Steam", "Connected to Steam", new Android.Content.Intent(SteamAlerts.GetContext(), typeof(App.Main)), null, null); */ } } if (msg.IsType <SteamUser.LoginKeyCallback>()) { Friends.SetPersonaState(EPersonaState.Online); Friend.Me = new Friend(User.GetSteamID()); Friend.Me.Name = "me"; SteamAlerts.ShowToast("Connected to Steam"); SteamAlerts.Notification("SteamDroid", "Connected to Steam", "Connected to Steam", new Android.Content.Intent(SteamAlerts.GetContext(), typeof(App.Main)), null, null); } Push(msg); }