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

            SetRosterObsererver();
            SetPresenceObserver();
            SetDiscoInfo();
            _provider = new XmppClientMessageProvider(this);
        }
Exemplo 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;
 }
Exemplo 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();
 }
Exemplo 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();
 }
Exemplo 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();
 }
Exemplo 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();
 }
Exemplo 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();
 }
Exemplo 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);
 }
Exemplo 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;
        }
Exemplo 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);
 }
Exemplo n.º 17
0
        public ClientNodeViewModel(Client client)
        {
            Client = client;

            Interlocutors = new ObservableCollection<Interlocutor>();

            HandleCollectionChanges();
            HandleSettingsChanges();

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

            _rosterManager = new RosterManager(_connection);

            SubscribeToEvents();

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

            HandleClientChanges();
        }
Exemplo 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);
        }
Exemplo 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();});
 }
Exemplo n.º 23
0
 private IClientContext GetContext(Client client)
 {
     return SessionModel.GetClientContext(client);
 }
Exemplo n.º 24
0
 public RoomEditorViewModel(Client client)
 {
     _client = client;
     Model = new RoomInfo();
     SetCommands();
 }
Exemplo n.º 25
0
 public ContactInfoRequest(Client client, string jid)
 {
     _client = client;
     _jid = jid;
 }
Exemplo n.º 26
0
 public RosterContainer(Client client)
 {
     _client = client;
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo n.º 29
0
 public RosterListener(Client client)
 {
     _client = client;
 }
Exemplo 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();
 }