Tizen Native API
5.0
|
The RPC Port API provides functions to send and receive messages between applications.
#include <rpc-port.h>
The RPC Port API provides functions for passing messages between applications. Applications can read and write data by using rpc-port.
Functions | |
int | rpc_port_read (rpc_port_h h, void *buf, unsigned int size) |
Reads data from an RPC port. | |
int | rpc_port_write (rpc_port_h h, const void *buf, unsigned int size) |
Writes data to an RPC port. | |
int | rpc_port_proxy_create (rpc_port_proxy_h *h) |
Creates a rpc port proxy handle. | |
int | rpc_port_proxy_destroy (rpc_port_proxy_h h) |
Destroys a rpc port proxy handle. | |
int | rpc_port_proxy_connect (rpc_port_proxy_h h, const char *appid, const char *port) |
Connects to port of appid. | |
int | rpc_port_proxy_add_connected_event_cb (rpc_port_proxy_h h, rpc_port_proxy_connected_event_cb cb, void *user_data) |
Adds a proxy connected callback. | |
int | rpc_port_proxy_add_disconnected_event_cb (rpc_port_proxy_h h, rpc_port_proxy_disconnected_event_cb cb, void *user_data) |
Adds a proxy disconnected callback. | |
int | rpc_port_proxy_add_rejected_event_cb (rpc_port_proxy_h h, rpc_port_proxy_rejected_event_cb cb, void *user_data) |
Adds a proxy rejected callback. | |
int | rpc_port_proxy_add_received_event_cb (rpc_port_proxy_h h, rpc_port_proxy_received_event_cb cb, void *user_data) |
Adds a proxy received callback. | |
int | rpc_port_proxy_get_port (rpc_port_proxy_h h, rpc_port_port_type_e type, rpc_port_h *port) |
Gets a port from proxy handle. | |
int | rpc_port_stub_create (rpc_port_stub_h *h, const char *port_name) |
Creates a rpc port stub handle. | |
int | rpc_port_stub_destroy (rpc_port_stub_h h) |
Destroys a rpc port stub handle. | |
int | rpc_port_stub_listen (rpc_port_stub_h h) |
Listens to the requests for connections. | |
int | rpc_port_stub_add_privilege (rpc_port_stub_h h, const char *privilege) |
Adds a privilege to the stub. | |
int | rpc_port_stub_set_trusted (rpc_port_stub_h h, const bool trusted) |
Sets trusted to the stub. | |
int | rpc_port_stub_add_connected_event_cb (rpc_port_stub_h h, rpc_port_stub_connected_event_cb cb, void *user_data) |
Adds a stub connected callback. | |
int | rpc_port_stub_add_disconnected_event_cb (rpc_port_stub_h h, rpc_port_stub_disconnected_event_cb cb, void *user_data) |
Adds a stub disconnected callback. | |
int | rpc_port_stub_add_received_event_cb (rpc_port_stub_h h, rpc_port_stub_received_event_cb cb, void *user_data) |
Adds a stub received callback. | |
int | rpc_port_stub_get_port (rpc_port_stub_h h, rpc_port_port_type_e type, const char *instance, rpc_port_h *port) |
Gets a port from stub handle. | |
Typedefs | |
typedef void * | rpc_port_h |
The rpc port handle. | |
typedef void(* | rpc_port_proxy_connected_event_cb )(const char *receiver, const char *port_name, rpc_port_h port, void *user_data) |
Called when the proxy is connected. | |
typedef void(* | rpc_port_proxy_disconnected_event_cb )(const char *receiver, const char *port_name, void *user_data) |
Called when the proxy is disconnected. | |
typedef void(* | rpc_port_proxy_rejected_event_cb )(const char *receiver, const char *port_name, void *user_data) |
Called when the proxy is rejected. | |
typedef void(* | rpc_port_proxy_received_event_cb )(const char *receiver, const char *port_name, void *user_data) |
Called when the proxy received data. | |
typedef void * | rpc_port_proxy_h |
The rpc port proxy handle. | |
typedef void * | rpc_port_stub_h |
The rpc port stub handle. | |
typedef void(* | rpc_port_stub_connected_event_cb )(const char *sender, const char *instance, void *user_data) |
Called when the proxy is connected with stub. | |
typedef void(* | rpc_port_stub_disconnected_event_cb )(const char *sender, const char *instance, void *user_data) |
Called when the proxy is disconnected from stub. | |
typedef int(* | rpc_port_stub_received_event_cb )(const char *sender, const char *instance, rpc_port_h port, void *user_data) |
Called when the stub received data from proxy. |
typedef void* rpc_port_h |
The rpc port handle.
typedef void(* rpc_port_proxy_connected_event_cb)(const char *receiver, const char *port_name, rpc_port_h port, void *user_data) |
Called when the proxy is connected.
The function is called when the proxy is connected with stub by port.
[in] | receiver | The target stub app id |
[in] | port_name | The name of the port |
[in] | port | The rpc port handle for reading and writing |
[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) |
Called when the proxy is disconnected.
The function is called when the proxy is disconnected from stub.
[in] | receiver | The target stub app id |
[in] | port_name | The name of the port |
[in] | user_data | The user data passed from the register function |
typedef void* rpc_port_proxy_h |
The rpc port proxy handle.
typedef void(* rpc_port_proxy_received_event_cb)(const char *receiver, const char *port_name, void *user_data) |
Called when the proxy received data.
The function is called when the proxy received data from stub.
[in] | receiver | The target stub app id |
[in] | port_name | The name of the port |
[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) |
Called when the proxy is rejected.
The function is called when the proxy is rejected to connect stub.
[in] | receiver | The target stub app id |
[in] | port_name | The name of the port |
[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 *user_data) |
Called when the proxy is connected with stub.
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 instance.
[in] | sender | The target proxy app id |
[in] | instance | The information of the request |
[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 *user_data) |
Called when the proxy is disconnected from stub.
The function is called when the proxy is disconnected from stub. When a proxy is disconnected, you can check the request by using instance.
[in] | sender | The target proxy app id |
[in] | instance | The information of the request |
[in] | user_data | The user data passed from the register function |
typedef void* rpc_port_stub_h |
The rpc port stub handle.
typedef int(* rpc_port_stub_received_event_cb)(const char *sender, const char *instance, rpc_port_h port, void *user_data) |
Called when the stub received data from proxy.
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 instance. If the function returns non zero value, the stub is disconnected.
[in] | sender | The target proxy app id |
[in] | instance | The information of the request |
[in] | port | The rpc port handle for reading and writing |
[in] | user_data | The user data passed from the register function |
zero
to continue receive data with the sender, otherwise nonzero
to disconnect from the port enum rpc_port_error_e |
enum rpc_port_port_type_e |
int rpc_port_proxy_add_connected_event_cb | ( | rpc_port_proxy_h | h, |
rpc_port_proxy_connected_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a proxy connected callback.
[in] | h | The rpc port proxy handle |
[in] | cb | The callback function to be called when proxy is connected |
[in] | user_data | The user data to be passed to the rpc_port_proxy_connected_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_add_disconnected_event_cb | ( | rpc_port_proxy_h | h, |
rpc_port_proxy_disconnected_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a proxy disconnected callback.
[in] | h | The rpc port proxy handle |
[in] | cb | The callback function to be called when proxy is disconnected |
[in] | user_data | The user data to be passed to the rpc_port_proxy_disconnected_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_add_received_event_cb | ( | rpc_port_proxy_h | h, |
rpc_port_proxy_received_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a proxy received callback.
[in] | h | The rpc port proxy handle |
[in] | cb | The callback function to be called when proxy received data |
[in] | user_data | The user data to be passed to the rpc_port_proxy_received_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_add_rejected_event_cb | ( | rpc_port_proxy_h | h, |
rpc_port_proxy_rejected_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a proxy rejected callback.
[in] | h | The rpc port proxy handle |
[in] | cb | The callback function to be called when proxy is rejected |
[in] | user_data | The user data to be passed to the rpc_port_proxy_rejected_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_connect | ( | rpc_port_proxy_h | h, |
const char * | appid, | ||
const char * | port | ||
) |
Connects to port of appid.
To send and receive data, the proxy should connect to port of stub
[in] | h | The rpc port proxy handle |
[in] | appid | The target stub appid |
[in] | port | The name of rpc port |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | Internal I/O error |
RPC_PORT_ERROR_PERMISSION_DENIED | Permission denied |
int rpc_port_proxy_create | ( | rpc_port_proxy_h * | h | ) |
Creates a rpc port proxy handle.
[out] | h | The rpc port proxy handle that is newly created |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_destroy | ( | rpc_port_proxy_h | h | ) |
Destroys a rpc port proxy handle.
[in] | h | The rpc port proxy handle |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_proxy_get_port | ( | rpc_port_proxy_h | h, |
rpc_port_port_type_e | type, | ||
rpc_port_h * | port | ||
) |
Gets a port from proxy handle.
[in] | h | The rpc port proxy handle |
[in] | type | The type of port |
[out] | port | The port to communicate |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | No available ports |
int rpc_port_read | ( | rpc_port_h | h, |
void * | buf, | ||
unsigned int | size | ||
) |
Reads data from an RPC port.
[in] | h | The rpc port handle |
[out] | buf | Buffer for reading data |
[in] | size | Size for reading data |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | Internal I/O error |
int rpc_port_stub_add_connected_event_cb | ( | rpc_port_stub_h | h, |
rpc_port_stub_connected_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a stub connected callback.
[in] | h | The rpc stub stub handle |
[in] | cb | The callback function to be called when proxy is connected with the stub |
[in] | user_data | The user data to be passed to the rpc_port_stub_connected_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_add_disconnected_event_cb | ( | rpc_port_stub_h | h, |
rpc_port_stub_disconnected_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a stub disconnected callback.
[in] | h | The rpc port stub handle |
[in] | cb | The callback function to be called when proxy is disconnected with the stub |
[in] | user_data | The user data to be passed to the rpc_port_stub_disconnected_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_add_privilege | ( | rpc_port_stub_h | h, |
const char * | privilege | ||
) |
Adds a privilege to the stub.
The stub can control access to the port using tizen privilege. It allows connections only if the proxy which have the privileges.
[in] | h | The rpc port stub handle |
[in] | privilege | The privilege to access this stub |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_add_received_event_cb | ( | rpc_port_stub_h | h, |
rpc_port_stub_received_event_cb | cb, | ||
void * | user_data | ||
) |
Adds a stub received callback.
[in] | h | The rpc port stub handle |
[in] | cb | The callback function to be called when stub received data |
[in] | user_data | The user data to be passed to the rpc_port_stub_received_event_cb() function |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_create | ( | rpc_port_stub_h * | h, |
const char * | port_name | ||
) |
Creates a rpc port stub handle.
[out] | h | The rpc port stub handle that is newly created |
[in] | port_name | The name of the port which want to listen |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_destroy | ( | rpc_port_stub_h | h | ) |
Destroys a rpc port stub handle.
[in] | h | The rpc port stub handle |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_stub_get_port | ( | rpc_port_stub_h | h, |
rpc_port_port_type_e | type, | ||
const char * | instance, | ||
rpc_port_h * | port | ||
) |
Gets a port from stub handle.
[in] | h | The rpc port stub handle |
[in] | type | The type of port |
[in] | instance | The ID of the instance which is connected |
[out] | port | The port to communicate |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | No available ports |
int rpc_port_stub_listen | ( | rpc_port_stub_h | h | ) |
Listens to the requests for connections.
The stub listens requests to connect by port
[in] | h | The rpc port stub handle |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | Internal I/O error |
int rpc_port_stub_set_trusted | ( | rpc_port_stub_h | h, |
const bool | trusted | ||
) |
Sets trusted to the stub.
The stub can control access to the port using tizen certificate. It allows connections only if the proxy is signed with the same certificate.
[in] | h | The rpc port stub handle |
[in] | trusted | Whether stub allows only trusted proxy or not |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
int rpc_port_write | ( | rpc_port_h | h, |
const void * | buf, | ||
unsigned int | size | ||
) |
Writes data to an RPC port.
[in] | h | The rpc port handle |
[in] | buf | Buffer for writing data |
[in] | size | Size for writing data |
0
on success, otherwise a negative error value RPC_PORT_ERROR_NONE | Successful |
RPC_PORT_ERROR_INVALID_PARAMETER | The specified h is NULL |
RPC_PORT_ERROR_IO_ERROR | Internal I/O error |