From: Ernest Borowski Date: Wed, 28 Sep 2022 13:22:04 +0000 (+0200) Subject: Add Settings Certificates UI. X-Git-Tag: accepted/tizen/unified/20221005.144458~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F282228%2F6;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-certificates.git Add Settings Certificates UI. This project has two subprojects: 1. SettingCertificates that has actual widget code and Interop API. 2. SettingView that has aplication for launching this widget, it is just for debugging purposes and should be not packaged in release build. To test it: 1. Install tpk file from packaging dir 2. Open sln in Visual Studio, build and launch project. When there is code change in "SettingsCertificates" subproject: 1. Build SettingsCertificates subproject 2. Install it on the device using sdb: sdb install ./SettingCertificates/SettingCertificates/bin/Release/tizen10.0/org.tizen.cssetting-certificates-1.0.0.tpk 3. Launch SettingView using: Visual Studio -> Debug -> Start Without Debugging Change-Id: I92510e1ec1deeccd5043cbda971b58021ae9e65b Signed-off-by: Ernest Borowski --- diff --git a/SettingCertificates/SettingCertificates/ItemLayout/ILCheckLabel.cs b/SettingCertificates/SettingCertificates/ItemLayout/ILCheckLabel.cs deleted file mode 100644 index 2527f63..0000000 --- a/SettingCertificates/SettingCertificates/ItemLayout/ILCheckLabel.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -/* - * The Item Layout has two modes depending on the number of text labels inserted into it. - * Structure is depicted below. - * - * +------------------------------------------------------------------------+ ------ - * | | -> Item Margin - * | +------+ +--------------------------------------------------------+ | ------ - * | | | | | | - * | |CHECK | | TITLE | | - * | | | | | | - * | +------+ +--------------------------------------------------------+ | - * +------------------------------------------------------------------------+ - * | | - * | | - * | | - * Text Left Margin - * | | - * Text Right Margin - * - * +------------------------------------------------------------------------------+------- - * | +-------------------------------------------------------------+ | - * | +-------+ | TITLE | | Description Top Margin - * | | | | | | - * | |CHECK | +-------------------------------------------------------------+ | - * | | | +-------------------------------------------------------------+ |------- - * | +-------+ | DESCRIPTION | | - * | | | | - * | +-------------------------------------------------------------+ | - * +------------------------------------------------------------------------------+ -*/ - -namespace SettingMain -{ - internal class ILCheckLabel : ItemLayout - { - } -} diff --git a/SettingCertificates/SettingCertificates/ItemLayout/ILIconLabel.cs b/SettingCertificates/SettingCertificates/ItemLayout/ILIconLabel.cs deleted file mode 100644 index 09dc080..0000000 --- a/SettingCertificates/SettingCertificates/ItemLayout/ILIconLabel.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -/* - * The Item Layout has two modes depending on the number of text labels inserted into it. - * Structure is depicted below. - * - * +------------------------------------------------------------------------+ ------ - * | | -> Item Margin - * | +------+ +--------------------------------------------------------+ | ------ - * | | | | | | - * | | ICON | | TITLE | | - * | | | | | | - * | +------+ +--------------------------------------------------------+ | - * +------------------------------------------------------------------------+ - * | | - * | | - * | | - * Text Left Margin - * | | - * Text Right Margin - * - * +------------------------------------------------------------------------------+------- - * | +-------------------------------------------------------------+ | - * | +-------+ | TITLE | | Description Top Margin - * | | | | | | - * | | ICON | +-------------------------------------------------------------+ | - * | | | +-------------------------------------------------------------+ |------- - * | +-------+ | DESCRIPTION | | - * | | | | - * | +-------------------------------------------------------------+ | - * +------------------------------------------------------------------------------+ -*/ - -namespace SettingMain -{ - /// - /// The custom layout sample implementation. This class creates layout for Item Object as it is depicted above. - /// The custom layout must be derived from LayoutGroup and override the two methods, OnMeasure and OnLayout. - /// OnMeasure and OnLayout methods must be extended and called during the measuring and layout phases respectively. - /// - internal class ILIconLabel : ItemLayout - { - } - -} diff --git a/SettingCertificates/SettingCertificates/ItemLayout/ILLabelSlider.cs b/SettingCertificates/SettingCertificates/ItemLayout/ILLabelSlider.cs deleted file mode 100644 index c99d523..0000000 --- a/SettingCertificates/SettingCertificates/ItemLayout/ILLabelSlider.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; - -/* - * The Item Layout has two modes depending on the number of text labels inserted into it. - * Structure is depicted below. - * - * +------------------------------------------------------------------------+ ------ - * | | -> Item Margin - * | +------+ +--------------------------------------------------------+ | ------ - * | | | | | | - * | | | | TITLE | | - * | | | | | | - * | +------+ +--------------------------------------------------------+ | - * +------------------------------------------------------------------------+ - * | | - * | | - * | | - * Text Left Margin - * | | - * Text Right Margin - * - * +------------------------------------------------------------------------------+------- - * | +-------------------------------------------------------------+ | - * | +-------+ | TITLE | | Description Top Margin - * | | | | | | - * | | | +-------------------------------------------------------------+ | - * | | | +-------------------------------------------------------------+ |------- - * | +-------+ | SLIDER | | - * | | | | - * | +-------------------------------------------------------------+ | - * +------------------------------------------------------------------------------+ -*/ - -namespace SettingMain -{ - internal class ILLabelSlider : ItemLayout - { - } -} diff --git a/SettingCertificates/SettingCertificates/ItemLayout/ItemLayout.cs b/SettingCertificates/SettingCertificates/ItemLayout/ItemLayout.cs deleted file mode 100644 index 07281ef..0000000 --- a/SettingCertificates/SettingCertificates/ItemLayout/ItemLayout.cs +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2017 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; - -/* - * The Item Layout has two modes depending on the number of text labels inserted into it. - * Structure is depicted below. - * - * +------------------------------------------------------------------------+ ------ - * | | -> Item Margin - * | +------+ +--------------------------------------------------------+ | ------ - * | | | | | | - * | | ICON | | TITLE | | - * | | | | | | - * | +------+ +--------------------------------------------------------+ | - * +------------------------------------------------------------------------+ - * | | - * | | - * | | - * Text Left Margin - * | | - * Text Right Margin - * - * +------------------------------------------------------------------------------+------- - * | +-------------------------------------------------------------+ | - * | +-------+ | TITLE | | Description Top Margin - * | | | | | | - * | | ICON | +-------------------------------------------------------------+ | - * | | | +-------------------------------------------------------------+ |------- - * | +-------+ | DESCRIPTION | | - * | | | | - * | +-------------------------------------------------------------+ | - * +------------------------------------------------------------------------------+ -*/ - -namespace SettingMain -{ - /// - /// The custom layout sample implementation. This class creates layout for Item Object as it is depicted above. - /// The custom layout must be derived from LayoutGroup and override the two methods, OnMeasure and OnLayout. - /// OnMeasure and OnLayout methods must be extended and called during the measuring and layout phases respectively. - /// - internal class ItemLayout : LayoutGroup - { - /// - /// Top margin of item contents. - /// - private const int ItemMargin = 5; - - /// - /// Point where Description and Title begins. - /// - private const int TextLeftMargin = 120; - - /// - /// Point where Description and Title ends. - /// - private const int TextRightMargin = 710; - - /// - /// Vertical Description margin. - /// - private const int DescriptionTopMargin = 70; - - /// - /// Height of a text object. - /// - private const int TextHeight = 50; - - /// - /// Function calculates the layout size requirements using parent width and height measure specifications. - /// - /// Parent width measure specification - /// Parent height measure specification - protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec) - { - var itemWidth = new LayoutLength(0); - var itemHeight = new LayoutLength(0); - var iconHeight = new LayoutLength(0); - - float labelMaxWidth = 0; - - //All layout items have to be measured to calculate Item width and height - foreach (LayoutItem childLayout in LayoutChildren) - { - if (childLayout != null) - { - //Set widthMEasureSpecification and HeightMeasureSpecification for children - MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec); - - //Item size depends of the content. If item contains descrpitoin height of the item is different. - if (childLayout.Owner is TextLabel) - { - itemHeight += childLayout.MeasuredHeight.Size; - - if (childLayout.MeasuredWidth.Size.AsRoundedValue() > labelMaxWidth) - { - labelMaxWidth = childLayout.MeasuredWidth.Size.AsRoundedValue(); - } - } - else if (childLayout.Owner is CheckBox) - { - itemHeight += childLayout.MeasuredHeight.Size; - - if (childLayout.MeasuredWidth.Size.AsRoundedValue() > labelMaxWidth) - { - labelMaxWidth = childLayout.MeasuredWidth.Size.AsRoundedValue(); - } - } - else if (childLayout.Owner is Slider) - { - itemHeight += childLayout.MeasuredHeight.Size * 2; - - if (childLayout.MeasuredWidth.Size.AsRoundedValue() > labelMaxWidth) - { - labelMaxWidth = childLayout.MeasuredWidth.Size.AsRoundedValue(); - } - } - else - { - itemWidth += childLayout.MeasuredWidth.Size; - iconHeight = childLayout.MeasuredHeight.Size; - } - - //update item width by maximum label widht - itemWidth += new LayoutLength(labelMaxWidth); - } - } - - if (iconHeight.AsRoundedValue() > itemHeight.AsRoundedValue()) - { - itemHeight = iconHeight; - } - - // Finally, call this method to set the dimensions we would like - SetMeasuredDimensions(new MeasuredSize(itemWidth, MeasuredSize.StateType.MeasuredSizeOK), - new MeasuredSize(itemHeight, MeasuredSize.StateType.MeasuredSizeOK)); - } - - /// - /// Laying out and positioning the children within View itself using their measured sizes. - /// - /// This is a new size or position for this layout. - /// Left position, relative to parent. - /// Top position, relative to parent. - /// Right position, relative to parent. - /// Bottom position, relative to parent. - protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom) - { - //Size have to be calculated for all childrens. - foreach (LayoutItem childLayout in LayoutChildren) - { - //Layout owner name is used to set valid size values - if (childLayout.Owner.Name == Program.ItemContentNameIcon) - { - LayoutLength width = childLayout.MeasuredWidth.Size; - LayoutLength height = childLayout.MeasuredHeight.Size; - - childLayout.Layout(new LayoutLength(ItemMargin), - new LayoutLength(ItemMargin), - width + ItemMargin, - height + ItemMargin); - } - else if (childLayout.Owner.Name == Program.ItemContentNameTitle) - { - childLayout.Layout(new LayoutLength(TextLeftMargin), - new LayoutLength(ItemMargin), - new LayoutLength(TextRightMargin), - new LayoutLength(TextHeight + ItemMargin)); - } - else if (childLayout.Owner.Name == Program.ItemContentNameDescription) - { - childLayout.Layout(new LayoutLength(TextLeftMargin), - new LayoutLength(DescriptionTopMargin), - new LayoutLength(TextRightMargin), - new LayoutLength(DescriptionTopMargin + TextHeight + 3 * ItemMargin)); - } - } - } - - } -} diff --git a/SettingCertificates/SettingCertificates/ListItem.cs b/SettingCertificates/SettingCertificates/ListItem.cs deleted file mode 100644 index 1beb759..0000000 --- a/SettingCertificates/SettingCertificates/ListItem.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SettingMain -{ - public class ListItem - { - private readonly int ItemType = 0; - private readonly string Path = null; - private readonly string Label = null; - private readonly string Description = null; - - public ListItem(int type, string path, string label, string description = "") - { - ItemType = type; - Path = path; - Label = label; - Description = description; - } - - - public int GetItemType() - { - return ItemType; - } - public string GetPath() - { - return Path; - } - - public string GetLabel() - { - return Label; - } - - public string GetDescription() - { - return Description; - } - }; -} diff --git a/SettingCertificates/SettingCertificates/SettingCertificates.cs b/SettingCertificates/SettingCertificates/SettingCertificates.cs index 0bcea6c..0a49932 100644 --- a/SettingCertificates/SettingCertificates/SettingCertificates.cs +++ b/SettingCertificates/SettingCertificates/SettingCertificates.cs @@ -1,20 +1,29 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; +/* + * Copyright (c) 2022 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; // for Dictionary using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; -using Tizen.Applications; -namespace SettingMain + +namespace SettingCertificates { public class Program : NUIWidgetApplication { - - public static readonly string ItemContentNameIcon = "ItemIcon"; - public static readonly string ItemContentNameTitle = "ItemTitle"; - public static readonly string ItemContentNameDescription = "ItemDescription"; + internal static readonly string LogTag = "SettingMain.Program"; public Program(Dictionary widgetSet) : base(widgetSet) { @@ -24,6 +33,7 @@ namespace SettingMain protected override void OnCreate() { base.OnCreate(); + Tizen.Log.Debug(LogTag, "OnCreate SettingMain"); } public void OnKeyEvent(object sender, Window.KeyEventArgs e) @@ -36,9 +46,11 @@ namespace SettingMain static void Main(string[] args) { - Dictionary widgetSet = new Dictionary(); - widgetSet.Add(typeof(SettingWidget_MainMenu), "main@org.tizen.SettingMain"); - //widgetSet.Add(typeof(SettingWidget_AboutDevice), "aboutdevice@org.tizen.SettingMain"); + Tizen.Log.Debug(LogTag, "Main SettingMain"); + Dictionary widgetSet = new Dictionary + { + { typeof(WidgetSettingCertificates), "certificates@org.tizen.cssetting-certificates" } + }; var app = new Program(widgetSet); app.Run(args); } diff --git a/SettingCertificates/SettingCertificates/SettingCertificates.csproj b/SettingCertificates/SettingCertificates/SettingCertificates.csproj index d37fb42..c68b57f 100644 --- a/SettingCertificates/SettingCertificates/SettingCertificates.csproj +++ b/SettingCertificates/SettingCertificates/SettingCertificates.csproj @@ -26,5 +26,29 @@ + + + + True + True + Resources.resx + + + True + True + Resources.en.resx + + + + + + ResXFileCodeGenerator + Resources.en.Designer.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + + diff --git a/SettingCertificates/SettingCertificates/SettingWidget_AboutDevice.cs b/SettingCertificates/SettingCertificates/SettingWidget_AboutDevice.cs deleted file mode 100644 index 3dbacf4..0000000 --- a/SettingCertificates/SettingCertificates/SettingWidget_AboutDevice.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Collections.Generic; // for Dictionary -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; -using Tizen.Applications; - -namespace SettingMain -{ - class SettingWidget_AboutDevice : SettingWidget_Base - { - private static readonly ListItem[] listItems = - { - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"sett_manage_cert_active_Default.png", "Manage certificate", ""), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"sett_legal_infot_active_Default.png", "Legal infomation", ""), - new ListItem(1, "", "Device Info", ""), - new ListItem(1, "", "Name", "Tizen"), - new ListItem(1, "", "Model number", "rpi3"), - new ListItem(1, "", "Tizen version", "TIZEN 6.5"), - new ListItem(1, "", "CPU", "BCM2837"), - new ListItem(1, "", "RAM", "4.0GB"), - new ListItem(1, "", "Resolution", "1280 x 720"), - new ListItem(1, "", "Status", "show network status and other infomation."), - }; - - public SettingWidget_AboutDevice() - : base(listItems) - { - Tizen.Log.Error("SettingWidget", "AboutDevice \n"); - } - } -} diff --git a/SettingCertificates/SettingCertificates/SettingWidget_Base.cs b/SettingCertificates/SettingCertificates/SettingWidget_Base.cs deleted file mode 100644 index 7b28886..0000000 --- a/SettingCertificates/SettingCertificates/SettingWidget_Base.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; -using Tizen.Applications; - -namespace SettingMain -{ - class SettingWidget_Base : Widget - { - private static readonly string resPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; - protected const string SETTING_LIST_ICON_PATH_CFG = "/list_icon/"; - protected ListItem[] mListItems; - - public SettingWidget_Base(ListItem[] listItems) - : base() - { - Tizen.Log.Error("SettingWidget", "SettingWidget_Base \n"); - mListItems = listItems; - } - protected override void OnCreate(string contentInfo, Window window) - { - Bundle bundle = Bundle.Decode(contentInfo); - - mRootView = new View(); - mRootView.BackgroundColor = Color.White; - mRootView.Size2D = window.Size; - mRootView.PivotPoint = PivotPoint.Center; - window.GetDefaultLayer().Add(mRootView); - - CreateVerticalScrollableBase(window); - - } - private void CreateVerticalScrollableBase(Window window) - { - verticalScrollableBase = new ScrollableBase() - { - ScrollingDirection = ScrollableBase.Direction.Vertical, - WidthSpecification = LayoutParamPolicies.MatchParent, - HeightSpecification = LayoutParamPolicies.MatchParent, - HideScrollbar = false, - }; - verticalScrollableBase.ScrollOutOfBound += OnVerticalScrollOutOfBound; - - ListItem[] items = mListItems; - verticalItems = new Button[items.Length]; - for (int i = 0; i < items.Length; i++) - { - verticalItems[i] = new Button - { - BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f), - Position = new Position(0, i * 80), - Size = new Size(mRootView.Size2D.Width, 80), - PointSize = 12.0f, - TextColor = Color.Black, - Layout = new LinearLayout() - { - LinearOrientation = LinearLayout.Orientation.Horizontal, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Begin, - CellPadding = new Size2D(20, 20), - }, - - }; - - string iconpath = items[i].GetPath(); - if (iconpath.Length > 0) - { - var margin1 = new View - { - Size2D = new Size2D(10, 32), - HeightResizePolicy = ResizePolicyType.FillToParent - }; - verticalItems[i].Add(margin1); - - ImageView icon = new ImageView(resPath + items[i].GetPath()) - { - Size2D = new Size2D(32, 32), - Name = Program.ItemContentNameIcon, - }; - verticalItems[i].Add(icon); - } - - var margin = new View - { - Size2D = new Size2D(10, 32), - HeightResizePolicy = ResizePolicyType.FillToParent - }; - verticalItems[i].Add(margin); - - PropertyMap titleStyle = new PropertyMap(); - titleStyle.Add("weight", new PropertyValue(600)); - TextLabel title = new TextLabel(items[i].GetLabel()) - { - FontStyle = titleStyle, - Name = Program.ItemContentNameTitle, - Padding = new Extents(8, 8, 8, 8), - }; - verticalItems[i].Add(title); - - - if (i % 2 == 0) - { - verticalItems[i].BackgroundColor = Color.White; - } - else - { - verticalItems[i].BackgroundColor = Color.Cyan; - } -#if false - var okButton = new Button() - { - Text = "OK", - }; - okButton.Clicked += (object sender1, ClickedEventArgs e) => { window.GetDefaultNavigator().Pop(); }; - - verticalItems[i].Clicked += (object sender, ClickedEventArgs e) => - { - DialogPage.ShowAlertDialog("Clicked", verticalItems[i].Name, okButton); - }; -#endif - - verticalScrollableBase.Add(verticalItems[i]); - } - mRootView.Add(verticalScrollableBase); - } - - private void OnVerticalScrollOutOfBound(object sender, ScrollOutOfBoundEventArgs e) - { -#if false - if (e.Displacement > 80) - { - if (e.PanDirection == ScrollOutOfBoundEventArgs.Direction.Down) - { - verticalItems[0].Text = $"Reached at the top, panned displacement is {e.Displacement}."; - } - } - else if (0 - e.Displacement > 80) - { - if (e.PanDirection == ScrollOutOfBoundEventArgs.Direction.Up) - { - verticalItems[mListItems.Length - 1].Text = $"Reached at the bottom, panned displacement is {e.Displacement}."; - } - } -#endif - } - - protected override void OnPause() - { - base.OnPause(); - } - - protected override void OnResume() - { - Tizen.Log.Error("widget", "OnResume \n"); - base.OnResume(); - } - - protected override void OnResize(Window window) - { - base.OnResize(window); - } - - protected override void OnTerminate(string contentInfo, TerminationType type) - { - base.OnTerminate(contentInfo, type); - } - - protected override void OnUpdate(string contentInfo, int force) - { - base.OnUpdate(contentInfo, force); - } - - protected View mRootView; - protected ScrollableBase verticalScrollableBase = null; - protected Button[] verticalItems; - } -} - diff --git a/SettingCertificates/SettingCertificates/SettingWidget_MainMenu.cs b/SettingCertificates/SettingCertificates/SettingWidget_MainMenu.cs deleted file mode 100644 index be37c13..0000000 --- a/SettingCertificates/SettingCertificates/SettingWidget_MainMenu.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Collections.Generic; -using Tizen.NUI; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; -using Tizen.Applications; - -namespace SettingMain -{ - class SettingWidget_MainMenu : SettingWidget_Base - { - private static readonly ListItem[] mItems = { - // Connections - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_wifi.png", "Wifi","Wifi"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_bluetooth.png", "Bluetooth","Bluetooth"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_wifi.png", "Wired Network","Wired Network"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_wifi.png", "Tethering","Tethering"), - - // Sound - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_sound_and_notifications.png", "Sound","Sound"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_notifications.png", "Notifications","Notifications"), - - // Display - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_display.png", "Display","Display"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_wallpapers.png", "Wallpaper","Wallpaper"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_softkey.png", "Tray","Tray"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_softkey.png", "Screen Mirroring","Screen Mirroring"), - - // Personal - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_account.png", "Accounts","Accounts"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_privacy_and_safety.png", "Privacy","Privacy"), - - // Memory - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_applications.png", "Apps","Applications"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_storage.png", "Storage","Storage"), - - // System - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_language_and_input.png", "Language and input","Language and input"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_date_and_time.png", "Date and time","Date and time"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_reset.png", "Reset","Reset"), - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_accessibility.png", "Accessibility","Accessibility"), - - // Device - new ListItem(1, SETTING_LIST_ICON_PATH_CFG+"settings_about_device.png", "About device","About device"), - }; - - public SettingWidget_MainMenu() - :base(mItems) - { - Tizen.Log.Error("SettingWidget", "Main menu \n"); - } - } - -} diff --git a/SettingCertificates/SettingCertificates/WidgetSettingCertificates.cs b/SettingCertificates/SettingCertificates/WidgetSettingCertificates.cs new file mode 100644 index 0000000..6e36e09 --- /dev/null +++ b/SettingCertificates/SettingCertificates/WidgetSettingCertificates.cs @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2022 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 SettingPrivacy.res.locale; +using System; +using System.Collections.Generic; +using Tizen.Applications; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using static Interop; +using static Interop.CertSvc; + +namespace SettingCertificates +{ + class WidgetSettingCertificates : Widget + { + protected View _rootView = null; + List _rootCA, _userCert; + private Navigator _navigator; + internal static string LogTag = "SettingMain.Certificate"; + + public WidgetSettingCertificates() : base() + { + } + void log(string str) + { + Tizen.Log.Debug(LogTag, str); + } + protected override void OnCreate(string contentInfo, Window window) + { + Bundle bundle = Bundle.Decode(contentInfo); + CreateCertList(); + _rootView = new View(); + _rootView.BackgroundColor = Color.White; + _rootView.Size2D = window.Size; + _rootView.PivotPoint = PivotPoint.Center; + window.GetDefaultLayer().Add(_rootView); + _navigator = window.GetDefaultNavigator(); + _navigator.Push(CreateFirstPage()); + + } + private ContentPage CreateFirstPage() + { + ScrollableBase content = CreateScrollableBase(); + var rootCert = new DefaultLinearItem() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + Text = Resources.IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB/*"Trusted root CA certificates"*/, + IsSelectable = false, + Margin = new Extents(20, 20, 1, 1), + BackgroundColor = Color.White, + }; + + rootCert.Clicked += (o, e) => + { + _navigator.Push(CreateSecondPage(Resources.IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB/*"Trusted root CA certificates"*/, _rootCA)); + }; + content.Add(rootCert); + var userCert = new DefaultLinearItem() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + Text = Resources.IDS_ST_BODY_USER_CERTIFICATES/*"User certificates"*/, + IsSelectable = false, + Margin = new Extents(20, 20, 1, 1), + BackgroundColor = Color.White, + CornerRadius = new Vector4(10, 10, 10, 10) + }; + + userCert.Clicked += (o, e) => + { + _navigator.Push(CreateSecondPage(Resources.IDS_ST_BODY_USER_CERTIFICATES/*"User certificates"*/, _userCert)); + }; + content.Add(userCert); + + ContentPage firstPage = CreateContentPage(Resources.IDS_ST_HEADER_MANAGE_CERTIFICATES_ABB/*"Manage certificates"*/, content); + firstPage.AppBar.AutoNavigationContent = false; + + var navigationContent = new Button(((AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar")).BackButton); + navigationContent.Clicked += (o, e) => + { + Bundle bundle = new Bundle(); + bundle.AddItem("WIDGET_ACTION", "POP"); + SetContentInfo(bundle.Encode()); + }; + firstPage.AppBar.NavigationContent = navigationContent; + + return firstPage; + } + private ContentPage CreateSecondPage(string title, List certificates) + { + ScrollableBase content = CreateScrollableBase(); + content.BackgroundColor = new Color("#EFEFEF"); + foreach (certificateMetadata cert in certificates) + { + var item = new DefaultLinearItem() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + Text = cert.title, + IsSelectable = false, + Margin = new Extents(20, 20, 1, 1), + BackgroundColor = Color.White, + CornerRadius = new Vector4(10, 10, 10, 10) + }; + + item.Clicked += (o, e) => + { + _navigator.Push(CreateCertDetails(cert)); + }; + content.Add(item); + } + return CreateContentPage(title, content); + } + private ContentPage CreateCertDetails(certificateMetadata cert) + { + ScrollableBase content = CreateScrollableBase(); + content.BackgroundColor = new Color("#EFEFEF"); + const float fieldTitleFontScale = 1.2F; + const float titleFontScale = 1.1F; + PropertyMap titleFontStyle = new PropertyMap(); + titleFontStyle.Add("weight", new PropertyValue("bold")); + /* Use Certificate */ + var item = new DefaultLinearItem() + { + WidthSpecification = LayoutParamPolicies.MatchParent, + Text = " " + "Use certificate", // NOT defined in Resources... + IsSelectable = false, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + CornerRadius = new Vector4(10, 10, 10, 10) + }; + content.Add(item); + /* Owner Certificate */ + TextLabel ownerLabel = new TextLabel() + { + Text = " " + Resources.IDS_SCP_BODY_OWNER_ABB/*"Owner"*/, + Margin = new Extents(20, 20, 6, 6), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontSizeScale = titleFontScale, + FontStyle = titleFontStyle, + }; + content.Add(ownerLabel); + foreach (CertificateField field in new CertificateField[] { CertificateField.CERTSVC_SUBJECT_COMMON_NAME, CertificateField.CERTSVC_SUBJECT_ORGANIZATION_NAME }) + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + cert.GetFieldTitle(field), + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.GetField(field), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + /* Issuer Certificate */ + TextLabel issuerLabel = new TextLabel() + { + Text = " " + Resources.IDS_ST_BODY_ISSUER/*"Issuer"*/, + Margin = new Extents(20, 20, 6, 6), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontSizeScale = titleFontScale, + FontStyle = titleFontStyle, + }; + content.Add(issuerLabel); + foreach (CertificateField field in new CertificateField[] { CertificateField.CERTSVC_ISSUER_COMMON_NAME, CertificateField.CERTSVC_ISSUER_ORGANIZATION_NAME }) + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + cert.GetFieldTitle(field), + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.GetField(field), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + /* Issuer Certificate information */ + TextLabel certInfo = new TextLabel() + { + Text = " " + Resources.IDS_ST_BODY_CERTIFICATE_INFORMATION/*"Certificate information"*/, + Margin = new Extents(20, 20, 6, 6), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontSizeScale = titleFontScale, + FontStyle = titleFontStyle, + }; + content.Add(certInfo); + foreach (CertificateField field in new CertificateField[] { CertificateField.CERTSVC_VERSION }) + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + cert.GetFieldTitle(field), + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.GetField(field), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + Resources.IDS_ST_BODY_VALID_FROM_C/*"Valid from:"*/, + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.before.ToString("U"), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + Resources.IDS_ST_BODY_VALID_TO_C/*"Valid to:"*/, + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.after.ToString("U"), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + foreach (CertificateField field in new CertificateField[] { CertificateField.CERTSVC_SERIAL_NUMBER, CertificateField.CERTSVC_SIGNATURE_ALGORITHM, + CertificateField.CERTSVC_KEY_USAGE }) + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + cert.GetFieldTitle(field), + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + cert.GetField(field), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + { + string txt = Resources.IDS_ST_BODY_FALSE/*"False"*/; + if (cert.rootCa == 1) + { + txt = Resources.IDS_ST_BODY_TRUE/*"True"*/; + } + TextLabel fieldTitle = new TextLabel() + { + Text = " " + Resources.IDS_ST_BODY_CERTIFICATION_AUTHORITY_C/*"Certification authority:"*/, + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + Text = " " + txt, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + { + TextLabel fieldTitle = new TextLabel() + { + Text = " " + cert.GetFieldTitle(CertificateField.CERTSVC_KEY), + FontSizeScale = fieldTitleFontScale, + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + }; + TextLabel fieldValue = new TextLabel() + { + MultiLine = true, + Text = cert.GetField(CertificateField.CERTSVC_KEY).Replace(" ", " "), + BackgroundColor = Color.White, + Margin = new Extents(20, 20, 1, 0), + WidthSpecification = LayoutParamPolicies.MatchParent, + FontStyle = titleFontStyle, + CornerRadius = new Vector4(0, 0, 10, 10), + }; + content.Add(fieldTitle); + content.Add(fieldValue); + } + + return CreateContentPage(Resources.IDS_ST_BODY_CERTIFICATE_DETAILS/*"Certificate details"*/, content); + } + bool CreateCertList() + { + log("create instance"); + int result = CertSvc.InstanceNew(out IntPtr instance); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unable to create cert instance, result: " + result.ToString()); + return false; + } + log("Instance created"); + result = CertSvc.GetPKCS12CertificateListFromStore(instance, CertSvc.CertStoreType.ALL_STORE, 0, out IntPtr storeCertList, out int length); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unable to get root certificates, result: " + result.ToString()); + result = CertSvc.FreePKCS12CertificateListFromStore(instance, out storeCertList); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unable to free certlist, result: " + result.ToString()); + } + CertSvc.InstanceFree(instance); + return false; + } + log("All store length: " + length); + _rootCA = CertSvc.GetCertLists(instance, storeCertList, length); + + result = CertSvc.FreePKCS12CertificateListFromStore(instance, out storeCertList); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unalbe to free certlist, result: " + result.ToString()); + } + result = CertSvc.GetPKCS12UserCertificateListFromStore(instance, CertStoreType.ALL_STORE, out IntPtr user, out int ul); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unable to get user certificate list, result: " + result.ToString()); + } + log("User length: " + ul); + _userCert = CertSvc.GetCertLists(instance, user, ul); + result = CertSvc.FreePKCS12CertificateListFromStore(instance, out user); + if ((CertSvc.ErrorCode)result != CertSvc.ErrorCode.CERTSVC_SUCCESS) + { + log("unalbe to free user certlist, result: " + result.ToString()); + } + CertSvc.InstanceFree(instance); + return true; + } + private ScrollableBase CreateScrollableBase() + { + return new ScrollableBase() + { + ScrollingDirection = ScrollableBase.Direction.Vertical, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.MatchParent, + HideScrollbar = false, + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; + } + private ContentPage CreateContentPage(string title, ScrollableBase content) + { + log("CreateContentPage with title: " + title); + return new ContentPage() + { + AppBar = new AppBar() + { + Title = title, + }, + Content = content, + BackgroundColor = new Color("#EFEFEF"), + }; + } + + private void OnVerticalScrollOutOfBound(object sender, ScrollOutOfBoundEventArgs e) + { +#if false + if (e.Displacement > 80) + { + if (e.PanDirection == ScrollOutOfBoundEventArgs.Direction.Down) + { + verticalItems[0].Text = $"Reached at the top, panned displacement is {e.Displacement}."; + } + } + else if (0 - e.Displacement > 80) + { + if (e.PanDirection == ScrollOutOfBoundEventArgs.Direction.Up) + { + verticalItems[mListItems.Length - 1].Text = $"Reached at the bottom, panned displacement is {e.Displacement}."; + } + } +#endif + } + } +} diff --git a/SettingCertificates/SettingCertificates/api/Interop/Interop.CertSvc.cs b/SettingCertificates/SettingCertificates/api/Interop/Interop.CertSvc.cs new file mode 100644 index 0000000..ff8775b --- /dev/null +++ b/SettingCertificates/SettingCertificates/api/Interop/Interop.CertSvc.cs @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2022 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; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using System.Linq; +using SettingPrivacy.res.locale; + +internal static partial class Interop +{ + internal static partial class CertSvc + { + internal static string LogTag = "InteropTest.CertSvc"; + internal enum ErrorCode + { + CERTSVC_TRUE = 1, + CERTSVC_FALSE = 0, + CERTSVC_SUCCESS = 1, + CERTSVC_FAIL = 0, + CERTSVC_BAD_ALLOC = -2, + CERTSVC_WRONG_ARGUMENT = -4, + CERTSVC_INVALID_ALGORITHM = -5, + CERTSVC_INVALID_SIGNATURE = -6, + CERTSVC_IO_ERROR = -7, + CERTSVC_INVALID_PASSWORD = -8, + CERTSVC_DUPLICATED_ALIAS = -9, + CERTSVC_ALIAS_DOES_NOT_EXIST = -10, + CERTSVC_INVALID_STORE_TYPE = -11, + CERTSVC_INVALID_STATUS = -12, + CERTSVC_INVALID_CERTIFICATE = -13, + }; + internal enum CertStoreType + { + NONE_STORE = 0, + VPN_STORE = 1 << 0, + WIFI_STORE = 1 << 1, + EMAIL_STORE = 1 << 2, + SYSTEM_STORE = 1 << 3, + ALL_STORE = VPN_STORE | WIFI_STORE | EMAIL_STORE | SYSTEM_STORE, + }; + internal enum CertificateField + { + CERTSVC_SUBJECT, + [Description("Common name")] + CERTSVC_SUBJECT_COMMON_NAME, + CERTSVC_SUBJECT_COUNTRY_NAME, + CERTSVC_SUBJECT_STATE_NAME, + CERTSVC_SUBJECT_LOCALITY_NAME, + [Description("Organization")] + CERTSVC_SUBJECT_ORGANIZATION_NAME, + CERTSVC_SUBJECT_ORGANIZATION_UNIT_NAME, + CERTSVC_SUBJECT_EMAIL_ADDRESS, + /* CERTSVC_SUBJECT_UID, */ + CERTSVC_ISSUER, + [Description("Common name")] + CERTSVC_ISSUER_COMMON_NAME, + CERTSVC_ISSUER_COUNTRY_NAME, + CERTSVC_ISSUER_STATE_NAME, + CERTSVC_ISSUER_LOCALITY_NAME, + [Description("Organization")] + CERTSVC_ISSUER_ORGANIZATION_NAME, + CERTSVC_ISSUER_ORGANIZATION_UNIT_NAME, + CERTSVC_ISSUER_EMAIL_ADDRESS, + /* CERTSVC_ISSUER_UID, */ + [Description("Version")] + CERTSVC_VERSION, + [Description("Serial number")] + CERTSVC_SERIAL_NUMBER, + [Description("Key usage")] + CERTSVC_KEY_USAGE, + [Description("Public key")] + CERTSVC_KEY, + CERTSVC_KEY_ALGO, + [Description("Signature algorithm")] + CERTSVC_SIGNATURE_ALGORITHM, + }; + public static string GetCertFieldDescription(CertificateField field) + { + Type genericEnumType = field.GetType(); + MemberInfo[] memberInfo = genericEnumType.GetMember(field.ToString()); + if ((memberInfo != null && memberInfo.Length > 0)) + { + var _Attribs = memberInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false); + if ((_Attribs != null && _Attribs.Count() > 0)) + { + return ((System.ComponentModel.DescriptionAttribute)_Attribs.ElementAt(0)).Description; + } + } + return field.ToString(); + } + + internal enum CertStatus + { + DISABLED = 0, + ENABLED = 1, + }; + [StructLayout(LayoutKind.Sequential)] + internal struct StoreCertList + { + internal IntPtr gname; + internal IntPtr title; + internal CertStatus status; + internal CertStoreType storeType; + internal IntPtr next; + } + internal class certificateMetadata + { + internal string gname; + internal string title; + internal CertStatus status; + internal CertStoreType storeType; + internal string[] fields; + internal DateTime before; + internal DateTime after; + internal int rootCa; + public certificateMetadata() + { + fields = new string[Enum.GetNames(typeof(CertificateField)).Length]; + } + public string GetField(CertificateField field) + { + return fields[(int)field]; + } + public string GetFieldTitle(CertificateField field) + { + switch (field) + { + case CertificateField.CERTSVC_SUBJECT_COMMON_NAME: + return Resources.IDS_ST_BODY_COMMON_NAME_C; /*Common name*/ + case CertificateField.CERTSVC_SUBJECT_ORGANIZATION_NAME: + return Resources.IDS_ST_BODY_ORGANISATION_C; /*Organization*/ + case CertificateField.CERTSVC_ISSUER_COMMON_NAME: + return Resources.IDS_ST_BODY_ISSUER_COLON; /*Common name*/ + case CertificateField.CERTSVC_ISSUER_ORGANIZATION_NAME: + return Resources.IDS_ST_BODY_ORGANISATION_C; /*Organization*/ + case CertificateField.CERTSVC_VERSION: + return Resources.IDS_ST_BODY_VERSION_C; /*Version*/ + case CertificateField.CERTSVC_SERIAL_NUMBER: + return Resources.IDS_ST_BODY_SERIAL_NUMBER_COLON; /*Serial number*/ + case CertificateField.CERTSVC_KEY_USAGE: + return Resources.IDS_ST_BODY_KEY_USAGE_C; /*Key usage*/ + case CertificateField.CERTSVC_KEY: + return Resources.IDS_ST_BODY_PUBLIC_KEY_C; /*Public key*/ + case CertificateField.CERTSVC_SIGNATURE_ALGORITHM: + return Resources.IDS_ST_BODY_SIGNATURE_ALGORITHM_C; /*Signature algorithm*/ + + default: + break; + } + return GetCertFieldDescription(field); + } + } + + internal struct StoreCertHandle + { + string name; + string title; + CertStatus status; + CertStoreType storeType; + } + internal struct Certificate + { + internal int privateHandler; + internal Instance Instance; + } + + internal struct Instance + { + internal IntPtr privatePtr; + } + + internal struct CertSvcString + { + internal IntPtr privateHandler; + internal int privateLength; + internal Instance Instance; + } + /* + // cert UI: + Owner: + Common name: + Organization: + Issuer: + Common name: + Organization: + Certificate Information: + Version: + Valid from: + Valid to: + Serial number: + Signature algorithm: + Key Usage: + Certification authority: + Public Key: + + */ + + internal static List GetCertLists(IntPtr instance, IntPtr certList, int length) + { + IntPtr cur = certList; + var list = new List(); + + while (cur != IntPtr.Zero) + { + StoreCertList item = Marshal.PtrToStructure(cur); + certificateMetadata cert = new certificateMetadata + { + status = item.status, + gname = Marshal.PtrToStringUTF8(item.gname), + title = Marshal.PtrToStringUTF8(item.title), + storeType = item.storeType + }; + ErrorCode err = (ErrorCode)GetPKCS12CertificateFromStore(instance, item.storeType, item.gname, out Certificate cout); + if (err != ErrorCode.CERTSVC_SUCCESS) + { + Tizen.Log.Debug(LogTag, "Unable to GetPKCS12CertificateFromStore, err: " + err + ", instance: " + + instance + " gname: " + item.gname + " store_type: " + item.storeType); + cur = item.next; + continue; + } + + err = (ErrorCode)GetCertificateNotAfter(cout, out long time); + if (err != ErrorCode.CERTSVC_SUCCESS) + { + Tizen.Log.Debug(LogTag, "Unable to GetCertificateNotAfter, , err: " + err + ", instance: " + + instance + " gname: " + item.gname + " store_type: " + item.storeType); + cur = item.next; + continue; + } + cert.after = new DateTime(1970, 1, 1).ToLocalTime().AddSeconds(time); + err = (ErrorCode)GetCertificateNotBefore(cout, out time); + if (err != ErrorCode.CERTSVC_SUCCESS) + { + Tizen.Log.Debug(LogTag, "Unable to GetCertificateNotBefore, , err: " + err + ", instance: " + + instance + " gname: " + item.gname + " store_type: " + item.storeType); + cur = item.next; + continue; + } + cert.before = new DateTime(1970, 1, 1).ToLocalTime().AddSeconds(time); + err = (ErrorCode)GetCertificateIsRootCa(cout, out int isRootCa); + if (err != ErrorCode.CERTSVC_SUCCESS) + { + Tizen.Log.Debug(LogTag, "Unable to GetCertificateIsRootCa, , err: " + err + ", instance: " + + instance + " gname: " + item.gname + " store_type: " + item.storeType); + cur = item.next; + continue; + } + cert.rootCa = isRootCa; + bool gotError = false; + foreach (CertificateField certificateField in Enum.GetValues(typeof(CertificateField))) + { + err = (ErrorCode)GetCertificateStringField(cout, certificateField, out CertSvcString certSvcString); + if (err != ErrorCode.CERTSVC_SUCCESS) + { + Tizen.Log.Debug(LogTag, "Unable to GetCertificateStringField, , err: " + err + ", instance: " + + instance + " gname: " + item.gname + " store_type: " + item.storeType); + cur = item.next; + gotError = true; + break; + } + string stringField = Marshal.PtrToStringUTF8(certSvcString.privateHandler); + cert.fields[(int)certificateField] = stringField; + } + if (gotError == true) + { + continue; + } + cur = item.next; + list.Add(cert); + } + Tizen.Log.Debug(LogTag, "CertList size: " + list.Count); + return list; + } + + // int certsvc_instance_new(CertSvcInstance *instance); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_instance_new")] + internal static extern int InstanceNew(out IntPtr instance); + // void certsvc_instance_free(CertSvcInstance instance); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_instance_free")] + internal static extern void InstanceFree(IntPtr instance); + // int certsvc_pkcs12_get_certificate_list_from_store(CertSvcInstance instance, CertStoreType storeType, int is_root_app, CertSvcStoreCertList **certlist, size_t *lenght); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_pkcs12_get_certificate_list_from_store")] + internal static extern int GetPKCS12CertificateListFromStore(IntPtr instance, CertStoreType storeType, int isRootApp, out IntPtr certList, out int length); + // int certsvc_pkcs12_free_certificate_list_from_store(CertSvcInstance instance, CertSvcStoreCertList **certlist); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_pkcs12_free_certificate_list_loaded_from_store")] + internal static extern int FreePKCS12CertificateListFromStore(IntPtr instance, out IntPtr certList); + // int certsvc_pkcs12_get_certificate_from_store(CertSvcInstance instance, CertStoreType storeType, const char* gname, CertSvcCertificate *certificate); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_pkcs12_get_certificate_from_store")] + internal static extern int GetPKCS12CertificateFromStore(IntPtr instance, CertStoreType storeType, IntPtr gname, out Certificate certificate); + + // int certsvc_certificate_get_string_field(CertSvcCertificate certificate, CertSvcCertificateField field, CertSvcString *buffer); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_certificate_get_string_field")] + internal static extern int GetCertificateStringField(Certificate certificate, CertificateField field, out CertSvcString buffer); + // int certsvc_certificate_get_not_after(CertSvcCertificate certificate, time_t *result); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_certificate_get_not_after")] + internal static extern int GetCertificateNotAfter(Certificate certificate, out long result); + // int certsvc_certificate_get_not_before(CertSvcCertificate certificate, time_t *result); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_certificate_get_not_before")] + internal static extern int GetCertificateNotBefore(Certificate certificate, out long result); + // int certsvc_certificate_is_root_ca(CertSvcCertificate certificate, int *result); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_certificate_is_root_ca")] + internal static extern int GetCertificateIsRootCa(Certificate certificate, out int status); + + /* END USER API */ + // int certsvc_pkcs12_get_end_user_certificate_list_from_store(CertSvcInstance instance, CertStoreType storeType, CertSvcStoreCertList **certlist, size_t *lenght); + [DllImport(Libraries.CertSvc, EntryPoint = "certsvc_pkcs12_get_end_user_certificate_list_from_store")] + internal static extern int GetPKCS12UserCertificateListFromStore(IntPtr instance, CertStoreType storeType, out IntPtr certList, out int length); + + } +} \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/api/Interop/Interop.Libraries.cs b/SettingCertificates/SettingCertificates/api/Interop/Interop.Libraries.cs new file mode 100644 index 0000000..1259020 --- /dev/null +++ b/SettingCertificates/SettingCertificates/api/Interop/Interop.Libraries.cs @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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 + */ + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string CertSvc = "libcert-svc-vcore.so.2"; + } +} \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/res/locale/Resource.Designer.cs b/SettingCertificates/SettingCertificates/res/locale/Resource.Designer.cs new file mode 100644 index 0000000..693caad --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resource.Designer.cs @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2022 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 + */ + +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace SettingPrivacy.res.locale +{ + using System; + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을 + // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if (object.ReferenceEquals(resourceMan, null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SettingCertificates.res.locale.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + internal static string IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB", resourceCulture); + } + } + internal static string IDS_ST_BODY_USER_CERTIFICATES + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_USER_CERTIFICATES", resourceCulture); + } + } + internal static string IDS_ST_HEADER_MANAGE_CERTIFICATES_ABB + { + get + { + return ResourceManager.GetString("IDS_ST_HEADER_MANAGE_CERTIFICATES_ABB", resourceCulture); + } + } + internal static string IDS_SCP_BODY_OWNER_ABB + { + get + { + return ResourceManager.GetString("IDS_SCP_BODY_OWNER_ABB", resourceCulture); + } + } + internal static string IDS_ST_BODY_ISSUER + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_ISSUER", resourceCulture); + } + } + internal static string IDS_ST_BODY_CERTIFICATE_INFORMATION + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATE_INFORMATION", resourceCulture); + } + } + internal static string IDS_ST_BODY_VALID_FROM_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_VALID_FROM_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_VALID_TO_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_VALID_TO_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_CERTIFICATION_AUTHORITY_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATION_AUTHORITY_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_TRUE + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_TRUE", resourceCulture); + } + } + internal static string IDS_ST_BODY_FALSE + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_FALSE", resourceCulture); + } + } + internal static string IDS_ST_BODY_CERTIFICATE_DETAILS + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATE_DETAILS", resourceCulture); + } + } + internal static string IDS_ST_BODY_COMMON_NAME_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_COMMON_NAME_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_ORGANISATION_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_ORGANISATION_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_ISSUER_COLON + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_ISSUER_COLON", resourceCulture); + } + } + internal static string IDS_ST_BODY_VERSION_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_VERSION_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_SERIAL_NUMBER_COLON + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_SERIAL_NUMBER_COLON", resourceCulture); + } + } + internal static string IDS_ST_BODY_KEY_USAGE_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_KEY_USAGE_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_PUBLIC_KEY_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_PUBLIC_KEY_C", resourceCulture); + } + } + internal static string IDS_ST_BODY_SIGNATURE_ALGORITHM_C + { + get + { + return ResourceManager.GetString("IDS_ST_BODY_SIGNATURE_ALGORITHM_C", resourceCulture); + } + } + } +} diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.Designer.cs b/SettingCertificates/SettingCertificates/res/locale/Resources.Designer.cs new file mode 100644 index 0000000..1b73135 --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.Designer.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SettingCertificates.res.locale { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SettingCertificates.res.locale.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Owner. + /// + internal static string IDS_SCP_BODY_OWNER_ABB { + get { + return ResourceManager.GetString("IDS_SCP_BODY_OWNER_ABB", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Certificate details. + /// + internal static string IDS_ST_BODY_CERTIFICATE_DETAILS { + get { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATE_DETAILS", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Certificate information. + /// + internal static string IDS_ST_BODY_CERTIFICATE_INFORMATION { + get { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATE_INFORMATION", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Certification authority:. + /// + internal static string IDS_ST_BODY_CERTIFICATION_AUTHORITY_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_CERTIFICATION_AUTHORITY_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Common name:. + /// + internal static string IDS_ST_BODY_COMMON_NAME_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_COMMON_NAME_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to False. + /// + internal static string IDS_ST_BODY_FALSE { + get { + return ResourceManager.GetString("IDS_ST_BODY_FALSE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Issuer:. + /// + internal static string IDS_ST_BODY_ISSUER { + get { + return ResourceManager.GetString("IDS_ST_BODY_ISSUER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Issuer:. + /// + internal static string IDS_ST_BODY_ISSUER_COLON { + get { + return ResourceManager.GetString("IDS_ST_BODY_ISSUER_COLON", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Key usage:. + /// + internal static string IDS_ST_BODY_KEY_USAGE_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_KEY_USAGE_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Organisation:. + /// + internal static string IDS_ST_BODY_ORGANISATION_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_ORGANISATION_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Public key:. + /// + internal static string IDS_ST_BODY_PUBLIC_KEY_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_PUBLIC_KEY_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Serial number:. + /// + internal static string IDS_ST_BODY_SERIAL_NUMBER_COLON { + get { + return ResourceManager.GetString("IDS_ST_BODY_SERIAL_NUMBER_COLON", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Signature algorithm:. + /// + internal static string IDS_ST_BODY_SIGNATURE_ALGORITHM_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_SIGNATURE_ALGORITHM_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to True. + /// + internal static string IDS_ST_BODY_TRUE { + get { + return ResourceManager.GetString("IDS_ST_BODY_TRUE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Trusted root CA certificates. + /// + internal static string IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB { + get { + return ResourceManager.GetString("IDS_ST_BODY_TRUSTED_ROOT_CA_CERTIFICATES_ABB", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to User certificates. + /// + internal static string IDS_ST_BODY_USER_CERTIFICATES { + get { + return ResourceManager.GetString("IDS_ST_BODY_USER_CERTIFICATES", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Valid from:. + /// + internal static string IDS_ST_BODY_VALID_FROM_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_VALID_FROM_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Valid to:. + /// + internal static string IDS_ST_BODY_VALID_TO_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_VALID_TO_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version:. + /// + internal static string IDS_ST_BODY_VERSION_C { + get { + return ResourceManager.GetString("IDS_ST_BODY_VERSION_C", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Manage certificates. + /// + internal static string IDS_ST_HEADER_MANAGE_CERTIFICATES_ABB { + get { + return ResourceManager.GetString("IDS_ST_HEADER_MANAGE_CERTIFICATES_ABB", resourceCulture); + } + } + } +} diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.en.Designer.cs b/SettingCertificates/SettingCertificates/res/locale/Resources.en.Designer.cs new file mode 100644 index 0000000..7c1b617 --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.en.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SettingCertificates.res.locale { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource1 { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource1() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SettingCertificates.res.locale.Resource1", typeof(Resource1).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.en.resx b/SettingCertificates/SettingCertificates/res/locale/Resources.en.resx new file mode 100644 index 0000000..07c961f --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.en.resx @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Owner + + + Certificate details + + + Certificate information + + + Certification authority: + + + Common name: + + + False + + + Issuer: + + + Issuer: + + + Key usage: + + + Organisation: + + + Public key: + + + Serial number: + + + Signature algorithm: + + + True + + + Trusted root CA certificates + + + User certificates + + + Valid from: + + + Valid to: + + + Version: + + + Manage certificates + + \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.ko-KR.resx b/SettingCertificates/SettingCertificates/res/locale/Resources.ko-KR.resx new file mode 100644 index 0000000..d35b53e --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.ko-KR.resx @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 소유자 + + + 인증서 상세정보 + + + 인증서 정보 + + + 인증 기관: + + + 일반 이름: + + + 거짓 + + + 발급자: + + + 발급자: + + + 키 용도: + + + 기관: + + + 공개키: + + + 시리얼 번호: + + + 서명 알고리즘: + + + 진실 + + + 신뢰할 수 있는 루트 CA 인증서 + + + 사용자 인증서 + + + 유효기간 시작일: + + + 유효기간 만료일: + + + 버전: + + + 인증서 관리 + + \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.pl.resx b/SettingCertificates/SettingCertificates/res/locale/Resources.pl.resx new file mode 100644 index 0000000..23e7ec7 --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.pl.resx @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Właściciel + + + Szczegóły certyfikatu + + + Informacje o certyfikacie + + + Urząd certyfikacji: + + + Używana nazwa: + + + Fałsz + + + Wystawca: + + + Wystawca: + + + Wykorzystanie klucza: + + + Organizacja: + + + Klucz publiczny: + + + Numer seryjny: + + + Algorytm podpisywania: + + + Prawda + + + Certyfikaty CA zauf. gł. urzędu + + + Certyfikaty użytkownika + + + Ważny od: + + + Ważny do: + + + Wersja: + + + Zarządzanie certyfikatami + + \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/res/locale/Resources.resx b/SettingCertificates/SettingCertificates/res/locale/Resources.resx new file mode 100644 index 0000000..07c961f --- /dev/null +++ b/SettingCertificates/SettingCertificates/res/locale/Resources.resx @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Owner + + + Certificate details + + + Certificate information + + + Certification authority: + + + Common name: + + + False + + + Issuer: + + + Issuer: + + + Key usage: + + + Organisation: + + + Public key: + + + Serial number: + + + Signature algorithm: + + + True + + + Trusted root CA certificates + + + User certificates + + + Valid from: + + + Valid to: + + + Version: + + + Manage certificates + + \ No newline at end of file diff --git a/SettingCertificates/SettingCertificates/tizen-manifest.xml b/SettingCertificates/SettingCertificates/tizen-manifest.xml index dfc3033..5f79a4c 100644 --- a/SettingCertificates/SettingCertificates/tizen-manifest.xml +++ b/SettingCertificates/SettingCertificates/tizen-manifest.xml @@ -1,23 +1,23 @@  - + - + SettingCertificates.png + + 4x4 + - - - http://tizen.org/privilege/systemsettings.admin + http://tizen.org/privilege/appmanager.launch - diff --git a/SettingCertificates/SettingView/SettingView.cs b/SettingCertificates/SettingView/SettingView.cs index 486cbd8..15c714f 100644 --- a/SettingCertificates/SettingView/SettingView.cs +++ b/SettingCertificates/SettingView/SettingView.cs @@ -1,12 +1,29 @@ -using System; +/* + * Copyright (c) 2022 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 Tizen.NUI; -using Tizen.NUI.BaseComponents; using Tizen.Applications; namespace SettingView { public class Program : NUIApplication { + + WidgetView mWidgetView; public Program(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface) : base(styleSheet, windowSize, windowPosition, borderInterface) { @@ -25,7 +42,7 @@ namespace SettingView Tizen.Log.Error("SettingWidget", "REQUEST \n"); - mWidgetView = WidgetViewManager.Instance.AddWidget("certificates@org.tizen.setting-certificates", encodedBundle, window.Size.Width, window.Size.Height, 0.0f); + mWidgetView = WidgetViewManager.Instance.AddWidget("certificates@org.tizen.cssetting-certificates", encodedBundle, window.Size.Width, window.Size.Height, 0.0f); mWidgetView.Position = new Position(0, 0); window.GetDefaultLayer().Add(mWidgetView); } @@ -45,7 +62,5 @@ namespace SettingView app.Run(args); } - - WidgetView mWidgetView; } } diff --git a/SettingCertificates/SettingView/SettingViewBorder.cs b/SettingCertificates/SettingView/SettingViewBorder.cs index 6b801c1..dcf5802 100644 --- a/SettingCertificates/SettingView/SettingViewBorder.cs +++ b/SettingCertificates/SettingView/SettingViewBorder.cs @@ -1,11 +1,21 @@ -using System; +/* + * Copyright (c) 2022 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 Tizen.NUI; using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; - -using System.Collections.Generic; -using System.Text; namespace SettingView { diff --git a/SettingCertificates/SettingView/tizen-manifest.xml b/SettingCertificates/SettingView/tizen-manifest.xml index 0f90291..4dcf8af 100644 --- a/SettingCertificates/SettingView/tizen-manifest.xml +++ b/SettingCertificates/SettingView/tizen-manifest.xml @@ -1,5 +1,5 @@  - + diff --git a/packaging/org.tizen.cssetting-certificates-1.0.0.tpk b/packaging/org.tizen.cssetting-certificates-1.0.0.tpk new file mode 100644 index 0000000..40a2968 Binary files /dev/null and b/packaging/org.tizen.cssetting-certificates-1.0.0.tpk differ diff --git a/packaging/org.tizen.setting-certificates-1.0.0.tpk b/packaging/org.tizen.setting-certificates-1.0.0.tpk deleted file mode 100644 index fde5de7..0000000 Binary files a/packaging/org.tizen.setting-certificates-1.0.0.tpk and /dev/null differ diff --git a/packaging/org.tizen.setting-certificates.spec b/packaging/org.tizen.setting-certificates.spec index 393faeb..8484fb6 100644 --- a/packaging/org.tizen.setting-certificates.spec +++ b/packaging/org.tizen.setting-certificates.spec @@ -13,7 +13,7 @@ Requires(post): /usr/sbin/cyad %description NUI application for displaying certificates installed on device. -%define tpk_pkgid org.tizen.setting-certificates +%define tpk_pkgid org.tizen.cssetting-certificates %define preload_tpk_path /usr/apps/.preload-tpk %prep @@ -30,8 +30,6 @@ install packaging/%{tpk_pkgid}-%{version}.tpk %{buildroot}/%{preload_tpk_path}/ # Uncomment following lines to test tpk installation #pkgcmd -it tpk -p %{preload_tpk_path}/%{tpk_pkgid}-%{version}.tpk -cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::%{tpk_pkgid} -u 5001 -p http://tizen.org/privilege/notexist -t ALLOW - # Uncomment following lines to test preload tpk installation on image creation #pkg_initdb --ro #install_preload_pkg