Commit b5641b08 authored by George Nash's avatar George Nash Committed by Kishen Maloor

Add context pointer to role and ping functions

The functions oc_assert_role and oc_send_ping both register
callback handler functions without adding the void *user_data.
C programs may never be expected to use the user_data parameter
but when developing language bindings like Java JNI the
user_data is used to hold pointer to the Java methods.

Without the context pointer language binding becomes much more
difficult.  Since the oc_response_handler_t already has space
for the user_data it is trivial to add the context pointer in
this case.

Change-Id: I75d8a8260005d78a3f34f2bbf7d04115cc0e97cf
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/27844Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent 34cb4415
...@@ -340,13 +340,13 @@ oc_remove_ping_handler(void *data) ...@@ -340,13 +340,13 @@ oc_remove_ping_handler(void *data)
bool bool
oc_send_ping(bool custody, oc_endpoint_t *endpoint, uint16_t timeout_seconds, oc_send_ping(bool custody, oc_endpoint_t *endpoint, uint16_t timeout_seconds,
oc_response_handler_t handler) oc_response_handler_t handler, void *user_data)
{ {
oc_client_handler_t client_handler; oc_client_handler_t client_handler;
client_handler.response = handler; client_handler.response = handler;
oc_client_cb_t *cb = oc_ri_alloc_client_cb("/ping", endpoint, 0, NULL, oc_client_cb_t *cb = oc_ri_alloc_client_cb("/ping", endpoint, 0, NULL,
client_handler, LOW_QOS, NULL); client_handler, LOW_QOS, user_data);
if (!cb) if (!cb)
return false; return false;
...@@ -561,13 +561,13 @@ oc_get_all_roles(void) ...@@ -561,13 +561,13 @@ oc_get_all_roles(void)
bool bool
oc_assert_role(const char *role, const char *authority, oc_endpoint_t *endpoint, oc_assert_role(const char *role, const char *authority, oc_endpoint_t *endpoint,
oc_response_handler_t handler) oc_response_handler_t handler, void *user_data)
{ {
oc_sec_cred_t *cr = oc_sec_find_role_cred(role, authority); oc_sec_cred_t *cr = oc_sec_find_role_cred(role, authority);
if (cr) { if (cr) {
if (oc_init_post("/oic/sec/roles", endpoint, NULL, handler, HIGH_QOS, if (oc_init_post("/oic/sec/roles", endpoint, NULL, handler, HIGH_QOS,
NULL)) { user_data)) {
oc_rep_start_root_object(); oc_rep_start_root_object();
oc_rep_set_array(root, roles); oc_rep_set_array(root, roles);
oc_rep_object_array_start_item(roles); oc_rep_object_array_start_item(roles);
......
...@@ -129,7 +129,7 @@ send_ping(uint16_t timeout_seconds) ...@@ -129,7 +129,7 @@ send_ping(uint16_t timeout_seconds)
#ifdef OC_TCP #ifdef OC_TCP
if (target_ep.flags & TCP) { if (target_ep.flags & TCP) {
if (!oc_send_ping(0, &target_ep, timeout_seconds, pong_received_handler)) { if (!oc_send_ping(0, &target_ep, timeout_seconds, pong_received_handler, NULL)) {
printf("oc_send_ping failed\n"); printf("oc_send_ping failed\n");
} }
} else } else
......
...@@ -385,10 +385,10 @@ typedef struct oc_role_t ...@@ -385,10 +385,10 @@ typedef struct oc_role_t
oc_role_t *oc_get_all_roles(void); oc_role_t *oc_get_all_roles(void);
bool oc_assert_role(const char *role, const char *authority, bool oc_assert_role(const char *role, const char *authority,
oc_endpoint_t *endpoint, oc_response_handler_t handler); oc_endpoint_t *endpoint, oc_response_handler_t handler, void *user_data);
#ifdef OC_TCP #ifdef OC_TCP
bool oc_send_ping(bool custody, oc_endpoint_t *endpoint, bool oc_send_ping(bool custody, oc_endpoint_t *endpoint,
uint16_t timeout_seconds, oc_response_handler_t handler); uint16_t timeout_seconds, oc_response_handler_t handler, void *user_data);
#endif /* OC_TCP */ #endif /* OC_TCP */
/** Common operations */ /** Common operations */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment