Skip to content
Snippets Groups Projects
Select Git revision
  • 7a6c7d8d640a7485836654888ff3089dc7a9f895
  • master default protected
  • release/beta-qt-202301101210
  • stable
  • release/beta-qt-202211182015
  • release/beta-qt-202211181752
  • release/beta-qt-202211171508
  • release/beta-qt-202211081754
  • release/beta-qt-202211071518
  • release/beta-qt-202210270957
  • release/beta-qt-202210071648
  • release/beta-qt-202209291549
  • release/beta-qt-202209011129
  • release/beta-qt-202208261640
  • release/beta-qt-202208241511
  • release/beta-qt-202208231849
  • release/beta-qt-202208091525
  • release/beta-qt-202207191241
  • release/beta-qt-202207181708
  • release/beta-qt-202207131914
  • release/beta-qt-202207131513
  • android/release_358
  • android/release_357
  • android/release_356
  • android/release_355
  • android/release_354
  • 20221220.0956.79e1207
  • android/release_353
  • android/release_352
  • android/release_350
  • android/release_349
  • android/release_348
  • android/release_347
  • 20221031.1308.130cc26
  • android/release_346
  • android/release_345
  • android/release_344
  • android/release_343
  • android/release_342
  • android/release_341
  • android/release_340
41 results

build-package-fedora.sh

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    sipaccount.cpp 4.54 KiB
    /*
     *  Copyright (C) 2006 Savoir-Faire Linux inc.
     *  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"
    #include "sipvoiplink.h"
    #include "manager.h"
    
    #define SIP_FULL_NAME      "SIP.fullName"
    #define SIP_USER_PART      "SIP.userPart"
    #define SIP_AUTH_NAME      "SIP.username"
    #define SIP_PASSWORD       "SIP.password"
    #define SIP_HOST_PART      "SIP.hostPart"
    #define SIP_PROXY          "SIP.proxy"
    #define SIP_STUN_SERVER    "STUN.STUNserver"
    #define SIP_USE_STUN       "STUN.useStun"
    
    
    SIPAccount::SIPAccount(const AccountID& accountID)
     : Account(accountID)
    {
      createVoIPLink();
    }
    
    
    SIPAccount::~SIPAccount()
    {
    }
    
    /* virtual Account function implementation */
    bool
    SIPAccount::createVoIPLink()
    {
      if (!_link) {
      //_link = new SipVoIPLink();
        _link = new SIPVoIPLink(_accountID);
      }
      return (_link != 0 ? true : false);
    }
    
    bool
    SIPAccount::registerAccount()
    {
      if (_link && !_registered) {
        SIPVoIPLink* tmplink = dynamic_cast<SIPVoIPLink*> (_link);
        if (tmplink) {
          tmplink->setProxy(Manager::instance().getConfigString(_accountID,SIP_PROXY));
          tmplink->setUserPart(Manager::instance().getConfigString(_accountID,SIP_USER_PART));
          tmplink->setAuthName(Manager::instance().getConfigString(_accountID,SIP_AUTH_NAME));
          tmplink->setPassword(Manager::instance().getConfigString(_accountID,SIP_PASSWORD));
        }
        _registered = _link->setRegister();
      }
      return _registered;
    }
    
    bool
    SIPAccount::unregisterAccount()
    {
      if (_link && _registered) {
        _registered = _link->setUnregister();
      }
      return !_registered;
    }
    
    bool
    SIPAccount::init()
    {
      if (_link && !_enabled) {
        _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* tmplink = dynamic_cast<SIPVoIPLink*> (_link);
        if (tmplink) {
          tmplink->setUseStun( useStun!=0 ? true : false);
        }
        _link->init();
        _enabled = true;
        return true;
      }
      return false;
    }
    
    bool
    SIPAccount::terminate()
    {
      if (_link && _enabled) {
        _link->terminate();
        _enabled = false;
        return true;
      }
      return false;
    }
    
    void 
    SIPAccount::initConfig(Conf::ConfigTree& config)
    {
      std::string section(_accountID);
      std::string type_str("string");
      std::string type_int("int");
      
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "SIP", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE,"1", type_int));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_FULL_NAME, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_USER_PART, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_HOST_PART, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_AUTH_NAME, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_PASSWORD, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_PROXY, "", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_AUTO_REGISTER, "1", type_int));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_STUN_SERVER, "stun.fwdnet.net:3478", type_str));
      config.addConfigTreeItem(section, Conf::ConfigTreeItem(SIP_USE_STUN, "0", type_int));
    }
    
    void
    SIPAccount::loadConfig() 
    {
      _shouldInitOnStart = Manager::instance().getConfigInt(_accountID, CONFIG_ACCOUNT_ENABLE) ? true : false;
      _shouldRegisterOnStart = Manager::instance().getConfigInt(_accountID, CONFIG_ACCOUNT_AUTO_REGISTER) ? true : false;
    }