/* the global app_session cache */
osrfHash* osrfAppSessionCache = NULL;
-
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// Request API
osrf_message* ret_msg = req->result;
osrf_message* tmp_msg = ret_msg->next;
req->result = tmp_msg;
+ if (ret_msg->sender_locale) {
+ if (req->session->session_locale)
+ free(req->session->session_locale);
+ req->session->session_locale = strdup(ret_msg->sender_locale);
+ }
return ret_msg;
}
osrf_message* ret_msg = req->result;
osrf_message* tmp_msg = ret_msg->next;
req->result = tmp_msg;
+ if (ret_msg->sender_locale) {
+ if (req->session->session_locale)
+ free(req->session->session_locale);
+ req->session->session_locale = strdup(ret_msg->sender_locale);
+ }
return ret_msg;
}
if( req->complete )
// --------------------------------------------------------------------------
/** returns a session from the global session hash */
+char* osrf_app_session_set_locale( osrf_app_session* session, const char* locale ) {
+ if (!session || !locale)
+ return NULL;
+
+ if(session->session_locale)
+ free(session->session_locale);
+
+ session->session_locale = strdup( locale );
+ return session->session_locale;
+}
+
+/** returns a session from the global session hash */
osrf_app_session* osrf_app_session_find_session( char* session_id ) {
if(session_id) return osrfHashGet(osrfAppSessionCache, session_id);
return NULL;
char* domain = osrfStringArrayGetString(arr, 0);
char* router_name = osrfConfigGetValue(NULL, "/router_name");
- int len = snprintf( target_buf, 512, "%s@%s/%s", router_name, domain, remote_service );
+ int len = snprintf( target_buf, 512, "%s@%s/%s",
+ router_name ? router_name : "(null)",
+ domain ? domain : "(null)",
+ remote_service ? remote_service : "(null)" );
osrfStringArrayFree(arr);
//free(domain);
free(router_name);
session->remote_id = strdup(target_buf);
session->orig_remote_id = strdup(session->remote_id);
session->remote_service = strdup(remote_service);
+ session->session_locale = NULL;
#ifdef ASSUME_STATELESS
session->stateless = 1;
if( session->userDataFree && session->userData )
session->userDataFree(session->userData);
+ if(session->session_locale)
+ free(session->session_locale);
+
free(session->remote_id);
free(session->orig_remote_id);
free(session->session_id);
osrf_app_session* session, jsonObject* params,
char* method_name, int protocol, string_array* param_strings ) {
- return osrf_app_session_make_req( session, params,
- method_name, protocol, param_strings );
+ return osrf_app_session_make_locale_req( session, params,
+ method_name, protocol, param_strings, NULL );
+}
+
+int osrfAppSessionMakeLocaleRequest(
+ osrf_app_session* session, jsonObject* params,
+ char* method_name, int protocol, string_array* param_strings, char* locale ) {
+
+ return osrf_app_session_make_locale_req( session, params,
+ method_name, protocol, param_strings, locale );
}
int osrf_app_session_make_req(
osrf_app_session* session, jsonObject* params,
- char* method_name, int protocol, string_array* param_strings ) {
+ char* method_name, int protocol, string_array* param_strings) {
+
+ return osrf_app_session_make_locale_req(session, params,
+ method_name, protocol, param_strings, NULL);
+}
+
+int osrf_app_session_make_locale_req(
+ osrf_app_session* session, jsonObject* params,
+ char* method_name, int protocol, string_array* param_strings, char* locale ) {
if(session == NULL) return -1;
- osrfLogMkXid();
+ osrfLogMkXid();
osrf_message* req_msg = osrf_message_init( REQUEST, ++(session->thread_trace), protocol );
osrf_message_set_method(req_msg, method_name);
+
+ if (locale) {
+ osrf_message_set_locale(req_msg, locale);
+ } else if (session->session_locale) {
+ osrf_message_set_locale(req_msg, session->session_locale);
+ }
+
if(params) {
osrf_message_set_params(req_msg, params);