From f78a0d306c5a28d969cbe40379c71ad8735ebb18 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 31 Aug 2016 19:40:31 +0900 Subject: [PATCH] Initial update Change-Id: Ib2842e06c5c761ba1b4168df1b145d7696362b92 Signed-off-by: Junghoon Park --- LICENSE | 202 ++++++ packaging/csapi-widget-control.manifest | 5 + packaging/csapi-widget-control.spec | 65 ++ .../CoreFx.References.targets | 265 ++++++++ .../CustomDictionary.xml | 0 .../GlobalSuppressions.cs | Bin 0 -> 954 bytes .../Interop/Interop.Libraries.cs | 15 + .../Interop/Interop.WidgetService.cs | 93 +++ .../Properties/AssemblyInfo.cs | 20 + .../Tizen.Applications.WidgetControl.csproj | 104 ++++ .../Tizen.Applications.WidgetControl.sln | 22 + .../Tizen.Applications.WidgetControl.snk | Bin 0 -> 596 bytes .../Tizen.Applications/WidgetControl.cs | 676 +++++++++++++++++++++ .../Tizen.Applications/WidgetLifecycleEventArgs.cs | 59 ++ 14 files changed, 1526 insertions(+) create mode 100644 LICENSE create mode 100755 packaging/csapi-widget-control.manifest create mode 100755 packaging/csapi-widget-control.spec create mode 100644 src/Tizen.Applications.WidgetControl/CoreFx.References.targets create mode 100755 src/Tizen.Applications.WidgetControl/CustomDictionary.xml create mode 100755 src/Tizen.Applications.WidgetControl/GlobalSuppressions.cs create mode 100755 src/Tizen.Applications.WidgetControl/Interop/Interop.Libraries.cs create mode 100755 src/Tizen.Applications.WidgetControl/Interop/Interop.WidgetService.cs create mode 100755 src/Tizen.Applications.WidgetControl/Properties/AssemblyInfo.cs create mode 100755 src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.csproj create mode 100755 src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.sln create mode 100755 src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.snk create mode 100755 src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs create mode 100755 src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetLifecycleEventArgs.cs diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/packaging/csapi-widget-control.manifest b/packaging/csapi-widget-control.manifest new file mode 100755 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/csapi-widget-control.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/csapi-widget-control.spec b/packaging/csapi-widget-control.spec new file mode 100755 index 0000000..20be7ff --- /dev/null +++ b/packaging/csapi-widget-control.spec @@ -0,0 +1,65 @@ +%{!?dotnet_assembly_path: %define dotnet_assembly_path %{_datadir}/assembly} +%{!?dotnet_core_path: %define dotnet_core_path %{_datadir}/tizen.net/ref} + +%if 0%{?tizen_build_devel_mode} +%define BUILDCONF Debug +%else +%define BUILDCONF Release +%endif + +Name: csapi-widget-control +Summary: Tizen widget control API for C# +Version: 1.0.0 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +URL: https://www.tizen.org +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest + +# Mono +BuildRequires: mono-compiler +BuildRequires: mono-devel + +# .NETCore +%if 0%{?_with_corefx} +AutoReqProv: no +BuildRequires: corefx-managed-32b-ref +%endif + +# C# API Requries +BuildRequires: csapi-tizen +BuildRequires: csapi-application + +%description +Tizen widget control API for C# + +%prep +%setup -q +cp %{SOURCE1} . + +%define Assemblies Tizen.Applications.WidgetControl + +%build +for ASM in %{Assemblies}; do +xbuild $ASM/$ASM.csproj \ +%if 0%{?_with_corefx} + /p:NoStdLib=True \ + /p:TargetFrameworkVersion=v5.0 \ + /p:AddAdditionalExplicitAssemblyReferences=False \ + /p:CoreFxPath=%{dotnet_core_path} \ +%endif + /p:Configuration=%{BUILDCONF} \ + /p:ReferencePath=%{dotnet_assembly_path} +done + +%install +mkdir -p %{buildroot}%{dotnet_assembly_path} +for ASM in %{Assemblies}; do +install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path} +done + +%files +%manifest %{name}.manifest +%license LICENSE +%attr(644,root,root) %{dotnet_assembly_path}/*.dll diff --git a/src/Tizen.Applications.WidgetControl/CoreFx.References.targets b/src/Tizen.Applications.WidgetControl/CoreFx.References.targets new file mode 100644 index 0000000..dab29ec --- /dev/null +++ b/src/Tizen.Applications.WidgetControl/CoreFx.References.targets @@ -0,0 +1,265 @@ + + + + + False + $(CoreFxPath)/Microsoft.Win32.Primitives.dll + + + False + $(CoreFxPath)/System.AppContext.dll + + + False + $(CoreFxPath)/System.Collections.Concurrent.dll + + + False + $(CoreFxPath)/System.Collections.dll + + + False + $(CoreFxPath)/System.ComponentModel.Annotations.dll + + + False + $(CoreFxPath)/System.ComponentModel.dll + + + False + $(CoreFxPath)/System.Console.dll + + + False + $(CoreFxPath)/System.Diagnostics.Debug.dll + + + False + $(CoreFxPath)/System.Diagnostics.Process.dll + + + False + $(CoreFxPath)/System.Diagnostics.Tools.dll + + + False + $(CoreFxPath)/System.Diagnostics.TraceSource.dll + + + False + $(CoreFxPath)/System.Diagnostics.Tracing.dll + + + False + $(CoreFxPath)/System.Dynamic.Runtime.dll + + + False + $(CoreFxPath)/System.Globalization.Calendars.dll + + + False + $(CoreFxPath)/System.Globalization.dll + + + False + $(CoreFxPath)/System.Globalization.Extensions.dll + + + False + $(CoreFxPath)/System.IO.Compression.dll + + + False + $(CoreFxPath)/System.IO.Compression.ZipFile.dll + + + False + $(CoreFxPath)/System.IO.dll + + + False + $(CoreFxPath)/System.IO.FileSystem.dll + + + False + $(CoreFxPath)/System.IO.FileSystem.Primitives.dll + + + False + $(CoreFxPath)/System.IO.FileSystem.Watcher.dll + + + False + $(CoreFxPath)/System.IO.MemoryMappedFiles.dll + + + False + $(CoreFxPath)/System.IO.UnmanagedMemoryStream.dll + + + False + $(CoreFxPath)/System.Linq.dll + + + False + $(CoreFxPath)/System.Linq.Expressions.dll + + + False + $(CoreFxPath)/System.Linq.Parallel.dll + + + False + $(CoreFxPath)/System.Linq.Queryable.dll + + + False + $(CoreFxPath)/System.Net.Http.dll + + + False + $(CoreFxPath)/System.Net.NameResolution.dll + + + False + $(CoreFxPath)/System.Net.Primitives.dll + + + False + $(CoreFxPath)/System.Net.Requests.dll + + + False + $(CoreFxPath)/System.Net.Security.dll + + + False + $(CoreFxPath)/System.Net.Sockets.dll + + + False + $(CoreFxPath)/System.Net.WebHeaderCollection.dll + + + False + $(CoreFxPath)/System.Numerics.Vectors.dll + + + False + $(CoreFxPath)/System.ObjectModel.dll + + + False + $(CoreFxPath)/System.Reflection.DispatchProxy.dll + + + False + $(CoreFxPath)/System.Reflection.dll + + + False + $(CoreFxPath)/System.Reflection.Extensions.dll + + + False + $(CoreFxPath)/System.Reflection.Primitives.dll + + + False + $(CoreFxPath)/System.Reflection.TypeExtensions.dll + + + False + $(CoreFxPath)/System.Resources.ResourceManager.dll + + + False + $(CoreFxPath)/System.Runtime.dll + + + False + $(CoreFxPath)/System.Runtime.Extensions.dll + + + False + $(CoreFxPath)/System.Runtime.Handles.dll + + + False + $(CoreFxPath)/System.Runtime.InteropServices.dll + + + False + $(CoreFxPath)/System.Runtime.InteropServices.RuntimeInformation.dll + + + False + $(CoreFxPath)/System.Runtime.Loader.dll + + + False + $(CoreFxPath)/System.Runtime.Numerics.dll + + + False + $(CoreFxPath)/System.Security.Cryptography.Algorithms.dll + + + False + $(CoreFxPath)/System.Security.Cryptography.Encoding.dll + + + False + $(CoreFxPath)/System.Security.Cryptography.Primitives.dll + + + False + $(CoreFxPath)/System.Security.Cryptography.X509Certificates.dll + + + False + $(CoreFxPath)/System.Text.Encoding.dll + + + False + $(CoreFxPath)/System.Text.Encoding.Extensions.dll + + + False + $(CoreFxPath)/System.Text.RegularExpressions.dll + + + False + $(CoreFxPath)/System.Threading.dll + + + False + $(CoreFxPath)/System.Threading.Tasks.dll + + + False + $(CoreFxPath)/System.Threading.Tasks.Parallel.dll + + + False + $(CoreFxPath)/System.Threading.Thread.dll + + + False + $(CoreFxPath)/System.Threading.ThreadPool.dll + + + False + $(CoreFxPath)/System.Threading.Timer.dll + + + False + $(CoreFxPath)/System.Xml.ReaderWriter.dll + + + False + $(CoreFxPath)/System.Xml.XDocument.dll + + + \ No newline at end of file diff --git a/src/Tizen.Applications.WidgetControl/CustomDictionary.xml b/src/Tizen.Applications.WidgetControl/CustomDictionary.xml new file mode 100755 index 0000000..e69de29 diff --git a/src/Tizen.Applications.WidgetControl/GlobalSuppressions.cs b/src/Tizen.Applications.WidgetControl/GlobalSuppressions.cs new file mode 100755 index 0000000000000000000000000000000000000000..9d742533852f291d5b872bdf32aedc33e5b3af4d GIT binary patch literal 954 zcmaKr%}&EG5QO*Kr?7IS^cfHm5(gwCdf{l&&<5J1Y7(TrJn+rB?oTREr1)oNXUF69 z&-ct`7Hn=StF2@9&bYRUSy~V5R<>aMW_$kk*0NIk&Kiqg_aG9sCl+kOZcVH|jKN-P zur1$?ypHebFh*NC(*zAt5y|O6)zli82^|<$9#LEj8pXB-mz1Tt!X+K5)Y=EplI&Z{ z{LdHrQ$Obys5PA3NMj8{Q&Lx?`Hbk<9$hs zsmHRm;;PHSsLu+|%-)_W%^C`ObZz5)%`QApQ*Wa + + + + Debug + AnyCPU + {A667ADA4-E7DB-4E45-9D31-491024750EE1} + Library + Properties + + + Tizen.Applications.WidgetControl + v4.5 + 512 + + + true + full + true + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + bin\Debug\Tizen.Applications.WidgetControl.XML + ExtendedDesignGuidelineRules.ruleset + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + true + + + Tizen.Applications.WidgetControl.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\tizen\Tizen\bin\Debug\Tizen.dll + + + ..\..\tizen\Tizen.Internals\bin\Debug\Tizen.Internals.dll + + + ..\..\task\application\Tizen.Applications\obj\Debug\Tizen.Applications.dll + + + + + {b9aa1cb2-f72d-4a30-a33b-a20c850a38a0} + Tizen.Internals + + + {7659ca59-410d-41a1-9841-586e88bc78c9} + Tizen + + + {d2d1a3ce-000e-4ab3-81c4-a8a44a008989} + Tizen.Applications + + + + + + + + diff --git a/src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.sln b/src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.sln new file mode 100755 index 0000000..4d955c4 --- /dev/null +++ b/src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.WidgetControl", "Tizen.Applications.WidgetControl.csproj", "{A667ADA4-E7DB-4E45-9D31-491024750EE1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.snk b/src/Tizen.Applications.WidgetControl/Tizen.Applications.WidgetControl.snk new file mode 100755 index 0000000000000000000000000000000000000000..7ac1b002b5c0f81a5b5194224843bb744535469c GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096S12Rh1DXm4>qRQE|Fs044$*e zEyJbLiSRL%Y#NVHY@M>K{9%``de=>mN4`TL|e33wl+OPc%mFqo0y5WXHq`9 zzb|ZJ4h&Bj6c_rG!7}`~i6%VYa##vxfyTV;!iBSG^crc_ZYFA#CU>3g9K5*jw~)Or zz!4Uw+aAT)FC3}nr!?kwh{M_Fq-Ii# z;Z*f_6NQu>yLa!^q~UAJ4yGN@`X9e*X}`7`c+Gny`pNGz9top#4Q7JitBDF~xjM?Yfw<8!w;k;&3kd6H; zc_m-w)0fvjmhV3!9a-U}J|vpk3}J!NNm;rFiy-#L)B-O5r)DkHSl_1`RKo~T`Ns1k zmW}ASU5<(A0WV&H#e}2kJfoL8I2fWqOreJRffWl&M2k)LE`<1N9254nJHy%AHN8vk zfcM~VsKgn7%Zd27DtZ~=pm20An|4X6Bx6v%A0yctfr={tz_&?S4$cPy|G@GzJ&^)7 iFLJDP0G>I0;>GMWh@X3wz0E^RqQ6^4@1FSr|AKP?HYIHU literal 0 HcmV?d00001 diff --git a/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs new file mode 100755 index 0000000..4111395 --- /dev/null +++ b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetControl.cs @@ -0,0 +1,676 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; +using System.Collections.Generic; +using Tizen.Applications; + +namespace Tizen.Applications +{ + /// + /// Class for receiving widget events and sending data to widget. + /// + public class WidgetControl : IDisposable + { + /// + /// Class for widget instance. + /// + public class Instance + { + private string _widgetId; + + /// + /// Constructor. + /// + /// Widget ID + public Instance(string widgetId) + { + _widgetId = widgetId; + } + + /// + /// Widget ID. + /// + public string Id { get; internal set; } + + /// + /// Gets widget content. + /// + /// Thrown in case of failed conditions + public Bundle GetContent() + { + IntPtr h; + + Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetContent(_widgetId, Id, out h); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.IoError: + throw new InvalidOperationException("Failed to access DB"); + } + + return new Bundle(new SafeBundleHandle(h, true)); + } + + /// + /// Changes the content for the widget instance. + /// + /// Content to be changed + /// True if you want to update your widget even if the provider is paused otherwise false. + /// Thrown when failed because of invalid argument + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public void ChangeContent(Bundle content, bool force) + { + Interop.WidgetService.ErrorCode err = Interop.WidgetService.UpdateContent(_widgetId, Id, content.SafeBundleHandle, force ? 1 : 0); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid parameter"); + + case Interop.WidgetService.ErrorCode.Canceled: + throw new InvalidOperationException("Provider is paused, so this update request is canceld"); + + case Interop.WidgetService.ErrorCode.OutOfMemory: + throw new InvalidOperationException("Out-of-memory at unmanaged code"); + + case Interop.WidgetService.ErrorCode.Fault: + throw new InvalidOperationException("Failed to create a request packet"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + } + + /// + /// Changes the update period for the widget instance. + /// + /// Thrown when failed because of invalid argument + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public void ChangePeriod(double period) + { + Interop.WidgetService.ErrorCode err = Interop.WidgetService.ChangePeriod(_widgetId, Id, period); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid parameter"); + + case Interop.WidgetService.ErrorCode.OutOfMemory: + throw new InvalidOperationException("Out-of-memory at unmanaged code"); + + case Interop.WidgetService.ErrorCode.Fault: + throw new InvalidOperationException("Failed to create a request packet"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + } + } + + /// + /// Class for widget size information. + /// + public class Scale + { + /// + /// Enumeration for types of widget size + /// + public enum SizeType : int + { + /// + /// 175x175 based on 720x1280 resolution. + /// + Basic1x1 = 0x0001, + + /// + /// 354x175 based on 720x1280 resolution. + /// + Basic2x1 = 0x0002, + + /// + /// 354x354 based on 720x1280 resolution. + /// + Basic2x2 = 0x0004, + + /// + /// 712x175 based on 720x1280 resolution. + /// + Basic4x1 = 0x0008, + + /// + /// 712x354 based on 720x1280 resolution. + /// + Basic4x2 = 0x0010, + + /// + /// 712x533 based on 720x1280 resolution. + /// + Basic4x3 = 0x0020, + + /// + /// 712x712 based on 720x1280 resolution. + /// + Basic4x4 = 0x0040, + + /// + /// 712x891 based on 720x1280 resolution. + /// + Basic4x5 = 0x0080, + + /// + /// 712x1070 based on 720x1280 resolution. + /// + Basic4x6 = 0x0100, + + + /// + /// 224x215 based on 720x1280 resolution. + /// + Easy1x1 = 0x1000, + + /// + /// 680x215 based on 720x1280 resolution. + /// + Easy1x2 = 0x2000, + + /// + /// 680x653 based on 720x1280 resolution. + /// + Easy1x3 = 0x4000, + + /// + /// 720x1280 based on 720x1280 resolution. + /// + Full = 0x0800, + } + + /// + /// Widget width. + /// + public int Width { get; internal set; } + + /// + /// Widget height. + /// + public int Height { get; internal set; } + + /// + /// The path for widget preview image file. + /// + public string PreviewImagePath { get; internal set; } + + /// + /// The size type of the widget. + /// + public SizeType Type { get; internal set; } + } + + private event EventHandler _created; + private event EventHandler _resumed; + private event EventHandler _paused; + private event EventHandler _destroyed; + private bool _disposedValue = false; + private static IDictionary s_lifecycleEventRefCnt = new Dictionary(); + private static IList s_eventObjects = new List(); + + /// + /// Factory method for WidgetControl. + /// It will create all objects of WidgetControl base on package ID. + /// + /// Parkage ID + /// http://tizen.org/privilege/widget.viewer + /// Thrown when failed because of invalid argument + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public static WidgetControl[] CreateAll(string pkgId) + { + List list = new List(); + + Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) => + { + list.Add(new WidgetControl(widgetId)); + }, IntPtr.Zero); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid parameter"); + + case Interop.WidgetService.ErrorCode.IoError: + throw new InvalidOperationException("Failed to access DB"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + + return list.ToArray(); + } + + /// + /// Gets all widget IDs by package ID. + /// + /// http://tizen.org/privilege/widget.viewer + /// Thrown when failed because of invalid argument + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public static string[] GetWidgetIds(string pkgId) + { + List list = new List(); + + Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetWidgetListByPkgId(pkgId, (widgetId, isPrime, userData) => + { + list.Add(widgetId); + }, IntPtr.Zero); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid parameter"); + + case Interop.WidgetService.ErrorCode.IoError: + throw new InvalidOperationException("Failed to access DB"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + + return list.ToArray(); + } + + /// + /// Widget ID. + /// + public string Id { get; internal set; } + + /// + /// The flag value for "nodisplay" + /// + /// http://tizen.org/privilege/widget.viewer + public bool IsNoDisplay + { + get + { + if (Interop.WidgetService.GetNoDisplay(Id) != 0) + return true; + + return false; + } + } + + /// + /// Event handler for created widget instance. + /// + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public event EventHandler Created + { + add + { + RegisterLifecycleEvent(); + _created += value; + } + remove + { + _created -= value; + UnregisterLifecycleEvent(); + } + } + + /// + /// Event handler for resumed widget instance. + /// + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public event EventHandler Resumed + { + add + { + RegisterLifecycleEvent(); + _resumed += value; + } + remove + { + _resumed -= value; + UnregisterLifecycleEvent(); + } + } + + /// + /// Event handler for paused widget instance. + /// + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public event EventHandler Paused + { + add + { + RegisterLifecycleEvent(); + _paused += value; + } + remove + { + _paused -= value; + UnregisterLifecycleEvent(); + } + } + + /// + /// Event handler for destroyed widget instance. + /// + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public event EventHandler Destroyed + { + add + { + RegisterLifecycleEvent(); + _destroyed += value; + } + remove + { + _destroyed -= value; + UnregisterLifecycleEvent(); + } + } + + /// + /// A constructor of WidgetControl object + /// + /// widget id. + public WidgetControl(string widgetId) + { + Id = widgetId; + } + + /// + /// Finalizer of the WidgetControl class. + /// + ~WidgetControl() + { + Dispose(false); + } + + /// + /// Gets objects for widget instance information. + /// + /// Thrown in case of failed conditions + /// Thrown when API is not supported in this device + /// Thrown when app does not have privilege to access this method + public IEnumerable GetInstances() + { + IList instances = new List(); + Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetInstances(Id, (widgetId, instanceId, userData) => + { + instances.Add(new Instance(widgetId) { Id = instanceId }); + }, IntPtr.Zero); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.NotSupported: + throw new NotSupportedException(); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + + return instances; + } + + /// + /// Gets objects for widget scale information. + /// + /// http://tizen.org/privilege/widget.viewer + /// Thrown in case of failed conditions + /// Thrown when app does not have privilege to access this method + public IEnumerable GetScales() + { + int[] w = new int[100]; + int[] h = new int[100]; + int[] types = new int[100]; + int cnt1 = 100; + int cnt2 = 100; + IList scales = new List(); + + Interop.WidgetService.ErrorCode err = Interop.WidgetService.GetSupportedSizes(Id, ref cnt1, out w, out h); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.IoError: + throw new InvalidOperationException("Failed to access DB"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + + err = Interop.WidgetService.GetSupportedSizeTypes(Id, ref cnt2, out types); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.IoError: + throw new InvalidOperationException("Failed to access DB"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + + if (cnt1 != cnt2) + return null; + + for (int i = 0; i < cnt1; i++) + { + string prev = Interop.WidgetService.GetPreviewImagePath(Id, types[i]); + + scales.Add(new Scale() + { + Width = w[i], + Height = h[i], + PreviewImagePath = prev, + Type = (Scale.SizeType)types[i] + }); + } + return scales; + } + + /// + /// Gets widget name. + /// + /// Language + /// http://tizen.org/privilege/widget.viewer + /// Thrown when argument is null + public string GetName(string lang) + { + if (lang == null) + throw new ArgumentNullException(); + + return Interop.WidgetService.GetName(Id, lang); + } + + /// + /// Gets widget icon path. + /// + /// Language + /// http://tizen.org/privilege/widget.viewer + /// Thrown when argument is null + public string GetIconPath(string lang) + { + if (lang == null) + throw new ArgumentNullException(); + + string pkgId = Interop.WidgetService.GetPkgId(Id); + + return Interop.WidgetService.GetIcon(pkgId, lang); + } + + /// + /// Releases all resources used by the WidgetControl class. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + } + + _created = null; + _resumed = null; + _paused = null; + _destroyed = null; + UnregisterLifecycleEvent(); + + _disposedValue = true; + } + } + + private void RegisterLifecycleEvent() + { + if (!s_lifecycleEventRefCnt.ContainsKey(Id)) + s_lifecycleEventRefCnt[Id] = 0; + + if (_created != null || _paused != null || _resumed != null || _destroyed != null) + return; + + if (s_lifecycleEventRefCnt[Id] == 0) + { + Interop.WidgetService.ErrorCode err = Interop.WidgetService.SetLifecycleEvent(Id, OnLifecycleEvent, IntPtr.Zero); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + } + } + + s_lifecycleEventRefCnt[Id]++; + s_eventObjects.Add(this); + } + + private void UnregisterLifecycleEvent() + { + if (!s_lifecycleEventRefCnt.ContainsKey(Id)) + return; + + if (s_lifecycleEventRefCnt[Id] <= 0) + return; + + if (_created != null || _paused != null || _resumed != null || _destroyed != null) + return; + + if (s_lifecycleEventRefCnt[Id] == 1) + { + Interop.WidgetService.ErrorCode err = Interop.WidgetService.UnsetLifecycleEvent(Id, IntPtr.Zero); + + switch (err) + { + case Interop.WidgetService.ErrorCode.InvalidParameter: + throw new InvalidOperationException("Invalid parameter at unmanaged code"); + + case Interop.WidgetService.ErrorCode.PermissionDenied: + throw new UnauthorizedAccessException(); + + case Interop.WidgetService.ErrorCode.NotExist: + throw new InvalidOperationException("Event handler is not exist"); + } + } + + s_eventObjects.Remove(this); + s_lifecycleEventRefCnt[Id]--; + } + + private static void OnLifecycleEvent(string widgetId, Interop.WidgetService.LifecycleEvent e, string instanceId, IntPtr userData) + { + switch (e) + { + case Interop.WidgetService.LifecycleEvent.Created: + foreach (WidgetControl c in s_eventObjects) + { + if (c.Id.CompareTo(widgetId) == 0) + { + c._created?.Invoke(null, new WidgetLifecycleEventArgs() + { + WidgetId = widgetId, + InstanceId = instanceId, + Type = WidgetLifecycleEventArgs.EventType.Created + }); + } + } + break; + + case Interop.WidgetService.LifecycleEvent.Resumed: + foreach (WidgetControl c in s_eventObjects) + { + if (c.Id.CompareTo(widgetId) == 0) + { + c._resumed?.Invoke(null, new WidgetLifecycleEventArgs() + { + WidgetId = widgetId, + InstanceId = instanceId, + Type = WidgetLifecycleEventArgs.EventType.Resumed + }); + } + } + break; + + case Interop.WidgetService.LifecycleEvent.Paused: + foreach (WidgetControl c in s_eventObjects) + { + if (c.Id.CompareTo(widgetId) == 0) + { + c._paused?.Invoke(null, new WidgetLifecycleEventArgs() + { + WidgetId = widgetId, + InstanceId = instanceId, + Type = WidgetLifecycleEventArgs.EventType.Paused + }); + } + } + break; + + case Interop.WidgetService.LifecycleEvent.Destroyed: + foreach (WidgetControl c in s_eventObjects) + { + if (c.Id.CompareTo(widgetId) == 0) + { + c._destroyed?.Invoke(null, new WidgetLifecycleEventArgs() + { + WidgetId = widgetId, + InstanceId = instanceId, + Type = WidgetLifecycleEventArgs.EventType.Destroyed + }); + } + } + break; + } + + } + } +} diff --git a/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetLifecycleEventArgs.cs b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetLifecycleEventArgs.cs new file mode 100755 index 0000000..6d0b5fa --- /dev/null +++ b/src/Tizen.Applications.WidgetControl/Tizen.Applications/WidgetLifecycleEventArgs.cs @@ -0,0 +1,59 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. + +using System; + +namespace Tizen.Applications +{ + /// + /// Class for event arguments of the widget lifecycle. + /// + public class WidgetLifecycleEventArgs : EventArgs + { + /// + /// Enumeration for event type. + /// + public enum EventType + { + /// + /// The widget is created. + /// + Created, + + /// + /// The widget is destroyed. + /// + Destroyed, + + /// + /// The widget is paused. + /// + Paused, + + /// + /// The widget is resumed. + /// + Resumed + } + + /// + /// Widget ID. + /// + public string WidgetId { get; internal set; } + + /// + /// Widget instnace ID. + /// + public string InstanceId { get; internal set; } + + /// + /// Event type. + /// + public EventType Type { get; internal set; } + } +} -- 2.7.4