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.

104 lines
3.1 KiB

  1. #ifndef _NAMEMAP_H_
  2. #define _NAMEMAP_H_
  3. #pragma warning( disable : 4786) // long symbol names
  4. #include <map>
  5. #include <atlcom.h>
  6. #include <iads.h>
  7. #include <adshlp.h>
  8. //used for icon functions
  9. #include <objbase.h>
  10. #define INITGUID
  11. #include <initguid.h>
  12. #include "shlobj.h"
  13. #include "dsclient.h"
  14. //glorified structure holds all neccessary information about icons
  15. struct ICONHOLDER
  16. {
  17. ICONHOLDER() : strPath(L""), hLarge(NULL), hSmall(NULL), hLargeDis(NULL), hSmallDis(NULL),
  18. iNormal(RESULT_ITEM_IMAGE), iDisabled(RESULT_ITEM_IMAGE), bAttempted(false) {}
  19. tstring strPath; //full iconPath value as returned by AD
  20. HICON hLarge; //handle to the large icon as returned by windows API/AD
  21. HICON hSmall; //handle to the small icon as returned by windows API/AD
  22. UINT iNormal; //virtual index to disabled icon passed to MMC
  23. HICON hLargeDis; //handle to the large disabled icon
  24. HICON hSmallDis; //handle to the small disabled icon
  25. UINT iDisabled; //virtual index to disabled icon passed to MMC
  26. bool bAttempted; //indicates whether an attempt to load this icon has occurred
  27. };
  28. class DisplayNameMap;
  29. // Derive class from std::map in order to add destructor code
  30. class DisplayNameMapMap : public std::map<tstring, DisplayNameMap*>
  31. {
  32. public:
  33. ~DisplayNameMapMap();
  34. };
  35. typedef std::map<tstring, tstring> STRINGMAP;
  36. class DisplayNameMap
  37. {
  38. public:
  39. DisplayNameMap();
  40. void InitializeMap(LPCWSTR name);
  41. void InitializeClassMap();
  42. // Note: AddRef and Release don't control lifetimes currently. All maps
  43. // are cached by the global PMAP until the DLL is unloaded.
  44. void AddRef() { m_nRefCount++; }
  45. void Release() { m_nRefCount--; }
  46. LPCWSTR GetClassDisplayName() { return m_strFriendlyClassName.c_str(); }
  47. LPCWSTR GetNameAttribute() { return m_strNameAttr.c_str(); }
  48. LPCWSTR GetAttributeDisplayName(LPCWSTR pszname);
  49. LPCWSTR GetInternalName(LPCWSTR pszDisplayName);
  50. LPCWSTR GetFriendlyName(LPCWSTR pszDisplayName);
  51. void GetFriendlyNames(string_vector* vec);
  52. //icon functions
  53. bool GetIcons(LPCWSTR pszClassName, ICONHOLDER** pReturnIH);
  54. private:
  55. STRINGMAP m_map;
  56. std::map<tstring, ICONHOLDER> m_msIcons;
  57. tstring m_strNameAttr;
  58. tstring m_strFriendlyClassName;
  59. int m_nRefCount;
  60. };
  61. //////////////////////////////////////////////////////////////////////////
  62. // class DisplayNames
  63. //
  64. // This class has all static member methods and variables. The functions
  65. // give users access to the class map and the display name maps for the
  66. // AD object classes. This class maintaines a map indexed by class name
  67. // of all display attribute maps.
  68. ///////////////////////////////////////////////////////////////////////////
  69. class DisplayNames
  70. {
  71. public:
  72. static DisplayNameMap* GetMap (LPCWSTR name);
  73. static DisplayNameMap* GetClassMap ();
  74. static LCID GetLocale() { return m_locale; }
  75. static void SetLocale(LCID lcid) { m_locale = lcid; }
  76. private:
  77. static DisplayNameMapMap m_mapMap;
  78. static DisplayNameMap* m_pmapClass;
  79. static LCID m_locale;
  80. };
  81. #endif