public MainControllerViewModel() { _isAccountLogged = false; _isContactDocked = false; _isDialpadDocked = false; _isHistoryDocked = false; _isMessagingDocked = false; _isCallPanelDocked = false; _isSettingsDocked = false; _isResourceDocked = false; _offerServiceSelection = false; _activateWizardPage = false; _dialPadViewModel = new DialpadViewModel(); _historyViewModel = new CallHistoryViewModel(ServiceManager.Instance.HistoryService, _dialPadViewModel); _contactsViewModel = new ContactsViewModel(ServiceManager.Instance.ContactService, _dialPadViewModel); _contactViewModel = new LocalContactViewModel(ServiceManager.Instance.ContactService); _simpleMessageViewModel = new SimpleMessagingViewModel(ServiceManager.Instance.ChatService, ServiceManager.Instance.ContactService); _settingsViewModel = new SettingsViewModel(); _menuViewModel = new MenuViewModel(); _historyViewModel.MissedCallsCountChanged += OnMissedCallsCountChanged; _simpleMessageViewModel.UnreadMessagesCountChanged += OnUnreadMesagesCountChanged; _callsViewModelList = new ObservableCollection <CallViewModel>(); _linphoneService = ServiceManager.Instance.LinphoneService; _dialpadHeight = 350; }
public MainControllerViewModel() { _isAccountLogged = false; _isContactDocked = false; _isDialpadDocked = false; _isHistoryDocked = false; _isMessagingDocked = false; _isCallPanelDocked = false; _isSettingsDocked = false; _isResourceDocked = false; _offerServiceSelection = false; _activateWizardPage = false; _dialPadViewModel = new DialpadViewModel(); _historyViewModel = new CallHistoryViewModel(ServiceManager.Instance.HistoryService, _dialPadViewModel); _contactsViewModel = new ContactsViewModel(ServiceManager.Instance.ContactService, _dialPadViewModel); _contactViewModel = new LocalContactViewModel(ServiceManager.Instance.ContactService); _inCallMessageViewModel = new InCallMessagingViewModel(ServiceManager.Instance.ChatService, ServiceManager.Instance.ContactService); _simpleMessageViewModel = new SimpleMessagingViewModel(ServiceManager.Instance.ChatService, ServiceManager.Instance.ContactService); _settingsViewModel = new SettingsViewModel(); _menuViewModel = new MenuViewModel(); _historyViewModel.MissedCallsCountChanged += OnMissedCallsCountChanged; _simpleMessageViewModel.UnreadMessagesCountChanged += OnUnreadMesagesCountChanged; _callsViewModelList = new ObservableCollection<CallViewModel>(); _linphoneService = ServiceManager.Instance.LinphoneService; _dialpadHeight = 350; }
public ChatsService(ServiceManagerBase mngBase) { this._serviceManager = mngBase; this._contactSvc = _serviceManager.ContactService; this._linphoneSvc = _serviceManager.LinphoneService; this._contactSvc.ContactAdded += OnContactAdded; this._contactSvc.ContactRemoved += OnContactRemoved; this._contactSvc.ContactsChanged += OnContactsChanged; this._contactSvc.ContactsLoadCompleted += OnContactsLoadCompleted; this._chatItems = new ObservableCollection<VATRPChat>(); this._linphoneSvc.IsComposingReceivedEvent += OnChatMessageComposing; this._linphoneSvc.OnChatMessageReceivedEvent += OnChatMessageReceived; this._linphoneSvc.OnChatMessageStatusChangedEvent += OnChatStatusChanged; IsRTTenabled = true; }
/// <summary> /// Configures the client for placing phone calls and validates user input. /// </summary> /// <remarks> /// Remote URI Format: sip:[email protected] /// </remarks> /// <param name="remoteUri"> The SIP URI the call is being placed to.</param> /// <returns>True if the call was placed successfully.</returns> internal static bool MakeVideoCall(string remoteUri) { string dialPadPhonePattern = @"^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$"; string pattern = @"[ \-\s\t\n\r\(\)\*\#\+\.]*"; string replacement = ""; Regex rgx = new Regex(pattern); Regex dialPadPhoneCheckRgx = new Regex(dialPadPhonePattern); //string result = rgx.Replace(remoteUri, replacement); Match match = dialPadPhoneCheckRgx.Match(remoteUri); if (match.Success) { string result = rgx.Replace(remoteUri, replacement); // Perserving the leading 1 if there is one: // /* * if (result.Length > 10 && result[0] == '1') * result = result.Remove(0, 1);*/ remoteUri = result; } //******************************** Maake Video Call ********************************************************************************************** // This method is called when user tap on call button on dial pad. or When user select the Contact from Contact list (All/Favorites) // It will called only when there is a valid number entered for a call (After validation) //************************************************************************************************************************************************* ILinphoneService _linphoneService = ServiceManager.Instance.LinphoneService; if (!_linphoneService.CanMakeVideoCall()) { MessageBox.Show("Video call not supported yet.", "VATRP", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } if (MainWindow.RegistrationState != LinphoneRegistrationState.LinphoneRegistrationOk) { MessageBox.Show("Not Registered. Please register first", "VATRP", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } // VATRP-2506, 2496: check to see if there is currently a call in progress. IF there is a call in progress, prevent // an outgoing call. int callCount = ServiceManager.Instance.LinphoneService.GetActiveCallsCount; // It checks if user already connected a call. if yes then it returns false. if (callCount > 0) { return(false); // i think this can be a quiet failure - the user is already in a call. } bool muteMicrophone = false; bool muteSpeaker = false; bool enableVideo = true; bool enableAudio = true; if (App.CurrentAccount != null) { muteMicrophone = App.CurrentAccount.MuteMicrophone; muteSpeaker = App.CurrentAccount.MuteSpeaker; enableVideo = App.CurrentAccount.VideoAutomaticallyStart; enableAudio = App.CurrentAccount.AudioAutomaticallyStart; } var target = string.Empty; string un, host; int port; VATRPCall.ParseSipAddress(remoteUri, out un, out host, out port); if (!host.NotBlank()) { // set proxy to selected provider // find selected provider host var provider = ServiceManager.Instance.ProviderService.FindProviderLooseSearch( ServiceManager.Instance.ConfigurationService.Get(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.CURRENT_PROVIDER, "")); //Use dial-around provider if selected if (!string.IsNullOrEmpty(App.CurrentAccount?.DialAroundProviderAddress)) { target = string.Format("sip:{0}@{1}", un, App.CurrentAccount.DialAroundProviderAddress); } else if (provider != null) { target = string.Format("sip:{0}@{1}", un, provider.Address); } else if (App.CurrentAccount != null) { target = string.Format("sip:{0}@{1}", un, App.CurrentAccount.ProxyHostname); } } else { if (!string.IsNullOrEmpty(App.CurrentAccount?.DialAroundProviderAddress)) { target = string.Format("sip:{0}@{1}", un, App.CurrentAccount.DialAroundProviderAddress); } else { target = string.Format("sip:{0}@{1}:{2}", un, host, port); } } if (!App.CurrentAccount.DisableUserPhoneTag) { // https://www.twilio.com/docs/glossary/what-e164 // https://en.wikipedia.org/wiki/E.164 Regex rE164 = new Regex(@"^(\+|00)?[1-9]\d{4,14}$"); bool isE164 = rE164.IsMatch(un); if (isE164) { target += ";user=phone"; } else { target += ";user=dialstring"; } } var privacyMask = VATRP.Core.Enums.LinphonePrivacy.LinphonePrivacyDefault; if (App.CurrentAccount.EnablePrivacy) { privacyMask = VATRP.Core.Enums.LinphonePrivacy.LinphonePrivacySession; } // update video policy settings prior to making a call _linphoneService.MakeCall(target, /* destination */ true, /* videoOn */ ServiceManager.Instance.ConfigurationService.Get(Configuration.ConfSection.GENERAL, Configuration.ConfEntry.USE_RTT, true), /* rttEnabled */ muteMicrophone, /* muteMicrophone */ muteSpeaker, /* muteSpeaker */ enableVideo, /* enableVideo */ enableAudio, App.CurrentAccount.GeolocationURI, /* geolocation */ privacyMask); /* privacyMask */ return(true); }
public MainWindow() : base(VATRPWindowType.MAIN_VIEW) { _mainViewModel = new MainControllerViewModel(); _mainViewModel.ActivateWizardPage = true; _mainViewModel.OfferServiceSelection = false; _linphoneService = ServiceManager.Instance.LinphoneService; _linphoneService.RegistrationStateChangedEvent += OnRegistrationChanged; _linphoneService.CallStateChangedEvent += OnCallStateChanged; _linphoneService.GlobalStateChangedEvent += OnGlobalStateChanged; _linphoneService.NetworkReachableEvent += OnLinphoneConnectivityChanged; ServiceManager.Instance.NewAccountRegisteredEvent += OnNewAccountRegistered; ServiceManager.Instance.LinphoneCoreStartedEvent += OnLinphoneCoreStarted; ServiceManager.Instance.LinphoneCoreStoppedEvent += OnLinphoneCoreStopped; InitializeComponent(); DataContext = _mainViewModel; ctrlHistory.SetDataContext(_mainViewModel.HistoryModel); ctrlContacts.SetDataContext(_mainViewModel.ContactsModel); _dialpadBox = new Dialpad(_mainViewModel.DialpadModel); _messagingWindow = new MediaTextWindow(_mainViewModel.SipSimpleMessagingModel); ctrlDialpad.SetViewModel(_mainViewModel.DialpadModel); ctrlLocalContact.SetDataContext(_mainViewModel.ContactModel); ctrlCall.ParentViewModel =_mainViewModel; ctrlMoreMenu.SetDataContext(_mainViewModel.MoreMenuModel); //_settingsView.SetSettingsModel(_mainViewModel.SettingsModel); EnterFullScreenCheckBox.IsEnabled = false; // _settingsWindow = new SettingsWindow(ctrlCall, OnAccountChangeRequested); // ctrlSettings.SetCallControl(ctrlCall); // ctrlCall.SettingsControl = ctrlSettings; deferredHideTimer.Tick += DeferedHideOnError; deferredShowPreviewTimer.Tick += DeferredShowPreview; CombinedUICallViewSize.Width = 700; CombinedUICallViewSize.Height = 700; }