#include "StdAfx.h" #include "CfgSipAccount.h" CCfgSipAccount::CCfgSipAccount(void) { } CCfgSipAccount::~CCfgSipAccount(void) { __free(); } /***************************************************************** **【函数名称】 __free **【函数功能】 释放所有sip账户信息 **【参数】 **【返回值】 ****************************************************************/ void CCfgSipAccount::__free( void ) { while(m_nCount > 0) { SIP_ACCOUNT* pAccount = RemoveHead(); ASSERT(pAccount != NULL); delete pAccount; } } /***************************************************************** **【函数名称】 load **【函数功能】 加载所有sip账户信息 **【参数】 **【返回值】 ****************************************************************/ bool CCfgSipAccount::load( void ) { COtlRecordset* pAccountRcd = COtlConnection::GetOtlInstence()->QueryRecords(_T("SELECT id, account, auth_account, password, proxy_addr, proxy_port, reg, reg_interval FROM conf_sip_account ORDER BY id ASC")); if (NULL == pAccountRcd) return false; while(!pAccountRcd->IsEOF()) { SIP_ACCOUNT* pSipAccount = new SIP_ACCOUNT; ASSERT(pSipAccount != NULL); ZeroMemory(pSipAccount, sizeof(SIP_ACCOUNT)); pAccountRcd->MoveNextRow(); pSipAccount->Id = pAccountRcd->GetValueIntByIndex(1); lstrcpy(pSipAccount->Account, pAccountRcd->GetValueStrByIndex(2)); lstrcpy(pSipAccount->AuthAccount, pAccountRcd->GetValueStrByIndex(3)); lstrcpy(pSipAccount->Password, pAccountRcd->GetValueStrByIndex(4)); lstrcpy(pSipAccount->Proxy, pAccountRcd->GetValueStrByIndex(5)); pSipAccount->ProxyPort = pAccountRcd->GetValueIntByIndex(6); if(lstrcmp(CONST_DEF_SIP_REG_TRUE, pAccountRcd->GetValueStrByIndex(7)) == 0) pSipAccount->IsReg = true; else pSipAccount->IsReg = false; pSipAccount->RegInterval = pAccountRcd->GetValueIntByIndex(8); AddTail(pSipAccount); } // end while COtlRecordset::DestroyInstance(pAccountRcd); // 释放记录集 return true; } /***************************************************************** **【函数名称】 getAccount **【函数功能】 获取指定sip账户信息 **【参数】 **【返回值】 ****************************************************************/ SIP_ACCOUNT* CCfgSipAccount::getAccount( int AccountId ) { CNode* pNodeCur = m_pNodeHead; while(pNodeCur != NULL) { SIP_ACCOUNT* pAccount = pNodeCur->data; ASSERT(pAccount != NULL); if(pAccount->Id == AccountId) return pAccount; pNodeCur = pNodeCur->pNext; } return NULL; }