--- /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";
+ internal const string VoiceControlWidget = "libvc_widget.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;
+using Tizen.Uix.VoiceControlWidget;
+
+/// <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.VoiceControlWidget.ErrorCode VcCmdListCreate(out SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_destroy")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListDestroy(IntPtr cmdList, bool freeCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_get_count")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListGetCount(SafeCommandListHandle cmdList, out int count);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_add")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListAdd(SafeCommandListHandle cmdList, SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_remove")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListRemove(SafeCommandListHandle cmdList, SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_foreach_commands")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListForeachCommands(SafeCommandListHandle cmdList, VcCmdListCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_first")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListFirst(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_last")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListLast(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_next")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListNext(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_prev")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListPrev(SafeCommandListHandle cmdList);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_list_get_current")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdListGetCurrent(SafeCommandListHandle cmdList, out SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_create")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdCreate(out SafeCommandHandle vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_destroy")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdDestroy(IntPtr vcCommand);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_command")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdSetCommand(SafeCommandHandle vcCommand, string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_command")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdGetCommand(SafeCommandHandle vcCommand, out string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_unfixed_command")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdGetUnfixedCommand(SafeCommandHandle vcCommand, out string command);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_type")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdSetType(SafeCommandHandle vcCommand, CommandType type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_type")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdGetType(SafeCommandHandle vcCommand, out int type);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_set_format")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdSetFormat(SafeCommandHandle vcCommand, CommandFormat format);
+
+ [DllImport(Libraries.VoiceControl, EntryPoint = "vc_cmd_get_format")]
+ internal static extern Interop.VoiceControlWidget.ErrorCode VcCmdGetFormat(SafeCommandHandle vcCommand, out CommandFormat format);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool VcCmdListCb(IntPtr vcCommand, IntPtr userData);
+
+ internal sealed class SafeCommandListHandle : SafeHandle
+ {
+ internal bool _ownership;
+
+ public SafeCommandListHandle(IntPtr handle)
+ : base(handle, true)
+ {
+ _ownership = true;
+ }
+
+ public SafeCommandListHandle()
+ : base(IntPtr.Zero, true)
+ {
+ _ownership = true;
+ }
+
+ public override bool IsInvalid
+ {
+ get { return this.handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle()
+ {
+ if (_ownership && !IsInvalid)
+ {
+ Interop.VoiceControlWidget.ErrorCode error = VcCmdListDestroy(this.handle, false);
+ if (error != Interop.VoiceControlWidget.ErrorCode.None)
+ {
+ Log.Error(VoiceControlWidget.LogTag, "Destroy Failed with error " + error);
+ }
+ Log.Debug(VoiceControlWidget.LogTag, "Destroy command list handle");
+ }
+ this.SetHandle(IntPtr.Zero);
+
+ Log.Debug(VoiceControlWidget.LogTag, "Release command list handle");
+ 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.VoiceControlWidget.ErrorCode error = VoiceControlWidget.ErrorCode.None;
+ if (_ownership && !IsInvalid)
+ {
+ error = VcCmdDestroy(this.handle);
+ if (error != Interop.VoiceControlWidget.ErrorCode.None)
+ {
+ Log.Error(VoiceControlWidget.LogTag, "Destroy Failed with error " + error);
+ }
+ Log.Debug(VoiceControlWidget.LogTag, "Destroy command handle");
+ }
+ Log.Debug(VoiceControlWidget.LogTag, "Release command handle");
+ this.SetHandle(IntPtr.Zero);
+ return true;
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright 2016 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System;
+using System.Runtime.InteropServices;
+using static Interop.VoiceControlCommand;
+using Tizen.Uix.VoiceControlWidget;
+using Tizen;
+
+internal static partial class Interop
+{
+ internal static partial class VoiceControlWidget
+ {
+ internal static string LogTag = "Tizen.Uix.VoiceControlWidget";
+
+ 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) */
+ };
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_initialize")]
+ internal static extern ErrorCode VcWidgetInitialize(out IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_deinitialize")]
+ internal static extern ErrorCode VcWidgetDeinitialize(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_prepare")]
+ internal static extern ErrorCode VcWidgetPrepare(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unprepare")]
+ internal static extern ErrorCode VcWidgetUnprepare(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_foreach_supported_languages")]
+ internal static extern ErrorCode VcWidgetForeachSupportedLanguages(IntPtr widget, VcWidgetSupportedLanguageCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_get_current_language")]
+ internal static extern ErrorCode VcWidgetGetCurrentLanguage(IntPtr widget, out string language);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_get_state")]
+ internal static extern ErrorCode VcWidgetGetState(IntPtr widget, out State state);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_get_service_state")]
+ internal static extern ErrorCode VcWidgetGetServiceState(IntPtr widget, out ServiceState state);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_is_command_format_supported")]
+ internal static extern ErrorCode VcWidgetIsCommandFormatSupported(IntPtr widget, CommandFormat format, out bool support);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_foreground")]
+ internal static extern ErrorCode VcWidgetSetForeground(IntPtr widget, bool value);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_cancel")]
+ internal static extern ErrorCode VcWidgetCancel(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_result_cb")]
+ internal static extern ErrorCode VcWidgetSetResultCb(IntPtr widget, VcWidgetResultCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_result_cb")]
+ internal static extern ErrorCode VcWidgetUnsetResultCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_state_changed_cb")]
+ internal static extern ErrorCode VcWidgetSetStateChangedCb(IntPtr widget, VcWidgetStateChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_state_changed_cb")]
+ internal static extern ErrorCode VcWidgetUnsetStateChangedCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_service_state_changed_cb")]
+ internal static extern ErrorCode VcWidgetSetServiceStateChangedCb(IntPtr widget, VcWidgetServiceStateChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_service_state_changed_cb")]
+ internal static extern ErrorCode VcWidgetUnsetServiceStateChangedCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_show_tooltip_cb")]
+ internal static extern ErrorCode VcWidgetSetShowTooltipCb(IntPtr widget, VcWidgetShowTooltipCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_show_tooltip_cb")]
+ internal static extern ErrorCode VcWidgetUnSetShowTooltipCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_current_language_changed_cb")]
+ internal static extern ErrorCode VcWidgetSetCurrentLanguageChangedCb(IntPtr widget, VcWidgetCurrentLanguageChangedCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_current_language_changed_cb")]
+ internal static extern ErrorCode VcWidgetUnsetCurrentLanguageChangedCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_error_cb")]
+ internal static extern ErrorCode VcWidgetSetErrorCb(IntPtr widget, VcWidgetErrorCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_error_cb")]
+ internal static extern ErrorCode VcWidgetUnsetErrorCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_send_current_command_list_cb")]
+ internal static extern ErrorCode VcWidgetSetSendCurrentCommandListCb(IntPtr widget, VcWidgetSendCurrentCommandListCb callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_send_current_command_list_cb")]
+ internal static extern ErrorCode VcWidgetUnSetSendCurrentCommandListCb(IntPtr widget);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_enable_asr_result")]
+ internal static extern ErrorCode VcWidgetEnableAsrResult(IntPtr widget, bool enable);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_set_asr_result_cb")]
+ internal static extern ErrorCode VcWidgetSetAsrResultCb(IntPtr widget, VcWidgetAsrResultCallback callback, IntPtr userData);
+
+ [DllImport(Libraries.VoiceControlWidget, EntryPoint = "vc_widget_unset_asr_result_cb")]
+ internal static extern ErrorCode VcWidgetUnSetAsrResultCb(IntPtr widget);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate bool VcWidgetAsrResultCallback(ResultEvent evt, IntPtr result, IntPtr userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate bool VcWidgetSupportedLanguageCb(IntPtr language, IntPtr userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetShowTooltipCb(bool show, IntPtr userData);
+
+ [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetSendCurrentCommandListCb(out IntPtr listPtr, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetCurrentLanguageChangedCallback(IntPtr previous, IntPtr current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetStateChangedCallback(State previous, State current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetServiceStateChangedCallback(ServiceState previous, ServiceState current, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetErrorCallback(ErrorCode reason, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void VcWidgetResultCallback(ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData);
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\src\Tizen\Tizen.csproj" />
+ <ProjectReference Include="..\..\..\src\Tizen.Log\Tizen.Log.csproj" />
+ </ItemGroup>
+
+</Project>
\ No newline at end of file
--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.16
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Uix.VoiceControlWidget", "Tizen.Uix.VoiceControlWidget.csproj", "{9204FAA1-799E-4109-8E5C-8B0219951530}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\..\..\src\Tizen\Tizen.csproj", "{DC1D4741-6C89-47E6-B039-B715B4EBB171}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\..\..\src\Tizen.Log\Tizen.Log.csproj", "{5D1CB4C3-CC99-440E-8C6F-E8DA387E3F3F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9204FAA1-799E-4109-8E5C-8B0219951530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9204FAA1-799E-4109-8E5C-8B0219951530}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9204FAA1-799E-4109-8E5C-8B0219951530}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9204FAA1-799E-4109-8E5C-8B0219951530}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DC1D4741-6C89-47E6-B039-B715B4EBB171}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DC1D4741-6C89-47E6-B039-B715B4EBB171}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DC1D4741-6C89-47E6-B039-B715B4EBB171}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DC1D4741-6C89-47E6-B039-B715B4EBB171}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D1CB4C3-CC99-440E-8C6F-E8DA387E3F3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D1CB4C3-CC99-440E-8C6F-E8DA387E3F3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D1CB4C3-CC99-440E-8C6F-E8DA387E3F3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D1CB4C3-CC99-440E-8C6F-E8DA387E3F3F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {4DA985A7-0407-40ED-AF02-4009E98085E4}
+ EndGlobalSection
+EndGlobal
--- /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.VoiceControlWidget
+{
+ public class AsrResultEventArgs
+ {
+ internal AsrResultEventArgs(ResultEvent evt, string resultString)
+ {
+ ResultEvent = evt;
+ Result = resultString;
+ }
+
+ public ResultEvent ResultEvent
+ {
+ get;
+ private set;
+ }
+
+ public string Result
+ {
+ get;
+ private 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 System.Collections.Generic;
+using System.Runtime.InteropServices;
+using static Interop.VoiceControlWidget;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ public class CurrentCommandListEventArgs
+ {
+ private VoiceCommandList _list;
+
+ internal CurrentCommandListEventArgs()
+ {
+ _list = new VoiceCommandList();
+ }
+
+ public VoiceCommandList CommandList
+ {
+ get
+ {
+ return _list;
+ }
+ set
+ {
+ _list = value;
+ }
+ }
+ }
+}
--- /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.VoiceControlWidget
+{
+ public class CurrentLanguageChangedEventArgs
+ {
+ internal CurrentLanguageChangedEventArgs(string previous, string current)
+ {
+ PreviousLanguage = previous;
+ CurrentLanguage = current;
+ }
+
+ public string PreviousLanguage
+ {
+ get;
+ internal set;
+ }
+
+ 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.VoiceControlWidget;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ public class ErrorOccurredEventArgs
+ {
+ internal ErrorOccurredEventArgs(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>
+ /// <since_tizen> 3 </since_tizen>
+ 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.VoiceControlWidget;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ 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 OutOfMemoryException("Out Of Memory");
+ break;
+ }
+
+ case ErrorCode.IoError:
+ {
+ exp = new InvalidOperationException("I/O Error Occurred");
+ break;
+ }
+
+ case ErrorCode.InvalidParameter:
+ {
+ exp = new ArgumentException("Invalid Parameters Provided");
+ break;
+ }
+
+ case ErrorCode.TimedOut:
+ {
+ exp = new TimeoutException("No answer from service");
+ break;
+ }
+
+ case ErrorCode.RecorderBusy:
+ {
+ exp = new InvalidOperationException("Recorder is Busy ");
+ break;
+ }
+
+ case ErrorCode.PermissionDenied:
+ {
+ exp = new UnauthorizedAccessException("Permission Denied");
+ break;
+ }
+
+ case ErrorCode.NotSupported:
+ {
+ exp = new NotSupportedException("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.VoiceControlWidget;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ public class RecognitionResult
+ {
+ private ResultEvent _resultEvent;
+ private VoiceCommandList _list;
+ private string _result;
+
+ internal RecognitionResult(ResultEvent evt, IntPtr cmdList, IntPtr result)
+ {
+ _resultEvent = evt;
+ SafeCommandListHandle handle = new SafeCommandListHandle(cmdList);
+ handle._ownership = false;
+ _list = new VoiceCommandList(handle);
+ _result = Marshal.PtrToStringAnsi(result);
+ }
+
+ public ResultEvent Result
+ {
+ get
+ {
+ return _resultEvent;
+ }
+ }
+
+ public string ResultMessage
+ {
+ get
+ {
+ return _result;
+ }
+ }
+
+ 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.VoiceControlWidget
+{
+ public class ServiceStateChangedEventArgs
+ {
+ internal ServiceStateChangedEventArgs(ServiceState previous, ServiceState current)
+ {
+ Previous = previous;
+ Current = current;
+ }
+
+ public ServiceState Previous
+ {
+ get;
+ internal set;
+ }
+
+ 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.VoiceControlWidget
+{
+ public class StateChangedEventArgs
+ {
+ internal StateChangedEventArgs(State previous, State current)
+ {
+ Previous = previous;
+ Current = current;
+ }
+
+ public State Previous
+ {
+ get;
+ internal set;
+ }
+
+ 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 System.Collections.Generic;
+using System.Runtime.InteropServices;
+using static Interop.VoiceControlWidget;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ public class TooltipEventArgs
+ {
+ internal TooltipEventArgs(bool value)
+ {
+ Show = value;
+ }
+
+ public bool Show
+ {
+ get;
+ }
+ }
+}
\ 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 static Interop.VoiceControlCommand;
+using static Interop.VoiceControlWidget;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ /// <summary>
+ /// Enumeration for the command format.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum CommandFormat
+ {
+ /// <summary>
+ /// The fixed command format.
+ /// </summary>
+ Fixed = 0,
+ /// <summary>
+ /// The fixed and variable fixed command format.
+ /// </summary>
+ FixedAndVFixed = 1,
+ /// <summary>
+ /// The variable fixed and fixed command format.
+ /// </summary>
+ VFixedAndFixed = 2,
+ /// <summary>
+ /// The fixed and non-fixed command format.
+ /// </summary>
+ FixedAndNonFixed = 3,
+ /// <summary>
+ /// The non-fixed and fixed command format.
+ /// </summary>
+ NonFixedAndFixed = 4,
+ /// <summary>
+ /// The action command
+ /// </summary>
+ Action = 5,
+ /// <summary>
+ /// The partial matched command
+ /// </summary>
+ Partial = 6,
+ /// <summary>
+ /// Undefined
+ /// </summary>
+ Undefined = -1
+ };
+
+ /// <summary>
+ /// This class represents a voice command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public class VoiceCommand
+ {
+ internal SafeCommandHandle _handle;
+
+ /// <summary>
+ /// The public constructor.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
+ /// <exception cref="OutOfMemoryException">This exception can be due to out Of memory.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</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.
+ /// An empty string will be returned in case of some internal error.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public string UnfixedCommand
+ {
+ get
+ {
+ string unfixedCommand;
+ ErrorCode error = VcCmdGetUnfixedCommand(_handle, out unfixedCommand);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "UnfixedCommand Failed with error " + error);
+ return "";
+ }
+
+ return unfixedCommand;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the command type.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <remarks>If you do not set the command type, the default value is undefined. You should set the type if the command is valid.</remarks>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to 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 or sets the command format.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <remarks>The default format is Fixed.</remarks>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to 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 or sets the command.
+ /// A get empty string will be returned in case of some internal error.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to 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.VoiceControlWidget;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ /// <summary>
+ /// This class represents a list of the voice commands.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public class VoiceCommandList
+ {
+ internal SafeCommandListHandle _handle;
+ private List<VoiceCommand> _list;
+ private VcCmdListCb _callback;
+ private int _index;
+
+ /// <summary>
+ /// The public constructor.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="OutOfMemoryException">This exception can be due to out of memory.</exception>
+ /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public VoiceCommandList()
+ {
+ SafeCommandListHandle handle;
+ ErrorCode error = VcCmdListCreate(out handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Create Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _handle = handle;
+ _list = new List<VoiceCommand>();
+ _index = 0;
+ }
+
+ internal VoiceCommandList(SafeCommandListHandle handle)
+ {
+ _handle = handle;
+ _index = 0;
+
+ _list = new List<VoiceCommand>();
+ _callback = (IntPtr vcCommand, IntPtr userData) =>
+ {
+ SafeCommandHandle cmdHandle = new SafeCommandHandle(vcCommand);
+ cmdHandle._ownership = false;
+ _list.Add(new VoiceCommand(cmdHandle));
+ 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);
+ }
+ }
+
+ /// <summary>
+ /// Gets a command count of the list.
+ /// -1 is returned in case of an internal failure.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <value>
+ /// Command count of the list.
+ /// </value>
+ public int Count
+ {
+ 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>
+ /// Gets the current command from the command list by index.
+ /// Null will be returned in case of an empty list.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <value>
+ /// Current command from the command list.
+ /// </value>
+ public VoiceCommand Current
+ {
+ get
+ {
+ SafeCommandHandle current;
+ ErrorCode error = VcCmdListGetCurrent(_handle, out current);
+ if (ErrorCode.None != error)
+ {
+ Log.Error(LogTag, "Current Failed with error " + error);
+ return null;
+ }
+
+ current._ownership = false;
+ return _list[_index];
+ }
+ }
+
+ /// <summary>
+ /// Adds a command to the command list.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="command">The command</param>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ /// <exception cref="NullReferenceException">This will occur if the provided 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);
+ }
+
+ _list.Add(command);
+ }
+
+ /// <summary>
+ /// Removes a command from the command list.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="command">The command</param>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ /// <exception cref="NullReferenceException">This will occur if the provided 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);
+ }
+
+ _list.Remove(command);
+ }
+
+ /// <summary>
+ /// Retrieves all commands from the command list.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public IEnumerable<VoiceCommand> GetAllCommands()
+ {
+ _callback = (IntPtr vcCommand, IntPtr userData) =>
+ {
+ if (IntPtr.Zero == vcCommand) {
+ Log.Error(LogTag, "Invalid command pointer");
+ return false;
+ }
+ 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 an index to the first command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">This exception can be due to list empty.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public void First()
+ {
+ ErrorCode error = VcCmdListFirst(_handle);
+ if (ErrorCode.None != error)
+ {
+ Log.Error(LogTag, "First Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _index = 0;
+ }
+
+ /// <summary>
+ /// Moves an index to the last command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">This exception can be due to list empty.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public void Last()
+ {
+ ErrorCode error = VcCmdListLast(_handle);
+ if (ErrorCode.None != error)
+ {
+ Log.Error(LogTag, "Last Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _index = Count - 1;
+ }
+
+ /// <summary>
+ /// Moves an index to the next command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">This exception can be due to list empty or list end.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public void Next()
+ {
+ ErrorCode error = VcCmdListNext(_handle);
+ if (ErrorCode.None != error)
+ {
+ Log.Error(LogTag, "Next Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _index++;
+ }
+
+ /// <summary>
+ /// Moves an index to the previous command.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <exception cref="InvalidOperationException">This exception can be due to list empty or list end.</exception>
+ /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
+ /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
+ public void Previous()
+ {
+ ErrorCode error = VcCmdListPrev(_handle);
+ if (ErrorCode.None != error)
+ {
+ Log.Error(LogTag, "Previous Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ _index--;
+ }
+ }
+}
--- /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.VoiceControlWidget;
+using static Interop.VoiceControlCommand;
+
+namespace Tizen.Uix.VoiceControlWidget
+{
+ /// <summary>
+ /// Enumeration for the error values that can occur.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ 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>
+ /// <since_tizen> 3 </since_tizen>
+ public enum State
+ {
+ /// <summary>
+ /// 'None' state.
+ /// </summary>
+ None = 0,
+ /// <summary>
+ /// 'Initialized' state.
+ /// </summary>
+ Initialized = 1,
+ /// <summary>
+ /// 'Ready' state.
+ /// </summary>
+ Ready = 2,
+ /// <summary>
+ /// The state cannot be determined.
+ /// </summary>
+ Unavailable = -1
+ };
+
+ /// <summary>
+ /// Enumeration for the service state.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ 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>
+ /// The state cannot be determined.
+ /// </summary>
+ Unavailable = -1
+ };
+
+ /// <summary>
+ /// Enumeration for the result event.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum ResultEvent
+ {
+ /// <summary>
+ /// Normal result.
+ /// </summary>
+ Success = 0,
+ /// <summary>
+ /// Rejected result.
+ /// </summary>
+ Rejected = 1
+ };
+
+ /// <summary>
+ /// Enumeration for the command type.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum CommandType
+ {
+ /// <summary>
+ /// foreground command type
+ /// </summary>
+ Foreground = 1,
+ /// <summary>
+ /// background command type
+ /// </summary>
+ Background = 2,
+ /// <summary>
+ /// widget command type
+ /// </summary>
+ Widget = 3,
+ /// <summary>
+ /// system command type
+ /// </summary>
+ System = 4,
+ /// <summary>
+ /// system background command type
+ /// </summary>
+ SystemBackground = 5,
+ /// <summary>
+ /// exclusive command type
+ /// </summary>
+ Exclusive = 6,
+ /// <summary>
+ /// Undefined command
+ /// </summary>
+ Undefined = -1
+ };
+
+ /// <summary>
+ /// Enumerations of send event type
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum SendEventType
+ {
+ /// <summary>
+ /// Send text event to vc engine
+ /// </summary>
+ Text,
+ /// <summary>
+ /// Send list event to vc engine
+ /// </summary>
+ ListEvent,
+ /// <summary>
+ /// Send haptic event to vc engine
+ /// </summary>
+ HapticEvent,
+ }
+
+ /// <summary>
+ /// Enumerations of recognition mode
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ public enum RecognitionModeType
+ {
+ /// <summary>
+ /// Default mode
+ /// </summary>
+ StopBySilence,
+ /// <summary>
+ /// Restart recognition after rejected result
+ /// </summary>
+ RestartAfterReject,
+ /// <summary>
+ /// Continuously restart recognition - not support yet
+ /// </summary>
+ RestartContinuously,
+ /// <summary>
+ /// Start and stop manually without silence
+ /// </summary>
+ Manual,
+ /// <summary>
+ /// Undefined
+ /// </summary>
+ Undefined = -1
+ }
+
+ public class VoiceControlWidget
+ {
+ private event EventHandler<StateChangedEventArgs> _stateChanged;
+ private event EventHandler<ServiceStateChangedEventArgs> _serviceStateChanged;
+ private event EventHandler<ErrorOccurredEventArgs> _errorOccurred;
+ private event EventHandler<CurrentLanguageChangedEventArgs> _currentLanguageChanged;
+ private event EventHandler<CurrentCommandListEventArgs> _currentCommandList;
+ private event EventHandler<AsrResultEventArgs> _asrResult;
+ private event EventHandler<TooltipEventArgs> _tooltip;
+ private event EventHandler<RecognitionResult> _recognitionResult;
+ private VcWidgetStateChangedCallback _stateDelegate;
+ private VcWidgetServiceStateChangedCallback _serviceStateDelegate;
+ private VcWidgetErrorCallback _errorDelegate;
+ private VcWidgetCurrentLanguageChangedCallback _languageDelegate;
+ private VcWidgetSendCurrentCommandListCb _currentCommandListDelegate;
+ private VcWidgetAsrResultCallback _asrResultDelegate;
+ private VcWidgetShowTooltipCb _showTooltiptDelegate;
+ private List<string> _supportedLanguages;
+ private IntPtr _handle;
+ private VcWidgetResultCallback _resultDelegate;
+ private VcWidgetSupportedLanguageCb _supportedLanguagesDelegate;
+
+
+ public string CurrentLanguage
+ {
+ get
+ {
+ string currentLanguage;
+
+ ErrorCode error = VcWidgetGetCurrentLanguage(_handle, out currentLanguage);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "CurrentLanaguge Failed with error " + error);
+ return "";
+ }
+
+ return currentLanguage;
+ }
+ }
+
+ public State State
+ {
+ get
+ {
+ State state;
+
+ ErrorCode error = VcWidgetGetState(_handle, out state);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "State Failed with error " + error);
+ return State.Unavailable;
+ }
+
+ return state;
+ }
+ }
+
+ public ServiceState ServiceState
+ {
+ get
+ {
+ ServiceState state;
+
+ ErrorCode error = VcWidgetGetServiceState(_handle, out state);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "ServiceState Failed with error " + error);
+ return ServiceState.Unavailable;
+ }
+
+ return state;
+ }
+ }
+
+ public bool IsCommandFormatSupported(CommandFormat format)
+ {
+ bool supported = false;
+ ErrorCode error = VcWidgetIsCommandFormatSupported(_handle, format, out supported);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "IsCommandFormatSupported Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ return supported;
+ }
+
+ public void SetForeground(bool value)
+ {
+ ErrorCode error = VcWidgetSetForeground(_handle, value);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "SetForeground Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void Cancel()
+ {
+ ErrorCode error = VcWidgetCancel(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Cancel Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void Initialize()
+ {
+ ErrorCode error = VcWidgetInitialize(out _handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Initialize Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void Deinitialize()
+ {
+ ErrorCode error = VcWidgetDeinitialize(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Deinitialize Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void Prepare()
+ {
+ ErrorCode error = VcWidgetPrepare(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Prepare Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void Unprepare()
+ {
+ ErrorCode error = VcWidgetUnprepare(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Unprepare Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public void EnableAsr(bool enable)
+ {
+ ErrorCode error = VcWidgetEnableAsrResult(_handle, enable);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "EnableAsr Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+ }
+
+ public IEnumerable<string> GetSupportedLanguages()
+ {
+ _supportedLanguages = new List<string>();
+ _supportedLanguagesDelegate = (IntPtr language, IntPtr userData) =>
+ {
+ string languageStr = Marshal.PtrToStringAnsi(language);
+ _supportedLanguages.Add(languageStr);
+ return true;
+ };
+ ErrorCode error = VcWidgetForeachSupportedLanguages(_handle, _supportedLanguagesDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetSupportedLanguages Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
+
+ return _supportedLanguages;
+ }
+
+ public event EventHandler<ServiceStateChangedEventArgs> ServiceStateChanged
+ {
+ add
+ {
+ _serviceStateDelegate = (ServiceState previous, ServiceState current, IntPtr userData) =>
+ {
+ ServiceStateChangedEventArgs args = new ServiceStateChangedEventArgs(previous, current);
+ _serviceStateChanged?.Invoke(null, args);
+ };
+ ErrorCode error = VcWidgetSetServiceStateChangedCb(_handle, _serviceStateDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ServiceStateChanged Failed with error " + error);
+ }
+ else
+ {
+ _serviceStateChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnsetServiceStateChangedCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove ServiceStateChanged Failed with error " + error);
+ }
+
+ _serviceStateChanged -= value;
+ }
+ }
+
+ public event EventHandler<StateChangedEventArgs> StateChanged
+ {
+ add
+ {
+ _stateDelegate = (State previous, State current, IntPtr userData) =>
+ {
+ StateChangedEventArgs args = new StateChangedEventArgs(previous, current);
+ _stateChanged?.Invoke(null, args);
+ };
+ ErrorCode error = VcWidgetSetStateChangedCb(_handle, _stateDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add StateChanged Failed with error " + error);
+ }
+ else
+ {
+ _stateChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnsetStateChangedCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove StateChanged Failed with error " + error);
+ }
+
+ _stateChanged -= value;
+ }
+ }
+
+ public event EventHandler<ErrorOccurredEventArgs> ErrorOccurred
+ {
+ add
+ {
+ _errorDelegate = (ErrorCode reason, IntPtr userData) =>
+ {
+ ErrorOccurredEventArgs args = new ErrorOccurredEventArgs(reason);
+ _errorOccurred?.Invoke(null, args);
+ };
+ ErrorCode error = VcWidgetSetErrorCb(_handle, _errorDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ErrorOccurred Failed with error " + error);
+ }
+
+ else
+ {
+ _errorOccurred += value;
+ }
+ }
+
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnsetErrorCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove ErrorOccurred Failed with error " + error);
+ }
+
+ _errorOccurred -= value;
+ }
+ }
+
+ public event EventHandler<CurrentLanguageChangedEventArgs> CurrentLanguageChanged
+ {
+ add
+ {
+ _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 = VcWidgetSetCurrentLanguageChangedCb(_handle, _languageDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add CurrentLanguageChanged Failed with error " + error);
+ }
+
+ else
+ {
+ _currentLanguageChanged += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnsetCurrentLanguageChangedCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove CurrentLanguageChanged Failed with error " + error);
+ }
+
+ _currentLanguageChanged -= value;
+ }
+ }
+
+ public event EventHandler<CurrentCommandListEventArgs> CurrentCommandList
+ {
+ add
+ {
+ _currentCommandListDelegate = (out IntPtr listPtr, IntPtr userData) =>
+ {
+ CurrentCommandListEventArgs args = new CurrentCommandListEventArgs();
+ _currentCommandList?.Invoke(null, args);
+
+ listPtr = args.CommandList._handle.DangerousGetHandle();
+ Log.Debug(LogTag, "Send current Command list");
+ };
+ ErrorCode error = VcWidgetSetSendCurrentCommandListCb(_handle, _currentCommandListDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add CurrentCommandList Failed with error " + error);
+ }
+
+ else
+ {
+ _currentCommandList += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnSetSendCurrentCommandListCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove CurrentCommandList Failed with error " + error);
+ }
+
+ _currentCommandList -= value;
+ }
+ }
+
+ public event EventHandler<AsrResultEventArgs> AsrResult
+ {
+ add
+ {
+ _asrResultDelegate = (ResultEvent evt, IntPtr result, IntPtr userData) =>
+ {
+ string resultString = Marshal.PtrToStringAnsi(result);
+ AsrResultEventArgs args = new AsrResultEventArgs(evt, resultString);
+ _asrResult?.Invoke(null, args);
+ return true;
+ };
+ ErrorCode error = VcWidgetSetAsrResultCb(_handle, _asrResultDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add AsrResult Failed with error " + error);
+ }
+
+ else
+ {
+ _asrResult += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnSetAsrResultCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove AsrResult Failed with error " + error);
+ }
+
+ _asrResult -= value;
+ }
+ }
+
+ public event EventHandler<TooltipEventArgs> ShowTooltip
+ {
+ add
+ {
+ _showTooltiptDelegate = (bool show, IntPtr userData) =>
+ {
+ TooltipEventArgs args = new TooltipEventArgs(show);
+ _tooltip?.Invoke(null, args);
+ };
+ ErrorCode error = VcWidgetSetShowTooltipCb(_handle, _showTooltiptDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add ShowTooltip Failed with error " + error);
+ }
+
+ else
+ {
+ _tooltip += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnSetShowTooltipCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove ShowTooltip Failed with error " + error);
+ }
+
+ _tooltip -= value;
+ }
+ }
+
+ public event EventHandler<RecognitionResult> RecognitionResult
+ {
+ add
+ {
+ _resultDelegate = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
+ {
+ Log.Info(LogTag, "Recognition Result Event Triggered");
+ if ((cmdList != null) && (result != null))
+ {
+ RecognitionResult args = new RecognitionResult(evt, cmdList, result);
+ _recognitionResult?.Invoke(null, args);
+ }
+ else
+ {
+ Log.Info(LogTag, "Recognition Result Event null received");
+ }
+ };
+ ErrorCode error = VcWidgetSetResultCb(_handle, _resultDelegate, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Add RecognitionResult Failed with error " + error);
+ }
+ else
+ {
+ _recognitionResult += value;
+ }
+ }
+
+ remove
+ {
+ ErrorCode error = VcWidgetUnsetResultCb(_handle);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "Remove RecognitionResult Failed with error " + error);
+ }
+
+ _recognitionResult -= value;
+ }
+ }
+ }
+}