--- /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 /opt/usr/share/dotnet.tizen/framework}
+
+%if 0%{?tizen_build_devel_mode}
+%define BUILDCONF Debug
+%else
+%define BUILDCONF Release
+%endif
+
+Name: csapi-geofence
+Summary: Tizen location geofence 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
+
+AutoReqProv: no
+
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+
+BuildRequires: dotnet-build-tools
+
+# NuGet for Dependencies
+BuildRequires: csapi-tizen-nuget
+
+
+%description
+geofence C# API for Tizen
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%define Assemblies Tizen.Location.Geofence
+
+%build
+for ASM in %{Assemblies}; do
+# NuGet Restore
+find $ASM/*.project.json -exec nuget restore {} \;
+# Build
+find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \;
+# NuGet Pack
+nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF}
+done
+
+%install
+# Runtime Binary
+mkdir -p %{buildroot}%{dotnet_assembly_path}
+for ASM in %{Assemblies}; do
+%if 0%{?_with_corefx}
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%else
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%endif
+done
+# NuGet
+mkdir -p %{buildroot}/nuget
+install -p -m 644 *.nupkg %{buildroot}/nuget
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_path}/*.dll
+
+%package nuget
+Summary: NuGet package for %{name}
+Group: Development/Libraries
+
+%description nuget
+NuGet package for %{name}
+
+%files nuget
+/nuget/*.nupkg
--- /dev/null
+/*
+ * Copyright (c) 2016 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 Geofence = "libcapi-geofence-manager.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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 Tizen.Location.Geofence;
+
+internal static partial class Interop
+{
+ internal static partial class Geofence
+ {
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_geopoint")]
+ public static extern int CreateGPSFence(int placeId, double latitude, double longitude, int radius, string address, out IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_bluetooth")]
+ public static extern int CreateBTFence(int placeId, string bssid, string ssid, out IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_create_wifi")]
+ public static extern int CreateWiFiFence(int placeId, string bssid, string ssid, out IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_destroy")]
+ public static extern int Destroy(IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_create")]
+ public static extern int CreateFenceStatus(int placeId, out IntPtr statusHandle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_destroy")]
+ public static extern int ReleaseFenceStatus(IntPtr statusHandle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_type")]
+ public static extern int FenceType(IntPtr handle, out FenceType type);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_place_id")]
+ public static extern int FencePlaceID(IntPtr handle, out int placeId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_latitude")]
+ public static extern int FenceLatitude(IntPtr handle, out double latitude);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_longitude")]
+ public static extern int FenceLongitude(IntPtr handle, out double longitude);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_radius")]
+ public static extern int FenceRadius(IntPtr handle, out int radius);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_address")]
+ public static extern int FenceAddress(IntPtr handle, out string address);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_bssid")]
+ public static extern int FenceBSSID(IntPtr handle, out string bssid);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_get_ssid")]
+ public static extern int FenceSSID(IntPtr handle, out string ssid);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_get_state")]
+ public static extern int FenceState(IntPtr statusHandle, out GeofenceState state);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_status_get_duration")]
+ public static extern int FenceDuration(IntPtr statusHandle, out int seconds);
+
+ }
+
+ internal static partial class GeofenceManager
+ {
+ public delegate bool StateChangedCallback(int fenceId,GeofenceState state,IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_is_supported")]
+ public static extern int IsSupported(out bool supported);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_create")]
+ public static extern int Create(out IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_destroy")]
+ public static extern int Destroy(IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_start")]
+ public static extern int Start(IntPtr handle, int fenceId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_stop")]
+ public static extern int Stop(IntPtr handle, int fenceId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_state_changed_cb")]
+ public static extern int SetStateChangedCB(IntPtr handle, StateChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_state_changed_cb")]
+ public static extern int UnsetStateChangedCB(IntPtr handle);
+ }
+
+ internal static partial class VirtualPerimeter
+ {
+ public delegate bool ForEachPlaceListCallback(int placeId, string placeName, int placeIndex, int placeCount, IntPtr userData);
+
+ public delegate bool ForEachFenceListCallback(int fenceId, IntPtr fenceHandle, int placeIndex, int placeCount, IntPtr userData);
+
+ public delegate bool ProximityStateChangedCallback(int fenceId, ProximityState state, ProximityProvider provider, IntPtr userData);
+
+ public delegate bool GeofenceEventCallback(int placeId,int fenceId, GeofenceError error, GeoFenceEventType eventType, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_add_place")]
+ public static extern int AddPlace(IntPtr handle, string placeName, out int placeId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_update_place")]
+ public static extern int UpdatePlace(IntPtr handle, int placeId, string placeName);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_remove_place")]
+ public static extern int RemovePlace(IntPtr handle, int placeId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_add_fence")]
+ public static extern int AddFence(IntPtr handle, IntPtr fenceHandle, out int fenceId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_remove_fence")]
+ public static extern int RemoveFence(IntPtr handle, int fenceId);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_event_cb")]
+ public static extern int SetGeofenceEventCB(IntPtr handle, GeofenceEventCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_event_cb")]
+ public static extern int UnsetGeofenceEventCB(IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_set_geofence_proximity_state_changed_cb")]
+ public static extern int SetProximityStateCB(IntPtr handle, ProximityStateChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_unset_geofence_proximity_state_changed_cb")]
+ public static extern int UnsetProximityStateCB(IntPtr handle);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_geofence_list")]
+ public static extern int GetForEachFenceList(IntPtr handle, ForEachFenceListCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_place_geofence_list")]
+ public static extern int GetForEachPlaceFenceList(IntPtr handle,int placeId, ForEachFenceListCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_foreach_place_list")]
+ public static extern int GetForEachPlaceList(IntPtr handle, ForEachPlaceListCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.Geofence, EntryPoint = "geofence_manager_get_place_name")]
+ public static extern int GetPlaceName(IntPtr handle, int placeId, out string placeName);
+
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Location")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Location")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a5d934e0-284a-42b9-8395-34b92fb32e63")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{47F9D980-5C53-495D-973A-E996ECDBE744}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Location</RootNamespace>
+ <AssemblyName>Tizen.Location.Geofence</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\Net45\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\Net45\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Location.Geofence.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="Tizen">
+ <HintPath>..\..\..\..\system\tct-system-device-tizen-tests\lib\Tizen.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Location.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceErrorFactory.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceEnum.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceEventArgs.cs" />
+ <Compile Include="Tizen.Location.Geofence\FenceData.cs" />
+ <Compile Include="Tizen.Location.Geofence\VirtualPerimeter.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceManager.cs" />
+ <Compile Include="Tizen.Location.Geofence\Fence.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Location.Geofence.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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>
+ -->
+</Project>
--- /dev/null
+{
+ "dependencies": {
+ "Tizen": "1.0.0"
+ },
+ "frameworks": {
+ "net45": {}
+ },
+ "runtimes": {
+ "win": {}
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{A5D934E0-284A-42B9-8395-34B92FB32E63}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Location</RootNamespace>
+ <AssemblyName>Tizen.Location.Geofence</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.6</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.6</NuGetTargetMoniker>
+ <TargetFrameworkMoniker>.NETStandard,Version=v1.6</TargetFrameworkMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701</NoWarn>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Location.Geofence.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Location.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceErrorFactory.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceEnum.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceEventArgs.cs" />
+ <Compile Include="Tizen.Location.Geofence\FenceData.cs" />
+ <Compile Include="Tizen.Location.Geofence\VirtualPerimeter.cs" />
+ <Compile Include="Tizen.Location.Geofence\GeofenceManager.cs" />
+ <Compile Include="Tizen.Location.Geofence\Fence.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Location.Geofence.nuspec" />
+ <None Include="Tizen.Location.Geofence.project.json" />
+ <None Include="Tizen.Location.Geofence.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets" Condition="Exists('$(MSBuildExtensionsPath)\Tizen\Tizen.CSharp.GBS.targets')" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- 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>
+ -->
+ <PropertyGroup>
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
+ </PropertyGroup>
+ <!-- Include tasks for Tizen -->
+ <PropertyGroup>
+ <TizenBuildPath>$(MSBuildExtensionsPath)\Tizen</TizenBuildPath>
+ <TizenToolsPath>$(TizenBuildPath)\bin</TizenToolsPath>
+ </PropertyGroup>
+ <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenCleanPackageSource" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+ <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenPreparePackageManifest" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+ <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenPreparePackageSource" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+ <UsingTask TaskName="Tizen.Tasks.SignPackage.TizenSignPackage" AssemblyFile="$(TizenToolsPath)\Tizen.Tasks.SignPackage.dll" />
+ <!-- Task to clean package source -->
+ <Target Name="_TizenCleanPkgSrc">
+ <TizenCleanPackageSource SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" />
+ </Target>
+ <!-- Task to prepare tizen-manifest.xml file -->
+ <Target Name="_TizenPrepManifest">
+ <TizenPreparePackageManifest SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" />
+ </Target>
+ <!-- Task to prepare package sources(executable, dlls, resource files) -->
+ <Target Name="_TizenPrepPkgSrc">
+ <TizenPreparePackageSource SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" AssemblyName="$(AssemblyName)" TargetPath="$(TargetPath)" />
+ </Target>
+ <!-- Task to signing and packaging -->
+ <Target Name="_TizenSignPackge">
+ <TizenSignPackage SolutionPath="$(SolutionPath)" ProjectPath="$(MSBuildProjectFullPath)" SolutionName="$(SolutionName)" AuthorCertificate="$(AuthorCertificate)" AuthorPasswd="$(AuthorPasswd)" DistribCertificate="$(DistribCertificate)" DistribPasswd="$(DistribPasswd)" />
+ </Target>
+</Project>
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Location.Geofence</id>
+ <version>$version$</version>
+ <authors>Tizen Developers</authors>
+ <description>Geofence management APIs for Tizen.Location</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.0" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Location.Geofence.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Location.Geofence.dll" target="lib/net45" />
+ </files>
+</package>
--- /dev/null
+{
+ "buildOptions": {
+ "debugType": "portable",
+ "platform": "AnyCPU",
+ "preserveCompilationContext": true
+ },
+ "dependencies": {
+ "NETStandard.Library": "1.6.0",
+ "Tizen": "1.0.0"
+ },
+ "runtimes": {
+ "win": {}
+ },
+ "frameworks": {
+ "netstandard1.6": {}
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Geo-fence defines a virtual perimeter for a real-world geographic area.
+ /// If you create a geofence, you can trigger some activities when a device enters(or exits) the geofences defined by you.
+ /// You can create a geofence with the information of Geopoint, Wi-Fi, or BT.
+ /// <list >
+ /// <item>Geopoint: Geofence is specified by coordinates (Latitude and Longitude) and Radius</item>
+ /// <item>WIFI: Geofence is specified by BSSID of Wi-Fi access point</item>
+ /// <item>BT: Geofence is specified by Bluetooth address</item>
+ /// </list>
+ /// Basic service set identification(BSSID) The BSSID is the MAC address of the wireless access point(WAP) generated by combining the 24 bit Organization Unique Identifier(the manufacturer's identity)
+ /// and the manufacturer's assigned 24-bit identifier for the radio chipset in the WAP.
+ /// </summary>
+ public class Fence : IDisposable
+ {
+ internal IntPtr Handle
+ {
+ get;
+ set;
+ }
+
+
+ internal Fence(IntPtr handle)
+ {
+ Handle = handle;
+ }
+
+ ~Fence()
+ {
+ Dispose(false);
+ }
+ /// <summary>
+ /// Gets the type of geofence
+ /// </summary>
+ public FenceType Type
+ {
+ get
+ {
+ FenceType val;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceType(Handle, out val);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get GeofenceType");
+ }
+
+ return val;
+ }
+ }
+
+ /// <summary>
+ /// Gets the id of place.
+ /// </summary>
+ public int PlaceId
+ {
+ get
+ {
+ int result = -1;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FencePlaceID(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get PlaceId");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ ///Gets the longitude of geofence.
+ /// </summary>
+ public double Longitude
+ {
+ get
+ {
+ double result = -1;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceLongitude(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Longitude");
+ }
+
+ return result;
+
+ }
+ }
+
+ /// <summary>
+ ///Gets the latitude of geofence.
+ /// </summary>
+ public double Latitude
+ {
+ get
+ {
+ double result = -1;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceLatitude(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Latitude");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the radius of geofence.
+ /// </summary>
+ public int Radius
+ {
+ get
+ {
+ int result = -1;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceRadius(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Radius");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the state of geofence.
+ /// </summary>
+ public GeofenceState FenceState
+ {
+ get
+ {
+ GeofenceState state;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceState(Handle, out state);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get GeofenceState");
+ }
+
+ return state;
+ }
+ }
+
+ /// <summary>
+ /// Gets the amount of seconds geofence is in the current state.
+ /// </summary>
+ public int Duration
+ {
+ get
+ {
+ int result = -1;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceDuration(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Duration");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the address of geofence.
+ /// </summary>
+ public string Address
+ {
+ get
+ {
+ string result = "";
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceAddress(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Adress");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Gets the bssid of geofence.
+ /// </summary>
+ public string Bssid
+ {
+ get
+ {
+ string result = "";
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceBSSID(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Bssid");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ ///Gets the ssid of geofence.
+ /// </summary>
+ public string Ssid
+ {
+ get
+ {
+ string result = "";
+ GeofenceError ret = (GeofenceError)Interop.Geofence.FenceSSID(Handle, out result);
+ if (ret != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get Ssid");
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// Creates a geopoint type of new geofence.
+ /// </summary>
+ /// <param name="placeId">The current place id</param>
+ /// <param name="latitude">Specifies the value of latitude of geofence [-90.0 ~ 90.0] (degrees) </param>
+ /// <param name="longitude">Specifies the value of longitude of geofence [-180.0 ~ 180.0] (degrees) </param>
+ /// <param name="radius">Specifies the value of radius of geofence [100 ~ 500](meter) </param>
+ /// <param name="adsress">Specifies the value of address</param>
+ /// <returns>Newly created geofence instance </returns>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public static Fence CreateGPSFence(int placeId, int latitude, int longitude, int radius, string address)
+ {
+ IntPtr handle = IntPtr.Zero;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.CreateGPSFence(placeId,latitude, longitude, radius,address,out handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence from GPS Data for " + placeId);
+ }
+
+ return new Fence(handle);
+ }
+
+ /// <summary>
+ /// Creates a Wi-Fi type of new geofence.
+ /// </summary>
+ /// <param name="placeId">The current place id </param>
+ /// <param name="bssid">Specifies the value of BSSID of Wi-Fi MAC address</param>
+ /// <param name="ssid"> Specifies the value of SSID of Wi-Fi Device </param>
+ /// <returns>Newly created geofence instance </returns>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public static Fence CreateWifiFence(int placeId, string bssid, string ssid)
+ {
+ IntPtr handle = IntPtr.Zero;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.CreateWiFiFence(placeId, bssid, ssid, out handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence from Wifi Data for " + placeId);
+ }
+
+ return new Fence(handle);
+ }
+
+ /// <summary>
+ /// Creates a bluetooth type of new geofence.
+ /// </summary>
+ /// <param name="placeId">The current place id </param>
+ /// <param name="bssid">Specifies the value of BSSID of BT MAC address</param>
+ /// <param name="ssid"> Specifies the value of SSID of BT Device </param>
+ /// <returns>Newly created geofence instance </returns>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public static Fence CreateBTFence(int placeId, string bssid, string ssid)
+ {
+ IntPtr handle = IntPtr.Zero;
+ GeofenceError ret = (GeofenceError)Interop.Geofence.CreateBTFence(placeId, bssid, ssid, out handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence from Bluetooth Data for " + placeId);
+ }
+
+ return new Fence(handle);
+ }
+
+ /// <summary>
+ /// Overloaded Dispose API for destroying the fence Handle.
+ /// </summary>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!disposing)
+ {
+ if (Handle != IntPtr.Zero)
+ {
+ Interop.Geofence.Destroy(Handle);
+ Handle = IntPtr.Zero;
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Represents the Geofence list Item data.
+ /// </summary>
+ public class FenceData
+ {
+ internal FenceData(int fenceId, IntPtr handle, int index, int count)
+ {
+ GeofenceId = fenceId;
+ Fence = new Fence(handle);
+ Index = index;
+ Count = count;
+ }
+ /// <summary>
+ /// Geofence instance
+ /// </summary>
+ public Fence Fence
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The geofence id
+ /// </summary>
+ public int GeofenceId
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The index number of the fences in the list.
+ /// Index value starts from 1.
+ /// </summary>
+ public int Index
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The total number of fences that exists for the requester
+ /// </summary>
+ public int Count
+ {
+ get;
+ internal set;
+ }
+ };
+
+ /// <summary>
+ /// Represents the Place list Item data.
+ /// </summary>
+ public class PlaceData
+ {
+ internal PlaceData(int id, string name, int index, int count)
+ {
+ PlaceId = id;
+ Name = name;
+ Index = index;
+ Count = count;
+ }
+ /// <summary>
+ /// The current place id
+ /// </summary>
+ public int PlaceId
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The current place name
+ /// </summary>
+ public string Name
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The index number of the places in the list.
+ /// Index value starts from 1.
+ /// </summary>
+ public int Index
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The total number of places that exists for the requester
+ /// </summary>
+ public int Count
+ {
+ get;
+ internal set;
+ }
+ };
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ */
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Enumeration for geofence type
+ /// </summary>
+ public enum FenceType
+ {
+ /// <summary>
+ /// Geofence is specified by geospatial coordinate
+ /// </summary>
+ GeoPoint = 1,
+
+ /// <summary>
+ /// Geofence is specified by Wi-Fi access point
+ /// </summary>
+ Wifi,
+
+ /// <summary>
+ /// Geofence is specified by Bluetooth device
+ /// </summary>
+ Bluetooth
+ };
+
+ /// <summary>
+ /// Enumerations for the state of geofence manager.
+ /// </summary>
+ public enum GeofenceState
+ {
+ /// <summary>
+ /// Uncertain state of geofence
+ /// </summary>
+ Uncertain = 0,
+
+ /// <summary>
+ /// Geofence In state
+ /// </summary>
+ In,
+
+ /// <summary>
+ /// Geofence Out state
+ /// </summary>
+ Out
+ };
+
+ /// <summary>
+ /// Enumerations for geofence management events.
+ /// </summary>
+ public enum GeoFenceEventType
+ {
+ /// <summary>
+ ///Geofence is added
+ /// </summary>
+ FenceAdded = 0,
+
+ /// <summary>
+ /// Geofence is removed
+ /// </summary>
+ FenceRemoved,
+
+ /// <summary>
+ ///Geofencing is started
+ /// </summary>
+ FenceStarted,
+
+ /// <summary>
+ /// Geofencing is stopped
+ /// </summary>
+ FenceStopped,
+
+ /// <summary>
+ ///Place is added
+ /// </summary>
+ PlaceAdded = 0x10,
+
+ /// <summary>
+ /// Place is removed
+ /// </summary>
+ PlaceRemoved,
+
+ /// <summary>
+ ///Place is updated
+ /// </summary>
+ PlaceUpdated,
+
+ /// <summary>
+ /// Setting for geofencing is enabled
+ /// </summary>
+ SettingEnabled = 0x20,
+
+ /// <summary>
+ /// Setting for geofencing is disabled
+ /// </summary>
+ SettingDisabled
+ };
+
+ /// <summary>
+ /// Enumeration for the provider of proximity
+ /// </summary>
+ public enum ProximityProvider
+ {
+ /// <summary>
+ /// Proximity is specified by geospatial coordinate
+ /// </summary>
+ Location,
+
+ /// <summary>
+ /// Proximity is specified by Wi-Fi access point
+ /// </summary>
+ WiFi,
+
+ /// <summary>
+ /// Proximity is specified by Bluetooth device
+ /// </summary>
+ Bluetooth,
+
+ /// <summary>
+ ///Proximity is specified by Bluetooth low energy device
+ /// </summary>
+ BLE,
+
+ /// <summary>
+ /// Proximity is specified by Sensor
+ /// </summary>
+ Sensor
+ }
+
+ /// <summary>
+ /// Enumeration for the state of proximity.
+ /// </summary>
+ public enum ProximityState
+ {
+ /// <summary>
+ /// Uncertain state of proximity
+ /// </summary>
+ Uncertain,
+
+ /// <summary>
+ /// Far state of proximity
+ /// </summary>
+ Far,
+
+ /// <summary>
+ /// Far state of proximity
+ /// </summary>
+ Near,
+
+ /// <summary>
+ /// Immediate state of proximity
+ /// </summary>
+ Immediate
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Enum to give the type of error occured, if any.
+ /// </summary>
+ public enum GeofenceError
+ {
+ /// <summary>
+ /// Successful.
+ /// </summary>
+ None = Tizen.Internals.Errors.ErrorCode.None,
+
+ /// <summary>
+ /// Out of memory.
+ /// </summary>
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+
+ /// <summary>
+ /// Invalid parameter.
+ /// </summary>
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+
+ /// <summary>
+ /// Permission denied.
+ /// </summary>
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+
+ /// <summary>
+ /// Not Supported
+ /// </summary>
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
+
+ /// <summary>
+ ///Geofence Manager is not initialized
+ /// </summary>
+ NotInitialized = -0x02C00000 | 0x100 | 0x01,
+
+ /// <summary>
+ ///Invalid geofence ID
+ /// </summary>
+ InvalidID = -0x02C00000 | 0x100 | 0x02,
+
+ /// <summary>
+ /// Exception occurs
+ /// </summary>
+ Exception = -0x02C00000 | 0x100 | 0x03,
+
+ /// <summary>
+ ///Geofencing is already started
+ /// </summary>
+ AlreadyStarted = -0x02C00000 | 0x100 | 0x04,
+
+ /// <summary>
+ ///Too many geofence
+ /// </summary>
+ TooManyGeofence = -0x02C00000 | 0x100 | 0x05,
+
+ /// <summary>
+ ///Error in GPS, Wi-Fi, or BT
+ /// </summary>
+ IPC = -0x02C00000 | 0x100 | 0x06,
+
+ /// <summary>
+ ///DB error in the server side
+ /// </summary>
+ DBFailed = -0x02C00000 | 0x100 | 0x07,
+
+ /// <summary>
+ ///Access to specified place is denied
+ /// </summary>
+ PlaceAccessDenied = -0x02C00000 | 0x100 | 0x08,
+
+ /// <summary>
+ /// Access to specified geofence is denied
+ /// </summary>
+ GeofenceAccessDenied = -0x02C00000 | 0x100 | 0x09
+ };
+
+ internal class GeofenceErrorFactory
+ {
+ internal const string LogTag = "Tizen.Location.Geofence";
+
+ internal static Exception CreateException(GeofenceError err, string msg)
+ {
+ Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg);
+ Exception exp;
+ switch (err)
+ {
+ case GeofenceError.InvalidParameter:
+ {
+ exp = new ArgumentException(msg + " Invalid Parameters Provided");
+ break;
+ }
+
+ case GeofenceError.OutOfMemory:
+ {
+ exp = new OutOfMemoryException(msg + " Out Of Memory");
+ break;
+ }
+
+ case GeofenceError.NotInitialized:
+ {
+ exp = new InvalidOperationException(msg + " Not initializded");
+ break;
+ }
+
+ case GeofenceError.NotSupported:
+ {
+ exp = new NotSupportedException(msg + " Not supported");
+ break;
+ }
+
+ case GeofenceError.PermissionDenied:
+ // fall through
+ case GeofenceError.GeofenceAccessDenied:
+ //fall through
+ case GeofenceError.PlaceAccessDenied:
+ {
+ exp = new UnauthorizedAccessException(msg + " Permission Denied");
+ break;
+ }
+
+ case GeofenceError.DBFailed:
+ {
+ exp = new InvalidOperationException(msg + " DataBase Failed");
+ break;
+ }
+
+ default:
+ {
+ exp = new InvalidOperationException(msg);
+ break;
+ }
+ }
+
+ return exp;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Event arguments passed when Event is triggered to notify proximity state change.
+ /// </summary>
+ public class ProximityStateEventArgs: EventArgs
+ {
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <param name="id">The geofence id </param>
+ /// <param name="state">The proximity state</param>
+ /// <param name="provider">The proximity provider</param>
+ internal ProximityStateEventArgs(int id, ProximityState state, ProximityProvider provider)
+ {
+ GeofenceId = id;
+ State = state;
+ Provider = provider;
+ }
+
+ /// <summary>
+ /// The geofence id
+ /// </summary>
+ public int GeofenceId
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The proximity state
+ /// </summary>
+ public ProximityState State
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The proximity provider
+ /// </summary>
+ public ProximityProvider Provider
+ {
+ get;
+ }
+ };
+
+ /// <summary>
+ /// Event arguments passed when Event is triggered to notify Geofence state change.
+ /// </summary>
+ public class GeofenceStateEventArgs :EventArgs
+ {
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <param name="fenceId">The specified geofence id</param>
+ /// <param name="state">The geofence state</param>
+ internal GeofenceStateEventArgs(int fenceId, GeofenceState state)
+ {
+ GeofenceId = fenceId;
+ State = state;
+ }
+
+ /// <summary>
+ /// The specified geofence id
+ /// </summary>
+ public int GeofenceId
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The geofence state
+ /// </summary>
+ public GeofenceState State
+ {
+ get;
+ }
+ }
+
+ /// <summary>
+ /// Event arguments passed when Event occurs in geofence and place such as add, update, etc..
+ /// </summary>
+ public class GeofenceResponseEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <param name="placeId">The place id </param>
+ /// <param name="fenceId">The specified geofence id</param>
+ /// <param name="error">The error code for the particular action </param>
+ /// <param name="eventType">The result code for the particular place and geofence management</param>
+ internal GeofenceResponseEventArgs(int placeId, int fenceId, GeofenceError error, GeoFenceEventType eventType)
+ {
+ PlaceId = placeId;
+ FenceId = fenceId;
+ ErrorCode = error;
+ EventType = eventType;
+ }
+
+ /// <summary>
+ /// The place id
+ /// </summary>
+ public int PlaceId
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The specified geofence id
+ /// </summary>
+ public int FenceId
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The error code for the particular action
+ /// </summary>
+ public GeofenceError ErrorCode
+ {
+ get;
+ }
+
+ /// <summary>
+ /// The result code for the particular place and geofence management
+ /// </summary>
+ public GeoFenceEventType EventType
+ {
+ get;
+ }
+ };
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// This Geofence Manager API provides service related to geofence(geo-fence).
+ /// A geofence is a virtual perimeter for a real-world geographic area.
+ /// This API provides functions to set geofence with geopoint, MAC address of Wi-Fi and Bluetooth address.
+ /// And, notifications on events like changing in service status are provided.
+ /// <list type="ul" There are two kinds of places and fences:>
+ /// <item>Public places and fences that are created by MyPlace app can be used by all apps.</item>
+ /// <item>Private places and fences that are created by specified app can be used by the same app.</item>
+ /// </list>
+ /// <list >Notifications can be received about the following events:
+ /// <item>Zone in when a device enters a specific area</item>
+ /// <item>Zone out when a device exits a specific area</item>
+ /// <item>Results and errors for each event requested to geofence module</item>
+ /// </list>
+ /// </summary>
+ public class GeofenceManager : IDisposable
+ {
+ internal IntPtr Handle
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Creates a new geofence manager.
+ /// </summary>
+ /// <exception cref="OutOfMemoryException">Incase of OutOfMemory condition</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public GeofenceManager()
+ {
+ IntPtr handle;
+ GeofenceError ret = (GeofenceError) Interop.GeofenceManager.Create(out handle);
+ if(ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to create Geofence Manager instance");
+ }
+
+ Handle = handle;
+ }
+
+ ~GeofenceManager()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>
+ /// Checks whether the geofence manager is available or not.
+ /// </summary>
+ public static bool IsSupported
+ {
+ get
+ {
+ bool ret = false;
+ GeofenceError res= (GeofenceError)Interop.GeofenceManager.IsSupported(out ret);
+ if(res != GeofenceError.None)
+ {
+ Tizen.Log.Error(GeofenceErrorFactory.LogTag, "Failed to get IsSupported feature for Geofence manager");
+ }
+
+ return ret;
+ }
+ }
+
+ /// <summary>
+ /// Starts the geofencing service.
+ /// </summary>
+ /// <param name="geofenceId">The specified geofence id </param>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <remarks>
+ /// When the location service is enabled, the StateChanged event is invoked and the service starts
+ /// </remarks>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public void Start(int geofenceId)
+ {
+ GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Start(Handle, geofenceId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to start service for " + geofenceId);
+ }
+ }
+
+ /// <summary>
+ /// Stops the geofenceing service.
+ /// </summary>
+ /// <param name="geofenceId">The specified geofence id </param>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <remarks>
+ ///This function initiates the process of stopping the service.
+ ///You can stop and start the geofence manager as needed.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public void Stop(int geofenceId)
+ {
+ GeofenceError ret = (GeofenceError)Interop.GeofenceManager.Stop(Handle, geofenceId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to stop service for " + geofenceId);
+ }
+ }
+
+ private static readonly Interop.GeofenceManager.StateChangedCallback s_stateChangedCallback = (int fenceId, GeofenceState state, IntPtr data) =>
+ {
+ GeofenceStateEventArgs evenArgs = new GeofenceStateEventArgs(fenceId, state);
+ s_stateChanged?.Invoke(null, evenArgs);
+ return true;
+ };
+
+ private static event EventHandler<GeofenceStateEventArgs> s_stateChanged = null;
+
+ /// <summary>
+ /// Invokes when a device enters or exits the given geofence, If this event is registered.
+ /// </summary>
+ /// <remarks>
+ /// Call to Start() will invoke this event.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Incase of feature Not supported</exception>
+ public event EventHandler<GeofenceStateEventArgs> StateChanged
+ {
+ add
+ {
+ if(s_stateChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.GeofenceManager.SetStateChangedCB(Handle, s_stateChangedCallback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to register state change callback");
+ }
+ }
+ s_stateChanged += value;
+ }
+ remove
+ {
+ s_stateChanged -= value;
+ if (s_stateChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.GeofenceManager.UnsetStateChangedCB(Handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to unregister state change callback");
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Overloaded Dispose API for destroying the GeofenceManager Handle.
+ /// </summary>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (!disposing)
+ {
+ if (Handle != IntPtr.Zero)
+ {
+ Interop.GeofenceManager.Destroy(Handle);
+ Handle = IntPtr.Zero;
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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;
+
+namespace Tizen.Location.Geofence
+{
+ /// <summary>
+ /// Allows to create a virtual fence as Geofence using GeofenceManager instance.
+ /// User can manage all the geofence/place related data and events.
+ /// </summary>
+ public class VirtualPerimeter
+ {
+ private IntPtr Handle;
+
+ /// <summary>
+ /// Creates a VirtualPerimeter which can be used to create virtual fence.
+ /// </summary>
+ /// <param name="manager">GeofenceManager instance</param>
+ /// <exception cref="ArgumentException"> Incase of invlid parameter</exception>
+ public VirtualPerimeter(GeofenceManager manager)
+ {
+ if (manager == null)
+ {
+ throw GeofenceErrorFactory.CreateException(GeofenceError.InvalidParameter, "Invalid GeofenceManager instance");
+ }
+ else
+ {
+ Handle = manager.Handle;
+ }
+ }
+
+ /// <summary>
+ /// Creates a new place for geofencing service.
+ /// </summary>
+ /// <param name="name">A place name to be created </param>
+ /// <returns>The place id to be newly created on success</returns>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public int AddPlaceName(string name)
+ {
+ int placeId = 0;
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.AddPlace(Handle, name, out placeId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to add place to Geofence Manager for " + name);
+ }
+
+ return placeId;
+ }
+
+ /// <summary>
+ /// Updates the place name of a given place id.
+ /// </summary>
+ /// <param name="placeId">The specified place id</param>
+ /// <param name="name">A new place name of the place id </param>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public void UpdatePlace(int placeId, string name)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.UpdatePlace(Handle, placeId, name);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to update place to Geofence Manager for " + placeId);
+ }
+ }
+
+ /// <summary>
+ /// Removes the specific place for geofencing service.
+ /// </summary>
+ /// <param name="placeId">The specified place id</param>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public void RemovePlace(int placeId)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.RemovePlace(Handle, placeId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to remove place from Geofence Manager for " + placeId);
+ }
+ }
+
+ /// <summary>
+ /// Adds a geofence for a given geofence manager.
+ /// </summary>
+ /// <param name="fence">The Geofence instance to be added.</param>
+ /// <returns>The geofence id to be newly created on success</returns>
+ /// <remarks> The retun value will always be a number greater than zero </remarks>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public int AddGeofence(Fence fence)
+ {
+ int fenceId = 0;
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.AddFence(Handle, fence.Handle, out fenceId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to add fence to Geofence Manager ");
+ }
+
+ return fenceId;
+ }
+
+ /// <summary>
+ /// Removes a geofence with a given geofence id.
+ /// </summary>
+ /// <param name="fenceId">The specified geofence id </param>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public void RemoveGeofence(int fenceId)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.RemoveFence(Handle, fenceId);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to remove geofence from Geofence Manager for " + fenceId);
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of place.
+ /// </summary>
+ /// <param name="placeId"> The place id</param>
+ /// <returns>The name of the place </returns>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public string GetPlaceName(int placeId)
+ {
+ string name = "";
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetPlaceName(Handle, placeId, out name);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to get placenamefrom Geofence Manager for " + placeId);
+ }
+
+ return name;
+ }
+
+ /// <summary>
+ /// Retrieves a list of places registered in the specified geofence manager.
+ /// </summary>
+ /// <returns>list of places registered as PlaceData instance list.</returns>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public IEnumerable<PlaceData> GetPlaceDataList()
+ {
+ List<PlaceData> places = new List<PlaceData>();
+ Interop.VirtualPerimeter.ForEachPlaceListCallback placeCallback = (int placeId, string name, int index, int count, IntPtr data) =>
+ {
+ if (count != 0)
+ {
+ PlaceData place = new PlaceData(placeId, name, index, count);
+ places.Add(place);
+ }
+ return true;
+ };
+
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetForEachPlaceList(Handle, placeCallback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to get Places list from Geofence Manager ");
+ }
+
+ return places;
+ }
+
+ /// <summary>
+ /// Retrieves a list of fences registered in the specified geofence manager.
+ /// </summary>
+ /// <returns>list of FenceData instances registred for each Geofence</returns>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public IEnumerable<FenceData> GetFenceDataList()
+ {
+ List<FenceData> fences = new List<FenceData>();
+ Interop.VirtualPerimeter.ForEachFenceListCallback callback = (int fenceId, IntPtr handle, int index, int count, IntPtr data) =>
+ {
+ if (count != 0)
+ {
+ FenceData fence = new FenceData(fenceId, handle, index, count);
+ fences.Add(fence);
+ }
+ return true;
+ };
+
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetForEachFenceList(Handle, callback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to get Geofence list from Geofence Manager ");
+ }
+
+ return fences;
+ }
+
+ /// <summary>
+ /// Retrieves a list of fences registered in the specified place.
+ /// </summary>
+ /// <param name="placeId"> The place id </param>
+ /// <returns>list of FenceData instances registred for each Geofence for specified place</returns>
+ /// <privilege>http://tizen.org/privilege/location</privilege>
+ /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
+ /// <exception cref="InvalidOperationException">Incase of any System error</exception>
+ /// <exception cref="UnauthorizedAccessException">Incase of Pvivileges are not defined</exception>
+ /// <exception cref="NotSupportedException">Incase of Geofence is not supported</exception>
+ public IEnumerable<FenceData> GetGeoFenceDataListByPlaceId(int placeId)
+ {
+ List<FenceData> fences = new List<FenceData>();
+ Interop.VirtualPerimeter.ForEachFenceListCallback callback = (int fenceId, IntPtr handle, int index, int count, IntPtr data) =>
+ {
+ FenceData fence = new FenceData(fenceId, handle, index, count);
+ fences.Add(fence);
+ return true;
+ };
+
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.GetForEachPlaceFenceList(Handle, placeId, callback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to get Geofence list from Geofence Manager for " + placeId);
+ }
+
+ return fences;
+ }
+
+ private static readonly Interop.VirtualPerimeter.ProximityStateChangedCallback s_proximityChangedCallback = (int fenceId, ProximityState state, ProximityProvider provider, IntPtr data) =>
+ {
+ ProximityStateEventArgs evenArgs = new ProximityStateEventArgs(fenceId, state, provider);
+ s_proximityChanged?.Invoke(null, evenArgs);
+ return true;
+ };
+
+ private static event EventHandler<ProximityStateEventArgs> s_proximityChanged;
+
+ /// <summary>
+ /// Called when a proximity state of device is changed.
+ /// </summary>
+ /// <remarks>
+ /// Call to Start() will invoke this event.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Incase of feature Not supported</exception>
+ public event EventHandler<ProximityStateEventArgs> ProximityChanged
+ {
+ add
+ {
+ if (s_proximityChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.SetProximityStateCB(Handle, s_proximityChangedCallback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to register proximity change callback");
+ }
+ s_proximityChanged += value;
+ }
+ }
+ remove
+ {
+ s_proximityChanged -= value;
+ if (s_proximityChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.UnsetProximityStateCB(Handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to un register proximity change callback");
+ }
+ }
+ }
+ }
+
+ private static readonly Interop.VirtualPerimeter.GeofenceEventCallback s_geofenceEventCallback = (int placeId, int fenceId, GeofenceError error, GeoFenceEventType eventType, IntPtr data) =>
+ {
+ GeofenceResponseEventArgs evenArgs = new GeofenceResponseEventArgs(placeId, fenceId, error, eventType);
+ s_geofenceEventChanged?.Invoke(null, evenArgs);
+ return true;
+ };
+
+ private static event EventHandler<GeofenceResponseEventArgs> s_geofenceEventChanged;
+
+ /// <summary>
+ /// Called when the some event occurs in geofence and place such as add, update, etc..
+ /// The events of public geofence is also received if there are public geofences.
+ /// </summary>
+ /// <remarks>
+ /// Call to Start() will invoke this event.
+ /// The value of place_id or geofence_id is -1 when the place id or geofence id is not assigned.
+ /// </remarks>
+ /// <exception cref="NotSupportedException">Incase of feature Not supported</exception>
+ public event EventHandler<GeofenceResponseEventArgs> GeoFenceEventChanged
+ {
+ add
+ {
+ if (s_geofenceEventChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.SetGeofenceEventCB(Handle, s_geofenceEventCallback, IntPtr.Zero);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to register geofence event change callback");
+ }
+ s_geofenceEventChanged += value;
+ }
+ }
+ remove
+ {
+ s_geofenceEventChanged -= value;
+ if (s_geofenceEventChanged == null)
+ {
+ GeofenceError ret = (GeofenceError)Interop.VirtualPerimeter.UnsetGeofenceEventCB(Handle);
+ if (ret != GeofenceError.None)
+ {
+ throw GeofenceErrorFactory.CreateException(ret, "Failed to un register geofence event change callback");
+ }
+ }
+ }
+ }
+ }
+}