mp_s_session_prop.C 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
  24. //%% (c) Copyright 1993, 1994 International Business Machines Corp.
  25. //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  26. //%% (c) Copyright 1993, 1994 Novell, Inc.
  27. //%% $XConsortium: mp_s_session_prop.C /main/3 1995/10/23 12:00:00 rswiston $
  28. /*
  29. *
  30. * mp_s_session_prop.cc
  31. *
  32. * Copyright (c) 1990 by Sun Microsystems, Inc.
  33. */
  34. #include "mp/mp_global.h"
  35. #include "mp_s_mp.h"
  36. #include "mp/mp_mp.h"
  37. #include "mp_rpc_server.h"
  38. #include "mp_rpc_implement.h"
  39. #include "mp_s_session.h"
  40. #include "mp/mp_session_prop.h"
  41. #include "mp/mp_xdr_functions.h"
  42. Tt_status _Tt_s_session::
  43. s_setprop(_Tt_string prop, _Tt_string val)
  44. {
  45. _Tt_session_prop_list_cursor propc(_properties);
  46. _Tt_string_list_cursor valp;
  47. while (propc.next()) {
  48. if (propc->_name == prop) {
  49. // found the property
  50. valp.reset(propc->_values);
  51. // remove all of the existing values
  52. while (valp.next()) {
  53. valp.remove();
  54. }
  55. // append the new value
  56. propc->_values->append(val);
  57. break;
  58. }
  59. }
  60. if (!propc.is_valid()) {
  61. // we didn't find the property, so add it
  62. _properties->append(_Tt_session_prop_ptr
  63. (new _Tt_session_prop(prop, val)));
  64. }
  65. return TT_OK;
  66. }
  67. Tt_status _Tt_s_session::
  68. s_addprop(_Tt_string prop, _Tt_string val)
  69. {
  70. _Tt_session_prop_list_cursor propc(_properties);
  71. while (propc.next()) {
  72. if (propc->_name == prop) {
  73. // found the property
  74. // append the new value
  75. propc->_values->append(val);
  76. break;
  77. }
  78. }
  79. if (!propc.is_valid()) {
  80. // we didn't find the property, so add it
  81. _properties->append(_Tt_session_prop_ptr
  82. (new _Tt_session_prop(prop, val)));
  83. }
  84. return TT_OK;
  85. }
  86. Tt_status _Tt_s_session::
  87. s_getprop(_Tt_string prop, int i, _Tt_string &value)
  88. {
  89. _Tt_session_prop_list_cursor propc(_properties);
  90. while (propc.next()) {
  91. if (propc->_name == prop) {
  92. // found the property
  93. if (i >= propc->_values->count()) {
  94. return TT_ERR_NUM;
  95. } else {
  96. value = (*propc->_values)[i];
  97. }
  98. break;
  99. }
  100. }
  101. if (!propc.is_valid()) {
  102. // we didn't find the property
  103. return TT_ERR_PROPNAME;
  104. } else {
  105. return TT_OK;
  106. }
  107. }
  108. Tt_status _Tt_s_session::
  109. s_propcount(_Tt_string prop, int &cnt)
  110. {
  111. _Tt_session_prop_list_cursor propc(_properties);
  112. while (propc.next()) {
  113. if (propc->_name == prop) {
  114. // found the property
  115. cnt = propc->_values->count();
  116. return TT_OK;
  117. }
  118. }
  119. // we didn't find the property
  120. return TT_ERR_PROPNAME;
  121. }
  122. Tt_status _Tt_s_session::
  123. s_propname(int i, _Tt_string &prop)
  124. {
  125. if (i >= _properties->count()) {
  126. return TT_ERR_NUM;
  127. }
  128. prop = (*_properties)[i]->_name;
  129. return TT_OK;
  130. }
  131. Tt_status _Tt_s_session::
  132. s_propnames_count(int &cnt)
  133. {
  134. cnt = _properties->count();
  135. return TT_OK;
  136. }