1
0
Fork 0

strip fixes -- more fixes

This commit is contained in:
bagyenda 2011-01-06 05:55:35 +00:00
parent 442846f4c0
commit 919aef48d5
3 changed files with 22 additions and 10 deletions

View File

@ -1,3 +1,5 @@
2011-01-06 P. A. Bagyenda <bagyenda@dsmagic.com>
* More fixes for strip-prefixes -- now applies to sender address as well
2011-01-05 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added strip-prefixes option for each mmsc connection (mmsbox)
* Fixed building of shared libs on mac os x

View File

@ -22,11 +22,12 @@
#define QFNAMEMAX 128
typedef struct MmsEnvelopeTo {
Octstr *rcpt; /* Recipient address. */
Octstr *rcpt; /* Recipient address. */
int process; /* 1 if delivery to this recipient should be attempted.
* Flags below for details.
*/
enum {SFailed=0, SSuccess, SDefered, SUnknown} flag;
void *_x; /* Used by client modules */
} MmsEnvelopeTo;
typedef struct MmsEnvelope {

View File

@ -1594,19 +1594,20 @@ static int cmp_mrcpt(struct MRcpt_t *m, MmscGrp *mmc)
static void process_send_res(MmsEnvelope *e, MmsMsg *msg,
MmsEnvelopeTo *to, MmscGrp *mmc,
int res, Octstr *err, List *errl, Octstr *new_msgid,
int first_one)
int first_one)
{
Octstr *rcpt = to->_x ? to->_x : to->rcpt; /* Might have a cleaned up recipient address */
time_t tnow = time(NULL);
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
to->process = 0;
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
queue_dlr(mmc, e->from, to->rcpt, new_msgid, octstr_imm("Forwarded"), "MM7-Out", errl);
queue_dlr(mmc, e->from, rcpt, new_msgid, octstr_imm("Forwarded"), "MM7-Out", errl);
} else if (res == MMS_SEND_ERROR_FATAL && mmc) {
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
queue_dlr(mmc, e->from, to->rcpt, e->msgId,
queue_dlr(mmc, e->from, rcpt, e->msgId,
(e->expiryt != 0 && e->expiryt < tnow) ?
octstr_imm("Expired") : octstr_imm("Rejected"),
"MM7-Out", errl);
@ -1636,7 +1637,7 @@ static void process_send_res(MmsEnvelope *e, MmsMsg *msg,
/* Do CDR */
cdrfs->logcdr(e->created,
octstr_get_cstr(e->from),
octstr_get_cstr(to->rcpt),
octstr_get_cstr(rcpt),
octstr_get_cstr(e->msgId),
mmc ? octstr_get_cstr(mmc->id) : NULL, /* Should we touch mmc here? XXX */
e->src_interface,
@ -1658,14 +1659,14 @@ static void process_send_res(MmsEnvelope *e, MmsMsg *msg,
if (err == NULL)
mms_info(0, "MM7", NULL, "%s MMSBox Outgoing Queue MMS Send: From %s, to %s, msgsize=%ld: msgid=[%s]",
SEND_ERROR_STR(res),
octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize,
octstr_get_cstr(e->from), octstr_get_cstr(rcpt), e->msize,
new_msgid ? octstr_get_cstr(new_msgid) : "N/A");
else
mms_error_ex("MT", 0,
"MM7", NULL,
"%s MMSBox Outgoing Queue MMS Send: From %s, to %s, msgsize=%ld: %s",
SEND_ERROR_STR(res),
octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize, octstr_get_cstr(err));
octstr_get_cstr(e->from), octstr_get_cstr(rcpt), e->msize, octstr_get_cstr(err));
}
/* Make a list of recpients up to max_rcpt */
@ -1715,6 +1716,7 @@ static int sendMsg(MmsEnvelope *e)
int res = MMS_SEND_OK;
MRcpt_t *m;
to->_x = NULL; /* Clear it. */
if (e->expiryt != 0 && /* Handle message expiry. */
e->expiryt < tnow) {
err = octstr_format("MMSC error: Message expired while sending to %S!", to->rcpt);
@ -1780,6 +1782,10 @@ static int sendMsg(MmsEnvelope *e)
int is_mm4 = (mmc && mmc->type == MM4_MMSC && mmc->started);
List *xto = gwlist_create();
Octstr *zto = NULL;
Octstr *oldfrom = octstr_duplicate(e->from); /* Save old from address */
if (mmc && mmc->strip_prefixes) /* strip prefixes from sender address */
_mms_fixup_address(&e->from, NULL, mmc->strip_prefixes, 1);
/* Make recipient list */
for (j = 0; j < gwlist_len(lto); j++) {
@ -1852,9 +1858,9 @@ static int sendMsg(MmsEnvelope *e)
/* For each recipient, process result */
for (j = 0; j < gwlist_len(lto); j++) {
MmsEnvelopeTo *to = gwlist_get(lto, j);
process_send_res(e, msg, to, mmc, res, err, errl, new_msgid, j == 0);
if (to)
to->_x = gwlist_get(xto, j);
process_send_res(e, msg, to, mmc, res, err, errl, new_msgid, j == 0);
}
octstr_destroy(zto);
gwlist_destroy(xto, (void *)octstr_destroy);
@ -1864,6 +1870,9 @@ static int sendMsg(MmsEnvelope *e)
gwlist_destroy(lto, NULL);
e->lasttry = tnow;
octstr_destroy(e->from);
e->from = oldfrom; /* restore old from address */
if (qfs->mms_queue_update(e) == 1) {
e = NULL;
break; /* Queue entry gone. */