diff --git a/ds_files/ds_types.anubis b/ds_files/ds_types.anubis index 87434a3..6532e5a 100644 --- a/ds_files/ds_types.anubis +++ b/ds_files/ds_types.anubis @@ -106,7 +106,16 @@ public define List(DS_Type_File) calexium_lib_types_description = // String from, // String reply_to // ). - + ds_type("File_ref", [ + alternative("file_ref", [ + component(string, "path", comment("access ptah to the file on the original machine")), + component(string, "name", comment("name of the file")), + component(ds_type("MIME"), "mime", comment("mime type of the file")), + component(string, "key", comment("key is a SHA1 gave by sender to certify it when it will be downloaded")), + component(int, "size", comment("size of the file in Bytes")) + ]) + ]), + ds_type("Email_to_send", [ alternative("data_to_send", [ component(ds_type("Email_Address"), "from", comment("email sent from that sender")), @@ -115,7 +124,7 @@ public define List(DS_Type_File) calexium_lib_types_description = component(list, ds_type("Email_Address"), "bcc", comment("email sent as blank carbon copy to that list of recipients")), component(string, "subject", comment("subject of email. Supposed to be UTF8")), component(string, "content", comment("content of the email")), - component(list, string, "files", comment("list of files")), + component(list, ds_type("File_ref"), "attached_files", comment("list of files to attach to this email")), component(bool, "send_copy",comment("send copy to sender by bcc (useful when the email is sent by an automat)")), component(string, "reply_to", comment("reply to !!")) ]) diff --git a/mail/types/generated/email_to_send.anubis b/mail/types/generated/email_to_send.anubis index 6eaa627..a3050c9 100644 --- a/mail/types/generated/email_to_send.anubis +++ b/mail/types/generated/email_to_send.anubis @@ -1,8 +1,8 @@ -/* +/* * Created by 伝作 (Densaku). * Types & Messages generator written by フランスのトトロ aka (David RENÉ) - * Date: 2018-12-07 - * Time: 01:14:06 + * Date: 2019-05-17 + * Time: 19:05:20 * */ @@ -10,7 +10,8 @@ transmit system/muscle.anubis transmit system/convert.anubis transmit tools/basis.anubis -transmit calexium_lib/mail/types/generated/email_address.anubis +transmit types/generated/file_ref.anubis +transmit types/generated/email_address.anubis @@ -22,7 +23,7 @@ public type Email_to_send: List(Email_Address) bcc, //email sent as blank carbon copy to that list of recipients String subject, //subject of email. Supposed to be UTF8 String content, //content of the email - List(String) files, //list of files + List(File_ref) attached_files, //list of files to attach to this email Bool send_copy, //send copy to sender by bcc (useful when the email is sent by an automat) String reply_to //reply to !! ) @@ -42,7 +43,7 @@ public define Message if _email_to_send is { //Alternative data_to_send - data_to_send(_from, __to, __cc, __bcc, _subject, _content, __files, _send_copy, _reply_to) then + data_to_send(_from, __to, __cc, __bcc, _subject, _content, __attached_files, _send_copy, _reply_to) then forget(add_string(_email_to_send_message, "__TYPE_ALT__", "data_to_send")); // [type = Email_Address] data_to_send.from forget(add_message(_email_to_send_message, "from", to_Message(_from))); @@ -56,8 +57,8 @@ public define Message forget(add_string(_email_to_send_message, "subject", _subject)); // [type = String] data_to_send.content forget(add_string(_email_to_send_message, "content", _content)); - // [type = List(String)] data_to_send.files - map_forget((String _files) |-> add_string(_email_to_send_message, "files", _files), __files); + // [type = List(File_ref)] data_to_send.attached_files + map_forget((File_ref _attached_files) |-> add_message(_email_to_send_message, "attached_files", to_Message(_attached_files)), __attached_files); // [type = Bool] data_to_send.send_copy forget(add_bool(_email_to_send_message, "send_copy", _send_copy)); // [type = String] data_to_send.reply_to @@ -93,15 +94,16 @@ public define Maybe(Email_to_send) if find_string(_email_to_send_message, "subject") is {failure then failure, success(_subject_) then // [type = String] data_to_send.content if find_string(_email_to_send_message, "content") is {failure then failure, success(_content_) then - // [type = List(String)] data_to_send.files - with _files_ = find_string_list(_email_to_send_message, "files"), + // [type = List(File_ref)] data_to_send.attached_files + with mb__attached_files_ = map_escape(( Message msg ) |-> (Maybe(File_ref)) from_Message(msg), find_messages(_email_to_send_message, "attached_files")), + if mb__attached_files_ is {failure then failure, success(_attached_files_) then // [type = Bool] data_to_send.send_copy if find_bool(_email_to_send_message, "send_copy") is {failure then failure, success(_send_copy_) then // [type = String] data_to_send.reply_to if find_string(_email_to_send_message, "reply_to") is {failure then failure, success(_reply_to_) then - success(data_to_send(_from_, _to_, _cc_, _bcc_, _subject_, _content_, _files_, _send_copy_, _reply_to_)) - }}}}}}}}} + success(data_to_send(_from_, _to_, _cc_, _bcc_, _subject_, _content_, _attached_files_, _send_copy_, _reply_to_)) + }}}}}}}}}} else failure //No valid Alternative found ! else diff --git a/types/generated/file_ref.anubis b/types/generated/file_ref.anubis new file mode 100644 index 0000000..90a4892 --- /dev/null +++ b/types/generated/file_ref.anubis @@ -0,0 +1,89 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2019-05-17 + * Time: 19:05:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit types/generated/mime.anubis + + + +public type File_ref: + file_ref( + String path, //access ptah to the file on the original machine + String name, //name of the file + MIME mime, //mime type of the file + String key, //key is a SHA1 gave by sender to certify it when it will be downloaded + Int size //size of the file in Bytes + ) +. + + File_ref message format + ======================= + + +public define Message + to_Message + ( + File_ref _file_ref + )= + with _file_ref_message = message((Word32)0), // + forget(add_string(_file_ref_message, "__TYPE__", "File_ref")); + if _file_ref is + { + //Alternative file_ref + file_ref(_path, _name, _mime, _key, _size) then + forget(add_string(_file_ref_message, "__TYPE_ALT__", "file_ref")); + // [type = String] file_ref.path + forget(add_string(_file_ref_message, "path", _path)); + // [type = String] file_ref.name + forget(add_string(_file_ref_message, "name", _name)); + // [type = MIME] file_ref.mime + forget(add_message(_file_ref_message, "mime", to_Message(_mime))); + // [type = String] file_ref.key + forget(add_string(_file_ref_message, "key", _key)); + // [type = Int] file_ref.size + forget(add_string(_file_ref_message, "size", to_String(_size))), + + }; + _file_ref_message +. + +public define Maybe(File_ref) + from_Message + ( + Message _file_ref_message + )= + if find_string(_file_ref_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_file_ref_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "File_ref" then + //Alternative file_ref + if __type_alt__ = "file_ref" then //Alternative file_ref + // [type = String] file_ref.path + if find_string(_file_ref_message, "path") is {failure then failure, success(_path_) then + // [type = String] file_ref.name + if find_string(_file_ref_message, "name") is {failure then failure, success(_name_) then + // [type = MIME] file_ref.mime + if find_message(_file_ref_message, "mime") is {failure then failure, success(_mime__msg) then + if (Maybe(MIME))from_Message(_mime__msg) is {failure then failure, success(_mime_) then + // [type = String] file_ref.key + if find_string(_file_ref_message, "key") is {failure then failure, success(_key_) then + // [type = Int] file_ref.size + if find_string(_file_ref_message, "size") is {failure then failure, success(__size_) then + if decimal_scan(__size_) is { failure then failure, success(_size_) then + + success(file_ref(_path_, _name_, _mime_, _key_, _size_)) + }}}}}}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + -- libgit2 0.21.4