Use the new version of NamedList::addParam() to avoid adding empty values.

git-svn-id: http://yate.null.ro/svn/yate/trunk@3282 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2010-05-04 11:17:46 +00:00
parent 64dae801eb
commit 5e77ad5c72
2 changed files with 24 additions and 43 deletions

View File

@ -1113,8 +1113,7 @@ bool Client::openMessage(const char* text, const Window* parent, const char* con
NamedList params("");
params.addParam("text",text);
params.addParam("modal",String::boolText(parent != 0));
if (!null(context))
params.addParam("context",context);
params.addParam("context",context,false);
return openPopup("message",&params,parent);
}
@ -1124,8 +1123,7 @@ bool Client::openConfirm(const char* text, const Window* parent, const char* con
NamedList params("");
params.addParam("text",text);
params.addParam("modal",String::boolText(parent != 0));
if (!null(context))
params.addParam("context",context);
params.addParam("context",context,false);
return openPopup("confirm",&params,parent);
}
@ -2025,8 +2023,7 @@ bool Client::select(Window* wnd, const String& name, const String& item, const S
// Not processed: enqueue event
Message* m = eventMessage("select",wnd,substitute);
m->addParam("item",item);
if (text)
m->addParam("text",text);
m->addParam("text",text,false);
Engine::enqueue(m);
return false;
}
@ -2335,10 +2332,8 @@ void Client::callTerminate(const String& id, const char* reason, const char* err
if (!reason)
reason = s_rejectReason;
}
if (!null(error))
m->addParam("error",error);
if (!null(reason))
m->addParam("reason",reason);
m->addParam("error",error,false);
m->addParam("reason",reason,false);
Engine::enqueue(m);
}
@ -2430,8 +2425,7 @@ Message* Client::buildMessage(const char* msg, const String& account, const char
Message* m = new Message(msg);
if (ClientDriver::self())
m->addParam("module",ClientDriver::self()->name());
if (!TelEngine::null(oper))
m->addParam("operation",oper);
m->addParam("operation",oper,false);
m->addParam("account",account);
return m;
}
@ -2459,8 +2453,7 @@ Message* Client::buildSubscribe(bool request, bool ok, const String& account,
m = buildMessage("resource.subscribe",account,ok ? "subscribe" : "unsubscribe");
else
m = buildMessage("resource.notify",account,ok ? "subscribed" : "unsubscribed");
if (!TelEngine::null(proto))
m->addParam("protocol",proto);
m->addParam("protocol",proto,false);
m->addParam("to",contact);
return m;
}
@ -2470,8 +2463,7 @@ Message* Client::buildUserRoster(bool update, const String& account,
const String& contact, const char* proto)
{
Message* m = buildMessage("user.roster",account,update ? "update" : "delete");
if (!TelEngine::null(proto))
m->addParam("protocol",proto);
m->addParam("protocol",proto,false);
m->addParam("contact",contact);
return m;
}
@ -2576,8 +2568,7 @@ Message* Client::eventMessage(const String& event, Window* wnd, const char* name
if (wnd)
m->addParam("window",wnd->id());
m->addParam("event",event);
if (name && *name)
m->addParam("name",name);
m->addParam("name",name,false);
if (params) {
unsigned int n = params->count();
for (unsigned int i = 0; i < n; i++) {
@ -3069,14 +3060,12 @@ void ClientChannel::update(int notif, bool chan, bool updatePeer,
m->userData(m_clientData);
m->addParam("id",id());
m->addParam("direction",isOutgoing() ? "incoming" : "outgoing");
if (m_address)
m->addParam("address",m_address);
m->addParam("address",m_address,false);
if (notif != Noticed && m_noticed)
m->addParam("noticed",String::boolText(true));
if (m_active)
m->addParam("active",String::boolText(true));
if (m_transferId)
m->addParam("transferid",m_transferId);
m->addParam("transferid",m_transferId,false);
if (m_conference)
m->addParam("conference",String::boolText(m_conference));
}
@ -3211,8 +3200,7 @@ void ClientDriver::dropCalls(const char* reason)
Message m("call.drop");
if (!reason && Engine::exiting())
reason = "shutdown";
if (reason)
m.addParam("reason",reason);
m.addParam("reason",reason,false);
if (self())
self()->dropAll(m);
}

View File

@ -396,13 +396,6 @@ static inline const String& getChildText(XmlElement& xml, const String& name,
return child ? child->getText() : String::empty();
}
// Add xml data parameter to a message
static inline void addValidParam(NamedList& list, const char* param, const char* value)
{
if (!TelEngine::null(value))
list.addParam(param,value);
}
// Get a space separated word from a buffer
// Return false if empty
static inline bool getWord(String& buf, String& word)
@ -551,12 +544,12 @@ void YJBEngine::processEvent(JBEvent* ev)
if (ev->element()) {
Message* m = __plugin.message("msg.execute",ev->clientStream());
m->addParam("type",ev->stanzaType());
addValidParam(*m,"id",ev->id());
m->addParam("id",ev->id(),false);
m->addParam("caller",ev->from().bare());
addValidParam(*m,"caller_instance",ev->from().resource());
m->addParam("caller_instance",ev->from().resource(),false);
XmlElement* xml = ev->releaseXml();
addValidParam(*m,"subject",XMPPUtils::subject(*xml));
addValidParam(*m,"body",XMPPUtils::body(*xml));
m->addParam("subject",XMPPUtils::subject(*xml),false);
m->addParam("body",XMPPUtils::body(*xml),false);
String tmp("delay");
XmlElement* delay = xml->findFirstChild(&tmp,&XMPPUtils::s_ns[XMPPNamespace::Delay]);
if (delay) {
@ -566,7 +559,7 @@ void YJBEngine::processEvent(JBEvent* ev)
sec = XMPPUtils::decodeDateTimeSec(*time);
if (sec != (unsigned int)-1) {
m->addParam("delay_time",String(sec));
addValidParam(*m,"delay_text",delay->getText());
m->addParam("delay_text",delay->getText(),false);
JabberID from(delay->attribute("from"));
if (from)
m->addParam("delay_by",from);
@ -1134,7 +1127,7 @@ void YJBEngine::processIqStanza(JBEvent* ev)
m->addParam(prefix + "name",name);
}
// EMAIL
addValidParam(*m,prefix + "email",getChildText(*service,"EMAIL"));
m->addParam(prefix + "email",getChildText(*service,"EMAIL"),false);
// Photo
ch = "PHOTO";
tmp = service->findFirstChild(&ch);
@ -1152,8 +1145,8 @@ void YJBEngine::processIqStanza(JBEvent* ev)
// Route the iq
Message m("jabber.iq");
__plugin.complete(m,ev->clientStream());
addValidParam(m,"from",ev->from().bare());
addValidParam(m,"from_instance",ev->from().resource());
m.addParam("from",ev->from().bare(),false);
m.addParam("from_instance",ev->from().resource(),false);
if (ev->to()) {
m.addParam("to",ev->to().bare());
m.addParam("to_instance",ev->to().resource());
@ -1163,8 +1156,8 @@ void YJBEngine::processIqStanza(JBEvent* ev)
m.addParam("to",ev->stream()->local().bare());
m.addParam("to_instance",ev->stream()->local().resource());
}
addValidParam(m,"id",ev->id());
addValidParam(m,"type",ev->stanzaType());
m.addParam("id",ev->id(),false);
m.addParam("type",ev->stanzaType(),false);
if (n != XMPPNamespace::Count)
m.addParam("xmlns",XMPPUtils::s_ns[n]);
m.addParam(new NamedPointer("xml",ev->releaseXml()));
@ -1281,8 +1274,8 @@ static void addRosterItem(NamedList& list, XmlElement& x, const String& id,
if (del)
return;
pref << ".";
addValidParam(list,pref + "name",x.attribute("name"));
addValidParam(list,pref + "subscription",x.attribute("subscription"));
list.addParam(pref + "name",x.attribute("name"),false);
list.addParam(pref + "subscription",x.attribute("subscription"),false);
NamedString* groups = new NamedString(pref + "groups");
list.addParam(groups);
// Groups and other children