Class: RCS::MAPISerializer
- Inherits:
-
Object
- Object
- RCS::MAPISerializer
- Includes:
- Tracer
- Defined in:
- lib/rcs-common/serializer.rb
Constant Summary collapse
- TYPES =
{0x03 => {field: :from, action: :unserialize_string}, 0x04 => {field: :rcpt, action: :unserialize_string}, 0x05 => {field: :cc, action: :unserialize_string}, 0x06 => {field: :bcc, action: :unserialize_string}, 0x07 => {field: :subject, action: :unserialize_string}, 0x80 => {field: :mime_body, action: :unserialize_blob}, 0x84 => {field: :text_body, action: :unserialize_blob} }
Constants included from Tracer
Instance Attribute Summary collapse
-
#delivery_time ⇒ Object
readonly
Returns the value of attribute delivery_time.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize ⇒ MAPISerializer
constructor
A new instance of MAPISerializer.
- #unserialize(stream) ⇒ Object
- #unserialize_blob(str) ⇒ Object
- #unserialize_string(str) ⇒ Object
Methods included from Tracer
#thread_name, #trace, #trace_ensure_log_folders, #trace_init, #trace_named_put, #trace_named_remove, #trace_nested_pop, #trace_nested_push, #trace_setup
Constructor Details
#initialize ⇒ MAPISerializer
Returns a new instance of MAPISerializer.
42 43 44 |
# File 'lib/rcs-common/serializer.rb', line 42 def initialize @fields = {} end |
Instance Attribute Details
#delivery_time ⇒ Object (readonly)
Returns the value of attribute delivery_time.
31 32 33 |
# File 'lib/rcs-common/serializer.rb', line 31 def delivery_time @delivery_time end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
31 32 33 |
# File 'lib/rcs-common/serializer.rb', line 31 def fields @fields end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
31 32 33 |
# File 'lib/rcs-common/serializer.rb', line 31 def flags @flags end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
31 32 33 |
# File 'lib/rcs-common/serializer.rb', line 31 def size @size end |
Instance Method Details
#unserialize(stream) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rcs-common/serializer.rb', line 46 def unserialize(stream) # HEADER header_begin = stream.pos tot_size = stream.read_dword @version = stream.read_dword @status = stream.read_dword @flags = stream.read_dword @size = stream.read_dword low, high = stream.read(8).unpack 'V2' @delivery_time = Time.from_filetime high, low @n_attachments = stream.read_dword # BODY header_length = stream.pos - header_begin content = stream.read(tot_size - header_length) until content.empty? prefix = content.slice!(0, 4) type, size = Serialization.decode_prefix prefix str = content.slice!(0, size) selector = TYPES[type] unless selector.nil? @fields[selector[:field]] = self.send(selector[:action], str) if TYPES.has_key? type end end self end |
#unserialize_blob(str) ⇒ Object
80 81 82 |
# File 'lib/rcs-common/serializer.rb', line 80 def unserialize_blob(str) str end |
#unserialize_string(str) ⇒ Object
76 77 78 |
# File 'lib/rcs-common/serializer.rb', line 76 def unserialize_string(str) str.utf16le_to_utf8 end |