forked from retronetworking/yate
Added a method to verify if call parameters look correct. Show a hint message in the interface it not all required parameters are present.
git-svn-id: http://yate.null.ro/svn/yate/trunk@4995 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
b682d50334
commit
a9b580dd16
|
@ -72,8 +72,10 @@ extern "C" int main(int argc, const char** argv, const char** envp)
|
|||
return EINVAL;
|
||||
|
||||
// build client if the driver didn't
|
||||
if (!QtClient::self())
|
||||
if (!QtClient::self()) {
|
||||
Debug(DebugWarn,"creating new client");
|
||||
new QtClient();
|
||||
}
|
||||
// run the client
|
||||
QtClient::self()->run();
|
||||
// the client finished running, do cleanup
|
||||
|
|
|
@ -5374,6 +5374,7 @@ bool DefaultLogic::select(Window* wnd, const String& name, const String& item,
|
|||
// when a protocol is chosen, the choice of account must be cleared
|
||||
bool acc = (name == YSTRING("account"));
|
||||
if (acc || name == YSTRING("protocol")) {
|
||||
Client::self()->setText(YSTRING("callto_hint"),YSTRING(""),false,wnd);
|
||||
if (Client::s_notSelected.matches(item))
|
||||
return true;
|
||||
if (acc)
|
||||
|
@ -5546,10 +5547,34 @@ bool DefaultLogic::callIncoming(Message& msg, const String& dest)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Validate an outgoing call
|
||||
bool DefaultLogic::validateCall(NamedList& params, Window* wnd)
|
||||
{
|
||||
const String& ns = params[YSTRING("target")];
|
||||
if (params[YSTRING("account")] || (ns.find('/') > 0))
|
||||
return true;
|
||||
else if (params[YSTRING("protocol")]) {
|
||||
if (ns.find('@') <= 0 && ns.find(':') <= 0) {
|
||||
// set in client the label
|
||||
Client::self()->setText(YSTRING("callto_hint"),YSTRING("This is not a valid protocol URI."),false,wnd);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// set in client the label
|
||||
Client::self()->setText(YSTRING("callto_hint"),YSTRING("You need a VoIP account to make calls."),false,wnd);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Start an outgoing call
|
||||
bool DefaultLogic::callStart(NamedList& params, Window* wnd, const String& cmd)
|
||||
{
|
||||
if (!(Client::self() && fillCallStart(params,wnd)))
|
||||
return false;
|
||||
if (!validateCall(params,wnd))
|
||||
return false;
|
||||
String target;
|
||||
const String& ns = params[YSTRING("target")];
|
||||
|
@ -7897,6 +7922,11 @@ bool DefaultLogic::handleTextChanged(NamedList* params, Window* wnd)
|
|||
updateFilter(s_contactList,wnd,(*params)["text"],"name","number/uri");
|
||||
return true;
|
||||
}
|
||||
// Editing started on the callto input, clear the callto_hing
|
||||
if (sender == s_calltoList) {
|
||||
Client::self()->setText(YSTRING("callto_hint"),YSTRING(""),false,wnd);
|
||||
return true;
|
||||
}
|
||||
// Conf/transfer targets
|
||||
bool conf = sender.startsWith("conf_add_target:");
|
||||
if (conf || sender.startsWith("transfer_start_target:")) {
|
||||
|
|
|
@ -1109,6 +1109,9 @@ border-bottom: 1px solid #717fa0;
|
|||
<property name="dynamicActionEnterFilter" stdset="0" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="_yate_textchangednotify" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
17
yatecbase.h
17
yatecbase.h
|
@ -2378,6 +2378,15 @@ public:
|
|||
virtual bool callIncoming(Message& msg, const String& dest)
|
||||
{ return false; }
|
||||
|
||||
/**
|
||||
* Check presence of all necessary data to make a call
|
||||
* @param params List of call parameters
|
||||
* @param wnd Optional window containing the widget that triggered the action
|
||||
* @return True on success
|
||||
*/
|
||||
virtual bool validateCall(NamedList& params, Window* wnd = 0)
|
||||
{ return true; }
|
||||
|
||||
/**
|
||||
* Called when the user trigger a call start action
|
||||
* The default logic fill the parameter list and ask the client to create an outgoing channel
|
||||
|
@ -2930,6 +2939,14 @@ public:
|
|||
*/
|
||||
virtual bool callIncoming(Message& msg, const String& dest);
|
||||
|
||||
/**
|
||||
* Check presence of all necessary data to make a call
|
||||
* @param params List of call parameters
|
||||
* @param wnd Optional window containing the widget that triggered the action
|
||||
* @return True on success
|
||||
*/
|
||||
virtual bool validateCall(NamedList& params, Window* wnd = 0);
|
||||
|
||||
/**
|
||||
* Called when the user trigger a call start action
|
||||
* The default logic fill the parameter list and ask the client to create an outgoing channel
|
||||
|
|
Loading…
Reference in New Issue