升龙物业 老版本 ocx IPO, 加密狗 转值班电话

CfgSipAccount.cpp 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "StdAfx.h"
  2. #include "CfgSipAccount.h"
  3. CCfgSipAccount::CCfgSipAccount(void)
  4. {
  5. }
  6. CCfgSipAccount::~CCfgSipAccount(void)
  7. {
  8. __free();
  9. }
  10. /*****************************************************************
  11. **【函数名称】 __free
  12. **【函数功能】 释放所有sip账户信息
  13. **【参数】
  14. **【返回值】
  15. ****************************************************************/
  16. void CCfgSipAccount::__free( void )
  17. {
  18. while(m_nCount > 0)
  19. {
  20. SIP_ACCOUNT* pAccount = RemoveHead();
  21. ASSERT(pAccount != NULL);
  22. delete pAccount;
  23. }
  24. }
  25. /*****************************************************************
  26. **【函数名称】 load
  27. **【函数功能】 加载所有sip账户信息
  28. **【参数】
  29. **【返回值】
  30. ****************************************************************/
  31. bool CCfgSipAccount::load( void )
  32. {
  33. 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"));
  34. if (NULL == pAccountRcd)
  35. return false;
  36. while(!pAccountRcd->IsEOF())
  37. {
  38. SIP_ACCOUNT* pSipAccount = new SIP_ACCOUNT;
  39. ASSERT(pSipAccount != NULL);
  40. ZeroMemory(pSipAccount, sizeof(SIP_ACCOUNT));
  41. pAccountRcd->MoveNextRow();
  42. pSipAccount->Id = pAccountRcd->GetValueIntByIndex(1);
  43. lstrcpy(pSipAccount->Account, pAccountRcd->GetValueStrByIndex(2));
  44. lstrcpy(pSipAccount->AuthAccount, pAccountRcd->GetValueStrByIndex(3));
  45. lstrcpy(pSipAccount->Password, pAccountRcd->GetValueStrByIndex(4));
  46. lstrcpy(pSipAccount->Proxy, pAccountRcd->GetValueStrByIndex(5));
  47. pSipAccount->ProxyPort = pAccountRcd->GetValueIntByIndex(6);
  48. if(lstrcmp(CONST_DEF_SIP_REG_TRUE, pAccountRcd->GetValueStrByIndex(7)) == 0)
  49. pSipAccount->IsReg = true;
  50. else
  51. pSipAccount->IsReg = false;
  52. pSipAccount->RegInterval = pAccountRcd->GetValueIntByIndex(8);
  53. AddTail(pSipAccount);
  54. } // end while
  55. COtlRecordset::DestroyInstance(pAccountRcd); // 释放记录集
  56. return true;
  57. }
  58. /*****************************************************************
  59. **【函数名称】 getAccount
  60. **【函数功能】 获取指定sip账户信息
  61. **【参数】
  62. **【返回值】
  63. ****************************************************************/
  64. SIP_ACCOUNT* CCfgSipAccount::getAccount( int AccountId )
  65. {
  66. CNode* pNodeCur = m_pNodeHead;
  67. while(pNodeCur != NULL)
  68. {
  69. SIP_ACCOUNT* pAccount = pNodeCur->data;
  70. ASSERT(pAccount != NULL);
  71. if(pAccount->Id == AccountId)
  72. return pAccount;
  73. pNodeCur = pNodeCur->pNext;
  74. }
  75. return NULL;
  76. }