[EflSharp] Update Circle and efl cs files (#995)
[platform/core/csapi/tizenfx.git] / test / SampleTelephony / CallPage.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Xamarin.Forms;
5 using Tizen;
6 using Tizen.Telephony;
7
8 namespace XamarinForTizen.Tizen
9 {
10     public class CallPage : ContentPage
11     {
12         private static Call _call = null;
13         private ChangeNotificationEventArgs.Notification[] notiArr = { ChangeNotificationEventArgs.Notification.CallPreferredVoiceSubscription,
14                                                                        ChangeNotificationEventArgs.Notification.VoiceCallStatusDialing,
15                                                                        ChangeNotificationEventArgs.Notification.VoiceCallStatusIncoming };
16         public CallPage()
17         {
18             var subsBtn = new Button
19             {
20                 Text = "Get preferred voice subscription",
21                 VerticalOptions = LayoutOptions.Start,
22                 HorizontalOptions = LayoutOptions.FillAndExpand
23             };
24             subsBtn.Clicked += subsBtn_Clicked;
25
26             var callListBtn = new Button
27             {
28                 Text = "Get call list",
29                 VerticalOptions = LayoutOptions.Start,
30                 HorizontalOptions = LayoutOptions.FillAndExpand
31             };
32             callListBtn.Clicked += callListBtn_Clicked;
33
34             Content = new StackLayout
35             {
36                 VerticalOptions = LayoutOptions.Center,
37                 Children = {
38                         subsBtn, callListBtn
39                     }
40             };
41
42             try
43             {
44                 if (Globals.slotHandle == null)
45                 {
46                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
47                     return;
48                 }
49
50                 Globals.slotHandle.ChangeNotification += SlotHandle_ChangeNotification;
51                 List<ChangeNotificationEventArgs.Notification> notiList = new List<ChangeNotificationEventArgs.Notification>();
52                 foreach (ChangeNotificationEventArgs.Notification noti in notiArr)
53                 {
54                     notiList.Add(noti);
55                 }
56
57                 Globals.slotHandle.SetNotificationId(notiList);
58                 _call = new Call(Globals.slotHandle);
59             }
60
61             catch (Exception ex)
62             {
63                 Log.Debug(Globals.LogTag, "Exception in call constructor: " + ex.ToString());
64             }
65         }
66
67         private void SlotHandle_ChangeNotification(object sender, ChangeNotificationEventArgs e)
68         {
69             Log.Debug(Globals.LogTag, "Change notification: " + e.NotificationType);
70         }
71
72         private void callListBtn_Clicked(object sender, EventArgs e)
73         {
74             try
75             {
76                 if (_call == null)
77                 {
78                     Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
79                     return;
80                 }
81
82                 List<CallHandle> handleList = _call.GetCallHandleList().ToList();
83                 if (handleList.Count == 0)
84                 {
85                     Log.Debug(Globals.LogTag, "Call handle list is empty");
86                     return;
87                 }
88
89                 foreach (CallHandle handle in handleList)
90                 {
91                     Log.Debug(Globals.LogTag, "HandleId: " + handle.HandleId);
92                     Log.Debug(Globals.LogTag, "Number: " + handle.Number);
93                     Log.Debug(Globals.LogTag, "Type: " + handle.Type);
94                     Log.Debug(Globals.LogTag, "Status: " + handle.Status);
95                     Log.Debug(Globals.LogTag, "Direction: " + handle.Direction);
96                     Log.Debug(Globals.LogTag, "ConferenceStatus: " + handle.ConferenceStatus);
97                 }
98             }
99
100             catch(Exception ex)
101             {
102                 Log.Debug(Globals.LogTag, "Exception caught in getting call list: " + ex.ToString());
103             }
104         }
105
106         private void subsBtn_Clicked(object sender, EventArgs e)
107         {
108             if (_call == null)
109             {
110                 Log.Debug(Globals.LogTag, "Telephony is not initialized/there are no sim slot handles");
111                 return;
112             }
113
114             Log.Debug(Globals.LogTag, "Preferred voice subscription: " + _call.PreferredVoiceSubscription);
115         }
116     }
117 }