--- /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
+Name: csapi-uix-voicecontrol
+Summary: Tizen Uix Voice Control API for C#
+Version: 1.0.2
+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
+
+%define Assemblies Tizen.Uix.VoiceControl
+
+%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}
--- /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.
+*/
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// Partial Libraries Class
+ /// </summary>
+ internal static partial class Libraries
+ {
+ internal const string VoiceControl = "libvc.so";
+ }
+}
--- /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.Uix.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// VoiceControl Interop Class
+ /// </summary>
+ internal static class VoiceControl
+ {
+ internal static string LogTag = "Tizen.Uix.VoiceControl";
+
+ private const int ErrorVoiceControl = -0x02F50000;
+
+ internal enum ErrorCode
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None, /**< Successful */
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /**< Out of Memory */
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError, /**< I/O error */
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /**< Invalid parameter */
+ TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut, /**< No answer from service */
+ RecorderBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy, /**< Busy recorder */
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /**< Permission denied */
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /**< VC NOT supported */
+ InvalidState = ErrorVoiceControl | 0x011, /**< Invalid state */
+ InvalidLanguage = ErrorVoiceControl | 0x012, /**< Invalid language */
+ EngineNotFound = ErrorVoiceControl | 0x013, /**< No available engine */
+ OperationFailed = ErrorVoiceControl | 0x014, /**< Operation failed */
+ OperationRejected = ErrorVoiceControl | 0x015, /**< Operation rejected */
+ IterationEnd = ErrorVoiceControl | 0x016, /**< List reached end */
+ Empty = ErrorVoiceControl | 0x017, /**< List empty */
+ ServiceReset = ErrorVoiceControl | 0x018, /**< Service daemon reset (Since 3.0) */
+ InProgressToReady = ErrorVoiceControl | 0x019, /**< In progress to ready (Since 3.0) */
+ InProgressToRecording = ErrorVoiceControl | 0x020, /**< In progress to recording (Since 3.0) */
+ InProgressToProcessing = ErrorVoiceControl | 0x021 /**< In progress to processing (Since 3.0) */
+ };
+
+ internal enum VoiceCommandType
+ {
+ Foreground = 1, /* Foreground command type. */
+ BackGround = 2 /* background command type. */
+ };
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_initialize")]
+ internal static extern ErrorCode VcInitialize();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_deinitialize")]
+ internal static extern ErrorCode VcDeinitialize();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_prepare")]
+ internal static extern ErrorCode VcPrepare();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unprepare")]
+ internal static extern ErrorCode VcUnprepare();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_foreach_supported_languages")]
+ internal static extern ErrorCode VcForeachSupportedLanguages(VcSupportedLanguageCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_current_language")]
+ internal static extern ErrorCode VcGetCurrentLanguage(out string language);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_state")]
+ internal static extern ErrorCode VcGetState(out State state);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_service_state")]
+ internal static extern ErrorCode VcGetServiceState(out ServiceState state);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_system_command_list")]
+ internal static extern ErrorCode VcGetSystemCommandList(out IntPtr vc_sys_cmd_list);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_invocation_name")]
+ internal static extern ErrorCode VcSetInvocationName(string name);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_request_dialog")]
+ internal static extern ErrorCode VcRequestDialog(string dispText, string uttText, bool autoStart);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_command_list")]
+ internal static extern ErrorCode VcSetCommandList(SafeCommandListHandle cmdList, VoiceCommandType type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_command_list")]
+ internal static extern ErrorCode VcUnsetCommandList(VoiceCommandType type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_get_result")]
+ internal static extern ErrorCode VcGetResult(VcResultCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_result_cb")]
+ internal static extern ErrorCode VcSetResultCb(VcResultCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_result_cb")]
+ internal static extern ErrorCode VcUnsetResultCb();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_service_state_changed_cb")]
+ internal static extern ErrorCode VcSetServiceStateChangedCb(VcServiceStateChangedCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_service_state_changed_cb")]
+ internal static extern ErrorCode VcUnsetServiceStateChangedCb();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_state_changed_cb")]
+ internal static extern ErrorCode VcSetStateChangedCb(VcStateChangedCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_state_changed_cb")]
+ internal static extern ErrorCode VcUnsetStateChangedCb();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_current_language_changed_cb")]
+ internal static extern ErrorCode VcSetCurrentLanguageChangedCb(VcCurrentLanguageChangedCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_current_language_changed_cb")]
+ internal static extern ErrorCode VcUnsetCurrentLanguageChangedCb();
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_set_error_cb")]
+ internal static extern ErrorCode VcSetErrorCb(VcErrorCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_unset_error_cb")]
+ internal static extern ErrorCode VcUnsetErrorCb();
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcResultCb(ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcCurrentLanguageChangedCb(IntPtr previous, IntPtr current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool VcSupportedLanguageCb(IntPtr language, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcStateChangedCb(State previous, State current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcServiceStateChangedCb(ServiceState previous, ServiceState current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcErrorCb(ErrorCode reason, IntPtr userData);
+ }
+}
\ 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;
+using Tizen.Uix.VoiceControl;
+
+/// <summary>
+/// Partial Interop Class
+/// </summary>
+internal static partial class Interop
+{
+ /// <summary>
+ /// VoiceControlCommand Interop Class
+ /// </summary>
+ internal static class VoiceControlCommand
+ {
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_create")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListCreate(out SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_destroy")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListDestroy(IntPtr cmdList, bool freeCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_get_count")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListGetCount(SafeCommandListHandle cmdList, out int count);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_add")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListAdd(SafeCommandListHandle cmdList, SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_remove")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListRemove(SafeCommandListHandle cmdList, SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_foreach_commands")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListForeachCommands(SafeCommandListHandle cmdList, VcCmdListCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_first")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListFirst(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_last")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListLast(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_next")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListNext(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_prev")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListPrev(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_get_current")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdListGetCurrent(SafeCommandListHandle cmdList, out SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_create")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdCreate(out SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_destroy")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdDestroy(IntPtr vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_command")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdSetCommand(SafeCommandHandle vcCommand, string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_command")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdGetCommand(SafeCommandHandle vcCommand, out string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_unfixed_command")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdGetUnfixedCommand(SafeCommandHandle vcCommand, out string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_type")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdSetType(SafeCommandHandle vcCommand, CommandType type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_type")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdGetType(SafeCommandHandle vcCommand, out int type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_format")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdSetFormat(SafeCommandHandle vcCommand, CommandFormat format);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_format")]
+ internal static extern Interop.VoiceControl.ErrorCode VcCmdGetFormat(SafeCommandHandle vcCommand, out CommandFormat format);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool VcCmdListCb(IntPtr vcCommand, IntPtr userData);
+
+ internal sealed class SafeCommandListHandle : SafeHandle
+ {
+ public SafeCommandListHandle(IntPtr handle)
+ : base(handle, true)
+ {
+ }
+
+ public SafeCommandListHandle()
+ : base(IntPtr.Zero, true)
+ {
+ }
+
+ public override bool IsInvalid
+ {
+ get { return this.handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle()
+ {
+ if (!IsInvalid)
+ {
+ Interop.VoiceControl.ErrorCode error = VcCmdListDestroy(this.handle, false);
+ if (error != Interop.VoiceControl.ErrorCode.None)
+ {
+ Log.Error(VoiceControl.LogTag, "Destroy Failed with error " + error);
+ }
+ }
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+
+ internal sealed class SafeCommandHandle : SafeHandle
+ {
+ internal bool _ownership;
+
+ public SafeCommandHandle(IntPtr handle)
+ : base(handle, true)
+ {
+ _ownership = true;
+ }
+
+ public SafeCommandHandle()
+ : base(IntPtr.Zero, true)
+ {
+ _ownership = true;
+ }
+
+ public override bool IsInvalid
+ {
+ get { return this.handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle()
+ {
+ Interop.VoiceControl.ErrorCode error = VoiceControl.ErrorCode.None;
+ if (_ownership && !IsInvalid)
+ {
+ error = VcCmdDestroy(this.handle);
+ if (error != Interop.VoiceControl.ErrorCode.None)
+ {
+ Log.Error(VoiceControl.LogTag, "Destroy Failed with error " + error);
+ }
+ }
+ 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.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.Uix.VoiceControl")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Uix.VoiceControl")]
+[assembly: AssemblyCopyright("Copyright \u00A9 2017")]
+[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("23e28ff0-aa5f-457b-ad1c-ad42d5f59254")]
+
+// 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">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{090D9725-02F5-4F2C-B41F-3B0D493904E8}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Uix.VoiceControl</RootNamespace>
+ <AssemblyName>Tizen.Uix.VoiceControl</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Uix.VoiceControl.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.VoiceControl.cs" />
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.VoiceControlCommand.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\CurrentLanguageChangedEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ErrorOccuredEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ExceptionFactory.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\RecognitionResultEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ServiceStateChangedEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\StateChangedEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceCommand.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceCommandList.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceControlClient.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Uix.VoiceControl.nuspec" />
+ <None Include="Tizen.Uix.VoiceControl.project.json" />
+ <None Include="Tizen.Uix.VoiceControl.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>
\ No newline at end of file
--- /dev/null
+{
+ "dependencies": {
+ "Tizen": "1.0.1"
+ },
+ "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>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{23E28FF0-AA5F-457B-AD1C-AD42D5F59254}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Uix.VoiceControl</RootNamespace>
+ <AssemblyName>Tizen.Uix.VoiceControl</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup>
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <NoStdLib>true</NoStdLib>
+ <NoWarn>$(NoWarn);1701;1702</NoWarn>
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </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>
+ <Prefer32Bit>false</Prefer32Bit>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Uix.VoiceControl.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.VoiceControl.cs" />
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.VoiceControlCommand.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceCommand.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceCommandList.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\VoiceControlClient.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\CurrentLanguageChangedEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ErrorOccuredEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ExceptionFactory.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\RecognitionResultEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\ServiceStateChangedEventArgs.cs" />
+ <Compile Include="Tizen.Uix.VoiceControl\StateChangedEventArgs.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Uix.VoiceControl.nuspec" />
+ <None Include="Tizen.Uix.VoiceControl.project.json" />
+ <None Include="Tizen.Uix.VoiceControl.snk" />
+ </ItemGroup>
+ <ItemGroup />
+ <ItemGroup>
+ <Reference Include="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
+ </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>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Uix.VoiceControl</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>VoiceControl API for Tizen.Net</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.3" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Uix.VoiceControl.dll" target="lib/netstandard1.3" />
+ <file src="bin/$Configuration$/Net45/Tizen.Uix.VoiceControl.dll" target="lib/net45" />
+ </files>
+</package>
--- /dev/null
+{
+ "dependencies": {
+ "NETStandard.Library": "1.6.0",
+ "Tizen": "1.0.1"
+ },
+ "frameworks": {
+ "netstandard1.3": {}
+ }
+}
--- /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.Uix.VoiceControl
+{
+ /// <summary>
+ /// This class holds information about the CurrentLanguageChanged Event
+ /// </summary>
+ public class CurrentLanguageChangedEventArgs
+ {
+ internal CurrentLanguageChangedEventArgs(string previous, string current)
+ {
+ PreviousLanguage = previous;
+ CurrentLanguage = current;
+ }
+
+ /// <summary>
+ /// The previous language
+ /// </summary>
+ public string PreviousLanguage
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// The current language
+ /// </summary>
+ public string CurrentLanguage
+ {
+ get;
+ internal set;
+ }
+ }
+}
\ 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 static Interop.VoiceControl;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// This class holds information related to the VoiceControl ErrorOccured Event
+ /// </summary>
+ public class ErrorOccuredEventArgs
+ {
+ internal ErrorOccuredEventArgs(ErrorCode error)
+ {
+ switch (error)
+ {
+ case ErrorCode.None:
+ {
+ ErrorValue = Error.None;
+ break;
+ }
+
+ case ErrorCode.OutOfMemory:
+ {
+ ErrorValue = Error.OutOfMemory;
+ break;
+ }
+
+ case ErrorCode.IoError:
+ {
+ ErrorValue = Error.IoError;
+ break;
+ }
+
+ case ErrorCode.InvalidParameter:
+ {
+ ErrorValue = Error.InvalidParameter;
+ break;
+ }
+
+ case ErrorCode.TimedOut:
+ {
+ ErrorValue = Error.TimedOut;
+ break;
+ }
+
+ case ErrorCode.RecorderBusy:
+ {
+ ErrorValue = Error.RecorderBusy;
+ break;
+ }
+
+ case ErrorCode.PermissionDenied:
+ {
+ ErrorValue = Error.PermissionDenied;
+ break;
+ }
+
+ case ErrorCode.NotSupported:
+ {
+ ErrorValue = Error.NotSupported;
+ break;
+ }
+
+ case ErrorCode.InvalidState:
+ {
+ ErrorValue = Error.InvalidState;
+ break;
+ }
+
+ case ErrorCode.InvalidLanguage:
+ {
+ ErrorValue = Error.InvalidLanguage;
+ break;
+ }
+
+ case ErrorCode.EngineNotFound:
+ {
+ ErrorValue = Error.EngineNotFound;
+ break;
+ }
+
+ case ErrorCode.OperationFailed:
+ {
+ ErrorValue = Error.OperationFailed;
+ break;
+ }
+
+ case ErrorCode.OperationRejected:
+ {
+ ErrorValue = Error.OperationRejected;
+ break;
+ }
+
+ case ErrorCode.IterationEnd:
+ {
+ ErrorValue = Error.IterationEnd;
+ break;
+ }
+
+ case ErrorCode.Empty:
+ {
+ ErrorValue = Error.Empty;
+ break;
+ }
+
+ case ErrorCode.InProgressToReady:
+ {
+ ErrorValue = Error.InProgressToReady;
+ break;
+ }
+
+ case ErrorCode.InProgressToRecording:
+ {
+ ErrorValue = Error.InProgressToRecording;
+ break;
+ }
+
+ case ErrorCode.InProgressToProcessing:
+ {
+ ErrorValue = Error.InProgressToProcessing;
+ break;
+ }
+
+ case ErrorCode.ServiceReset:
+ {
+ ErrorValue = Error.ServiceReset;
+ break;
+ }
+ }
+ }
+
+ /// <summary>
+ /// The Error Value
+ /// </summary>
+ public Error ErrorValue
+ {
+ get;
+ internal set;
+ }
+ }
+}
\ 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 static Interop.VoiceControl;
+
+namespace Tizen.Uix.VoiceControl
+{
+ internal static class ExceptionFactory
+ {
+ internal static Exception CreateException(ErrorCode err)
+ {
+ Tizen.Log.Error(LogTag, "Error " + err);
+ Exception exp;
+ switch (err)
+ {
+ case ErrorCode.OutOfMemory:
+ {
+ exp = new InvalidOperationException("Out Of Memory");
+ break;
+ }
+
+ case ErrorCode.IoError:
+ {
+ exp = new InvalidOperationException("I/O Error Occured");
+ break;
+ }
+
+ case ErrorCode.InvalidParameter:
+ {
+ exp = new InvalidOperationException("Invalid Parameters Provided");
+ break;
+ }
+
+ case ErrorCode.TimedOut:
+ {
+ exp = new InvalidOperationException("No answer from service");
+ break;
+ }
+
+ case ErrorCode.RecorderBusy:
+ {
+ exp = new InvalidOperationException("Recorder is Busy ");
+ break;
+ }
+
+ case ErrorCode.PermissionDenied:
+ {
+ exp = new InvalidOperationException("Permission Denied");
+ break;
+ }
+
+ case ErrorCode.NotSupported:
+ {
+ exp = new InvalidOperationException("VC NOT supported");
+ break;
+ }
+
+ case ErrorCode.InvalidState:
+ {
+ exp = new InvalidOperationException("Invalid state");
+ break;
+ }
+
+ case ErrorCode.InvalidLanguage:
+ {
+ exp = new InvalidOperationException("Invalid language");
+ break;
+ }
+
+ case ErrorCode.EngineNotFound:
+ {
+ exp = new InvalidOperationException("No available engine");
+ break;
+ }
+
+ case ErrorCode.OperationFailed:
+ {
+ exp = new InvalidOperationException("Operation Failed");
+ break;
+ }
+
+ case ErrorCode.OperationRejected:
+ {
+ exp = new InvalidOperationException("Operation Rejected");
+ break;
+ }
+
+ case ErrorCode.IterationEnd:
+ {
+ exp = new InvalidOperationException("List Reached End");
+ break;
+ }
+
+ case ErrorCode.Empty:
+ {
+ exp = new InvalidOperationException("List Empty");
+ break;
+ }
+
+ case ErrorCode.InProgressToReady:
+ {
+ exp = new InvalidOperationException("Progress to ready is not finished");
+ break;
+ }
+
+ case ErrorCode.InProgressToRecording:
+ {
+ exp = new InvalidOperationException("Progress to recording is not finished");
+ break;
+ }
+
+ case ErrorCode.InProgressToProcessing:
+ {
+ exp = new InvalidOperationException("Progress to processing is not finished");
+ break;
+ }
+
+ case ErrorCode.ServiceReset:
+ {
+ exp = new InvalidOperationException("Service reset");
+ break;
+ }
+
+ default:
+ {
+ exp = new Exception("");
+ 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;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using static Interop.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// The recognition result from the engine.
+ /// If the duplicated commands are recognized, the event(e.g. Result.Rejected) of command may be rejected
+ /// for selecting command as priority.If you set similar or same commands or the recognized results are multi-results, CommandList has the multi commands.
+ /// </summary>
+ public class RecognitionResultEventArgs
+ {
+ private ResultEvent _resultEvent;
+ private VoiceCommandList _list;
+ private string _result;
+
+ internal RecognitionResultEventArgs(ResultEvent evt, IntPtr cmdList, IntPtr result)
+ {
+ _resultEvent = evt;
+ SafeCommandListHandle handle = new SafeCommandListHandle(cmdList);
+ _list = new VoiceCommandList(handle);
+ _result = Marshal.PtrToStringAnsi(result);
+ }
+
+ /// <summary>
+ /// The result event
+ /// </summary>
+ public ResultEvent Result
+ {
+ get
+ {
+ return _resultEvent;
+ }
+ }
+
+ /// <summary>
+ /// The spoken text
+ /// </summary>
+ public string ResultMessage
+ {
+ get
+ {
+ return _result;
+ }
+ }
+
+
+ /// <summary>
+ /// The recognized command list
+ /// </summary>
+ public VoiceCommandList CommandList
+ {
+ get
+ {
+ return _list;
+ }
+ }
+ }
+}
--- /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.Uix.VoiceControl
+{
+ /// <summary>
+ /// This class holds information related to the VoiceControl service ServiceStateChanged event
+ /// </summary>
+ public class ServiceStateChangedEventArgs
+ {
+ internal ServiceStateChangedEventArgs(ServiceState previous, ServiceState current)
+ {
+ Previous = previous;
+ Current = current;
+ }
+
+ /// <summary>
+ /// A previous state
+ /// </summary>
+ public ServiceState Previous
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// A current state
+ /// </summary>
+ public ServiceState Current
+ {
+ 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.Uix.VoiceControl
+{
+ /// <summary>
+ /// This class holds information related to the VoiceControl client StateChanged event
+ /// </summary>
+ public class StateChangedEventArgs
+ {
+ internal StateChangedEventArgs(State previous, State current)
+ {
+ Previous = previous;
+ Current = current;
+ }
+
+ /// <summary>
+ /// A previous state
+ /// </summary>
+ public State Previous
+ {
+ get;
+ internal set;
+ }
+
+ /// <summary>
+ /// A current state
+ /// </summary>
+ public State Current
+ {
+ 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.
+*/
+
+using System;
+using static Interop.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// Enumeration for Command Format
+ /// </summary>
+ public enum CommandFormat
+ {
+ /// <summary>
+ /// fixed command format.
+ /// </summary>
+ Fixed = 0,
+ /// <summary>
+ /// fixed and variable fixed command format.
+ /// </summary>
+ FixedAndVFixed = 1,
+ /// <summary>
+ /// variable fixed and fixed command format.
+ /// </summary>
+ VFixedAndFixed = 2,
+ /// <summary>
+ /// fixed and non-fixed command format.
+ /// </summary>
+ FixedAndNonFixed = 3,
+ /// <summary>
+ /// non-fixed and fixed command format.
+ /// </summary>
+ NonFixedAndFixed = 4,
+ /// <summary>
+ /// Undefined
+ /// </summary>
+ Undefined = 5
+ };
+
+ /// <summary>
+ /// This class represents a Voice Command
+ /// </summary>
+ public class VoiceCommand
+ {
+ internal SafeCommandHandle _handle;
+
+ /// <summary>
+ /// Public Constructor
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Out of memory
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// </exception>
+ public VoiceCommand()
+ {
+ SafeCommandHandle handle;
+ ErrorCode error = VcCmdCreate(out handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Create Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _handle = handle;
+ }
+
+ internal VoiceCommand(SafeCommandHandle handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// Gets the unfixed command.
+ /// This property should be used for commands which have non-fixed format.
+ /// empty string will be returned in case of some internal error
+ /// </summary>
+ public string GetUnfixedCommand
+ {
+ get
+ {
+ string unfixedCommand;
+ ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetUnfixedCommand Failed with error " + error);
+ return "";
+ }
+
+ return unfixedCommand;
+ }
+ }
+
+ /// <summary>
+ /// Gets/Sets command type.
+ /// </summary>
+ /// <remarks>If you do not set the command type, the default value is Undefined. You should set type if command is valid</remarks>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons for set operation
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ public CommandType Type
+ {
+ get
+ {
+ CommandType cmdType = CommandType.Undefined;
+ int type;
+ ErrorCode error = VcCmdGetType(_handle, out type);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetType Failed with error " + error);
+ return CommandType.Undefined;
+ }
+
+ if (type != -1)
+ {
+ cmdType = (CommandType)type;
+ }
+
+ return cmdType;
+ }
+ set
+ {
+ ErrorCode error = VcCmdSetType(_handle, value);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetType Failed with error " + error);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets/Sets the command format.
+ /// </summary>
+ /// <remarks>The default format is Fixed</remarks>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons for set operation
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ public CommandFormat Format
+ {
+ get
+ {
+ CommandFormat format;
+ ErrorCode error = VcCmdGetFormat(_handle, out format);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetFormat Failed with error " + error);
+ return CommandFormat.Undefined;
+ }
+
+ return format;
+ }
+ set
+ {
+ ErrorCode error = VcCmdSetFormat(_handle, value);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetFormat Failed with error " + error);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets/Sets command
+ /// in case of get empty string will be returned in case of some internal error
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons for set operation
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ public string Command
+ {
+ get
+ {
+ string command;
+ ErrorCode error = VcCmdGetCommand(_handle, out command);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetCommand Failed with error " + error);
+ return "";
+ }
+
+ return command;
+ }
+ set
+ {
+ ErrorCode error = VcCmdSetCommand(_handle, value);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetCommand Failed with error " + error);
+ }
+ }
+ }
+ }
+}
--- /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 static Interop.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// this class represents list of Voice Commands
+ /// </summary>
+ public class VoiceCommandList
+ {
+ internal SafeCommandListHandle _handle;
+ private List<VoiceCommand> _list;
+ private VcCmdListCb _callback;
+
+ /// <summary>
+ /// Public Constructor
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// 4. Out of memory
+ /// </exception>
+ public VoiceCommandList()
+ {
+ SafeCommandListHandle handle = new SafeCommandListHandle();
+ ErrorCode error = VcCmdListCreate(out handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Create Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _handle = handle;
+ }
+
+ internal VoiceCommandList(SafeCommandListHandle handle)
+ {
+ _handle = handle;
+ }
+
+ /// <summary>
+ /// Gets command count of list.
+ /// -1 is returned in case of internal failure.
+ /// </summary>
+ public int GetCount
+ {
+ get
+ {
+ int count;
+ ErrorCode error = VcCmdListGetCount(_handle, out count);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Count Failed with error " + error);
+ return -1;
+ }
+
+ return count;
+ }
+ }
+
+ /// <summary>
+ /// Get current command from command list by index.
+ /// null will be returned in case of Empty List
+ /// </summary>
+ public VoiceCommand GetCurrent
+ {
+ get
+ {
+ SafeCommandHandle current;
+ ErrorCode error = VcCmdListGetCurrent(_handle, out current);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Current Failed with error " + error);
+ return null;
+ }
+ current._ownership = false;
+ return new VoiceCommand(current);
+ }
+ }
+
+ /// <summary>
+ /// Adds command to command list.
+ /// </summary>
+ /// <param name="command">The command</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ /// <exception cref="NullReferenceException">This will occur if the provide parameter is null</exception>
+ public void Add(VoiceCommand command)
+ {
+ ErrorCode error = VcCmdListAdd(_handle, command._handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Removes command from command list.
+ /// </summary>
+ /// <param name="command">The command</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Invalid parameter
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ /// <exception cref="NullReferenceException">This will occur if the provide parameter is null</exception>
+ public void Remove(VoiceCommand command)
+ {
+ ErrorCode error = VcCmdListRemove(_handle, command._handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all commands of command list.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Permission Denied
+ /// 2. Not supported
+ /// </exception>
+ public IEnumerable<VoiceCommand> GetAllCommands()
+ {
+ _list = new List<VoiceCommand>();
+ _callback = (IntPtr vcCommand, IntPtr userData) =>
+ {
+ SafeCommandHandle handle = new SafeCommandHandle(vcCommand);
+ handle._ownership = false;
+ _list.Add(new VoiceCommand(handle));
+ return true;
+ };
+ ErrorCode error = VcCmdListForeachCommands(_handle, _callback, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetAllCommands Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+
+ return _list;
+ }
+
+ /// <summary>
+ /// Moves index to first command.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. List Empty
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ public void First()
+ {
+ ErrorCode error = VcCmdListFirst(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "First Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Moves index to last command.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. List Empty
+ /// 2. Permission Denied
+ /// 3. Not supported
+ /// </exception>
+ public void Last()
+ {
+ ErrorCode error = VcCmdListLast(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Last Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Moves index to next command.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. List Empty
+ /// 2. List reached end
+ /// 3. Permission Denied
+ /// 4. Not supported
+ /// </exception>
+ public void Next()
+ {
+ ErrorCode error = VcCmdListNext(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Next Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Moves index to previous command.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. List Empty
+ /// 2. List reached end
+ /// 3. Permission Denied
+ /// 4. Not supported
+ /// </exception>
+ public void Previous()
+ {
+ ErrorCode error = VcCmdListPrev(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Previous Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+ }
+}
--- /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 System.Runtime.InteropServices;
+using static Interop.VoiceControl;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControl
+{
+ /// <summary>
+ /// Enum for Error values that can occur
+ /// </summary>
+ public enum Error
+ {
+ /// <summary>
+ /// Successful, No error
+ /// </summary>
+ None,
+ /// <summary>
+ /// Out of Memory
+ /// </summary>
+ OutOfMemory,
+ /// <summary>
+ /// I/O error
+ /// </summary>
+ IoError,
+ /// <summary>
+ /// Invalid parameter
+ /// </summary>
+ InvalidParameter,
+ /// <summary>
+ /// No answer from the STT service
+ /// </summary>
+ TimedOut,
+ /// <summary>
+ /// Device or resource busy
+ /// </summary>
+ RecorderBusy,
+ /// <summary>
+ /// Permission denied
+ /// </summary>
+ PermissionDenied,
+ /// <summary>
+ /// VC NOT supported
+ /// </summary>
+ NotSupported,
+ /// <summary>
+ /// Invalid state
+ /// </summary>
+ InvalidState,
+ /// <summary>
+ /// Invalid language
+ /// </summary>
+ InvalidLanguage,
+ /// <summary>
+ /// No available engine
+ /// </summary>
+ EngineNotFound,
+ /// <summary>
+ /// Operation failed
+ /// </summary>
+ OperationFailed,
+ /// <summary>
+ /// Operation Rejected
+ /// </summary>
+ OperationRejected,
+ /// <summary>
+ /// List reached end
+ /// </summary>
+ IterationEnd,
+ /// <summary>
+ /// List Empty
+ /// </summary>
+ Empty,
+ /// <summary>
+ /// Service reset
+ /// </summary>
+ ServiceReset,
+ /// <summary>
+ /// Progress to ready is not finished
+ /// </summary>
+ InProgressToReady,
+ /// <summary>
+ /// Progress to recording is not finished
+ /// </summary>
+ InProgressToRecording,
+ /// <summary>
+ /// Progress to processing is not finished
+ /// </summary>
+ InProgressToProcessing
+ };
+
+ /// <summary>
+ /// Enumeration for the client state.
+ /// </summary>
+ public enum State
+ {
+ /// <summary>
+ /// 'None' state
+ /// </summary>
+ None = 0,
+ /// <summary>
+ /// 'Initialized' state
+ /// </summary>
+ Initialized = 1,
+ /// <summary>
+ /// 'Ready' state
+ /// </summary>
+ Ready = 2,
+ /// <summary>
+ /// state cannot be determined
+ /// </summary>
+ Unavailable
+ };
+
+ /// <summary>
+ /// Enumerations of service state.
+ /// </summary>
+ public enum ServiceState
+ {
+ /// <summary>
+ /// 'None' state
+ /// </summary>
+ None = 0,
+ /// <summary>
+ /// 'Ready' state
+ /// </summary>
+ Ready = 1,
+ /// <summary>
+ /// 'Recording' state
+ /// </summary>
+ Recording = 2,
+ /// <summary>
+ /// 'Processing' state
+ /// </summary>
+ Processing = 3,
+ /// <summary>
+ /// state cannot be determined
+ /// </summary>
+ Unavailable
+ };
+
+ /// <summary>
+ /// Enumerations of result event.
+ /// </summary>
+ public enum ResultEvent
+ {
+ /// <summary>
+ /// Normal result
+ /// </summary>
+ Success = 0,
+ /// <summary>
+ /// Rejected result
+ /// </summary>
+ Rejected = 1
+ };
+
+ /// <summary>
+ /// Enumerations of command type.
+ /// </summary>
+ public enum CommandType
+ {
+ /// <summary>
+ /// Foreground command by client
+ /// </summary>
+ Foreground = 1,
+ /// <summary>
+ /// Background command by client
+ /// </summary>
+ Background = 2,
+ /// <summary>
+ /// Undefined command
+ /// </summary>
+ Undefined = -1
+ };
+
+ /// <summary>
+ /// A main function of Voice Control API register command and gets notification for recognition result.
+ /// Applications can add their own commands and be provided result when their command is recognized by user voice input.
+ /// </summary>
+ public static class VoiceControlClient
+ {
+ /// <summary>
+ /// Called when client gets the recognition result.
+ /// </summary>
+ /// <remarks>
+ /// If the duplicated commands are recognized, the event(e.g. Result.Rejected) of command may be rejected
+ /// for selecting command as priority.If you set similar or same commands or the recognized results are multi-results, cmdList has the multi commands.
+ /// </remarks>
+ /// <param name="evt">The ResultEvent</param>
+ /// <param name="cmdList">Command List</param>
+ /// <param name="result">Result</param>
+ public delegate void RecognitionResultDelegate(ResultEvent evt, VoiceCommandList cmdList, string result);
+
+ private static event EventHandler<RecognitionResultEventArgs> _recognitionResult;
+ private static event EventHandler<StateChangedEventArgs> _stateChanged;
+ private static event EventHandler<ServiceStateChangedEventArgs> _serviceStateChanged;
+ private static event EventHandler<ErrorOccuredEventArgs> _errorOccured;
+ private static event EventHandler<CurrentLanguageChangedEventArgs> _currentLanguageChanged;
+ private static VcResultCb s_resultDelegate;
+ private static VcStateChangedCb s_stateDelegate;
+ private static VcServiceStateChangedCb s_serviceStateDelegate;
+ private static VcErrorCb s_errorDelegate;
+ private static VcCurrentLanguageChangedCb s_languageDelegate;
+ private static List<string> s_supportedLanguages;
+ private static VcSupportedLanguageCb s_supportedLanguagesCb;
+ private static VcResultCb s_resultCb;
+
+ /// <summary>
+ /// Gets current language.
+ /// A language is specified as an ISO 3166 alpha-2 two letter country-code
+ /// followed by ISO 639-1 for the two-letter language code.
+ /// For example, "ko_KR" for Korean, "en_US" for American English.
+ /// Empty string is returned incase of some internal error
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <precondition>
+ /// The State must be Initialized or Ready.
+ /// </precondition>
+ public static string GetCurrentLanaguge
+ {
+ get
+ {
+ string currentLanaguge;
+
+ ErrorCode error = VcGetCurrentLanguage(out currentLanaguge);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "CurrentLanaguge Failed with error " + error);
+ return "";
+ }
+
+ return currentLanaguge;
+ }
+ }
+
+ /// <summary>
+ /// Gets current state of voice control client.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <precondition>
+ /// The State must be Initialized or Ready.
+ /// </precondition>
+ public static State GetState
+ {
+ get
+ {
+ State state;
+
+ ErrorCode error = VcGetState(out state);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetState Failed with error " + error);
+ return State.Unavailable;
+ }
+
+ return state;
+ }
+ }
+
+ /// <summary>
+ /// Gets current state of voice control service.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <precondition>
+ /// The State must be Ready.
+ /// </precondition>
+ public static ServiceState GetServiceState
+ {
+ get
+ {
+ ServiceState state;
+
+ ErrorCode error = VcGetServiceState(out state);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetServiceState Failed with error " + error);
+ return ServiceState.Unavailable;
+ }
+
+ return state;
+ }
+ }
+
+ /// <summary>
+ /// Sets the invocation name.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <remarks>
+ /// Invocation name is used to activate background commands. The invocation name can be the same as the application name or any other phrase.
+ /// For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample".
+ /// In order to activate the background command, users can say "Tizen Sample, Play music". The invocation name is dependent on the current language.
+ /// For example, if the current language is "en_US"(English), the invocation name is also "en_US".
+ /// If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized.
+ /// This function should be called before SetCommandList().
+ /// </remarks>
+ /// <param name="name">Invocation name that an application wants to be invoked by</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Invalid parameter
+ /// 2. Invalid state
+ /// 3. Not Supported
+ /// 4. Permission Denied
+ /// </exception>
+ /// <precondition>
+ /// The State must be Ready.
+ /// </precondition>
+ public static void SetInvocationName(string name)
+ {
+ ErrorCode error = VcSetInvocationName(name);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetInvocationName Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Initializes voice control.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Out Of Memory
+ /// 2. Operation Failed
+ /// 3. Not Supported
+ /// 4. Permission Denied
+ /// </exception>
+ /// <postcondition>
+ /// The State will be Initialized.
+ /// </postcondition>
+ public static void Initialize()
+ {
+ ErrorCode error = VcInitialize();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Initialize Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Deinitializes voice control.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Operation Failed
+ /// 2. Invalid state
+ /// 3. Not Supported
+ /// 4. Permission Denied
+ /// </exception>
+ public static void Deinitialize()
+ {
+ ErrorCode error = VcDeinitialize();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Deinitialize Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Connects the voice control service.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Operation Failed
+ /// 2. Not Supported
+ /// 3. Permission Denied
+ /// 4. Invalid State
+ /// </exception>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ /// <postcondition>
+ /// The State will be Ready
+ /// </postcondition>
+ public static void Prepare()
+ {
+ ErrorCode error = VcPrepare();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Prepare Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Disconnects the voice control service.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ /// <postcondition>
+ /// The State should be Initialized
+ /// </postcondition>
+ public static void Unprepare()
+ {
+ ErrorCode error = VcUnprepare();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Unprepare Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Retrieves all supported languages.
+ /// A language is specified as an ISO 3166 alpha-2 two letter country-code
+ /// followed by ISO 639-1 for the two-letter language code.
+ /// For example, "ko_KR" for Korean, "en_US" for American English.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Operation Failed
+ /// 2. Not Supported
+ /// 3. Permission Denied
+ /// 4. Invalid State
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready or Initialized
+ /// </precondition>
+ public static IEnumerable<string> GetSupportedLangauges()
+ {
+ s_supportedLanguages = new List<string>();
+ s_supportedLanguagesCb = (IntPtr language, IntPtr userData) =>
+ {
+ string languageStr = Marshal.PtrToStringAnsi(language);
+ s_supportedLanguages.Add(languageStr);
+ return true;
+ };
+ ErrorCode error = VcForeachSupportedLanguages(s_supportedLanguagesCb, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetSupportedLangauges Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+
+ return s_supportedLanguages;
+ }
+
+ /// <summary>
+ /// Gets the system command list.
+ /// </summary>
+ /// <returns>
+ /// The Command List else null in case of no System Commands
+ /// </returns>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <remarks>
+ /// In the system command list, there are system commands predefined by product manufacturers.
+ /// Those commands have the highest priority. Therefore, the user can not set any commands same with the system commands.
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ public static VoiceCommandList GetSytemCommandList()
+ {
+ IntPtr handle = IntPtr.Zero;
+ ErrorCode error = VcGetSystemCommandList(out handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetSystemCommandList Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+
+ if (handle == IntPtr.Zero)
+ {
+ Log.Error(LogTag, "GetSystemCommandList handle is null");
+ return null;
+ }
+
+ SafeCommandListHandle list = new SafeCommandListHandle(handle);
+ return new VoiceCommandList(list);
+ }
+
+ /// <summary>
+ /// Requests to start the dialogue.
+ /// Using this function, the developer can request starting the dialogue to the framework.
+ /// When the developer requests the dialogue, two types of texts, dispText and uttText, can be sent by this function.dispText is a text for displaying, and uttText is that for uttering.
+ /// For example, if dispText is "October 10th" and uttText is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken.
+ /// Also, the developer can set whether the dialogue starts automatically or not, using autoStart.
+ /// If the developer sets autoStart as true, the framework will start to record next speech and continue the dialogue.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <remarks>
+ /// If autoStart is true, the recognition will start again. In this case, it can be restarted up to 4 times.
+ /// </remarks>
+ /// <param name="dispText"> Text to be displayed on the screen/// </param>
+ /// <param name="uttText">Text to be spoken</param>
+ /// <param name="autoStart">A variable for setting whether the dialog session will be restarted automatically or not</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// 4. Invalid parameter
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ public static void RequestDialog(string dispText, string uttText, bool autoStart)
+ {
+ ErrorCode error = VcRequestDialog(dispText, uttText, autoStart);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "RequestDialog Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Sets command list.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <remarks>
+ /// The command type is valid for CommandType 'Foreground' or 'Background'.
+ /// The matched commands of command list should be set and they should include type and command text at least.
+ /// </remarks>
+ /// <param name="list">Command list</param>
+ /// <param name="type">Command type</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// 4. Invalid parameter
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ public static void SetCommandList(VoiceCommandList list, CommandType type)
+ {
+ if ((type == CommandType.Foreground) || (type == CommandType.Background))
+ {
+ ErrorCode error = VcSetCommandList(list._handle, (VoiceCommandType)type);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetCommandList Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ else
+ {
+ throw ExceptionFactory.CreateException(ErrorCode.InvalidParameter);
+ }
+ }
+
+ /// <summary>
+ /// Unsets command list.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <param name="type">Command type</param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Permission Denied
+ /// 3. Invalid State
+ /// 4. Invalid parameter
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ public static void UnsetCommandList(CommandType type)
+ {
+ if ((type == CommandType.Foreground) || (type == CommandType.Background))
+ {
+ VoiceCommandType commandType = VoiceCommandType.Foreground;
+ if (type == CommandType.Background)
+ commandType = VoiceCommandType.BackGround;
+ ErrorCode error = VcUnsetCommandList(commandType);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "UnsetCommandList Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ else
+ {
+ throw ExceptionFactory.CreateException(ErrorCode.InvalidParameter);
+ }
+ }
+
+ /// <summary>
+ /// Gets the recognition result.
+ /// </summary>
+ /// <privilege>
+ /// http://tizen.org/privilege/recorder
+ /// </privilege>
+ /// <param name="resultDelegate">
+ /// Callback function to get recognition result
+ /// </param>
+ /// <exception cref="InvalidOperationException">
+ /// This Exception can be due to the following reaons
+ /// 1. Not Supported
+ /// 2. Invalid State
+ /// 3. Invalid parameter
+ /// </exception>
+ /// <precondition>
+ /// The State should be Ready
+ /// </precondition>
+ public static void GetResult(RecognitionResultDelegate resultDelegate)
+ {
+ s_resultCb = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
+ {
+ VoiceCommandList list = new VoiceCommandList(new SafeCommandListHandle(cmdList));
+ string resultStr = Marshal.PtrToStringAnsi(result);
+ resultDelegate(evt, list, resultStr);
+ };
+ ErrorCode error = VcGetResult(s_resultCb, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetResult Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ /// <summary>
+ /// Event to be invoked when the recognition is done.
+ /// </summary>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ public static event EventHandler<RecognitionResultEventArgs> RecognitionResult
+ {
+ add
+ {
+ s_resultDelegate = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
+ {
+ Log.Info(LogTag, "Recognition Result Event Triggered");
+ if ((cmdList != null) && (result != null))
+ {
+ RecognitionResultEventArgs args = new RecognitionResultEventArgs(evt, cmdList, result);
+ _recognitionResult?.Invoke(null, args);
+ }
+ else
+ {
+ Log.Info(LogTag, "Recognition Result Event null received");
+ }
+ };
+ ErrorCode error = VcSetResultCb(s_resultDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add RecognitionResult Failed with error " + error);
+ }
+ else
+ {
+ _recognitionResult += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcUnsetResultCb();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove RecognitionResult Failed with error " + error);
+ }
+
+ _recognitionResult -= value;
+ }
+ }
+
+ /// <summary>
+ /// Event to be invoked when VoiceControl service state changes.
+ /// </summary>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ public static event EventHandler<ServiceStateChangedEventArgs> ServiceStateChanged
+ {
+ add
+ {
+ s_serviceStateDelegate = (ServiceState previous, ServiceState current, IntPtr userData) =>
+ {
+ ServiceStateChangedEventArgs args = new ServiceStateChangedEventArgs(previous, current);
+ _serviceStateChanged?.Invoke(null, args);
+ };
+ ErrorCode error = VcSetServiceStateChangedCb(s_serviceStateDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ServiceStateChanged Failed with error " + error);
+ }
+ else
+ {
+ _serviceStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcUnsetServiceStateChangedCb();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove ServiceStateChanged Failed with error " + error);
+ }
+
+ _serviceStateChanged -= value;
+ }
+ }
+
+ /// <summary>
+ /// Event to be invoked when VoiceControl client state changes.
+ /// </summary>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ public static event EventHandler<StateChangedEventArgs> StateChanged
+ {
+ add
+ {
+ s_stateDelegate = (State previous, State current, IntPtr userData) =>
+ {
+ StateChangedEventArgs args = new StateChangedEventArgs(previous, current);
+ _stateChanged?.Invoke(null, args);
+ };
+ ErrorCode error = VcSetStateChangedCb(s_stateDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add StateChanged Failed with error " + error);
+ }
+ else
+ {
+ _stateChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcUnsetStateChangedCb();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove StateChanged Failed with error " + error);
+ }
+
+ _stateChanged -= value;
+ }
+ }
+
+ /// <summary>
+ /// Event to be invoked when an error occurs.
+ /// </summary>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ public static event EventHandler<ErrorOccuredEventArgs> ErrorOccured
+ {
+ add
+ {
+ s_errorDelegate = (ErrorCode reason, IntPtr userData) =>
+ {
+ ErrorOccuredEventArgs args = new ErrorOccuredEventArgs(reason);
+ _errorOccured?.Invoke(null, args);
+ };
+ ErrorCode error = VcSetErrorCb(s_errorDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ErrorOccured Failed with error " + error);
+ }
+
+ else
+ {
+ _errorOccured += value;
+ }
+ }
+
+
+ remove
+ {
+ ErrorCode error = VcUnsetErrorCb();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove ErrorOccured Failed with error " + error);
+ }
+
+ _errorOccured -= value;
+ }
+ }
+
+ /// <summary>
+ /// Event to be invoked when default laungage change.
+ /// </summary>
+ /// <precondition>
+ /// The State should be Initialized
+ /// </precondition>
+ public static event EventHandler<CurrentLanguageChangedEventArgs> CurrentLanguageChanged
+ {
+ add
+ {
+ s_languageDelegate = (IntPtr previousLanguage, IntPtr currentLanguage, IntPtr userData) =>
+ {
+ string previousLanguageString = Marshal.PtrToStringAnsi(previousLanguage);
+ string currentLanguageString = Marshal.PtrToStringAnsi(currentLanguage);
+ CurrentLanguageChangedEventArgs args = new CurrentLanguageChangedEventArgs(previousLanguageString, currentLanguageString);
+ _currentLanguageChanged?.Invoke(null, args);
+ };
+ ErrorCode error = VcSetCurrentLanguageChangedCb(s_languageDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add CurrentLanguageChanged Failed with error " + error);
+ }
+
+ else
+ {
+ _currentLanguageChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcUnsetCurrentLanguageChangedCb();
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove CurrentLanguageChanged Failed with error " + error);
+ }
+
+ _currentLanguageChanged -= value;
+ }
+ }
+ }
+}