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, BlockParser::USE_MAIN_DATA

Instance Attribute Summary collapse

Attributes inherited from BlockParser

#data_chunks

Instance Method Summary collapse

Methods inherited from BlockParser

#get_data_array, #get_data_indirect, #get_data_indirect_io, #handle_indirect_values, #load_page_header, #load_root_header

Constructor Details

#initialize(node) ⇒ AttachmentTable

Returns a new instance of AttachmentTable.

Parameters:



1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
# File 'lib/mapi/pst.rb', line 1553

def initialize node
	@node = node
	# no super, we only actually want BlockParser2#idx2
	#@table = nil
	#return unless node.sub_block
	#return unless block = sub_block[ID2_ATTACHMENTS]
	## FIXME make a fake desc.
	#@fake_node = OpenStruct.new :block => block, :pst => node.pst, :sub_block => node.sub_block
	if @node.has_sub ID2_ATTACHMENTS
		@table = RawPropertyStoreTable.new @node, ID2_ATTACHMENTS
	else
		@table = []
	end
end

Instance Attribute Details

#nodeNodePtr (readonly)

Returns:



1547
1548
1549
# File 'lib/mapi/pst.rb', line 1547

def node
  @node
end

#tableRawPropertyStoreTable (readonly)



1550
1551
1552
# File 'lib/mapi/pst.rb', line 1550

def table
  @table
end

Instance Method Details

#to_aArray<Array<Array(Integer, Integer, Object)>>

Returns:

  • (Array<Array<Array(Integer, Integer, Object)>>)


1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
# File 'lib/mapi/pst.rb', line 1569

def to_a
	return [] if !table
	table.map do |attachment|
		attachment = attachment.to_a
		# potentially merge with yet more properties
		# this still seems pretty broken - especially the property overlap
		if attachment_id2 = attachment.assoc(PR_ATTACHMENT_ID2)
			# verify existence of this record
			if @node.has_sub attachment_id2.last
				RawPropertyStore.new(@node, attachment_id2.last).each do |a, b, c|
					record = attachment.assoc a
					attachment << record = [] unless record
					record.replace [a, b, c]
				end
			else
				warn "attachment record is missing"
			end
		end
		attachment
	end
end