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();
 }
Esempio n. 3
0
 public RosterObesrver(Client client, XmppClientConnection connection)
 {
     _dispatcher = Dispatcher.CurrentDispatcher;
     _connection = connection;
     _listHandler = new RosterListHandler(client);
     _itemHandler = new RosterItemHandler(client);
 }
Esempio n. 4
0
 public ClientNodeViewModel(Client client)
 {
     Model = client;
     Context = SessionModel.GetClientContext(client);
     ActiveResources = new ObservableCollection<IClientResource>();
     ResourcesManager = CreateResourceManager();
     SetCommands();
 }
Esempio n. 5
0
 public void RemoveClient(Client client)
 {
     EventBus.Publish(new ClientRemovingEvent
     {
         ClientId = client.Id
     });
     Account.XmppClients.Remove(client);
 }
Esempio n. 6
0
 public ClientContext(Client client)
 {
     Client = client;
     _connection = AppServices
             .Get<IConnectionManager>()
             .GetOrCreateConnection(Client)
             .Connection;
 }
Esempio n. 7
0
        public ClientConnection(Client client)
        {
            _client = client;

            SetRosterObsererver();
            SetPresenceObserver();
            SetDiscoInfo();
            _provider = new XmppClientMessageProvider(this);
        }
Esempio n. 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;
 }
Esempio n. 9
0
 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();
 }
Esempio n. 10
0
 public AddContactWindow(VSTalkCore core, Client client = null)
 {
     InitializeComponent();
     DataContext = this;
     _core = core;
     Clients = new ObservableCollection<Client>(core.AvailableClients);
     SelectedClient = client ?? Clients.FirstOrDefault();
     SetCommands();
 }
Esempio n. 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();
 }
Esempio n. 12
0
 public void Connect(Client client)
 {
     var context = SessionModel.GetClientContext(client);
     if (context.State != ClientState.Disconnected)
     {
         return;
     }
     var connection = GetOrCreateConnection(client);
     connection.Connect();
 }
Esempio n. 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();
 }
Esempio n. 14
0
 private void UnsubscribeClient(Client client)
 {
     if (!_presenceListeners.ContainsKey(client))
     {
         return;
     }
     var listener = _presenceListeners[client];
     listener.PresenceReceived -= PresenceListenerOnPresenceReceived;
     listener.StopListen();
     _presenceListeners.Remove(client);
 }
Esempio n. 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;
        }
Esempio n. 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);
 }
Esempio n. 17
0
        public ClientNodeViewModel(Client client)
        {
            Client = client;

            Interlocutors = new ObservableCollection<Interlocutor>();

            HandleCollectionChanges();
            HandleSettingsChanges();

            PopulateContacts();
        }
Esempio n. 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;
        }
Esempio n. 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;
 }
Esempio n. 20
0
        public ClientConnection(INotificationQueue notificationQueue, Client client)
        {
            _client = client;
            _notificationQueue = notificationQueue;

            _rosterManager = new RosterManager(_connection);

            SubscribeToEvents();

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

            HandleClientChanges();
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
 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();});
 }
Esempio n. 23
0
 private IClientContext GetContext(Client client)
 {
     return SessionModel.GetClientContext(client);
 }
Esempio n. 24
0
 public RoomEditorViewModel(Client client)
 {
     _client = client;
     Model = new RoomInfo();
     SetCommands();
 }
Esempio n. 25
0
 public ContactInfoRequest(Client client, string jid)
 {
     _client = client;
     _jid = jid;
 }
Esempio n. 26
0
 public RosterContainer(Client client)
 {
     _client = client;
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 29
0
 public RosterListener(Client client)
 {
     _client = client;
 }
Esempio n. 30
0
 private static List<IMessage> LoadHistory(Client client, Jid with)
 {
     return HistoryService.Read(client.Id, with)
             .Where(message => !string.IsNullOrEmpty(message.XmppMessage.Body))
             .ToList();
 }