/security/manager/pki/src/nsPKIParamBlock.cpp

http://github.com/zpao/v8monkey · C++ · 132 lines · 71 code · 21 blank · 40 comment · 4 complexity · a89ca7ef4e1d4f9e0908e2415cea418d MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is mozilla.org code.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. * Javier Delgadillo <javi@netscape.com>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "nsPKIParamBlock.h"
  40. #include "nsIServiceManager.h"
  41. #include "nsIDialogParamBlock.h"
  42. #include "nsIMutableArray.h"
  43. NS_IMPL_THREADSAFE_ISUPPORTS2(nsPKIParamBlock, nsIPKIParamBlock,
  44. nsIDialogParamBlock)
  45. nsPKIParamBlock::nsPKIParamBlock()
  46. {
  47. }
  48. nsresult
  49. nsPKIParamBlock::Init()
  50. {
  51. mDialogParamBlock = do_CreateInstance(NS_DIALOGPARAMBLOCK_CONTRACTID);
  52. return (mDialogParamBlock == nsnull) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
  53. }
  54. nsPKIParamBlock::~nsPKIParamBlock()
  55. {
  56. }
  57. NS_IMETHODIMP
  58. nsPKIParamBlock::SetNumberStrings( PRInt32 inNumStrings )
  59. {
  60. return mDialogParamBlock->SetNumberStrings(inNumStrings);
  61. }
  62. NS_IMETHODIMP
  63. nsPKIParamBlock::SetInt(PRInt32 inIndex, PRInt32 inInt)
  64. {
  65. return mDialogParamBlock->SetInt(inIndex, inInt);
  66. }
  67. NS_IMETHODIMP
  68. nsPKIParamBlock::GetInt(PRInt32 inIndex, PRInt32 *outInt)
  69. {
  70. return mDialogParamBlock->GetInt(inIndex, outInt);
  71. }
  72. NS_IMETHODIMP
  73. nsPKIParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval)
  74. {
  75. return mDialogParamBlock->GetString(inIndex, _retval);
  76. }
  77. NS_IMETHODIMP
  78. nsPKIParamBlock::SetString(PRInt32 inIndex, const PRUnichar *inString)
  79. {
  80. return mDialogParamBlock->SetString(inIndex, inString);
  81. }
  82. NS_IMETHODIMP
  83. nsPKIParamBlock::GetObjects(nsIMutableArray * *aObjects)
  84. {
  85. return mDialogParamBlock->GetObjects(aObjects);
  86. }
  87. NS_IMETHODIMP
  88. nsPKIParamBlock::SetObjects(nsIMutableArray * aObjects)
  89. {
  90. return mDialogParamBlock->SetObjects(aObjects);
  91. }
  92. /* void setISupportAtIndex (in PRInt32 index, in nsISupports object); */
  93. NS_IMETHODIMP
  94. nsPKIParamBlock::SetISupportAtIndex(PRInt32 index, nsISupports *object)
  95. {
  96. if (!mSupports) {
  97. mSupports = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
  98. if (mSupports == nsnull) {
  99. return NS_ERROR_OUT_OF_MEMORY;
  100. }
  101. }
  102. return mSupports->InsertElementAt(object, index-1);
  103. }
  104. /* nsISupports getISupportAtIndex (in PRInt32 index); */
  105. NS_IMETHODIMP
  106. nsPKIParamBlock::GetISupportAtIndex(PRInt32 index, nsISupports **_retval)
  107. {
  108. NS_ENSURE_ARG(_retval);
  109. *_retval = mSupports->ElementAt(index-1);
  110. return NS_OK;
  111. }