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.

150 lines
4.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: connection.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _CONNECTION_H
  11. #define _CONNECTION_H
  12. #include "editor.h"
  13. #include "resource.h"
  14. #include "snapdata.h"
  15. #include "querynode.h"
  16. #include "schemacache.h"
  17. ///////////////////////////////////////////////////////////////////
  18. #define MAX_CONNECT_NAME_LENGTH 255
  19. ///////////////////////////////////////////////////////////////////
  20. // CADSIConnectionNode
  21. class CADSIEditConnectionNode : public CADSIEditContainerNode
  22. {
  23. public:
  24. CADSIEditConnectionNode(CConnectionData* pConnectData)
  25. {
  26. m_pConnectData = new CConnectionData(pConnectData);
  27. HRESULT hr = m_SchemaCache.Initialize();
  28. ASSERT(SUCCEEDED(hr));
  29. }
  30. CADSIEditConnectionNode(LPCWSTR lpszDisplayName)
  31. {
  32. SetDisplayName(lpszDisplayName);
  33. HRESULT hr = m_SchemaCache.Initialize();
  34. ASSERT(SUCCEEDED(hr));
  35. }
  36. ~CADSIEditConnectionNode();
  37. // node info
  38. DECLARE_NODE_GUID()
  39. virtual BOOL OnEnumerate(CComponentDataObject* pComponentData, BOOL bAsync = TRUE);
  40. void EnumerateQueries();
  41. virtual HRESULT OnCommand(long nCommandID,
  42. DATA_OBJECT_TYPES type,
  43. CComponentDataObject* pComponentData,
  44. CNodeList* pNodeList);
  45. virtual OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem,
  46. long *pInsertionAllowed);
  47. virtual void OnSettings(CComponentDataObject* pComponentData);
  48. virtual BOOL OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  49. BOOL* pbHide,
  50. CNodeList* pNodeList);
  51. virtual HRESULT OnRename(CComponentDataObject* pComponentData, PWSTR pszNewName);
  52. virtual void OnRemove(CComponentDataObject* pComponentData);
  53. virtual void OnFilter(CComponentDataObject* pComponentData);
  54. virtual void OnUpdateSchema();
  55. virtual void OnNewQuery(CComponentDataObject* pComponentData);
  56. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  57. CNodeList* pNodeList);
  58. virtual void OnCreate(CComponentDataObject* pComponentData);
  59. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  60. BOOL* pbHide,
  61. CNodeList* pNodeList);
  62. HRESULT SaveToStream(IStream* pStm);
  63. static HRESULT CreateFromStream(IStream* pStm, CADSIEditConnectionNode** ppConnectionNode);
  64. void SaveQueryListToStream(IStream* pStm);
  65. void LoadQueryListFromStream(IStream* pStm);
  66. void BuildQueryPath(const CString& sPath, CString& sRootPath);
  67. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  68. { return CADSIEditConnectMenuHolder::GetContextMenuItem(); }
  69. CADSIEditConnectionNode* GetConnectionNode() { return this; }
  70. void SetConnectionNode(CADSIEditConnectionNode* pConnect) { m_pConnectData->SetConnectionNode(pConnect); }
  71. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  72. BOOL* pbHideVerb,
  73. CNodeList* pNodeList);
  74. int GetImageIndex(BOOL bOpenImage);
  75. void OnChangeState(CComponentDataObject* pComponentDataObject);
  76. virtual BOOL FindNode(LPCWSTR lpszPath, CList<CTreeNode*, CTreeNode*>& foundNodeList);
  77. virtual CADsObject* GetADsObject() { return m_pConnectData; }
  78. virtual CConnectionData* GetConnectionData() { return m_pConnectData; }
  79. // Accessors to query list
  80. void AddQueryToList(CADSIEditQueryData* pQueryData)
  81. {
  82. m_queryList.AddHead(pQueryData);
  83. }
  84. void RemoveQueryFromList(CADSIEditQueryData* pQueryData)
  85. {
  86. POSITION pos = m_queryList.Find(pQueryData);
  87. if (pos != NULL)
  88. {
  89. CADSIEditQueryData* pData = m_queryList.GetAt(pos);
  90. m_queryList.RemoveAt(pos);
  91. delete pData;
  92. }
  93. }
  94. void RemoveAndDeleteAllQueriesFromList()
  95. {
  96. POSITION pos = m_queryList.GetHeadPosition();
  97. while (pos != NULL)
  98. {
  99. CADSIEditQueryData* pQueryData = m_queryList.GetNext(pos);
  100. delete pQueryData;
  101. }
  102. }
  103. void RemoveAllQueriesFromList()
  104. {
  105. m_queryList.RemoveAll();
  106. }
  107. BOOL HasQueries()
  108. {
  109. return (m_queryList.GetCount() > 0);
  110. }
  111. CList<CADSIEditQueryData*, CADSIEditQueryData*>* GetQueryList() { return &m_queryList; }
  112. bool IsClassAContainer(CCredentialObject* pCredObject,
  113. PCWSTR pszClass,
  114. PCWSTR pszSchemaPath);
  115. private:
  116. CConnectionData* m_pConnectData;
  117. CList<CADSIEditQueryData*, CADSIEditQueryData*> m_queryList;
  118. CADSIEditSchemaCache m_SchemaCache;
  119. };
  120. #endif _CONNECTION_H