/// <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); } }
/// <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); }
/// <summary> /// Registers a notification callback for property change events on DBus interface. /// </summary> /// <param name="property">Property definition 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 RegisterPropEvent(Property property) { _notificationChangedCb = (IntPtr handle, IntPtr propPtr, IntPtr data, IntPtr userData) => { if (_propertyChanged != null) { string prop = null; object propData = null; Property propertyId = default(Property); if (propPtr != IntPtr.Zero) { prop = Marshal.PtrToStringAnsi(propPtr); foreach (Property p in Enum.GetValues(typeof(Property))) { if (prop == TapiUtility.ConvertPropToString(p)) { propertyId = p; break; } } } switch (propertyId) { case Property.ModemPower: propData = (PhonePowerStatus)Marshal.ReadInt32(data); break; case Property.ModemDongleStatus: int dongleStatus = Marshal.ReadInt32(data); if (dongleStatus == 1) { propData = true; } else if (dongleStatus == 0) { propData = false; } break; case Property.ModemDongleLogin: int loginStatus = Marshal.ReadInt32(data); if (loginStatus == 1) { propData = true; } else if (loginStatus == 0) { propData = false; } break; case Property.SimCallForwardState: int forwardState = Marshal.ReadInt32(data); if (forwardState == 1) { propData = true; } else if (forwardState == 0) { propData = false; } break; case Property.NetworkLac: propData = (uint)Marshal.ReadInt32(data); break; case Property.NetworkTac: propData = (uint)Marshal.ReadInt32(data); break; case Property.NetworkPlmn: propData = Marshal.PtrToStringAnsi(data); break; case Property.NetworkCellId: propData = (uint)Marshal.ReadInt32(data); break; case Property.NetworkPhysicalCellId: propData = (uint)Marshal.ReadInt32(data); break; case Property.NetworkServiceType: propData = (NetworkServiceType)Marshal.ReadInt32(data); break; case Property.NetworkAct: propData = (NetworkSystemType)Marshal.ReadInt32(data); break; case Property.NetworkPsType: propData = (NetworkPsType)Marshal.ReadInt32(data); break; case Property.NetworkCircuitStatus: propData = (NetworkServiceLevel)Marshal.ReadInt32(data); break; case Property.NetworkPacketStatus: propData = (NetworkServiceLevel)Marshal.ReadInt32(data); break; case Property.NetworkRoamingStatus: int roamingStatus = Marshal.ReadInt32(data); if (roamingStatus == 1) { propData = true; } else if (roamingStatus == 0) { propData = false; } break; case Property.NetworkNameOption: propData = (NetworkNameDisplayCondition)Marshal.ReadInt32(data); break; case Property.NetworkName: propData = Marshal.PtrToStringAnsi(data); break; case Property.NetworkSpnName: propData = Marshal.PtrToStringAnsi(data); break; case Property.NetworkSignalDbm: propData = Marshal.ReadInt32(data); break; case Property.NetworkSignalLevel: propData = Marshal.ReadInt32(data); break; case Property.NetworkImsVoiceStatus: int imsStatus = Marshal.ReadInt32(data); if (imsStatus == 1) { propData = true; } else if (imsStatus == 0) { propData = false; } break; case Property.NetworkVolteEnable: propData = (VolteNetworkType)Marshal.ReadInt32(data); break; case Property.NetworkLteBand: propData = (NetworkLteBandType)Marshal.ReadInt32(data); break; } _propertyChanged(null, new PropertyChangedEventArgs(propertyId, propData)); } }; _notificationChangedCbList.Add(_notificationChangedCb); int ret = Interop.Tapi.RegisterNotiEvent(_handle, TapiUtility.ConvertPropToString(property), _notificationChangedCb, IntPtr.Zero); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to register notification event for property change, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle); } }