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.

381 lines
12 KiB

  1. //
  2. // brfprv.h: Includes all files that are to be part of the precompiled
  3. // header.
  4. //
  5. #ifndef __BRFPRV_H__
  6. #define __BRFPRV_H__
  7. ///////////////////////////////////////////////////// INCLUDES
  8. #define NEW_REC
  9. #define STRICT
  10. #define NOWINDOWSX
  11. #define NOSHELLDEBUG
  12. //#define NO_COMMCTRL_DA
  13. #define NO_COMMCTRL_ALLOCFCNS
  14. #define USE_MONIKER
  15. #define _INC_OLE // WIN32
  16. #include <windows.h>
  17. #include <windowsx.h>
  18. #include <shellapi.h> // for registration functions
  19. #include <port32.h>
  20. #include <shfusion.h>
  21. #include <shlobj.h> // WIN32
  22. #include <shlobjp.h>
  23. #include <shlapip.h>
  24. #include <shsemip.h>
  25. #include <winuserp.h>
  26. #include <shlwapi.h>
  27. #include <commctrl.h>
  28. #include <comctrlp.h>
  29. #include <ccstock.h>
  30. #ifdef CbFromCch
  31. #undef CbFromCch
  32. #endif // CbFromCch
  33. #ifdef ZeroInit
  34. #undef ZeroInit
  35. #endif // ZeroInit
  36. #ifdef InRange
  37. #undef InRange
  38. #endif // InRange
  39. #include <ole2.h> // object binding
  40. // Internal Shell headers
  41. #include <shellp.h>
  42. #include <brfcasep.h>
  43. #include <prsht.h> // Property sheet stuff
  44. #include <synceng.h> // Twin Engine include file
  45. #include <indirect.h> // For type-safe indirect calling
  46. #define PUBLIC
  47. #define CPUBLIC _cdecl
  48. #define PRIVATE
  49. #define MAXBUFLEN 260
  50. #define MAXMSGLEN 520
  51. #define MAXMEDLEN 64
  52. #define MAXSHORTLEN 32
  53. #define NULL_CHAR TEXT('\0')
  54. #define HIDWORD(_qw) (DWORD)((_qw)>>32)
  55. #define LODWORD(_qw) (DWORD)(_qw)
  56. #define DPA_ERR (-1)
  57. #define CRL_FLAGS CRL_FL_DELETE_DELETED_TWINS
  58. //---------------------------------------------------------------------------
  59. // misc.c
  60. //---------------------------------------------------------------------------
  61. // Structure for handling abort events
  62. typedef struct
  63. {
  64. UINT uFlags;
  65. } ABORTEVT, * PABORTEVT;
  66. // Flags for ABORTEVT struct
  67. #define AEF_DEFAULT 0x0000
  68. #define AEF_SHARED 0x0001
  69. #define AEF_ABORT 0x0002
  70. BOOL PUBLIC AbortEvt_Create(PABORTEVT * ppabortevt, UINT uFlags);
  71. void PUBLIC AbortEvt_Free(PABORTEVT this);
  72. BOOL PUBLIC AbortEvt_Set(PABORTEVT this, BOOL bAbort);
  73. BOOL PUBLIC AbortEvt_Query(PABORTEVT this);
  74. // Structure for the update progress bar
  75. typedef struct
  76. {
  77. UINT uFlags;
  78. PABORTEVT pabortevt;
  79. HWND hwndParent;
  80. DWORD dwTickShow; // Tick count at which to display dialog
  81. HCURSOR hcurSav;
  82. } UPDBAR, * PUPDBAR; // Update progress bar struct
  83. HWND PUBLIC UpdBar_Show (HWND hwndParent, UINT uFlags, UINT nSecs);
  84. void PUBLIC UpdBar_Kill (HWND hdlg);
  85. void PUBLIC UpdBar_SetCount (HWND hdlg, ULONG ulcFiles);
  86. void PUBLIC UpdBar_SetRange (HWND hdlg, WORD wRangeMax);
  87. void PUBLIC UpdBar_DeltaPos (HWND hdlg, WORD wdelta);
  88. void PUBLIC UpdBar_SetPos(HWND hdlg, WORD wPos);
  89. void PUBLIC UpdBar_SetName (HWND hdlg, LPCTSTR lpcszName);
  90. void PUBLIC UpdBar_SetDescription(HWND hdlg, LPCTSTR psz);
  91. void PUBLIC UpdBar_SetAvi(HWND hdlg, UINT uFlags);
  92. HWND PUBLIC UpdBar_GetStatusWindow(HWND hdlg);
  93. PABORTEVT PUBLIC UpdBar_GetAbortEvt(HWND hdlg);
  94. BOOL PUBLIC UpdBar_QueryAbort (HWND hdlg);
  95. #define DELAY_UPDBAR 3 // 3 seconds
  96. // Flags for UpdBar_Show
  97. #define UB_UPDATEAVI 0x0001
  98. #define UB_CHECKAVI 0x0002
  99. #define UB_NOSHOW 0x0004
  100. #define UB_NOCANCEL 0x0008
  101. #define UB_TIMER 0x0010
  102. #define UB_NOPROGRESS 0x0020
  103. #define UB_CHECKING (UB_CHECKAVI | UB_NOPROGRESS | UB_TIMER)
  104. #define UB_UPDATING UB_UPDATEAVI
  105. // Additional MB_ flags
  106. #define MB_WARNING (MB_OK | MB_ICONWARNING)
  107. #define MB_INFO (MB_OK | MB_ICONINFORMATION)
  108. #define MB_ERROR (MB_OK | MB_ICONERROR)
  109. #define MB_QUESTION (MB_YESNO | MB_ICONQUESTION)
  110. int PUBLIC MsgBox(HWND hwndParent, LPCTSTR pszText, LPCTSTR pszCaption, HICON hicon, UINT uStyle, ...);
  111. int PUBLIC ConfirmReplace_DoModal(HWND hwndOwner, LPCTSTR pszPathExisting, LPCTSTR pszPathOther, UINT uFlags);
  112. // Flags for ConfirmReplace_DoModal
  113. #define CRF_DEFAULT 0x0000
  114. #define CRF_MULTI 0x0001
  115. #define CRF_FOLDER 0x0002 // Internal
  116. int PUBLIC Intro_DoModal(HWND hwndParent);
  117. //---------------------------------------------------------------------------
  118. // Local includes
  119. //---------------------------------------------------------------------------
  120. #include "mem.h" // Shared heap functions
  121. #include "da.h" // Dynamic array functions
  122. #include "cstrings.h" // Read-only string constants
  123. #include "init.h" // Global DLL and initialization
  124. #include "strings.h" // Private string include
  125. #include "comm.h" // Common functions
  126. #include "err.h" // Error/debug code
  127. #include "twin.h" // Engine specific macros
  128. #include "cache.h" // Cache functions
  129. #include "atoms.h" // Atom functions
  130. //---------------------------------------------------------------------------
  131. // Critical section stuff
  132. //---------------------------------------------------------------------------
  133. // Notes:
  134. // 1. Never "return" from the critical section.
  135. // 2. Never "SendMessage" or "Yield" from the critical section.
  136. // 3. Never call USER API which may yield.
  137. // 4. Always make the critical section as small as possible.
  138. //
  139. void PUBLIC Brief_EnterExclusive(void);
  140. void PUBLIC Brief_LeaveExclusive(void);
  141. extern UINT g_cRefSyncUI;
  142. #define ENTEREXCLUSIVE() Brief_EnterExclusive()
  143. #define LEAVEEXCLUSIVE() Brief_LeaveExclusive()
  144. #define ASSERTEXCLUSIVE() ASSERT(0 < g_cRefSyncUI)
  145. #define ASSERT_NOT_EXCLUSIVE() ASSERT(0 == g_cRefSyncUI)
  146. UINT PUBLIC Delay_Own(void);
  147. UINT PUBLIC Delay_Release(void);
  148. //---------------------------------------------------------------------------
  149. // IDataObject prototypes
  150. //---------------------------------------------------------------------------
  151. BOOL PUBLIC DataObj_KnowsBriefObj(LPDATAOBJECT pdtobj);
  152. HRESULT PUBLIC DataObj_QueryBriefPath(LPDATAOBJECT pdtobj, LPTSTR pszBriefPath);
  153. HRESULT PUBLIC DataObj_QueryPath(LPDATAOBJECT pdtobj, LPTSTR pszPath);
  154. HRESULT PUBLIC DataObj_QueryFileList(LPDATAOBJECT pdtobj, LPTSTR * ppszList, LPUINT puCount);
  155. void PUBLIC DataObj_FreeList(LPTSTR pszList);
  156. // Helper macros
  157. #define NextString(psz) while (*(psz)++)
  158. #define DataObj_NextFile(psz) NextString(psz)
  159. //---------------------------------------------------------------------------
  160. // path.c
  161. //---------------------------------------------------------------------------
  162. // Events for PathNotifyShell
  163. typedef enum _notifyshellevent
  164. {
  165. NSE_CREATE = 0,
  166. NSE_MKDIR,
  167. NSE_UPDATEITEM,
  168. NSE_UPDATEDIR
  169. } NOTIFYSHELLEVENT;
  170. LPTSTR PUBLIC MyPathRemoveBackslash(LPTSTR lpszPath);
  171. LPTSTR PUBLIC PathRemoveExt(LPCTSTR pszPath, LPTSTR pszBuf);
  172. void PUBLIC PathMakePresentable(LPTSTR pszPath);
  173. LPTSTR PUBLIC PathGetDisplayName(LPCTSTR pszPath, LPTSTR pszBuf);
  174. void PUBLIC BrfPathCanonicalize(LPCTSTR pszPath, LPTSTR pszBuf);
  175. BOOL PUBLIC PathCheckForBriefcase(LPCTSTR pszPath, DWORD dwAttrib);
  176. BOOL PUBLIC PathIsBriefcase(LPCTSTR pszPath);
  177. BOOL PUBLIC PathExists(LPCTSTR pszPath);
  178. UINT PUBLIC PathGetLocality(LPCTSTR pszPath, LPTSTR pszBuf);
  179. void PUBLIC PathNotifyShell(LPCTSTR pszPath, NOTIFYSHELLEVENT nse, BOOL bDoNow);
  180. LPCTSTR PUBLIC PathFindEndOfRoot(LPCTSTR pszPath);
  181. LPTSTR PUBLIC PathFindNextComponentI(LPCTSTR lpszPath);
  182. BOOL PUBLIC PathsTooLong(LPCTSTR pszFolder, LPCTSTR pszName);
  183. // Path locality values, relative to a briefcase
  184. //
  185. #define PL_FALSE 0 // path is not related at all to a briefcase
  186. #define PL_ROOT 1 // path directly references the root of a briefcase
  187. #define PL_INSIDE 2 // path is somewhere inside a briefcase
  188. //---------------------------------------------------------------------------
  189. // state.c
  190. //---------------------------------------------------------------------------
  191. #ifdef DEBUG
  192. BOOL PUBLIC ProcessIniFile(void);
  193. BOOL PUBLIC CommitIniFile(void);
  194. #else
  195. #define ProcessIniFile()
  196. #define CommitIniFile()
  197. #endif
  198. //---------------------------------------------------------------------------
  199. // oledup.c
  200. //---------------------------------------------------------------------------
  201. HRESULT MyReleaseStgMedium(LPSTGMEDIUM pmedium);
  202. //---------------------------------------------------------------------------
  203. // thread.c
  204. //---------------------------------------------------------------------------
  205. BOOL PUBLIC RunDLLThread(HWND hwnd, LPCTSTR pszCmdLine, int nCmdShow);
  206. //---------------------------------------------------------------------------
  207. // ibrfext.c
  208. //---------------------------------------------------------------------------
  209. // This structure shares common data between all briefcase
  210. // property pages
  211. typedef struct tagPAGEDATA
  212. {
  213. LPBRIEFCASESTG pbrfstg; // IBriefcaseStg instance
  214. int atomPath;
  215. PCBS pcbs;
  216. UINT cRef;
  217. PRECLIST prl;
  218. PFOLDERTWINLIST pftl;
  219. BOOL bOrphan:1; // TRUE: This is an orphan
  220. BOOL bFolder:1; // TRUE: This is a folder
  221. BOOL bRecalc:1; // TRUE: Need to recalc
  222. LPARAM lParam; // Page-specific data
  223. } PAGEDATA, * PPAGEDATA;
  224. HRESULT PUBLIC PageData_Init(PPAGEDATA this, HWND hwndOwner);
  225. HRESULT PUBLIC PageData_Query(PPAGEDATA this, HWND hwndOwner, PRECLIST * pprl, PFOLDERTWINLIST * ppftl);
  226. void PUBLIC PageData_Orphanize(PPAGEDATA this);
  227. #define PageData_GetHbrf(this) ((this)->pcbs->hbrf)
  228. HRESULT CALLBACK BriefExt_CreateInstance(LPUNKNOWN punkOuter, REFIID riid, LPVOID * ppvOut);
  229. //---------------------------------------------------------------------------
  230. // status.c
  231. //---------------------------------------------------------------------------
  232. INT_PTR _export CALLBACK Stat_WrapperProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  233. void PUBLIC SelectItemInCabinet(HWND hwndCabinet, LPCITEMIDLIST pidl, BOOL bEdit);
  234. void PUBLIC OpenCabinet(HWND hwnd, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST pidl, BOOL bEdit);
  235. //---------------------------------------------------------------------------
  236. // info.c
  237. //---------------------------------------------------------------------------
  238. typedef struct
  239. {
  240. int atomTo;
  241. HDPA hdpaTwins; // handle to array of twin handles which will
  242. // be filled by dialog.
  243. // N.b. Caller must release these twins!
  244. BOOL bStandAlone; // private: should only be set by Info_DoModal
  245. } INFODATA, * PINFODATA;
  246. INT_PTR _export CALLBACK Info_WrapperProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  247. HRESULT PUBLIC Info_DoModal(HWND hwndParent, LPCTSTR pszPath1, LPCTSTR pszPath2, HDPA hdpaTwin, PCBS pcbs);
  248. //---------------------------------------------------------------------------
  249. // ibrfstg.c
  250. //---------------------------------------------------------------------------
  251. void PUBLIC TermCacheTables(void);
  252. HRESULT CALLBACK BriefStg_CreateInstance(LPUNKNOWN punkOuter, REFIID riid, LPVOID * ppvOut);
  253. //---------------------------------------------------------------------------
  254. // update.c
  255. //---------------------------------------------------------------------------
  256. // Flags for Upd_DoModal
  257. #define UF_SELECTION 0x0001
  258. #define UF_ALL 0x0002
  259. HRESULT PUBLIC Upd_DoModal(HWND hwndOwner, CBS * pcbs, LPCTSTR pszList, UINT cFiles, UINT uFlags);
  260. //---------------------------------------------------------------------------
  261. // init.c
  262. //---------------------------------------------------------------------------
  263. LPSHELLFOLDER PUBLIC GetDesktopShellFolder(void);
  264. //---------------------------------------------------------------------------
  265. // Semaphores
  266. //---------------------------------------------------------------------------
  267. // The BusySemaphore is used only for areas of code that do not
  268. // rely on the sync engine v-table. One example is the IContextMenu
  269. // code.
  270. //
  271. // The BriefSemaphore is used for any code that opens/closes a
  272. // Briefcase storage interface.
  273. //
  274. // These must be serialized.
  275. extern UINT g_cBusyRef; // Semaphore
  276. extern UINT g_cBriefRef; // Semaphore
  277. #define IsBusySemaphore() (g_cBusyRef > 0)
  278. #define IncBusySemaphore() (g_cBusyRef++)
  279. #define DecBusySemaphore() (g_cBusyRef--)
  280. #define IncBriefSemaphore() (g_cBriefRef++)
  281. #define DecBriefSemaphore() (g_cBriefRef--)
  282. #define IsOpenBriefSemaphore() (g_cBriefRef > 0)
  283. #define IsFirstBriefSemaphore() (g_cBriefRef == 1)
  284. #define IsLastBriefSemaphore() (g_cBriefRef == 0)
  285. #endif //!__BRFPRV_H__