--- /dev/null
+
+ 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.
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+%{!?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-badge
+Summary: Tizen badge 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
+
+%description
+Tizen badge API for C#
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%define Assemblies Tizen.Applications.Badge
+
+%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
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Condition=" '$(CoreFxPath)' != '' ">
+ <Reference Include="Microsoft.Win32.Primitives">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/Microsoft.Win32.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.AppContext">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.AppContext.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Collections.Concurrent">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Collections.Concurrent.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Collections">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Collections.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel.Annotations">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.ComponentModel.Annotations.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ComponentModel">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.ComponentModel.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Console">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Console.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.Debug">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Diagnostics.Debug.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.Process">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Diagnostics.Process.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.Tools">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Diagnostics.Tools.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.TraceSource">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Diagnostics.TraceSource.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Diagnostics.Tracing">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Diagnostics.Tracing.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Dynamic.Runtime">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Dynamic.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Globalization.Calendars">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Globalization.Calendars.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Globalization">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Globalization.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Globalization.Extensions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Globalization.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.Compression">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.Compression.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.Compression.ZipFile">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.Compression.ZipFile.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.FileSystem.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem.Primitives">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.FileSystem.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.FileSystem.Watcher">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.FileSystem.Watcher.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.MemoryMappedFiles">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.MemoryMappedFiles.dll</HintPath>
+ </Reference>
+ <Reference Include="System.IO.UnmanagedMemoryStream">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.IO.UnmanagedMemoryStream.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Linq">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Linq.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Linq.Expressions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Linq.Expressions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Linq.Parallel">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Linq.Parallel.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Linq.Queryable">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Linq.Queryable.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.NameResolution">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.NameResolution.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Primitives">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Requests">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.Requests.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Security">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.Security.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Sockets">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.Sockets.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.WebHeaderCollection">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Net.WebHeaderCollection.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Numerics.Vectors">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Numerics.Vectors.dll</HintPath>
+ </Reference>
+ <Reference Include="System.ObjectModel">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.ObjectModel.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection.DispatchProxy">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Reflection.DispatchProxy.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Reflection.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection.Extensions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Reflection.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection.Primitives">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Reflection.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Reflection.TypeExtensions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Reflection.TypeExtensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Resources.ResourceManager">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Resources.ResourceManager.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.Extensions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.Handles">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.Handles.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.InteropServices">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.InteropServices.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.InteropServices.RuntimeInformation">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.Loader">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.Loader.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Runtime.Numerics">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Runtime.Numerics.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Algorithms">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Security.Cryptography.Algorithms.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Encoding">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Security.Cryptography.Encoding.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.Primitives">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Security.Cryptography.Primitives.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Security.Cryptography.X509Certificates">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Security.Cryptography.X509Certificates.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Text.Encoding">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Text.Encoding.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Text.Encoding.Extensions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Text.Encoding.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Text.RegularExpressions">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Text.RegularExpressions.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Tasks">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.Tasks.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Tasks.Parallel">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.Tasks.Parallel.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Thread">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.Thread.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.ThreadPool">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.ThreadPool.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Threading.Timer">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Threading.Timer.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.ReaderWriter">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Xml.ReaderWriter.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Xml.XDocument">
+ <Private>False</Private>
+ <HintPath>$(CoreFxPath)/System.Xml.XDocument.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+// 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.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Badge
+ {
+ internal enum ErrorCode : int
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+ FromDb = -0x01120000 | 0x01,
+ AlreadyExist = -0x01120000 | 0x02,
+ FromDbus = -0x01120000 | 0x03,
+ NotExist = -0x01120000 | 0x04,
+ ServiceNotReady = -0x01120000 | 0x05,
+ InvalidPackage = -0x01120000 | 0x06
+ }
+
+ internal enum Action : uint
+ {
+ Create = 0,
+ Remove,
+ Update,
+ ChangedDisplay,
+ ServiceReady
+ }
+
+ internal delegate void ForeachCallback(string appId, uint count, IntPtr userData);
+ internal delegate void ChangedCallback(Action action, string appId, uint count, IntPtr userData);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_add")]
+ internal static extern ErrorCode Add(string appId);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_remove")]
+ internal static extern ErrorCode Remove(string appId);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_set_count")]
+ internal static extern ErrorCode SetCount(string appId, uint count);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_get_count")]
+ internal static extern ErrorCode GetCount(string appId, out uint count);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_set_display")]
+ internal static extern ErrorCode SetDisplay(string appId, uint isDisplay);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_get_display")]
+ internal static extern ErrorCode GetDisplay(string appId, out uint isDisplay);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_foreach")]
+ internal static extern ErrorCode Foreach(ForeachCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_register_changed_cb")]
+ internal static extern ErrorCode SetChangedCallback(ChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Badge, EntryPoint = "badge_unregister_changed_cb")]
+ internal static extern ErrorCode UnsetChangedCallback(ChangedCallback callback);
+
+ }
+}
--- /dev/null
+// 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.
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Badge = "libbadge.so.0";
+ }
+}
--- /dev/null
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Tizen.Applications.Badge")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.Applications.Badge")]
+[assembly: AssemblyCopyright("Copyright (c) 2016 Samsung Electronics Co., Ltd")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+[assembly: CLSCompliant(true)]
+
+[assembly: Guid("99E463CB-A535-4652-B29F-BDEE93076DBB")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{A667ADA4-E7DB-4E45-9D31-491024750EE1}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>\r
+ </RootNamespace>\r
+ <AssemblyName>Tizen.Applications.Badge</AssemblyName>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ <FileAlignment>512</FileAlignment>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Debug\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+ <DocumentationFile>bin\Debug\Tizen.Applications.Badge.XML</DocumentationFile>\r
+ <CodeAnalysisRuleSet>ExtendedDesignGuidelineRules.ruleset</CodeAnalysisRuleSet>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>true</SignAssembly>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <AssemblyOriginatorKeyFile>Tizen.Applications.Badge.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <Import Project="CoreFx.References.targets" />\r
+ <ItemGroup Condition=" '$(CoreFxPath)' == '' ">\r
+ <Reference Include="System" />\r
+ <Reference Include="System.Core" />\r
+ <Reference Include="System.Xml.Linq" />\r
+ <Reference Include="System.Data.DataSetExtensions" />\r
+ <Reference Include="Microsoft.CSharp" />\r
+ <Reference Include="System.Data" />\r
+ <Reference Include="System.Net.Http" />\r
+ <Reference Include="System.Xml" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="GlobalSuppressions.cs" />\r
+ <Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Interop\Interop.Badge.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Tizen.Applications\Badge.cs" />\r
+ <Compile Include="Tizen.Applications\BadgeControl.cs" />\r
+ <Compile Include="Tizen.Applications\BadgeEventArgs.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Applications.Badge.snk" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <CodeAnalysisDictionary Include="CustomDictionary.xml" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Reference Include="Tizen">\r
+ <HintPath>..\..\tizen\Tizen\bin\Debug\Tizen.dll</HintPath>\r
+ </Reference>\r
+ <Reference Include="Tizen.Internals">\r
+ <HintPath>..\..\tizen\Tizen.Internals\bin\Debug\Tizen.Internals.dll</HintPath>\r
+ </Reference>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ProjectReference Include="..\..\tizen\Tizen.Internals\Tizen.Internals.csproj">\r
+ <Project>{b9aa1cb2-f72d-4a30-a33b-a20c850a38a0}</Project>\r
+ <Name>Tizen.Internals</Name>\r
+ </ProjectReference>\r
+ <ProjectReference Include="..\..\tizen\Tizen\Tizen.csproj">\r
+ <Project>{7659ca59-410d-41a1-9841-586e88bc78c9}</Project>\r
+ <Name>Tizen</Name>\r
+ </ProjectReference>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <WCFMetadata Include="Service References\" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->\r
+</Project>
\ No newline at end of file
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.24720.0\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.Badge", "Tizen.Applications.Badge.csproj", "{A667ADA4-E7DB-4E45-9D31-491024750EE1}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {A667ADA4-E7DB-4E45-9D31-491024750EE1}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+// 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.
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// Immutable class for getting information of the badge.
+ /// </summary>
+ public class Badge
+ {
+ private readonly string _appId;
+ private readonly int _count;
+ private readonly bool _isDisplay;
+
+ internal Badge(string appid, int count, bool isDisplay)
+ {
+ _appId = appid;
+ _count = count;
+ _isDisplay = isDisplay;
+ }
+
+ /// <summary>
+ /// Property for the count value of the badge.
+ /// </summary>
+ public int Count
+ {
+ get
+ {
+ return _count;
+ }
+ }
+
+ /// <summary>
+ /// Property for the application ID of the badge.
+ /// </summary>
+ public string AppId
+ {
+ get
+ {
+ return _appId;
+ }
+ }
+
+ /// <summary>
+ /// Property for the flag of 'display'.
+ /// </summary>
+ public bool IsDisplay
+ {
+ get
+ {
+ return _isDisplay;
+ }
+ }
+ }
+}
--- /dev/null
+// 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;
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// Class for badge operaion.
+ /// </summary>
+ public static class BadgeControl
+ {
+ private static event EventHandler<BadgeEventArgs> s_changed;
+ private static bool s_registered = false;
+
+ /// <summary>
+ /// Event handler for receiving badge events.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static event EventHandler<BadgeEventArgs> Changed
+ {
+ add
+ {
+ if (s_changed == null && !s_registered)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.SetChangedCallback(OnChangedEvent, IntPtr.Zero);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter at unmanaged code");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.OutOfMemory:
+ throw new InvalidOperationException("Out-of-memory at unmanaged code");
+ }
+
+ s_registered = true;
+ }
+ s_changed += value;
+ }
+ remove
+ {
+ s_changed -= value;
+ if (s_changed == null && s_registered)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.UnsetChangedCallback(OnChangedEvent);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter at unmanaged code");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.NotExist:
+ throw new InvalidOperationException("Not exist");
+ }
+
+ s_registered = false;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the badge information from application ID.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static Badge Find(string appId)
+ {
+ uint count;
+ uint display;
+
+ Interop.Badge.ErrorCode err = Interop.Badge.GetCount(appId, out count);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.FromDb:
+ throw new InvalidOperationException("Error from DB");
+
+ case Interop.Badge.ErrorCode.OutOfMemory:
+ throw new InvalidOperationException("Out-of-memory at unmanaged code");
+ }
+
+ err = Interop.Badge.GetDisplay(appId, out display);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.FromDb:
+ throw new InvalidOperationException("Error from DB");
+
+ case Interop.Badge.ErrorCode.OutOfMemory:
+ throw new InvalidOperationException("Out-of-memory at unmanaged code");
+
+ case Interop.Badge.ErrorCode.NotExist:
+ throw new InvalidOperationException("Not exist");
+ }
+
+ return new Badge(appId, (int)count, display == 0 ? false : true);
+ }
+
+ /// <summary>
+ /// Removes the badge information.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static void Remove(string appId)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.Remove(appId);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.IoError:
+ throw new InvalidOperationException("Error from I/O");
+
+ case Interop.Badge.ErrorCode.ServiceNotReady:
+ throw new InvalidOperationException("Service is not ready");
+ }
+ }
+
+ /// <summary>
+ /// Adds the badge information.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <param name="count">Count value</param>
+ /// <param name="isDisplay">True if it should be displayed</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static void Add(string appId, int count = 1, bool isDisplay = true)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.Add(appId);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.IoError:
+ throw new InvalidOperationException("Error from I/O");
+
+ case Interop.Badge.ErrorCode.ServiceNotReady:
+ throw new InvalidOperationException("Service is not ready");
+
+ case Interop.Badge.ErrorCode.InvalidPackage:
+ throw new InvalidOperationException("The caller application is not signed with the certificate of badge application ID");
+ }
+
+ try
+ {
+ Update(appId, count, isDisplay);
+ }
+ catch (Exception e)
+ {
+ Remove(appId);
+ throw e;
+ }
+ }
+
+ /// <summary>
+ /// Updates the badge information.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <param name="count">Count value</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static void Update(string appId, int count)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.SetCount(appId, (uint)count);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.IoError:
+ throw new InvalidOperationException("Error from I/O");
+
+ case Interop.Badge.ErrorCode.ServiceNotReady:
+ throw new InvalidOperationException("Service is not ready");
+ }
+ }
+
+ /// <summary>
+ /// Updates the badge information.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <param name="isDisplay">True if it should be displayed</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static void Update(string appId, bool isDisplay)
+ {
+ Interop.Badge.ErrorCode err = Interop.Badge.SetDisplay(appId, isDisplay ? 1U : 0U);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new ArgumentException("Invalid parameter");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.IoError:
+ throw new InvalidOperationException("Error from I/O");
+
+ case Interop.Badge.ErrorCode.ServiceNotReady:
+ throw new InvalidOperationException("Service is not ready");
+ }
+ }
+
+ /// <summary>
+ /// Updates the badge information.
+ /// </summary>
+ /// <param name="appId">Application ID</param>
+ /// <param name="count">Count value</param>
+ /// <param name="isDisplay">True if it should be displayed</param>
+ /// <exception cref="ArgumentException">Thrown when failed because of invalid argument</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static void Update(string appId, int count, bool isDisplay)
+ {
+ Update(appId, count);
+ Update(appId, isDisplay);
+ }
+
+ /// <summary>
+ /// Gets all badge information.
+ /// </summary>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of failed conditions</exception>
+ /// <privilege>http://tizen.org/privilege/notification</privilege>
+ public static IEnumerable<Badge> GetBadges()
+ {
+ IList<Badge> list = new List<Badge>();
+
+ Interop.Badge.ErrorCode err = Interop.Badge.Foreach((appId, count, userData) =>
+ {
+ uint display = 0;
+ Interop.Badge.ErrorCode e = Interop.Badge.GetDisplay(appId, out display);
+ switch (e)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter at unmanaged code");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.FromDb:
+ throw new InvalidOperationException("Error from DB");
+
+ case Interop.Badge.ErrorCode.OutOfMemory:
+ throw new InvalidOperationException("Out-of-memory at unmanaged code");
+
+ case Interop.Badge.ErrorCode.NotExist:
+ throw new InvalidOperationException("Not exist");
+
+ case Interop.Badge.ErrorCode.ServiceNotReady:
+ throw new InvalidOperationException("Service is not ready");
+ }
+
+ list.Add(new Badge(appId, (int)count, display == 0 ? false : true));
+ }, IntPtr.Zero);
+
+ switch (err)
+ {
+ case Interop.Badge.ErrorCode.InvalidParameter:
+ throw new InvalidOperationException("Invalid parameter at unmanaged code");
+
+ case Interop.Badge.ErrorCode.PermissionDenied:
+ throw new UnauthorizedAccessException();
+
+ case Interop.Badge.ErrorCode.FromDb:
+ throw new InvalidOperationException("Error from DB");
+
+ case Interop.Badge.ErrorCode.OutOfMemory:
+ throw new InvalidOperationException("Out-of-memory at unmanaged code");
+
+ case Interop.Badge.ErrorCode.NotExist:
+ throw new InvalidOperationException("Not exist");
+ }
+
+ return list;
+ }
+
+ private static void OnChangedEvent(Interop.Badge.Action action, string appId, uint count, IntPtr userData)
+ {
+ uint display = 0;
+
+ switch (action)
+ {
+ case Interop.Badge.Action.Create:
+ s_changed?.Invoke(null, new BadgeEventArgs()
+ {
+ Reason = BadgeEventArgs.Action.Add,
+ Badge = new Badge(appId, 0, false)
+ });
+ break;
+
+ case Interop.Badge.Action.Remove:
+ s_changed?.Invoke(null, new BadgeEventArgs()
+ {
+ Reason = BadgeEventArgs.Action.Remove,
+ Badge = new Badge(appId, 0, false)
+ });
+ break;
+
+ case Interop.Badge.Action.Update:
+ case Interop.Badge.Action.ChangedDisplay:
+ Interop.Badge.GetDisplay(appId, out display);
+ s_changed?.Invoke(null, new BadgeEventArgs()
+ {
+ Reason = BadgeEventArgs.Action.Update,
+ Badge = new Badge(appId, (int)count, display == 0 ? false : true)
+ });
+ break;
+
+ case Interop.Badge.Action.ServiceReady:
+ // Ignore
+ break;
+ }
+ }
+ }
+}
--- /dev/null
+// 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.
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// Class for event arguments of the badge event
+ /// </summary>
+ public class BadgeEventArgs
+ {
+ /// <summary>
+ /// Enumeration for badge action.
+ /// </summary>
+ public enum Action : int
+ {
+ /// <summary>
+ /// Badge was added.
+ /// </summary>
+ Add = 0,
+
+ /// <summary>
+ /// Badge was removed.
+ /// </summary>
+ Remove,
+
+ /// <summary>
+ /// Badge was updated.
+ /// </summary>
+ Update,
+ }
+
+ /// <summary>
+ /// Property for Badge object.
+ /// </summary>
+ public Badge Badge { get; internal set; }
+
+ /// <summary>
+ /// Property for Action value.
+ /// </summary>
+ public Action Reason { get; internal set; }
+ }
+}