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.

144 lines
3.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2000, Microsoft Corporation
  4. //
  5. // File: DfsReplica.hxx
  6. //
  7. // Contents: the DFS Replica class, this contains the replica
  8. // information.
  9. //
  10. // Classes: DfsReplica.
  11. //
  12. // History: Dec. 24 2000, Author: udayh
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifndef __DFS_REPLICA__
  16. #define __DFS_REPLICA__
  17. #include "DfsGeneric.hxx"
  18. #include "DfsServerSiteInfo.hxx"
  19. #include "DfsInit.hxx"
  20. //+----------------------------------------------------------------------------
  21. //
  22. // Class: DfsReplica
  23. //
  24. // Synopsis: This class implements a DfsReplica class.
  25. //
  26. //-----------------------------------------------------------------------------
  27. #define DFS_REPLICA_OFFLINE 0x0001
  28. #define DFS_REPLICA_AVAILABLE 0x0002
  29. class DfsReplica: public DfsGeneric {
  30. private:
  31. DfsServerSiteInfo *_pTargetServer;
  32. UNICODE_STRING _TargetFolder;
  33. ULONG _Flags;
  34. public:
  35. DfsReplica() :
  36. DfsGeneric(DFS_OBJECT_TYPE_REPLICA)
  37. {
  38. _pTargetServer = NULL;
  39. RtlInitUnicodeString( &_TargetFolder, NULL );
  40. _Flags = 0;
  41. }
  42. virtual ~DfsReplica()
  43. {
  44. if (_pTargetServer != NULL) {
  45. DfsReleaseServerInfo( _pTargetServer);
  46. }
  47. if (_TargetFolder.Buffer != NULL) {
  48. DfsFreeUnicodeString(&_TargetFolder);
  49. }
  50. }
  51. DFSSTATUS
  52. SetTargetServer( PUNICODE_STRING pServerName, BOOLEAN * CacheHit )
  53. {
  54. DFSSTATUS Status = ERROR_SUCCESS;
  55. DfsServerSiteInfo *pInfo = NULL;
  56. _Flags |= DFS_REPLICA_AVAILABLE;
  57. Status = DfsGetServerInfo( pServerName,
  58. &pInfo,
  59. CacheHit );
  60. if (Status == ERROR_SUCCESS)
  61. {
  62. DFSLOG("Setting Target server to %p %wS %wS\n", pInfo,
  63. pInfo->GetServerNameString(),
  64. pInfo->GetSiteNameString());
  65. _pTargetServer = pInfo;
  66. }
  67. return Status;
  68. }
  69. DFSSTATUS
  70. SetTargetFolder( PUNICODE_STRING pFolderName )
  71. {
  72. DFSLOG("Setting Target Folder in replica to %wZ\n", pFolderName);
  73. return DfsCreateUnicodeString( &_TargetFolder, pFolderName );
  74. }
  75. VOID
  76. SetTargetOffline()
  77. {
  78. DFSLOG("Setting replica offline\n");
  79. _Flags |= DFS_REPLICA_OFFLINE;
  80. }
  81. PUNICODE_STRING GetTargetFolder(void)
  82. {
  83. return &_TargetFolder;
  84. }
  85. PUNICODE_STRING GetTargetServer(void)
  86. {
  87. return _pTargetServer->GetServerName();
  88. }
  89. DfsSite *
  90. GetSite( VOID )
  91. {
  92. return _pTargetServer->GetSite();
  93. }
  94. ULONG GetReplicaFlags(void) const
  95. {
  96. return _Flags;
  97. }
  98. BOOLEAN
  99. IsTargetAvailable()
  100. {
  101. BOOLEAN ReturnValue = FALSE;
  102. if ((_Flags & DFS_REPLICA_AVAILABLE) == DFS_REPLICA_AVAILABLE)
  103. {
  104. if ((_Flags & DFS_REPLICA_OFFLINE) == 0)
  105. {
  106. ReturnValue = TRUE;
  107. }
  108. }
  109. return ReturnValue;
  110. }
  111. };
  112. #endif // __DFS_FOLDER__