[NUI] Sync dalihub/TizenFX and Samsung/TizenFX (#528)
[platform/core/csapi/tizenfx.git] / internals / src / Tizen.CallManager / Tizen.CallManager / CallManager.cs
1 /*
2  * Copyright (c) 2018 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
19 namespace Tizen.CallManager
20 {
21     /// <summary>
22     /// A class which manages the use of Call Manager APIs.
23     /// </summary>
24     public static class CallManager
25     {
26         /// <summary>
27         /// Initializes the call manager.
28         /// </summary>
29         /// <returns>An instance of CmClientHandle class to use call manager APIs.</returns>
30         /// <feature>http://tizen.org/feature/network.telephony</feature>
31         /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
32         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
33         public static CmClientHandle InitCm()
34         {
35             int ret = Interop.CallManager.InitCm(out IntPtr handle);
36             if (ret != (int)CmError.None)
37             {
38                 Log.Error(CmUtility.LogTag, "Failed to initialize call manager, Error: " + (CmError)ret);
39                 CmUtility.ThrowCmException(ret);
40             }
41
42             return new CmClientHandle(handle);
43         }
44
45         /// <summary>
46         /// Deinitializes the Call Manager handle.
47         /// </summary>
48         /// <param name="handle">The Call Manager handle to be deinitialized.</param>
49         /// <exception cref="ArgumentNullException">Thrown when CmClientHandle is passed as null.</exception>
50         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
51         public static void DeinitCm(CmClientHandle handle)
52         {
53             if (handle == null)
54             {
55                 throw new ArgumentNullException("Call manager client handle is null");
56             }
57
58             int ret = Interop.CallManager.DeinitCm(handle._handle);
59             if (ret != (int)CmError.None)
60             {
61                 Log.Error(CmUtility.LogTag, "Failed to deinitialize call manager, Error: " + (CmError)ret);
62                 CmUtility.ThrowCmException(ret, handle._handle);
63             }
64
65             handle._handle = IntPtr.Zero;
66         }
67
68         /// <summary>
69         /// Sets LCD state for the device display.
70         /// </summary>
71         /// <param name="state">LCD state to be set.</param>
72         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
73         public static void SetLcdState(LcdControlState state)
74         {
75             int ret = Interop.CallManager.SetLcdState(state);
76             if (ret != (int)CmError.None)
77             {
78                 Log.Error(CmUtility.LogTag, "Failed to set LCD state, Error: " + (CmError)ret);
79                 CmUtility.ThrowCmException(ret);
80             }
81         }
82     }
83 }