support for uid (UserID) / did (DomainID) in voicemail/voicebox/annrecorder

which is needed if the platform supports aliases and/or multi domain
and the canonical username or domain name can not be determined at the
proxy (call control)




git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1168 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 17 years ago
parent aec2dda84f
commit 61c0d81569

@ -133,14 +133,19 @@ void AnnRecorderFactory::getAppParams(const AmSipRequest& req, map<string, strin
language = get_header_keyvalue(iptel_app_param, "lng", "Language");
user = get_header_keyvalue(iptel_app_param,"usr", "User");
if (!user.length())
user = req.user;
user = get_header_keyvalue(iptel_app_param,"uid", "UserID");
if (user.empty()) {
user = get_header_keyvalue(iptel_app_param,"usr", "User");
if (!user.length())
user = req.user;
}
domain = get_header_keyvalue(iptel_app_param, "dom", "Domain");
if (!domain.length())
domain = req.domain;
domain = get_header_keyvalue(iptel_app_param, "did", "DomainID");
if (domain.empty()){
domain = get_header_keyvalue(iptel_app_param, "dom", "Domain");
if (domain.empty())
domain = req.domain;
}
typ = get_header_keyvalue(iptel_app_param, "typ", "Type");
if (!typ.length())
@ -500,6 +505,14 @@ FILE* AnnRecorderDialog::getCurrentMessage() {
user.c_str(), domain.c_str(),
msgname.c_str(),
MsgStrError(ret.get(0).asInt()));
if ((ret.size() > 1) && isArgAObject(ret.get(1))) {
MessageDataFile* f =
dynamic_cast<MessageDataFile*>(ret.get(1).asObject());
if (NULL != f)
delete f;
}
return NULL;
}

@ -296,6 +296,9 @@ AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req)
string pin;
string domain;
string language;
string uid;
string did;
string iptel_app_param = getHeader(req.hdrs, PARAM_HDR);
@ -303,11 +306,23 @@ AmSession* VoiceboxFactory::onInvite(const AmSipRequest& req)
AmSession::Exception(500, APP_NAME ": parameters not found");
}
user = get_header_keyvalue(iptel_app_param, "usr", "User");
// consistently with voicemail application:
// uid overrides user
user = get_header_keyvalue(iptel_app_param, "uid", "UserID");
if (user.empty())
user = get_header_keyvalue(iptel_app_param, "usr", "User");
// did overrides domain
domain = get_header_keyvalue(iptel_app_param, "did", "DomainID");
if (domain.empty())
domain = get_header_keyvalue(iptel_app_param, "dom", "Domain");
pin = get_header_keyvalue(iptel_app_param, "pin", "PIN");
domain = get_header_keyvalue(iptel_app_param, "dom", "Domain");
language = get_header_keyvalue(iptel_app_param,"lng", "Language");
// checks
if (user.empty())
throw AmSession::Exception(500, APP_NAME ": user missing");

@ -489,6 +489,8 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
string user;
string sender;
string typ;
string uid; // user ID
string did; // domain ID
int vm_mode = MODE_VOICEMAIL;
@ -534,8 +536,17 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
if (!typ.length())
typ = DEFAULT_TYPE;
uid = get_header_keyvalue(iptel_app_param, "uid", "UserID");
if (uid.empty())
uid=user;
did = get_header_keyvalue(iptel_app_param, "did", "DomainID");
if (did.empty())
did=domain;
// checks
if (user.empty())
if (uid.empty())
throw AmSession::Exception(500, "voicemail: user missing");
if (sender.empty())
@ -555,10 +566,12 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
DBG(" Domain: <%s> \n", domain.c_str());
DBG(" Language: <%s> \n", language.c_str());
DBG(" Type: <%s> \n", typ.c_str());
DBG(" UID: <%s> \n", uid.c_str());
DBG(" DID: <%s> \n", did.c_str());
FILE* greeting_fp = NULL;
if (TryPersonalGreeting)
greeting_fp = getMsgStoreGreeting(typ, user, domain);
greeting_fp = getMsgStoreGreeting(typ, uid, did);
#ifdef USE_MYSQL
@ -588,17 +601,17 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
#else
string announce_file = add2path(AnnouncePath,2,
domain.c_str(), (user + ".wav").c_str());
did.c_str(), (uid + ".wav").c_str());
if (file_exists(announce_file)) goto announce_found;
if (!language.empty()) {
announce_file = add2path(AnnouncePath,3,
domain.c_str(), language.c_str(), DefaultAnnounce.c_str());
did.c_str(), language.c_str(), DefaultAnnounce.c_str());
if (file_exists(announce_file)) goto announce_found;
}
announce_file = add2path(AnnouncePath,2,
domain.c_str(), DefaultAnnounce.c_str());
did.c_str(), DefaultAnnounce.c_str());
if (file_exists(announce_file)) goto announce_found;
if (!language.empty()) {
@ -620,17 +633,17 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
// VBOX mode does not need email template
if ((vm_mode == MODE_BOX) || (vm_mode == MODE_ANN))
return new AnswerMachineDialog(user, sender, domain,
email, announce_file, greeting_fp,
vm_mode, NULL);
email, announce_file, uid, did,
greeting_fp, vm_mode, NULL);
if(email.empty())
throw AmSession::Exception(404,"missing email address");
map<string,EmailTemplate>::iterator tmpl_it;
if (!language.empty()) {
tmpl_it = email_tmpl.find(domain + "_" + language);
tmpl_it = email_tmpl.find(did + "_" + language);
if(tmpl_it == email_tmpl.end()) {
tmpl_it = email_tmpl.find(domain);
tmpl_it = email_tmpl.find(did);
if(tmpl_it == email_tmpl.end()) {
tmpl_it = email_tmpl.find(DEFAULT_MAIL_TMPL + "_"
+ language);
@ -639,7 +652,7 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
}
}
} else {
tmpl_it = email_tmpl.find(domain);
tmpl_it = email_tmpl.find(did);
if(tmpl_it == email_tmpl.end())
tmpl_it = email_tmpl.find(DEFAULT_MAIL_TMPL);
}
@ -649,7 +662,9 @@ AmSession* AnswerMachineFactory::onInvite(const AmSipRequest& req)
return 0;
}
return new AnswerMachineDialog(user, sender, domain,
email, announce_file, greeting_fp,
email, announce_file,
uid, did,
greeting_fp,
vm_mode, &tmpl_it->second);
}
@ -659,6 +674,8 @@ AnswerMachineDialog::AnswerMachineDialog(const string& user,
const string& domain,
const string& email,
const string& announce_file,
const string& uid,
const string& did,
FILE* announce_fp,
int vm_mode,
const EmailTemplate* tmpl)
@ -671,6 +688,8 @@ AnswerMachineDialog::AnswerMachineDialog(const string& user,
email_dict["from"] = sender;
email_dict["domain"] = domain;
email_dict["email"] = email;
email_dict["uid"] = uid;
email_dict["did"] = did;
user_timer = AnswerMachineFactory::UserTimer->getInstance();
if(!user_timer){
@ -920,8 +939,8 @@ void AnswerMachineDialog::saveBox(FILE* fp) {
DBG("message name is '%s'\n", msg_name.c_str());
AmArg di_args,ret;
di_args.push(email_dict["domain"].c_str()); // domain
di_args.push(email_dict["user"].c_str()); // user
di_args.push(email_dict["did"].c_str()); // domain
di_args.push(email_dict["uid"].c_str()); // user
di_args.push(msg_name.c_str()); // message name
AmArg df;
MessageDataFile df_arg(fp);
@ -966,6 +985,14 @@ FILE* AnswerMachineFactory::getMsgStoreGreeting(string msgname,
user.c_str(), domain.c_str(),
msgname.c_str(),
MsgStrError(ret.get(0).asInt()));
if ((ret.size() > 1) && isArgAObject(ret.get(1))) {
MessageDataFile* f =
dynamic_cast<MessageDataFile*>(ret.get(1).asObject());
if (NULL != f)
delete f;
}
return NULL;
}

@ -127,6 +127,8 @@ class AnswerMachineDialog : public AmSession
const string& domain,
const string& email,
const string& announce_file,
const string& uid,
const string& did,
FILE* announce_fp,
int vm_mode,
const EmailTemplate* tmpl);

@ -25,7 +25,8 @@ App-Params
usr User param_user
typ Type param_type; defaults to "vm" (for: voicemail)
lng Language used for finding default greeting
did DomainID optional, overrides Domain above
uid UserID optional, overrides User above
Flow Diagram
------------

@ -24,6 +24,8 @@ application parameters (App-Param header)
PIN pin PIN (will be asked for PIN if not empty)
Domain dom Domain (for prompts/storage)
Language lng Language (for prompts/storage)
UserID uid optional, overrides User above
DomainID did optional, overrides Domain above
Prompts
-------

@ -17,15 +17,16 @@ messages to be played.
If file system is used to store audio files, the announcement file to be
played is looked for in the following order:
<announce_path><domain><user>'.wav'
<announce_path><domain><language><default_announce>
<announce_path><domain><default_announce>
<announce_path><did><uid>'.wav'
<announce_path><did><language><default_announce>
<announce_path><did><default_announce>
<announce_path><language><default_announce>
<announce_path><default_announce>
where <announce_path> and <default_announce> is set in voicemail.conf,
<domain> is the host part of the request URI, <user> the user part of
the request URI, and <language> is the App-Param 'Language' (see below).
the request URI (if not overridden by uid="..." or "usr=..."), and
<language> is the App-Param 'Language' (see below).
If MySQL database is used to store audio files, the announcement to be
played is looked for first from user_audio table, then from domain_audio
@ -95,6 +96,8 @@ avoid packet fragmentation (UDP).
Language lng - optional: language for announcement file/email template
Type typ - optional (default: 'vm'): prompt file to play, for user recorded
greeting (see annrecorder app)
UserID uid - optional: override user by user id (see Note below)
DomainID did - optional: override domain by domain id (see Note below)
Example:
@ -106,6 +109,17 @@ avoid packet fragmentation (UDP).
P-App-name: voicemail
P-App-Param: eml=user@maildomain.net;mod=both;lng=english;snd=someone@iptel.org;dom=iptel.org;
Using UserID (UID) and DomainID (DID)
-------------------------------------
If the platform supports aliases and multiple domains, the canonical user name and domain
name may not be available when sending the INVITE request to the voicemail/voicebox server.
Also, domain ID is case insensitive, thus iptel.org and Iptel.org may appear as different
domains to the case sensitive msg_storage engine.
Thus, the user and domain may be overridden by user id and domain id. These values are not
used in the email template, they are used only for selection of the user's voicebox and
personal greeting message.
Voicebox mode
-------------
@ -215,3 +229,9 @@ Following variables are supported:
- %from%/%sender% : Sender or remote URI.
- %from_user% : remote user.
- %from_domain% : remote domain.
- %vmsg_length% : voice message length in seconds
- %uid% : user id
- %did% : domain id
- %ts% : unix timestamp (seconds)

Loading…
Cancel
Save