1
0
Fork 0

improved dlr

This commit is contained in:
bagyenda 2008-09-14 11:33:59 +00:00
parent 0dfdfdc305
commit 3e3b9b2b2b
4 changed files with 56 additions and 57 deletions

View File

@ -78,11 +78,12 @@ done:
return res;
}
int mmsbox_send_report(Octstr *from, char *report_type,
Octstr *dlr_url, Octstr *status,
Octstr *msgid, Octstr *mmc_id, Octstr *mmc_gid,
Octstr *orig_transid, Octstr *uaprof,
time_t uaprof_tstamp)
static int mmsbox_send_report(Octstr *from, char *report_type,
Octstr *dlr_url, Octstr *status,
Octstr *msgid, Octstr *orig_msgid,
Octstr *mmc_id, Octstr *mmc_gid,
Octstr *orig_transid, Octstr *uaprof,
time_t uaprof_tstamp)
{
Octstr *url = NULL;
@ -117,6 +118,10 @@ int mmsbox_send_report(Octstr *from, char *report_type,
octstr_get_cstr(xtransid ? xtransid : orig_transid));
if (msgid)
http_header_add(rh, "X-Mbuni-Message-ID", octstr_get_cstr(msgid));
if (orig_msgid)
http_header_add(rh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(orig_msgid));
if (uaprof) {
Octstr *sx = date_format_http(uaprof_tstamp);
http_header_add(rh, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
@ -159,6 +164,8 @@ static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype)
octstr_delete(newmsgid, 0, x+1);
mms_replace_header_value(m, "Message-ID", octstr_get_cstr(newmsgid));
/* Add it back as original. */
mms_replace_header_value(m, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value));
mms_dlr_url_remove(value, "delivery-report", mmc->group_id);
}
@ -297,7 +304,7 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
octstr_get_cstr(from), octstr_get_cstr(value), octstr_get_cstr(desc),
octstr_get_cstr(h->m->id));
mmsbox_send_report(from, "delivery-report", NULL,
value, msgid, h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
value, msgid, NULL, h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
mms_log("DeliveryReport",
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
@ -336,8 +343,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
msgid = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
mmsbox_send_report(from,
"read-report", NULL, value, msgid,
h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
"read-report", NULL, value, msgid, NULL,
h->m->id, h->m->group_id, NULL, uaprof, uaprof_tstamp);
octstr_destroy(value);
mms_log("ReadReport",
@ -380,6 +387,20 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
return MM7_SOAP_STATUS_OK(status) ? 0 : -1;
}
/* Helper func to avoid code duplication below. */
static void handle_report_dispatch(MmscGrp *m, Octstr *hfrom, char *rtype, List *mh, Octstr *status_hdr)
{
Octstr *value = http_header_value(mh, status_hdr);
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
Octstr *value3 = http_header_value(mh, octstr_imm("X-Mbuni-Orig-Message-ID"));
mmsbox_send_report(hfrom, rtype, NULL, value, value2, value3, m->id,
m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
octstr_destroy(value3);
}
static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
{
MmsMsg *m = NULL;
@ -524,14 +545,8 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
hstatus = HTTP_NO_CONTENT;
} else
hstatus = HTTP_INTERNAL_SERVER_ERROR;
} else {
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Status"));
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
mmsbox_send_report(hfrom, "delivery-report", NULL, value, value2, h->m->id, h->m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
}
} else
handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status"));
break;
case MMS_MSGTYPE_READ_ORIG_IND:
@ -554,16 +569,9 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
hstatus = HTTP_NO_CONTENT;
} else
hstatus = HTTP_INTERNAL_SERVER_ERROR;
} else {
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Read-Status"));
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
mmsbox_send_report(hfrom, "read-report", NULL, value, value2, h->m->id,
h->m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
}
} else
handle_report_dispatch(h->m, hfrom, "read-report", mh, octstr_imm("X-Mms-Read-Status"));
break;
}
@ -762,16 +770,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
hstatus = HTTP_OK;
} else
hstatus = HTTP_INTERNAL_SERVER_ERROR;
} else {
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Status"));
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
mmsbox_send_report(hfrom, "delivery-report", NULL, value, value2,
h->m->id, h->m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
}
} else
handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status"));
break;
case MMS_MSGTYPE_READ_ORIG_IND:
@ -795,15 +795,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
hstatus = HTTP_NO_CONTENT;
} else
hstatus = HTTP_INTERNAL_SERVER_ERROR;
} else {
Octstr *value = http_header_value(mh, octstr_imm("X-Mms-Read-Status"));
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
mmsbox_send_report(hfrom, "read-report", NULL, value, value2, h->m->id,
h->m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
}
} else
handle_report_dispatch(h->m, hfrom, "read-report", mh, octstr_imm("X-Mms-Read-Status"));
break;
}
@ -1354,13 +1347,14 @@ static int sendMsg(MmsEnvelope *e)
if (res == MMS_SEND_OK || res == MMS_SEND_QUEUED) {
to->process = 0;
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
octstr_imm("Sent"), new_msgid, mmc->id, mmc->group_id, otransid, NULL, -1);
octstr_imm("Sent"), new_msgid, NULL,
mmc->id, mmc->group_id, otransid, NULL, -1);
} else if (res == MMS_SEND_ERROR_FATAL && mmc)
mmsbox_send_report(to->rcpt, "delivery-report",
e->url1,
(e->expiryt != 0 && e->expiryt < tnow) ?
octstr_imm("Expired") : octstr_imm("Rejected"),
e->msgId, mmc->id, mmc->group_id, otransid, NULL, -1);
e->url1,
(e->expiryt != 0 && e->expiryt < tnow) ?
octstr_imm("Expired") : octstr_imm("Rejected"),
e->msgId, NULL, mmc->id, mmc->group_id, otransid, NULL, -1);
if (res == MMS_SEND_ERROR_FATAL)
to->process = 0; /* No more attempts. */
@ -1392,9 +1386,9 @@ static int sendMsg(MmsEnvelope *e)
else
mms_error_ex("MT", 0,
"MM7", NULL,
"%s MMSBox Outgoing Queue MMS Send: From %s, to %s, msgsize=%ld",
"%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(e->from), octstr_get_cstr(to->rcpt), e->msize, octstr_get_cstr(err));
octstr_destroy(new_msgid);
octstr_destroy(err);

View File

@ -639,11 +639,12 @@ int main(int argc, char *argv[])
sleep(2);
/* Wait for the sender thread, then quit. */
gwthread_join(qthread); /* Wait for it to die... */
if (qthread >= 0)
gwthread_join(qthread); /* Wait for it to die... */
if (sendmms_port.port > 0)
if (sendmms_port.port > 0 && sthread >= 0)
gwthread_join(sthread);
mmsbox_settings_cleanup();
mms_info(0, "mmsbox", NULL, "Shutdown complete..");

View File

@ -18,11 +18,14 @@ extern int rstop;
void mms_dlr_url_put(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr *dlr_url, Octstr *transid);
int mms_dlr_url_get(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr **dlr_url, Octstr **transid);
void mms_dlr_url_remove(Octstr *msgid, char *rtype, Octstr *mmc_gid);
#if 0
int mmsbox_send_report(Octstr *from, char *report_type,
Octstr *dlr_url, Octstr *status,
Octstr *msgid, Octstr *mmc_id, Octstr *mmc_gid,
Octstr *msgid, Octstr *orig_msgid,
Octstr *mmc_id, Octstr *mmc_gid,
Octstr *orig_transid, Octstr *uaprof,
time_t uaprof_tstamp);
#endif
void mmsc_receive_func(MmscGrp *m);
void mmsbox_outgoing_queue_runner(int *rstop);

View File

@ -778,7 +778,8 @@ void mmsbox_settings_cleanup(void)
if (admin_port > 0) {
http_close_port(admin_port);
gwthread_join(admin_thread);
if (admin_thread >= 0)
gwthread_join(admin_thread);
mms_info(0, "mmsbox", NULL,"Admin port on %d, shutdown", (int)admin_port);
}
cdrfs->cleanup();