db2fdc6e59618b6b880b1e1c0360f9406e985dad
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Common / Tizen.Applications / RecentApplicationControl.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.ComponentModel;
20 using System.Runtime.InteropServices;
21
22 namespace Tizen.Applications
23 {
24     /// <summary>
25     /// This class provides methods and properties to get information of the recent application.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class RecentApplicationControl
30     {
31         private const string LogTag = "Tizen.Applications";
32
33         private readonly string _pkgId;
34
35         internal RecentApplicationControl(String pkgId)
36         {
37             _pkgId = pkgId;
38         }
39
40         /// <summary>
41         /// Deletes the application from the recent application list.
42         /// </summary>
43         /// <privlevel>platform</privlevel>
44         /// <since_tizen> 3 </since_tizen>
45         public void Delete()
46         {
47             Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
48             err = Interop.ApplicationManager.RuaDeleteHistoryWithPkgname(_pkgId);
49             if (err != Interop.ApplicationManager.ErrorCode.None)
50             {
51                 throw ApplicationManagerErrorFactory.GetException(err, "Failed to delete application from recent application list.");
52             }
53         }
54
55         /// <summary>
56         /// Deletes all recent applications from the recent application list.
57         /// </summary>
58         /// <privlevel>platform</privlevel>
59         /// <since_tizen> 3 </since_tizen>
60         public static void DeleteAll()
61         {
62             Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
63             err = Interop.ApplicationManager.RuaClearHistory();
64             if (err != Interop.ApplicationManager.ErrorCode.None)
65             {
66                 throw ApplicationManagerErrorFactory.GetException(err, "Failed to clear the recent application list.");
67             }
68         }
69     }
70 }