Skip to content
Snippets Groups Projects
Commit 9f7579f1 authored by yanmorin's avatar yanmorin
Browse files

*** empty log message ***

parent 2953c83c
Branches
No related tags found
No related merge requests found
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "iaxvoiplink.h" #include "iaxvoiplink.h"
#include "manager.h" #include "manager.h"
#define IAX_HOST "IAX.host"
#define IAX_USER "IAX.user"
#define IAX_PASS "IAX.pass"
IAXAccount::IAXAccount(const AccountID& accountID) IAXAccount::IAXAccount(const AccountID& accountID)
: Account(accountID) : Account(accountID)
{ {
...@@ -45,6 +49,14 @@ bool ...@@ -45,6 +49,14 @@ bool
IAXAccount::registerAccount() IAXAccount::registerAccount()
{ {
if (_link && !_registered) { if (_link && !_registered) {
init();
unregisterAccount();
IAXVoIPLink* tmplink = dynamic_cast<IAXVoIPLink*> (_link);
if (tmplink) {
tmplink->setHost(Manager::instance().getConfigString(_accountID,IAX_HOST));
tmplink->setUser(Manager::instance().getConfigString(_accountID,IAX_USER));
tmplink->setPass(Manager::instance().getConfigString(_accountID,IAX_PASS));
}
_registered = _link->setRegister(); _registered = _link->setRegister();
} }
return _registered; return _registered;
...@@ -91,6 +103,10 @@ IAXAccount::initConfig(Conf::ConfigTree& config) ...@@ -91,6 +103,10 @@ IAXAccount::initConfig(Conf::ConfigTree& config)
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "IAX", type_str)); config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "IAX", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE,"1", type_int)); config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE,"1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_AUTO_REGISTER, "1", type_int)); config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_AUTO_REGISTER, "1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_HOST, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_USER, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_PASS, "", type_str));
} }
void void
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "iaxcall.h" #include "iaxcall.h"
#include "eventthread.h" #include "eventthread.h"
#include "manager.h"
#define IAX_SUCCESS 0 #define IAX_SUCCESS 0
#define IAX_FAILURE -1 #define IAX_FAILURE -1
...@@ -76,6 +78,7 @@ IAXVoIPLink::getEvent() ...@@ -76,6 +78,7 @@ IAXVoIPLink::getEvent()
iax_event* event = 0; iax_event* event = 0;
IAXCall* call = 0; IAXCall* call = 0;
while ( (event = iax_get_event(0)) != 0 ) { while ( (event = iax_get_event(0)) != 0 ) {
_debug ("Receive IAX Event: %d\n", event->etype);
call = iaxFindCallBySession(event->session); call = iaxFindCallBySession(event->session);
if (call!=0) { if (call!=0) {
iaxHandleCallEvent(event, call); iaxHandleCallEvent(event, call);
...@@ -83,7 +86,7 @@ IAXVoIPLink::getEvent() ...@@ -83,7 +86,7 @@ IAXVoIPLink::getEvent()
// in iaxclient, there is many session handling, here, only one // in iaxclient, there is many session handling, here, only one
iaxHandleRegReply(event); iaxHandleRegReply(event);
} else { } else {
switch(e->etype) { switch(event->etype) {
case IAX_EVENT_REGACK: case IAX_EVENT_REGACK:
case IAX_EVENT_REGREJ: case IAX_EVENT_REGREJ:
_debug("Unknown IAX Registration Event\n"); _debug("Unknown IAX Registration Event\n");
...@@ -101,7 +104,7 @@ IAXVoIPLink::getEvent() ...@@ -101,7 +104,7 @@ IAXVoIPLink::getEvent()
break; break;
default: default:
_debug("Unknown event type: %d\n", event->type); _debug("Unknown event type: %d\n", event->etype);
} }
} }
iax_event_free(event); iax_event_free(event);
...@@ -117,7 +120,16 @@ IAXVoIPLink::getEvent() ...@@ -117,7 +120,16 @@ IAXVoIPLink::getEvent()
bool bool
IAXVoIPLink::setRegister() IAXVoIPLink::setRegister()
{ {
bool result = false;
if (_regSession==0) { if (_regSession==0) {
if (_host.empty()) {
Manager::instance().displayConfigError("Fill host field for IAX Account");
return false;
}
if (_user.empty()) {
Manager::instance().displayConfigError("Fill user field for IAX Account");
return false;
}
// lock // lock
_regSession = iax_session_new(); _regSession = iax_session_new();
...@@ -127,11 +139,22 @@ IAXVoIPLink::setRegister() ...@@ -127,11 +139,22 @@ IAXVoIPLink::setRegister()
} else { } else {
// refresh // refresh
// last reg // last reg
char host[_host.length()+1];
strcpy(host, _host.c_str());
char user[_user.length()+1];
strcpy(user, _user.c_str());
char pass[_pass.length()+1];
strcpy(pass, _pass.c_str());
//iax_register don't use const char*
_debug("Sending registration to %s with user %s\n", host, user);
iax_register(_regSession, host, user, pass, 300);
result = true;
} }
// unlock // unlock
} }
return false; return result;
} }
bool bool
...@@ -164,7 +187,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) ...@@ -164,7 +187,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
// call should not be 0 // call should not be 0
// note activity? // note activity?
// //
switch(event->type) { switch(event->etype) {
case IAX_EVENT_HANGUP: case IAX_EVENT_HANGUP:
break; break;
...@@ -195,8 +218,8 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) ...@@ -195,8 +218,8 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
case IAX_EVENT_URL: case IAX_EVENT_URL:
break; break;
case IAX_EVENT_CNG: // case IAX_EVENT_CNG: ??
break; // break;
case IAX_EVENT_TIMEOUT: case IAX_EVENT_TIMEOUT:
break; break;
...@@ -205,7 +228,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call) ...@@ -205,7 +228,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
break; break;
default: default:
_debug("Unknown event type: %d\n", event->type); _debug("Unknown event type: %d\n", event->etype);
} }
} }
......
...@@ -57,6 +57,11 @@ public: ...@@ -57,6 +57,11 @@ public:
bool carryingDTMFdigits(const CallID& id, char code) { return false; } bool carryingDTMFdigits(const CallID& id, char code) { return false; }
bool sendMessage(const std::string& to, const std::string& body) { return false; } bool sendMessage(const std::string& to, const std::string& body) { return false; }
public: // iaxvoiplink only
void setHost(const std::string& host) { _host = host; }
void setUser(const std::string& user) { _user = user; }
void setPass(const std::string& pass) { _pass = pass; }
private: private:
/** /**
* Find a iaxcall by iax session number * Find a iaxcall by iax session number
...@@ -79,7 +84,16 @@ private: ...@@ -79,7 +84,16 @@ private:
void iaxHandleRegReply(iax_event* event); void iaxHandleRegReply(iax_event* event);
EventThread* _evThread; EventThread* _evThread;
/** registration session : 0 if not register */
struct iax_session* _regSession; struct iax_session* _regSession;
/** IAX Host */
std::string _host;
/** IAX User */
std::string _user;
/** IAX Password */
std::string _pass;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment