[ previous ] [ next ] [ threads ]
 To :  Diana Cionoiu <diana-liste@v...>
 From :  Maciek Kaminski <maciejka@t...>
 Subject :  iaxchan.cpp patch
 Date :  Thu, 23 Jun 2005 16:45:16 +0200
Patch that makes iaxchan handle user.login message. Notice that accfile 
at the moment sends user.login only at startup.

mk



Index: iaxchan.cpp
===================================================================
RCS file: /home/cvsroot/private/yate/modules/iaxchan.cpp,v
retrieving revision 1.40
diff -r1.40 iaxchan.cpp
160a161,169
> class UserHandler : public MessageHandler
> {
> public:
>     UserHandler()
> 	: MessageHandler("user.login",150)
> 	{ }
>     virtual bool received(Message &msg);
> };
> 
305a315,320
> 		case IAX_EVENT_REGACK:
>                     Debug(&iplugin,DebugInfo,"Registration acknowledged.");
> 		    break;
> 		case IAX_EVENT_REGREJ:
>                     Debug(&iplugin,DebugInfo,"Registration rejected.");
> 		    break;
520c535,536
<     else
---
>     else {
>       if(e->session->callerid && strcmp(e->session->callerid, "") != 0)
521a538,543
>       else {
> 	if(e->ies.calling_number)
> 	  m->addParam("callername",e->ies.calling_number);
>       }
>     }
>     
854a877,898
> bool UserHandler::received(Message &msg)
> {
>     String tmp(msg.getValue("protocol"));
>     if (tmp != "iax")
> 	return false;
> 
>     if(!(msg.getValue("server") && msg.getValue("username") && msg.getValue("password") && msg.getIntValue("interval"))) {
>         Debug(&iplugin,DebugWarn,"Message 'user.login' should have following attributes set: server, username, password, interval.");
> 	return false;
>     }
> 
>     iax_session *s = iax_session_new();
>     if(s) {
>       iax_register(s, 
> 		   const_cast(msg.getValue("server")), 
> 		   const_cast(msg.getValue("username")), 
> 		   const_cast(msg.getValue("password")), 
> 		   msg.getIntValue("interval"));
>     }
>     return true;
> }
> 
923a968
>     Engine::install(new UserHandler);