예제 #1
0
        /// <summary>
        /// Retrieves all the 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>
        /// <since_tizen> 3 </since_tizen>
        /// <privilege>
        /// http://tizen.org/privilege/recorder
        /// </privilege>
        /// <privlevel>
        /// public
        /// </privlevel>
        /// <feature>
        /// http://tizen.org/feature/speech.control
        /// http://tizen.org/feature/microphone
        /// </feature>
        /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
        /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
        /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
        /// <pre>
        /// The state must be ready or initialized.
        /// </pre>
        public static IEnumerable <string> GetSupportedLanguages()
        {
            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, "GetSupportedLanguages Failed with error " + error);
                throw ExceptionFactory.CreateException(error);
            }

            return(s_supportedLanguages);
        }
예제 #2
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);
            }
        }
예제 #3
0
        /// <summary>
        /// Retrieves all commands from the command list.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <privilege>
        /// http://tizen.org/privilege/recorder
        /// </privilege>
        /// <privlevel>
        /// public
        /// </privlevel>
        /// <feature>
        /// http://tizen.org/feature/speech.control
        /// http://tizen.org/feature/microphone
        /// </feature>
        /// <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);
        }
예제 #4
0
        /// <summary>
        /// Gets the system command list.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>
        /// The command list, else null in case of no system commands.
        /// </returns>
        /// <privilege>
        /// http://tizen.org/privilege/recorder
        /// </privilege>
        /// <privlevel>
        /// public.
        /// </privlevel>
        /// <feature>
        /// http://tizen.org/feature/speech.control
        /// http://tizen.org/feature/microphone
        /// </feature>
        /// <remarks>
        /// In the system command list, there are system commands predefined by product manufacturers.
        /// Those commands have the highest priority. Therefore, the user cannot set any commands similar to system commands.
        /// </remarks>
        /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
        /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
        /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
        /// <pre>
        /// The state must be ready.
        /// </pre>
        public static VoiceCommandList GetSystemCommandList()
        {
            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));
        }
예제 #5
0
        /// <summary>
        /// Unsets the command list.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <privilege>
        /// http://tizen.org/privilege/recorder
        /// </privilege>
        /// <privlevel>
        /// public
        /// </privlevel>
        /// <feature>
        /// http://tizen.org/feature/speech.control
        /// http://tizen.org/feature/microphone
        /// </feature>
        /// <param name="type">Command type</param>
        /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
        /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
        /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
        /// <pre>
        /// The state should be ready.
        /// </pre>
        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);
            }
        }