Source code of Windows XP (NT5)
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.

149 lines
4.4 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 void OnRemove(CComponentDataObject* pComponentData);
  52. virtual void OnFilter(CComponentDataObject* pComponentData);
  53. virtual void OnUpdateSchema();
  54. virtual void OnNewQuery(CComponentDataObject* pComponentData);
  55. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  56. CNodeList* pNodeList);
  57. virtual void OnCreate(CComponentDataObject* pComponentData);
  58. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  59. BOOL* pbHide,
  60. CNodeList* pNodeList);
  61. HRESULT SaveToStream(IStream* pStm);
  62. static HRESULT CreateFromStream(IStream* pStm, CADSIEditConnectionNode** ppConnectionNode);
  63. void SaveQueryListToStream(IStream* pStm);
  64. void LoadQueryListFromStream(IStream* pStm);
  65. void BuildQueryPath(const CString& sPath, CString& sRootPath);
  66. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  67. { return CADSIEditConnectMenuHolder::GetContextMenuItem(); }
  68. CADSIEditConnectionNode* GetConnectionNode() { return this; }
  69. void SetConnectionNode(CADSIEditConnectionNode* pConnect) { m_pConnectData->SetConnectionNode(pConnect); }
  70. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  71. BOOL* pbHideVerb,
  72. CNodeList* pNodeList);
  73. int GetImageIndex(BOOL bOpenImage);
  74. void OnChangeState(CComponentDataObject* pComponentDataObject);
  75. virtual BOOL FindNode(LPCWSTR lpszPath, CList<CTreeNode*, CTreeNode*>& foundNodeList);
  76. virtual CADsObject* GetADsObject() { return m_pConnectData; }
  77. virtual CConnectionData* GetConnectionData() { return m_pConnectData; }
  78. // Accessors to query list
  79. void AddQueryToList(CADSIEditQueryData* pQueryData)
  80. {
  81. m_queryList.AddHead(pQueryData);
  82. }
  83. void RemoveQueryFromList(CADSIEditQueryData* pQueryData)
  84. {
  85. POSITION pos = m_queryList.Find(pQueryData);
  86. if (pos != NULL)
  87. {
  88. CADSIEditQueryData* pData = m_queryList.GetAt(pos);
  89. m_queryList.RemoveAt(pos);
  90. delete pData;
  91. }
  92. }
  93. void RemoveAndDeleteAllQueriesFromList()
  94. {
  95. POSITION pos = m_queryList.GetHeadPosition();
  96. while (pos != NULL)
  97. {
  98. CADSIEditQueryData* pQueryData = m_queryList.GetNext(pos);
  99. delete pQueryData;
  100. }
  101. }
  102. void RemoveAllQueriesFromList()
  103. {
  104. m_queryList.RemoveAll();
  105. }
  106. BOOL HasQueries()
  107. {
  108. return (m_queryList.GetCount() > 0);
  109. }
  110. CList<CADSIEditQueryData*, CADSIEditQueryData*>* GetQueryList() { return &m_queryList; }
  111. bool IsClassAContainer(CCredentialObject* pCredObject,
  112. PCWSTR pszClass,
  113. PCWSTR pszSchemaPath);
  114. private:
  115. CConnectionData* m_pConnectData;
  116. CList<CADSIEditQueryData*, CADSIEditQueryData*> m_queryList;
  117. CADSIEditSchemaCache m_SchemaCache;
  118. };
  119. #endif _CONNECTION_H