mm7 changes -- special header add
This commit is contained in:
parent
04037fbb64
commit
069455ec3d
|
@ -1,3 +1,5 @@
|
|||
2008-09-12 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Added facility for appending special response header to each message (mime) part in MM7 response
|
||||
2008-09-11 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* MMSBox HTTP MMSC type added, for inter-mmsbox message relay
|
||||
* MM5 support, basic infrastructure on the MMSC side.
|
||||
|
|
|
@ -205,6 +205,7 @@ MULTI_GROUP(mms-service,
|
|||
OCTSTR(aliases)
|
||||
OCTSTR(http-post-parameters)
|
||||
OCTSTR(service-code)
|
||||
OCTSTR(extra-reply-content-header)
|
||||
)
|
||||
#undef OCTSTR
|
||||
#undef SINGLE_GROUP
|
||||
|
|
|
@ -467,6 +467,13 @@ static int fetch_serviceurl(MmsEnvelope *e,
|
|||
goto done;
|
||||
} else {
|
||||
Octstr *base_url = url_path_prefix(ms->url, typ);
|
||||
|
||||
if (ms->special_header) {
|
||||
if (rph == NULL)
|
||||
rph = http_create_empty_headers();
|
||||
http_header_remove_all(rph, "X-Mbuni-Content-Header");
|
||||
http_header_add(rph, "X-Mbuni-Content-Header", octstr_get_cstr(ms->special_header));
|
||||
}
|
||||
res = make_and_queue_msg(rb, ctype, rph,
|
||||
ms->url,
|
||||
base_url,
|
||||
|
@ -709,9 +716,9 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
|
|||
Octstr *top_url,
|
||||
int type, Octstr *svc_name,
|
||||
Octstr *mmc_id,
|
||||
Dict *url_map)
|
||||
Dict *url_map, Octstr *xmhdr, Octstr *xmhdr_val)
|
||||
{
|
||||
Octstr *curl = NULL, *ctype = NULL, *body = NULL, *xcid = NULL;
|
||||
Octstr *curl = NULL, *ctype = NULL, *body = NULL, *xcid = NULL;
|
||||
char *src = NULL;
|
||||
int isurl, slash_prefix;
|
||||
Octstr *cid = NULL;
|
||||
|
@ -790,6 +797,10 @@ static int add_msg_part(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
|
|||
http_header_add(headers, "Content-Type", octstr_get_cstr(ctype));
|
||||
http_header_add(headers, "Content-ID", octstr_get_cstr(cid_header_val));
|
||||
http_header_add(headers, "Content-Location", p);
|
||||
|
||||
if (xmhdr)
|
||||
http_header_add(headers, octstr_get_cstr(xmhdr), octstr_get_cstr(xmhdr_val));
|
||||
|
||||
mime_replace_headers(x, headers);
|
||||
mime_entity_set_body(x, body);
|
||||
|
||||
|
@ -824,15 +835,15 @@ static void add_msg_parts(MIMEEntity *res, xmlNodePtr node, Octstr *base_url,
|
|||
Octstr *top_url,
|
||||
int type, Octstr *svc_name,
|
||||
Octstr *mmc_id,
|
||||
Dict *url_map)
|
||||
Dict *url_map, Octstr *xmhdr, Octstr *xmhdr_val)
|
||||
{
|
||||
xmlNodePtr n;
|
||||
/* Do all the children recursively, then come back and do parent. */
|
||||
for (n = node; n; n = n->next)
|
||||
if (n->type != XML_COMMENT_NODE) {
|
||||
add_msg_part(res, n, base_url, top_url, type, svc_name, mmc_id, url_map);
|
||||
add_msg_part(res, n, base_url, top_url, type, svc_name, mmc_id, url_map, xmhdr, xmhdr_val);
|
||||
add_msg_parts(res, n->xmlChildrenNode, base_url, top_url, type,
|
||||
svc_name, mmc_id, url_map);
|
||||
svc_name, mmc_id, url_map, xmhdr, xmhdr_val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -853,7 +864,8 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
List *xheaders = NULL;
|
||||
List *hdrs = http_create_empty_headers();
|
||||
Octstr *otransid = NULL;
|
||||
|
||||
Octstr *xmhdr = NULL, *xmhdr_val = NULL;
|
||||
|
||||
time_t expiryt = time(NULL) + DEFAULT_EXPIRE;
|
||||
Octstr *x;
|
||||
List *xto = gwlist_create();
|
||||
|
@ -916,6 +928,21 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
if (!subject && e && e->subject)
|
||||
subject = octstr_duplicate(e->subject);
|
||||
|
||||
/* Look for special header name/value to be inserted on all objects. */
|
||||
if (reply_headers &&
|
||||
(xmhdr = http_header_value(reply_headers, octstr_imm("X-Mbuni-Content-Header"))) != NULL) {
|
||||
int x = octstr_search_char(xmhdr,':', 0);
|
||||
|
||||
if (x > 0) {
|
||||
xmhdr_val = octstr_copy(xmhdr, x+1, octstr_len(xmhdr));
|
||||
octstr_delete(xmhdr, x, octstr_len(xmhdr));
|
||||
} else
|
||||
xmhdr_val = octstr_create("");
|
||||
|
||||
octstr_strip_blanks(xmhdr_val);
|
||||
octstr_strip_blanks(xmhdr);
|
||||
}
|
||||
|
||||
#if 0 /* don't route via sender, instead use allow/deny settings. */
|
||||
if (!mmc && e)
|
||||
mmc = octstr_duplicate(e->fromproxy);
|
||||
|
@ -986,7 +1013,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
|
||||
add_msg_parts(me, smil->xmlChildrenNode,
|
||||
base_url, turl, type, svc_name,
|
||||
mmc, url_map);
|
||||
mmc, url_map, xmhdr, xmhdr_val);
|
||||
|
||||
dict_destroy(url_map);
|
||||
/* SMIL has been modified, convert it to text, put it in. */
|
||||
|
@ -999,6 +1026,8 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
|
||||
http_header_add(xh, "Content-Type", "application/smil");
|
||||
http_header_add(xh, "Content-ID", "<presentation>"); /* identify it as start element. */
|
||||
if (xmhdr)
|
||||
http_header_add(xh, octstr_get_cstr(xmhdr), octstr_get_cstr(xmhdr_val));
|
||||
s = octstr_create_from_data((char *)buf, bsize);
|
||||
|
||||
mime_replace_headers(sm, xh);
|
||||
|
@ -1036,6 +1065,9 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
|
|||
}
|
||||
|
||||
http_header_add(xh, "Content-Type", octstr_get_cstr(ctype));
|
||||
if (xmhdr)
|
||||
http_header_add(xh, octstr_get_cstr(xmhdr), octstr_get_cstr(xmhdr_val));
|
||||
|
||||
mime_replace_headers(me, xh);
|
||||
|
||||
http_destroy_headers(xh);
|
||||
|
@ -1163,11 +1195,14 @@ done:
|
|||
octstr_destroy(subject);
|
||||
octstr_destroy(otransid);
|
||||
octstr_destroy(turl);
|
||||
|
||||
octstr_destroy(xmhdr);
|
||||
octstr_destroy(xmhdr_val);
|
||||
if (me)
|
||||
mime_entity_destroy(me);
|
||||
|
||||
mms_destroy(m);
|
||||
gwlist_destroy(xto, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
gwlist_destroy(xto, (void *)octstr_destroy);
|
||||
http_destroy_headers(hdrs);
|
||||
octstr_destroy(xservice_code);
|
||||
octstr_destroy(hsvc_code);
|
||||
|
@ -1225,6 +1260,8 @@ static void dispatch_sendmms_recv(List *rl)
|
|||
Octstr *prio = http_cgi_variable(h->cgivars, "priority");
|
||||
Octstr *distro = http_cgi_variable(h->cgivars, "distribution");
|
||||
Octstr *send_type = http_cgi_variable(h->cgivars, "mms-direction");
|
||||
Octstr *sheader = http_cgi_variable(h->cgivars, "extra-content-header");
|
||||
|
||||
Octstr *data_url = NULL;
|
||||
|
||||
dlr_url = http_cgi_variable(h->cgivars, "dlr-url");
|
||||
|
@ -1336,6 +1373,9 @@ static void dispatch_sendmms_recv(List *rl)
|
|||
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Priority", octstr_get_cstr(prio));
|
||||
if (distro)
|
||||
HTTP_REPLACE_HEADER(rh, "X-Mbuni-DistributionIndicator", octstr_get_cstr(distro));
|
||||
|
||||
if (sheader)
|
||||
HTTP_REPLACE_HEADER(rh, "X-Mbuni-Content-Header", octstr_get_cstr(sheader));
|
||||
|
||||
/* Requests to make_and_queue below can block, but for now we don't care. */
|
||||
if (ctype && data && !rb) { /* only send if no error. */
|
||||
|
|
|
@ -393,7 +393,7 @@ int mms_load_mmsbox_settings(Octstr *fname, gwthread_func_t *mmsc_handler_func)
|
|||
m->params = NULL;
|
||||
|
||||
m->service_code = mms_cfg_get(cfg, x, octstr_imm("service-code"));
|
||||
|
||||
m->special_header = mms_cfg_get(cfg, x, octstr_imm("extra-reply-content-header"));
|
||||
gwlist_append(mms_services, m);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ typedef struct MmsService {
|
|||
Octstr *service_code; /* Service code (MM7/SOAP only) */
|
||||
|
||||
Octstr *allowed_receiver_prefix, *denied_receiver_prefix;
|
||||
Octstr *special_header; /* To be added to each content element. */
|
||||
} MmsService;
|
||||
|
||||
typedef struct SendMmsUser {
|
||||
|
|
Loading…
Reference in New Issue