Release 4.0.0-preview1-00051
[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 recent application.
26     /// </summary>
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class RecentApplicationControl
29     {
30         private const string LogTag = "Tizen.Applications";
31
32         private readonly string _pkgId;
33
34         internal RecentApplicationControl(String pkgId)
35         {
36             _pkgId = pkgId;
37         }
38
39         /// <summary>
40         /// Deletes the application from recent application list.
41         /// </summary>
42         /// <privlevel>platform</privlevel>
43         public void Delete()
44         {
45             Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
46             err = Interop.ApplicationManager.RuaDeleteHistoryWithPkgname(_pkgId);
47             if (err != Interop.ApplicationManager.ErrorCode.None)
48             {
49                 throw ApplicationManagerErrorFactory.GetException(err, "Failed to delete application from recent application list.");
50             }
51         }
52
53         /// <summary>
54         /// Delete all recent applicationsfrom recent application list.
55         /// </summary>
56         /// <privlevel>platform</privlevel>
57         public static void DeleteAll()
58         {
59             Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None;
60             err = Interop.ApplicationManager.RuaClearHistory();
61             if (err != Interop.ApplicationManager.ErrorCode.None)
62             {
63                 throw ApplicationManagerErrorFactory.GetException(err, "Failed to clear the recent application list.");
64             }
65         }
66     }
67 }