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";
<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" />
[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);
}
}
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";
}
<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" />
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
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
--- /dev/null
+/*
+ * 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.");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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));
+ }
+ }
+}