sipaccount.cpp 2.69 KB
Newer Older
yanmorin's avatar
 
yanmorin committed
1
/*
2
3
 *  Copyright (C) 2006-2007 Savoir-Faire Linux inc.
 *  Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com>
yanmorin's avatar
 
yanmorin committed
4
5
6
7
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
 *                                                                              
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 3 of the License, or
yanmorin's avatar
 
yanmorin committed
9
10
11
12
13
14
15
16
17
18
19
20
 *  (at your option) any later version.
 *                                                                                
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *                                                                              
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include "sipaccount.h"
yanmorin's avatar
   
yanmorin committed
21
#include "sipvoiplink.h"
yanmorin's avatar
   
yanmorin committed
22
#include "manager.h"
Emmanuel Milou's avatar
Bug fix    
Emmanuel Milou committed
23
#include "user_cfg.h"
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
24

yanmorin's avatar
 
yanmorin committed
25
26
27
SIPAccount::SIPAccount(const AccountID& accountID)
 : Account(accountID)
{
28
  _link = new SIPVoIPLink(accountID);
yanmorin's avatar
 
yanmorin committed
29
30
31
32
33
}


SIPAccount::~SIPAccount()
{
34
  delete _link;
35
  _link = NULL;
yanmorin's avatar
 
yanmorin committed
36
37
}

38
void
39
SIPAccount::registerVoIPLink()
yanmorin's avatar
 
yanmorin committed
40
{
Emmanuel Milou's avatar
nothing    
Emmanuel Milou committed
41
  _debug("SIPAccount: register account %s\n" , getAccountID().c_str());
42
43
44
  _link->setFullName(Manager::instance().getConfigString(_accountID,SIP_FULL_NAME));
  _link->setHostName(Manager::instance().getConfigString(_accountID,SIP_HOST_PART));
  int useStun = Manager::instance().getConfigInt(_accountID,SIP_USE_STUN);
Emmanuel Milou's avatar
nothing    
Emmanuel Milou committed
45
  //_link->setAccountID( getAccountID() );
46
47
  
  SIPVoIPLink* thislink = dynamic_cast<SIPVoIPLink*> (_link);
Emmanuel Milou's avatar
Emmanuel Milou committed
48
  thislink->setStunServer(Manager::instance().getConfigString(_accountID,SIP_STUN_SERVER));
49
50
  thislink->setUseStun( useStun!=0 ? true : false);

51
  _link->init();
52
53
54
55
56
57
  // Stuff needed for SIP registration.
  thislink->setProxy   (Manager::instance().getConfigString(_accountID,SIP_PROXY));
  thislink->setUserPart(Manager::instance().getConfigString(_accountID,SIP_USER_PART));
  thislink->setAuthName(Manager::instance().getConfigString(_accountID,SIP_AUTH_NAME));
  thislink->setPassword(Manager::instance().getConfigString(_accountID,SIP_PASSWORD));
  _link->sendRegister();
yanmorin's avatar
 
yanmorin committed
58
59
}

60
61
void
SIPAccount::unregisterVoIPLink()
yanmorin's avatar
 
yanmorin committed
62
{
Emmanuel Milou's avatar
nothing    
Emmanuel Milou committed
63
  _debug("SIPAccount: unregister account %s\n" , getAccountID().c_str());
64
  _link->sendUnregister();
Emmanuel Milou's avatar
nothing    
Emmanuel Milou committed
65
  _debug("Terminate SIP account\n");
66
  _link->terminate();
yanmorin's avatar
 
yanmorin committed
67
68
}

yanmorin's avatar
   
yanmorin committed
69
70
71
void
SIPAccount::loadConfig() 
{
72
73
74
75
76
  // Account generic
  Account::loadConfig();

  // SIP specific
  //none
yanmorin's avatar
   
yanmorin committed
77
}