Skip to content

Commit

Permalink
Merge branch 'rdkcentral:main' into Event_Reg
Browse files Browse the repository at this point in the history
  • Loading branch information
NetajiPanigrahi authored Jul 17, 2024
2 parents 2bb8513 + 9a0c79f commit fd8c45e
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 432 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ cmake_minimum_required (VERSION 2.8.12)

if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
project(rbus VERSION 2.0.12)
project(rbus VERSION 2.0.13)
else ()
project(rbus)
set(PROJECT_VERSION "2.0.12")
set(PROJECT_VERSION "2.0.13")
endif (POLICY CMP0048)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
Expand Down
92 changes: 55 additions & 37 deletions src/rbus/rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -5884,70 +5884,83 @@ rbusError_t rbus_createSession(rbusHandle_t handle, uint32_t *pSessionId)
{
(void)handle;
rbusError_t rc = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;
rbusMessage response = NULL;
rbusObject_t outParams = NULL;
if (pSessionId && handle)
{
*pSessionId = 0;
if((err = rbus_invokeRemoteMethod(RBUS_SMGR_DESTINATION_NAME, RBUS_SMGR_METHOD_REQUEST_SESSION_ID, NULL, rbusConfig_ReadSetTimeout(), &response)) == RBUSCORE_SUCCESS)
if ((rc = rbusMethod_Invoke(handle, RBUS_SMGR_METHOD_REQUEST_SESSION_ID, NULL, &outParams)) == RBUS_ERROR_SUCCESS)
{
rbusMessage_GetInt32(response, /*MESSAGE_FIELD_RESULT,*/ (int*) &err);
if(RBUSCORE_SUCCESS != err)
rbusProperty_t prop = NULL;
prop = rbusObject_GetProperties(outParams);
int result = rbusValue_GetInt32(rbusProperty_GetValue(prop));
if (RBUS_ERROR_SUCCESS != result)
{
RBUSLOG_ERROR("Session manager reports internal error %d for the object %s", err, RBUS_SMGR_DESTINATION_NAME);
RBUSLOG_ERROR("Session manager reports internal error %d from %s for the object %s", rc, handle->componentName, RBUS_SMGR_DESTINATION_NAME);
rc = RBUS_ERROR_SESSION_ALREADY_EXIST;
}
else
{
rbusMessage_GetInt32(response, /*MESSAGE_FIELD_PAYLOAD,*/ (int*) pSessionId);
RBUSLOG_INFO("Received new session id %u", *pSessionId);
prop = rbusProperty_GetNext(prop);
/* Get current session id*/
if (prop)
{
*pSessionId = rbusValue_GetInt32(rbusProperty_GetValue(prop));
RBUSLOG_INFO("Received new session id %u", *pSessionId);
}
else
RBUSLOG_ERROR("Malformed response from session manager.\n");
}
}
else
{
RBUSLOG_ERROR("Failed to communicated with session manager.");
rc = rbusCoreError_to_rbusError(err);
}
rbusMessage_Release(response);
}
else
{
RBUSLOG_WARN("Invalid Input passed..");
rc = RBUS_ERROR_INVALID_INPUT;
}
return rc;
}
return rc;
}

rbusError_t rbus_getCurrentSession(rbusHandle_t handle, uint32_t *pSessionId)
{
(void)handle;
rbusError_t rc = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;
rbusMessage response = NULL;
rbusObject_t outParams = NULL;

if (pSessionId && handle)
{
*pSessionId = 0;
if((err = rbus_invokeRemoteMethod(RBUS_SMGR_DESTINATION_NAME, RBUS_SMGR_METHOD_GET_CURRENT_SESSION_ID, NULL, rbusConfig_ReadGetTimeout(), &response)) == RBUSCORE_SUCCESS)
if ((rc = rbusMethod_Invoke(handle, RBUS_SMGR_METHOD_GET_CURRENT_SESSION_ID, NULL, &outParams)) == RBUS_ERROR_SUCCESS)
{
rbusMessage_GetInt32(response, /*MESSAGE_FIELD_RESULT,*/ (int*) &err);
if(RBUSCORE_SUCCESS != err)
rbusProperty_t prop = NULL;
prop = rbusObject_GetProperties(outParams);
int result = rbusValue_GetInt32(rbusProperty_GetValue(prop));
if (RBUS_ERROR_SUCCESS != result)
{
RBUSLOG_ERROR("Session manager reports internal error %d from %s for the object %s", err, handle->componentName, RBUS_SMGR_DESTINATION_NAME);
RBUSLOG_ERROR("Session manager reports internal error %d from %s for the object %s", rc, handle->componentName, RBUS_SMGR_DESTINATION_NAME);
rc = RBUS_ERROR_SESSION_ALREADY_EXIST;
}
else
{
rbusMessage_GetInt32(response, /*MESSAGE_FIELD_PAYLOAD,*/ (int*) pSessionId);
RBUSLOG_INFO("Received new session id %u", *pSessionId);
prop = rbusProperty_GetNext(prop);
/* Get current session id*/
if (prop)
{
*pSessionId = rbusValue_GetInt32(rbusProperty_GetValue(prop));
RBUSLOG_INFO("Received new session id %u", *pSessionId);
}
else
RBUSLOG_ERROR("Malformed response from session manager.\n");
}
}
else
{
RBUSLOG_ERROR("Failed to communicated with session manager.");
rc = rbusCoreError_to_rbusError(err);
return rc;
}
rbusMessage_Release(response);
}
else
{
Expand All @@ -5961,44 +5974,49 @@ rbusError_t rbus_closeSession(rbusHandle_t handle, uint32_t sessionId)
{
(void)handle;
rbusError_t rc = RBUS_ERROR_SUCCESS;
rbusCoreError_t err = RBUSCORE_SUCCESS;

if (handle)
{
rbusMessage inputSession;
rbusMessage response = NULL;

if (sessionId == 0)
{
RBUSLOG_WARN("Passing default session ID which is 0");
return RBUS_ERROR_SUCCESS;
}
rbusMessage_Init(&inputSession);
rbusMessage_SetInt32(inputSession, /*MESSAGE_FIELD_PAYLOAD,*/ sessionId);
if((err = rbus_invokeRemoteMethod(RBUS_SMGR_DESTINATION_NAME, RBUS_SMGR_METHOD_END_SESSION, inputSession, rbusConfig_ReadSetTimeout(), &response)) == RBUSCORE_SUCCESS)

rbusObject_t inParams = NULL, outParams = NULL;
rbusObject_Init(&inParams, NULL);
rbusValue_t inputSession;
rbusValue_Init(&inputSession);
rbusValue_SetInt32(inputSession, sessionId);
rbusObject_SetValue(inParams, "session", inputSession);

if ((rc = rbusMethod_Invoke(handle, RBUS_SMGR_METHOD_END_SESSION, inParams, &outParams)) == RBUS_ERROR_SUCCESS)
{
rbusMessage_GetInt32(response, /*MESSAGE_FIELD_RESULT,*/ (int*) &err);
if(RBUSCORE_SUCCESS != err)
VERIFY_NULL(outParams);
rbusProperty_t prop = NULL;
prop = rbusObject_GetProperties(outParams);
int result = rbusValue_GetInt32(rbusProperty_GetValue(prop));

if (RBUS_ERROR_SUCCESS == result)
{
RBUSLOG_ERROR("Session manager reports internal error %d from %s for the object %s", err, handle->componentName, RBUS_SMGR_DESTINATION_NAME);
rc = RBUS_ERROR_SESSION_ALREADY_EXIST;
RBUSLOG_INFO("Successfully ended session %u.", sessionId);
}
else
RBUSLOG_INFO("Successfully ended session %u.", sessionId);
{
RBUSLOG_ERROR("Session manager reports internal error %d from %s for the object %s", result, handle->componentName, RBUS_SMGR_DESTINATION_NAME);
rc = RBUS_ERROR_SESSION_ALREADY_EXIST;
}
}
else
{
RBUSLOG_ERROR("Failed to communicated with session manager.");
rc = rbusCoreError_to_rbusError(err);
}
rbusMessage_Release(response);
}
else
{
RBUSLOG_WARN("Invalid Input passed..");
rc = RBUS_ERROR_INVALID_INPUT;
}

return rc;
}

Expand Down
15 changes: 8 additions & 7 deletions src/session_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
# limitations under the License.
##########################################################################
include_directories(.
../core
../rtmessage)
../../include
../core
../rtmessage)

add_executable(rbus_session_mgr session_manager.c)
add_dependencies(rbus_session_mgr rbuscore)
target_link_libraries(rbus_session_mgr rbuscore)
add_dependencies(rbus_session_mgr rbus rbuscore)
target_link_libraries(rbus_session_mgr rbus rbuscore)

if (BUILD_SESSIONMGR_SAMPLE_APPS)
add_executable(rbus_session_mgr_client test/sample_client.c)
add_dependencies(rbus_session_mgr_client rbuscore)
target_link_libraries(rbus_session_mgr_client rbuscore)
add_dependencies(rbus_session_mgr_client rbus rbuscore)
target_link_libraries(rbus_session_mgr_client rbus rbuscore)
endif (BUILD_SESSIONMGR_SAMPLE_APPS)

install (TARGETS rbus_session_mgr
install (TARGETS rbus_session_mgr
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(FILES rbus_session_mgr.h DESTINATION "include/rbus")
Loading

0 comments on commit fd8c45e

Please sign in to comment.