Skip to content

Commit

Permalink
mapi_lib: use standardized MAPI recipient type names
Browse files Browse the repository at this point in the history
  • Loading branch information
jengelh committed Nov 30, 2021
1 parent e7f53f0 commit b568a5e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 44 deletions.
6 changes: 3 additions & 3 deletions exch/emsmdb/common_util.cpp
Expand Up @@ -1276,7 +1276,7 @@ BOOL common_util_propvals_to_openrecipient(uint32_t cpid,
OPENRECIPIENT_ROW *prow)
{
auto pvalue = ppropvals->get<uint32_t>(PR_RECIPIENT_TYPE);
prow->recipient_type = pvalue == nullptr ? RECIPIENT_TYPE_NONE : *pvalue;
prow->recipient_type = pvalue == nullptr ? MAPI_ORIG : *pvalue;
prow->reserved = 0;
prow->cpid = cpid;
return common_util_propvals_to_recipient(cpid,
Expand All @@ -1293,7 +1293,7 @@ BOOL common_util_propvals_to_readrecipient(uint32_t cpid,
}
prow->row_id = *pvalue;
pvalue = ppropvals->get<uint32_t>(PR_RECIPIENT_TYPE);
prow->recipient_type = pvalue == nullptr ? RECIPIENT_TYPE_NONE : *pvalue;
prow->recipient_type = pvalue == nullptr ? MAPI_ORIG : *pvalue;
prow->reserved = 0;
prow->cpid = cpid;
return common_util_propvals_to_recipient(cpid,
Expand Down Expand Up @@ -2021,7 +2021,7 @@ BOOL common_util_send_message(logon_object *plogon,
if (NULL == pvalue) {
continue;
}
if (!(*static_cast<uint32_t *>(pvalue) & RECIPIENT_TYPE_NEED_RESEND))
if (!(*static_cast<uint32_t *>(pvalue) & MAPI_P1))
continue;
}
/*
Expand Down
6 changes: 3 additions & 3 deletions exch/exmdb_provider/common_util.cpp
Expand Up @@ -1555,15 +1555,15 @@ static BOOL common_util_get_message_display_recipients(
switch (proptag) {
case PR_DISPLAY_TO:
case PR_DISPLAY_TO_A:
recipient_type = RECIPIENT_TYPE_TO;
recipient_type = MAPI_TO;
break;
case PR_DISPLAY_CC:
case PR_DISPLAY_CC_A:
recipient_type = RECIPIENT_TYPE_CC;
recipient_type = MAPI_CC;
break;
case PR_DISPLAY_BCC:
case PR_DISPLAY_BCC_A:
recipient_type = RECIPIENT_TYPE_BCC;
recipient_type = MAPI_BCC;
break;
}
snprintf(sql_string, arsizeof(sql_string), "SELECT recipient_id FROM"
Expand Down
6 changes: 3 additions & 3 deletions exch/exmdb_provider/instance.cpp
Expand Up @@ -1800,15 +1800,15 @@ static BOOL instance_get_message_display_recipients(
switch (proptag) {
case PR_DISPLAY_TO:
case PR_DISPLAY_TO_A:
recipient_type = RECIPIENT_TYPE_TO;
recipient_type = MAPI_TO;
break;
case PR_DISPLAY_CC:
case PR_DISPLAY_CC_A:
recipient_type = RECIPIENT_TYPE_CC;
recipient_type = MAPI_CC;
break;
case PR_DISPLAY_BCC:
case PR_DISPLAY_BCC_A:
recipient_type = RECIPIENT_TYPE_BCC;
recipient_type = MAPI_BCC;
break;
}
size_t offset = 0;
Expand Down
9 changes: 5 additions & 4 deletions exch/exmdb_provider/message.cpp
Expand Up @@ -2926,7 +2926,7 @@ static BOOL message_auto_reply(sqlite3 *psqlite,
if (NULL == pvalue) {
return FALSE;
}
*(uint32_t*)pvalue = RECIPIENT_TYPE_TO;
*static_cast<uint32_t *>(pvalue) = MAPI_TO;
(*prcpts->pparray)->ppropval[1].pvalue = pvalue;
if (!common_util_get_property(MESSAGE_PROPERTIES_TABLE, message_id,
0, psqlite, PR_SENT_REPRESENTING_NAME, &pvalue))
Expand Down Expand Up @@ -4465,12 +4465,12 @@ BOOL exmdb_server_delivery_message(const char *dir,
continue;
}
switch (*(uint32_t*)pvalue) {
case RECIPIENT_TYPE_TO:
case MAPI_TO:
pvalue = pmsg->children.prcpts->pparray[i]->getval(PR_SMTP_ADDRESS);
if (pvalue != nullptr && strcasecmp(account, static_cast<char *>(pvalue)) == 0)
b_to_me = TRUE;
break;
case RECIPIENT_TYPE_CC:
case MAPI_CC:
pvalue = pmsg->children.prcpts->pparray[i]->getval(PR_SMTP_ADDRESS);
if (pvalue != nullptr && strcasecmp(account, static_cast<char *>(pvalue)) == 0)
b_cc_me = TRUE;
Expand Down Expand Up @@ -4499,6 +4499,7 @@ BOOL exmdb_server_delivery_message(const char *dir,
return TRUE;
}
if (TRUE == exmdb_server_check_private()) {
void *pvalue;
if (!common_util_get_property(STORE_PROPERTIES_TABLE, 0, 0,
pdb->psqlite, PR_OOF_STATE, &pvalue))
return FALSE;
Expand Down Expand Up @@ -4591,7 +4592,7 @@ BOOL exmdb_server_delivery_message(const char *dir,
}
}
nt_time = rop_util_current_nttime();
pvalue = tmp_msg.proplist.getval(PROP_TAG_MESSAGEDELIVERYTIME);
auto pvalue = tmp_msg.proplist.getval(PROP_TAG_MESSAGEDELIVERYTIME);
if (NULL != pvalue) {
*(uint64_t*)pvalue = nt_time;
}
Expand Down
2 changes: 1 addition & 1 deletion exch/zcore/common_util.cpp
Expand Up @@ -1802,7 +1802,7 @@ BOOL common_util_send_message(store_object *pstore,
if (NULL == pvalue) {
return FALSE;
}
if (!(*static_cast<uint32_t *>(pvalue) & RECIPIENT_TYPE_NEED_RESEND))
if (!(*static_cast<uint32_t *>(pvalue) & MAPI_P1))
continue;
}
/*
Expand Down
8 changes: 0 additions & 8 deletions include/gromox/mapi_types.hpp
Expand Up @@ -326,14 +326,6 @@ struct RECIPIENT_ROW {
#define CP_ISO2022JPESC 0xC42D
#define CP_ISO2022JPSIO 0xC42E

#define RECIPIENT_TYPE_NONE 0x00000000
#define RECIPIENT_TYPE_TO 0x00000001
#define RECIPIENT_TYPE_CC 0x00000002
#define RECIPIENT_TYPE_BCC 0x00000003

#define RECIPIENT_TYPE_NEED_RESEND 0x10000000
#define RECIPIENT_TYPE_NOT_NEED_RESEND 0x80000000

struct OPENRECIPIENT_ROW {
uint8_t recipient_type;
uint16_t cpid;
Expand Down
9 changes: 9 additions & 0 deletions include/gromox/mapidefs.h
Expand Up @@ -776,6 +776,15 @@ enum mapi_object_type {
MAPI_FORMINFO = 0xC,
};

enum mapi_recipient_type {
MAPI_ORIG = 0U,
MAPI_TO = 1U,
MAPI_CC = 2U,
MAPI_BCC = 3U,
MAPI_P1 = 1U << 28, /* a need to resend */
MAPI_SUBMITTED = 1U << 31, /* no need to resend */
};

enum mapi_sensitivity {
SENSITIVITY_NONE = 0,
SENSITIVITY_PERSONAL = 1,
Expand Down
30 changes: 10 additions & 20 deletions lib/mapi/oxcmail.cpp
Expand Up @@ -1355,26 +1355,17 @@ static BOOL oxcmail_enum_mail_head(
return FALSE;
}
} else if (0 == strcasecmp(tag, "To")) {
if (FALSE == oxcmail_parse_addresses(
penum_param->charset,
field, RECIPIENT_TYPE_TO,
penum_param->pmsg->children.prcpts)) {
if (!oxcmail_parse_addresses(penum_param->charset, field, MAPI_TO,
penum_param->pmsg->children.prcpts))
return FALSE;
}
} else if (0 == strcasecmp(tag, "Cc")) {
if (FALSE == oxcmail_parse_addresses(
penum_param->charset,
field, RECIPIENT_TYPE_CC,
penum_param->pmsg->children.prcpts)) {
if (!oxcmail_parse_addresses(penum_param->charset, field, MAPI_CC,
penum_param->pmsg->children.prcpts))
return FALSE;
}
} else if (0 == strcasecmp(tag, "Bcc")) {
if (FALSE == oxcmail_parse_addresses(
penum_param->charset,
field, RECIPIENT_TYPE_BCC,
penum_param->pmsg->children.prcpts)) {
if (!oxcmail_parse_addresses(penum_param->charset, field, MAPI_BCC,
penum_param->pmsg->children.prcpts))
return FALSE;
}
} else if (0 == strcasecmp(tag, "Return-Receipt-To")) {
tmp_byte = 1;
if (penum_param->pmsg->proplist.set(PROP_TAG_ORIGINATORDELIVERYREPORTREQUESTED, &tmp_byte) != 0)
Expand Down Expand Up @@ -3011,7 +3002,6 @@ static bool oxcmail_enum_dsn_rcpt_fields(DSN_FIELDS *pfields, void *pparam)
char *ptoken2;
BINARY tmp_bin;
char essdn[1280];
uint32_t tmp_int32;
char tmp_buff[1280];
uint32_t status_code;
DSN_ENUM_INFO *pinfo;
Expand Down Expand Up @@ -3083,7 +3073,7 @@ static bool oxcmail_enum_dsn_rcpt_fields(DSN_FIELDS *pfields, void *pparam)
tpropval_array_free(pproplist);
return false;
}
tmp_int32 = RECIPIENT_TYPE_TO;
uint32_t tmp_int32 = MAPI_TO;
if (pproplist->set(PR_RECIPIENT_TYPE, &tmp_int32) != 0)
return false;
if (NULL != f_info.x_display_name) {
Expand Down Expand Up @@ -4781,14 +4771,14 @@ static BOOL oxcmail_export_mail_head(const MESSAGE_CONTENT *pmsg,
goto EXPORT_CONTENT_CLASS;
}
if (oxcmail_export_addresses(pskeleton->charset, pmsg->children.prcpts,
RECIPIENT_TYPE_TO, alloc, tmp_field, GX_ARRAY_SIZE(tmp_field))) {
MAPI_TO, alloc, tmp_field, GX_ARRAY_SIZE(tmp_field))) {
if (FALSE == mime_set_field(
phead, "To", tmp_field)) {
return FALSE;
}
}
if (oxcmail_export_addresses(pskeleton->charset, pmsg->children.prcpts,
RECIPIENT_TYPE_CC, alloc, tmp_field, GX_ARRAY_SIZE(tmp_field))) {
MAPI_CC, alloc, tmp_field, GX_ARRAY_SIZE(tmp_field))) {
if (FALSE == mime_set_field(
phead, "Cc", tmp_field)) {
return FALSE;
Expand All @@ -4801,7 +4791,7 @@ static BOOL oxcmail_export_mail_head(const MESSAGE_CONTENT *pmsg,
"IPM.Task") || 0 == strncasecmp(
pskeleton->pmessage_class, "IPM.Task.", 9)) {
if (oxcmail_export_addresses(pskeleton->charset,
pmsg->children.prcpts, RECIPIENT_TYPE_BCC, alloc,
pmsg->children.prcpts, MAPI_BCC, alloc,
tmp_field, GX_ARRAY_SIZE(tmp_field))) {
if (FALSE == mime_set_field(
phead, "Bcc", tmp_field)) {
Expand Down
3 changes: 1 addition & 2 deletions lib/mapi/tnef.cpp
Expand Up @@ -2463,9 +2463,8 @@ static BOOL tnef_serialize_internal(EXT_PUSH *pext, BOOL b_embedded,
for (size_t i = 0; i < pmsg->children.prcpts->count; ++i) {
pvalue = pmsg->children.prcpts->pparray[i]->getval(PR_RECIPIENT_TYPE);
/* BCC recipients must be excluded */
if (NULL != pvalue && RECIPIENT_TYPE_BCC == *(uint32_t*)pvalue) {
if (pvalue != nullptr && *static_cast<uint32_t *>(pvalue) == MAPI_BCC)
continue;
}
tnef_propset.pplist[tnef_propset.count] =
tnef_convert_recipient(pmsg->children.prcpts->pparray[i],
alloc, get_propname);
Expand Down

0 comments on commit b568a5e

Please sign in to comment.