sipaccount.cpp 2.46 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
8
9
10
11
12
13
14
15
16
17
18
19
20
 *  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
 *  the Free Software Foundation; either version 2 of the License, or
 *  (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"
yanmorin's avatar
   
yanmorin committed
23

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
{
41
42
43
44
45
  _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);
  
  SIPVoIPLink* thislink = dynamic_cast<SIPVoIPLink*> (_link);
46
47
48
49

  thislink->setStunServer(Manager::instance().getConfigString(_accountID,SIP_STUN_SERVER));
  thislink->setUseStun( useStun!=0 ? true : false);

50
  _link->init();
51
52
53
54
55
56
57
58

  // 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
59
60
}

61
62
void
SIPAccount::unregisterVoIPLink()
yanmorin's avatar
 
yanmorin committed
63
{
64
  _link->sendUnregister();
65
  _link->terminate();
yanmorin's avatar
 
yanmorin committed
66
67
}

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

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