diff options
-rwxr-xr-x | Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs | 38 | ||||
-rwxr-xr-x | Tizen.Applications.Common/Interop/Interop.Libraries.cs | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | Tizen.Applications.Common/Tizen.Applications.Common.csproj | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs | 43 | ||||
-rwxr-xr-x | Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs | 63 | ||||
-rwxr-xr-x | Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs | 69 | ||||
-rwxr-xr-x | Tizen.Applications/Interop/Interop.Libraries.cs | 1 | ||||
-rwxr-xr-x | Tizen.Applications/Tizen.Applications.csproj | 2 |
8 files changed, 219 insertions, 0 deletions
diff --git a/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs b/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs index d93378a..e114c1b 100755 --- a/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs +++ b/Tizen.Applications.Common/Interop/Interop.ApplicationManager.cs @@ -305,5 +305,43 @@ internal static partial class Interop [DllImport(Libraries.AppManager, EntryPoint = "app_info_metadata_filter_foreach")] internal static extern ErrorCode AppInfoMetadataFilterForeach(IntPtr handle, AppInfoFilterCallback callback, IntPtr userData); //int app_info_metadata_filter_foreach (app_info_metadata_filter_h handle, app_info_filter_cb callback, void *user_data) + + [StructLayout(LayoutKind.Sequential)] + internal struct RuaRec + { + internal int id; + internal IntPtr pkgName; + internal IntPtr appPath; + internal IntPtr arg; + internal long launchTime; + internal IntPtr instanceId; + internal IntPtr instanceName; + internal IntPtr icon; + internal IntPtr uri; + }; + + [DllImport(Libraries.Rua, EntryPoint = "rua_history_get_rec")] + internal static extern ErrorCode RuaHistoryGetRecord(out RuaRec record, IntPtr table, int nRows, int nCols, int row); + //int rua_history_get_rec(struct rua_rec *rec, char** table, int nrows, int ncols, int row); + + [DllImport(Libraries.Rua, EntryPoint = "rua_history_load_db")] + internal static extern ErrorCode RuaHistoryLoadDb(out IntPtr table, out int nRows, out int nCols); + //int rua_history_load_db(char*** table, int *nrows, int *ncols); + + [DllImport(Libraries.Rua, EntryPoint = "rua_history_unload_db")] + internal static extern ErrorCode RuaHistoryUnLoadDb(ref IntPtr table); + //int rua_history_unload_db(char*** table); + + [DllImport(Libraries.Rua, EntryPoint = "rua_delete_history_with_pkgname")] + internal static extern ErrorCode RuaDeleteHistoryWithPkgname(string pkgName); + //int rua_delete_history_with_pkgname(char* pkg_name); + + [DllImport(Libraries.Rua, EntryPoint = "rua_delete_history_with_apppath")] + internal static extern ErrorCode RuaDeleteHistoryWithApppath(string appPath); + //int rua_delete_history_with_apppath(char* app_path); + + [DllImport(Libraries.Rua, EntryPoint = "rua_clear_history")] + internal static extern ErrorCode RuaClearHistory(); + //int rua_clear_history(void); } } diff --git a/Tizen.Applications.Common/Interop/Interop.Libraries.cs b/Tizen.Applications.Common/Interop/Interop.Libraries.cs index 5caecca..e9a8f47 100755 --- a/Tizen.Applications.Common/Interop/Interop.Libraries.cs +++ b/Tizen.Applications.Common/Interop/Interop.Libraries.cs @@ -23,6 +23,7 @@ internal static partial class Interop public const string AppEvent = "libcapi-appfw-event.so.0"; public const string AppManager = "libcapi-appfw-app-manager.so.0"; public const string Bundle = "libbundle.so.0"; + public const string Rua = "librua.so.0"; public const string Glib = "libglib-2.0.so.0"; public const string Libc = "libc.so.6"; } diff --git a/Tizen.Applications.Common/Tizen.Applications.Common.csproj b/Tizen.Applications.Common/Tizen.Applications.Common.csproj index 2a69bc6..c2880a2 100644..100755 --- a/Tizen.Applications.Common/Tizen.Applications.Common.csproj +++ b/Tizen.Applications.Common/Tizen.Applications.Common.csproj @@ -60,6 +60,8 @@ <Compile Include="Tizen.Applications\ApplicationDisabledEventArgs.cs" /> <Compile Include="Tizen.Applications\ApplicationEventState.cs" /> <Compile Include="Tizen.Applications\ApplicationRunningContext.cs" /> + <Compile Include="Tizen.Applications\RecentApplicationControl.cs" /> + <Compile Include="Tizen.Applications\RecentApplicationInfo.cs" /> <Compile Include="Tizen.Applications\ApplicationInfo.cs" /> <Compile Include="Tizen.Applications\ApplicationManager.cs" /> <Compile Include="Tizen.Applications\ApplicationInfoFilter.cs" /> diff --git a/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs b/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs index ea2dd74..c99c04d 100644..100755 --- a/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs +++ b/Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace Tizen.Applications @@ -399,6 +400,48 @@ namespace Tizen.Applications _eventHandle = IntPtr.Zero; } } + + /// <summary> + /// Gets the information of the recent applications. + /// </summary> + /// <returns>Returns a dictionary containing all recent application info.</returns> + /// <exception cref="InvalidOperationException">Thrown when failed because of invalid operation</exception> + public static IEnumerable<RecentApplicationInfo> GetRecentApplications() + { + Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None; + + List<RecentApplicationInfo> result = new List<RecentApplicationInfo>(); + IntPtr table; + int nrows, ncols; + + err = Interop.ApplicationManager.RuaHistoryLoadDb(out table, out nrows, out ncols); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + throw ApplicationManagerErrorFactory.GetException(err, "Failed to load a table for the recent application list."); + } + + for (int row = 0; row < nrows; ++row) + { + Interop.ApplicationManager.RuaRec record; + + err = Interop.ApplicationManager.RuaHistoryGetRecord(out record, table, nrows, ncols, row); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + throw ApplicationManagerErrorFactory.GetException(err, "Failed to get record."); + } + + RecentApplicationInfo info = new RecentApplicationInfo(record); + result.Add(info); + } + + err = Interop.ApplicationManager.RuaHistoryUnLoadDb(ref table); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + throw ApplicationManagerErrorFactory.GetException(err, "Failed to unload a table for the recent application list."); + } + + return result; + } } internal static class FilterExtension diff --git a/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs b/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs new file mode 100755 index 0000000..418cef1 --- /dev/null +++ b/Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Tizen.Applications +{ + /// <summary> + /// This class provides methods and properties to get information of recent application. + /// </summary> + public class RecentApplicationControl + { + private const string LogTag = "Tizen.Applications"; + + private readonly string _pkgId; + + internal RecentApplicationControl(String pkgId) + { + _pkgId = pkgId; + } + + /// <summary> + /// Deletes the application from recent application list. + /// </summary> + public void Delete() + { + Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None; + err = Interop.ApplicationManager.RuaDeleteHistoryWithPkgname(_pkgId); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + throw ApplicationManagerErrorFactory.GetException(err, "Failed to delete application from recent application list."); + } + } + + /// <summary> + /// Delete all recent applicationsfrom recent application list. + /// </summary> + public static void DeleteAll() + { + Interop.ApplicationManager.ErrorCode err = Interop.ApplicationManager.ErrorCode.None; + err = Interop.ApplicationManager.RuaClearHistory(); + if (err != Interop.ApplicationManager.ErrorCode.None) + { + throw ApplicationManagerErrorFactory.GetException(err, "Failed to clear the recent application list."); + } + } + } +} diff --git a/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs b/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs new file mode 100755 index 0000000..8812e4f --- /dev/null +++ b/Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +namespace Tizen.Applications +{ + /// <summary> + /// This class provides methods and properties to get information of recent application. + /// </summary> + public class RecentApplicationInfo : ApplicationInfo + { + private const string LogTag = "Tizen.Applications"; + + /// <summary> + /// Gets the instance id. + /// </summary> + public string InstanceId { get; private set; } + + /// <summary> + /// Gets the instance Name. + /// </summary> + public string InstanceName { get; private set; } + + /// <summary> + /// Gets the arguements. + /// </summary> + public string Arg { get; private set; } + + /// <summary> + /// Gets the uri. + /// </summary> + public string Uri { get; private set; } + + /// <summary> + /// Gets the launchTime. + /// </summary> + public DateTime LaunchTime { get; private set; } + + /// <summary> + /// Gets the recent application controller. + /// </summary> + public RecentApplicationControl Controller { get; private set; } + + internal RecentApplicationInfo(Interop.ApplicationManager.RuaRec record) : base(Marshal.PtrToStringAnsi(record.pkgName)) + { + InstanceId = Marshal.PtrToStringAnsi(record.instanceId); + InstanceName = Marshal.PtrToStringAnsi(record.instanceName); + Arg = Marshal.PtrToStringAnsi(record.arg); + Uri = Marshal.PtrToStringAnsi(record.uri); + LaunchTime = new DateTime(1970, 1, 1).AddSeconds(record.launchTime); + Controller = new RecentApplicationControl(Marshal.PtrToStringAnsi(record.pkgName)); + } + } +} diff --git a/Tizen.Applications/Interop/Interop.Libraries.cs b/Tizen.Applications/Interop/Interop.Libraries.cs index ecf4b10..b1463d7 100755 --- a/Tizen.Applications/Interop/Interop.Libraries.cs +++ b/Tizen.Applications/Interop/Interop.Libraries.cs @@ -29,6 +29,7 @@ internal static partial class Interop public const string Bundle = "libbundle.so.0"; public const string Glib = "libglib-2.0.so.0"; public const string Libc = "libc.so.6"; + public const string Rua = "librua.so.0"; public const string Notification = "libnotification.so.0"; public const string Preference = "libcapi-appfw-preference.so.0"; public const string Alarm = "libcapi-appfw-alarm.so.0"; diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj index f74d4a0..201adcf 100755 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -62,6 +62,8 @@ <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationInfo.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationInfoFilter.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationInfoMetadataFilter.cs" /> + <Compile Include="../Tizen.Applications.Common/Tizen.Applications/RecentApplicationInfo.cs" /> + <Compile Include="../Tizen.Applications.Common/Tizen.Applications/RecentApplicationControl.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationLaunchedEventArgs.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationManager.cs" /> <Compile Include="../Tizen.Applications.Common/Tizen.Applications/ApplicationRunningContext.cs" /> |