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.

170 lines
6.6 KiB

  1. // ServerNode.h: interface for the CServerNode class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SERVERNODE_H__1B5E5554_A8BB_4682_B1A8_56453753643D__INCLUDED_)
  5. #define AFX_SERVERNODE_H__1B5E5554_A8BB_4682_B1A8_56453753643D__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. //
  10. // WM_SERVER_NOTIFY_BASE is the base (minimal) message id used for notifications
  11. // that arrive from the server(s). Each server is assigned a differnet message id
  12. // which is equal of bigger than this value.
  13. //
  14. #define WM_SERVER_NOTIFY_BASE WM_APP + 10
  15. #ifndef __AFXWIN_H__
  16. #error include 'stdafx.h' before including this file for PCH
  17. #endif
  18. class CServerNode : public CTreeNode
  19. {
  20. public:
  21. CServerNode ();
  22. DECLARE_DYNAMIC(CServerNode)
  23. DWORD Init (LPCTSTR tstrMachine);
  24. const CString & Machine () const { return m_cstrMachine; }
  25. DWORD RefreshState ();
  26. void AttachFoldersToViews()
  27. {
  28. m_Inbox.AttachView();
  29. m_SentItems.AttachView();
  30. m_Outbox.AttachView();
  31. m_Incoming.AttachView();
  32. }
  33. BOOL IsIncomingBlocked () const { return (m_dwQueueState & FAX_INCOMING_BLOCKED) ? TRUE : FALSE; }
  34. BOOL IsOutboxBlocked () const { return (m_dwQueueState & FAX_OUTBOX_BLOCKED) ? TRUE : FALSE; }
  35. BOOL IsOutboxPaused () const { return (m_dwQueueState & FAX_OUTBOX_PAUSED) ? TRUE : FALSE; }
  36. BOOL IsOnline () const { return m_hConnection ? TRUE : FALSE; }
  37. BOOL IsRefreshing() const { return m_bInBuildup; }
  38. DWORD GetActivity(CString& cstrText, TreeIconType& iconIndex) const;
  39. DWORD BlockIncoming (BOOL bBlock);
  40. DWORD BlockOutbox (BOOL bBlock);
  41. DWORD PauseOutbox (BOOL bPause);
  42. BOOL CanSeeInbox () const { return IsRightHeld(FAX_ACCESS_QUERY_IN_ARCHIVE); }
  43. BOOL CanManageInbox() const { return IsRightHeld(FAX_ACCESS_MANAGE_IN_ARCHIVE); }
  44. BOOL CanSeeAllJobs () const { return IsRightHeld(FAX_ACCESS_QUERY_JOBS); }
  45. BOOL CanManageAllJobs() const { return IsRightHeld(FAX_ACCESS_MANAGE_JOBS); }
  46. BOOL CanManageConfig() const { return IsRightHeld(FAX_ACCESS_MANAGE_CONFIG); }
  47. BOOL CanSendFax() const { return (IsRightHeld(FAX_ACCESS_SUBMIT) ||
  48. IsRightHeld(FAX_ACCESS_SUBMIT_NORMAL) ||
  49. IsRightHeld(FAX_ACCESS_SUBMIT_HIGH)) &&
  50. !IsOutboxBlocked(); }
  51. BOOL CanReceiveNow() const { return IsRightHeld(FAX_ACCESS_QUERY_IN_ARCHIVE) && // FaxAnswerCall requires FAX_ACCESS_QUERY_IN_ARCHIVE
  52. m_cstrMachine.IsEmpty(); } // FaxAnswerCall only works on local server
  53. CFolder* GetFolder(FolderType type);
  54. const CMessageFolder &GetInbox () const { return m_Inbox; }
  55. const CMessageFolder &GetSentItems () const { return m_SentItems; }
  56. const CQueueFolder &GetOutbox () const { return m_Outbox; }
  57. const CQueueFolder &GetIncoming () const { return m_Incoming; }
  58. virtual void AssertValid( ) const;
  59. virtual void Dump( CDumpContext &dc ) const;
  60. DWORD GetConnectionHandle (HANDLE &hFax);
  61. DWORD InvalidateSubFolders(BOOL bClearView);
  62. void SetLastRPCError (DWORD dwErr, BOOL DisconnectOnFailure = TRUE);
  63. DWORD GetLastRPCError () { return m_dwLastRPCError; }
  64. DWORD Disconnect (BOOL bShutdownAware = FALSE, BOOL bWaitForBuildThread = TRUE);
  65. void Destroy ();
  66. static CServerNode *LookupServerFromMessageId (DWORD dwMsgId);
  67. static DWORD InitMsgsMap ();
  68. static DWORD ShutdownMsgsMap ();
  69. DWORD OnNotificationMessage (PFAX_EVENT_EX pEvent);
  70. BOOL IsValid() { return m_bValid; }
  71. void SetValid(BOOL bValid) { m_bValid = bValid; }
  72. DWORD GetNotifyMsgID() { return m_dwMsgId; }
  73. private:
  74. virtual ~CServerNode();
  75. BOOL IsRightHeld (DWORD dwRight) const
  76. {
  77. return ((m_dwRights & dwRight) == dwRight) ? TRUE : FALSE;
  78. }
  79. DWORD Connect ();
  80. BOOL m_bValid;
  81. DWORD SetNewQueueState (DWORD dwNewState);
  82. DWORD ClearContents ();
  83. DWORD CreateFolders ();
  84. BOOL FatalRPCError (DWORD dwErr);
  85. DWORD m_dwRights; // Current relevant access rights
  86. DWORD m_dwQueueState; // Current queue state
  87. HANDLE m_hConnection; // Handle to RPC connection
  88. CString m_cstrMachine; // Server's machine name
  89. CMessageFolder m_Inbox; // Inbox folder
  90. CMessageFolder m_SentItems; // SentItems folder
  91. CQueueFolder m_Outbox; // Outbox folder
  92. CQueueFolder m_Incoming; // Incoming folder
  93. DWORD m_dwLastRPCError; // Error code of last RPC call
  94. //
  95. // Buildup thread members and functions:
  96. //
  97. CRITICAL_SECTION m_csBuildup; // Protects buildup phase
  98. BOOL m_bCsBuildupValid; // Is the critical section valid?
  99. HANDLE m_hBuildupThread; // Handle of background contents building thread
  100. BOOL m_bStopBuildup; // Should we abort the buildup operation?
  101. BOOL m_bInBuildup; // Are we doing a buildup now?
  102. CRITICAL_SECTION m_csBuildupThread; // Protects access to the m_hBuildupThread
  103. BOOL m_bCsBuildupThreadValid;// Is the critical section valid?
  104. DWORD StopBuildThread (BOOL bWaitForDeath = TRUE);
  105. DWORD Buildup ();
  106. BOOL m_bSelfDestruct; // Should we destroy ourselves ASAP?
  107. static DWORD WINAPI BuildupThreadProc (LPVOID lpParameter);
  108. //
  109. // Notifications handling:
  110. //
  111. HANDLE m_hNotification; // Notification registration handle
  112. DWORD m_dwMsgId; // Windows message id used for notification
  113. //
  114. // Map between Windows message and server pointer from
  115. // which the notification message was sent.
  116. //
  117. typedef map <DWORD, CServerNode *> MESSAGES_MAP;
  118. static CRITICAL_SECTION m_sMsgsCs; // Protects access to the map
  119. static BOOL m_sbMsgsCsInitialized; // Was m_sMsgsCs initialized;
  120. static MESSAGES_MAP m_sMsgs;
  121. static DWORD m_sdwMinFreeMsg; // The smallest available message id
  122. static DWORD AllocateNewMessageId (CServerNode *pServer, DWORD &dwMsdgId);
  123. static DWORD FreeMessageId (DWORD dwMsgId);
  124. };
  125. #endif // !defined(AFX_SERVERNODE_H__1B5E5554_A8BB_4682_B1A8_56453753643D__INCLUDED_)