Exemple #1
0
        public UserViewModel GetUserViewModel(User user)
        {
            UserViewModel toReturn = GetUserViewModel(user.Name);

            if (toReturn != null)
                return toReturn;

            toReturn = _serviceLocator.GetViewModel<UserViewModel>();

            toReturn.IsNotifying = false;

            toReturn.Name = user.Name;
            toReturn.IsAway = user.Status == UserStatus.Inactive || user.IsAfk;
            toReturn.Note = (user.IsAfk) ? user.AfkNote ?? user.Note : user.Note;
            toReturn.Gravatar = CreateGravatarUrl(user.Hash);

            toReturn.IsNotifying = true;

            if (!_users.TryAdd(toReturn.Name, toReturn))
            {
                return GetUserViewModel(user.Name);
            }

            return toReturn;
        }
Exemple #2
0
        private void OnUserActivityChanged(User user)
        {
            UserViewModel userVm = GetUserViewModel(user.Name);
            if (userVm == null)
                return;

            PostOnUi(() => { userVm.IsAway = user.Status == UserStatus.Inactive; });
        }
Exemple #3
0
        public void ProcessNoteChanged(User user)
        {
            UserViewModel userVm = GetUserViewModel(user.Name);

            if (userVm == null)
                return;

            userVm.SetNote(user.IsAfk, user.AfkNote, user.Note);
        }
Exemple #4
0
 public RoomUserViewModel(JabbR.Client.Models.User user, bool isOwner)
 {
     Name         = user.Name;
     Hash         = user.Hash;
     Active       = user.Active;
     Status       = user.Status;
     Note         = user.Note;
     AfkNote      = user.AfkNote;
     IsAfk        = user.IsAfk;
     Flag         = user.Flag;
     Country      = user.Country;
     LastActivity = LastActivity;
     IsOwner      = isOwner;
 }
Exemple #5
0
        private void SendMessagesToRoom(JabbrCommand command, JabbRClient client, User user, string roomName)
        {
            client.GetRoomInfo(roomName).
                ContinueWith(r =>
                                 {
                                     Room info = r.Result;
                                     bool userInRoom = info.Users.Any(usr => usr.Name == user.Name);

                                     if (userInRoom)
                                     {
                                         Send(client,roomName, command.GetMessages());
                                         return;
                                     }

                                     Action leave = () => client.LeaveRoom(roomName);

                                     client.JoinRoom(roomName)
                                         .ContinueWith(j => Send(client, roomName, command.GetMessages(), leave));
                                 });
        }
Exemple #6
0
        private void OnUserTyping(User user, string room)
        {
            InvokeIfInRoom(room, roomVm =>
            {
                UserViewModel userVm = _userService.GetUserViewModel(user);
                if (userVm == null || userVm.IsCurrentUser)
                    return;

                PostOnUi(() => roomVm.SetUserTyping(userVm));
            });
        }
Exemple #7
0
 public JabbrUserTypingMessage(object sender, JabbrConnection jabbr, User user, string roomName)
     : base(sender, jabbr)
 {
     this.User = user;
     this.RoomName = roomName;
 }
Exemple #8
0
 public JabbrUserJoinedMessage(object sender, JabbrConnection jabbr, User user, string roomName, bool isOwner)
     : base(sender, jabbr)
 {
     this.User = user;
     this.RoomName = roomName;
     this.IsOwner = isOwner;
 }
Exemple #9
0
 public JabbrNoteChangedMessage(object sender, JabbrConnection jabbr, User user, string note)
     : base(sender, jabbr)
 {
     this.User = user;
     this.Note = note;
 }
        void OnUserJoined(User user, string room, bool isOwner)
        {
            Trace.Call(user, room, isOwner);

            var chat = (GroupChatModel) GetChat(room, ChatType.Group);
            if (chat == null) {
                return;
            }

            var person = CreatePerson(user.Name);
            lock (chat) {
                if (chat.Persons.ContainsKey(person.ID)) {
            #if LOG4NET
                    Logger.Warn("OnUserJoined(): person already on chat, ignoring...");
            #endif
                    return;
                }
                Session.AddPersonToGroupChat(chat, person);
            }
        }
 void HandleOwnerAdded(JabbR.Client.Models.User user, string roomName)
 {
     Log("OwnerAdded> " + user.Name + " -> " + roomName);
     _messenger.Publish(new JabbrOwnerAddedMessage(this, this, user, roomName));
 }
Exemple #12
0
        private void ClientOnUserJoined(User user, string room, bool isOwner)
        {
            List<string> rooms;
            var isUpdating = true;
            if (!Settings.KnownUsers.TryGetValue(user.Name, out rooms))
            {
                isUpdating = false;
                rooms = new List<string>();
            }

            if (rooms.Contains(room))
            {
                // no need to track them, for some reason we already are
                return;
            }

            rooms.Add(room);

            if (!isUpdating)
            {
                Settings.KnownUsers.TryAdd(user.Name, rooms);
            }
        }
        private void AddUser(User user)
        {
            UserViewModel userVm = _userService.GetUserViewModel(user);

            AddUser(userVm);
        }
Exemple #14
0
        private void UserNoteChanged(User user, string room)
        {
            UserViewModel userVm = GetUserViewModel(user.Name);
            if (userVm == null)
                return;

            PostOnUi(() => userVm.SetNote(user.IsAfk, user.AfkNote, user.Note));
        }
Exemple #15
0
 private void OnUserJoined(User user, string room)
 {
     InvokeIfInRoom(room, roomVm =>
     {
         UserViewModel userVm = _userService.GetUserViewModel(user);
         PostOnUi(() => roomVm.AddUser(userVm));
     });
 }
Exemple #16
0
        private void ClientOnUserLeft(User user, string room)
        {
            List<string> rooms;
            if (!Settings.KnownUsers.TryGetValue(user.Name, out rooms))
            {
                return;
            }

            rooms.Remove(room);

            if (rooms.Count != 0)
            {
                return;
            }

            if (!Settings.KnownUsers.TryRemove(user.Name, out rooms))
            {
                Console.Error.WriteLine("There was an error removing '{0}' from the user list.", user.Name);
            }
        }
Exemple #17
0
        private void OnUsernameChanged(string oldUsername, User user, string arg3)
        {
            UserViewModel userVm = GetUserViewModel(oldUsername);

            if (userVm == null)
                return;

            if (!_users.TryRemove(oldUsername, out userVm))
                return;

            _users.TryAdd(user.Name, userVm);

            PostOnUi(() => { userVm.Name = user.Name; });
        }
 public UserViewModel(JabbR.Client.Models.User user) : base()
 {
     User = user;
 }
 void HandleNoteChanged(JabbR.Client.Models.User user, string note)
 {
     Log("NoteChanged> " + user.Name + " -> " + note);
     _messenger.Publish(new JabbrNoteChangedMessage(this, this, user, note));
 }
 public UserSelectedMessage(object sender, User user)
     : base(sender)
 {
     this.User = user;
 }
 PersonModel CreatePerson(User user)
 {
     return CreatePerson(user.Name);
 }
 void HandleFlagChanged(JabbR.Client.Models.User user, string flag)
 {
     Log("FlagChanged> " + user.Name + " -> " + flag);
     _messenger.Publish(new JabbrFlagChangedMessage(this, this, user, flag));
 }
        void OnUserLeft(User user, string room)
        {
            Trace.Call(user, room);

            var chat = (GroupChatModel) GetChat(room, ChatType.Group);
            if (chat == null) {
                return;
            }

            if (user.Name == Username) {
                Session.RemoveChat(chat);
                return;
            }

            PersonModel person = null;
            if (chat.Persons.TryGetValue(user.Name, out person)) {
                Session.RemovePersonFromGroupChat(chat, person);
            }
        }
 void HandleUserTyping(JabbR.Client.Models.User user, string roomName)
 {
     _messenger.Publish(new JabbrUserTypingMessage(this, this, user, roomName));
 }
Exemple #25
0
 public JabbrUserActivityChangedMessage(object sender, JabbrConnection jabbr, User user)
     : base(sender, jabbr)
 {
     this.User = user;
 }
 void HandleUsernameChanged(string oldUsername, JabbR.Client.Models.User user, string roomName)
 {
     Log("UsernameChanged> " + oldUsername + " -> " + user.Name + " -> " + roomName);
     _messenger.Publish(new JabbrUsernameChangedMessage(this, this, oldUsername, user, roomName));
 }
Exemple #27
0
 public JabbrUsernameChangedMessage(object sender, JabbrConnection jabbr, string oldUsername, User user, string roomName)
     : base(sender, jabbr)
 {
     this.User = user;
     this.RoomName = roomName;
     this.OldUsername = oldUsername;
 }
 void HandleUserLeft(JabbR.Client.Models.User user, string roomName)
 {
     Log("UserLeft> " + user.Name + " -> " + roomName);
     _messenger.Publish(new JabbrUserLeftMessage(this, this, user, roomName));
 }
Exemple #29
0
 public JabbrFlagChangedMessage(object sender, JabbrConnection jabbr, User user, string flag)
     : base(sender, jabbr)
 {
     this.User = user;
     this.Flag = flag;
 }
 void HandleUserJoined(JabbR.Client.Models.User user, string roomName, bool isOwner)
 {
     Log("UserJoined> " + user.Name + " -> " + roomName + " -> " + isOwner);
     _messenger.Publish(new JabbrUserJoinedMessage(this, this, user, roomName, isOwner));
 }
Exemple #31
0
        private void OnUserLeft(User user, string room)
        {
            InvokeIfInRoom(room, roomVm =>
            {
                UserViewModel userVm = _userService.GetUserViewModel(user.Name);
                if (userVm == null)
                    return;

                PostOnUi(() => roomVm.UserLeft(userVm));
            });
        }
 void HandleUserActivityChanged(JabbR.Client.Models.User user)
 {
     //Log ("UserActivityChanged> " + user.Name);
     //_messenger.Publish(new JabbrUserActivityChangedMessage(this, this, user));
 }
Exemple #33
0
 private void OnOwnerAdded(User user, string room)
 {
     InvokeIfInRoom(room, roomVm => PostOnUi(() => roomVm.AddOwner(user.Name)));
 }
Exemple #34
0
        private void OnGravatarChanged(User user, string room)
        {
            UserViewModel userVm = GetUserViewModel(user.Name);
            if (userVm == null)
                return;

            PostOnUi(() => userVm.Gravatar = CreateGravatarUrl(user.Hash));
        }