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.

397 lines
9.4 KiB

  1. /*
  2. * ConfUtil.h
  3. *
  4. * CConfRoom and app level utility functions
  5. */
  6. #ifndef _CONFUTIL_H_
  7. #define _CONFUTIL_H_
  8. #include "SDKInternal.h"
  9. #define QUICK_LAUNCH_SUBDIR _T("\\Microsoft\\Internet Explorer\\Quick Launch")
  10. void DeleteShortcut(int csidl, LPCTSTR pszSubDir);
  11. // File Transfer
  12. BOOL FTransferInProgress(VOID);
  13. BOOL FEnableSendFileMenu(VOID);
  14. BOOL FEnableCancelSendMenu(VOID);
  15. BOOL FEnableCancelReceiveMenu(VOID);
  16. // Options Dialog
  17. #define OPTIONS_GENERAL_PAGE 0
  18. #define OPTIONS_SECURITY_PAGE 1
  19. #define OPTIONS_MYINFO_PAGE 2
  20. #define OPTIONS_FRIENDS_PAGE 3
  21. #define OPTIONS_AUDIO_PAGE 4
  22. #define OPTIONS_VIDEO_PAGE 5
  23. #define OPTIONS_DEFAULT_PAGE OPTIONS_GENERAL_PAGE
  24. VOID LaunchConfCpl(HWND hwnd, int nStartPage);
  25. BOOL CanLaunchConfCpl();
  26. // Capabilities
  27. extern BOOL FIsAudioAllowed();
  28. extern BOOL FIsSendVideoAllowed();
  29. extern BOOL FIsReceiveVideoAllowed();
  30. // String Functions
  31. BOOL FLoadString(UINT id, LPTSTR psz, UINT cb = MAX_PATH);
  32. BOOL FLoadString1(UINT id, LPTSTR psz, LPVOID pv);
  33. int FLoadString2(UINT id, LPTSTR psz, UINT cb = MAX_PATH);
  34. LPTSTR PszLoadString(UINT id);
  35. LPTSTR PszAlloc(LPCTSTR pszSrc);
  36. VOID FreePsz(LPTSTR psz);
  37. LPTSTR PszFromBstr(PCWSTR pwStr);
  38. int LoadResInt(UINT id, int iDefault);
  39. HRESULT LPTSTR_to_BSTR(BSTR *pbstr, LPCTSTR psz);
  40. HRESULT BSTR_to_LPTSTR(LPTSTR *ppsz, BSTR bstr);
  41. // Other
  42. BOOL GetDefaultName(LPTSTR pszName, int nBufferMax);
  43. LPCTSTR ExtractServerName(LPCTSTR pcszAddr, LPTSTR pszServer, UINT cchMax);
  44. BOOL FCreateIlsName(LPTSTR pszDest, LPCTSTR pszServer, LPCTSTR pszEmail, int cchMax);
  45. BOOL FLocalIpAddress(DWORD dwIP);
  46. INmConference2 * GetActiveConference(void);
  47. BOOL FIsConferenceActive(void);
  48. // Forward declaration
  49. interface ITranslateAccelerator;
  50. VOID AddModelessDlg(HWND hwnd);
  51. VOID RemoveModelessDlg(HWND hwnd);
  52. VOID AddTranslateAccelerator(ITranslateAccelerator* pTrans);
  53. VOID RemoveTranslateAccelerator(ITranslateAccelerator* pTrans);
  54. BOOL FBrowseForFolder(LPTSTR pszFolder, UINT cchMax, LPCTSTR pszTitle, HWND hwndParent);
  55. VOID DisableControl(HWND hdlg, int id);
  56. VOID KillScrnSaver(void);
  57. int DxpSz(LPCTSTR pcszName);
  58. BOOL FAnsiSz(LPCTSTR psz);
  59. extern int g_cBusyOperations;
  60. VOID DecrementBusyOperations(void);
  61. VOID IncrementBusyOperations(void);
  62. // Useful Macros
  63. #define ClearStruct(lpv) ZeroMemory((LPVOID) (lpv), sizeof(*(lpv)))
  64. // ZONE bitmasks (depends on _rgZonesOther)
  65. #define ZONE_API 0x01
  66. #define ZONE_VIDEO 0x02
  67. #define ZONE_WIZARD 0x04
  68. #define ZONE_QOS 0x08
  69. #define ZONE_REFCOUNT 0x10
  70. #define ZONE_OBJECTS 0x20
  71. #define ZONE_UI 0x40
  72. #define ZONE_CALL 0x0080
  73. // Zone indexes
  74. #define iZONE_API 0
  75. #define iZONE_VIDEO 1
  76. #define iZONE_WIZARD 2
  77. #define iZONE_QOS 3
  78. #define iZONE_REFCOUNT 4
  79. #define iZONE_OBJECTS 5
  80. #define iZONE_UI 6
  81. #define iZONE_CALL 7
  82. // Debugging Macros
  83. #ifdef DEBUG
  84. BOOL InitDebugZones(VOID);
  85. VOID DeinitDebugZones(VOID);
  86. extern HDBGZONE ghZoneOther; // initialized in conf.cpp
  87. // Old: requires double brackets ApiDebugMsg(("x=%d", x));
  88. #define ApiDebugMsg(s) DBGMSG(ghZoneOther, iZONE_API, s)
  89. #define VideoDebugMsg(s) DBGMSG(ghZoneOther, iZONE_VIDEO, s)
  90. // General: DbgMsg(iZONE_API, "x=%d", x);
  91. VOID DbgMsg(UINT iZone, PSTR pszFormat,...);
  92. // Specific: DbgMsgApi("x=%d", x);
  93. VOID DbgMsgApi(PSTR pszFormat,...);
  94. VOID DbgMsgVideo(PSTR pszFormat,...);
  95. VOID DbgMsgRefCount(PSTR pszFormat,...);
  96. VOID DbgMsgUI(PSTR pszFormat,...);
  97. VOID DbgMsgCall(PSTR pszFormat,...);
  98. LPCTSTR PszWSALastError(void);
  99. LPCTSTR PszLastError(void);
  100. LPCTSTR PszHResult(HRESULT hr);
  101. // Redefine the standard HR result display macro
  102. #undef DBGEXIT_HR
  103. #define DBGEXIT_HR(s,hr) DbgZPrintFunction("Exit " #s " (result=%s)", PszHResult(hr));
  104. #else
  105. #define ApiDebugMsg(s)
  106. #define VideoDebugMsg(s)
  107. inline void WINAPI DbgMsgNop(LPCTSTR, ...) { }
  108. #define DbgMsgRefCount 1 ? (void)0 : ::DbgMsgNop
  109. #define DbgMsgApi 1 ? (void)0 : ::DbgMsgNop
  110. #define DbgMsgVideo 1 ? (void)0 : ::DbgMsgNop
  111. #define DbgMsgUI 1 ? (void)0 : ::DbgMsgNop
  112. #define DbgMsgCall 1 ? (void)0 : ::DbgMsgNop
  113. inline void WINAPI DbgMsgZoneNop(UINT, LPCTSTR, ...) { }
  114. #define DbgMsg 1 ? (void) 0 : ::DbgMsgZoneNop
  115. #endif /* DEBUG */
  116. interface ITranslateAccelerator : public IUnknown
  117. {
  118. public:
  119. // Copied from IOleControlSite, but I don't use grfModifiers
  120. virtual HRESULT TranslateAccelerator(
  121. LPMSG pMsg , //Pointer to the structure
  122. DWORD grfModifiers //Flags describing the state of the keys
  123. ) = 0;
  124. // Copied from IOleWindow
  125. virtual HRESULT GetWindow(
  126. HWND * phwnd //Pointer to where to return window handle
  127. ) = 0;
  128. } ;
  129. BOOL IsWindowActive(HWND hwnd);
  130. class CTranslateAccel : public ITranslateAccelerator, RefCount
  131. {
  132. private:
  133. HWND m_hwnd;
  134. public:
  135. CTranslateAccel(HWND hwnd) : m_hwnd(hwnd)
  136. {
  137. }
  138. HWND GetWindow() const { return(m_hwnd); }
  139. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj)
  140. { return(E_NOTIMPL); }
  141. ULONG STDMETHODCALLTYPE AddRef()
  142. { return(RefCount::AddRef()); }
  143. ULONG STDMETHODCALLTYPE Release()
  144. { return(RefCount::Release()); }
  145. HRESULT TranslateAccelerator(
  146. LPMSG pMsg , //Pointer to the structure
  147. DWORD grfModifiers //Flags describing the state of the keys
  148. )
  149. {
  150. return(S_FALSE);
  151. }
  152. HRESULT GetWindow(
  153. HWND * phwnd //Pointer to where to return window handle
  154. )
  155. {
  156. *phwnd = m_hwnd;
  157. return(S_OK);
  158. }
  159. } ;
  160. class CTranslateAccelTable : public CTranslateAccel
  161. {
  162. private:
  163. HACCEL m_hAccel;
  164. int m_nEntries;
  165. public:
  166. CTranslateAccelTable(HWND hwnd, HACCEL hAccel) : CTranslateAccel(hwnd), m_hAccel(hAccel)
  167. {
  168. m_nEntries = CopyAcceleratorTable(m_hAccel, NULL, 0);
  169. }
  170. HRESULT TranslateAccelerator(
  171. LPMSG pMsg , //Pointer to the structure
  172. DWORD grfModifiers //Flags describing the state of the keys
  173. )
  174. {
  175. HWND hwnd = GetWindow();
  176. WORD cmd = 0;
  177. if (!IsAccelerator(m_hAccel, m_nEntries, pMsg, &cmd) || !IsWindowActive(hwnd))
  178. {
  179. return(S_FALSE);
  180. }
  181. return(::TranslateAccelerator(hwnd, m_hAccel, pMsg) ? S_OK : S_FALSE);
  182. }
  183. } ;
  184. // Global list of modeless dialogs (declared in conf.cpp)
  185. extern CSimpleArray<ITranslateAccelerator*>* g_pDialogList;
  186. extern CRITICAL_SECTION dialogListCriticalSection;
  187. /////////////////////////////////////////////////////////////////////////////
  188. // Connection Point Helpers
  189. HRESULT NmAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw);
  190. HRESULT NmUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw);
  191. /////////////////////////////////////////////////////////////////////////////
  192. // NmMkCert wrapper
  193. DWORD MakeCertWrap(LPCSTR szFirstName, LPCSTR szLastName, LPCSTR szEmailName,
  194. DWORD dwFlags );
  195. /////////////////////////////////////////////////////////////////////////////
  196. // MessageBox routines
  197. int ConfMsgBox(HWND hwndParent, LPCTSTR pcszMsg, UINT uType=(MB_OK | MB_ICONINFORMATION));
  198. VOID PostConfMsgBox(UINT uStringID);
  199. VOID DisplayMsgIdsParam(int ids, LPCTSTR pcsz);
  200. int DisplayMsg(LPTSTR pcsz, UINT uType);
  201. VOID DisplayErrMsg(INT_PTR ids);
  202. HWND GetMainWindow();
  203. BOOL FDontShowEnabled(LPCTSTR pszKey);
  204. /////////////////////////////////////////////////////////////////////////////
  205. // Icon utilties
  206. VOID LoadIconImages(void);
  207. VOID FreeIconImages(void);
  208. VOID DrawIconSmall(HDC hdc, int iIcon, int x, int y);
  209. extern HIMAGELIST g_himlIconSmall;
  210. // Create an array that can be easily copied
  211. template <class T>
  212. class CCopyableArray : public CSimpleArray<T>
  213. {
  214. public:
  215. CCopyableArray()
  216. {
  217. }
  218. CCopyableArray(const CCopyableArray<T>& rhs)
  219. {
  220. *this = rhs;
  221. }
  222. CCopyableArray<T>& operator=(const CCopyableArray<T>& rhs)
  223. {
  224. if (&rhs == this)
  225. {
  226. return(*this);
  227. }
  228. RemoveAll();
  229. for (int i=0; i<rhs.GetSize(); ++i)
  230. {
  231. Add(rhs[i]);
  232. }
  233. return(*this);
  234. }
  235. } ;
  236. HFONT GetDefaultFont(void);
  237. // Dialog utilities
  238. BOOL FEmptyDlgItem(HWND hdlg, UINT id);
  239. UINT GetDlgItemTextTrimmed(HWND hdlg, int id, PTCHAR psz, int cch);
  240. UINT TrimDlgItemText(HWND hdlg, UINT id);
  241. int FmtDateTime(LPSYSTEMTIME pst, LPTSTR pszDateTime, int cchMax);
  242. VOID CombineNames(LPTSTR pszResult, int cchResult, LPCTSTR pcszFirst, LPCTSTR pcszLast);
  243. BOOL NMGetSpecialFolderPath(HWND hwndOwner, LPTSTR lpszPath, int nFolder, BOOL fCreate);
  244. //--------------------------------------------------------------------------//
  245. // CDirectoryManager class. //
  246. //--------------------------------------------------------------------------//
  247. class CDirectoryManager
  248. {
  249. public: // public static methods --------------------------------//
  250. static
  251. const TCHAR * const
  252. get_DomainDirectory(void);
  253. static
  254. const TCHAR * const
  255. get_defaultServer(void);
  256. static
  257. void
  258. set_defaultServer
  259. (
  260. const TCHAR * const serverName
  261. );
  262. static
  263. bool
  264. isWebDirectory
  265. (
  266. const TCHAR * const directory = NULL
  267. );
  268. static
  269. const TCHAR * const
  270. get_dnsName
  271. (
  272. const TCHAR * const name
  273. );
  274. static
  275. const TCHAR * const
  276. get_displayName
  277. (
  278. const TCHAR * const name
  279. );
  280. static
  281. const TCHAR * const
  282. loadDisplayName(void);
  283. static
  284. void
  285. get_webDirectoryUrl(LPTSTR szWebDir, int cchmax);
  286. static
  287. const TCHAR * const
  288. get_webDirectoryIls(void);
  289. static
  290. bool
  291. isWebDirectoryEnabled(void);
  292. private: // private static members --------------------------------//
  293. static bool m_webEnabled;
  294. static TCHAR m_ils[ MAX_PATH ];
  295. static TCHAR m_displayName[ MAX_PATH ];
  296. static TCHAR m_displayNameDefault[ MAX_PATH ];
  297. static TCHAR m_defaultServer[ MAX_PATH ];
  298. static TCHAR m_DomainDirectory[ MAX_PATH ];
  299. }; // End of class CDirectoryManager.
  300. //--------------------------------------------------------------------------//
  301. #endif /* _CONFUTIL_H_ */