1 /// Copyright 2016 by Samsung Electronics, Inc.,
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
10 using System.Collections.Generic;
11 using System.Runtime.InteropServices;
13 namespace Tizen.Applications.Manager
16 /// InstalledApplication class. This class has the methods and properties of InstalledApplication.
18 public class InstalledApplication : IDisposable
20 private IntPtr _handle;
21 private bool disposed = false;
23 internal InstalledApplication(IntPtr handle)
29 /// ApplicationId property.
31 /// <returns>string application id.</returns>
32 public string ApplicationId
36 IntPtr ptr = IntPtr.Zero;
37 Interop.ApplicationManager.AppInfoGetAppId(_handle, out ptr);
38 string appid = Marshal.PtrToStringAuto(ptr);
43 /// PackageId property.
45 /// <returns>string package id.</returns>
46 public string PackageId
50 IntPtr ptr = IntPtr.Zero;
51 Interop.ApplicationManager.AppInfoGetPackage(_handle, out ptr);
52 string packageid = Marshal.PtrToStringAuto(ptr);
59 /// <returns>string label.</returns>
64 IntPtr ptr = IntPtr.Zero;
65 Interop.ApplicationManager.AppInfoGetLabel(_handle, out ptr);
66 string label = Marshal.PtrToStringAuto(ptr);
71 /// ExcutablePath property.
73 /// <returns>string executable path.</returns>
74 public string ExcutablePath
78 IntPtr ptr = IntPtr.Zero;
79 Interop.ApplicationManager.AppInfoGetExec(_handle, out ptr);
80 string exec = Marshal.PtrToStringAuto(ptr);
85 /// IconPath property.
87 /// <returns>string icon path.</returns>
88 public string IconPath
92 IntPtr ptr = IntPtr.Zero;
93 Interop.ApplicationManager.AppInfoGetIcon(_handle, out ptr);
94 string path = Marshal.PtrToStringAuto(ptr);
101 /// <returns>string application type.</returns>
106 IntPtr ptr = IntPtr.Zero;
107 Interop.ApplicationManager.AppInfoGetType(_handle, out ptr);
108 string type = Marshal.PtrToStringAuto(ptr);
114 /// Metadata property.
116 /// <returns>It returns IDictionary object with string key value pairs.</returns>
117 public IDictionary<String, String> Metadata
121 IDictionary<string, string> metadata = new Dictionary<String, String>();
123 Interop.ApplicationManager.AppInfoMetadataCallback cb = (string key, string value, IntPtr userData) =>
125 Console.WriteLine("AppInfoMetadataCallback");
128 metadata.Add(key, value);
133 Interop.ApplicationManager.AppInfoForeachMetadata(_handle, cb, IntPtr.Zero);
139 /// NoDisplay property.
141 /// <returns>bool. If the application icon is not displayed on the menu screen, true; otherwise, false.</returns>
142 public bool NoDisplay
146 bool nodisplay = false;
147 Interop.ApplicationManager.AppInfoIsNodisplay(_handle, out nodisplay);
154 /// <returns>bool. If the application will be automatically start on boot, true; otherwise, false.</returns>
160 Interop.ApplicationManager.AppInfoIsOnBoot(_handle, out onboot);
165 /// PreLoaded property.
167 /// <returns>bool. If the application is preloaded, true; otherwise, false.</returns>
168 public bool PreLoaded
172 bool preloaded = false;
173 Interop.ApplicationManager.AppInfoIsPreLoad(_handle, out preloaded);
178 /// GetLocalizedLabel method.
180 /// <param name="locale">string locale.</param>
181 /// <returns>string Localized Label. It returns the label for the input locale.</returns>
182 public string GetLocalizedLabel(string locale)
184 IntPtr ptr = IntPtr.Zero;
185 Interop.ApplicationManager.AppInfoGetLocaledLabel(ApplicationId, locale, out ptr);
186 string label = Marshal.PtrToStringAuto(ptr);
190 ~InstalledApplication()
198 public void Dispose()
201 GC.SuppressFinalize(this);
204 private void Dispose(bool disposing)
210 // to be used if there are any other disposable objects
212 if (_handle != IntPtr.Zero)
214 Interop.ApplicationManager.AppInfoDestroy(_handle);