1
0
Fork 0

added send-dlr-on-fetch config param

This commit is contained in:
bagyenda 2007-08-09 09:32:49 +00:00
parent 8124439d44
commit 9cbf72f5f1
7 changed files with 132 additions and 152 deletions

View File

@ -1,3 +1,5 @@
2007-08-09 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added send-dlr-on-fetch config param to MMC settings
2007-08-08 P. A. Bagyenda <bagyenda@dsmagic.com> 2007-08-08 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added User-Agent and UAProf URL arguments to call to prov-notify script in MMC. * Added User-Agent and UAProf URL arguments to call to prov-notify script in MMC.
2007-08-06 P. A. Bagyenda <bagyenda@dsmagic.com> 2007-08-06 P. A. Bagyenda <bagyenda@dsmagic.com>

View File

@ -1184,6 +1184,27 @@ lists all the configuration directives. The column <b>Mode</b>
&nbsp; &nbsp;</td> &nbsp; &nbsp;</td>
</tr> </tr>
<tr >
<td valign=top >
<tt>send-dlr-on-fetch</tt>
&nbsp; &nbsp;</td>
<td valign=top >
<i>MMSC</i>
&nbsp; &nbsp;
</td>
<td valign=top >
Boolean
&nbsp; &nbsp;</td>
<td valign=top >
The MMSC sends a confirmation delivery report to the sender only
when the recipient confirms receipt on the MM1 interface. If you
want a report as soon as the recipient fetches the message (before
receipt of the acknowledge-ind MM1 packet) set this to true. Default: false
&nbsp; &nbsp;</td>
</tr>
<tr > <tr >
<td valign=top > <td valign=top >
<tt>email2mms-relay-hosts</tt> <tt>email2mms-relay-hosts</tt>

View File

@ -81,7 +81,7 @@ SINGLE_GROUP(mbuni,
OCTSTR(allow-ip-type) OCTSTR(allow-ip-type)
OCTSTR(optimize-notification-size) OCTSTR(optimize-notification-size)
OCTSTR(content-adaptation) OCTSTR(content-adaptation)
OCTSTR(send-dlr-on-fetch)
OCTSTR(sendmms-port) OCTSTR(sendmms-port)
OCTSTR(sendmms-port-ssl) OCTSTR(sendmms-port-ssl)

View File

@ -892,7 +892,7 @@ MmsMsg *mm7_soap_to_mmsmsg(MSoapMsg_t *m, Octstr *from)
if ((s = http_header_value(m->envelope, octstr_imm("ReadReply"))) != NULL) { if ((s = http_header_value(m->envelope, octstr_imm("ReadReply"))) != NULL) {
long x = mms_string_to_boolean_flag(s); long x = mms_string_to_boolean_flag(s);
if (x >= 0) if (x >= 0)
mms_replace_header_value(msg, "X-Mms-Read-Reply", mms_replace_header_value(msg, "X-Mms-Read-Report",
(char *)mms_reports_to_cstr(x)); (char *)mms_reports_to_cstr(x));
octstr_destroy(s); octstr_destroy(s);
} }
@ -1070,7 +1070,7 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
octstr_destroy(s); octstr_destroy(s);
} }
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Read-Reply"))) != NULL) { if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Read-Report"))) != NULL) {
char *val = (octstr_case_compare(s, octstr_imm("Yes")) == 0) ? char *val = (octstr_case_compare(s, octstr_imm("Yes")) == 0) ?
"true" : "false"; "true" : "false";
http_header_add(m->envelope, "ReadReply", val); http_header_add(m->envelope, "ReadReply", val);

View File

@ -276,6 +276,9 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays)
if (mms_cfg_get_bool(grp, octstr_imm("content-adaptation"), &m->content_adaptation) < 0) if (mms_cfg_get_bool(grp, octstr_imm("content-adaptation"), &m->content_adaptation) < 0)
m->content_adaptation = 1; m->content_adaptation = 1;
if (mms_cfg_get_bool(grp, octstr_imm("send-dlr-on-fetch"), &m->dlr_on_fetch) < 0)
m->dlr_on_fetch = 0;
if (qdir) if (qdir)
octstr_destroy(qdir); octstr_destroy(qdir);

View File

@ -78,7 +78,8 @@ typedef struct MmscSettings {
int optimize_notification_size; int optimize_notification_size;
int content_adaptation; int content_adaptation;
int dlr_on_fetch;
Octstr *prov_notify; Octstr *prov_notify;
Octstr *prov_getstatus; Octstr *prov_getstatus;

View File

@ -237,6 +237,7 @@ int main(int argc, char *argv[])
void fetchmms_proxy(MmsHTTPClientInfo *h) void fetchmms_proxy(MmsHTTPClientInfo *h)
{ {
Octstr *dlr_flag = NULL;
Octstr *qf = NULL, *token = NULL, *s = NULL, *transid = NULL; Octstr *qf = NULL, *token = NULL, *s = NULL, *transid = NULL;
MmsEnvelope *e = NULL; MmsEnvelope *e = NULL;
MmsMsg *m = NULL, *mr = NULL; MmsMsg *m = NULL, *mr = NULL;
@ -301,6 +302,7 @@ void fetchmms_proxy(MmsHTTPClientInfo *h)
} }
/* Adapt content, if turned on. */ /* Adapt content, if turned on. */
transid = mms_maketransid(octstr_get_cstr(qf), settings->host_alias); transid = mms_maketransid(octstr_get_cstr(qf), settings->host_alias);
dlr_flag = mms_get_header_value(m, octstr_imm("X-Mms-Delivery-Report"));
if (settings->content_adaptation) { if (settings->content_adaptation) {
MmsMsg *outmsg = NULL; MmsMsg *outmsg = NULL;
int x = mms_transform_msg(m, prof, &outmsg); int x = mms_transform_msg(m, prof, &outmsg);
@ -365,6 +367,40 @@ void fetchmms_proxy(MmsHTTPClientInfo *h)
notify_cmd = "fetched"; notify_cmd = "fetched";
if (settings->dlr_on_fetch &&
dlr_flag && octstr_str_case_compare(dlr_flag, "Yes") == 0 &&
e != NULL) {
char tbuf[64];
Octstr *x, *from = h->client_addr ? h->client_addr : settings->system_user;
List *l = gwlist_create(), *qh = gwlist_create();
MmsMsg *mrpt = mms_deliveryreport(e->msgId, h->client_addr, time(NULL), octstr_imm("Retrieved"));
gwlist_append(l, octstr_duplicate(e->from));
/* Record user agent and profile url. */
if (h->ua)
http_header_add(qh, "X-Mbuni-User-Agent", octstr_get_cstr(h->ua));
if (h->profile_url)
http_header_add(qh, "X-Mbuni-Profile-Url", octstr_get_cstr(h->profile_url));
sprintf(tbuf, "%ld", time(NULL));
http_header_add(qh, "X-Mbuni-Timestamp", tbuf); /* record time of message. */
x = mms_queue_add(from, l, NULL, NULL, NULL, 0,
time(NULL) + settings->default_msgexpiry, mrpt, NULL,
NULL, NULL,
NULL, NULL,
qh,
0,
octstr_get_cstr(settings->global_queuedir),
settings->host_alias);
octstr_destroy(x);
gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
http_destroy_headers(qh);
mms_destroy(mrpt);
}
if (e) { if (e) {
e->lastaccess = time(NULL); /* No more notifications requests. */ e->lastaccess = time(NULL); /* No more notifications requests. */
e->sendt = e->expiryt + 3600*24*30*12; e->sendt = e->expiryt + 3600*24*30*12;
@ -430,7 +466,7 @@ void fetchmms_proxy(MmsHTTPClientInfo *h)
octstr_destroy(qf); octstr_destroy(qf);
octstr_destroy(token); octstr_destroy(token);
octstr_destroy(transid); octstr_destroy(transid);
octstr_destroy(dlr_flag);
free_clientInfo(h,1); free_clientInfo(h,1);
} }
@ -870,36 +906,19 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
e = NULL; e = NULL;
} }
if (qf) octstr_destroy(qf);
octstr_destroy(qf); octstr_destroy(token);
octstr_destroy(from);
if (token) octstr_destroy(subject);
octstr_destroy(token); http_destroy_headers(mh);
if (from) gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
octstr_destroy(from); octstr_destroy(otransid);
if (subject) octstr_destroy(url);
octstr_destroy(subject); octstr_destroy(read_report);
if (mh) octstr_destroy(allow_report);
http_destroy_headers(mh); octstr_destroy(delivery_report);
if (to) octstr_destroy(mmbox_loc);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy); octstr_destroy(sdf);
if (otransid)
octstr_destroy(otransid);
if (url)
octstr_destroy(url);
if (read_report)
octstr_destroy(read_report);
if (allow_report)
octstr_destroy(allow_report);
if (delivery_report)
octstr_destroy(delivery_report);
if (mmbox_loc)
octstr_destroy(mmbox_loc);
if (sdf)
octstr_destroy(sdf);
reply_body = mms_tobinary(mresp); reply_body = mms_tobinary(mresp);
notify_cmd = "fetched"; notify_cmd = "fetched";
@ -963,8 +982,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
0, 0,
octstr_get_cstr(settings->global_queuedir), octstr_get_cstr(settings->global_queuedir),
settings->host_alias); settings->host_alias);
if (x) octstr_destroy(x);
octstr_destroy(x);
gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy); gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
mms_destroy(mrpt); mms_destroy(mrpt);
@ -980,14 +998,10 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
mms_queue_update(e) != 1) /* Should be freed. */ mms_queue_update(e) != 1) /* Should be freed. */
mms_queue_free_env(e); mms_queue_free_env(e);
if (qf) octstr_destroy(qf);
octstr_destroy(qf); octstr_destroy(transid);
if (transid) octstr_destroy(allow_report);
octstr_destroy(transid); octstr_destroy(status);
if (allow_report)
octstr_destroy(allow_report);
if (status)
octstr_destroy(status);
http_header_add(rh, "Content-Type", "text/plain"); http_header_add(rh, "Content-Type", "text/plain");
ctype_set = 1; ctype_set = 1;
reply_body = octstr_imm("Received"); reply_body = octstr_imm("Received");
@ -1021,14 +1035,11 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
settings->host_alias); settings->host_alias);
/* Log to access log */ /* Log to access log */
mms_log("ReadReport", h->client_addr, NULL, msize, NULL, NULL, NULL, "MM1", h->ua,NULL); mms_log("ReadReport", h->client_addr, NULL, msize, NULL, NULL, NULL, "MM1", h->ua,NULL);
octstr_destroy(x);
if (x)
octstr_destroy(x);
mdone2: mdone2:
if (mh) http_destroy_headers(mh);
http_destroy_headers(mh);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy); gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
http_header_add(rh, "Content-Type", "text/plain"); http_header_add(rh, "Content-Type", "text/plain");
@ -1217,25 +1228,15 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
} }
upload_done: upload_done:
if (mstore)
mms_destroy(mstore);
if (mh)
http_destroy_headers(mh);
if (otransid)
octstr_destroy(otransid);
if (s)
octstr_destroy(s);
if (ctype) mms_destroy(mstore);
octstr_destroy(ctype); http_destroy_headers(mh);
if (mmbox_loc) octstr_destroy(otransid);
octstr_destroy(mmbox_loc); octstr_destroy(s);
octstr_destroy(ctype);
octstr_destroy(mmbox_loc);
octstr_destroy(sdf);
if (sdf)
octstr_destroy(sdf);
reply_body = mms_tobinary(mresp); reply_body = mms_tobinary(mresp);
notify_cmd = "uploaded"; notify_cmd = "uploaded";
} }
@ -1319,9 +1320,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
gwlist_destroy(rss, (gwlist_item_destructor_t *)octstr_destroy); gwlist_destroy(rss, (gwlist_item_destructor_t *)octstr_destroy);
gwlist_destroy(lh, (gwlist_item_destructor_t *)octstr_destroy); gwlist_destroy(lh, (gwlist_item_destructor_t *)octstr_destroy);
if (otransid) octstr_destroy(otransid);
octstr_destroy(otransid);
reply_body = mms_tobinary(mresp); reply_body = mms_tobinary(mresp);
notify_cmd = "deleted"; notify_cmd = "deleted";
@ -1479,7 +1478,7 @@ static void sendmms_proxy(MmsHTTPClientInfo *h)
done: done:
#if 1 #if 0
if (mresp) if (mresp)
mms_msgdump(mresp, 0); mms_msgdump(mresp, 0);
#endif #endif
@ -1531,12 +1530,10 @@ static MmsVasp *find_mm7sender(List *headers, List *vasps)
/* if it can't authenticate, returns NULL. */ /* if it can't authenticate, returns NULL. */
done: done:
if (v) octstr_destroy(v);
octstr_destroy(v); octstr_destroy(p);
if (p) octstr_destroy(q);
octstr_destroy(p);
if (q)
octstr_destroy(q);
return m; return m;
} }
@ -1724,38 +1721,19 @@ static void mm7soap_dispatch(MmsHTTPClientInfo *h)
mresp ? "ok" : "(null)", mresp ? "ok" : "(null)",
reply_body ? "ok" : "(null)"); reply_body ? "ok" : "(null)");
if (e) mms_queue_free_env(e);
mms_queue_free_env(e); octstr_destroy(sender);
octstr_destroy(from);
if (sender) octstr_destroy(subject);
octstr_destroy(sender); octstr_destroy(vasid);
octstr_destroy(msgid);
if (from) octstr_destroy(qf);
octstr_destroy(from); mms_destroy(m);
http_destroy_headers(rh);
if (subject) octstr_destroy(reply_body);
octstr_destroy(subject); mm7_soap_destroy(mresp);
if (vasid) mm7_soap_destroy(mreq);
octstr_destroy(vasid); gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
if (msgid)
octstr_destroy(msgid);
if (qf)
octstr_destroy(qf);
if (m)
mms_destroy(m);
if (rh)
http_destroy_headers(rh);
if (reply_body)
octstr_destroy(reply_body);
if (mresp)
mm7_soap_destroy(mresp);
if (mreq)
mm7_soap_destroy(mreq);
if (to)
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
free_clientInfo(h,1); free_clientInfo(h,1);
} }
@ -1880,22 +1858,14 @@ static void mm7eaif_dispatch(MmsHTTPClientInfo *h)
http_send_reply(h->client, hstatus, rh, octstr_imm("")); http_send_reply(h->client, hstatus, rh, octstr_imm(""));
if (hto) http_destroy_headers(hto);
http_destroy_headers(hto); gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
if (to) octstr_destroy(hfrom);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy); octstr_destroy(subject);
if (hfrom) octstr_destroy(otransid);
octstr_destroy(hfrom); octstr_destroy(msgid);
if (subject) http_destroy_headers(mh);
octstr_destroy(subject); mms_destroy(m);
if (otransid)
octstr_destroy(otransid);
if (msgid)
octstr_destroy(msgid);
if (mh)
http_destroy_headers(mh);
if (m) mms_destroy(m);
} }
static void mm7proxy(void *unused) static void mm7proxy(void *unused)
@ -1956,32 +1926,15 @@ static void free_clientInfo(MmsHTTPClientInfo *h, int freeh)
debug("free info", 0, debug("free info", 0,
" entered free_clientinfo %d, ip=%ld", freeh, (long)h->ip); " entered free_clientinfo %d, ip=%ld", freeh, (long)h->ip);
if (h->ip) octstr_destroy(h->ip);
octstr_destroy(h->ip); octstr_destroy(h->url);
octstr_destroy(h->ua);
octstr_destroy(h->body);
if (h->url) octstr_destroy(h->base_client_addr);
octstr_destroy(h->url); octstr_destroy(h->client_addr);
if (h->ua) octstr_destroy(h->ua); http_destroy_cgiargs(h->cgivars);
http_destroy_headers(h->headers);
octstr_destroy(h->profile_url);
if (h->body) octstr_destroy(h->body);
if (h->base_client_addr)
octstr_destroy(h->base_client_addr);
if (h->client_addr)
octstr_destroy(h->client_addr);
if (h->cgivars)
http_destroy_cgiargs(h->cgivars);
if (h->headers)
http_destroy_headers(h->headers);
if (h->profile_url)
octstr_destroy(h->profile_url);
if (freeh) if (freeh)
gw_free(h); gw_free(h);