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.

391 lines
16 KiB

  1. /*
  2. * ishcut.h - Internet Shortcut class implementation description.
  3. */
  4. #ifndef _INTSHCUT_HPP_
  5. #define _INTSHCUT_HPP_
  6. #include "urlprop.h"
  7. #include "subsmgr.h"
  8. #include "cowsite.h"
  9. //
  10. // Define this to enable the integrated history database
  11. //
  12. #define USE_NEW_HISTORYDATA
  13. #ifdef __cplusplus
  14. /* Types
  15. ********/
  16. // Intshcut flags
  17. #define ISF_DEFAULT 0x00000000
  18. #define ISF_DIRTY 0x00000001 // URL is dirty
  19. #define ISF_DESKTOP 0x00000002 // Located on the desktop
  20. #define ISF_FAVORITES 0x00000004 // Located in favorites folder
  21. #define ISF_WATCH 0x00000008 // Scratch flag for context menu
  22. #define ISF_SPECIALICON 0x00000010 // Icon is munged for splat
  23. #define ISF_CODEPAGE 0x00000020 // Code page is set
  24. #define ISF_ALL 0x0000003F
  25. // Intshcut Shell extension
  26. class Intshcut : public IDataObject,
  27. public IContextMenu2,
  28. public IExtractIconA,
  29. public IExtractIconW,
  30. public IPersistFile,
  31. public IPersistStream,
  32. public IShellExtInit,
  33. public IShellLinkA,
  34. public IShellLinkW,
  35. public IShellPropSheetExt,
  36. public IPropertySetStorage,
  37. public INewShortcutHookA,
  38. public INewShortcutHookW,
  39. public IUniformResourceLocatorA,
  40. public IUniformResourceLocatorW,
  41. public IQueryInfo,
  42. public IQueryCodePage,
  43. public CObjectWithSite,
  44. public INamedPropertyBag,
  45. public IOleCommandTarget
  46. {
  47. private:
  48. LONG m_cRef;
  49. DWORD m_dwFlags; // ISF_* flags
  50. LPTSTR m_pszFile; // Name of internet shortcut
  51. LPTSTR m_pszFileToLoad ; // Name of Internet Shortcut that was
  52. IntshcutProp *m_pprop; // Internal properties
  53. IntsiteProp *m_psiteprop; // Internet Site properties
  54. LPTSTR m_pszFolder; // Used by INewShortcutHook
  55. UINT m_uiCodePage; // Used by IQueryCodePage -- sendmail.dll for send current document
  56. BOOL m_bCheckForDelete; // Used to see if we need to delete a subscription if the
  57. // shortcut is deleted.
  58. BOOL m_fMustLoadSync; // Set to TRUE if any interface other than IPersistFile or
  59. // IExtractIconW/A are given out
  60. BOOL m_fProbablyDefCM; // this shortcut was most likely init'd by defcm
  61. IDataObject *m_pInitDataObject;
  62. LPTSTR m_pszTempFileName; // temporary file to be deleted when ishcut goes away
  63. LPTSTR m_pszDescription;
  64. IUnknown *_punkLink; // for file: URLs
  65. STDMETHODIMP InitProp(void);
  66. STDMETHODIMP InitSiteProp(void);
  67. STDMETHODIMP OnReadOffline(void);
  68. STDMETHODIMP OnWatch(void);
  69. STDMETHODIMP MirrorProperties(void);
  70. // data transfer methods
  71. STDMETHODIMP_(DWORD) GetFileContentsAndSize(LPSTR *ppsz);
  72. STDMETHODIMP TransferUniformResourceLocator(FORMATETC *pfmtetc, STGMEDIUM *pstgmed);
  73. STDMETHODIMP TransferText(FORMATETC *pfmtetc, STGMEDIUM *pstgmed);
  74. STDMETHODIMP TransferFileGroupDescriptorA(FORMATETC *pfmtetc, STGMEDIUM *pstgmed);
  75. STDMETHODIMP TransferFileGroupDescriptorW(FORMATETC *pfmtetc, STGMEDIUM *pstgmed);
  76. STDMETHODIMP TransferFileContents(FORMATETC *pfmtetc, STGMEDIUM *pstgmed);
  77. STDMETHODIMP GetDocumentStream(IStream **ppstm);
  78. STDMETHODIMP GetDocumentName(LPTSTR pszName);
  79. HRESULT _Extract(LPCTSTR pszIconFile, UINT iIcon, HICON * phiconLarge, HICON * phiconSmall, UINT ucIconSize);
  80. HRESULT _GetIconLocation(UINT uFlags, LPWSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags);
  81. ~Intshcut(void); // Prevent this class from being allocated on the stack or it will fault.
  82. public:
  83. Intshcut(void);
  84. // IDataObject methods
  85. STDMETHODIMP GetData(FORMATETC *pfmtetcIn, STGMEDIUM *pstgmed);
  86. STDMETHODIMP GetDataHere(FORMATETC *pfmtetc, STGMEDIUM *pstgpmed);
  87. STDMETHODIMP QueryGetData(FORMATETC *pfmtetc);
  88. STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *pfmtetcIn, FORMATETC *pfmtetcOut);
  89. STDMETHODIMP SetData(FORMATETC *pfmtetc, STGMEDIUM *pstgmed, BOOL bRelease);
  90. STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppienumFormatEtc);
  91. STDMETHODIMP DAdvise(FORMATETC *pfmtetc, DWORD dwAdviseFlags, IAdviseSink * piadvsink, PDWORD pdwConnection);
  92. STDMETHODIMP DUnadvise(DWORD dwConnection);
  93. STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppienumStatData);
  94. // IExtractIconA methods
  95. STDMETHODIMP GetIconLocation(UINT uFlags, LPSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags);
  96. STDMETHODIMP Extract(LPCSTR pcszFile, UINT uIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT ucIconSize);
  97. // IExtractIconW methods
  98. STDMETHODIMP GetIconLocation(UINT uFlags, LPWSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags);
  99. STDMETHODIMP Extract(LPCWSTR pcszFile, UINT uIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT ucIconSize);
  100. // INewShortcutHookA methods
  101. STDMETHODIMP SetReferent(LPCSTR pcszReferent, HWND hwndParent);
  102. STDMETHODIMP GetReferent(LPSTR pszReferent, int ncReferentBufLen);
  103. STDMETHODIMP SetFolder(LPCSTR pcszFolder);
  104. STDMETHODIMP GetFolder(LPSTR pszFolder, int ncFolderBufLen);
  105. STDMETHODIMP GetName(LPSTR pszName, int ncNameBufLen);
  106. STDMETHODIMP GetExtension(LPSTR pszExtension, int ncExtensionBufLen);
  107. // INewShortcutHookW methods
  108. STDMETHODIMP SetReferent(LPCWSTR pcszReferent, HWND hwndParent);
  109. STDMETHODIMP GetReferent(LPWSTR pszReferent, int ncReferentBufLen);
  110. STDMETHODIMP SetFolder(LPCWSTR pcszFolder);
  111. STDMETHODIMP GetFolder(LPWSTR pszFolder, int ncFolderBufLen);
  112. STDMETHODIMP GetName(LPWSTR pszName, int ncNameBufLen);
  113. STDMETHODIMP GetExtension(LPWSTR pszExtension, int ncExtensionBufLen);
  114. // IPersist methods
  115. STDMETHODIMP GetClassID(CLSID *pclsid);
  116. // IPersistFile methods
  117. STDMETHODIMP IsDirty(void);
  118. STDMETHODIMP Save(LPCOLESTR pcwszFileName, BOOL bRemember);
  119. STDMETHODIMP SaveCompleted(LPCOLESTR pcwszFileName);
  120. STDMETHODIMP Load(LPCOLESTR pcwszFileName, DWORD dwMode);
  121. STDMETHODIMP GetCurFile(LPOLESTR *ppwszFileName);
  122. // IPersistStream methods
  123. STDMETHODIMP Save(IStream * pistr, BOOL bClearDirty);
  124. STDMETHODIMP Load(IStream * pistr);
  125. STDMETHODIMP GetSizeMax(PULARGE_INTEGER pcbSize);
  126. // IShellExtInit methods
  127. STDMETHODIMP Initialize(LPCITEMIDLIST pcidlFolder, IDataObject * pidobj, HKEY hkeyProgID);
  128. // IShellLink methods
  129. STDMETHODIMP SetPath(LPCSTR pcszPath);
  130. STDMETHODIMP GetPath(LPSTR pszFile, int ncFileBufLen, PWIN32_FIND_DATAA pwfd, DWORD dwFlags);
  131. STDMETHODIMP SetRelativePath(LPCSTR pcszRelativePath, DWORD dwReserved);
  132. STDMETHODIMP SetIDList(LPCITEMIDLIST pcidl);
  133. STDMETHODIMP GetIDList(LPITEMIDLIST *ppidl);
  134. STDMETHODIMP SetDescription(LPCSTR pcszDescription);
  135. STDMETHODIMP GetDescription(LPSTR pszDescription, int ncDesciptionBufLen);
  136. STDMETHODIMP SetArguments(LPCSTR pcszArgs);
  137. STDMETHODIMP GetArguments(LPSTR pszArgs, int ncArgsBufLen);
  138. STDMETHODIMP SetWorkingDirectory(LPCSTR pcszWorkingDirectory);
  139. STDMETHODIMP GetWorkingDirectory(LPSTR pszWorkingDirectory, int ncbLen);
  140. STDMETHODIMP SetHotkey(WORD wHotkey);
  141. STDMETHODIMP GetHotkey(PWORD pwHotkey);
  142. STDMETHODIMP SetShowCmd(int nShowCmd);
  143. STDMETHODIMP GetShowCmd(PINT pnShowCmd);
  144. STDMETHODIMP SetIconLocation(LPCSTR pcszIconFile, int niIcon);
  145. STDMETHODIMP GetIconLocation(LPSTR pszIconFile, int ncbLen, PINT pniIcon);
  146. STDMETHODIMP Resolve(HWND hwnd, DWORD dwFlags);
  147. // IShellLinkW functions that change from the A functions...
  148. STDMETHODIMP SetPath(LPCWSTR pcszPath);
  149. STDMETHODIMP GetPath(LPWSTR pszFile, int ncFileBufLen, PWIN32_FIND_DATAW pwfd, DWORD dwFlags);
  150. STDMETHODIMP SetRelativePath(LPCWSTR pcszRelativePath, DWORD dwReserved);
  151. STDMETHODIMP SetDescription(LPCWSTR pcszDescription);
  152. STDMETHODIMP GetDescription(LPWSTR pszDescription, int ncDesciptionBufLen);
  153. STDMETHODIMP SetArguments(LPCWSTR pcszArgs);
  154. STDMETHODIMP GetArguments(LPWSTR pszArgs, int ncArgsBufLen);
  155. STDMETHODIMP SetWorkingDirectory(LPCWSTR pcszWorkingDirectory);
  156. STDMETHODIMP GetWorkingDirectory(LPWSTR pszWorkingDirectory, int ncbLen);
  157. STDMETHODIMP SetIconLocation(LPCWSTR pcszIconFile, int niIcon);
  158. STDMETHODIMP GetIconLocation(LPWSTR pszIconFile, int ncbLen, PINT pniIcon);
  159. // IShellPropSheetExt methods
  160. STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);
  161. STDMETHODIMP ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplaceWith, LPARAM lParam);
  162. // IContextMenu methods
  163. STDMETHODIMP QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
  164. STDMETHODIMP InvokeCommand(IN LPCMINVOKECOMMANDINFO pici);
  165. STDMETHODIMP GetCommandString(UINT_PTR idCmd, UINT uType, UINT * puReserved, LPSTR pszName, UINT cchMax);
  166. STDMETHODIMP HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
  167. // IUniformResourceLocatorA methods
  168. STDMETHODIMP SetURL(LPCSTR pcszURL, DWORD dwFlags);
  169. STDMETHODIMP GetURL(LPSTR *ppszURL);
  170. STDMETHODIMP InvokeCommand(PURLINVOKECOMMANDINFOA purlici);
  171. // IUniformResourceLocatorW methods
  172. STDMETHODIMP SetURL(LPCWSTR pcszURL, DWORD dwFlags);
  173. STDMETHODIMP GetURL(LPWSTR *ppszURL);
  174. STDMETHODIMP InvokeCommand(PURLINVOKECOMMANDINFOW purlici);
  175. // IPropertySetStorage methods
  176. STDMETHODIMP Create(REFFMTID fmtid, const CLSID * pclsid, DWORD grfFlags, DWORD grfMode, IPropertyStorage** ppPropStg);
  177. STDMETHODIMP Open(REFFMTID fmtid, DWORD grfMode, IPropertyStorage** ppPropStg);
  178. STDMETHODIMP Delete(REFFMTID fmtid);
  179. STDMETHODIMP Enum(IEnumSTATPROPSETSTG** ppenum);
  180. // IQueryInfo methods
  181. STDMETHODIMP GetInfoTip(DWORD dwFlags, WCHAR **ppwszTip);
  182. STDMETHODIMP GetInfoFlags(DWORD *pdwFlags);
  183. // IOleCommandTarget
  184. STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
  185. ULONG cCmds, MSOCMD rgCmds[], MSOCMDTEXT *pcmdtext);
  186. STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  187. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  188. // IQueryCodePage methods
  189. // Purpose: This is a hack to use the URL to store the codepage for
  190. // send currenct document and pass it to sendmail.dll
  191. STDMETHODIMP GetCodePage(UINT * puiCodePage);
  192. STDMETHODIMP SetCodePage(UINT uiCodePage);
  193. // *** IObjectWithSite methods from CObjectWithSite***
  194. /*
  195. virtual STDMETHODIMP SetSite(IUnknown *pUnkSite);
  196. virtual STDMETHODIMP GetSite(REFIID riid, void **ppvSite);
  197. */
  198. // INamedPropertyBag Methods
  199. STDMETHODIMP ReadPropertyNPB(/* [in] */ LPCOLESTR pszSectionname,
  200. /* [in] */ LPCOLESTR pszPropName,
  201. /* [out] */ PROPVARIANT *pVar);
  202. STDMETHODIMP WritePropertyNPB(/* [in] */ LPCOLESTR pszSectionname,
  203. /* [in] */ LPCOLESTR pszPropName,
  204. /* [in] */ PROPVARIANT *pVar);
  205. STDMETHODIMP RemovePropertyNPB (/* [in] */ LPCOLESTR pszBagname,
  206. /* [in] */ LPCOLESTR pszPropName);
  207. // IUnknown methods
  208. STDMETHODIMP QueryInterface(REFIID riid, PVOID *ppvObj);
  209. STDMETHODIMP_(ULONG) AddRef(void);
  210. STDMETHODIMP_(ULONG) Release(void);
  211. // other methods
  212. STDMETHODIMP SaveToFile(LPCTSTR pcszFile, BOOL bRemember);
  213. STDMETHODIMP LoadFromFile(LPCTSTR pcszFile);
  214. STDMETHODIMP LoadFromAsyncFileNow();
  215. STDMETHODIMP GetCurFile(LPTSTR pszFile, UINT ucbLen);
  216. STDMETHODIMP Dirty(BOOL bDirty);
  217. STDMETHODIMP GetURLIconLocation(UINT uInFlags, LPTSTR pszBuf, UINT cchBuf, int * pniIcon, BOOL fRecentlyChanged, OUT PUINT puOutFlags);
  218. STDMETHODIMP GetIconLocationFromFlags(UINT uInFlags, LPTSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags, DWORD dwPropFlags);
  219. STDMETHODIMP_(void) ChangeNotify(LONG wEventId, UINT uFlags);
  220. STDMETHODIMP GetIDListInternal(LPITEMIDLIST *ppidl);
  221. STDMETHODIMP GetURLW(WCHAR **ppszURL);
  222. BOOL ExtractIconFromWininetCache(IN LPCTSTR pszIconString,
  223. IN UINT iIcon,
  224. OUT HICON * phiconLarge,
  225. OUT HICON * phiconSmall,
  226. IN UINT ucIconSize,
  227. BOOL *pfFoundUrl,
  228. DWORD dwPropFlags);
  229. STDMETHODIMP _GetIconLocationWithURLHelper(IN LPTSTR pszBuf,
  230. IN int cchBuf,
  231. OUT PINT pniIcon,
  232. IN LPTSTR pszActualUrl,
  233. UINT cchUrlBufSize,
  234. BOOL fRecentlyChanged);
  235. STDMETHODIMP _DoIconDownload();
  236. STDMETHODIMP _SaveOffPersistentDataFromSite();
  237. STDMETHODIMP _CreateTemporaryBackingFile();
  238. STDMETHODIMP _SetTempFileName(TCHAR *pszTempFileName);
  239. STDMETHODIMP _ComputeDescription();
  240. STDMETHODIMP_(BOOL) _IsInFavoritesFolder();
  241. IDataObject *GetInitDataObject() { ASSERT(m_pInitDataObject); return m_pInitDataObject; }
  242. STDMETHODIMP_(BOOL)_TryLink(REFIID riid, void **ppvOut);
  243. STDMETHODIMP _CreateShellLink(LPCTSTR pszPath, IUnknown **ppunk);
  244. // Query methods
  245. STDMETHODIMP_(DWORD) GetScheme(void);
  246. #ifdef DEBUG
  247. STDMETHODIMP_(void) Dump(void);
  248. friend BOOL IsValidPCIntshcut(const Intshcut *pcintshcut);
  249. #endif
  250. };
  251. typedef Intshcut * PIntshcut;
  252. typedef const Intshcut CIntshcut;
  253. typedef const Intshcut * PCIntshcut;
  254. /* Prototypes
  255. *************/
  256. // isbase.cpp
  257. HRESULT ValidateURL(LPCTSTR pcszURL);
  258. HRESULT IsProtocolRegistered(LPCTSTR pcszProtocol);
  259. BOOL AnyMeatW(LPCWSTR pcsz);
  260. BOOL AnyMeatA(LPCSTR pcsz);
  261. #ifdef UNICODE
  262. #define AnyMeat AnyMeatW
  263. #else
  264. #define AnyMeat AnyMeatA
  265. #endif
  266. #define ISHCUT_INISTRING_SECTION TEXT("InternetShortcut")
  267. #define ISHCUT_INISTRING_SECTIONW L"InternetShortcut"
  268. #define ISHCUT_INISTRING_URL TEXT("URL")
  269. #define ISHCUT_INISTRING_WORKINGDIR TEXT("WorkingDirectory")
  270. #define ISHCUT_INISTRING_WHATSNEW TEXT("WhatsNew")
  271. #define ISHCUT_INISTRING_AUTHOR TEXT("Author")
  272. #define ISHCUT_INISTRING_DESC TEXT("Desc")
  273. #define ISHCUT_INISTRING_COMMENT TEXT("Comment")
  274. #define ISHCUT_INISTRING_MODIFIED TEXT("Modified")
  275. #define ISHCUT_INISTRING_ICONINDEX TEXT("IconIndex")
  276. #define ISHCUT_INISTRING_ICONINDEXW L"IconIndex"
  277. #define ISHCUT_INISTRING_ICONFILE TEXT("IconFile")
  278. #define ISHCUT_INISTRING_ICONFILEW L"IconFile"
  279. #define ISHCUT_DEFAULT_FAVICONW L"favicon.ico";
  280. #define ISHCUT_DEFAULT_FAVICONATROOTW L"/favicon.ico";
  281. HRESULT
  282. GetGenericURLIcon(
  283. LPTSTR pszIconFile,
  284. UINT cchIconFile,
  285. PINT pniIcon);
  286. struct IS_SUBS_DEL_DATA
  287. {
  288. TCHAR m_szFile[MAX_PATH];
  289. LPWSTR m_pwszURL;
  290. ~IS_SUBS_DEL_DATA()
  291. {
  292. if (m_pwszURL)
  293. {
  294. SHFree(m_pwszURL);
  295. }
  296. }
  297. };
  298. #endif // __cplusplus
  299. //
  300. // Prototypes for all modules
  301. //
  302. STDAPI CopyURLProtocol(LPCTSTR pcszURL, LPTSTR * ppszProtocol, PARSEDURL * ppu);
  303. #endif // _INTSHCUT_HPP_