@@ -107,30 +107,46 @@ class Properties
107107 :default => proc { |obj | obj . open }
108108 }
109109
110- # these won't be strings for much longer.
111- # maybe later, the Key#inspect could automatically show symbolic guid names if they
112- # are part of this builtin list.
113- # FIXME. hey, nice that my fake string is the same length though :)
114- PS_MAPI = '{not-really-sure-what-this-should-say}'
115- PS_PUBLIC_STRINGS = '{00020329-0000-0000-c000-000000000046}'
116- # string properties in this namespace automatically get added to the internet headers
117- PS_INTERNET_HEADERS = '{00020386-0000-0000-c000-000000000046}'
118- # theres are bunch of outlook ones i think
119- # http://blogs.msdn.com/stephen_griffin/archive/2006/05/10/outlook-2007-beta-documentation-notification-based-indexing-support.aspx
120- # IPM.Appointment
121- PSETID_Appointment = '{00062002-0000-0000-c000-000000000046}'
122- # IPM.Task
123- PSETID_Task = '{00062003-0000-0000-c000-000000000046}'
124- # used for IPM.Contact
125- PSETID_Address = '{00062004-0000-0000-c000-000000000046}'
126- PSETID_Common = '{00062008-0000-0000-c000-000000000046}'
127- # didn't find a source for this name. it is for IPM.StickyNote
128- PSETID_Note = '{0006200e-0000-0000-c000-000000000046}'
129- # for IPM.Activity. also called the journal?
130- PSETID_Log = '{0006200a-0000-0000-c000-000000000046}'
131-
132110 SUBSTG_RX = /__substg1\. 0_([0-9A-F]{4})([0-9A-F]{4})(?:-([0-9A-F]{8}))?/
133111
112+ # the property set guid constants
113+ # these guids are all defined with the macro DEFINE_OLEGUID in mapiguid.h.
114+ # see http://doc.ddart.net/msdn/header/include/mapiguid.h.html
115+ oleguid = proc do |prefix |
116+ Ole ::Types ::Clsid . parse "{#{ prefix } -0000-0000-c000-000000000046}"
117+ end
118+
119+ NAMES = {
120+ oleguid [ '00020328' ] => 'PS_MAPI' ,
121+ oleguid [ '00020329' ] => 'PS_PUBLIC_STRINGS' ,
122+ oleguid [ '00020380' ] => 'PS_ROUTING_EMAIL_ADDRESSES' ,
123+ oleguid [ '00020381' ] => 'PS_ROUTING_ADDRTYPE' ,
124+ oleguid [ '00020382' ] => 'PS_ROUTING_DISPLAY_NAME' ,
125+ oleguid [ '00020383' ] => 'PS_ROUTING_ENTRYID' ,
126+ oleguid [ '00020384' ] => 'PS_ROUTING_SEARCH_KEY' ,
127+ # string properties in this namespace automatically get added to the internet headers
128+ oleguid [ '00020386' ] => 'PS_INTERNET_HEADERS' ,
129+ # theres are bunch of outlook ones i think
130+ # http://blogs.msdn.com/stephen_griffin/archive/2006/05/10/outlook-2007-beta-documentation-notification-based-indexing-support.aspx
131+ # IPM.Appointment
132+ oleguid [ '00062002' ] => 'PSETID_Appointment' ,
133+ # IPM.Task
134+ oleguid [ '00062003' ] => 'PSETID_Task' ,
135+ # used for IPM.Contact
136+ oleguid [ '00062004' ] => 'PSETID_Address' ,
137+ oleguid [ '00062008' ] => 'PSETID_Common' ,
138+ # didn't find a source for this name. it is for IPM.StickyNote
139+ oleguid [ '0006200e' ] => 'PSETID_Note' ,
140+ # for IPM.Activity. also called the journal?
141+ oleguid [ '0006200a' ] => 'PSETID_Log' ,
142+ }
143+
144+ module Constants
145+ NAMES . each { |guid , name | const_set name , guid }
146+ end
147+
148+ include Constants
149+
134150 # access the underlying raw property hash
135151 attr_reader :raw
136152 # unused (non-property) objects after parsing an +Dirent+.
@@ -453,6 +469,8 @@ def body_html
453469 #
454470 # Also contains the code that maps keys to symbolic names.
455471 class Key
472+ include Constants
473+
456474 attr_reader :code , :guid
457475 def initialize code , guid = PS_MAPI
458476 @code , @guid = code , guid
@@ -502,17 +520,21 @@ def == other
502520 alias eql? :==
503521
504522 def inspect
523+ # maybe the way to do this, would be to be able to register guids
524+ # in a global lookup, which are used by Clsid#inspect itself, to
525+ # provide symbolic names...
526+ guid_str = NAMES [ guid ] || "{#{ guid . format } }"
505527 if Integer === code
506528 hex = '0x%04x' % code
507529 if guid == PS_MAPI
508530 # just display as plain hex number
509531 hex
510532 else
511- "#<Key #{ guid } /#{ hex } >"
533+ "#<Key #{ guid_str } /#{ hex } >"
512534 end
513535 else
514536 # display full guid and code
515- "#<Key #{ guid } /#{ code . inspect } >"
537+ "#<Key #{ guid_str } /#{ code . inspect } >"
516538 end
517539 end
518540 end
0 commit comments