--- /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
+/*
+ * 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 AppCommon = "libcapi-appfw-app-common.so.0";
+ public const string AppCoreWatch = "libappcore-watch.so.1";
+ }
+}
\ No newline at end of file
--- /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.Applications;
+
+internal static partial class Interop
+{
+ internal static partial class Watch
+ {
+ internal enum AppEventType
+ {
+ LowMemory = 0,
+ LowBattery,
+ LanguageChanged,
+ DeviceOrientationChanged,
+ RegionFormatChanged,
+ SuspendedStateChanged
+ }
+
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ InvalidContext = -0x01100000 | 0x01,
+ NoSuchFile = Tizen.Internals.Errors.ErrorCode.NoSuchFile,
+ AlreadyRunning = Tizen.Internals.Errors.ErrorCode.AlreadyInProgress
+ }
+
+ internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
+
+ internal delegate bool WatchAppCreateCallback(int width, int height, IntPtr userData);
+
+ internal delegate void WatchAppPauseCallback(IntPtr userData);
+
+ internal delegate void WatchAppResumeCallback(IntPtr userData);
+
+ internal delegate void WatchAppTerminateCallback(IntPtr userData);
+
+ internal delegate void WatchAppControlCallback(IntPtr appControl, IntPtr userData);
+
+ internal delegate void WatchAppTimeTickCallback(IntPtr watchTime, IntPtr userData);
+
+ internal delegate void WatchAppAmbientTickCallback(IntPtr watchTime, IntPtr userData);
+
+ internal delegate void WatchAppAmbientChangedCallback(bool ambientMode, IntPtr userData);
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WatchAppLifecycleCallbacks
+ {
+ public WatchAppCreateCallback OnCreate;
+ public WatchAppControlCallback OnAppControl;
+ public WatchAppPauseCallback OnPause;
+ public WatchAppResumeCallback OnResume;
+ public WatchAppTerminateCallback OnTerminate;
+ public WatchAppTimeTickCallback OnTick;
+ public WatchAppAmbientTickCallback OnAmbientTick;
+ public WatchAppAmbientChangedCallback OnAmbientChanged;
+ }
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_main")]
+ internal static extern ErrorCode Main(int argc, string[] argv, ref WatchAppLifecycleCallbacks callback, IntPtr userData);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_exit")]
+ internal static extern void Exit();
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_add_event_handler")]
+ internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppEventType eventType, AppEventCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_remove_event_handler")]
+ internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
+
+ // tizen 3.0
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_time_tick_frequency")]
+ internal static extern ErrorCode SetTimeTickFrequency(int ticks, TimeTickResolution type);
+
+ // tizen 3.0
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_time_tick_frequency")]
+ internal static extern ErrorCode GetTimeTickFrequency(out int ticks, out TimeTickResolution type);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_set_ambient_tick_type")]
+ internal static extern ErrorCode SetAmbientTickType(AmbientTickType type);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_ambient_tick_type")]
+ internal static extern ErrorCode GetAmbientTickType(out AmbientTickType type);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_delete")]
+ internal static extern ErrorCode WatchTimeDelete(IntPtr watchTime);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_year")]
+ internal static extern ErrorCode WatchTimeGetYear(SafeWatchTimeHandle handle, out int year);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_month")]
+ internal static extern ErrorCode WatchTimeGetMonth(SafeWatchTimeHandle handle, out int month);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day")]
+ internal static extern ErrorCode WatchTimeGetDay(SafeWatchTimeHandle handle, out int day);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_day_of_week")]
+ internal static extern ErrorCode WatchTimeGetDayOfWeek(SafeWatchTimeHandle handle, out int day_of_week);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour")]
+ internal static extern ErrorCode WatchTimeGetHour(SafeWatchTimeHandle handle, out int hour);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_hour24")]
+ internal static extern ErrorCode WatchTimeGetHour24(SafeWatchTimeHandle handle, out int hour24);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_minute")]
+ internal static extern ErrorCode WatchTimeGetMinute(SafeWatchTimeHandle handle, out int minute);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_second")]
+ internal static extern ErrorCode WatchTimeGetSecond(SafeWatchTimeHandle handle, out int second);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_millisecond")]
+ internal static extern ErrorCode WatchTimeGetMillisecond(SafeWatchTimeHandle handle, out int millisecond);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_app_get_elm_win")]
+ internal static extern ErrorCode GetWin(out IntPtr win);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_utc_timestamp")]
+ internal static extern ErrorCode WatchTimeGetUtcTimestamp(SafeWatchTimeHandle handle, out long utc_timestamp);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_time_zone")]
+ internal static extern ErrorCode WatchTimeGetTimeZone(SafeWatchTimeHandle handle, out string time_zone_id);
+
+ [DllImport(Libraries.AppCoreWatch, EntryPoint = "watch_time_get_current_time")]
+ internal static extern ErrorCode WatchTimeGetCurrentTime(out SafeWatchTimeHandle handle);
+
+ // app common
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_memory_status")]
+ internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowMemoryStatus(IntPtr handle, out LowMemoryStatus status);
+
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_battery_status")]
+ internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLowBatteryStatus(IntPtr handle, out LowBatteryStatus status);
+
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
+ internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
+
+ [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
+ internal static extern Tizen.Internals.Errors.ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
+
+ }
+}
--- /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.Applications.WatchApplication")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Applications.WatchApplication")]
+[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("cc2aa967-232a-4a16-9b46-45f3fdb44e0d")]
+
+// 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
+/*
+ * 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;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Applications.CoreBackend
+{
+ internal class WatchCoreBackend : ICoreBackend
+ {
+ private const string LOGTAG = "Tizen.Applications.WatchApplication";
+
+ private Dictionary<EventType, object> _handlers = new Dictionary<EventType, object>();
+
+ private bool _disposedValue = false;
+
+ private Interop.Watch.AppEventCallback _lowMemoryCallback;
+ private Interop.Watch.AppEventCallback _lowBatteryCallback;
+ private Interop.Watch.AppEventCallback _localeChangedCallback;
+ private Interop.Watch.AppEventCallback _regionChnagedCallback;
+
+ private IntPtr _lowMemoryEventHandle = IntPtr.Zero;
+ private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
+ private IntPtr _localeChangedEventHandle = IntPtr.Zero;
+ private IntPtr _regionChnagedEventHandle = IntPtr.Zero;
+
+ private Interop.Watch.WatchAppLifecycleCallbacks _callbacks;
+
+ public WatchCoreBackend()
+ {
+ _lowMemoryCallback = new Interop.Watch.AppEventCallback(OnLowMemoryNative);
+ _lowBatteryCallback = new Interop.Watch.AppEventCallback(OnLowBatteryNative);
+ _localeChangedCallback = new Interop.Watch.AppEventCallback(OnLocaleChangedNative);
+ _regionChnagedCallback = new Interop.Watch.AppEventCallback(OnRegionChangedNative);
+
+ _callbacks.OnCreate = new Interop.Watch.WatchAppCreateCallback(OnCreateNative);
+ _callbacks.OnTerminate = new Interop.Watch.WatchAppTerminateCallback(OnTerminateNative);
+ _callbacks.OnResume = new Interop.Watch.WatchAppResumeCallback(OnResumeNative);
+ _callbacks.OnPause = new Interop.Watch.WatchAppPauseCallback(OnPauseNative);
+ _callbacks.OnAppControl = new Interop.Watch.WatchAppControlCallback(OnAppControlNative);
+
+ _callbacks.OnTick = new Interop.Watch.WatchAppTimeTickCallback(OnTimeTickNative);
+ _callbacks.OnAmbientTick = new Interop.Watch.WatchAppAmbientTickCallback(OnAmbientTickNative);
+ _callbacks.OnAmbientChanged = new Interop.Watch.WatchAppAmbientChangedCallback(OnAmbientChangedNative);
+ }
+
+ ~WatchCoreBackend()
+ {
+ Dispose(false);
+ }
+
+ public void AddEventHandler(EventType evType, Action handler)
+ {
+ _handlers.Add(evType, handler);
+ }
+
+ public void AddEventHandler<TEventArgs>(EventType evType, Action<TEventArgs> handler) where TEventArgs : EventArgs
+ {
+ _handlers.Add(evType, handler);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposedValue)
+ {
+ if (disposing)
+ {
+ // Release disposable objects
+ }
+
+ if (_lowMemoryEventHandle != IntPtr.Zero)
+ {
+ Interop.Watch.RemoveEventHandler(_lowMemoryEventHandle);
+ }
+ if (_lowBatteryEventHandle != IntPtr.Zero)
+ {
+ Interop.Watch.RemoveEventHandler(_lowBatteryEventHandle);
+ }
+ if (_localeChangedEventHandle != IntPtr.Zero)
+ {
+ Interop.Watch.RemoveEventHandler(_localeChangedEventHandle);
+ }
+ if (_regionChnagedEventHandle != IntPtr.Zero)
+ {
+ Interop.Watch.RemoveEventHandler(_regionChnagedEventHandle);
+ }
+
+ _disposedValue = true;
+ }
+ }
+
+ public void Exit()
+ {
+ Interop.Watch.Exit();
+ }
+
+ public void Run(string[] args)
+ {
+ Interop.Watch.ErrorCode err = Interop.Watch.ErrorCode.None;
+
+ err = Interop.Watch.AddEventHandler(out _lowMemoryEventHandle, Interop.Watch.AppEventType.LowMemory, _lowMemoryCallback, IntPtr.Zero);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to add event handler for LowMemory event, Err = " + err);
+ }
+
+ err = Interop.Watch.AddEventHandler(out _lowBatteryEventHandle, Interop.Watch.AppEventType.LowBattery, _lowBatteryCallback, IntPtr.Zero);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to add event handler for LowBattery event, Err = " + err);
+ }
+
+ err = Interop.Watch.AddEventHandler(out _localeChangedEventHandle, Interop.Watch.AppEventType.LanguageChanged, _localeChangedCallback, IntPtr.Zero);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to add event handler for LocaleChanged event, Err = " + err);
+ }
+
+ err = Interop.Watch.AddEventHandler(out _regionChnagedEventHandle, Interop.Watch.AppEventType.RegionFormatChanged, _regionChnagedCallback, IntPtr.Zero);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to add event handler for RegionFormatChanged event, Err = " + err);
+ }
+
+ err = Interop.Watch.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to run the Watch application, Err = " + err);
+ }
+ }
+
+ private void OnLowMemoryNative(IntPtr infoHandle, IntPtr data)
+ {
+ LowMemoryStatus status = LowMemoryStatus.None;
+ ErrorCode err = Interop.Watch.AppEventGetLowMemoryStatus(infoHandle, out status);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get memory status, Err = " + err);
+ }
+ if (_handlers.ContainsKey(WatchEventType.LowMemory))
+ {
+ var handler = _handlers[WatchEventType.LowMemory] as Action<LowMemoryEventArgs>;
+ handler?.Invoke(new LowMemoryEventArgs(status));
+ }
+ }
+
+ private void OnLowBatteryNative(IntPtr infoHandle, IntPtr data)
+ {
+ LowBatteryStatus status = LowBatteryStatus.None;
+ ErrorCode err = Interop.Watch.AppEventGetLowBatteryStatus(infoHandle, out status);
+ if (err != Tizen.Internals.Errors.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get battery status, Err = " + err);
+ }
+ if (_handlers.ContainsKey(WatchEventType.LowBattery))
+ {
+ var handler = _handlers[WatchEventType.LowBattery] as Action<LowBatteryEventArgs>;
+ handler?.Invoke(new LowBatteryEventArgs(status));
+ }
+ }
+ private void OnLocaleChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ string lang;
+ ErrorCode err = Interop.Watch.AppEventGetLanguage(infoHandle, out lang);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get changed language. Err = " + err);
+ }
+ if (_handlers.ContainsKey(WatchEventType.LocaleChanged))
+ {
+ var handler = _handlers[WatchEventType.LocaleChanged] as Action<LocaleChangedEventArgs>;
+ handler?.Invoke(new LocaleChangedEventArgs(lang));
+ }
+ }
+ private void OnRegionChangedNative(IntPtr infoHandle, IntPtr data)
+ {
+ string region;
+ ErrorCode err = Interop.Watch.AppEventGetRegionFormat(infoHandle, out region);
+ if (err != ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get changed region format. Err = " + err);
+ }
+ if (_handlers.ContainsKey(WatchEventType.RegionFormatChanged))
+ {
+ var handler = _handlers[WatchEventType.RegionFormatChanged] as Action<RegionFormatChangedEventArgs>;
+ handler?.Invoke(new RegionFormatChangedEventArgs(region));
+ }
+ }
+ private bool OnCreateNative(int width, int height, IntPtr data)
+ {
+ if (_handlers.ContainsKey(WatchEventType.PreCreated))
+ {
+ var handler = _handlers[WatchEventType.PreCreated] as Action;
+ handler?.Invoke();
+ }
+
+ if (_handlers.ContainsKey(WatchEventType.Created))
+ {
+ var handler = _handlers[WatchEventType.Created] as Action;
+ handler?.Invoke();
+ }
+ return true;
+ }
+
+ private void OnTerminateNative(IntPtr data)
+ {
+ if (_handlers.ContainsKey(WatchEventType.Terminated))
+ {
+ var handler = _handlers[WatchEventType.Terminated] as Action;
+ handler?.Invoke();
+ }
+ }
+
+ private void OnAppControlNative(IntPtr appControlHandle, IntPtr data)
+ {
+ if (_handlers.ContainsKey(WatchEventType.AppControlReceived))
+ {
+ SafeAppControlHandle safeHandle = new SafeAppControlHandle(appControlHandle, false);
+
+ var handler = _handlers[WatchEventType.AppControlReceived] as Action<AppControlReceivedEventArgs>;
+
+ handler?.Invoke(new AppControlReceivedEventArgs(new ReceivedAppControl(safeHandle)));
+ }
+ }
+
+ private void OnResumeNative(IntPtr data)
+ {
+ if (_handlers.ContainsKey(WatchEventType.Resumed))
+ {
+ var handler = _handlers[WatchEventType.Resumed] as Action;
+ handler?.Invoke();
+ }
+ }
+
+ private void OnPauseNative(IntPtr data)
+ {
+ if (_handlers.ContainsKey(WatchEventType.Paused))
+ {
+ var handler = _handlers[WatchEventType.Paused] as Action;
+ handler?.Invoke();
+ }
+ }
+
+ private void OnTimeTickNative(IntPtr watchTime, IntPtr userData)
+ {
+ if (_handlers.ContainsKey(WatchEventType.TimeTick))
+ {
+ var handler = _handlers[WatchEventType.TimeTick] as Action<TimeEventArgs>;
+ handler?.Invoke(new TimeEventArgs()
+ {
+ Time = new WatchTime(new SafeWatchTimeHandle(watchTime, false))
+ });
+ }
+ }
+
+ private void OnAmbientTickNative(IntPtr watchTime, IntPtr userData)
+ {
+ if (_handlers.ContainsKey(WatchEventType.AmbientTick))
+ {
+ var handler = _handlers[WatchEventType.AmbientTick] as Action<TimeEventArgs>;
+ handler?.Invoke(new TimeEventArgs()
+ {
+ Time = new WatchTime(new SafeWatchTimeHandle(watchTime, false))
+ });
+ }
+ }
+
+ private void OnAmbientChangedNative(bool ambientMode, IntPtr userData)
+ {
+ if (_handlers.ContainsKey(WatchEventType.AmbientChanged))
+ {
+ var handler = _handlers[WatchEventType.AmbientChanged] as Action<AmbientEventArgs>;
+ handler?.Invoke(new AmbientEventArgs()
+ {
+ Enabled = ambientMode
+ });
+ }
+ }
+ }
+}
--- /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;
+using Tizen.Applications.CoreBackend;
+
+namespace Tizen.Applications.CoreBackend
+{
+ /// <summary>
+ /// Class that represents the type of event for backends. This class can be converted from string type.
+ /// </summary>
+ public class WatchEventType : EventType
+ {
+ /// <summary>
+ /// Pre-defined event type. "Created"
+ /// </summary>
+ public static readonly WatchEventType TimeTick = "TimeTick";
+
+ /// <summary>
+ /// Pre-defined event type. "AmbientTick"
+ /// </summary>
+ public static readonly WatchEventType AmbientTick = "AmbientTick";
+
+ /// <summary>
+ /// Pre-defined event type. "AmbientChanged"
+ /// </summary>
+ public static readonly WatchEventType AmbientChanged = "AmbientChanged";
+
+ /// <summary>
+ /// Initializes the WatchEventType class.
+ /// </summary>
+ /// <param name="name">The name of watch event type.</param>
+ public WatchEventType(string name) : base(name)
+ {
+ }
+
+ /// <summary>
+ /// Converts a string to WatchEventType instance.
+ /// </summary>
+ public static implicit operator WatchEventType(string value)
+ {
+ return new WatchEventType(value);
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProjectGuid>{07A0D110-3092-4A09-BF85-95555C7E7DFF}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>\r
+ </RootNamespace>\r
+ <AssemblyName>Tizen.Applications.WatchApplication</AssemblyName>\r
+ <FileAlignment>512</FileAlignment>\r
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\Net45\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+ <DocumentationFile>bin\Debug\Tizen.Applications.WatchApplication.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\Net45\</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.WatchApplication.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <ItemGroup>\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="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Interop\Interop.Watch.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Tizen.Applications\AmbientEventArgs.cs" />\r
+ <Compile Include="Tizen.Applications\AmbientTickType.cs" />\r
+ <Compile Include="Tizen.Applications\SafeWatchTimeHandle.cs" />\r
+ <Compile Include="Tizen.Applications\TimeEventArgs.cs" />\r
+ <Compile Include="Tizen.Applications\TimeTickResolution.cs" />\r
+ <Compile Include="Tizen.Applications\WatchApplication.cs" />\r
+ <Compile Include="Tizen.Applications\WatchTime.cs" />\r
+ <Compile Include="Tizen.Applications\WatchWindow.cs" />\r
+ <Compile Include="Tizen.Applications.CoreBackend\WatchCoreBackend.cs" />\r
+ <Compile Include="Tizen.Applications.CoreBackend\WatchEventType.cs" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Applications.WatchApplication.Net45.project.json" />\r
+ <None Include="Tizen.Applications.WatchApplication.nuspec" />\r
+ <None Include="Tizen.Applications.WatchApplication.snk" />\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.\r
+ Other similar extension points exist, see Microsoft.Common.targets.\r
+ <Target Name="BeforeBuild">\r
+ </Target>\r
+ <Target Name="AfterBuild">\r
+ </Target>\r
+ -->\r
+</Project>
\ No newline at end of file
--- /dev/null
+{
+ "dependencies": {
+ "Tizen": "1.0.2",
+ "Tizen.Applications.Common": "1.2.0",
+ "ElmSharp": "1.1.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>{CC2AA967-232A-4A16-9B46-45F3FDB44E0D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Applications.WatchApplication</RootNamespace>
+ <AssemblyName>Tizen.Applications.WatchApplication</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <DefaultLanguage>en-US</DefaultLanguage>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <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.Applications.WatchApplication.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <None Include="Tizen.Applications.WatchApplication.project.json" />
+ <None Include="Tizen.Applications.WatchApplication.nuspec" />
+ <None Include="Tizen.Applications.WatchApplication.snk" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Watch.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Applications.CoreBackend\WatchCoreBackend.cs" />
+ <Compile Include="Tizen.Applications.CoreBackend\WatchEventType.cs" />
+ <Compile Include="Tizen.Applications\AmbientEventArgs.cs" />
+ <Compile Include="Tizen.Applications\AmbientTickType.cs" />
+ <Compile Include="Tizen.Applications\SafeWatchTimeHandle.cs" />
+ <Compile Include="Tizen.Applications\TimeEventArgs.cs" />
+ <Compile Include="Tizen.Applications\TimeTickResolution.cs" />
+ <Compile Include="Tizen.Applications\WatchApplication.cs" />
+ <Compile Include="Tizen.Applications\WatchTime.cs" />
+ <Compile Include="Tizen.Applications\WatchWindow.cs" />
+ </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>
+ -->
+ <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>
+</Project>
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Applications.WatchApplication</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Watch Application API for Tizen.Net</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.2" />
+ <dependency id="Tizen.Applications.Common" version="1.2.0" />
+ <dependency id="ElmSharp" version="1.0.14" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Applications.WatchApplication.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Applications.WatchApplication.dll" target="lib/net45" />
+ </files>
+</package>
--- /dev/null
+{\r
+ "dependencies": {\r
+ "ElmSharp": "1.1.0-*",\r
+ "NETStandard.Library": "1.6.0",\r
+ "Tizen": "1.0.2",\r
+ "Tizen.Applications.Common": "1.2.0"\r
+ },\r
+ "frameworks": {\r
+ "netstandard1.3": {}\r
+ }\r
+}\r
--- /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 ElmSharp;
+using System;
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// Arguments for the event that reaised when the device enters or exits the ambient mode.
+ /// </summary>
+ public class AmbientEventArgs : EventArgs
+ {
+ /// <summary>
+ /// The received Ambient mode
+ /// </summary>
+ public bool Enabled { get; internal set; }
+
+ internal AmbientEventArgs()
+ {
+ }
+ }
+}
\ No newline at end of file
--- /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.Applications
+{
+ /// <summary>
+ /// Enumeration for Ambient tick type.
+ /// </summary>
+ public enum AmbientTickType
+ {
+ /// <summary>
+ /// No peridoic ambient tick.
+ /// </summary>
+ NoTick,
+ /// <summary>
+ /// Every minute.
+ /// </summary>
+ EveryMinute,
+ /// <summary>
+ /// Every 5 minutes.
+ /// </summary>
+ EveryFiveMinutes,
+ /// <summary>
+ /// Every 15 minutes.
+ /// </summary>
+ EveryFiftenMinutes,
+ /// <summary>
+ /// Every 30 minutes.
+ /// </summary>
+ EveryThirtyMinutes,
+ /// <summary>
+ /// Every hour.
+ /// </summary>
+ EveryHour,
+ /// <summary>
+ /// Every 3 hours.
+ /// </summary>
+ EveryThreeHours,
+ /// <summary>
+ /// Every 6 hours.
+ /// </summary>
+ EverySixHours,
+ /// <summary>
+ /// Every 12 hours.
+ /// </summary>
+ EveryTwelveHours,
+ /// <summary>
+ /// Every day.
+ /// </summary>
+ EveryDay
+ }
+}
--- /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;
+
+namespace Tizen.Applications
+{
+ internal sealed class SafeWatchTimeHandle : SafeHandle
+ {
+ internal SafeWatchTimeHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ internal SafeWatchTimeHandle(IntPtr existingHandle, bool ownHandle) : base(IntPtr.Zero, ownHandle)
+ {
+ SetHandle(existingHandle);
+ }
+
+ public override bool IsInvalid
+ {
+ get { return this.handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle()
+ {
+ Interop.Watch.WatchTimeDelete(this.handle);
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+}
\ No newline at end of file
--- /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.Applications
+{
+ /// <summary>
+ /// Arguments for the event that reaised when the time tick comes.
+ /// </summary>
+ public class TimeEventArgs : EventArgs
+ {
+ /// <summary>
+ /// The received WatchTime.
+ /// </summary>
+ public WatchTime Time { get; internal set; }
+
+ internal TimeEventArgs()
+ {
+ }
+ }
+}
--- /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.Applications
+{
+ /// <summary>
+ /// Enumeration for Time tick resolution.
+ /// </summary>
+ public enum TimeTickResolution
+ {
+ /// <summary>
+ /// 1 ~ 60 ticks per second.
+ /// </summary>
+ TimeTicksPerSecond,
+ /// <summary>
+ /// 1 ~ 60 ticks per minute.
+ /// </summary>
+ TimeTicksPerMinute,
+ /// <summary>
+ /// 1 ~ 60 ticks per hour.
+ /// </summary>
+ TimeTicksPerHour
+ }
+}
--- /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.Applications.CoreBackend;
+using ElmSharp;
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// The class that represents a Tizen watch application.
+ /// </summary>
+ public class WatchApplication : CoreApplication
+ {
+ /// <summary>
+ /// Initialize the WatchApplication class
+ /// </summary>
+ /// <remarks>
+ /// Default backend for Watch application will be used.
+ /// </remarks>
+ public WatchApplication() : base(new WatchCoreBackend())
+ {
+ }
+
+ /// <summary>
+ /// Initialize the WatchApplication class
+ /// </summary>
+ /// <remarks>
+ /// If want to change the backend , use this constructor
+ /// </remarks>
+ /// <param name="backend">The backend instance implementing ICoreBackend interface.</param>
+ public WatchApplication(ICoreBackend backend) : base(backend)
+ {
+ }
+
+ /// <summary>
+ /// Instance for the window
+ /// </summary>
+ protected Widget Window;
+
+ /// <summary>
+ /// Occurs whenever the application is resumed.
+ /// </summary>
+ public event EventHandler Resumed;
+
+ /// <summary>
+ /// Occurs whenever the application is paused.
+ /// </summary>
+ public event EventHandler Paused;
+
+ /// <summary>
+ /// Occurs whenever the time tick comes.
+ /// </summary>
+ public event EventHandler<TimeEventArgs> TimeTick;
+
+ /// <summary>
+ /// Occurs whenever the time tick comes in ambient mode.
+ /// </summary>
+ public event EventHandler<TimeEventArgs> AmbientTick;
+
+ /// <summary>
+ /// Occurs when the ambient mode is changed.
+ /// </summary>
+ public event EventHandler<AmbientEventArgs> AmbientChanged;
+
+ /// <summary>
+ /// Runs the UI applications' main loop.
+ /// </summary>
+ /// <param name="args">Arguments from commandline.</param>
+ public override void Run(string[] args)
+ {
+ Backend.AddEventHandler(EventType.Resumed, OnResume);
+ Backend.AddEventHandler(EventType.Paused, OnPause);
+
+ Backend.AddEventHandler<TimeEventArgs>(WatchEventType.TimeTick, OnTick);
+ Backend.AddEventHandler<TimeEventArgs>(WatchEventType.AmbientTick, OnAmbientTick);
+ Backend.AddEventHandler<AmbientEventArgs>(WatchEventType.AmbientChanged, OnAmbientChanged);
+
+ base.Run(args);
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the application is launched.
+ /// If base.OnCreate() is not called, the event 'Created' will not be emitted.
+ /// </summary>
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ IntPtr win;
+
+ Interop.Watch.GetWin(out win);
+ Window = new WatchWindow(win);
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the application is resumed.
+ /// If base.OnResume() is not called, the event 'Resumed' will not be emitted.
+ /// </summary>
+ protected virtual void OnResume()
+ {
+ Resumed?.Invoke(this, EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the application is paused.
+ /// If base.OnPause() is not called, the event 'Paused' will not be emitted.
+ /// </summary>
+ protected virtual void OnPause()
+ {
+ Paused?.Invoke(this, EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the time tick event comes.
+ /// If base.OnTick() is not called, the event 'TimeTick' will not be emitted.
+ /// </summary>
+ /// <param name="time">The received TimeEventArgs to get time information.</param>
+ protected virtual void OnTick(TimeEventArgs time)
+ {
+ TimeTick?.Invoke(this, time);
+ }\r
+\r
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the time tick event comes in ambient mode.
+ /// If base.OnAmbientTick() is not called, the event 'AmbientTick' will not be emitted.
+ /// </summary>
+ /// <param name="time">The received TimeEventArgs to get time information.</param>
+ /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
+ protected virtual void OnAmbientTick(TimeEventArgs time)
+ {
+ AmbientTick?.Invoke(this, time);
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the ambient mode is changed.
+ /// If base.OnAmbientChanged() is not called, the event 'AmbientChanged' will not be emitted.
+ /// </summary>
+ /// <param name="mode">The received AmbientEventArgs</param>
+ protected virtual void OnAmbientChanged(AmbientEventArgs mode)
+ {
+ AmbientChanged?.Invoke(this, mode);
+ }
+
+ /// <summary>
+ /// Gets the current time
+ /// </summary>
+ /// <returns>WatchTime</returns>
+ /// <exception cref="InvalidOperationException">Thrown when failed to get current time because of invalid parameter.</exception>
+ /// <exception cref="OutOfMemoryException">Thrown when failed to get current time because memory is not enough.</exception>
+ /// <example>
+ /// <code>
+ /// class MyApp : WatchApplication
+ /// {
+ /// ...
+ /// public void TestMethod()
+ /// {
+ /// WatchTime wt;
+ /// try
+ /// {
+ /// wt = GetCurrentTime();
+ /// }
+ /// catch
+ /// {
+ /// }
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ protected WatchTime GetCurrentTime()
+ {
+ SafeWatchTimeHandle handle;
+
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetCurrentTime(out handle);
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ if (err == Interop.Watch.ErrorCode.InvalidParameter)
+ throw new InvalidOperationException("Failed to get current time. err : " + err);
+ else if (err == Interop.Watch.ErrorCode.OutOfMemory)
+ throw new OutOfMemoryException("Failed to get current time. err : " + err);
+ }
+ return new WatchTime(handle);
+ }
+
+ /// <summary>
+ /// Gets the type of periodic ambient tick.
+ /// </summary>
+ /// <returns>AmbientTickType</returns>
+ /// <exception cref="InvalidOperationException">Thrown when failed to get ambient tick type.</exception>
+ /// <example>
+ /// <code>
+ /// class MyApp : WatchApplication
+ /// {
+ /// ...
+ /// public void TestMethod()
+ /// {
+ /// AmbientTickType atType;
+ /// try
+ /// {
+ /// atType = GetAmbientTickType();
+ /// }
+ /// catch
+ /// {
+ /// }
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ protected AmbientTickType GetAmbientTickType()
+ {
+ AmbientTickType ambientTickType;
+
+ Interop.Watch.ErrorCode err = Interop.Watch.GetAmbientTickType(out ambientTickType);
+
+ if(err != Interop.Watch.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to get ambient tick type. err : " + err);
+ }
+
+ return ambientTickType;
+ }
+
+ /// <summary>
+ /// Sets the type of periodic ambient tick.
+ /// OnAmbientTick will be called following settings.
+ /// If SetAmbientTickType is not called, OnAmbientTick will be called every minute.
+ /// </summary>
+ /// <param name="ambientTickType">the type of ambient tick</param>
+ /// <exception cref="InvalidOperationException">Thrown when failed to set ambient tick type.</exception>
+ /// <example>
+ /// <code>
+ /// class MyApp : WatchApplication
+ /// {
+ /// ...
+ /// public void TestMethod()
+ /// {
+ /// try
+ /// {
+ /// SetAmbientTickType(AmbientTickType.EveryMinute);
+ /// }
+ /// catch
+ /// {
+ /// }
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ protected void SetAmbientTickType(AmbientTickType ambientTickType)
+ {
+ Interop.Watch.ErrorCode err = Interop.Watch.SetAmbientTickType(ambientTickType);
+
+ if(err != Interop.Watch.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to set ambient tick type. err : " + err);
+ }
+ }
+
+ /// <summary>
+ /// Sets the frequency of time tick.
+ /// OnTick will be called following settings.
+ /// If SetTimeTickFrequency is not called, OnTick will be called every second.
+ /// </summary>
+ /// <param name="ticks">Ticks the number of ticks per given resolution type</param>
+ /// <param name="type">Type of the resolution type</param>
+ /// <exception cref="InvalidOperationException">Thrown when failed to set time tick frequency.</exception>
+ /// <example>
+ /// <code>
+ /// class MyApp : WatchApplication
+ /// {
+ /// ...
+ /// public void TestMethod()
+ /// {
+ /// try
+ /// {
+ /// SetTimeTickFrequency(1, TimeTickResolution.TimeTicksPerMinute);
+ /// }
+ /// catch
+ /// {
+ /// }
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ protected void SetTimeTickFrequency(int ticks, TimeTickResolution type)
+ {
+ Interop.Watch.ErrorCode err = Interop.Watch.SetTimeTickFrequency(ticks, type);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to set time tick frequency. err : " + err);
+ }
+ }
+
+ /// <summary>
+ /// Gets the frequency fo time tick.
+ /// </summary>
+ /// <param name="ticks">Ticks the number of ticks per given resolution type</param>
+ /// <param name="type">Type of the resolution type</param>
+ /// <exception cref="InvalidOperationException">Thrown when failed to get time tick frequency.</exception>
+ /// <example>
+ /// <code>
+ /// class MyApp : WatchApplication
+ /// {
+ /// ...
+ /// public void TestMethod()
+ /// {
+ /// int tick;
+ /// TimeTickResolution tType;
+ /// try
+ /// {
+ /// GetTimeTickFrequency(out tick, out tType);
+ /// }
+ /// catch
+ /// {
+ /// }
+ /// }
+ /// }
+ /// </code>
+ /// </example>
+ protected void GetTimeTickFrequency(out int ticks, out TimeTickResolution type)
+ {
+ Interop.Watch.ErrorCode err = Interop.Watch.GetTimeTickFrequency(out ticks, out type);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ throw new InvalidOperationException("Failed to get time tick frequency. err : " + err);
+ }
+ }
+ }
+}
--- /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.Applications
+{
+ /// <summary>
+ /// The information of Watch Time
+ /// </summary>
+ public class WatchTime
+ {
+ private readonly SafeWatchTimeHandle _handle;
+ private static readonly string LOGTAG = "Tizen.Applications.WatchApplication";
+
+ internal WatchTime(SafeWatchTimeHandle handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// The information of year
+ /// </summary>
+ public int Year
+ {
+ get
+ {
+ int year;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetYear(_handle, out year);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Year err : " + err);
+ }
+ return year;
+ }
+ }
+
+ /// <summary>
+ /// The information fo month
+ /// </summary>
+ public int Month
+ {
+ get
+ {
+ int month;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMonth(_handle, out month);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Month err : " + err);
+ }
+ return month;
+ }
+ }
+
+ /// <summary>
+ /// The information of day
+ /// </summary>
+ public int Day
+ {
+ get
+ {
+ int day;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDay(_handle, out day);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Day err : " + err);
+ }
+ return day;
+ }
+ }
+
+ /// <summary>
+ /// The information of day of week
+ /// </summary>
+ public int DayOfWeek
+ {
+ get
+ {
+ int dayOfWeek;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetDayOfWeek(_handle, out dayOfWeek);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Second err : " + err);
+ }
+ return dayOfWeek;
+ }
+ }
+
+ /// <summary>
+ /// The information of hour
+ /// </summary>
+ public int Hour
+ {
+ get
+ {
+ int hour;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour(_handle, out hour);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Hour err : " + err);
+ }
+ return hour;
+ }
+ }
+
+ /// <summary>
+ /// The information of hour for 24 hour form
+ /// </summary>
+ public int Hour24
+ {
+ get
+ {
+ int hour24;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetHour24(_handle, out hour24);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Hour24 err : " + err);
+ }
+ return hour24;
+ }
+ }
+
+ /// <summary>
+ /// The information of Minute
+ /// </summary>
+ public int Minute
+ {
+ get
+ {
+ int minute;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMinute(_handle, out minute);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Minute err : " + err);
+ }
+ return minute;
+ }
+ }
+
+ /// <summary>
+ /// The information of second
+ /// </summary>
+ public int Second
+ {
+ get
+ {
+ int second;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetSecond(_handle, out second);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Second err : " + err);
+ }
+ return second;
+ }
+ }
+
+ /// <summary>
+ /// The information of millisecond
+ /// </summary>
+ public int Millisecond
+ {
+ get
+ {
+ int ms;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetMillisecond(_handle, out ms);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Second err : " + err);
+ }
+ return ms;
+ }
+ }
+
+ /// <summary>
+ /// The information of timezone
+ /// </summary>
+ public string TimeZone
+ {
+ get
+ {
+ string zone;
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetTimeZone(_handle, out zone);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get Second err : " + err);
+ }
+ return zone;
+ }
+ }
+
+ /// <summary>
+ /// The information of UTC time stamp
+ /// </summary>
+ public DateTime UtcTimestamp
+ {
+ get
+ {
+ long ts = 0;
+
+ Interop.Watch.ErrorCode err = Interop.Watch.WatchTimeGetUtcTimestamp(_handle, out ts);
+
+ if (err != Interop.Watch.ErrorCode.None)
+ {
+ Log.Error(LOGTAG, "Failed to get UtcTimestamp err : " + err);
+ }
+
+ return (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(ts).ToLocalTime();
+ }
+ }
+ }
+}
--- /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 ElmSharp;
+using System;
+
+namespace Tizen.Applications
+{
+ internal class WatchWindow : Widget
+ {
+ private IntPtr _handle;
+
+ internal WatchWindow(IntPtr handle) : base()
+ {
+ _handle = handle;
+ Realize(null);
+ }
+
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ return _handle;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: csapi-watch-application
+Summary: Tizen Watch Application 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
+ExcludeArch: aarch64
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requires
+BuildRequires: csapi-tizen-nuget
+BuildRequires: csapi-application-common-nuget
+BuildRequires: elm-sharp-nuget
+
+%define Assemblies Tizen.Applications.WatchApplication
+
+%description
+%{summary}
+
+%dotnet_import_sub_packages
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%build
+for ASM in %{Assemblies}; do
+%dotnet_build $ASM
+%dotnet_pack $ASM/$ASM.nuspec %{version}
+done
+
+%install
+for ASM in %{Assemblies}; do
+%dotnet_install $ASM
+done
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_files}