Inheritance: INotifyPropertyChanged
        private void HandleCollectionChanges(Client client, NotifyCollectionChangedEventArgs args, ObservableCollection<Interlocutor> actualCollection, ObservableCollection<object> nullCollection)
        {
            if (actualCollection.Count == 0)
            {
                nullCollection.Clear();
                nullCollection.Add(new NullInterlocutor(client));
                return;
            }
            var nullInterlocutor = nullCollection.OfType<NullInterlocutor>().FirstOrDefault();
            if (nullInterlocutor != null)
            {
                nullCollection.Remove(nullInterlocutor);
            }

            if (args.OldItems != null)
            {
                foreach (var oldItem in args.OldItems)
                {
                    nullCollection.Remove(oldItem);
                }
            }

            if (args.NewItems != null)
            {
                foreach (var newItem in args.NewItems)
                {
                    nullCollection.Insert(actualCollection.IndexOf((Interlocutor) newItem), newItem);
                }
            }
        }
 private void SubscribeClient(Client client)
 {
     var presenceListener = new SingleClientPresenceListener(client);
     _presenceListeners.Add(client, presenceListener);
     presenceListener.PresenceReceived += PresenceListenerOnPresenceReceived;
     presenceListener.StartListen();
 }
Exemple #3
0
 public RosterObesrver(Client client, XmppClientConnection connection)
 {
     _dispatcher = Dispatcher.CurrentDispatcher;
     _connection = connection;
     _listHandler = new RosterListHandler(client);
     _itemHandler = new RosterItemHandler(client);
 }
Exemple #4
0
 public ClientNodeViewModel(Client client)
 {
     Model = client;
     Context = SessionModel.GetClientContext(client);
     ActiveResources = new ObservableCollection<IClientResource>();
     ResourcesManager = CreateResourceManager();
     SetCommands();
 }
Exemple #5
0
 public void RemoveClient(Client client)
 {
     EventBus.Publish(new ClientRemovingEvent
     {
         ClientId = client.Id
     });
     Account.XmppClients.Remove(client);
 }
Exemple #6
0
 public ClientContext(Client client)
 {
     Client = client;
     _connection = AppServices
             .Get<IConnectionManager>()
             .GetOrCreateConnection(Client)
             .Connection;
 }
Exemple #7
0
        public ClientConnection(Client client)
        {
            _client = client;

            SetRosterObsererver();
            SetPresenceObserver();
            SetDiscoInfo();
            _provider = new XmppClientMessageProvider(this);
        }
Exemple #8
0
 private static Client InitClient(IClientInfo clientInfo)
 {
     var client = new Client();
     client.Id = Guid.NewGuid();
     client.Login = clientInfo.Login;
     client.Server = clientInfo.Server;
     client.Password = clientInfo.Password;
     return client;
 }
 public ContactEditorViewModel(Client client = null)
 {
     var modelContext = AppServices.Get<IModelContext>();
     Clients = new ObservableCollection<Client>(modelContext.Clients);
     Contact = new ContactInfo();
     SetCommands();
     HandleChanges();
     SelectedClient = client ?? Clients.FirstOrDefault();
 }
 public AddContactWindow(VSTalkCore core, Client client = null)
 {
     InitializeComponent();
     DataContext = this;
     _core = core;
     Clients = new ObservableCollection<Client>(core.AvailableClients);
     SelectedClient = client ?? Clients.FirstOrDefault();
     SetCommands();
 }
Exemple #11
0
 public ClientEditorViewModel(Client client)
 {
     Client = new ClientInfo();
     _nativeClient = client;
     Client.Login = client.Login;
     Client.Server = client.Server;
     Client.Password = client.Password;
     _isEditing = true;
     SetCommands();
 }
Exemple #12
0
 public void Connect(Client client)
 {
     var context = SessionModel.GetClientContext(client);
     if (context.State != ClientState.Disconnected)
     {
         return;
     }
     var connection = GetOrCreateConnection(client);
     connection.Connect();
 }
Exemple #13
0
 public void Disconnect(Client client)
 {
     var context = SessionModel.GetClientContext(client);
     if (context.State != ClientState.Connected)
     {
         return;
     }
     var targetConnection = _registeredConnections.First(connection => connection.Client == client);
     targetConnection.Disconnect();
 }
 private void UnsubscribeClient(Client client)
 {
     if (!_presenceListeners.ContainsKey(client))
     {
         return;
     }
     var listener = _presenceListeners[client];
     listener.PresenceReceived -= PresenceListenerOnPresenceReceived;
     listener.StopListen();
     _presenceListeners.Remove(client);
 }
Exemple #15
0
        public InterlocutorContext(Interlocutor interlocutor)
        {
            Interlocutor = interlocutor;
            Bare = XmppIdConverter.Jid(interlocutor);
            Resources = new ObservableCollection<IInterlocutorResource>();

            _client = ModelContext.GetClientByContact(interlocutor);
            _connection = ConnectionManager
                    .GetOrCreateConnection(_client)
                    .Connection;
        }
Exemple #16
0
 public void OnPresence(Client client, Presence presence)
 {
     var clientContext = SessionModel.GetClientContext(client);
     if (clientContext.Jid.Equals(presence.From, new CaseInsensitiveComparer()))
     {
         return;
     }
     var fromJid = presence.From.ToString().ToLower();
     var capsKey = new CapsSource(client, fromJid);
     ProcessedPresence(capsKey, presence);
 }
        public ClientNodeViewModel(Client client)
        {
            Client = client;

            Interlocutors = new ObservableCollection<Interlocutor>();

            HandleCollectionChanges();
            HandleSettingsChanges();

            PopulateContacts();
        }
Exemple #18
0
        public RoomContext(Room room)
        {
            Bare = new Jid(room.Name, room.Server, null);
            Room = room;
            Members = new ObservableCollection<IRoomMember>();

            _client = AppServices.Get<IModelContext>().GetClientByRoom(room);
            _connection = AppServices.Get<IConnectionManager>()
                    .GetOrCreateConnection(_client)
                    .Connection;
        }
Exemple #19
0
 public IClientContext GetClientContext(Client client)
 {
     if (_clients.ContainsKey(client))
     {
         return _clients[client];
     }
     var context = new ClientContext(client);
     _clients.Add(client, context);
     context.StartListen();
     return context;
 }
        public ClientConnection(INotificationQueue notificationQueue, Client client)
        {
            _client = client;
            _notificationQueue = notificationQueue;

            _rosterManager = new RosterManager(_connection);

            SubscribeToEvents();

            SetAuthorizationProvider();
            SetRosterObsererver();
            SetPresenceObserver();

            HandleClientChanges();
        }
        public HistoryExplorerViewModel(Client client, Jid with)
        {
            _client = client;
            var history = LoadHistory(client, with);
            With = with;
            HistoryView = new ObservableCollection<HistoryView>();

            HistoryMessages = new RichTextBox(new FlowDocument());
            HistoryMessages.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            HistoryMessages.Background = System.Windows.Media.Brushes.Transparent;
            HistoryMessages.IsReadOnly = true;

            BuildView(history);
            SetTheme(ThemeManager.ActiveTheme);
        }
 public ClientWindow()
 {
     InitializeComponent();
     DataContext = this;
     Client = new Client();
     AddClient = new RelayCommand(
         delegate
         {
             Client.Password = PasswordBox.Password;
             Client.Enabled = true;
             DialogResult = true;
             this.Close();
         },
         delegate
         {
             return !string.IsNullOrEmpty(Client.Login) &&
                 !string.IsNullOrEmpty(PasswordBox.Password) &&
                 !string.IsNullOrEmpty(Client.Server);
         });
     CloseWindow = new RelayCommand(delegate { Close();});
 }
Exemple #23
0
 private IClientContext GetContext(Client client)
 {
     return SessionModel.GetClientContext(client);
 }
Exemple #24
0
 public RoomEditorViewModel(Client client)
 {
     _client = client;
     Model = new RoomInfo();
     SetCommands();
 }
Exemple #25
0
 public ContactInfoRequest(Client client, string jid)
 {
     _client = client;
     _jid = jid;
 }
 public RosterContainer(Client client)
 {
     _client = client;
 }
Exemple #27
0
 private void InitiateRequest(Client client, Tuple<string, string> key, string jid)
 {
     var request = new ContactInfoRequest(client, jid);
     _pendingReuests.Add(key, request);
     request.Send().ContinueWith(_dispatcher.Wrap<Task<ContactDetails>>(task =>
     {
         _pendingReuests.Remove(key);
         if (task.Result == null)
         {
             return;
         }
         _dataProvider.RecordDetails(key.Item1, key.Item2, task.Result);
         if (_providers.ContainsKey(key.Item1))
         {
             _providers[key.Item1].Set(task.Result);
         }
     }).Exec);
 }
Exemple #28
0
 private void OnPresence(Client client, Presence presence)
 {
     var clientContext = SessionModel.GetClientContext(client);
     if (clientContext.Jid.Equals(presence.From, new CaseInsensitiveComparer()))
     {
         return;
     }
     var vcardUpdate = presence.SelectSingleElement<VcardUpdate>();
     if (vcardUpdate == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(vcardUpdate.Photo))
     {
         return;
     }
     var bare = presence.From.Bare.ToLower();
     var hash = vcardUpdate.Photo;
     var key = Tuple.Create(bare, hash);
     if (_pendingReuests.ContainsKey(key))
     {
         return;
     }
     if (_dataProvider.HasPhoto(bare, hash))
     {
         return;
     }
     var jid = presence.From.ToString().ToLower();
     InitiateRequest(client, key, jid);
 }
Exemple #29
0
 public RosterListener(Client client)
 {
     _client = client;
 }
 private static List<IMessage> LoadHistory(Client client, Jid with)
 {
     return HistoryService.Read(client.Id, with)
             .Where(message => !string.IsNullOrEmpty(message.XmppMessage.Body))
             .ToList();
 }