Class: Mapi::Pst::AttachmentTable

Inherits:
BlockParser show all
Defined in:
lib/mapi/pst.rb

Constant Summary collapse

PR_ATTACHMENT_ID2 =

a “fake” MAPI property name for this constant. if you get a mapi property with this value, it is the id2 value to use to get attachment data.

0x67f2

Constants inherited from BlockParser

BlockParser::ID2_ATTACHMENTS, BlockParser::ID2_RECIPIENTS, BlockParser::IMMEDIATE_TYPES, BlockParser::INDIRECT_TYPES, BlockParser::PR_BODY_HTML, BlockParser::PR_SUBJECT, BlockParser::TYPES

Instance Attribute Summary collapse

Attributes inherited from BlockParser

#data, #data_chunks, #offset_tables

Instance Method Summary collapse

Methods inherited from BlockParser

#get_data_indirect, #get_data_indirect_io, #handle_indirect_values, #idx2, #load_header

Constructor Details

#initialize(desc) ⇒ AttachmentTable



1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/mapi/pst.rb', line 1442

def initialize desc
  @desc = desc
  # no super, we only actually want BlockParser2#idx2
  @table = nil
  return unless desc.list_index
  return unless idx = idx2[ID2_ATTACHMENTS]
  # FIXME make a fake desc.
  @desc2 = OpenStruct.new :desc => idx, :pst => desc.pst, :list_index => desc.list_index
  @table = RawPropertyStoreTable.new @desc2
end

Instance Attribute Details

#descObject (readonly)

Returns the value of attribute desc.



1441
1442
1443
# File 'lib/mapi/pst.rb', line 1441

def desc
  @desc
end

#tableObject (readonly)

Returns the value of attribute table.



1441
1442
1443
# File 'lib/mapi/pst.rb', line 1441

def table
  @table
end

Instance Method Details

#to_aObject



1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
# File 'lib/mapi/pst.rb', line 1453

def to_a
  return [] if !table
  table.map do |attachment|
    attachment = attachment.to_a
    #p attachment
    # potentially merge with yet more properties
    # this still seems pretty broken - especially the property overlap
    if attachment_id2 = attachment.assoc(PR_ATTACHMENT_ID2)
      #p attachment_id2.last
      #p idx2[attachment_id2.last]
      @desc2.desc = idx2[attachment_id2.last]
      RawPropertyStore.new(@desc2).each do |a, b, c|
        record = attachment.assoc a
        attachment << record = [] unless record
        record.replace [a, b, c]
      end
    end
    attachment
  end
end