REMOTE_INPUT_RESOURCE_REMOTE, /**< Input event from remote input API */
} remote_input_resource_e;
+/**
+ * @platform
+ * @brief Enumeration for connection status.
+ * @since_tizen 10.0
+ * @see remote_input_connection_status_changed_cb()
+ */
+typedef enum {
+ REMOTE_INPUT_CONNECTION_STATUS_CONNECTED = 0, /**< Connected */
+ REMOTE_INPUT_CONNECTION_STATUS_REJECTED, /**< Rejected */
+} remote_input_connection_status_e;
+
/**
* @platform
* @brief Handle of the remote input.
*/
typedef void (*remote_input_cursor_position_updated_cb)(int cursor_pos, void *user_data);
+/**
+ * @platform
+ * @brief Called when the connection status is changed.
+ * @since_tizen 10.0
+ * @param[in] remote_handle The remote input handle
+ * @param[in] status The connection status
+ * @param[in] user_data User data to be passed to the callback function
+ * @pre The callback can be registered using remote_input_async_create() function.
+ * @see remote_input_async_create()
+ */
+typedef void (*remote_input_connection_status_changed_cb)(remote_input_h remote_handle, remote_input_connection_status_e status, void *user_data);
+
/**
* @platform
* @brief Creates a remote input handle.
*/
int remote_input_cursor_position_updated_callback_unset(remote_input_h remote_handle);
+/**
+ * @platform
+ * @brief Sets a callback function to handle asynchronous creation of a remote input handle.
+ * @since_tizen 10.0
+ * @param[in] callback A callback function to receive the remote control client asynchronously
+ * @param[in] user_data User data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #REMOTE_INPUT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int remote_input_async_create(remote_input_connection_status_changed_cb callback, void *user_data);
/**
* @}
void *key_event_cb_user_data;
remote_input_cursor_position_updated_cb cursor_position_updated_cb;
void *cursor_position_updated_cb_user_data;
+ remote_input_connection_status_changed_cb connection_status_changed_cb;
+ void *connection_status_changed_cb_user_data;
};
#endif /* __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ */
remote_handle->cursor_position_updated_cb(cursor_pos, remote_handle->text_updated_cb_user_data);
}
}
+
+static void _async_create_cb(void *user_data, remote_control_client *client, remote_control_connection_status_e status)
+{
+ remote_input_h remote_handle = (remote_input_h)user_data;
+
+ if (remote_handle == NULL) {
+ LOGE("remote handle is not available");
+ return;
+ }
+
+ remote_handle->remote_client = client;
+
+ if (remote_handle->connection_status_changed_cb) {
+ remote_handle->connection_status_changed_cb(status == REMOTE_CONTROL_CONNECTION_STATUS_CONNECTED ? remote_handle : NULL,
+ (remote_input_connection_status_e)status, remote_handle->connection_status_changed_cb_user_data);
+ }
+
+ if (status == REMOTE_CONTROL_CONNECTION_STATUS_REJECTED) {
+ free(remote_handle);
+ remote_handle = NULL;
+ }
+}
//LCOV_EXCL_STOP
EXPORT_API int remote_input_create(remote_input_h *remote_handle)
remote_handle->cursor_position_updated_cb_user_data = NULL;
return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_async_create(remote_input_connection_status_changed_cb callback, void *user_data)
+{
+ remote_input_error_e ret = REMOTE_INPUT_ERROR_NONE;
+
+ if (!callback) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _remote_check_privilege();
+ if (ret != REMOTE_INPUT_ERROR_NONE) {
+ LOGE("REMOTE_INPUT_ERROR_PERMISSION_DENIED");
+ return ret;
+ }
+
+ struct remote_input_s *remote_input = (remote_input_h)calloc(1, sizeof(struct remote_input_s));
+ if (!remote_input) {
+ LOGE("REMOTE_INPUT_ERROR_OUT_OF_MEMORY");
+ return REMOTE_INPUT_ERROR_OUT_OF_MEMORY;
+ }
+
+ remote_input_h remote_handle = (remote_input_h)remote_input;
+ remote_control_async_connect(_async_create_cb, (void *)remote_handle);
+ remote_handle->connection_status_changed_cb = callback;
+ remote_handle->connection_status_changed_cb_user_data = user_data;
+
+ return ret;
}
\ No newline at end of file
EXPECT_EQ(ret, REMOTE_INPUT_ERROR_INVALID_PARAMETER);
}
+TEST_F(RemoteInputTest, remote_input_async_create_n)
+{
+ int ret = remote_input_async_create(NULL, NULL);
+ EXPECT_EQ(ret, REMOTE_INPUT_ERROR_INVALID_PARAMETER);
+}
+
} // namespace
//LCOV_EXCL_STOP