Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.6 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. iextconn.cpp
  5. Abstract:
  6. Implementation of IExternalConnection as required for an
  7. in-process object that supports linking to embedding.
  8. Specifically, this will call IOleObject::Close when there
  9. are no more strong locks on the object.
  10. --*/
  11. #include "polyline.h"
  12. #include "unkhlpr.h"
  13. // CImpIExternalConnection interface implementation
  14. CImpIExternalConnection::CImpIExternalConnection(
  15. PCPolyline pObj,
  16. LPUNKNOWN pUnkOuter
  17. )
  18. {
  19. m_cRef=0;
  20. m_pObj=pObj;
  21. m_pUnkOuter=pUnkOuter;
  22. m_cLockStrong=0L;
  23. }
  24. IMPLEMENT_CONTAINED_DESTRUCTOR(CImpIExternalConnection)
  25. IMPLEMENT_CONTAINED_IUNKNOWN(CImpIExternalConnection)
  26. /*
  27. * CImpIExternalConnection::AddConnection
  28. *
  29. * Purpose:
  30. * Informs the object that a strong connection has been made to it.
  31. *
  32. * Parameters:
  33. * dwConn DWORD identifying the type of connection, taken
  34. * from the EXTCONN enumeration.
  35. * dwReserved DWORD reserved. This is used inside OLE and
  36. * should not be validated.
  37. *
  38. * Return Value:
  39. * DWORD The number of connection counts on the
  40. * object, used for debugging purposes only.
  41. */
  42. STDMETHODIMP_(DWORD) CImpIExternalConnection::AddConnection(
  43. DWORD dwConn,
  44. DWORD /* dwReserved */
  45. )
  46. {
  47. if (EXTCONN_STRONG & dwConn)
  48. return ++m_cLockStrong;
  49. return 0;
  50. }
  51. /*
  52. * CImpIExternalConnection::ReleaseConnection
  53. *
  54. * Purpose:
  55. * Informs an object that a connection has been taken away from
  56. * it in which case the object may need to shut down.
  57. *
  58. * Parameters:
  59. * dwConn DWORD identifying the type of connection,
  60. * taken from the EXTCONN enumeration.
  61. * dwReserved DWORD reserved. This is used inside OLE and
  62. * should not be validated.
  63. * dwRerved DWORD reserved
  64. * fLastReleaseCloses BOOL indicating if the last call to this
  65. * function should close the object.
  66. *
  67. * Return Value:
  68. * DWORD The number of remaining connection counts on
  69. * the object, used for debugging purposes only.
  70. */
  71. STDMETHODIMP_(DWORD) CImpIExternalConnection::ReleaseConnection(
  72. DWORD dwConn,
  73. DWORD /* dwReserved */,
  74. BOOL fLastReleaseCloses
  75. )
  76. {
  77. if (EXTCONN_STRONG==dwConn)
  78. {
  79. if (0==--m_cLockStrong && fLastReleaseCloses)
  80. m_pObj->m_pImpIOleObject->Close(OLECLOSE_SAVEIFDIRTY);
  81. return m_cLockStrong;
  82. }
  83. return 0L;
  84. }