Пример #1
0
        /// <summary>
        /// Gets the status of the calling line identity service.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The Cli service type.</param>
        /// <returns>A task containing SS CLI response information.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <SsCliResponse> SsGetCliStatus(SsCliType type)
        {
            TaskCompletionSource <SsCliResponse> task = new TaskCompletionSource <SsCliResponse>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)SsCause.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs in getting SS CLI status: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs in getting SS CLI status, " + (SsCause)result));
                        return;
                    }

                    SsCliResponseStruct response = Marshal.PtrToStructure <SsCliResponseStruct>(data);
                    task.SetResult(SsStructConversions.ConvertSsCliResponseStruct(response));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            int ret = Interop.Tapi.Ss.SsGetCliStatus(_handle, type, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get CLI status, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #2
0
        /// <summary>
        /// Set the default subscription for voice asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>A task indicating whether the SetNetworkDefaultSubscription method is done or not.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task SetNetworkDefaultSubscription()
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during setting the default subscription for voice, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during setting the default subscription for voice, " + (TapiError)result));
                        return;
                    }

                    task.SetResult(true);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.SetNetworkDefaultDataSubs(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to set the default subscription for voice, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #3
0
        /// <summary>
        /// Turn the modem on/off asynchronously.
        /// </summary>
        /// <param name="cmd">Power command value.</param>
        /// <returns>A task indicating whether the ProcessPowerCommand method is done or not.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task ProcessPowerCommand(PhonePowerCommand cmd)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during turning modem on/off, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during turning modem on/off, " + (TapiError)result));
                        return;
                    }

                    task.SetResult(true);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.ProcessPowerCommand(_handle, cmd, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to turn the modem on/off, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #4
0
        /// <summary>
        /// Activates/deactivates the status of the calling line identity service.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The Cli service type.</param>
        /// <param name="status">The Cli Status.</param>
        /// <returns>A task indicating whether setting of CLI status is done or not.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privlevel>platform</privlevel>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <bool> SsSetCliStatus(SsCliType type, SsCliStatus status)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)SsCause.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs in setting SS CLI status: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs in setting SS CLI status, " + (SsCause)result));
                        return;
                    }

                    task.SetResult(true);
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            int ret = Interop.Tapi.Ss.SsSetCliStatus(_handle, type, status, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to set SS CLI status, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #5
0
        /// <summary>
        /// Get the Misc Me Imei asynchronously.
        /// </summary>
        /// <returns>The imei string.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <string> GetMiscMeImei()
        {
            TaskCompletionSource <string> task = new TaskCompletionSource <string>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Misc Me Imei, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the Misc Me Imei, " + (TapiError)result));
                        return;
                    }

                    task.SetResult(Marshal.PtrToStringAnsi(data));
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetMiscMeImei(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the Misc Me Imei information, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #6
0
        /// <summary>
        /// Get the network roaming preference asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Value of NetworkPreferred.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <NetworkPreferred> GetRoamingPreference()
        {
            TaskCompletionSource <NetworkPreferred> task = new TaskCompletionSource <NetworkPreferred>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the network roaming preference, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the network roaming preference, " + (TapiError)result));
                        return;
                    }

                    task.SetResult((NetworkPreferred)Marshal.ReadInt32(dataResponse));
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.GetNetworkRoamPreference(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the network roaming preference, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #7
0
        /// <summary>
        /// Gets the number of used records and total records of a specific SIM phonebook type.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The different storage types to be selected in the SIM.</param>
        /// <returns>A task containing an instance of PhonebookStorageInfo.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <PhonebookStorageInfo> GetPhonebookStorage(PhonebookType type)
        {
            TaskCompletionSource <PhonebookStorageInfo> task = new TaskCompletionSource <PhonebookStorageInfo>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)PhonebookAccessResult.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting phone book storage: " + (PhonebookAccessResult)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting phone book storage, " + (PhonebookAccessResult)result));
                        return;
                    }

                    PhonebookStorageInfoStruct info = Marshal.PtrToStructure <PhonebookStorageInfoStruct>(data);
                    task.SetResult(PhonebookStructConversions.ConvertPhonebookStorageStruct(info));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            int ret = Interop.Tapi.Phonebook.GetPhonebookStorage(_handle, type, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get phonebook storage info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #8
0
        /// <summary>
        /// Deregisters notification callback for notification change events on DBus interface.
        /// </summary>
        /// <param name="id">Notification id for which the callback has to be de-registered.</param>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public void DeregisterNotiEvent(Notification id)
        {
            int ret = Interop.Tapi.DeregisterNotiEvent(_handle, TapiUtility.ConvertNotiToString(id));

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to deregister notification event, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle);
            }
        }
Пример #9
0
        /// <summary>
        /// Deregisters notification callback for property change events on DBus interface.
        /// </summary>
        /// <param name="property">Property definition for which the callback has to be de-registered.</param>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public void DeregisterPropEvent(Property property)
        {
            int ret = Interop.Tapi.DeregisterNotiEvent(_handle, TapiUtility.ConvertPropToString(property));

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to deregister notification event for property change, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle);
            }
        }
Пример #10
0
        /// <summary>
        /// Deinitializes the TAPI Handle.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public static void DeinitTapi(TapiHandle handle)
        {
            int ret = Interop.Tapi.DeinitTapi(handle._handle);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to deinitialize tapi, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, handle._handle);
            }

            handle._handle = IntPtr.Zero;
        }
Пример #11
0
        /// <summary>
        /// Get the default subscription for voice.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Value of NetworkDefaultSubscription.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public NetworkDefaultSubscription GetNetworkDefaultSubscription()
        {
            NetworkDefaultSubscription defaultSubs;
            int ret = Interop.Tapi.Network.GetNetworkDefaultSubs(_handle, out defaultSubs);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the default subscription, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(defaultSubs);
        }
Пример #12
0
        /// <summary>
        /// Gets the property value in a string format for the given property.
        /// </summary>
        /// <param name="property">The property to be retrieved from Dbus.</param>
        /// <returns>The property value in string format.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public string GetStringProperty(Property property)
        {
            string result;
            int    ret = Interop.Tapi.GetStringProperty(_handle, TapiUtility.ConvertPropToString(property), out result);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get property in string format, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(result);
        }
Пример #13
0
        /// <summary>
        /// Check the modem power status.
        /// </summary>
        /// <returns>Phone power status value.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public PhonePowerStatus CheckPowerStatus()
        {
            int result;
            int ret = Interop.Tapi.Modem.CheckPowerStatus(_handle, out result);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to check the modem power status, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return((PhonePowerStatus)result);
        }
Пример #14
0
        /// <summary>
        /// Sends oem data directly.
        /// </summary>
        /// <param name="oemId">Oem id for user specification.</param>
        /// <param name="data">Oem data for sending.</param>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when oem instance is invalid or when method failed due to invalid operation.</exception>
        public void SendOemData(int oemId, byte[] data)
        {
            int    length  = data.Length;
            IntPtr oemData = Marshal.AllocHGlobal(length);

            Marshal.Copy(data, 0, oemData, length);
            int ret = Interop.Tapi.Oem.SendOemData(_handle, oemId, oemData, Convert.ToUInt32(length));

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to send oem data directly, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }
        }
Пример #15
0
        /// <summary>
        /// Gets the current inserted SIM phonebook init status, available phonebook list, and first valid index in case of FDN, ADN, and 3G phonebook.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>An instance of SimPhonebookStatus containing init status and phonebook list information.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public SimPhonebookStatus GetPhonebookInitInfo()
        {
            SimPhonebookStatusStruct pbStatus;
            int ret = Interop.Tapi.Phonebook.GetPhonebookInitInfo(_handle, out int isInitCompleted, out SimPhonebookListStruct pbList);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get phonebook init info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            pbStatus.IsInitCompleted = isInitCompleted;
            pbStatus.PbList          = pbList;
            return(PhonebookStructConversions.ConvertSimPhonebookStatusStruct(pbStatus));
        }
Пример #16
0
        /// <summary>
        /// Get the flight mode asynchronously.
        /// </summary>
        /// <returns>If flight mode is On, it returns true else it returns false.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <bool> GetFlightMode()
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the flight mode, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the flight mode, " + (TapiError)result));
                        return;
                    }

                    int mode = Marshal.ReadInt32(data);
                    if (mode == 1)
                    {
                        task.SetResult(true);
                    }

                    else
                    {
                        task.SetResult(false);
                    }
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetFlightMode(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the flight mode, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #17
0
        /// <summary>
        /// Adds or edits SIM phone book record entry information.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="record">The phonebook data to be updated or added.</param>
        /// <returns>A task indicating whether the updation is done or not.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privlevel>platform</privlevel>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentNullException">Thrown when record is passed as null.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <bool> UpdatePhonebookRecord(PhonebookRecord record)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)PhonebookAccessResult.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during updation of phone book record: " + (PhonebookAccessResult)result);
                        task.SetException(new InvalidOperationException("Error occurs during updation of phone book record, " + (PhonebookAccessResult)result));
                        return;
                    }

                    task.SetResult(true);
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (record == null)
            {
                throw new ArgumentNullException("Phonebook record is null");
            }

            if (record.Index == 0)
            {
                throw new ArgumentException("Index in phonebook record is zero");
            }

            PhonebookRecordStruct recordStruct = PhonebookClassConversions.ConvertPhonebookrecord(record);
            int ret = Interop.Tapi.Phonebook.UpdatePhonebookRecord(_handle, ref recordStruct, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to update phonebook record, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #18
0
        /// <summary>
        /// Set the network preferred plmn asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="operation">The operation to be done on the preferred plmn.</param>
        /// <param name="info">The preferred plmn info.</param>
        /// <returns>A task indicating whether the SetNetworkPreferredPlmn method is done or not.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.ArgumentNullException">Thrown when NetworkPreferredPlmnInfo argument is null.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task SetNetworkPreferredPlmn(NetworkPreferredPlmnOp operation, NetworkPreferredPlmnInfo info)
        {
            if (info != null)
            {
                TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
                IntPtr id;
                id = (IntPtr)_requestId++;
                _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
                {
                    Task resultTask = new Task(() =>
                    {
                        if (result != (int)TapiError.Success)
                        {
                            Log.Error(TapiUtility.LogTag, "Error occurs during setting the network preferred plmn, " + (TapiError)result);
                            task.SetException(new InvalidOperationException("Error occurs during setting the network preferred plmn, " + (TapiError)result));
                            return;
                        }

                        task.SetResult(true);
                    });

                    resultTask.Start();
                    resultTask.Wait();
                    _response_map.Remove(key);
                };

                NetworkPreferredPlmnStruct plmnStruct = NetworkClassConversions.ConvertNetworkPreferredPlmn(info);
                int ret = Interop.Tapi.Network.SetNetworkPreferredPlmn(_handle, operation, ref plmnStruct, _response_map[id], id);
                if (ret != (int)TapiError.Success)
                {
                    Log.Error(TapiUtility.LogTag, "Failed to set the network preferred plmn, Error: " + (TapiError)ret);
                    TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
                }

                return(task.Task);
            }

            else
            {
                throw new ArgumentNullException("NetworkPreferredPlmnInfo argument is null");
            }
        }
Пример #19
0
        /// <summary>
        /// Sends oem data directly.
        /// </summary>
        /// <param name="oemId">Oem id for user specification.</param>
        /// <param name="data">Oem data for sending.</param>
        /// <returns>The oem data which is sent.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when call instance is invalid or when method failed due to invalid operation.</exception>
        public Task <OemData> SendOemDataAsync(int oemId, byte[] data)
        {
            TaskCompletionSource <OemData> task = new TaskCompletionSource <OemData>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)NetworkOperationCause.NoError)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during sending oem data, " + (NetworkOperationCause)result);
                        task.SetException(new InvalidOperationException("Error occurs during sending oem data, " + (NetworkOperationCause)result));
                        return;
                    }

                    OemDataStruct oemStruct = Marshal.PtrToStructure <OemDataStruct>(dataResponse);
                    OemData oemClass        = OemStructConversions.ConvertOemStruct(oemStruct);
                    task.SetResult(oemClass);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int    length  = data.Length;
            IntPtr oemData = Marshal.AllocHGlobal(length);

            Marshal.Copy(data, 0, oemData, length);
            int ret = Interop.Tapi.Oem.SendOemDataAsync(_handle, oemId, oemData, Convert.ToUInt32(length), _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to send oem data, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #20
0
        /// <summary>
        /// Sends a request to activate/deactivate call barring.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="info">The information about call barring.</param>
        /// <returns>A task containing an instance of SsBarringResponse which contains information about barring response.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privlevel>platform</privlevel>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentNullException">Thrown when barring info is passed as null.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <SsBarringResponse> SsSetBarring(SsBarringInfo info)
        {
            TaskCompletionSource <SsBarringResponse> task = new TaskCompletionSource <SsBarringResponse>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)SsCause.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during setting SS barring info: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs during setting SS barring info, " + (SsCause)result));
                        return;
                    }

                    SsBarringResponseStruct response = Marshal.PtrToStructure <SsBarringResponseStruct>(data);
                    task.SetResult(SsStructConversions.ConvertBarringRspStruct(response));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (info == null)
            {
                throw new ArgumentNullException("Ss barring info is null");
            }

            SsBarringInfoStruct infoStruct = SsClassConversions.ConvertSsBarringInfo(info);
            int ret = Interop.Tapi.Ss.SsSetBarring(_handle, ref infoStruct, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to set barring info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #21
0
        /// <summary>
        /// Reads SIM phone book entry information from the given storage type and index.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The different storage types to be selected in the SIM.</param>
        /// <param name="index">The index for accessing the SIM data.</param>
        /// <returns>A task containing an instance of PhonebookRecord.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <PhonebookRecord> ReadPhonebookRecord(PhonebookType type, ushort index)
        {
            TaskCompletionSource <PhonebookRecord> task = new TaskCompletionSource <PhonebookRecord>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)PhonebookAccessResult.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during reading phone book record: " + (PhonebookAccessResult)result);
                        task.SetException(new InvalidOperationException("Error occurs during reading phone book record, " + (PhonebookAccessResult)result));
                        return;
                    }

                    PhonebookRecordStruct record = Marshal.PtrToStructure <PhonebookRecordStruct>(data);
                    task.SetResult(PhonebookStructConversions.ConvertPhonebookRecordStruct(record));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (index == 0)
            {
                throw new ArgumentException("Index should not be zero");
            }

            int ret = Interop.Tapi.Phonebook.ReadPhonebookRecord(_handle, type, index, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to read phonebook record, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #22
0
        /// <summary>
        /// Allows changing of the barring password in the network.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="oldPassword">The old password set for Barring in the Network.</param>
        /// <param name="newPassword">The new password set for Barring in the Network.</param>
        /// <param name="newPasswordAgain">The new password again.</param>
        /// <returns>A task indicating whether the change of password is done or not.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privlevel>platform</privlevel>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentNullException">Thrown when any of the parameter is passed as null.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <bool> SsChangeBarringPassword(string oldPassword, string newPassword, string newPasswordAgain)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)SsCause.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs in changing barring password: "******"Error occurs in changing barring password, " + (SsCause)result));
                        return;
                    }

                    task.SetResult(true);
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (oldPassword == null || newPassword == null || newPasswordAgain == null)
            {
                throw new ArgumentNullException("Old password/new password is null");
            }

            int ret = Interop.Tapi.Ss.SsChangeBarringPassword(_handle, oldPassword, newPassword, newPasswordAgain, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to change barring password, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #23
0
        /// <summary>
        /// Deletes a SIM phonebook record.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The different storage types to be selected in the SIM.</param>
        /// <param name="index">The index of the record to be deleted.</param>
        /// <returns>A task indicating whether deletion is done or not.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privlevel>platform</privlevel>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public Task <bool> DeletePhonebookRecord(PhonebookType type, ushort index)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)PhonebookAccessResult.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during deletion of phone book record: " + (PhonebookAccessResult)result);
                        task.SetException(new InvalidOperationException("Error occurs during deletion of phone book record, " + (PhonebookAccessResult)result));
                        return;
                    }

                    task.SetResult(true);
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (index == 0)
            {
                throw new ArgumentException("Index of the record is zero");
            }

            int ret = Interop.Tapi.Phonebook.DeletePhonebookRecord(_handle, type, index, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to delete phonebook record, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #24
0
        /// <summary>
        /// Get device vendor name and device name of cellular dongle.
        /// </summary>
        /// <returns>Instance of MiscDeviceInfo.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <remarks>
        /// Result can be delivered with only cellular dongle insertion.
        /// </remarks>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <MiscDeviceInfo> GetDeviceInfo()
        {
            TaskCompletionSource <MiscDeviceInfo> task = new TaskCompletionSource <MiscDeviceInfo>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the device name and vendor name, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the device name and vendor name, " + (TapiError)result));
                        return;
                    }

                    MiscDeviceInfoStruct infoStruct = Marshal.PtrToStructure <MiscDeviceInfoStruct>(data);
                    MiscDeviceInfo deviceInfo       = ModemStructConversions.ConvertMiscInfoStruct(infoStruct);
                    task.SetResult(deviceInfo);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetDeviceInfo(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the device vendor name and device name, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #25
0
        /// <summary>
        /// Get the neighboring cell info asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Instance of NetworkNeighboringCell.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <NetworkNeighboringCell> GetNeighborCellNetwork()
        {
            TaskCompletionSource <NetworkNeighboringCell> task = new TaskCompletionSource <NetworkNeighboringCell>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the neigboring cell info, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the neigboring cell info, " + (TapiError)result));
                        return;
                    }

                    NetworkNeighboringCellStruct cellStruct = Marshal.PtrToStructure <NetworkNeighboringCellStruct>(dataResponse);
                    NetworkNeighboringCell cell             = NetworkStructConversions.ConvertNeighborCellStruct(cellStruct);
                    task.SetResult(cell);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.GetNetworkNeighborCell(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the neigboring cell info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #26
0
        /// <summary>
        /// Get the preferred plmn list asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>List of NetworkPreferredPlmnInfo.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <IEnumerable <NetworkPreferredPlmnInfo> > GetNetworkPreferredPlmn()
        {
            TaskCompletionSource <IEnumerable <NetworkPreferredPlmnInfo> > task = new TaskCompletionSource <IEnumerable <NetworkPreferredPlmnInfo> >();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the preferred plmn list, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the preferred plmn list, " + (TapiError)result));
                        return;
                    }

                    NetworkPreferredPlmnListStruct plmnStruct       = Marshal.PtrToStructure <NetworkPreferredPlmnListStruct>(dataResponse);
                    IEnumerable <NetworkPreferredPlmnInfo> plmnInfo = NetworkStructConversions.ConvertNetworkPreferredPlmnStruct(plmnStruct);
                    task.SetResult(plmnInfo);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.GetNetworkPreferredPlmn(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the preferred plmn list, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #27
0
        /// <summary>
        /// Sends a request to do manual search for the available networks and provides the Network List to the user asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Instance of NetworkPlmnList.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <NetworkPlmnList> SearchNetwork()
        {
            TaskCompletionSource <NetworkPlmnList> task = new TaskCompletionSource <NetworkPlmnList>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during manual search for the available networks, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during manual search for the available networks, " + (TapiError)result));
                        return;
                    }

                    NetworkPlmnListStruct listStruct = Marshal.PtrToStructure <NetworkPlmnListStruct>(dataResponse);
                    NetworkPlmnList plmnClass        = NetworkStructConversions.ConvertNetworkPlmnListStruct(listStruct);
                    task.SetResult(plmnClass);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.SearchNetwork(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to do manual search for the available networks, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #28
0
        /// <summary>
        /// Get the Me Esn/Meid for each phone type asynchronously.
        /// </summary>
        /// <returns>Instance of MiscSerialNumberInformation.</returns>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task <MiscSerialNumberInformation> GetMiscMeSn()
        {
            TaskCompletionSource <MiscSerialNumberInformation> task = new TaskCompletionSource <MiscSerialNumberInformation>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if (result != (int)TapiError.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Me Esn/Meid, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting the Me Esn/Meid, " + (TapiError)result));
                        return;
                    }

                    MiscSerialNumInfoStruct infoStruct            = Marshal.PtrToStructure <MiscSerialNumInfoStruct>(data);
                    MiscSerialNumberInformation serialNumberClass = ModemStructConversions.ConvertSerialNumberStruct(infoStruct);
                    task.SetResult(serialNumberClass);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.GetMiscMeSn(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to get the Me Esn/Meid information for each phone type, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
            }

            return(task.Task);
        }
Пример #29
0
        /// <summary>
        /// Switch the flight mode on/off asynchronously.
        /// </summary>
        /// <param name="mode">Flight mode request value.</param>
        /// <returns>A task indicating whether the SetFlightMode method is done or not.</returns>
        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
        /// <privlevel>platform</privlevel>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
        public Task SetFlightMode(PowerFlightModeRequest mode)
        {
            TaskCompletionSource <bool> task = new TaskCompletionSource <bool>();
            IntPtr id;

            id = (IntPtr)_requestId++;
            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
            {
                Task resultTask = new Task(() =>
                {
                    if ((mode == PowerFlightModeRequest.Leave && result != (int)PowerFlightModeResponse.Off) ||
                        (mode == PowerFlightModeRequest.Enter && result != (int)PowerFlightModeResponse.On))
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during switching flight mode on/off, " + (PowerFlightModeResponse)result);
                        task.SetException(new InvalidOperationException("Error occurs during switching flight mode on/off, " + (PowerFlightModeResponse)result));
                        return;
                    }

                    task.SetResult(true);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Modem.SetFlightMode(_handle, mode, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to switch the flight mode on/off, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }
Пример #30
0
        /// <summary>
        /// Registers a notification callback for notification change events on DBus interface.
        /// </summary>
        /// <param name="id">Notification id for which a callback has to be registered.</param>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
        public void RegisterNotiEvent(Notification id)
        {
            _notificationChangedCb = (IntPtr handle, IntPtr notiIdPtr, IntPtr data, IntPtr userData) =>
            {
                if (_notificationChanged != null)
                {
                    string       notiId   = null;
                    object       notiData = null;
                    Notification noti     = default(Notification);
                    if (notiIdPtr != IntPtr.Zero)
                    {
                        notiId = Marshal.PtrToStringAnsi(notiIdPtr);
                        foreach (Notification n in Enum.GetValues(typeof(Notification)))
                        {
                            if (notiId == TapiUtility.ConvertNotiToString(n))
                            {
                                noti = n;
                                break;
                            }
                        }
                    }

                    switch (noti)
                    {
                    case Notification.IdleVoiceCall:
                        CallIdleStatusNotiStruct voiceIdleStatusNoti = Marshal.PtrToStructure <CallIdleStatusNotiStruct>(data);
                        notiData = CallStructConversions.ConvertCallIdleStatusNoti(voiceIdleStatusNoti);
                        break;

                    case Notification.ActiveVoiceCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.HeldVoiceCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.DialingVoiceCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.AlertVoiceCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.IncomingVoiceCall:
                        CallIncomingInfoStruct callIncomingInfo = Marshal.PtrToStructure <CallIncomingInfoStruct>(data);
                        notiData = CallStructConversions.ConvertIncomingCallInfo(callIncomingInfo);
                        break;

                    case Notification.IdleVideoCall:
                        CallIdleStatusNotiStruct videoIdleStatus = Marshal.PtrToStructure <CallIdleStatusNotiStruct>(data);
                        notiData = CallStructConversions.ConvertCallIdleStatusNoti(videoIdleStatus);
                        break;

                    case Notification.ActiveVideoCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.DialingVideoCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.AlertVideoCall:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.IncomingVideoCall:
                        CallIncomingInfoStruct videoIncomingInfo = Marshal.PtrToStructure <CallIncomingInfoStruct>(data);
                        notiData = CallStructConversions.ConvertIncomingCallInfo(videoIncomingInfo);
                        break;

                    case Notification.WaitingCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.ForwardCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.BarredIncomingCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.BarredOutgoingCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.ForwardUnconditionalCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.ForwardConditionalCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.ForwardedCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.HeldCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.ActiveCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.JoinedCallInfo:
                        notiData = (uint)Marshal.ReadInt32(data);
                        break;

                    case Notification.RecCallInfo:
                        CallRecordStruct recordStruct = Marshal.PtrToStructure <CallRecordStruct>(data);
                        notiData = CallStructConversions.ConvertCallRecordStruct(recordStruct);
                        break;

                    case Notification.PrivacyModeCall:
                        notiData = (CallPrivacyMode)Marshal.ReadInt32(data);
                        break;

                    case Notification.OtaspCall:
                        notiData = (CallOtaspStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.OtapaCall:
                        notiData = (CallOtapaStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.CallSignalInfo:
                        CallSignalInfoStruct signalInfoStruct = Marshal.PtrToStructure <CallSignalInfoStruct>(data);
                        notiData = CallStructConversions.ConvertCallSignalInfo(signalInfoStruct);
                        break;

                    case Notification.CallSoundPath:
                        notiData = (SoundPath)Marshal.ReadInt32(data);
                        break;

                    case Notification.CallSoundRingbackTone:
                        notiData = (CallSoundRingbackNoti)Marshal.ReadInt32(data);
                        break;

                    case Notification.CallSoundWbamr:
                        notiData = (CallSoundWbamrNoti)Marshal.ReadInt32(data);
                        break;

                    case Notification.CallSoundNoiceReduction:
                        notiData = (CallSoundNoiseReduction)Marshal.ReadInt32(data);
                        break;

                    case Notification.CallSoundClock:
                        int status = Marshal.ReadInt32(data);
                        if (status == 1)
                        {
                            notiData = true;
                        }

                        else if (status == 0)
                        {
                            notiData = false;
                        }

                        break;

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

                    case Notification.CallupgradeRequested:
                        CallUpgradeDowngradeNotiStruct upgradeNotiStruct = Marshal.PtrToStructure <CallUpgradeDowngradeNotiStruct>(data);
                        notiData = CallStructConversions.ConvertCallUpgradeNoti(upgradeNotiStruct);
                        break;

                    case Notification.CallDowngraded:
                        CallUpgradeDowngradeNotiStruct downgradeNotiStruct = Marshal.PtrToStructure <CallUpgradeDowngradeNotiStruct>(data);
                        notiData = CallStructConversions.ConvertCallUpgradeNoti(downgradeNotiStruct);
                        break;

                    case Notification.ModemPower:
                        notiData = (PhonePowerStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.SimStatus:
                        notiData = (SimCardStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.SimRefreshed:
                        notiData = (SatCmdQualiRefresh)Marshal.ReadInt32(data);
                        break;

                    case Notification.SatSetupMenu:
                        SatMainMenuInfoStruct mainMenuStruct = Marshal.PtrToStructure <SatMainMenuInfoStruct>(data);
                        notiData = SatStructConversions.ConvertSatMainMenuInfoStruct(mainMenuStruct);
                        break;

                    case Notification.SatDisplayText:
                        SatDisplayTextStruct textStruct = Marshal.PtrToStructure <SatDisplayTextStruct>(data);
                        notiData = SatStructConversions.ConvertSatDisplayTextStruct(textStruct);
                        break;

                    case Notification.SatSelectItem:
                        SatSelectItemStruct itemStruct = Marshal.PtrToStructure <SatSelectItemStruct>(data);
                        notiData = SatStructConversions.ConvertSatSelectItemStruct(itemStruct);
                        break;

                    case Notification.SatGetInKey:
                        SatGetInKeyStruct inKeyStruct = Marshal.PtrToStructure <SatGetInKeyStruct>(data);
                        notiData = SatStructConversions.ConvertSatGetInKeyStruct(inKeyStruct);
                        break;

                    case Notification.SatGetInput:
                        SatGetInputStruct inputStruct = Marshal.PtrToStructure <SatGetInputStruct>(data);
                        notiData = SatStructConversions.ConvertSatGetInputStruct(inputStruct);
                        break;

                    case Notification.SatRefresh:
                        SatRefreshStruct refreshStruct = Marshal.PtrToStructure <SatRefreshStruct>(data);
                        notiData = SatStructConversions.ConvertSatRefreshStruct(refreshStruct);
                        break;

                    case Notification.SatSendSms:
                        SatSendSmsStruct smsStruct = Marshal.PtrToStructure <SatSendSmsStruct>(data);
                        notiData = SatStructConversions.ConvertSatSendSmsStruct(smsStruct);
                        break;

                    case Notification.SatSetupEventList:
                        SatEventListDataStruct eventStruct = Marshal.PtrToStructure <SatEventListDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatEventListStruct(eventStruct);
                        break;

                    case Notification.SatSendDtmf:
                        SatSendDtmfDataStruct dtmfStruct = Marshal.PtrToStructure <SatSendDtmfDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatSendDtmfStruct(dtmfStruct);
                        break;

                    case Notification.SatEndProactiveSession:
                        notiData = (SatCommandType)Marshal.ReadInt32(data);
                        break;

                    case Notification.SatCallControlResult:
                        SatCallCtrlIndDataStruct dataStruct = Marshal.PtrToStructure <SatCallCtrlIndDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatCallCtrlIndDataStruct(dataStruct);
                        break;

                    case Notification.SatMoSmControlResult:
                        SatMoSmsCtrlDataStruct moStruct = Marshal.PtrToStructure <SatMoSmsCtrlDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatMoSmsCtrlDataStruct(moStruct);
                        break;

                    case Notification.SatSetupCall:
                        SatSetupCallDataStruct callDataStruct = Marshal.PtrToStructure <SatSetupCallDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatSetupCallDataStruct(callDataStruct);
                        break;

                    case Notification.SatSendSs:
                        SatSendSsDataStruct ssStruct = Marshal.PtrToStructure <SatSendSsDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatSendSsDataStruct(ssStruct);
                        break;

                    case Notification.SatSetupUssd:
                        SatSetupUssdDataStruct ussdStruct = Marshal.PtrToStructure <SatSetupUssdDataStruct>(data);
                        notiData = SatStructConversions.ConvertSatSetupUssdDataStruct(ussdStruct);
                        break;

                    case Notification.PhonebookStatus:
                        SimPhonebookStatusStruct statusStruct = Marshal.PtrToStructure <SimPhonebookStatusStruct>(data);
                        notiData = PhonebookStructConversions.ConvertSimPhonebookStatusStruct(statusStruct);
                        break;

                    case Notification.PhonebookContactChange:
                        PhonebookContactChangeInfoStruct contactStruct = Marshal.PtrToStructure <PhonebookContactChangeInfoStruct>(data);
                        notiData = PhonebookStructConversions.ConvertPhonebookContactChangeStruct(contactStruct);
                        break;

                    case Notification.NetworkRegistrationStatus:
                        NetworkRegistrationStatusStruct nwStruct = Marshal.PtrToStructure <NetworkRegistrationStatusStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkRegistrationStruct(nwStruct);
                        break;

                    case Notification.NetworkCellInfo:
                        NetworkCellNotiStruct notiStruct = Marshal.PtrToStructure <NetworkCellNotiStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkCellNotiStruct(notiStruct);
                        break;

                    case Notification.NetworkChange:
                        NetworkChangeNotiStruct changeStruct = Marshal.PtrToStructure <NetworkChangeNotiStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkChangeStruct(changeStruct);
                        break;

                    case Notification.NetworkTimeInfo:
                        NetworkTimeNotiStruct timeStruct = Marshal.PtrToStructure <NetworkTimeNotiStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkTimeNotiStruct(timeStruct);
                        break;

                    case Notification.NetworkIdentity:
                        NetworkIdentityNotiStruct idStruct = Marshal.PtrToStructure <NetworkIdentityNotiStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkIdentityStruct(idStruct);
                        break;

                    case Notification.NetworkSignalStrength:
                        notiData = Marshal.ReadInt32(data);
                        break;

                    case Notification.NetworkEmergencyCallbackMode:
                        notiData = (NetworkEmergencyCallbackMode)Marshal.ReadInt32(data);
                        break;

                    case Notification.NetworkDefaultDataSubscription:
                        notiData = (NetworkDefaultDataSubscription)Marshal.ReadInt32(data);
                        break;

                    case Notification.NetworkDefaultSubscription:
                        notiData = (NetworkDefaultSubscription)Marshal.ReadInt32(data);
                        break;

                    case Notification.NetworkCellId:
                        notiData = Marshal.ReadInt32(data);
                        break;

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

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

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

                    case Notification.NetworkNetworkId:
                        notiData = Marshal.ReadInt32(data);
                        break;

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

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

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

                    case Notification.NetworkVolteStatus:
                        NetworkVolteStatusStruct volteStruct = Marshal.PtrToStructure <NetworkVolteStatusStruct>(data);
                        notiData = NetworkStructConversions.ConvertNetworkVolteStruct(volteStruct);
                        break;

                    case Notification.NetworkEpdgStatus:
                        int epdgStatus = Marshal.ReadInt32(data);
                        if (epdgStatus == 1)
                        {
                            notiData = true;
                        }

                        else if (epdgStatus == 0)
                        {
                            notiData = false;
                        }

                        break;

                    case Notification.SsUssd:
                        SsUssdMsgInfoStruct ussdInfoStruct = Marshal.PtrToStructure <SsUssdMsgInfoStruct>(data);
                        notiData = SsStructConversions.ConvertSsMsgStruct(ussdInfoStruct);
                        break;

                    case Notification.SsReleaseComplete:
                        SsReleaseCompleteMsgStruct msgStruct = Marshal.PtrToStructure <SsReleaseCompleteMsgStruct>(data);
                        notiData = SsStructConversions.ConvertReleaseMsgStruct(msgStruct);
                        break;

                    case Notification.SsNotifyForwarding:
                        SsForwardResponseStruct responseStruct = Marshal.PtrToStructure <SsForwardResponseStruct>(data);
                        notiData = SsStructConversions.ConvertForwardRspStruct(responseStruct);
                        break;

                    case Notification.SsNotifyBarring:
                        SsBarringResponseStruct barringStruct = Marshal.PtrToStructure <SsBarringResponseStruct>(data);
                        notiData = SsStructConversions.ConvertBarringRspStruct(barringStruct);
                        break;

                    case Notification.SsNotifyWaiting:
                        SsWaitingResponseStruct waitingStruct = Marshal.PtrToStructure <SsWaitingResponseStruct>(data);
                        notiData = SsStructConversions.ConvertWaitingRspStruct(waitingStruct);
                        break;

                    case Notification.SsNotifyInfo:
                        SsInfoStruct ssInfoStruct = Marshal.PtrToStructure <SsInfoStruct>(data);
                        notiData = SsStructConversions.ConvertInfoStruct(ssInfoStruct);
                        break;

                    case Notification.SmsIncomingMsg:
                        SmsIncomingMsgNotiStruct smsNotiStruct = Marshal.PtrToStructure <SmsIncomingMsgNotiStruct>(data);
                        notiData = SmsStructConversions.ConvertSmsIncomingStruct(smsNotiStruct);
                        break;

                    case Notification.SmsIncomingCbMsg:
                        SmsIncomingCbMsgNotiStruct smsCbStruct = Marshal.PtrToStructure <SmsIncomingCbMsgNotiStruct>(data);
                        notiData = SmsStructConversions.ConvertSmsIncomingCbStruct(smsCbStruct);
                        break;

                    case Notification.SmsIncomingEtwsMsg:
                        SmsIncomingEtwsMsgNotiStruct etwsStruct = Marshal.PtrToStructure <SmsIncomingEtwsMsgNotiStruct>(data);
                        notiData = SmsStructConversions.ConvertSmsIncomingEtwsStruct(etwsStruct);
                        break;

                    case Notification.SmsMemoryStatus:
                        notiData = (SmsMemoryStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.SmsReady:
                        notiData = (SmsReadyStatus)Marshal.ReadInt32(data);
                        break;

                    case Notification.OemData:
                        OemDataStruct oemStruct = Marshal.PtrToStructure <OemDataStruct>(data);
                        notiData = OemStructConversions.ConvertOemStruct(oemStruct);
                        break;
                    }

                    _notificationChanged(null, new NotificationChangedEventArgs(noti, notiData));
                }
            };

            _notificationChangedCbList.Add(_notificationChangedCb);

            int ret = Interop.Tapi.RegisterNotiEvent(_handle, TapiUtility.ConvertNotiToString(id), _notificationChangedCb, IntPtr.Zero);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to register notification event, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle);
            }
        }