1/*
2 mapi.cpp
3
4 Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
5
6 This file is part of KTNEF, the KDE TNEF support library/program.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22 */
23/**
24 * @file
25 * This file is part of the API for handling TNEF data and
26 * provides functions that convert MAPI keycodes to/from tag strings.
27 *
28 * @author Michael Goffioul
29 */
30
31#include "mapi.h"
32#include <QtCore/QMap>
33#include <klocalizedstring.h>
34
35//@cond IGNORE
36static struct
37{
38 int tag;
39 const char *str;
40} MAPI_TagStrings[] =
41{
42 { 0x0002, I18N_NOOP( "Alternate Recipient Allowed" ) },
43 { 0x001A, I18N_NOOP( "Message Class" ) },
44 { 0x0023, I18N_NOOP( "Originator Delivery Report Requested" ) },
45 { 0x0024, I18N_NOOP( "Originator Return Address" ) },
46 { 0x0026, I18N_NOOP( "Priority" ) },
47 { 0x0029, I18N_NOOP( "Read Receipt Requested" ) },
48 { 0x002B, I18N_NOOP( "Recipient Reassignment Prohibited" ) },
49 { 0x002E, I18N_NOOP( "Original Sensitivity" ) },
50 { 0x0031, I18N_NOOP( "Report Tag" ) },
51 { 0x0036, I18N_NOOP( "Sensitivity" ) },
52 { 0x0037, I18N_NOOP2( "@label The subject of an email", "Subject" ) },
53 { 0x0039, I18N_NOOP( "Client Submit Time" ) },
54 { 0x003B, I18N_NOOP( "Sent Representing Search Key" ) },
55 { 0x003D, I18N_NOOP( "Subject Prefix" ) },
56 { 0x0041, I18N_NOOP( "Sent Representing Entry ID" ) },
57 { 0x0042, I18N_NOOP( "Sent Representing Name" ) },
58 { 0x0047, I18N_NOOP( "Message Submission ID" ) },
59 { 0x004D, I18N_NOOP( "Original Author Name" ) },
60 { 0x0062, I18N_NOOP( "Owner Appointment ID" ) },
61 { 0x0063, I18N_NOOP( "Response Requested" ) },
62 { 0x0064, I18N_NOOP( "Sent Representing Address Type" ) },
63 { 0x0065, I18N_NOOP( "Sent Representing E-mail Address" ) },
64 { 0x0070, I18N_NOOP( "Conversation Topic" ) },
65 { 0x0071, I18N_NOOP( "Conversation Index" ) },
66 { 0x007F, I18N_NOOP( "TNEF Correlation Key" ) },
67 { 0x0C17, I18N_NOOP( "Reply Requested" ) },
68 { 0x0C1A, I18N_NOOP( "Sender Name" ) },
69 { 0x0C1D, I18N_NOOP( "Sender Search Key" ) },
70 { 0x0C1E, I18N_NOOP( "Sender Address Type" ) },
71 { 0x0C1F, I18N_NOOP( "Sender E-mail Address" ) },
72 { 0x0E01, I18N_NOOP( "Delete After Submit" ) },
73 { 0x0E02, I18N_NOOP( "Display Bcc" ) },
74 { 0x0E03, I18N_NOOP( "Display Cc" ) },
75 { 0x0E04, I18N_NOOP( "Display To" ) },
76 { 0x0E06, I18N_NOOP( "Message Delivery Time" ) },
77 { 0x0E07, I18N_NOOP( "Message Flags" ) },
78 { 0x0E08, I18N_NOOP( "Message Size" ) },
79 { 0x0E09, I18N_NOOP( "Parent Entry ID" ) },
80 { 0x0E0A, I18N_NOOP( "Sent-Mail Entry ID" ) },
81 { 0x0E12, I18N_NOOP( "Message Recipients" ) },
82 { 0x0E14, I18N_NOOP( "Submit Flags" ) },
83 { 0x0E1B, I18N_NOOP( "Has Attachment" ) },
84 { 0x0E1D, I18N_NOOP( "Normalized Subject" ) },
85 { 0x0E1F, I18N_NOOP( "RTF In Sync" ) },
86 { 0x0E20, I18N_NOOP( "Attachment Size" ) },
87 { 0x0E21, I18N_NOOP( "Attachment Number" ) },
88 { 0x0FF4, I18N_NOOP( "Access" ) },
89 { 0x0FF7, I18N_NOOP( "Access Level" ) },
90 { 0x0FF8, I18N_NOOP( "Mapping Signature" ) },
91 { 0x0FF9, I18N_NOOP( "Record Key" ) },
92 { 0x0FFA, I18N_NOOP( "Store Record Key" ) },
93 { 0x0FFB, I18N_NOOP( "Store Entry ID" ) },
94 { 0x0FFE, I18N_NOOP( "Object Type" ) },
95 { 0x0FFF, I18N_NOOP( "Entry ID" ) },
96 { 0x1000, I18N_NOOP( "Message Body" ) },
97 { 0x1006, I18N_NOOP( "RTF Sync Body CRC" ) },
98 { 0x1007, I18N_NOOP( "RTF Sync Body Count" ) },
99 { 0x1008, I18N_NOOP( "RTF Sync Body Tag" ) },
100 { 0x1009, I18N_NOOP( "RTF Compressed" ) },
101 { 0x1010, I18N_NOOP( "RTF Sync Prefix Count" ) },
102 { 0x1011, I18N_NOOP( "RTF Sync Trailing Count" ) },
103 { 0x1013, I18N_NOOP( "HTML Message Body" ) },
104 { 0x1035, I18N_NOOP( "Message ID" ) },
105 { 0x1042, I18N_NOOP( "Parent's Message ID" ) },
106 { 0x1080, I18N_NOOP( "Action" ) },
107 { 0x1081, I18N_NOOP( "Action Flag" ) },
108 { 0x1082, I18N_NOOP( "Action Date" ) },
109 { 0x3001, I18N_NOOP( "Display Name" ) },
110 { 0x3007, I18N_NOOP( "Creation Time" ) },
111 { 0x3008, I18N_NOOP( "Last Modification Time" ) },
112 { 0x300B, I18N_NOOP( "Search Key" ) },
113 { 0x340D, I18N_NOOP( "Store Support Mask" ) },
114 { 0x3414, I18N_NOOP( "MDB Provider" ) },
115 { 0x3701, I18N_NOOP( "Attachment Data" ) },
116 { 0x3702, I18N_NOOP( "Attachment Encoding" ) },
117 { 0x3703, I18N_NOOP( "Attachment Extension" ) },
118 { 0x3705, I18N_NOOP( "Attachment Method" ) },
119 { 0x3707, I18N_NOOP( "Attachment Long File Name" ) },
120 { 0x370B, I18N_NOOP( "Attachment Rendering Position" ) },
121 { 0x370E, I18N_NOOP( "Attachment Mime Tag" ) },
122 { 0x3714, I18N_NOOP( "Attachment Flags" ) },
123 { 0x3A00, I18N_NOOP( "Account" ) },
124 { 0x3A05, I18N_NOOP( "Generation" ) },
125 { 0x3A06, I18N_NOOP( "Given Name" ) },
126 { 0x3A0A, I18N_NOOP( "Initials" ) },
127 { 0x3A0B, I18N_NOOP( "Keyword" ) },
128 { 0x3A0C, I18N_NOOP( "Language" ) },
129 { 0x3A0D, I18N_NOOP( "Location" ) },
130 { 0x3A11, I18N_NOOP( "Surname" ) },
131 { 0x3A16, I18N_NOOP( "Company Name" ) },
132 { 0x3A17, I18N_NOOP2( "@label The title of a person", "Title" ) },
133 { 0x3A18, I18N_NOOP( "Department Name" ) },
134 { 0x3A26, I18N_NOOP( "Country" ) },
135 { 0x3A27, I18N_NOOP( "Locality" ) },
136 { 0x3A28, I18N_NOOP( "State/Province" ) },
137 { 0x3A44, I18N_NOOP( "Middle Name" ) },
138 { 0x3A45, I18N_NOOP( "Display Name Prefix" ) },
139
140 /* Some TNEF attributes */
141 { 0x0008, I18N_NOOP( "Owner Appointment ID" ) },
142 { 0x0009, I18N_NOOP( "Response Requested" ) },
143 { 0x8000, I18N_NOOP( "From" ) },
144 { 0x8004, I18N_NOOP2( "@label The subject of an email", "Subject" ) },
145 { 0x8005, I18N_NOOP( "Date Sent" ) },
146 { 0x8006, I18N_NOOP( "Date Received" ) },
147 { 0x8007, I18N_NOOP( "Message Status" ) },
148 { 0x8008, I18N_NOOP( "Message Class" ) },
149 { 0x8009, I18N_NOOP( "Message ID" ) },
150 { 0x800A, I18N_NOOP( "Parent ID" ) },
151 { 0x800B, I18N_NOOP( "Conversation ID" ) },
152 { 0x800C, I18N_NOOP( "Body" ) },
153 { 0x800D, I18N_NOOP( "Priority" ) },
154 { 0x800F, I18N_NOOP( "Attachment Data" ) },
155 { 0x8010, I18N_NOOP( "Attachment Title" ) },
156 { 0x8011, I18N_NOOP( "Attachment Meta File" ) },
157 { 0x8012, I18N_NOOP( "Attachment Create Date" ) },
158 { 0x8013, I18N_NOOP( "Attachment Modify Date" ) },
159 { 0x8020, I18N_NOOP( "Date Modified" ) },
160 { 0x9001, I18N_NOOP( "Attachment Transport File Name" ) },
161 { 0x9002, I18N_NOOP( "Attachment Rendering Data" ) },
162 { 0x9003, I18N_NOOP( "MAPI Properties" ) },
163 { 0x9004, I18N_NOOP( "Recipients Table" ) },
164 { 0x9005, I18N_NOOP( "Attachment MAPI Properties" ) },
165 { 0x9006, I18N_NOOP( "TNEF Version" ) },
166 { 0x9007, I18N_NOOP( "OEM Code Page" ) },
167
168 { 0, 0 }
169},
170MAPI_NamedTagStrings[] =
171{
172 { 0x8005, I18N_NOOP( "Contact File Under" ) },
173 { 0x8017, I18N_NOOP( "Contact Last Name And First Name" ) },
174 { 0x8018, I18N_NOOP( "Contact Company And Full Name" ) },
175
176 { 0x8080, I18N_NOOP( "Contact EMail-1 Full" ) },
177 { 0x8082, I18N_NOOP( "Contact EMail-1 Address Type" ) },
178 { 0x8083, I18N_NOOP( "Contact EMail-1 Address" ) },
179 { 0x8084, I18N_NOOP( "Contact EMail-1 Display Name" ) },
180 { 0x8085, I18N_NOOP( "Contact EMail-1 Entry ID" ) },
181
182 { 0x8090, I18N_NOOP( "Contact EMail-2 Full" ) },
183 { 0x8092, I18N_NOOP( "Contact EMail-2 Address Type" ) },
184 { 0x8093, I18N_NOOP( "Contact EMail-2 Address" ) },
185 { 0x8094, I18N_NOOP( "Contact EMail-2 Display Name" ) },
186 { 0x8095, I18N_NOOP( "Contact EMail-2 Entry ID" ) },
187
188 { 0x8208, I18N_NOOP( "Appointment Location" ) },
189 { 0x8208, I18N_NOOP( "Appointment Location" ) },
190 { 0x820D, I18N_NOOP( "Appointment Start Date" ) },
191 { 0x820E, I18N_NOOP( "Appointment End Date" ) },
192 { 0x8213, I18N_NOOP( "Appointment Duration" ) },
193 { 0x8218, I18N_NOOP( "Appointment Response Status" ) },
194 { 0x8223, I18N_NOOP( "Appointment Is Recurring" ) },
195 { 0x8231, I18N_NOOP( "Appointment Recurrence Type" ) },
196 { 0x8232, I18N_NOOP( "Appointment Recurrence Pattern" ) },
197 { 0x8502, I18N_NOOP( "Reminder Time" ) },
198 { 0x8503, I18N_NOOP( "Reminder Set" ) },
199 { 0x8516, I18N_NOOP( "Start Date" ) },
200 { 0x8517, I18N_NOOP( "End Date" ) },
201 { 0x8560, I18N_NOOP( "Reminder Next Time" ) },
202 { 0, 0 }
203};
204static QMap<int,QString> MAPI_TagMap;
205static QMap<int,QString> MAPI_NamedTagMap;
206//@endcond
207
208QString mapiTagString( int key )
209{
210 if ( MAPI_TagMap.count() == 0 ) {
211 for ( int i=0; MAPI_TagStrings[ i ].str; i++ ) {
212 MAPI_TagMap[ MAPI_TagStrings[ i ].tag ] =
213 i18n( MAPI_TagStrings[ i ].str );
214 }
215 }
216 QMap<int,QString>::ConstIterator it = MAPI_TagMap.constFind( key );
217 if ( it == MAPI_TagMap.constEnd() ) {
218 return QString().sprintf( "0x%04X", key );
219 } else {
220 return QString().sprintf( "0x%04X ________: ", key ) + *it;
221 }
222}
223
224QString mapiNamedTagString( int key, int tag )
225{
226 if ( MAPI_NamedTagMap.count() == 0 ) {
227 for ( int i=0; MAPI_NamedTagStrings[ i ].str; i++ ) {
228 MAPI_NamedTagMap[ MAPI_NamedTagStrings[ i ].tag ] =
229 i18n( MAPI_NamedTagStrings[ i ].str );
230 }
231 }
232 QMap<int,QString>::ConstIterator it = MAPI_NamedTagMap.constFind( key );
233 if ( it == MAPI_NamedTagMap.constEnd() ) {
234 if ( tag >= 0 ) {
235 return QString().sprintf( "0x%04X [0x%04X]: ", tag, key ) + *it;
236 } else {
237 return QString().sprintf( "0x%04X ________:", key ) + *it;
238 }
239 } else {
240 return *it;
241 }
242}
243