Exemplo n.º 1
0
 public override void OnEnter(PhoneLine line)
 {
     Debug.Log("Entering state: " + this.GetType().ToString());
     line.ChangeLight(LightState.OFF);
     // Clear the line targets
     line.ClearLine();
 }
Exemplo n.º 2
0
        //Get network connection name
        internal static async Task <string> GetNetworkName()
        {
            try
            {
                //Check connection
                ConnectionProfile ConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
                if (ConnectionProfile == null)
                {
                    return("No connection");
                }
                else
                {
                    //Get Wi-Fi / Ethernet name
                    string FirstNetwork = ConnectionProfile.GetNetworkNames().FirstOrDefault();
                    if (!string.IsNullOrWhiteSpace(FirstNetwork))
                    {
                        return(FirstNetwork);
                    }

                    //Get Cellular name
                    if (ConnectionProfile.IsWwanConnectionProfile)
                    {
                        PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync();

                        PhoneLine phoneLine = await PhoneLine.FromIdAsync(await phoneCallStore.GetDefaultLineAsync());

                        return(phoneLine.NetworkName);
                    }

                    return("Unknown");
                }
            }
            catch { return("Unknown"); }
        }
Exemplo n.º 3
0
        public static async Task Initialize()
        {
            DeviceInformationCollection devices;

            CallManager = await CallManager.GetSystemPhoneCallManagerAsync();

            CallStore = await PhoneCallManager.RequestStoreAsync();

            CallHistoryStore = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesReadWrite);

            devices = await DeviceInformation.FindAllAsync(ProximitySensor.GetDeviceSelector());

            ProximitySensor = devices.Count > 0 ? ProximitySensor.FromId(devices.First().Id) : null;
            VibrationAccessStatus accessStatus = await VibrationDevice.RequestAccessAsync();

            if (accessStatus == VibrationAccessStatus.Allowed)
            {
                VibrationDevice = await VibrationDevice.GetDefaultAsync();
            }
            try
            {
                DefaultLine = await PhoneLine.FromIdAsync(await CallStore.GetDefaultLineAsync());
            }
            catch
            {
            }
            Initialized = true;
        }
Exemplo n.º 4
0
 public override void OnUpdate(PhoneLine line)
 {
     if (line.IsUnplugged)
     {
         line.ChangeState <WaitForCall>();
     }
 }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(string id, [Bind("PhoneNumber,PUK,PIN")] PhoneLine phoneLine)
        {
            //if (id != phoneLine.PhoneNumber)
            //{
            //    return NotFound();
            //}

            if (ModelState.IsValid)
            {
                var pl = await _context.PhoneLines
                         .FirstOrDefaultAsync(m => m.PhoneNumber == id);

                try
                {
                    //_context.Update(costCenter);
                    _context.PhoneLines.Remove(pl);
                    _context.Add(phoneLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhoneLineExists(phoneLine.PhoneNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { phoneNumberCheck = "On", pUKCheck = "On", pINCheck = "On" }));
            }
            return(View(phoneLine));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("PhoneNumber,PUK,PIN")] PhoneLine phoneLine)
        {
            if (id != phoneLine.PhoneNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phoneLine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhoneLineExists(phoneLine.PhoneNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phoneLine));
        }
Exemplo n.º 7
0
 public override void OnEnter(PhoneLine line)
 {
     Debug.Log("Entering state: " + this.GetType().ToString());
     line.ChangeLight(LightState.FLASH);
     line.ringTime = Time.time;
     line.Ring();
 }
Exemplo n.º 8
0
 public static void FillPhoneLine(PhoneLine line)
 {
     if (!_freeLines.Remove(line))
     {
         Debug.LogWarning(line + " not listed as free");
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Enumerate through all phone lines and returns a list of all phone lines
        /// </summary>
        /// <returns>A dictionary of cellular phone lines and their guids.</returns>
        private async Task <Dictionary <Guid, PhoneLine> > GetPhoneLinesAsync()
        {
            PhoneCallStore store = await PhoneCallManager.RequestStoreAsync();

            // Start the PhoneLineWatcher
            var watcher    = store.RequestLineWatcher();
            var phoneLines = new List <PhoneLine>();
            var lineEnumerationCompletion = new TaskCompletionSource <bool>();

            watcher.LineAdded            += async(o, args) => { var line = await PhoneLine.FromIdAsync(args.LineId); phoneLines.Add(line); };
            watcher.Stopped              += (o, args) => lineEnumerationCompletion.TrySetResult(false);
            watcher.EnumerationCompleted += (o, args) => lineEnumerationCompletion.TrySetResult(true);
            watcher.Start();

            // Wait for enumeration completion
            if (!await lineEnumerationCompletion.Task)
            {
                throw new Exception("Phone Line Enumeration failed");
            }

            watcher.Stop();

            Dictionary <Guid, PhoneLine> returnedLines = new Dictionary <Guid, PhoneLine>();

            foreach (PhoneLine phoneLine in phoneLines)
            {
                if (phoneLine != null && phoneLine.Transport == PhoneLineTransport.Cellular)
                {
                    returnedLines.Add(phoneLine.Id, phoneLine);
                }
            }

            return(returnedLines);
        }
Exemplo n.º 10
0
        protected virtual void ProcessUserPropertiesInstance(IUccProvisioningPolicyInstance userProperties)
        {
            IUccProperty property = userProperties.Properties.get_NamedProperty(@"lines");

            if (property != null)
            {
                IUccCollection phoneLines = property.Value as IUccCollection;

                if (phoneLines.Count > 0)
                {
                    PhoneLine[] phones = new PhoneLine[phoneLines.Count];

                    for (int i = 0; i < phones.Length; i++)
                    {
                        IUccPresencePhoneLine line = phoneLines[i + 1] as IUccPresencePhoneLine;

                        phones[i] = new PhoneLine();

                        try { phones[i].LineServer = line.LineServer; }
                        catch (COMException) { }

                        try { phones[i].Uri = line.Uri; }
                        catch (COMException) { }

                        try { phones[i].UccLineType = line.LineType; }
                        catch (COMException) { }
                    }

                    this.Phones = phones;
                }
            }

            this.Fax      = GetNamedProperty(userProperties, @"facsimileTelephoneNumber");
            this.Homepage = GetNamedProperty(userProperties, @"wWWHomePage");

            string streetAddr  = GetNamedProperty(userProperties, @"streetAddress");
            string city        = GetNamedProperty(userProperties, @"l");
            string state       = GetNamedProperty(userProperties, @"st");
            string zip         = GetNamedProperty(userProperties, @"postalCode");
            string countryCode = GetNamedProperty(userProperties, @"countryCode");

            string addr = @"";

            if (string.IsNullOrEmpty(streetAddr) == false)
            {
                addr += streetAddr + "\r\n";
            }
            if (string.IsNullOrEmpty(state) == false)
            {
                addr += state + "\r\n";
            }
            if (string.IsNullOrEmpty(city) == false)
            {
                addr += city + "\r\n";
            }
            addr += zip + @" " + countryCode;

            this.Address = addr;
        }
Exemplo n.º 11
0
        async Task <PhoneLine> GetDefaultPhoneLineAsync()
        {
            var phoneCallStore = await PhoneCallManager.RequestStoreAsync();

            var lineId = await phoneCallStore.GetDefaultLineAsync();

            return(await PhoneLine.FromIdAsync(lineId));
        }
Exemplo n.º 12
0
 public override void OnEnter(PhoneLine line)
 {
     Debug.Log("Entering state: " + this.GetType().ToString());
     line.PlayCall();
     line.GetRequest();
     line.ChangeLight(LightState.ON);
     line.startTime = Time.time;
 }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is PhoneCallHistoryEntry entry)
            {
                try
                {
                    IRandomAccessStream stream;
                    switch (entry.RemoteId)
                    {
                    case string celluarID when celluarID.StartsWith(PhoneLineTransport.Cellular.ToString()):
                        celluarID = celluarID.Split('|')[1];

                        IAsyncOperation <PhoneLine> task0 = PhoneLine.FromIdAsync(Guid.Parse(celluarID));
                        task0.AsTask().Wait();
                        IAsyncOperation <IReadOnlyList <AppListEntry> > task3 = Package.Current.GetAppListEntriesAsync();
                        task3.AsTask().Wait();
                        IAsyncOperation <IRandomAccessStreamWithContentType> task2 = task3.GetResults().First().DisplayInfo.GetLogo(new Size(512, 512)).OpenReadAsync();
                        task2.AsTask().Wait();
                        stream = task2.GetResults();
                        break;

                    case string appID when appID.StartsWith(PhoneLineTransport.VoipApp.ToString()):
                        appID = appID.Split('|')[1];

                        IAsyncOperation <IList <AppDiagnosticInfo> > task1 = AppDiagnosticInfo.RequestInfoForPackageAsync(appID);
                        task1.AsTask().Wait();
                        task2 = task1.GetResults().First().AppInfo.DisplayInfo.GetLogo(new Size(512, 512)).OpenReadAsync();
                        task2.AsTask().Wait();
                        stream = task2.GetResults();
                        break;

                    case string deviceID when deviceID.StartsWith(PhoneLineTransport.Bluetooth.ToString()):
                    //deviceID = deviceID.Split('|')[1];
                    //task0 = PhoneLine.FromIdAsync(Guid.Parse(deviceID));
                    //task0.AsTask().Wait();
                    //IAsyncOperation<DeviceInformation> task3 = DeviceInformation.CreateFromIdAsync(task0.GetResults().TransportDeviceId);
                    //task3.AsTask().Wait();
                    //IAsyncOperation<DeviceThumbnail> task4 = task3.GetResults().GetThumbnailAsync();
                    //task4.AsTask().Wait();
                    //stream = task4.GetResults();
                    //break;
                    default:
                        return(null);
                    }
                    BitmapImage a = new BitmapImage();
                    a.SetSource(stream);
                    return(a);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// Used to update the current phone line when the user changes this from the line picker.
 /// </summary>
 /// <param name="lineGuid">The unique ID of the new line. Used to retrieve the phone line</param>
 public void ChangePhoneLine(Guid lineGuid)
 {
     PhoneLine newLine = AllPhoneLines[lineGuid];
     if (newLine != null)
     {
         currentPhoneLine = newLine;
         updateCellularInformation();
     }
 }
Exemplo n.º 15
0
 public override void OnUpdate(PhoneLine line)
 {
     // Check if the incoming line has a target
     if (line.Incoming.TargetedJack != null)
     {
         // If so, change state to ringing
         line.ChangeState <Ringing>();
     }
 }
Exemplo n.º 16
0
        public static string DEBUG = "+420604540531";    /*INSERT NUMBER*/

        public static async Task CallAsync()
        {
            PhoneCallStore PhoneCallStore = await PhoneCallManager.RequestStoreAsync();

            Guid LineGuid = await PhoneCallStore.GetDefaultLineAsync();

            PhoneLine line = await PhoneLine.FromIdAsync(LineGuid);

            line.Dial(DEBUG, "CALL");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Used to update the current phone line when the user changes this from the line picker.
        /// </summary>
        /// <param name="lineGuid">The unique ID of the new line. Used to retrieve the phone line</param>
        public void ChangePhoneLine(Guid lineGuid)
        {
            PhoneLine newLine = AllPhoneLines[lineGuid];

            if (newLine != null)
            {
                currentPhoneLine = newLine;
                updateCellularInformation();
            }
        }
Exemplo n.º 18
0
    void AddLine(PhoneConversationsData.Data data)
    {
        asource.clip         = messageSFX;
        asource.spatialBlend = 0.6f;
        asource.Play();
        PhoneLine line = Instantiate(phoneLine_to_instantiate);

        line.transform.SetParent(container);
        line.transform.localScale = Vector3.one;
        line.AddLine(data);
    }
Exemplo n.º 19
0
 public override void OnUpdate(PhoneLine line)
 {
     if (Time.time >= line.startTime + line.CallLength)
     {
         line.CallDropped();
     }
     else if (line.IsConnected)
     {
         line.ChangeState <InCall>();
     }
 }
Exemplo n.º 20
0
        public async Task <IActionResult> Create([Bind("PhoneNumber,PUK,PIN")] PhoneLine phoneLine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phoneLine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phoneLine));
        }
Exemplo n.º 21
0
        private static void LineWatcher_LineRemoved(PhoneLineWatcher sender, PhoneLineWatcherEventArgs args)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine("LineRemoved: " + args.LineId);
#endif
            if (Guid.Equals(args.LineId, LineId))
            {
                Line   = null;
                LineId = Guid.Empty;
            }
        }
Exemplo n.º 22
0
 public static void FreePhoneLine(PhoneLine line)
 {
     if (!_freeLines.Contains(line))
     {
         _freeLines.Add(line);
     }
     else
     {
         Debug.LogWarning(line.name + " already free");
     }
 }
Exemplo n.º 23
0
 public override void OnUpdate(PhoneLine line)
 {
     // Check if call is answered
     if (line.Incoming.IsTargetPlugged)
     {
         line.ChangeState <WaitForConnection>();
     }
     else if (Time.time > line.ringTime + line.ringLength)
     {
         line.CallDropped();
     }
 }
Exemplo n.º 24
0
        public PhoneLine AddPhoneLine(Guid id)
        {
            var phoneLine = new PhoneLine()
            {
                Id          = Guid.NewGuid(),
                PhoneNumber = $"0114{(phoneLineCounter++).ToString("D7")}"
            };

            this.Get(id).PhoneLine = phoneLine;

            return(phoneLine);
        }
Exemplo n.º 25
0
    public override void OnUpdate(PhoneLine line)
    {
        if (!line.IsConnected)
        {
            Debug.LogWarning("Disconnected too early!");
            line.CallDropped();
        }

        if (Time.time > line.startTime + line.CallLength)
        {
            line.ChangeState <CallComplete>();
        }
    }
Exemplo n.º 26
0
        private static async void LineWatcher_LineAdded(PhoneLineWatcher sender, PhoneLineWatcherEventArgs args)
        {
#if DEBUG
            System.Diagnostics.Debug.WriteLine("LineAdded: " + args.LineId);
#endif
            PhoneLine line = await PhoneLine.FromIdAsync(args.LineId);

            if (line.TransportDeviceId == DeviceInfo.Id)
            {
                Line   = line;
                LineId = args.LineId;
            }
        }
        private void PhoneLine_ResumeClickHelper(int line)
        {
            PhoneLine phoneLine = phoneLines[line] as PhoneLine;

            if (phoneLine.IsRinging)
            {
                briaAPI.RequestAnswerCall(phoneLine.Id, false);
            }
            else
            {
                briaAPI.RequestResumeCall(phoneLine.Id);
            }
        }
Exemplo n.º 28
0
        private async void CallButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _CurrentPhoneLine = await PhoneLine.FromIdAsync(await App.Current.CallStore.GetDefaultLineAsync());

                _CurrentPhoneLine.DialWithOptions(new PhoneDialOptions()
                {
                    Number = currentNumber.ToString()
                });
            }
            catch (Exception ee)
            {
                handleException(ee);
            }
        }
Exemplo n.º 29
0
 public static void RegisterPhoneLine(PhoneLine line)
 {
     Debug.Log("attempting to register line: " + line);
     // Add to master list
     if (!_lines.Contains(line))
     {
         Debug.Log("Adding line to master list: " + line);
         _lines.Add(line);
     }
     // Add to free lines
     if (!_freeLines.Contains(line))
     {
         Debug.Log("Adding line to free list: " + line);
         _freeLines.Add(line);
     }
 }
Exemplo n.º 30
0
        public async void InitializeCallingInfoAsync()
        {
            MonitorCallState();

            //Get all phone lines (To detect dual SIM devices)
            var getPhoneLinesTask = GetPhoneLinesAsync();
            AllPhoneLines = await getPhoneLinesTask;

            //Get number of lines
            NoOfLines = AllPhoneLines.Count;

            //Get Default Phone Line
            var getDefaultLineTask = GetDefaultPhoneLineAsync();
            CurrentPhoneLine = await getDefaultLineTask;


        }
Exemplo n.º 31
0
        public async void InitializeCallingInfoAsync()
        {
            MonitorCallState();

            //Get all phone lines (To detect dual SIM devices)
            var getPhoneLinesTask = GetPhoneLinesAsync();

            AllPhoneLines = await getPhoneLinesTask;

            //Get number of lines
            NoOfLines = AllPhoneLines.Count;

            //Get Default Phone Line
            var getDefaultLineTask = GetDefaultPhoneLineAsync();

            CurrentPhoneLine = await getDefaultLineTask;
        }
Exemplo n.º 32
0
        private async void Button_Click_Call(object sender, RoutedEventArgs e)
        {
            if (_PhoneLineList.SelectedItem == null)
            {
                return;
            }

            PhoneLine line = await PhoneLine.FromIdAsync((Guid)_PhoneLineList.SelectedItem);

            if (line == null)
            {
                return;
            }
            if (line.CanDial)
            {
                line.Dial(PhoneNumberBox.Text, PhoneNumberBox.Text);
            }
        }
        /// <summary>
        /// Sets up an event listner for phone call state.
        /// Gets all cellular phone line objects.
        /// Calculates the number of lines on the device.
        /// Gets the default phone line object.
        /// Updates the cellular information properties based on the default phone line.
        /// </summary>
        private async void InitializeCallingInfoAsync()
        {
            this.MonitorCallState();

            //Get all phone lines (To detect dual SIM devices)
            Task<Dictionary<Guid,PhoneLine>> getPhoneLinesTask = GetPhoneLinesAsync();
            allPhoneLines = await getPhoneLinesTask;

            //Get number of lines
            noOfLines = allPhoneLines.Count;

            //Get Default Phone Line
            Task<PhoneLine> getDefaultLineTask = GetDefaultPhoneLineAsync();
            currentPhoneLine = await getDefaultLineTask;

            //Update cellular information based on default line
            updateCellularInformation();
        }