File indexing completed on 2024-04-28 05:19:27
0001 /* 0002 mapi.cpp 0003 0004 SPDX-FileCopyrightText: 2002 Michael Goffioul <kdeprint@swing.be> 0005 0006 This file is part of KTNEF, the KDE TNEF support library/program. 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 /** 0011 * @file 0012 * This file is part of the API for handling TNEF data and 0013 * provides functions that convert MAPI keycodes to/from tag strings. 0014 * 0015 * @author Michael Goffioul 0016 */ 0017 0018 #include "mapi.h" 0019 #include <KLocalizedString> 0020 #include <QMap> 0021 //@cond IGNORE 0022 #include <KLazyLocalizedString> 0023 static const struct { 0024 int tag; 0025 const KLazyLocalizedString str; 0026 } MAPI_TagStrings[] = {{0x0002, kli18n("Alternate Recipient Allowed")}, 0027 {0x001A, kli18n("Message Class")}, 0028 {0x0023, kli18n("Originator Delivery Report Requested")}, 0029 {0x0024, kli18n("Originator Return Address")}, 0030 {0x0026, kli18n("Priority")}, 0031 {0x0029, kli18n("Read Receipt Requested")}, 0032 {0x002B, kli18n("Recipient Reassignment Prohibited")}, 0033 {0x002E, kli18n("Original Sensitivity")}, 0034 {0x0031, kli18n("Report Tag")}, 0035 {0x0036, kli18n("Sensitivity")}, 0036 {0x0037, kli18n("Subject")}, 0037 {0x0039, kli18n("Client Submit Time")}, 0038 {0x003B, kli18n("Sent Representing Search Key")}, 0039 {0x003D, kli18n("Subject Prefix")}, 0040 {0x0041, kli18n("Sent Representing Entry ID")}, 0041 {0x0042, kli18n("Sent Representing Name")}, 0042 {0x0047, kli18n("Message Submission ID")}, 0043 {0x004D, kli18n("Original Author Name")}, 0044 {0x0062, kli18n("Owner Appointment ID")}, 0045 {0x0063, kli18n("Response Requested")}, 0046 {0x0064, kli18n("Sent Representing Address Type")}, 0047 {0x0065, kli18n("Sent Representing E-mail Address")}, 0048 {0x0070, kli18n("Conversation Topic")}, 0049 {0x0071, kli18n("Conversation Index")}, 0050 {0x007F, kli18n("TNEF Correlation Key")}, 0051 {0x0C17, kli18n("Reply Requested")}, 0052 {0x0C1A, kli18n("Sender Name")}, 0053 {0x0C1D, kli18n("Sender Search Key")}, 0054 {0x0C1E, kli18n("Sender Address Type")}, 0055 {0x0C1F, kli18n("Sender E-mail Address")}, 0056 {0x0E01, kli18n("Delete After Submit")}, 0057 {0x0E02, kli18n("Display Bcc")}, 0058 {0x0E03, kli18n("Display Cc")}, 0059 {0x0E04, kli18n("Display To")}, 0060 {0x0E06, kli18n("Message Delivery Time")}, 0061 {0x0E07, kli18n("Message Flags")}, 0062 {0x0E08, kli18n("Message Size")}, 0063 {0x0E09, kli18n("Parent Entry ID")}, 0064 {0x0E0A, kli18n("Sent-Mail Entry ID")}, 0065 {0x0E12, kli18n("Message Recipients")}, 0066 {0x0E14, kli18n("Submit Flags")}, 0067 {0x0E1B, kli18n("Has Attachment")}, 0068 {0x0E1D, kli18n("Normalized Subject")}, 0069 {0x0E1F, kli18n("RTF In Sync")}, 0070 {0x0E20, kli18n("Attachment Size")}, 0071 {0x0E21, kli18n("Attachment Number")}, 0072 {0x0FF4, kli18n("Access")}, 0073 {0x0FF7, kli18n("Access Level")}, 0074 {0x0FF8, kli18n("Mapping Signature")}, 0075 {0x0FF9, kli18n("Record Key")}, 0076 {0x0FFA, kli18n("Store Record Key")}, 0077 {0x0FFB, kli18n("Store Entry ID")}, 0078 {0x0FFE, kli18n("Object Type")}, 0079 {0x0FFF, kli18n("Entry ID")}, 0080 {0x1000, kli18n("Message Body")}, 0081 {0x1006, kli18n("RTF Sync Body CRC")}, 0082 {0x1007, kli18n("RTF Sync Body Count")}, 0083 {0x1008, kli18n("RTF Sync Body Tag")}, 0084 {0x1009, kli18n("RTF Compressed")}, 0085 {0x1010, kli18n("RTF Sync Prefix Count")}, 0086 {0x1011, kli18n("RTF Sync Trailing Count")}, 0087 {0x1013, kli18n("HTML Message Body")}, 0088 {0x1035, kli18n("Message ID")}, 0089 {0x1042, kli18n("Parent's Message ID")}, 0090 {0x1080, kli18n("Action")}, 0091 {0x1081, kli18n("Action Flag")}, 0092 {0x1082, kli18n("Action Date")}, 0093 {0x3001, kli18n("Display Name")}, 0094 {0x3007, kli18n("Creation Time")}, 0095 {0x3008, kli18n("Last Modification Time")}, 0096 {0x300B, kli18n("Search Key")}, 0097 {0x340D, kli18n("Store Support Mask")}, 0098 {0x3414, kli18n("MDB Provider")}, 0099 {0x3701, kli18n("Attachment Data")}, 0100 {0x3702, kli18n("Attachment Encoding")}, 0101 {0x3703, kli18n("Attachment Extension")}, 0102 {0x3705, kli18n("Attachment Method")}, 0103 {0x3707, kli18n("Attachment Long File Name")}, 0104 {0x370B, kli18n("Attachment Rendering Position")}, 0105 {0x370E, kli18n("Attachment Mime Tag")}, 0106 {0x3714, kli18n("Attachment Flags")}, 0107 {0x3A00, kli18n("Account")}, 0108 {0x3A05, kli18n("Generation")}, 0109 {0x3A06, kli18n("Given Name")}, 0110 {0x3A0A, kli18n("Initials")}, 0111 {0x3A0B, kli18n("Keyword")}, 0112 {0x3A0C, kli18n("Language")}, 0113 {0x3A0D, kli18n("Location")}, 0114 {0x3A11, kli18n("Surname")}, 0115 {0x3A16, kli18n("Company Name")}, 0116 {0x3A17, kli18n("Title")}, 0117 {0x3A18, kli18n("Department Name")}, 0118 {0x3A26, kli18n("Country")}, 0119 {0x3A27, kli18n("Locality")}, 0120 {0x3A28, kli18n("State/Province")}, 0121 {0x3A44, kli18n("Middle Name")}, 0122 {0x3A45, kli18n("Display Name Prefix")}, 0123 0124 /* Some TNEF attributes */ 0125 {0x0008, kli18n("Owner Appointment ID")}, 0126 {0x0009, kli18n("Response Requested")}, 0127 {0x8000, kli18n("From")}, 0128 {0x8004, kli18n("Subject")}, 0129 {0x8005, kli18n("Date Sent")}, 0130 {0x8006, kli18n("Date Received")}, 0131 {0x8007, kli18n("Message Status")}, 0132 {0x8008, kli18n("Message Class")}, 0133 {0x8009, kli18n("Message ID")}, 0134 {0x800A, kli18n("Parent ID")}, 0135 {0x800B, kli18n("Conversation ID")}, 0136 {0x800C, kli18n("Body")}, 0137 {0x800D, kli18n("Priority")}, 0138 {0x800F, kli18n("Attachment Data")}, 0139 {0x8010, kli18n("Attachment Title")}, 0140 {0x8011, kli18n("Attachment Meta File")}, 0141 {0x8012, kli18n("Attachment Create Date")}, 0142 {0x8013, kli18n("Attachment Modify Date")}, 0143 {0x8020, kli18n("Date Modified")}, 0144 {0x9001, kli18n("Attachment Transport File Name")}, 0145 {0x9002, kli18n("Attachment Rendering Data")}, 0146 {0x9003, kli18n("MAPI Properties")}, 0147 {0x9004, kli18n("Recipients Table")}, 0148 {0x9005, kli18n("Attachment MAPI Properties")}, 0149 {0x9006, kli18n("TNEF Version")}, 0150 {0x9007, kli18n("OEM Code Page")}, 0151 {0, KLazyLocalizedString()}}, 0152 MAPI_NamedTagStrings[] = {{0x8005, kli18n("Contact File Under")}, 0153 {0x8017, kli18n("Contact Last Name And First Name")}, 0154 {0x8018, kli18n("Contact Company And Full Name")}, 0155 0156 {0x8080, kli18n("Contact EMail-1 Full")}, 0157 {0x8082, kli18n("Contact EMail-1 Address Type")}, 0158 {0x8083, kli18n("Contact EMail-1 Address")}, 0159 {0x8084, kli18n("Contact EMail-1 Display Name")}, 0160 {0x8085, kli18n("Contact EMail-1 Entry ID")}, 0161 0162 {0x8090, kli18n("Contact EMail-2 Full")}, 0163 {0x8092, kli18n("Contact EMail-2 Address Type")}, 0164 {0x8093, kli18n("Contact EMail-2 Address")}, 0165 {0x8094, kli18n("Contact EMail-2 Display Name")}, 0166 {0x8095, kli18n("Contact EMail-2 Entry ID")}, 0167 0168 {0x8208, kli18n("Appointment Location")}, 0169 {0x8208, kli18n("Appointment Location")}, 0170 {0x820D, kli18n("Appointment Start Date")}, 0171 {0x820E, kli18n("Appointment End Date")}, 0172 {0x8213, kli18n("Appointment Duration")}, 0173 {0x8218, kli18n("Appointment Response Status")}, 0174 {0x8223, kli18n("Appointment Is Recurring")}, 0175 {0x8231, kli18n("Appointment Recurrence Type")}, 0176 {0x8232, kli18n("Appointment Recurrence Pattern")}, 0177 {0x8502, kli18n("Reminder Time")}, 0178 {0x8503, kli18n("Reminder Set")}, 0179 {0x8516, kli18n("Start Date")}, 0180 {0x8517, kli18n("End Date")}, 0181 {0x8560, kli18n("Reminder Next Time")}, 0182 {0, KLazyLocalizedString()}}; 0183 0184 using TagMap = QMap<int, QString>; 0185 Q_GLOBAL_STATIC(TagMap, MAPI_TagMap) 0186 Q_GLOBAL_STATIC(TagMap, MAPI_NamedTagMap) 0187 0188 //@endcond 0189 0190 QString KTnef::mapiTagString(int key) 0191 { 0192 if (MAPI_TagMap()->isEmpty()) { 0193 for (int i = 0; !KLocalizedString(MAPI_TagStrings[i].str).isEmpty(); i++) { 0194 (*MAPI_TagMap())[MAPI_TagStrings[i].tag] = KLocalizedString(MAPI_TagStrings[i].str).toString(); 0195 } 0196 } 0197 auto it = MAPI_TagMap()->constFind(key); 0198 if (it == MAPI_TagMap()->constEnd()) { 0199 return QString::asprintf("0x%04X", key); 0200 } else { 0201 return QString::asprintf("0x%04X ________: ", key) + *it; 0202 } 0203 } 0204 0205 QString KTnef::mapiNamedTagString(int key, int tag) 0206 { 0207 if (MAPI_NamedTagMap()->isEmpty()) { 0208 for (int i = 0; !KLocalizedString(MAPI_NamedTagStrings[i].str).isEmpty(); i++) { 0209 (*MAPI_TagMap())[MAPI_TagStrings[i].tag] = KLocalizedString(MAPI_NamedTagStrings[i].str).toString(); 0210 } 0211 } 0212 auto it = MAPI_NamedTagMap()->constFind(key); 0213 if (it != MAPI_NamedTagMap()->constEnd()) { 0214 if (tag >= 0) { 0215 return QString::asprintf("0x%04X [0x%04X]: ", tag, key) + *it; 0216 } else { 0217 return QString::asprintf("0x%04X ________:", key) + *it; 0218 } 0219 } else { 0220 return QString::asprintf("0x%04X ________:", key); 0221 } 0222 }