From c58cfafec59f66b85a3505a475616cae95f608e6 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Wed, 7 Nov 2007 07:53:29 +0000 Subject: [PATCH] added reroute-add-sender flag to mmsbox config --- mbuni/ChangeLog | 2 ++ mbuni/doc/userguide.shtml | 14 ++++++++++++++ mbuni/mmlib/mms_cfg.def | 1 + mbuni/mmsbox/bearerbox.c | 21 ++++++++++++++++++++- mbuni/mmsbox/mmsbox_cfg.c | 1 + mbuni/mmsbox/mmsbox_cfg.h | 2 ++ mbuni/mmsc/mms_resolve.h | 1 + 7 files changed, 41 insertions(+), 1 deletion(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 69bca34..53e4e06 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2007-11-07 P. A. Bagyenda + * Added reroute-add-sender-to-subject config param for MMSBox 2007-09-25 P. A. Bagyenda * Added flag to conditionally remove mm7: XML namespace prefix 2007-09-18 P. A. Bagyenda diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 16b5f4a..db9bd6c 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -2367,6 +2367,20 @@ string + + + reroute-add-sender-to-subject + + + Boolean + + + If reroute is true and this flag is also true then all messages + received on this connection are re-routed, and the original sender + is added to the message subject line + + + mm7-mt-filter-params diff --git a/mbuni/mmlib/mms_cfg.def b/mbuni/mmlib/mms_cfg.def index 6cc514b..8acec65 100644 --- a/mbuni/mmlib/mms_cfg.def +++ b/mbuni/mmlib/mms_cfg.def @@ -142,6 +142,7 @@ MULTI_GROUP(mmsc, OCTSTR(mm7-mt-filter-params) OCTSTR(reroute) OCTSTR(reroute-mmsc-id) + OCTSTR(reroute-add-sender-to-subject) OCTSTR(mmsc-library) OCTSTR(custom-settings) ) diff --git a/mbuni/mmsbox/bearerbox.c b/mbuni/mmsbox/bearerbox.c index 9aebdcd..09a5493 100644 --- a/mbuni/mmsbox/bearerbox.c +++ b/mbuni/mmsbox/bearerbox.c @@ -25,6 +25,20 @@ #include "mmsbox.h" +#define MOD_SUBJECT(msg, mmc,xfrom) do { \ + if ((mmc)->reroute_mod_subject) { \ + Octstr *s = mms_get_header_value((msg),octstr_imm("Subject")); \ + Octstr *f = octstr_duplicate(xfrom); \ + int _i; \ + if (s == NULL) s = octstr_create(""); \ + if ((_i = octstr_search(f, octstr_imm("/TYPE="), 0)) >= 0) \ + octstr_delete(f, _i, octstr_len(f)); \ + octstr_format_append(s, " (from %S)", (f)); \ + mms_replace_header_value((msg), "Subject", octstr_get_cstr(s)); \ + octstr_destroy(s); octstr_destroy(f); \ + } \ +} while(0) + typedef struct MmsHTTPClientInfo { HTTPClient *client; Octstr *ua; @@ -166,7 +180,8 @@ static void mm7soap_receive(MmsHTTPClientInfo *h) goto done; } - mm7_get_envelope(mreq, &from, &to, &subject, &vasid, &expiryt, &delivert, &uaprof, &uaprof_tstamp); + mm7_get_envelope(mreq, &from, &to, &subject, &vasid, + &expiryt, &delivert, &uaprof, &uaprof_tstamp); if (!from) from = octstr_imm("anon@anon"); @@ -202,6 +217,8 @@ static void mm7soap_receive(MmsHTTPClientInfo *h) octstr_destroy(sx); } + MOD_SUBJECT(m, h->m, from); + qf = qfs->mms_queue_add(from, to, subject, h->m->id, mmc_id, delivert, expiryt, m, linkedid, @@ -434,6 +451,8 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h) mms_remove_headers(m, "X-Mms-Expiry"); mms_remove_headers(m, "X-Mms-Sender-Visibility"); + MOD_SUBJECT(m, h->m, hfrom); + /* Save it, put message id in header, return. */ qf = qfs->mms_queue_add(hfrom, to, subject, h->m->id, mmc_id, diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index eb0a026..f926018 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -269,6 +269,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) m->use_mt_filter = 0; mms_cfg_get_bool(x, octstr_imm("reroute"), &m->reroute); + mms_cfg_get_bool(x, octstr_imm("reroute-add-sender-to-subject"), &m->reroute_mod_subject); m->reroute_mmsc_id = mms_cfg_get(x, octstr_imm("reroute-mmsc-id")); if (m->reroute_mmsc_id != NULL && m->reroute == 0) warning(0, "MMSBox: reroute-mmsc-id parameter set but reroute=false!"); diff --git a/mbuni/mmsbox/mmsbox_cfg.h b/mbuni/mmsbox/mmsbox_cfg.h index b66bfde..9075649 100644 --- a/mbuni/mmsbox/mmsbox_cfg.h +++ b/mbuni/mmsbox/mmsbox_cfg.h @@ -36,6 +36,8 @@ typedef struct MmscGrp { int reroute; /* whether messages from this mmsc are re-routed outwards. */ Octstr *reroute_mmsc_id; + + int reroute_mod_subject; /* Set to true if we'll change subject line on reroute. */ MM7Version_t ver; /* supported MM7/SOAP version. */ int use_mt_filter; /* whether to use MT filter on this connection. */ Mutex *mutex; diff --git a/mbuni/mmsc/mms_resolve.h b/mbuni/mmsc/mms_resolve.h index 404e46c..d222729 100644 --- a/mbuni/mmsc/mms_resolve.h +++ b/mbuni/mmsc/mms_resolve.h @@ -36,6 +36,7 @@ typedef struct MmsResolverFuncStruct { Octstr *(*mms_resolve)(Octstr * phonenum, void *module_data, void *settings, void *proxyrelays); int (*mms_resolvermodule_fini)(void *module_data); + } MmsResolverFuncStruct; extern MmsResolverFuncStruct mms_resolvefuncs; /* The module must expose this symbol. */