diff --git a/CXM_message_constants.anubis b/CXM_message_constants.anubis index 124a483..d4a8fdc 100644 --- a/CXM_message_constants.anubis +++ b/CXM_message_constants.anubis @@ -207,5 +207,6 @@ public define Word32 _CXM_HK_MSG_END = 0x3379FFFF. public define Word32 _RMT_ANUBIX_MSG_BASIS = 0x33800000. public define Word32 _RMT_ANUBIX_CORE_SERVICE_ID = 0x33800000. +public define Word32 _RMT_ANUBIX_CORE_AUTH = 0x33800001. public define Word32 _RMT_ANUBIX_MSG_END = 0x3380FFFF. diff --git a/database/db_types.anubis b/database/db_types.anubis index fd24400..02084f1 100644 --- a/database/db_types.anubis +++ b/database/db_types.anubis @@ -46,6 +46,16 @@ public define String none then "none", db_id(_idx) then abs_to_decimal(_idx) }. + +public define String + String s + DB_id idx = + s + to_String(idx) +. + +public define String + DB_id idx + String s = + to_String(idx) + s +. public define Int to_Int diff --git a/net_services/CXM_generic_client.anubis b/net_services/CXM_generic_client.anubis index 18b4eee..cd64a55 100644 --- a/net_services/CXM_generic_client.anubis +++ b/net_services/CXM_generic_client.anubis @@ -7,19 +7,12 @@ * */ +transmit system/message_transceiver.anubis +transmit calexium_lib/net_services_protocols/logger_service.anubis -read tools/basis.anubis -read system/muscle.anubis -read system/data_io.anubis -read system/convert.anubis -read system/string.anubis -read system/message_queue.anubis -read system/message_transceiver.anubis -read tools/connections.anubis - -read calexium_lib/CXM_message_constants.anubis -read calexium_lib/net_services/CXM_net_services.anubis -read calexium_lib/net_services/CXM_generic_protocol.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/net_services/CXM_net_services.anubis +transmit calexium_lib/net_services/CXM_generic_protocol.anubis // --Generic types--------------------------------------------------------------------- public type NetServiceAnswer: @@ -31,7 +24,6 @@ public type NetServiceAnswer: // --Generic functions--------------------------------------------------------------------- - /** * Sends the message to the server then parses the answer and returns the RESULT message on CMD success. */ @@ -66,6 +58,42 @@ public define Maybe(NetServiceAnswer) } }. + +public define Maybe(NetServiceAnswer) +/** + * Sends the message to the server then parses the answer and returns the RESULT message on CMD success. + * + */ + generic_send_message + ( + MessageQueue queue, + Message msg_to_send, + Int timeout, + String logger_name + )= + queue.add_Message_to_send(msg_to_send); + if queue.get_next_received_Message(timeout) is + { + timeout then logError(logger_name, "["+queue.get_name(unique)+"]: receive timeout");failure, + closed then logError(logger_name, "["+queue.get_name(unique)+"]: socket closed");failure, + msg(msg) then + if find_int32(msg, "CMD") is + { + failure then logError(logger_name, "["+queue.get_name(unique)+"]: CMD field not found"); failure, + success(cmd) then + if find_int32(msg, "STATUS") is + { + failure then logError(logger_name, "["+queue.get_name(unique)+"]: STATUS field not found"); failure, + success(v) then + if v = _CXM_OK then + success(netservice_ok(cmd, find_message(msg, "RESULT"))) + else + with error_string = if find_string(msg, "STATUS_MSG") is success(s) then s else "", + success(netservice_error(cmd, v, error_string)) + } + } + }. + public define Maybe($T) simple_handler ( @@ -173,6 +201,80 @@ define Maybe($T) } }. +define Maybe($T) + generic_request_for_service + ( + MessageQueue queue, + Word32 service_id, + Word32 service_version, + String domain, + (MessageQueue, String) -> Maybe($T) handler, + String logger + )= + with test_msg = message(_CXM_REQUEST_FOR_SERVICE), + forget(add_int32(test_msg, "SERVICE", service_id)); + forget(add_int32(test_msg, "VERSION", service_version)); + forget(add_string(test_msg, "DOMAIN", domain)); + queue.add_Message_to_send(test_msg); + if queue.get_next_received_Message(10) is + { + timeout then logError(logger, "["+queue.get_name(unique)+"]: requesting service receive timeout");failure, + closed then logError(logger, "["+queue.get_name(unique)+"]: requesting service socket closed");failure, + msg(msg) then + if find_int32(msg, "STATUS") is + { + failure then logError(logger, "["+queue.get_name(unique)+"]: requesting service STATUS not found");failure, + success(v) then + if v = _CXM_OK then + if find_message(msg, "RESULT") is + { + failure then logError(logger, "["+queue.get_name(unique)+"]: requesting service RESULT not found");failure, + success(result) then + with timestamp = if find_string(result, "TIMESTAMP") is + { + failure then logError(logger, "["+queue.get_name(unique)+"]: requesting service TIMESTAMP not found"); "", + success(timestamp) then timestamp + }, + handler(queue, timestamp) + } + else + logError(logger, "["+queue.get_name(unique)+"]: the requested service is not available on server.");failure + } + }. + +public define Maybe(MessageQueue) + get_message_queue_to_net_service + ( + String queue_name, + Word32 server, + Word32 port, + Word32 service_id, + Word32 service_version, + String domain, + (MessageQueue, String) -> Maybe(One) handler, //1st function to apply if need (i.e authentication to remote service) + String logger + ) + = + if connect( server, port) is + { + error(_) then logError(logger, queue_name + ": Can't connect to service ["+ip_addr_to_string(server)+":"+port+"]");failure, + ok(conn) then +// println("[" + virtual_machine_id + "] netservices create queue"); + with queue = create_MessageQueue(queue_name), + message_transceiver(tcp(conn), queue); +// println("[" + virtual_machine_id + "] netservices generic_request_for_service()"); + if generic_request_for_service(queue, service_id, service_version, domain, handler, logger) is + { + failure then + //we can't apply first function correctly, so we ask to Message Queue to quit and return failure + logError(logger, "can't apply first function correctly"); + queue.quit(unique); + failure, + success(_) then success(queue) + } + }. + + public define Maybe($T) generic_connect_to_net_service ( diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index e5ca9cf..b3e33ba 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -317,6 +317,10 @@ public define CXM_Form_Field submit(WEB_Action_Name action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) = submit([], htmlClass(""), action_name, label, button_text, extra_operands). +public define CXM_Form_Field + submit(WEB_Action_Name action_name, Maybe(String) label, String button_text) + = submit([], htmlClass(""), action_name, label, button_text, []). + public define CXM_Form_Field //Helper for older project wich use only String as Action name submit(String _action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) = submit([], htmlClass(""), action_name(_action_name), label, button_text, extra_operands). @@ -535,7 +539,7 @@ public define HTML_In_Form ), ]), one_line_fields(fields) then - table([nude],[row([], + table([nude, class("form_one_line")],[row([], map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))]) , -- libgit2 0.21.4