From 67cdf0f387d91fecd6fbbc033626d1d984166a3a Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Fri, 3 Aug 2007 12:18:45 +0000 Subject: [PATCH] added mms-direction cgi param to send-mms interface --- mbuni/ChangeLog | 2 ++ mbuni/doc/userguide.shtml | 12 +++++++++++ mbuni/mmlib/mms_mm7soap.c | 19 +++++++++++++---- mbuni/mmlib/mms_queue.c | 43 +++++++++++---------------------------- mbuni/mmlib/mms_util.c | 10 +++++++++ mbuni/mmlib/mms_util.h | 2 ++ mbuni/mmsbox/mmsbox.c | 15 +++++++++++--- 7 files changed, 65 insertions(+), 38 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index aa7cb58..4916ab5 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2007-08-03 P. A. Bagyenda + * added mms-direction CGI param to send-mms interface (see doc for additional info) 2007-07-27 P. A. Bagyenda * Misc. fixes for DLR reporting, VAS GW 2007-07-13 P. A. Bagyenda diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index ff5bd82..690224b 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -2588,6 +2588,18 @@ faked-sender = 100
+ + + mms-direction + + + MT (mobile terminating) or MO (mobile orginating). When set to MO, + the MMS is queued as if it came from the + operator MMSC side. This is useful for testing service + configurations as it mimics receiving an MO MMS. Default is MT. + + +

diff --git a/mbuni/mmlib/mms_mm7soap.c b/mbuni/mmlib/mms_mm7soap.c index ed2b9a2..ce780a3 100644 --- a/mbuni/mmlib/mms_mm7soap.c +++ b/mbuni/mmlib/mms_mm7soap.c @@ -142,11 +142,21 @@ static int parse_header(xmlNodePtr node, List *headers, int *sigparent) case MM7_TAG_To: case MM7_TAG_Cc: case MM7_TAG_Bcc: - case MM7_TAG_Sender: + case MM7_TAG_Sender: case MM7_TAG_SenderAddress: - skip = 1; - - *sigparent = tag; /* We wait for number and stuff below. */ + if (has_node_children(node)) { /* account for buggy senders! XXX */ + skip = 1; + *sigparent = tag; /* wait for number. */ + } else { + char *sx; + char *s = (void *)xmlGetProp(node, (unsigned char *)"displayOnly"); + if (s && strcasecmp((char *)s, "true") == 0) /* a '-' indicates don't use this to send. */ + sx = "-"; + else + sx = "+"; + value = octstr_format("%s %s", sx, nvalue); + if (s) xmlFree(s); + } break; case MM7_TAG_Content: if ((s = xmlGetProp(node, (unsigned char *)"href")) != NULL) { @@ -250,6 +260,7 @@ MSoapMsg_t *mm7_parse_soap(List *headers, Octstr *body) if (!xml) goto done; + octstr_strip_blanks(xml); #if 1 info(0, "XML sent is: %s!", octstr_get_cstr(xml)); #endif diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index f3f2d6f..1b81feb 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -779,8 +779,7 @@ static int free_envelope(MmsEnvelope *e, int removefromqueue) { int i, n; - if (e->msgId) - octstr_destroy(e->msgId); + octstr_destroy(e->msgId); for (i = 0, n = gwlist_len(e->to); i < n; i++) { MmsEnvelopeTo *x = gwlist_get(e->to, i); @@ -790,35 +789,17 @@ static int free_envelope(MmsEnvelope *e, int removefromqueue) } gwlist_destroy(e->to, NULL); - if (e->from) - octstr_destroy(e->from); - - if (e->fromproxy) - octstr_destroy(e->fromproxy); - if (e->mdata) - octstr_destroy(e->mdata); - if (e->viaproxy) - octstr_destroy(e->viaproxy); - if (e->token) - octstr_destroy(e->token); - - if (e->subject) - octstr_destroy(e->subject); - - if (e->vaspid) - octstr_destroy(e->vaspid); - - if (e->vasid) - octstr_destroy(e->vasid); - - if (e->url1) - octstr_destroy(e->url1); - - if (e->url2) - octstr_destroy(e->url2); - - if (e->hdrs) - http_destroy_headers(e->hdrs); + octstr_destroy(e->from); + octstr_destroy(e->fromproxy); + octstr_destroy(e->mdata); + octstr_destroy(e->viaproxy); + octstr_destroy(e->token); + octstr_destroy(e->subject); + octstr_destroy(e->vaspid); + octstr_destroy(e->vasid); + octstr_destroy(e->url1); + octstr_destroy(e->url2); + http_destroy_headers(e->hdrs); if (removefromqueue) { char fname[2*QFNAMEMAX]; diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index ccc7122..bb81a9d 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -1640,3 +1640,13 @@ int mms_is_token(Octstr *token) octstr_check_range(token, 0, octstr_len(token), is_token_char); } + +int has_node_children(xmlNodePtr node) +{ + xmlNodePtr x; + + for (x = node->xmlChildrenNode; x; x = x->next) + if (x->type == XML_ELEMENT_NODE) + return 1; + return 0; +} diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h index f21ae23..1520971 100644 --- a/mbuni/mmlib/mms_util.h +++ b/mbuni/mmlib/mms_util.h @@ -192,6 +192,8 @@ Octstr *filename2content_type(char *fname); /* try to give a good extension name based on the url or content type. */ char *make_file_ext(Octstr *url, Octstr *ctype, char fext[5]); +/* return true if node has a child... */ +int has_node_children(xmlNodePtr node); #define MAXQTRIES 100 #define BACKOFF_FACTOR 5*60 /* In seconds */ #define QUEUERUN_INTERVAL 1*60 /* 1 minutes. */ diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index c242247..40e6672 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -275,7 +275,6 @@ done: mime_entity_destroy(p); octstr_destroy(cd); - } if (xctype) @@ -300,6 +299,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, Octstr *svc_name, Octstr *faked_sender, Octstr *service_code, int accept_x_headers, List *passthro_headers, + Octstr *qdir, Octstr **err); static int fetch_serviceurl(MmsEnvelope *e, MmsService *ms, MmsMsg *m, @@ -427,6 +427,7 @@ static int fetch_serviceurl(MmsEnvelope *e, base_url, typ, e, ms->name, ms->faked_sender, ms->service_code, ms->accept_x_headers, ms->passthro_headers, + outgoing_qdir, err); octstr_destroy(base_url); @@ -471,6 +472,9 @@ static int mmsbox_service_dispatch(MmsEnvelope *e) mmsbox_maxsendattempts); res = -1; goto done; + } else if (gwlist_len(e->to) == 0) { /* nothing to do. odd XXX */ + res = 0; + goto done; } me = mms_tomime(msg, 0); @@ -791,6 +795,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, Octstr *base_url, int type, MmsEnvelope *e, Octstr *svc_name, Octstr *faked_sender, Octstr *service_code, int accept_x_headers, List *passthro_headers, + Octstr *qdir, Octstr **err) { Octstr *from = NULL, *xfrom = NULL, *subject = NULL, *turl = get_toplevel_url(base_url); @@ -1065,9 +1070,9 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, dlr_url, rr_url, hdrs, (dlr_url != NULL), - octstr_get_cstr(outgoing_qdir), + octstr_get_cstr(qdir), octstr_imm(MM_NAME)); - info(0, "MMSBox: Queued message from service [%s] to outgoing: %s", + info(0, "MMSBox: Queued message from service [%s]: %s", octstr_get_cstr(svc_name), octstr_get_cstr(x)); *err = x; res = 0; @@ -1143,6 +1148,7 @@ static void sendmms_func(void *unused) Octstr *mclass = http_cgi_variable(cgivars, "mclass"); Octstr *prio = http_cgi_variable(cgivars, "priority"); Octstr *distro = http_cgi_variable(cgivars, "distribution"); + Octstr *send_type = http_cgi_variable(cgivars, "mms-direction"); Octstr *data_url = NULL; dlr_url = http_cgi_variable(cgivars, "dlr-url"); @@ -1258,6 +1264,9 @@ static void sendmms_func(void *unused) vasid ? vasid : octstr_imm("sendmms-user"), u->faked_sender, service_code, 1, NULL, + (send_type && + octstr_str_case_compare(send_type, "mo") == 0) ? + incoming_qdir : outgoing_qdir, &err); if (res < 0) rb = octstr_format("Error in message conversion: %S", err);