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(); }
public RosterObesrver(Client client, XmppClientConnection connection) { _dispatcher = Dispatcher.CurrentDispatcher; _connection = connection; _listHandler = new RosterListHandler(client); _itemHandler = new RosterItemHandler(client); }
public ClientNodeViewModel(Client client) { Model = client; Context = SessionModel.GetClientContext(client); ActiveResources = new ObservableCollection<IClientResource>(); ResourcesManager = CreateResourceManager(); SetCommands(); }
public void RemoveClient(Client client) { EventBus.Publish(new ClientRemovingEvent { ClientId = client.Id }); Account.XmppClients.Remove(client); }
public ClientContext(Client client) { Client = client; _connection = AppServices .Get<IConnectionManager>() .GetOrCreateConnection(Client) .Connection; }
public ClientConnection(Client client) { _client = client; SetRosterObsererver(); SetPresenceObserver(); SetDiscoInfo(); _provider = new XmppClientMessageProvider(this); }
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(); }
public ClientEditorViewModel(Client client) { Client = new ClientInfo(); _nativeClient = client; Client.Login = client.Login; Client.Server = client.Server; Client.Password = client.Password; _isEditing = true; SetCommands(); }
public void Connect(Client client) { var context = SessionModel.GetClientContext(client); if (context.State != ClientState.Disconnected) { return; } var connection = GetOrCreateConnection(client); connection.Connect(); }
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); }
public InterlocutorContext(Interlocutor interlocutor) { Interlocutor = interlocutor; Bare = XmppIdConverter.Jid(interlocutor); Resources = new ObservableCollection<IInterlocutorResource>(); _client = ModelContext.GetClientByContact(interlocutor); _connection = ConnectionManager .GetOrCreateConnection(_client) .Connection; }
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(); }
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; }
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();}); }
private IClientContext GetContext(Client client) { return SessionModel.GetClientContext(client); }
public RoomEditorViewModel(Client client) { _client = client; Model = new RoomInfo(); SetCommands(); }
public ContactInfoRequest(Client client, string jid) { _client = client; _jid = jid; }
public RosterContainer(Client client) { _client = client; }
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); }
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); }
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(); }