122736c2fSopenharmony_ci/* 222736c2fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 322736c2fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 422736c2fSopenharmony_ci * you may not use this file except in compliance with the License. 522736c2fSopenharmony_ci * You may obtain a copy of the License at 622736c2fSopenharmony_ci * 722736c2fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 822736c2fSopenharmony_ci * 922736c2fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1022736c2fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1122736c2fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1222736c2fSopenharmony_ci * See the License for the specific language governing permissions and 1322736c2fSopenharmony_ci * limitations under the License. 1422736c2fSopenharmony_ci */ 1522736c2fSopenharmony_ci#ifndef OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H 1622736c2fSopenharmony_ci#define OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H 1722736c2fSopenharmony_ci/** 1822736c2fSopenharmony_ci * @addtogroup InputMethod 1922736c2fSopenharmony_ci * @{ 2022736c2fSopenharmony_ci * 2122736c2fSopenharmony_ci * @brief InputMethod provides functions to use input methods and develop input methods. 2222736c2fSopenharmony_ci * 2322736c2fSopenharmony_ci * @since 12 2422736c2fSopenharmony_ci */ 2522736c2fSopenharmony_ci 2622736c2fSopenharmony_ci/** 2722736c2fSopenharmony_ci * @file inputmethod_private_command_capi.h 2822736c2fSopenharmony_ci * 2922736c2fSopenharmony_ci * @brief Provides functions to manage private commands. 3022736c2fSopenharmony_ci * 3122736c2fSopenharmony_ci * @library libohinputmethod.so 3222736c2fSopenharmony_ci * @kit IMEKit 3322736c2fSopenharmony_ci * @syscap SystemCapability.MiscServices.InputMethodFramework 3422736c2fSopenharmony_ci * @since 12 3522736c2fSopenharmony_ci * @version 1.0 3622736c2fSopenharmony_ci */ 3722736c2fSopenharmony_ci#include <stddef.h> 3822736c2fSopenharmony_ci#include <stdint.h> 3922736c2fSopenharmony_ci 4022736c2fSopenharmony_ci#include "inputmethod_types_capi.h" 4122736c2fSopenharmony_ci#ifdef __cplusplus 4222736c2fSopenharmony_ciextern "C" { 4322736c2fSopenharmony_ci#endif /* __cplusplus */ 4422736c2fSopenharmony_ci/** 4522736c2fSopenharmony_ci * @brief Define the InputMethod_PrivateCommand structure type. 4622736c2fSopenharmony_ci * 4722736c2fSopenharmony_ci * The private command between text editor and input method. 4822736c2fSopenharmony_ci * 4922736c2fSopenharmony_ci * @since 12 5022736c2fSopenharmony_ci */ 5122736c2fSopenharmony_citypedef struct InputMethod_PrivateCommand InputMethod_PrivateCommand; 5222736c2fSopenharmony_ci 5322736c2fSopenharmony_ci/** 5422736c2fSopenharmony_ci * @brief Create a new {@link InputMethod_PrivateCommand} instance. 5522736c2fSopenharmony_ci * 5622736c2fSopenharmony_ci * @param key The key of the private command. 5722736c2fSopenharmony_ci * @param keyLength The length of the key. 5822736c2fSopenharmony_ci * @return If the creation succeeds, a pointer to the newly created {@link InputMethod_PrivateCommand} 5922736c2fSopenharmony_ci * instance is returned. If the creation fails, NULL is returned, possible cause is insufficient memory. 6022736c2fSopenharmony_ci * @since 12 6122736c2fSopenharmony_ci */ 6222736c2fSopenharmony_ciInputMethod_PrivateCommand *OH_PrivateCommand_Create(char key[], size_t keyLength); 6322736c2fSopenharmony_ci/** 6422736c2fSopenharmony_ci * @brief Destroy a {@link InputMethod_PrivateCommand} instance. 6522736c2fSopenharmony_ci * 6622736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be destroyed. 6722736c2fSopenharmony_ci * @since 12 6822736c2fSopenharmony_ci */ 6922736c2fSopenharmony_civoid OH_PrivateCommand_Destroy(InputMethod_PrivateCommand *command); 7022736c2fSopenharmony_ci/** 7122736c2fSopenharmony_ci * @brief Set key value into {@link InputMethod_PrivateCommand}. 7222736c2fSopenharmony_ci * 7322736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. 7422736c2fSopenharmony_ci * @param key Represents key value. 7522736c2fSopenharmony_ci * @param keyLength Represents key length. 7622736c2fSopenharmony_ci * @return Returns a specific error code. 7722736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 7822736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 7922736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 8022736c2fSopenharmony_ci * @since 12 8122736c2fSopenharmony_ci */ 8222736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_SetKey(InputMethod_PrivateCommand *command, char key[], size_t keyLength); 8322736c2fSopenharmony_ci/** 8422736c2fSopenharmony_ci * @brief Set bool data value into {@link InputMethod_PrivateCommand}. 8522736c2fSopenharmony_ci * 8622736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. 8722736c2fSopenharmony_ci * @param value Represents bool data value. 8822736c2fSopenharmony_ci * @return Returns a specific error code. 8922736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 9022736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 9122736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 9222736c2fSopenharmony_ci * @since 12 9322736c2fSopenharmony_ci */ 9422736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_SetBoolValue(InputMethod_PrivateCommand *command, bool value); 9522736c2fSopenharmony_ci/** 9622736c2fSopenharmony_ci * @brief Set integer data value into {@link InputMethod_PrivateCommand}. 9722736c2fSopenharmony_ci * 9822736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. 9922736c2fSopenharmony_ci * @param value Represents integer data value. 10022736c2fSopenharmony_ci * @return Returns a specific error code. 10122736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 10222736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 10322736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 10422736c2fSopenharmony_ci * @since 12 10522736c2fSopenharmony_ci */ 10622736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_SetIntValue(InputMethod_PrivateCommand *command, int32_t value); 10722736c2fSopenharmony_ci/** 10822736c2fSopenharmony_ci * @brief Set string data value into {@link InputMethod_PrivateCommand}. 10922736c2fSopenharmony_ci * 11022736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be set value. 11122736c2fSopenharmony_ci * @param value Represents string data value. 11222736c2fSopenharmony_ci * @param valueLength Represents the length of string data value. 11322736c2fSopenharmony_ci * @return Returns a specific error code. 11422736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 11522736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 11622736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 11722736c2fSopenharmony_ci * @since 12 11822736c2fSopenharmony_ci */ 11922736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_SetStrValue( 12022736c2fSopenharmony_ci InputMethod_PrivateCommand *command, char value[], size_t valueLength); 12122736c2fSopenharmony_ci 12222736c2fSopenharmony_ci/** 12322736c2fSopenharmony_ci * @brief Get key value from {@link InputMethod_PrivateCommand}. 12422736c2fSopenharmony_ci * 12522736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. 12622736c2fSopenharmony_ci * @param key Represents key value. 12722736c2fSopenharmony_ci * @param keyLength Represents key length. 12822736c2fSopenharmony_ci * @return Returns a specific error code. 12922736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 13022736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 13122736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 13222736c2fSopenharmony_ci * @since 12 13322736c2fSopenharmony_ci */ 13422736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_GetKey( 13522736c2fSopenharmony_ci InputMethod_PrivateCommand *command, const char **key, size_t *keyLength); 13622736c2fSopenharmony_ci/** 13722736c2fSopenharmony_ci * @brief Get value type from {@link InputMethod_PrivateCommand}. 13822736c2fSopenharmony_ci * 13922736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. 14022736c2fSopenharmony_ci * @param type Represents a pointer to a {@link InputMethod_CommandValueType} instance. Indicates the data type of the 14122736c2fSopenharmony_ci * value. 14222736c2fSopenharmony_ci * @return Returns a specific error code. 14322736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 14422736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 14522736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 14622736c2fSopenharmony_ci * @since 12 14722736c2fSopenharmony_ci */ 14822736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_GetValueType( 14922736c2fSopenharmony_ci InputMethod_PrivateCommand *command, InputMethod_CommandValueType *type); 15022736c2fSopenharmony_ci/** 15122736c2fSopenharmony_ci * @brief Get bool data value from {@link InputMethod_PrivateCommand}. 15222736c2fSopenharmony_ci * 15322736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. 15422736c2fSopenharmony_ci * @param value Represents bool data value. 15522736c2fSopenharmony_ci * @return Returns a specific error code. 15622736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 15722736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 15822736c2fSopenharmony_ci * {@link IME_ERR_QUERY_FAILED} - query failed, no bool value in command. 15922736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 16022736c2fSopenharmony_ci * @since 12 16122736c2fSopenharmony_ci */ 16222736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_GetBoolValue(InputMethod_PrivateCommand *command, bool *value); 16322736c2fSopenharmony_ci/** 16422736c2fSopenharmony_ci * @brief Get integer data value from {@link InputMethod_PrivateCommand}. 16522736c2fSopenharmony_ci * 16622736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. 16722736c2fSopenharmony_ci * @param value Represents integer data value. 16822736c2fSopenharmony_ci * @return Returns a specific error code. 16922736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 17022736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 17122736c2fSopenharmony_ci * {@link IME_ERR_QUERY_FAILED} - query failed, no integer value in command. 17222736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 17322736c2fSopenharmony_ci * @since 12 17422736c2fSopenharmony_ci */ 17522736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_GetIntValue(InputMethod_PrivateCommand *command, int32_t *value); 17622736c2fSopenharmony_ci/** 17722736c2fSopenharmony_ci * @brief Get string data value from {@link InputMethod_PrivateCommand}. 17822736c2fSopenharmony_ci * 17922736c2fSopenharmony_ci * @param command Represents a pointer to an {@link InputMethod_PrivateCommand} instance which will be get value from. 18022736c2fSopenharmony_ci * @param value Represents string data value. 18122736c2fSopenharmony_ci * @param valueLength Represents the length of string data value. 18222736c2fSopenharmony_ci * @return Returns a specific error code. 18322736c2fSopenharmony_ci * {@link IME_ERR_OK} - success. 18422736c2fSopenharmony_ci * {@link IME_ERR_NULL_POINTER} - unexpected null pointer. 18522736c2fSopenharmony_ci * {@link IME_ERR_QUERY_FAILED} - query failed, no string value in command. 18622736c2fSopenharmony_ci * Specific error codes can be referenced {@link InputMethod_ErrorCode}. 18722736c2fSopenharmony_ci * @since 12 18822736c2fSopenharmony_ci */ 18922736c2fSopenharmony_ciInputMethod_ErrorCode OH_PrivateCommand_GetStrValue( 19022736c2fSopenharmony_ci InputMethod_PrivateCommand *command, const char **value, size_t *valueLength); 19122736c2fSopenharmony_ci#ifdef __cplusplus 19222736c2fSopenharmony_ci} 19322736c2fSopenharmony_ci#endif /* __cplusplus */ 19422736c2fSopenharmony_ci/** @} */ 19522736c2fSopenharmony_ci#endif // OHOS_INPUTMETHOD_PRIVATE_COMMAND_CAPI_H