[Tapi] Mark API Level as 4
[platform/core/csapi/tizenfx.git] / internal / src / Tizen.Tapi / Tizen.Tapi / TapiHandle.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
20
21 namespace Tizen.Tapi
22 {
23     /// <summary>
24     /// This class is used for managing event callbacks for notifications and properties.
25     /// </summary>
26     /// <since_tizen> 4 </since_tizen>
27     public class TapiHandle
28     {
29         internal IntPtr _handle = IntPtr.Zero;
30         private event EventHandler<NotificationChangedEventArgs> _notificationChanged;
31         private event EventHandler<PropertyChangedEventArgs> _propertyChanged;
32
33         private List<Interop.Tapi.TapiNotificationCallback> _notificationChangedCbList = new List<Interop.Tapi.TapiNotificationCallback>();
34         private Interop.Tapi.TapiNotificationCallback _notificationChangedCb;
35
36         /// <summary>
37         /// This event is called for the TAPI notification change.
38         /// </summary>
39         /// <since_tizen> 4 </since_tizen>
40         public event EventHandler<NotificationChangedEventArgs> NotificationChanged
41         {
42             add
43             {
44                 _notificationChanged += value;
45             }
46
47             remove
48             {
49                 _notificationChanged -= value;
50             }
51         }
52
53         /// <summary>
54         /// This event is called for the TAPI property change.
55         /// </summary>
56         /// <since_tizen> 4 </since_tizen>
57         public event EventHandler<PropertyChangedEventArgs> PropertyChanged
58         {
59             add
60             {
61                 _propertyChanged += value;
62             }
63
64             remove
65             {
66                 _propertyChanged -= value;
67             }
68         }
69
70         internal TapiHandle(IntPtr handle)
71         {
72             _handle = handle;
73         }
74
75         /// <summary>
76         /// Registers a notification callback for notification change events on DBus interface.
77         /// </summary>
78         /// <since_tizen> 4 </since_tizen>
79         /// <param name="id">Notification id for which a callback has to be registered.</param>
80         /// <feature>http://tizen.org/feature/network.telephony</feature>
81         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
82         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
83         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
84         public void RegisterNotiEvent(Notification id)
85         {
86             _notificationChangedCb = (IntPtr handle, IntPtr notiIdPtr, IntPtr data, IntPtr userData) =>
87             {
88                 if (_notificationChanged != null)
89                 {
90                     string notiId = null;
91                     object notiData = null;
92                     Notification noti = default(Notification);
93                     if (notiIdPtr != IntPtr.Zero)
94                     {
95                         notiId = Marshal.PtrToStringAnsi(notiIdPtr);
96                         foreach (Notification n in Enum.GetValues(typeof(Notification)))
97                         {
98                             if (notiId == TapiUtility.ConvertNotiToString(n))
99                             {
100                                 noti = n;
101                                 break;
102                             }
103                         }
104                     }
105
106                     switch (noti)
107                     {
108                         case Notification.IdleVoiceCall:
109                             CallIdleStatusNotiStruct voiceIdleStatusNoti = Marshal.PtrToStructure<CallIdleStatusNotiStruct>(data);
110                             notiData = CallStructConversions.ConvertCallIdleStatusNoti(voiceIdleStatusNoti);
111                             break;
112                         case Notification.ActiveVoiceCall:
113                             notiData = (uint)Marshal.ReadInt32(data);
114                             break;
115                         case Notification.HeldVoiceCall:
116                             notiData = (uint)Marshal.ReadInt32(data);
117                             break;
118                         case Notification.DialingVoiceCall:
119                             notiData = (uint)Marshal.ReadInt32(data);
120                             break;
121                         case Notification.AlertVoiceCall:
122                             notiData = (uint)Marshal.ReadInt32(data);
123                             break;
124                         case Notification.IncomingVoiceCall:
125                             CallIncomingInfoStruct callIncomingInfo = Marshal.PtrToStructure<CallIncomingInfoStruct>(data);
126                             notiData = CallStructConversions.ConvertIncomingCallInfo(callIncomingInfo);
127                             break;
128                         case Notification.IdleVideoCall:
129                             CallIdleStatusNotiStruct videoIdleStatus = Marshal.PtrToStructure<CallIdleStatusNotiStruct>(data);
130                             notiData = CallStructConversions.ConvertCallIdleStatusNoti(videoIdleStatus);
131                             break;
132                         case Notification.ActiveVideoCall:
133                             notiData = (uint)Marshal.ReadInt32(data);
134                             break;
135                         case Notification.DialingVideoCall:
136                             notiData = (uint)Marshal.ReadInt32(data);
137                             break;
138                         case Notification.AlertVideoCall:
139                             notiData = (uint)Marshal.ReadInt32(data);
140                             break;
141                         case Notification.IncomingVideoCall:
142                             CallIncomingInfoStruct videoIncomingInfo = Marshal.PtrToStructure<CallIncomingInfoStruct>(data);
143                             notiData = CallStructConversions.ConvertIncomingCallInfo(videoIncomingInfo);
144                             break;
145                         case Notification.WaitingCallInfo:
146                             notiData = (uint)Marshal.ReadInt32(data);
147                             break;
148                         case Notification.ForwardCallInfo:
149                             notiData = (uint)Marshal.ReadInt32(data);
150                             break;
151                         case Notification.BarredIncomingCallInfo:
152                             notiData = (uint)Marshal.ReadInt32(data);
153                             break;
154                         case Notification.BarredOutgoingCallInfo:
155                             notiData = (uint)Marshal.ReadInt32(data);
156                             break;
157                         case Notification.ForwardUnconditionalCallInfo:
158                             notiData = (uint)Marshal.ReadInt32(data);
159                             break;
160                         case Notification.ForwardConditionalCallInfo:
161                             notiData = (uint)Marshal.ReadInt32(data);
162                             break;
163                         case Notification.ForwardedCallInfo:
164                             notiData = (uint)Marshal.ReadInt32(data);
165                             break;
166                         case Notification.HeldCallInfo:
167                             notiData = (uint)Marshal.ReadInt32(data);
168                             break;
169                         case Notification.ActiveCallInfo:
170                             notiData = (uint)Marshal.ReadInt32(data);
171                             break;
172                         case Notification.JoinedCallInfo:
173                             notiData = (uint)Marshal.ReadInt32(data);
174                             break;
175                         case Notification.RecCallInfo:
176                             CallRecordStruct recordStruct = Marshal.PtrToStructure<CallRecordStruct>(data);
177                             notiData = CallStructConversions.ConvertCallRecordStruct(recordStruct);
178                             break;
179                         case Notification.PrivacyModeCall:
180                             notiData = (CallPrivacyMode)Marshal.ReadInt32(data);
181                             break;
182                         case Notification.OtaspCall:
183                             notiData = (CallOtaspStatus)Marshal.ReadInt32(data);
184                             break;
185                         case Notification.OtapaCall:
186                             notiData = (CallOtapaStatus)Marshal.ReadInt32(data);
187                             break;
188                         case Notification.CallSignalInfo:
189                             CallSignalInfoStruct signalInfoStruct = Marshal.PtrToStructure<CallSignalInfoStruct>(data);
190                             notiData = CallStructConversions.ConvertCallSignalInfo(signalInfoStruct);
191                             break;
192                         case Notification.CallSoundPath:
193                             notiData = (SoundPath)Marshal.ReadInt32(data);
194                             break;
195                         case Notification.CallSoundRingbackTone:
196                             notiData = (CallSoundRingbackNoti)Marshal.ReadInt32(data);
197                             break;
198                         case Notification.CallSoundWbamr:
199                             notiData = (CallSoundWbamrNoti)Marshal.ReadInt32(data);
200                             break;
201                         case Notification.CallSoundNoiceReduction:
202                             notiData = (CallSoundNoiseReduction)Marshal.ReadInt32(data);
203                             break;
204                         case Notification.CallSoundClock:
205                             int status = Marshal.ReadInt32(data);
206                             if (status == 1)
207                             {
208                                 notiData = true;
209                             }
210
211                             else if (status == 0)
212                             {
213                                 notiData = false;
214                             }
215
216                             break;
217                         case Notification.CallPreferredVoiceSubscription:
218                             notiData = (CallPreferredVoiceSubscription)Marshal.ReadInt32(data);
219                             break;
220                         case Notification.CallupgradeRequested:
221                             CallUpgradeDowngradeNotiStruct upgradeNotiStruct = Marshal.PtrToStructure<CallUpgradeDowngradeNotiStruct>(data);
222                             notiData = CallStructConversions.ConvertCallUpgradeNoti(upgradeNotiStruct);
223                             break;
224                         case Notification.CallDowngraded:
225                             CallUpgradeDowngradeNotiStruct downgradeNotiStruct = Marshal.PtrToStructure<CallUpgradeDowngradeNotiStruct>(data);
226                             notiData = CallStructConversions.ConvertCallUpgradeNoti(downgradeNotiStruct);
227                             break;
228                         case Notification.ModemPower:
229                             notiData = (PhonePowerStatus)Marshal.ReadInt32(data);
230                             break;
231                         case Notification.SimStatus:
232                             notiData = (SimCardStatus)Marshal.ReadInt32(data);
233                             break;
234                         case Notification.SimRefreshed:
235                             notiData = (SatCmdQualiRefresh)Marshal.ReadInt32(data);
236                             break;
237                         case Notification.SatSetupMenu:
238                             SatMainMenuInfoStruct mainMenuStruct = Marshal.PtrToStructure<SatMainMenuInfoStruct>(data);
239                             notiData = SatStructConversions.ConvertSatMainMenuInfoStruct(mainMenuStruct);
240                             break;
241                         case Notification.SatDisplayText:
242                             SatDisplayTextStruct textStruct = Marshal.PtrToStructure<SatDisplayTextStruct>(data);
243                             notiData = SatStructConversions.ConvertSatDisplayTextStruct(textStruct);
244                             break;
245                         case Notification.SatSelectItem:
246                             SatSelectItemStruct itemStruct = Marshal.PtrToStructure<SatSelectItemStruct>(data);
247                             notiData = SatStructConversions.ConvertSatSelectItemStruct(itemStruct);
248                             break;
249                         case Notification.SatGetInKey:
250                             SatGetInKeyStruct inKeyStruct = Marshal.PtrToStructure<SatGetInKeyStruct>(data);
251                             notiData = SatStructConversions.ConvertSatGetInKeyStruct(inKeyStruct);
252                             break;
253                         case Notification.SatGetInput:
254                             SatGetInputStruct inputStruct = Marshal.PtrToStructure<SatGetInputStruct>(data);
255                             notiData = SatStructConversions.ConvertSatGetInputStruct(inputStruct);
256                             break;
257                         case Notification.SatRefresh:
258                             SatRefreshStruct refreshStruct = Marshal.PtrToStructure<SatRefreshStruct>(data);
259                             notiData = SatStructConversions.ConvertSatRefreshStruct(refreshStruct);
260                             break;
261                         case Notification.SatSendSms:
262                             SatSendSmsStruct smsStruct = Marshal.PtrToStructure<SatSendSmsStruct>(data);
263                             notiData = SatStructConversions.ConvertSatSendSmsStruct(smsStruct);
264                             break;
265                         case Notification.SatSetupEventList:
266                             SatEventListDataStruct eventStruct = Marshal.PtrToStructure<SatEventListDataStruct>(data);
267                             notiData = SatStructConversions.ConvertSatEventListStruct(eventStruct);
268                             break;
269                         case Notification.SatSendDtmf:
270                             SatSendDtmfDataStruct dtmfStruct = Marshal.PtrToStructure<SatSendDtmfDataStruct>(data);
271                             notiData = SatStructConversions.ConvertSatSendDtmfStruct(dtmfStruct);
272                             break;
273                         case Notification.SatEndProactiveSession:
274                             notiData = (SatCommandType)Marshal.ReadInt32(data);
275                             break;
276                         case Notification.SatCallControlResult:
277                             SatCallCtrlIndDataStruct dataStruct = Marshal.PtrToStructure<SatCallCtrlIndDataStruct>(data);
278                             notiData = SatStructConversions.ConvertSatCallCtrlIndDataStruct(dataStruct);
279                             break;
280                         case Notification.SatMoSmControlResult:
281                             SatMoSmsCtrlDataStruct moStruct = Marshal.PtrToStructure<SatMoSmsCtrlDataStruct>(data);
282                             notiData = SatStructConversions.ConvertSatMoSmsCtrlDataStruct(moStruct);
283                             break;
284                         case Notification.SatSetupCall:
285                             SatSetupCallDataStruct callDataStruct = Marshal.PtrToStructure<SatSetupCallDataStruct>(data);
286                             notiData = SatStructConversions.ConvertSatSetupCallDataStruct(callDataStruct);
287                             break;
288                         case Notification.SatSendSs:
289                             SatSendSsDataStruct ssStruct = Marshal.PtrToStructure<SatSendSsDataStruct>(data);
290                             notiData = SatStructConversions.ConvertSatSendSsDataStruct(ssStruct);
291                             break;
292                         case Notification.SatSetupUssd:
293                             SatSetupUssdDataStruct ussdStruct = Marshal.PtrToStructure<SatSetupUssdDataStruct>(data);
294                             notiData = SatStructConversions.ConvertSatSetupUssdDataStruct(ussdStruct);
295                             break;
296                         case Notification.PhonebookStatus:
297                             SimPhonebookStatusStruct statusStruct = Marshal.PtrToStructure<SimPhonebookStatusStruct>(data);
298                             notiData = PhonebookStructConversions.ConvertSimPhonebookStatusStruct(statusStruct);
299                             break;
300                         case Notification.PhonebookContactChange:
301                             PhonebookContactChangeInfoStruct contactStruct = Marshal.PtrToStructure<PhonebookContactChangeInfoStruct>(data);
302                             notiData = PhonebookStructConversions.ConvertPhonebookContactChangeStruct(contactStruct);
303                             break;
304                         case Notification.NetworkRegistrationStatus:
305                             NetworkRegistrationStatusStruct nwStruct = Marshal.PtrToStructure<NetworkRegistrationStatusStruct>(data);
306                             notiData = NetworkStructConversions.ConvertNetworkRegistrationStruct(nwStruct);
307                             break;
308                         case Notification.NetworkCellInfo:
309                             NetworkCellNotiStruct notiStruct = Marshal.PtrToStructure<NetworkCellNotiStruct>(data);
310                             notiData = NetworkStructConversions.ConvertNetworkCellNotiStruct(notiStruct);
311                             break;
312                         case Notification.NetworkChange:
313                             NetworkChangeNotiStruct changeStruct = Marshal.PtrToStructure<NetworkChangeNotiStruct>(data);
314                             notiData = NetworkStructConversions.ConvertNetworkChangeStruct(changeStruct);
315                             break;
316                         case Notification.NetworkTimeInfo:
317                             NetworkTimeNotiStruct timeStruct = Marshal.PtrToStructure<NetworkTimeNotiStruct>(data);
318                             notiData = NetworkStructConversions.ConvertNetworkTimeNotiStruct(timeStruct);
319                             break;
320                         case Notification.NetworkIdentity:
321                             NetworkIdentityNotiStruct idStruct = Marshal.PtrToStructure<NetworkIdentityNotiStruct>(data);
322                             notiData = NetworkStructConversions.ConvertNetworkIdentityStruct(idStruct);
323                             break;
324                         case Notification.NetworkSignalStrength:
325                             notiData = Marshal.ReadInt32(data);
326                             break;
327                         case Notification.NetworkEmergencyCallbackMode:
328                             notiData = (NetworkEmergencyCallbackMode)Marshal.ReadInt32(data);
329                             break;
330                         case Notification.NetworkDefaultDataSubscription:
331                             notiData = (NetworkDefaultDataSubscription)Marshal.ReadInt32(data);
332                             break;
333                         case Notification.NetworkDefaultSubscription:
334                             notiData = (NetworkDefaultSubscription)Marshal.ReadInt32(data);
335                             break;
336                         case Notification.NetworkCellId:
337                             notiData = Marshal.ReadInt32(data);
338                             break;
339                         case Notification.NetworkLac:
340                             notiData = Marshal.ReadInt32(data);
341                             break;
342                         case Notification.NetworkTac:
343                             notiData = Marshal.ReadInt32(data);
344                             break;
345                         case Notification.NetworkSystemId:
346                             notiData = Marshal.ReadInt32(data);
347                             break;
348                         case Notification.NetworkNetworkId:
349                             notiData = Marshal.ReadInt32(data);
350                             break;
351                         case Notification.NetworkBsId:
352                             notiData = Marshal.ReadInt32(data);
353                             break;
354                         case Notification.NetworkBsLatitude:
355                             notiData = Marshal.ReadInt32(data);
356                             break;
357                         case Notification.NetworkBsLongitude:
358                             notiData = Marshal.ReadInt32(data);
359                             break;
360                         case Notification.NetworkVolteStatus:
361                             NetworkVolteStatusStruct volteStruct = Marshal.PtrToStructure<NetworkVolteStatusStruct>(data);
362                             notiData = NetworkStructConversions.ConvertNetworkVolteStruct(volteStruct);
363                             break;
364                         case Notification.NetworkEpdgStatus:
365                             int epdgStatus = Marshal.ReadInt32(data);
366                             if (epdgStatus == 1)
367                             {
368                                 notiData = true;
369                             }
370
371                             else if (epdgStatus == 0)
372                             {
373                                 notiData = false;
374                             }
375
376                             break;
377                         case Notification.SsUssd:
378                             SsUssdMsgInfoStruct ussdInfoStruct = Marshal.PtrToStructure<SsUssdMsgInfoStruct>(data);
379                             notiData = SsStructConversions.ConvertSsMsgStruct(ussdInfoStruct);
380                             break;
381                         case Notification.SsReleaseComplete:
382                             SsReleaseCompleteMsgStruct msgStruct = Marshal.PtrToStructure<SsReleaseCompleteMsgStruct>(data);
383                             notiData = SsStructConversions.ConvertReleaseMsgStruct(msgStruct);
384                             break;
385                         case Notification.SsNotifyForwarding:
386                             SsForwardResponseStruct responseStruct = Marshal.PtrToStructure<SsForwardResponseStruct>(data);
387                             notiData = SsStructConversions.ConvertForwardRspStruct(responseStruct);
388                             break;
389                         case Notification.SsNotifyBarring:
390                             SsBarringResponseStruct barringStruct = Marshal.PtrToStructure<SsBarringResponseStruct>(data);
391                             notiData = SsStructConversions.ConvertBarringRspStruct(barringStruct);
392                             break;
393                         case Notification.SsNotifyWaiting:
394                             SsWaitingResponseStruct waitingStruct = Marshal.PtrToStructure<SsWaitingResponseStruct>(data);
395                             notiData = SsStructConversions.ConvertWaitingRspStruct(waitingStruct);
396                             break;
397                         case Notification.SsNotifyInfo:
398                             SsInfoStruct ssInfoStruct = Marshal.PtrToStructure<SsInfoStruct>(data);
399                             notiData = SsStructConversions.ConvertInfoStruct(ssInfoStruct);
400                             break;
401                         case Notification.SmsIncomingMsg:
402                             SmsIncomingMsgNotiStruct smsNotiStruct = Marshal.PtrToStructure<SmsIncomingMsgNotiStruct>(data);
403                             notiData = SmsStructConversions.ConvertSmsIncomingStruct(smsNotiStruct);
404                             break;
405                         case Notification.SmsIncomingCbMsg:
406                             SmsIncomingCbMsgNotiStruct smsCbStruct = Marshal.PtrToStructure<SmsIncomingCbMsgNotiStruct>(data);
407                             notiData = SmsStructConversions.ConvertSmsIncomingCbStruct(smsCbStruct);
408                             break;
409                         case Notification.SmsIncomingEtwsMsg:
410                             SmsIncomingEtwsMsgNotiStruct etwsStruct = Marshal.PtrToStructure<SmsIncomingEtwsMsgNotiStruct>(data);
411                             notiData = SmsStructConversions.ConvertSmsIncomingEtwsStruct(etwsStruct);
412                             break;
413                         case Notification.SmsMemoryStatus:
414                             notiData = (SmsMemoryStatus)Marshal.ReadInt32(data);
415                             break;
416                         case Notification.SmsReady:
417                             notiData = (SmsReadyStatus)Marshal.ReadInt32(data);
418                             break;
419                         case Notification.OemData:
420                             OemDataStruct oemStruct = Marshal.PtrToStructure<OemDataStruct>(data);
421                             notiData = OemStructConversions.ConvertOemStruct(oemStruct);
422                             break;
423                     }
424
425                     _notificationChanged(null, new NotificationChangedEventArgs(noti, notiData));
426                 }
427             };
428
429             _notificationChangedCbList.Add(_notificationChangedCb);
430
431             int ret = Interop.Tapi.RegisterNotiEvent(_handle, TapiUtility.ConvertNotiToString(id), _notificationChangedCb, IntPtr.Zero);
432             if (ret != (int)TapiError.Success)
433             {
434                 Log.Error(TapiUtility.LogTag, "Failed to register notification event, Error: " + (TapiError)ret);
435                 TapiUtility.ThrowTapiException(ret, _handle);
436             }
437         }
438
439         /// <summary>
440         /// Registers a notification callback for property change events on DBus interface.
441         /// </summary>
442         /// <since_tizen> 4 </since_tizen>
443         /// <param name="property">Property definition for which a callback has to be registered.</param>
444         /// <feature>http://tizen.org/feature/network.telephony</feature>
445         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
446         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
447         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
448         public void RegisterPropEvent(Property property)
449         {
450             _notificationChangedCb = (IntPtr handle, IntPtr propPtr, IntPtr data, IntPtr userData) =>
451             {
452                 if (_propertyChanged != null)
453                 {
454                     string prop = null;
455                     object propData = null;
456                     Property propertyId = default(Property);
457                     if (propPtr != IntPtr.Zero)
458                     {
459                         prop = Marshal.PtrToStringAnsi(propPtr);
460                         foreach (Property p in Enum.GetValues(typeof(Property)))
461                         {
462                             if (prop == TapiUtility.ConvertPropToString(p))
463                             {
464                                 propertyId = p;
465                                 break;
466                             }
467                         }
468                     }
469
470                     switch (propertyId)
471                     {
472                         case Property.ModemPower:
473                             propData = (PhonePowerStatus)Marshal.ReadInt32(data);
474                             break;
475                         case Property.ModemDongleStatus:
476                             int dongleStatus = Marshal.ReadInt32(data);
477                             if (dongleStatus == 1)
478                             {
479                                 propData = true;
480                             }
481
482                             else if (dongleStatus == 0)
483                             {
484                                 propData = false;
485                             }
486
487                             break;
488                         case Property.ModemDongleLogin:
489                             int loginStatus = Marshal.ReadInt32(data);
490                             if (loginStatus == 1)
491                             {
492                                 propData = true;
493                             }
494
495                             else if (loginStatus == 0)
496                             {
497                                 propData = false;
498                             }
499
500                             break;
501                         case Property.SimCallForwardState:
502                             int forwardState = Marshal.ReadInt32(data);
503                             if (forwardState == 1)
504                             {
505                                 propData = true;
506                             }
507
508                             else if (forwardState == 0)
509                             {
510                                 propData = false;
511                             }
512
513                             break;
514                         case Property.NetworkLac:
515                             propData = (uint)Marshal.ReadInt32(data);
516                             break;
517                         case Property.NetworkTac:
518                             propData = (uint)Marshal.ReadInt32(data);
519                             break;
520                         case Property.NetworkPlmn:
521                             propData = Marshal.PtrToStringAnsi(data);
522                             break;
523                         case Property.NetworkCellId:
524                             propData = (uint)Marshal.ReadInt32(data);
525                             break;
526                         case Property.NetworkPhysicalCellId:
527                             propData = (uint)Marshal.ReadInt32(data);
528                             break;
529                         case Property.NetworkServiceType:
530                             propData = (NetworkServiceType)Marshal.ReadInt32(data);
531                             break;
532                         case Property.NetworkAct:
533                             propData = (NetworkSystemType)Marshal.ReadInt32(data);
534                             break;
535                         case Property.NetworkPsType:
536                             propData = (NetworkPsType)Marshal.ReadInt32(data);
537                             break;
538                         case Property.NetworkCircuitStatus:
539                             propData = (NetworkServiceLevel)Marshal.ReadInt32(data);
540                             break;
541                         case Property.NetworkPacketStatus:
542                             propData = (NetworkServiceLevel)Marshal.ReadInt32(data);
543                             break;
544                         case Property.NetworkRoamingStatus:
545                             int roamingStatus = Marshal.ReadInt32(data);
546                             if (roamingStatus == 1)
547                             {
548                                 propData = true;
549                             }
550
551                             else if (roamingStatus == 0)
552                             {
553                                 propData = false;
554                             }
555
556                             break;
557                         case Property.NetworkNameOption:
558                             propData = (NetworkNameDisplayCondition)Marshal.ReadInt32(data);
559                             break;
560                         case Property.NetworkName:
561                             propData = Marshal.PtrToStringAnsi(data);
562                             break;
563                         case Property.NetworkSpnName:
564                             propData = Marshal.PtrToStringAnsi(data);
565                             break;
566                         case Property.NetworkSignalDbm:
567                             propData = Marshal.ReadInt32(data);
568                             break;
569                         case Property.NetworkSignalLevel:
570                             propData = Marshal.ReadInt32(data);
571                             break;
572                         case Property.NetworkImsVoiceStatus:
573                             int imsStatus = Marshal.ReadInt32(data);
574                             if (imsStatus == 1)
575                             {
576                                 propData = true;
577                             }
578
579                             else if (imsStatus == 0)
580                             {
581                                 propData = false;
582                             }
583
584                             break;
585                         case Property.NetworkVolteEnable:
586                             propData = (VolteNetworkType)Marshal.ReadInt32(data);
587                             break;
588                         case Property.NetworkLteBand:
589                             propData = (NetworkLteBandType)Marshal.ReadInt32(data);
590                             break;
591                     }
592
593                     _propertyChanged(null, new PropertyChangedEventArgs(propertyId, propData));
594                 }
595             };
596
597             _notificationChangedCbList.Add(_notificationChangedCb);
598             int ret = Interop.Tapi.RegisterNotiEvent(_handle, TapiUtility.ConvertPropToString(property), _notificationChangedCb, IntPtr.Zero);
599             if (ret != (int)TapiError.Success)
600             {
601                 Log.Error(TapiUtility.LogTag, "Failed to register notification event for property change, Error: " + (TapiError)ret);
602                 TapiUtility.ThrowTapiException(ret, _handle);
603             }
604         }
605
606         /// <summary>
607         /// Deregisters notification callback for notification change events on DBus interface.
608         /// </summary>
609         /// <since_tizen> 4 </since_tizen>
610         /// <param name="id">Notification id for which the callback has to be de-registered.</param>
611         /// <feature>http://tizen.org/feature/network.telephony</feature>
612         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
613         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
614         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
615         public void DeregisterNotiEvent(Notification id)
616         {
617             int ret = Interop.Tapi.DeregisterNotiEvent(_handle, TapiUtility.ConvertNotiToString(id));
618             if (ret != (int)TapiError.Success)
619             {
620                 Log.Error(TapiUtility.LogTag, "Failed to deregister notification event, Error: " + (TapiError)ret);
621                 TapiUtility.ThrowTapiException(ret, _handle);
622             }
623         }
624
625         /// <summary>
626         /// Deregisters notification callback for property change events on DBus interface.
627         /// </summary>
628         /// <since_tizen> 4 </since_tizen>
629         /// <param name="property">Property definition for which the callback has to be de-registered.</param>
630         /// <feature>http://tizen.org/feature/network.telephony</feature>
631         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
632         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
633         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
634         public void DeregisterPropEvent(Property property)
635         {
636             int ret = Interop.Tapi.DeregisterNotiEvent(_handle, TapiUtility.ConvertPropToString(property));
637             if (ret != (int)TapiError.Success)
638             {
639                 Log.Error(TapiUtility.LogTag, "Failed to deregister notification event for property change, Error: " + (TapiError)ret);
640                 TapiUtility.ThrowTapiException(ret, _handle);
641             }
642         }
643
644         /// <summary>
645         /// Gets the property value in an integer format for the given property.
646         /// </summary>
647         /// <since_tizen> 4 </since_tizen>
648         /// <param name="property">The property to be retrieved from Dbus.</param>
649         /// <returns>The property value in integer format.</returns>
650         /// <feature>http://tizen.org/feature/network.telephony</feature>
651         /// <privilege>http://tizen.org/privilege/telephony</privilege>
652         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
653         /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
654         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
655         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
656         public int GetIntProperty(Property property)
657         {
658             int result;
659             int ret = Interop.Tapi.GetIntProperty(_handle, TapiUtility.ConvertPropToString(property), out result);
660             if (ret != (int)TapiError.Success)
661             {
662                 Log.Error(TapiUtility.LogTag, "Failed to get property in integer format, Error: " + (TapiError)ret);
663                 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
664             }
665
666             return result;
667         }
668
669         /// <summary>
670         /// Gets the property value in a string format for the given property.
671         /// </summary>
672         /// <since_tizen> 4 </since_tizen>
673         /// <param name="property">The property to be retrieved from Dbus.</param>
674         /// <returns>The property value in string format.</returns>
675         /// <feature>http://tizen.org/feature/network.telephony</feature>
676         /// <privilege>http://tizen.org/privilege/telephony</privilege>
677         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
678         /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
679         /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
680         /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
681         public string GetStringProperty(Property property)
682         {
683             string result;
684             int ret = Interop.Tapi.GetStringProperty(_handle, TapiUtility.ConvertPropToString(property), out result);
685             if (ret != (int)TapiError.Success)
686             {
687                 Log.Error(TapiUtility.LogTag, "Failed to get property in string format, Error: " + (TapiError)ret);
688                 TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
689             }
690
691             return result;
692         }
693     }
694 }