예제 #1
0
        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);
        }
예제 #2
0
        public FriendsAdapter(Context context)
        {
            this.context = context;
            friends      = new List <Friend>();
            inflater     = LayoutInflater.FromContext(context);

            SteamService.GetClient().AddHandler(this);
        }
예제 #3
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);

            EPersonaState state = stateAdapter.GetItem(position);

            SteamService.GetClient().Friends.SetPersonaState(state);
        }
예제 #4
0
        public override bool OnPrepareOptionsMenu(IMenu menu)
        {
            bool connected = (SteamService.GetClient() != null && SteamService.GetClient().LoggedIn);

            menu.GetItem(0).SetEnabled(connected);
            menu.GetItem(1).SetEnabled(connected);

            return(base.OnPrepareOptionsMenu(menu));
        }
예제 #5
0
        public Friend(SteamID steamId)
        {
            this.steamId = steamId;
            this.name    = Unknown;
            this.avatar  = Unknown;

            adapter = new ChatAdapter(this, SteamAlerts.GetContext());

            SteamService.GetClient().AddHandler(this);
        }
예제 #6
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name='message'>
        /// Message.
        /// </param>
        public virtual void SendMessage(String message)
        {
            ChatMessage chatMessage = new ChatMessage(Friend.Me, message);

            adapter.Add(chatMessage);

            SteamService.GetClient().Friends.SendChatMessage(steamId, EChatEntryType.ChatMsg, message);

            adapter.NotifyDataSetChanged();
        }
예제 #7
0
        private void UpdateButtons()
        {
            bool connected = SteamService.GetClient() != null && SteamService.GetClient().LoggedIn;

            Button buttonConnect = FindViewById <Button>(Resource.Id.ButtonConnect);

            buttonConnect.Enabled = !connected;

            Button buttonFriends = FindViewById <Button>(Resource.Id.ButtonFriends);

            buttonFriends.Enabled = connected;
        }
예제 #8
0
            protected override void OnPostExecute(CallbackMsg result)
            {
                base.OnPostExecute(result);

                SteamClient client = SteamService.GetClient().Client;

                if (result != null)
                {
                    client.FreeLastCallback();

                    SteamService.GetClient().ProcessCallback(result);
                }

                new SteamCallback().Execute();
            }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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();
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        /// <summary>
        /// Updates friend attributes
        /// </summary>
        public void Update()
        {
            String name = SteamService.GetClient().Friends.GetFriendPersonaName(steamId);

            if (name.Length > 0)
            {
                this.name = name;
            }

            byte[] hash = SteamService.GetClient().Friends.GetFriendAvatar(steamId);

            if (hash != null)
            {
                String avatar = BitConverter.ToString(hash).Replace("-", "").ToLower();
                if (!avatar.StartsWith("000000"))
                {
                    avatar      = avatar.Substring(0, 2) + "/" + avatar;
                    avatar      = "http://media.steampowered.com/steamcommunity/public/images/avatars/" + avatar + "_medium.jpg";
                    this.avatar = avatar;
                }
            }
        }
예제 #13
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            Steam client = SteamService.GetClient();

            switch (item.ItemId)
            {
            case Resource.Id.button_state_1:
                client.Friends.SetPersonaState(EPersonaState.Online);
                break;

            case Resource.Id.button_state_2:
                client.Friends.SetPersonaState(EPersonaState.Away);
                break;

            case Resource.Id.button_state_3:
                client.Friends.SetPersonaState(EPersonaState.Busy);
                break;

            case Resource.Id.button_state_4:
                client.Friends.SetPersonaState(EPersonaState.Snooze);
                break;

            case Resource.Id.button_state_5:
                client.Friends.SetPersonaState(EPersonaState.Offline);
                break;

            case Resource.Id.button_disconnect:
                SteamService.DisableAutoReconnect();
                client.Disconnect();
                break;

            case Resource.Id.button_settings:
                Intent intentSettings = new Intent(this, typeof(Preferences));
                StartActivity(intentSettings);
                break;
            }
            return(base.OnOptionsItemSelected(item));
        }
예제 #14
0
        private void LoadFriendsList()
        {
            SteamFriends steamFriends = SteamService.GetClient().Friends;

            int count = steamFriends.GetFriendCount();

            for (int i = 0; i < count; i++)
            {
                SteamID steamId = steamFriends.GetFriendByIndex(i);
                Friend  friend  = GetFriendBySteamId(steamId);

                if (friend == null)
                {
                    friend = new Friend(steamId);
                    Add(friend);
                }

                friend.Update();
            }

            friends.Sort();

            NotifyDataSetChanged();
        }
예제 #15
0
            protected override CallbackMsg RunInBackground(params Int32[] parameters)
            {
                CallbackMsg msg = SteamService.GetClient().Client.WaitForCallback(true);

                return(msg);
            }