diff --git a/asterisk/ami.anubis b/asterisk/ami.anubis index 0e9d912..b7c28aa 100644 --- a/asterisk/ami.anubis +++ b/asterisk/ami.anubis @@ -14,29 +14,41 @@ transmit calexium_lib/asterisk/ami_types.anubis transmit calexium_lib/asterisk/ami_commands.anubis transmit calexium_lib/web/CXM_http_get_common.anubis -define Maybe(One) +define Maybe(List(String)) receive ( - Bool print_dump, - Connection conn + Bool print_dump, + Connection conn, + List(String) response )= //TODO find the header and content-lenght to get full length of answer - if read(conn, 16384, 5) is + //if read(conn, 16384, 5) is + if read_line(conn, 80, 10) is { - error then println("Read error");failure, - timeout then println("Read timeout");failure, - ok(ba) then - with ami_response = to_string(ba), - // typed_response = xml_rpc_get_response(xml_response), - if print_dump then - println("=== ASTERISK SERVER answer ==="+crlf +"["+ ami_response + "]" ); - receive(print_dump, conn) - - else - receive(print_dump, conn) + error then println("Read error");failure, + timeout then println("Read timeout");failure, + eof then println("Read timeout");failure, + ok(str) then + if str = crlf then + (if print_dump then + println("=== ASTERISK SERVER answer ==="+crlf +"["+ join("",(reverse(response))) + "]" ) + else + unique); + success(reverse(response)) + else + receive(print_dump, conn, [str . response]) } - . +. + +public define Maybe(List(String)) + ami_receive + ( + Bool print_dump, + Connection conn + )= + receive(print_dump, conn, []) +. define Maybe(String) _format_action @@ -46,7 +58,9 @@ define Maybe(String) )= if values is { - [] then success(so_far+crlf), + [] then + println("AMI _format_action\n"+so_far+crlf); + success(so_far+crlf), [h . t] then if h is key_value(key, value) then _format_action(so_far+key+": "+value+crlf, t) @@ -69,7 +83,7 @@ define Maybe(String) -public define Maybe(One) +public define Maybe(List(String)) send_action ( Asterisk_client client, @@ -90,7 +104,7 @@ public define Maybe(One) if write(conn, to_byte_array(action_str)) is { failure then failure, - success(_) then receive(true, conn) + success(_) then ami_receive(true, conn) } }. @@ -98,7 +112,8 @@ public define Maybe(Asterisk_client) asterisk_new_client ( String server_name, - AMI_Auth auth + AMI_Auth auth, + Bool subscribe_events )= //println("asterisk_new_client "+server_name); if separate_name_port(server_name, 5038) is (name, server_port) then @@ -112,6 +127,7 @@ public define Maybe(Asterisk_client) { error(e) then failure, ok(conn) then + //read line of 80 bytes and timeout for 10 seconds if read_line(tcp(conn), 80, 10) is { error then failure, @@ -123,7 +139,7 @@ public define Maybe(Asterisk_client) if start_with(to_lower(str), "asterisk call manager") then with client = asterisk_client(tcp(conn), var(0), auth), - if send_action(client, ami_login(auth)) is + if send_action(client, ami_login(auth, subscribe_events)) is { failure then failure, success(_) then success(client) @@ -137,6 +153,15 @@ public define Maybe(Asterisk_client) else failure. +public define Maybe(Asterisk_client) + asterisk_new_client + ( + String server_name, + AMI_Auth auth, + )= + asterisk_new_client(server_name, auth, false) +. + global define One ami_test diff --git a/asterisk/ami_commands.anubis b/asterisk/ami_commands.anubis index 35e0840..e9660d6 100644 --- a/asterisk/ami_commands.anubis +++ b/asterisk/ami_commands.anubis @@ -17,10 +17,14 @@ public define AMI_Action ami_login(String user, String password, Bool events) = public define AMI_Action ami_login(String user, String password)= ami_login(user, password, true). - + public define AMI_Action ami_login(AMI_Auth ami_auth) = if ami_auth is auth(user, password) then ami_login(user, password, true). + +public define AMI_Action ami_login(AMI_Auth ami_auth, Bool event) = + if ami_auth is auth(user, password) then + ami_login(user, password, event). public define AMI_Action ami_originate_call(String extension, String out_number) = action("Originate", [ diff --git a/web/CXM_jquery.anubis b/web/CXM_jquery.anubis index 6bdf2c2..ea2da90 100644 --- a/web/CXM_jquery.anubis +++ b/web/CXM_jquery.anubis @@ -12,7 +12,7 @@ read tools/basis.anubis /* jQuery Actioner type */ public type JQuery_Actioner_type: - jqform ( String form), + jqform ( String form, WEB_Action_Name name, List((String,String)) extra_ops), jqlink ( WEB_Action_Name name, List((String,String)) extra_ops), jqflink ( String link), jqscript( String script) @@ -74,7 +74,19 @@ public define String same then if act_type is { - jqform(form) then "$('#"+form+"').submit();", + jqform(form, control_action, extra_ops) then + + if control_action is + { + no_action then "", //will use the default action defined in form + controller_action(ctrl, action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"');\n" + action_name(action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", + url(url) then + "$('#"+form+"').get(0).setAttribute('action','"+url+"');", + }+ + "$('#"+form+"').submit();\n", jqlink(control_action, extra_ops) then if control_action is { @@ -89,7 +101,18 @@ public define String same(label) then if act_type is { - jqform(form) then "$('#"+form+"').submit();", + jqform(form, control_action, extra_ops) then + if control_action is + { + no_action then "", //will use the default action defined in form + controller_action(ctrl, action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"');\n" + action_name(action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", + url(url) then + "$('#"+form+"').get(0).setAttribute('action','"+url+"');", + }+ + "$('#"+form+"').submit();\n", jqlink(control_action, extra_ops) then if control_action is { @@ -104,7 +127,18 @@ public define String other(window_name, window_options) then if act_type is { - jqform(form) then "$('#"+form+"').submit();",//il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! + jqform(form, control_action, extra_ops) then //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! + if control_action is + { + no_action then "", //will use the default action defined in form + controller_action(ctrl, action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"');\n" + action_name(action) then + "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", + url(url) then + "$('#"+form+"').get(0).setAttribute('action','"+url+"');", + }+ + "$('#"+form+"').submit();\n", jqlink(control_action, extra_ops) then if control_action is { diff --git a/web/jQuery/CXM_jquery_button.anubis b/web/jQuery/CXM_jquery_button.anubis index 3317af0..c692752 100644 --- a/web/jQuery/CXM_jquery_button.anubis +++ b/web/jQuery/CXM_jquery_button.anubis @@ -338,10 +338,40 @@ public define HTML_Partial_Content public define HTML_Partial_Content img_submit_button ( + String img, //path to image + String label, //translated label of the button + String form_id, //form id to submit + WEB_Action_Name action, // + List((String,String)) extra_ops + )= + jquery_button(jquery_img_button(img, label, "", jQuery_actioner(same, jqform(form_id, action, extra_ops)), left)). + +public define HTML_Partial_Content + img_submit_button + ( + String img, //path to image + String label, //translated label of the button + String form_id, //form id to submit + WEB_Action_Name action + )= + jquery_button(jquery_img_button(img, label, "", jQuery_actioner(same, jqform(form_id, action, [])), left)). + +public define HTML_Partial_Content + img_submit_button + ( + String label, //translated label of the button + String form_id, //form id to submit + WEB_Action_Name action + )= + jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqform(form_id, action, [])), left)). + +public define HTML_Partial_Content + img_submit_button + ( String label, //translated label of the button String form_id // )= - jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqform(form_id)), left)). + jquery_button(jquery_img_button(icn16_check, label, "", jQuery_actioner(same, jqform(form_id, no_action, [])), left)). public define HTML_Partial_Content img_button -- libgit2 0.21.4