DtMailMailBox.C 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /*
  24. *+SNOTICE
  25. *
  26. *
  27. * $TOG: DtMailMailBox.C /main/6 1997/09/26 09:07:17 mgreess $
  28. *
  29. * RESTRICTED CONFIDENTIAL INFORMATION:
  30. *
  31. * The information in this document is subject to special
  32. * restrictions in a confidential disclosure agreement bertween
  33. * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
  34. * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
  35. * Sun's specific written approval. This documment and all copies
  36. * and derivative works thereof must be returned or destroyed at
  37. * Sun's request.
  38. *
  39. * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
  40. *
  41. *+ENOTICE
  42. */
  43. #ifndef I_HAVE_NO_IDENT
  44. #endif
  45. #include <string.h>
  46. #include <stdlib.h>
  47. #include <DtMail/DtMail.hh>
  48. #include <DtMail/Threads.hh>
  49. #include <DtMail/IO.hh>
  50. DtMail::MailBox::MailBox(DtMailEnv & error,
  51. Session * session,
  52. DtMailObjectSpace space,
  53. void * arg,
  54. DtMailCallback cb,
  55. void * clientData)
  56. {
  57. _hide_access_events = DTM_FALSE;
  58. _key = session->newObjectKey();
  59. _session = session;
  60. error.clear();
  61. _space = space;
  62. _arg = arg;
  63. _errmsg_func = NULL;
  64. _err_data = NULL;
  65. _callback = cb;
  66. _cb_data = clientData;
  67. _obj_mutex = MutexInit();
  68. _mail_box_writable = DTM_FALSE;
  69. _default_mode = 0;
  70. }
  71. DtMail::MailBox::~MailBox(void)
  72. {
  73. if (_obj_mutex) {
  74. MutexDestroy(_obj_mutex);
  75. _obj_mutex = NULL;
  76. _session->removeObjectKey(_key);
  77. }
  78. }
  79. void
  80. DtMail::MailBox::appendCB(
  81. DtMailEnv &error,
  82. char *buf,
  83. int len,
  84. void *clientData)
  85. {
  86. DtMail::MailBox *obj = (DtMail::MailBox*) clientData;
  87. if (NULL == obj) return;
  88. obj->append(error, buf, len);
  89. }
  90. DtMail::Session *
  91. DtMail::MailBox::session(void)
  92. {
  93. return(_session);
  94. }
  95. DtMailBoolean
  96. DtMail::MailBox::mailBoxWritable(DtMailEnv & error)
  97. {
  98. error.clear();
  99. return(_mail_box_writable);
  100. }
  101. void
  102. DtMail::MailBox::registerErrMsgFunc(err_func errmsg_func, void * err_data)
  103. {
  104. _errmsg_func = errmsg_func;
  105. _err_data = err_data;
  106. }
  107. void
  108. DtMail::MailBox::unregisterErrMsgFunc(DtMailEnv&)
  109. {
  110. _errmsg_func = NULL;
  111. _err_data = NULL;
  112. }
  113. void
  114. DtMail::MailBox::showError(char *fsnam)
  115. {
  116. if (_errmsg_func && _err_data) {
  117. _errmsg_func(fsnam,FALSE,_err_data);
  118. }
  119. }