Commit cd6e40a206f36ecdc26468f8064d9d25a6fe3de7

Authored by Cédric RICARD
1 parent 4dbf1f03

More message constants into NetServices

calexium_lib/net_services/CXM_generic_protocol.anubis
@@ -14,18 +14,21 @@ read tools/basis.anubis @@ -14,18 +14,21 @@ read tools/basis.anubis
14 read system/message_queue.anubis 14 read system/message_queue.anubis
15 read calexium_lib/CXM_message_constants.anubis 15 read calexium_lib/CXM_message_constants.anubis
16 16
17 -public define Word32 _CXM_OK = 0.  
18 -public define Word32 _CXM_ERROR = 1.  
19 -public define Word32 _CXM_UNKNOW_CMD = 2.  
20 -public define Word32 _CXM_UNKNOW_SERVICE = 3. 17 +public define Word32 _CXM_OK = 0.
  18 +public define Word32 _CXM_ERROR = 1.
  19 +public define Word32 _CXM_UNKNOW_CMD = 2.
  20 +public define Word32 _CXM_UNKNOW_SERVICE = 3.
21 public define Word32 _CXM_MISSING_REQUIRED_FIELD = 4. 21 public define Word32 _CXM_MISSING_REQUIRED_FIELD = 4.
22 -public define Word32 _CXM_FORBIDDEN = 5. 22 +public define Word32 _CXM_FORBIDDEN = 5.
  23 +public define Word32 _CXM_BAD_AUTHENTICATION = 6.
  24 +public define Word32 _CXM_TEMPORARY_ERROR = 7. // When received, the client should try later
23 25
24 public type ProtocolResult: 26 public type ProtocolResult:
25 failure, 27 failure,
26 timeout, 28 timeout,
27 unknow_cmd, 29 unknow_cmd,
28 error, 30 error,
  31 + error(Word32, String),
29 ok, 32 ok,
30 ok_msg(Message). 33 ok_msg(Message).
31 34
@@ -33,8 +36,8 @@ public define One @@ -33,8 +36,8 @@ public define One
33 send_ACK_error 36 send_ACK_error
34 ( 37 (
35 MessageQueue queue, 38 MessageQueue queue,
36 - Word32 cmd_id,  
37 - Word32 error_code, 39 + Word32 cmd_id,
  40 + Word32 error_code,
38 String error_string, 41 String error_string,
39 )= 42 )=
40 with err_msg = message(_CXM_ACK), 43 with err_msg = message(_CXM_ACK),
@@ -137,24 +140,29 @@ public define ProtocolResult @@ -137,24 +140,29 @@ public define ProtocolResult
137 failure then failure, //println("wait_for_reply CMD"); 140 failure then failure, //println("wait_for_reply CMD");
138 success(cmd) then 141 success(cmd) then
139 // println("wait_for_reply CMD="+to_hexa(cmd)); 142 // println("wait_for_reply CMD="+to_hexa(cmd));
140 - if find_int32(_msg, "STATUS") is  
141 - {  
142 - failure then failure, //println("wait_for_reply STATUS");  
143 - success(status) then  
144 - if cmd = wait_cmd & status = _CXM_OK then  
145 - if find_message(_msg, "RESULT") is  
146 - {  
147 - failure then ok,  
148 - success(ok_message) then ok_msg(ok_message)  
149 - }  
150 - else if cmd = wait_cmd & status = _CXM_ERROR then  
151 - error  
152 - else if cmd = wait_cmd & status = _CXM_UNKNOW_CMD then  
153 - unknow_cmd  
154 - else  
155 - failure //println("wait_for_reply ");  
156 - }  
157 - } 143 + if find_int32(_msg, "STATUS") is
  144 + {
  145 + failure then failure, //println("wait_for_reply STATUS");
  146 + success(status) then
  147 + if cmd = wait_cmd then
  148 + (
  149 + if status = _CXM_OK then
  150 + if find_message(_msg, "RESULT") is
  151 + {
  152 + failure then ok,
  153 + success(ok_message) then ok_msg(ok_message)
  154 + }
  155 + else if status = _CXM_ERROR then
  156 + error
  157 + else if status = _CXM_UNKNOW_CMD then
  158 + unknow_cmd
  159 + else
  160 + error(status, if find_string(_msg, "STATUS_MSG") is success(txt) then txt else "")
  161 + )
  162 + else
  163 + failure //println("wait_for_reply ");
  164 + }
  165 + }
158 else 166 else
159 failure //println("wait_for_reply not ACK"); 167 failure //println("wait_for_reply not ACK");
160 }. 168 }.
calexium_lib/net_services_protocols/ftp_client.anubis
@@ -91,6 +91,7 @@ define Maybe(One) @@ -91,6 +91,7 @@ define Maybe(One)
91 timeout then println("get_file timeout");failure, 91 timeout then println("get_file timeout");failure,
92 unknow_cmd then println("get_file unknow_cmd");failure, 92 unknow_cmd then println("get_file unknow_cmd");failure,
93 error then println("get_file remote error msg");failure, 93 error then println("get_file remote error msg");failure,
  94 + error(c,m) then println("get_file remote error [" + c + "] msg '" + m + "'");failure,
94 ok then println("get_file ok");failure, 95 ok then println("get_file ok");failure,
95 ok_msg(msg)then 96 ok_msg(msg)then
96 if find_int32(msg, "FileSize") is 97 if find_int32(msg, "FileSize") is