Skip to content

Commit

Permalink
[NUI.Gadget] Modify NUIGadget implementation (Samsung#5912)
Browse files Browse the repository at this point in the history
The mount path is changed to the directory path of the executable file.
The environment variable related to resource package IDs is changed to
"GADGET_PKGIDS".

Signed-off-by: Hwankyu Jhun <[email protected]>
  • Loading branch information
hjhun authored Jan 25, 2024
1 parent 121dfc2 commit ce361fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
30 changes: 4 additions & 26 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Tizen.Applications;

using SystemIO = System.IO;

namespace Tizen.NUI
{
/// <summary>
Expand All @@ -34,22 +35,13 @@ public class NUIGadgetInfo
private const string MetadataUIGadgetDll = "http://tizen.org/metadata/ui-gadget/dll";
private const string MetadataUIGadgetResourceDll = "http://tizen.org/metadata/ui-gadget/resource/dll";
private const string MetadataUIGadgetResourceClassName = "http://tizen.org/metadata/ui-gadget/resource/class-name";
private string _resourcePath = string.Empty;

internal NUIGadgetInfo(string packageId)
{
PackageId = packageId;
Log.Warn("PackageId: " + PackageId);
AllowedPath = Application.Current.DirectoryInfo.Resource + "mount/allowed/";
Log.Warn("AllowedPath: " + AllowedPath);
GlobalPath = Application.Current.DirectoryInfo.Resource + "mount/global/";
Log.Warn("GlobalPath: " + GlobalPath);
}

private string AllowedPath { get; set; }

private string GlobalPath { get; set; }

/// <summary>
/// Gets the package ID of the gadget.
/// </summary>
Expand All @@ -74,22 +66,7 @@ internal NUIGadgetInfo(string packageId)
/// <since_tizen> 10 </since_tizen>
public string ResourcePath
{
get
{
if (!string.IsNullOrEmpty(_resourcePath))
return _resourcePath;

if (File.Exists(GlobalPath + ExecutableFile))
{
_resourcePath = GlobalPath;
}
else if (File.Exists(AllowedPath + ExecutableFile))
{
_resourcePath = AllowedPath;
}

return _resourcePath;
}
get; private set;
}

/// <summary>
Expand Down Expand Up @@ -199,6 +176,7 @@ int callback(string key, string value, IntPtr userData)
Log.Warn("Failed to destroy package info. error = " + errorCode);
}

info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/";
info.Assembly = new NUIGadgetAssembly(info.ResourcePath + info.ExecutableFile);
return info;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public static class NUIGadgetManager

static NUIGadgetManager()
{
IntPtr resPkgIds = Interop.Libc.GetEnviornmentVariable("RES_PKGIDS");
if (resPkgIds != IntPtr.Zero)
IntPtr gadgetPkgIds = Interop.Libc.GetEnviornmentVariable("GADGET_PKGIDS");
if (gadgetPkgIds != IntPtr.Zero)
{
string packages = Marshal.PtrToStringAnsi(resPkgIds);
string packages = Marshal.PtrToStringAnsi(gadgetPkgIds);
if (string.IsNullOrEmpty(packages))
{
Log.Warn("There is no resource packages");
Expand Down

0 comments on commit ce361fd

Please sign in to comment.