Exemplo n.º 1
0
        /// <summary>
        /// The Modem class constructor.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="handle">
        /// SlotHandle received in the Manager.Init API.
        /// </param>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="ArgumentNullException">
        /// This exception occurs if the handle provided is null.
        /// </exception>
        public Modem(SlotHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException();
            }

            _handle = handle._handle;
        }
Exemplo n.º 2
0
        internal static SlotHandle FindHandle(IntPtr handle)
        {
            SlotHandle temp = _telephonyHandle[0];

            foreach (SlotHandle simHandle in _telephonyHandle)
            {
                if (simHandle._handle == handle)
                {
                    temp = simHandle;
                }
            }

            return(temp);
        }
Exemplo n.º 3
0
        private void SetCallback(ChangeNotificationEventArgs.Notification n)
        {
            Interop.Telephony.NotificationCallback NotificationDelegate = (IntPtr handle, ChangeNotificationEventArgs.Notification notiId, IntPtr data, IntPtr userData) =>
            {
                SlotHandle simHandle = Manager.FindHandle(handle);
                object     notiData  = null;
                switch (notiId)
                {
                case ChangeNotificationEventArgs.Notification.SimStatus:
                {
                    notiData = (Sim.State)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.SimCallForwardingIndicatorState:
                {
                    notiData = ((Marshal.ReadInt32(data) == 0) ? false : true);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkServiceState:
                {
                    notiData = (Network.ServiceState)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkCellid:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkRoamingStatus:
                {
                    notiData = (Marshal.ReadInt32(data) == 0) ? false : true;
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSignalstrengthLevel:
                {
                    notiData = (Network.Rssi)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkNetworkName:
                {
                    notiData = Marshal.PtrToStringAnsi(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkPsType:
                {
                    notiData = (Network.PsType)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultDataSubscription:
                {
                    notiData = (Network.DefaultDataSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultSubscription:
                {
                    notiData = (Network.DefaultSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkLac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkTac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSystemId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLatitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLongitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusHeld:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.CallPreferredVoiceSubscription:
                {
                    notiData = (CallPreferredVoiceSubscription)Marshal.ReadInt32(data);
                    break;
                }
                }

                ChangeNotificationEventArgs args = new ChangeNotificationEventArgs(notiId, notiData);
                ChangeNotification?.Invoke(simHandle, args);
            };
            _changeNotificationList.Add(NotificationDelegate);

            Interop.Telephony.TelephonyError error = Interop.Telephony.TelephonySetNotiCb(_handle, n, NotificationDelegate, IntPtr.Zero);
            if (error != Interop.Telephony.TelephonyError.None)
            {
                Exception e = ExceptionFactory.CreateException(error);
                // Check if error is Invalid Parameter then hide the error
                if (e is ArgumentException)
                {
                    e = new InvalidOperationException("Internal Error Occured");
                }

                throw e;
            }
        }