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