rt_SipUri.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "rt_SipUri.h"
  19. #include "rt_String.h"
  20. #include "SipUri.h"
  21. using namespace doubango_rt::BackEnd;
  22. using namespace Platform;
  23. using namespace std;
  24. rtSipUri::rtSipUri(Platform::String^ uriString, Platform::String^ displayName)
  25. {
  26. m_pSipUri = new SipUri(
  27. rtString::toUtf8(uriString).data(),
  28. rtString::toUtf8(displayName).data());
  29. }
  30. rtSipUri::rtSipUri(Platform::String^ uriString)
  31. {
  32. m_pSipUri = new SipUri(rtString::toUtf8(uriString).data());
  33. }
  34. rtSipUri::~rtSipUri()
  35. {
  36. rtSafeDelete(m_pSipUri);
  37. }
  38. bool rtSipUri::isValid(Platform::String^ uri)
  39. {
  40. return SipUri::isValid(rtString::toUtf8(uri).data());
  41. }
  42. // MIDL4069: Static members and instance members cannot have the same name on a runtime class. isValid
  43. #if COM_VISIBLE
  44. bool rtSipUri::isValid_()
  45. #else
  46. bool rtSipUri::isValid()
  47. #endif
  48. {
  49. return (m_pSipUri && m_pSipUri->isValid());
  50. }
  51. Platform::String^ rtSipUri::getScheme()
  52. {
  53. return m_pSipUri ? rtString::toString(m_pSipUri->getScheme()) : nullptr;
  54. }
  55. Platform::String^ rtSipUri::getHost()
  56. {
  57. return m_pSipUri ? rtString::toString(m_pSipUri->getHost()) : nullptr;
  58. }
  59. unsigned short rtSipUri::getPort()
  60. {
  61. return m_pSipUri ? m_pSipUri->getPort() : 0;
  62. }
  63. Platform::String^ rtSipUri::getUserName()
  64. {
  65. return m_pSipUri ? rtString::toString(m_pSipUri->getUserName()) : nullptr;
  66. }
  67. Platform::String^ rtSipUri::getPassword()
  68. {
  69. return m_pSipUri ? rtString::toString(m_pSipUri->getPassword()) : nullptr;
  70. }
  71. Platform::String^ rtSipUri::getDisplayName()
  72. {
  73. return m_pSipUri ? rtString::toString(m_pSipUri->getDisplayName()) : nullptr;
  74. }
  75. Platform::String^ rtSipUri::getParamValue(Platform::String^ name)
  76. {
  77. return m_pSipUri ? rtString::toString(m_pSipUri->getParamValue(rtString::toUtf8(name).data())) : nullptr;
  78. }
  79. void rtSipUri::setDisplayName(Platform::String^ displayName)
  80. {
  81. if(m_pSipUri) {
  82. m_pSipUri->setDisplayName(rtString::toUtf8(displayName).data());
  83. }
  84. }