--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ */
+
+#ifndef __RPC_PORT_DOC_H__
+#define __RPC_PORT_DOC_H__
+
+
+/**
+ * @ingroup CAPI_APPLICATION_FRAMEWORK
+ * @defgroup CAPI_RPC_PORT_MODULE RPC Port
+ * @brief The @ref CAPI_RPC_PORT_MODULE API provides functions to send and receive messages between applications.
+ * @section CAPI_RPC_PORT_MODULE_HEADER Required Header
+ * \#include <rpc-port.h>
+ *
+ * @section CAPI_RPC_PORT_MODULE_OVERVIEW Overview
+ * The @ref CAPI_RPC_PORT_MODULE API provides functions for passing messages between applications.
+ * Applications can read and write data by using rpc-port.
+*/
+
+/**
+ * @ingroup CAPI_RPC_PORT_MODULE
+ * @defgroup CAPI_RPC_PORT_PARCEL_MODULE RPC Port Parcel
+ * @brief The @ref CAPI_RPC_PORT_PRCEL_MODULE API provides functions to make parcel data
+ * @section CAPI_PACKAGE_INFO_MODULE_HEADER Required Header
+ * \#include <rpc-port-parcel.h>
+ *
+ * @section CAPI_RPC_PORT_PARCEL_MODULE_OVERVIEW Overview
+ * It is container for a data that can be sent via RPCPort.
+*/
+
+
+#endif /* __RPC_PORT_DOC_H__ */
* limitations under the License.
*/
-#ifndef __RPC_PORT_INTERNAL_INCLUDE_H__
-#define __RPC_PORT_INTERNAL_INCLUDE_H__
+#ifndef __TIZEN_APPFW_RPC_PORT_INTERNAL_INCLUDE_H__
+#define __TIZEN_APPFW_RPC_PORT_INTERNAL_INCLUDE_H__
#include <rpc-port.h>
}
#endif
-#endif /* __RPC_PORT_INTERNAL_INCLUDE_H__ */
+#endif /* __TIZEN_APPFW_RPC_PORT_INTERNAL_INCLUDE_H__ */
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
* limitations under the License.
*/
-#ifndef __RPC_PORT_PARCEL_INCLUDE_H__
-#define __RPC_PORT_PARCEL_INCLUDE_H__
+#ifndef __TIZEN_APPFW_RPC_PORT_PARCEL_INCLUDE_H__
+#define __TIZEN_APPFW_RPC_PORT_PARCEL_INCLUDE_H__
#include <stdbool.h>
#include <bundle.h>
extern "C" {
#endif
+/**
+ * @addtogroup CAPI_RPC_PORT_PARCEL_MODULE
+ * @{
+ */
+
+/**
+ * @brief The rpc port parcel handle.
+ * @since_tizen 5.0
+ */
typedef void *rpc_port_parcel_h;
+
+/**
+ * @brief The interface for converting data to/from a parcel.
+ * @since_tizen 5.0
+ */
typedef struct __rpc_port_parcelable {
void (*to)(rpc_port_parcel_h h, void *data);
void (*from)(rpc_port_parcel_h h, void *data);
} rpc_port_parcelable_t;
+/**
+ * @brief Creates a rpc port parcel handle.
+ * @since_tizen 5.0
+ * @remarks You must release @a h using rpc_port_parcel_destroy().
+ * @param[out] h The rpc port parcel handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @see rpc_port_parcel_destroy()
+ */
int rpc_port_parcel_create(rpc_port_parcel_h *h);
+
+/**
+ * @brief Creates a rpc port parcel handle from port.
+ * @details Creates a rpc port parcel handle using read data from the port.
+ * It calls rpc_port_read() internally.
+ * @since_tizen 5.0
+ * @remarks You must release @a h using rpc_port_parcel_destroy().
+ * @param[out] h The rpc port parcel handle that is newly created
+ * @param[in] port The rpc port handle for creating handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ * @see rpc_port_parcel_destroy()
+ * @see rpc_port_parcel_send()
+ */
int rpc_port_parcel_create_from_port(rpc_port_parcel_h *h, rpc_port_h port);
+
+/**
+ * @brief Sends parcel data through the port.
+ * @details Sends parcel data through the port. It calls rpc_port_write()
+ * internally.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle that is newly created
+ * @param[in] port The rpc port handle for writing data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ * @see rpc_port_parcel_create_from_port()
+ */
int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port);
+
+/**
+ * @brief Destroys a rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_create()
+ */
int rpc_port_parcel_destroy(rpc_port_parcel_h h);
+
+/**
+ * @brief Writes a byte value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] b Byte data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_byte()
+ */
int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b);
+
+/**
+ * @brief Writes a short value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] i short data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_int16()
+ */
int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i);
+
+/**
+ * @brief Writes a integer value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] i int data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_int32()
+ */
int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i);
+
+/**
+ * @brief Writes a long long integer value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] i long long data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_int64()
+ */
int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i);
+
+/**
+ * @brief Writes a floating point value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] f float data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_float()
+ */
int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f);
+
+/**
+ * @brief Writes a double precision floating point value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] d double data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_double()
+ */
int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d);
+
+/**
+ * @brief Writes a string value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] str string data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_string()
+ */
int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char *str);
+
+/**
+ * @brief Writes a boolean value into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] b boolean data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_bool()
+ */
int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b);
+
+/**
+ * @brief Writes a bundle data into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] b Bundle data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_bundle()
+ */
int rpc_port_parcel_write_bundle(rpc_port_parcel_h h, bundle *b);
+
+/**
+ * @brief Writes a count for array into rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] count Array count
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read_array_count()
+ */
int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count);
+
+/**
+ * @brief Writes the data into parcel handle using @a parcelable.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] parcelable The interface to write the data into parcel handle
+ * @param[in] data Data which write into parcel
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_read()
+ */
int rpc_port_parcel_write(rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable, void *data);
+
+/**
+ * @brief Reads a byte value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] b Byte data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_byte()
+ */
int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char *b);
+
+/**
+ * @brief Reads a short value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] i short data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_int16()
+ */
int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short *i);
+
+/**
+ * @brief Reads a integer value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] i int data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_int32()
+ */
int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int *i);
+
+/**
+ * @brief Reads a long long integer value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] i long long data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_int64()
+ */
int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long *i);
+
+/**
+ * @brief Reads a floating point value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] f float data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_float()
+ */
int rpc_port_parcel_read_float(rpc_port_parcel_h h, float *f);
+
+/**
+ * @brief Reads a double precision floating point value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] d double data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_double()
+ */
int rpc_port_parcel_read_double(rpc_port_parcel_h h, double *d);
+
+/**
+ * @brief Reads a string value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @remarks The @a str should be released using free().
+ * @param[in] h The rpc port parcel handle
+ * @param[out] str string data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_string()
+ */
int rpc_port_parcel_read_string(rpc_port_parcel_h h, char **str);
+
+/**
+ * @brief Reads a boolean value from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] b boolean data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_bool()
+ */
int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool *b);
+
+/**
+ * @brief Reads a bundle data from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @remarks The @a b should be released using bundle_free().
+ * @param[in] h The rpc port parcel handle
+ * @param[out] b Bundle data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_bundle()
+ */
int rpc_port_parcel_read_bundle(rpc_port_parcel_h h, bundle **b);
+
+/**
+ * @brief Reads a count for array from rpc port parcel handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[out] count Array count
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write_array_count()
+ */
int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int *count);
+
+/**
+ * @brief Reads a parcel from the data using @a parcelable.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port parcel handle
+ * @param[in] parcelable The interface to get data from parcel handle
+ * @param[in] data Data which get from parcel
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_parcel_write()
+ */
int rpc_port_parcel_read(rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable, void *data);
+/**
+ * @}
+ */
+
#ifdef __cplusplus
}
#endif
-#endif // __RPC_PORT_PARCEL_INCLUDE_H__
+#endif // __TIZEN_APPFW_RPC_PORT_PARCEL_INCLUDE_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
* limitations under the License.
*/
-#ifndef __RPC_PORT_INCLUDE_H__
-#define __RPC_PORT_INCLUDE_H__
+#ifndef __TIZEN_APPFW_RPC_PORT_INCLUDE_H__
+#define __TIZEN_APPFW_RPC_PORT_INCLUDE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
+#include <tizen_error.h>
-/* common */
+/**
+ * @addtogroup CAPI_RPC_PORT_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Enumeration for error codes of a rpc port.
+ * @since_tizen 4.0
+ */
+typedef enum {
+ RPC_PORT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ RPC_PORT_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
+ RPC_PORT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ RPC_PORT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ RPC_PORT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+} rpc_port_error_e;
+
+/* Common */
+
+/**
+ * @brief The rpc port handle.
+ * @since_tizen 5.0
+ */
typedef void *rpc_port_h;
+
+/**
+ * @brief Reads data from an RPC port.
+ * @since_tizen 5.0
+ *
+ * @param[in] h The rpc port handle
+ * @param[out] buf Buffer for reading data
+ * @param[in] size Size for reading data
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ * @see rpc_port_write()
+ */
int rpc_port_read(rpc_port_h h, void *buf, unsigned int size);
+
+/**
+ * @brief Writes data to an RPC port.
+ * @since_tizen 5.0
+ *
+ * @param[in] h The rpc port handle
+ * @param[in] buf Buffer for writing data
+ * @param[in] size Size for writing data
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ * @see rpc_port_read()
+ */
int rpc_port_write(rpc_port_h h, const void *buf, unsigned int size);
-/* proxy */
-typedef void (*rpc_port_proxy_connected_event_cb)(const char *ep,
- const char *port_name, rpc_port_h port, void *data);
-typedef void (*rpc_port_proxy_disconnected_event_cb)(const char *ep,
- const char *port_name, void *data);
-typedef void (*rpc_port_proxy_rejected_event_cb)(const char *ep,
- const char *port_name, void *data);
-typedef void (*rpc_port_proxy_received_event_cb)(const char *ep,
- const char *port_name, void *data);
+
+/* Proxy */
+
+/**
+ * @brief Called when the proxy is connected.
+ * @details The function is called when the proxy is connected with stub by port.
+ * @since_tizen 5.0
+ * @param[in] receiver The target stub app id
+ * @param[in] port_name The name of the port
+ * @param[in] port The rpc port handle for reading and writing
+ * @param[in] user_data The user data passed from the register function
+ */
+typedef void (*rpc_port_proxy_connected_event_cb)(const char *receiver,
+ const char *port_name, rpc_port_h port, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected.
+ * @details The function is called when the proxy is disconnected from stub.
+ * @since_tizen 5.0
+ * @param[in] receiver The target stub app id
+ * @param[in] port_name The name of the port
+ * @param[in] user_data The user data passed from the register function
+ */
+typedef void (*rpc_port_proxy_disconnected_event_cb)(const char *receiver,
+ const char *port_name, void *user_data);
+
+/**
+ * @brief Called when the proxy is rejected.
+ * @details The function is called when the proxy is rejected to connect stub.
+ * @since_tizen 5.0
+ * @param[in] receiver The target stub app id
+ * @param[in] port_name The name of the port
+ * @param[in] user_data The user data passed from the register function
+ */
+typedef void (*rpc_port_proxy_rejected_event_cb)(const char *receiver,
+ const char *port_name, void *user_data);
+
+/**
+ * @brief Called when the proxy received data.
+ * @details The function is called when the proxy received data from stub.
+ * @since_tizen 5.0
+ * @param[in] receiver The target stub app id
+ * @param[in] port_name The name of the port
+ * @param[in] user_data The user data passed from the register function
+ */
+typedef void (*rpc_port_proxy_received_event_cb)(const char *receiver,
+ const char *port_name, void *user_data);
+
+/**
+ * @brief The rpc port proxy handle.
+ * @since_tizen 5.0
+ */
typedef void *rpc_port_proxy_h;
+
+/**
+ * @brief Creates a rpc port proxy handle.
+ * @since_tizen 5.0
+ * @remarks You must release @a h using rpc_port_proxy_destroy().
+ * @param[out] h The rpc port proxy handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @see rpc_port_proxy_destroy()
+ */
int rpc_port_proxy_create(rpc_port_proxy_h *h);
+
+/**
+ * @brief Destroys a rpc port proxy handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port proxy handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_proxy_create()
+ */
int rpc_port_proxy_destroy(rpc_port_proxy_h h);
+
+/**
+ * @brief Connects to @a port of @a appid.
+ * @details To send and receive data, the proxy should connect to port of stub
+ * @since_tizen 5.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/appmanager.launch \n
+ * %http://tizen.org/privilege/datasharing
+ * @remarks If you want to use this function, you must add privileges.
+ * @param[in] h The rpc port proxy handle
+ * @param[in] appid The target stub appid
+ * @param[in] port The name of rpc port
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ */
int rpc_port_proxy_connect(rpc_port_proxy_h h, const char *appid,
const char *port);
+/**
+ * @brief Adds a proxy connected callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port proxy handle
+ * @param[in] cb The callback function to be called when proxy is connected
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_proxy_connected_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_connected_event_cb cb, void *data);
+ rpc_port_proxy_connected_event_cb cb, void *user_data);
+
+/**
+ * @brief Adds a proxy disconnected callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port proxy handle
+ * @param[in] cb The callback function to be called when proxy is disconnected
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_proxy_disconnected_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_proxy_add_disconnected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_disconnected_event_cb cb, void *data);
+ rpc_port_proxy_disconnected_event_cb cb, void *user_data);
+
+/**
+ * @brief Adds a proxy rejected callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port proxy handle
+ * @param[in] cb The callback function to be called when proxy is rejected
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_proxy_rejected_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_proxy_add_rejected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_rejected_event_cb cb, void *data);
+ rpc_port_proxy_rejected_event_cb cb, void *user_data);
+
+/**
+ * @brief Adds a proxy received callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port proxy handle
+ * @param[in] cb The callback function to be called when proxy received data
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_proxy_received_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_proxy_add_received_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_received_event_cb cb, void *data);
+ rpc_port_proxy_received_event_cb cb, void *user_data);
-/* stub */
+/* Stub */
+
+/**
+ * @brief The rpc port stub handle.
+ * @since_tizen 5.0
+ */
typedef void *rpc_port_stub_h;
+
+/**
+ * @brief Called when the proxy is connected with stub.
+ * @details The function is called when the proxy is connected with stub.
+ * When a proxy connects to stub several times with new port,
+ * you can handle each request by using @a instance.
+ * @since_tizen 5.0
+ * @param[in] sender The target proxy app id
+ * @param[in] instance The information of the request
+ * @param[in] user_data The user data passed from the register function
+ */
typedef void (*rpc_port_stub_connected_event_cb)(const char *sender,
- const char *instance, void *data);
+ const char *instance, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected from stub.
+ * @details The function is called when the proxy is disconnected from stub.
+ * When a proxy is disconnected, you can check the request
+ * by using @a instance.
+ * @since_tizen 5.0
+ * @param[in] sender The target proxy app id
+ * @param[in] instance The information of the request
+ * @param[in] user_data The user data passed from the register function
+ */
typedef void (*rpc_port_stub_disconnected_event_cb)(const char *sender,
- const char *instance, void *data);
+ const char *instance, void *user_data);
+
+/**
+ * @brief Called when the stub received data from proxy.
+ * @details The function is called when the stub received data from stub.
+ * When a stub received data from several ports, you can handle
+ * each request by using @a instance.
+ * @since_tizen 5.0
+ * @param[in] sender The target proxy app id
+ * @param[in] instance The information of the request
+ * @param[in] port The rpc port handle for reading and writing
+ * @param[in] user_data The user data passed from the register function
+ */
typedef int (*rpc_port_stub_received_event_cb)(const char *sender,
- const char *instance, rpc_port_h port, void *data);
+ const char *instance, rpc_port_h port, void *user_data);
+
+/**
+ * @brief Creates a rpc port stub handle.
+ * @since_tizen 5.0
+ * @remarks You must release @a h using rpc_port_stub_destroy().
+ * @param[out] h The rpc port stub handle that is newly created
+ * @param[in] port_name The name of the port which want to listen
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_stub_destroy()
+ */
int rpc_port_stub_create(rpc_port_stub_h *h, const char *port_name);
+
+/**
+ * @brief Destroys a rpc port stub handle.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @see rpc_port_stub_create()
+ */
int rpc_port_stub_destroy(rpc_port_stub_h h);
+
+/**
+ * @brief Listens to the requests for connections.
+ * @details The stub listens requests to connect by port
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ * @retval #RPC_PORT_ERROR_IO_ERROR Internal I/O error
+ */
int rpc_port_stub_listen(rpc_port_stub_h h);
+
+/**
+ * @brief Adds a privilege to the stub.
+ * @details The stub can control access to the port using tizen privilege.
+ * It allows connections only if the proxy which have the privileges.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @param[in] privilege The privilege to access this stub
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_stub_add_privilege(rpc_port_stub_h h, const char *privilege);
+
+/**
+ * @brief Sets trusted to the stub.
+ * @details The stub can control access to the port using tizen certificate.
+ * It allows connections only if the proxy is signed with the same
+ * certificate.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @param[in] trusted Whether stub allows only trusted proxy or not
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_stub_set_trusted(rpc_port_stub_h h, const bool trusted);
+
+/**
+ * @brief Adds a stub connected callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc stub stub handle
+ * @param[in] cb The callback function to be called when proxy is connected
+ * with the stub
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_stub_connected_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_stub_add_connected_event_cb(rpc_port_stub_h h,
- rpc_port_stub_connected_event_cb cb, void *data);
+ rpc_port_stub_connected_event_cb cb, void *user_data);
+
+/**
+ * @brief Adds a stub disconnected callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @param[in] cb The callback function to be called when proxy is disconnected
+ * with the stub
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_stub_disconnected_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_stub_add_disconnected_event_cb(rpc_port_stub_h h,
- rpc_port_stub_disconnected_event_cb cb, void *data);
+ rpc_port_stub_disconnected_event_cb cb, void *user_data);
+
+/**
+ * @brief Adds a stub received callback.
+ * @since_tizen 5.0
+ * @param[in] h The rpc port stub handle
+ * @param[in] cb The callback function to be called when stub received data
+ * @param[in] user_data The user data to be passed to
+ * the rpc_port_stub_received_event_cb() function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER The specified @a h is NULL
+ */
int rpc_port_stub_add_received_event_cb(rpc_port_stub_h h,
- rpc_port_stub_received_event_cb cb, void *data);
+ rpc_port_stub_received_event_cb cb, void *user_data);
+
+/**
+ * @}
+ */
#ifdef __cplusplus
}
#endif
-#endif /* __RPC_PORT_INCLUDE_H__ */
+#endif /* __TIZEN_APPFW_RPC_PORT_INCLUDE_H__ */
#include <uuid/uuid.h>
#include <dlog.h>
+#include "rpc-port.h"
#include "port-internal.h"
#ifdef LOG_TAG
nb = read(fd_, buffer, left);
if (nb == 0) {
LOGE("read_socket: ...read EOF, socket closed %d: nb %d\n", fd_, nb);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
} else if (nb == -1) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
LOGE("read_socket: %d errno, sleep and retry ...", errno);
continue;
}
LOGE("read_socket: ...error fd %d: errno %d\n", fd_, errno);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
}
left -= nb;
if (left != 0) {
LOGE("error fd %d: retry_cnt %d", fd_, retry_cnt);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
}
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
int Port::Write(const void* buf, unsigned int size) {
ret = poll(fds, 1, SEND_TIMEOUT);
if (ret == 0) {
LOGE("write_socket: : fd %d poll timeout", fd_);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
}
while (left && (retry_cnt < MAX_RETRY_CNT)) {
}
LOGE("write_socket: ...error fd %d: errno %d\n", fd_, errno);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
}
left -= nb;
if (left != 0) {
LOGE("error fd %d: retry_cnt %d", fd_, retry_cnt);
- return -1;
+ return RPC_PORT_ERROR_IO_ERROR;
}
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
} // namespace internal
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 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.
*h = p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_create_from_port(rpc_port_parcel_h* h,
*h = p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port) {
int len = p->GetRaw().size();
if (len <= 0)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
internal::Port* pt = static_cast<internal::Port*>(port);
{
return ret;
}
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_destroy(rpc_port_parcel_h h) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
delete static_cast<Parcel*>(h);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteByte(b);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteInt16(i);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteInt32(i);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteInt64(i);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteFloat(f);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteDouble(d);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char* str) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteString(str);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteBool(b);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_bundle(rpc_port_parcel_h h, bundle* b) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteBundle(b);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
p->WriteArrayCount(count);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_write(rpc_port_parcel_h h,
rpc_port_parcelable_t* parcelable, void* data) {
if (parcelable == nullptr || parcelable->to == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
parcelable->to(h, data);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char* b) {
+
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*b = p->ReadByte();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short* i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*i = p->ReadInt16();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int* i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*i = p->ReadInt32();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long* i) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*i = p->ReadInt64();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_float(rpc_port_parcel_h h, float* f) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*f = p->ReadFloat();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_double(rpc_port_parcel_h h, double* d) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*d = p->ReadDouble();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_string(rpc_port_parcel_h h, char** str) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*str = strdup(p->ReadString());
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool* b) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*b = p->ReadBool();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_bundle(rpc_port_parcel_h h, bundle** b) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*b = p->ReadBundle();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int* count) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
Parcel* p = static_cast<Parcel*>(h);
*count = p->ReadArrayCount();
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_parcel_read(rpc_port_parcel_h h,
rpc_port_parcelable_t* parcelable, void* data) {
if (parcelable == nullptr || parcelable->from == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
parcelable->from(h, data);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_read(rpc_port_h h, void* buf, unsigned int size) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto port = static_cast<Port*>(h);
RPC_API int rpc_port_write(rpc_port_h h, const void* buf, unsigned int size) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto port = static_cast<Port*>(h);
auto p = new ::ProxyExt();
*h = p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_proxy_create_mockup(rpc_port_proxy_h* h) {
RPC_API int rpc_port_proxy_destroy(rpc_port_proxy_h h) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
delete p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_proxy_connect(rpc_port_proxy_h h, const char* appid,
const char* port) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
}
RPC_API int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_connected_event_cb cb, void *data) {
+ rpc_port_proxy_connected_event_cb cb, void *user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddConnectedEventListener(cb, data);
- return 0;
+ p->AddConnectedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_proxy_add_disconnected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_disconnected_event_cb cb, void* data) {
+ rpc_port_proxy_disconnected_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddDisconnectedEventListener(cb, data);
- return 0;
+ p->AddDisconnectedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_proxy_add_rejected_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_rejected_event_cb cb, void* data) {
+ rpc_port_proxy_rejected_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddRejectedEventListener(cb, data);
- return 0;
+ p->AddRejectedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_proxy_add_received_event_cb(rpc_port_proxy_h h,
- rpc_port_proxy_received_event_cb cb, void* data) {
+ rpc_port_proxy_received_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::ProxyExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddReceivedEventListener(cb, data);
- return 0;
+ p->AddReceivedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_create(rpc_port_stub_h* h, const char* port_name) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = new ::StubExt(port_name);
*h = p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_create_mockup(rpc_port_stub_h* h,
RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
delete p;
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_listen(rpc_port_stub_h h) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
RPC_API int rpc_port_stub_add_privilege(rpc_port_stub_h h,
const char* privilege) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->AddPrivilege(privilege);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_set_trusted(rpc_port_stub_h h,
const bool trusted) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
p->SetTrusted(trusted);
- return 0;
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_add_connected_event_cb(rpc_port_stub_h h,
- rpc_port_stub_connected_event_cb cb, void* data) {
+ rpc_port_stub_connected_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddConnectedEventListener(cb, data);
- return 0;
+ p->AddConnectedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_add_disconnected_event_cb(rpc_port_stub_h h,
- rpc_port_stub_disconnected_event_cb cb, void* data) {
+ rpc_port_stub_disconnected_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddDisconnectedEventListener(cb, data);
- return 0;
+ p->AddDisconnectedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}
RPC_API int rpc_port_stub_add_received_event_cb(rpc_port_stub_h h,
- rpc_port_stub_received_event_cb cb, void* data) {
+ rpc_port_stub_received_event_cb cb, void* user_data) {
if (h == nullptr)
- return -1;
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
auto p = static_cast<::StubExt*>(h);
std::lock_guard<std::recursive_mutex> lock(p->GetMutex());
- p->AddReceivedEventListener(cb, data);
- return 0;
+ p->AddReceivedEventListener(cb, user_data);
+ return RPC_PORT_ERROR_NONE;
}