Esempio n. 1
0
        internal static SimPhonebookStatus ConvertSimPhonebookStatusStruct(SimPhonebookStatusStruct statusStruct)
        {
            SimPhonebookStatus status = new SimPhonebookStatus();

            if (statusStruct.IsInitCompleted == 1)
            {
                status.InitStatus = true;
            }

            else if (statusStruct.IsInitCompleted == 0)
            {
                status.InitStatus = false;
            }

            status.List = ConvertSimPhonebookListStruct(statusStruct.PbList);
            return(status);
        }
Esempio n. 2
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);
            }
        }