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.

444 lines
17 KiB

  1. /* *
  2. * Browser implementation
  3. *
  4. * Jan 97: erican
  5. */
  6. #pragma once
  7. // for ITreeViewNotify
  8. #include "treeview.h"
  9. // for IConnectionNotify
  10. #include "conman.h"
  11. #include "tbbands.h"
  12. // for IIdentityChangeNotify
  13. #include "msident.h"
  14. // for IMessageList
  15. #include "msoeobj.h"
  16. typedef enum tagLAYOUTPOS
  17. {
  18. LAYOUT_POS_NA = -1,
  19. LAYOUT_POS_TOP = 0,
  20. LAYOUT_POS_LEFT,
  21. LAYOUT_POS_BOTTOM,
  22. LAYOUT_POS_RIGHT
  23. } LAYOUTPOS;
  24. typedef struct tagLAYOUT
  25. {
  26. DWORD cbSize;
  27. // Things that can be turned on or off
  28. unsigned fToolbar : 1;
  29. unsigned fStatusBar : 1;
  30. unsigned fFolderBar : 1;
  31. unsigned fFolderList : 1;
  32. unsigned fTipOfTheDay : 1;
  33. unsigned fInfoPaneEnabled : 1;
  34. unsigned fInfoPane : 1;
  35. unsigned fOutlookBar : 1;
  36. unsigned fContacts : 1;
  37. unsigned fMailPreviewPane : 1;
  38. unsigned fMailPreviewPaneHeader : 1;
  39. unsigned fMailSplitVertically : 1;
  40. unsigned fNewsPreviewPane : 1;
  41. unsigned fNewsPreviewPaneHeader : 1;
  42. unsigned fNewsSplitVertically : 1;
  43. unsigned fFilterBar : 1;
  44. // Which side is the toolbar docked to
  45. //COOLBAR_SIDE csToolbarSide;
  46. // Preview Pane settings
  47. BYTE bMailSplitHorzPct; // Percent of the view that the preview pane occupies in mail / imap
  48. BYTE bMailSplitVertPct;
  49. BYTE bNewsSplitHorzPct; // Percent of the view that the preview pane occupies in news
  50. BYTE bNewsSplitVertPct;
  51. } LAYOUT, *PLAYOUT;
  52. // forward defines
  53. class CStatusBar;
  54. class CBodyBar;
  55. class CFolderBar;
  56. class COutBar;
  57. typedef struct tagACCTMENU *LPACCTMENU;
  58. class CNavPane;
  59. class CAdBar;
  60. class IBrowserDoc
  61. {
  62. public:
  63. virtual void ResetMenus(HMENU) = 0;
  64. virtual void BrowserExiting(void) = 0;
  65. };
  66. interface IAthenaBrowser;
  67. /////////////////////////////////////////////////////////////////////////////
  68. //
  69. // IViewWindow
  70. //
  71. // Description:
  72. // IViewWindow is implemented by all views that are hosted within the
  73. // Outlook Express shell. The methods in this interface are used to manage
  74. // UI related things such as creation and destruction, keyboard input, and
  75. // menu enabling etc.
  76. //
  77. interface IViewWindow : public IOleWindow
  78. {
  79. STDMETHOD(TranslateAccelerator)(THIS_ LPMSG pMsg) PURE;
  80. STDMETHOD(UIActivate)(THIS_ UINT uState) PURE;
  81. STDMETHOD(CreateViewWindow)(THIS_ IViewWindow *pPrevView, IAthenaBrowser *pBrowser,
  82. RECT *prcView, HWND *pHwnd) PURE;
  83. STDMETHOD(DestroyViewWindow)(THIS) PURE;
  84. STDMETHOD(SaveViewState)(THIS) PURE;
  85. STDMETHOD(OnPopupMenu)(THIS_ HMENU hMenu, HMENU hMenuPopup, UINT uID) PURE;
  86. };
  87. /////////////////////////////////////////////////////////////////////////////
  88. //
  89. // IMessageWindow
  90. //
  91. // IMessageWindow is an interface implemented specifically by views in
  92. // Outlook Express that contain the Message List object and Preview Pane
  93. // object. Methods are used to control the behavior of those controls.
  94. //
  95. interface IMessageWindow : public IUnknown
  96. {
  97. STDMETHOD(OnFrameWindowActivate)(THIS_ BOOL fActivate) PURE;
  98. STDMETHOD(GetCurCharSet)(THIS_ UINT *cp) PURE;
  99. STDMETHOD(UpdateLayout)(THIS_ BOOL fPreviewVisible, BOOL fPreviewHeader,
  100. BOOL fPreviewVert, BOOL fReload) PURE;
  101. STDMETHOD(GetMessageList)(THIS_ IMessageList ** ppMsgList) PURE;
  102. };
  103. /////////////////////////////////////////////////////////////////////////////
  104. //
  105. // IServerInfo
  106. //
  107. // IServerInfo is used so a newly created view can query the previous view
  108. // to see if the current connection to the server can be reused for this new
  109. // folder.
  110. //
  111. interface IServerInfo : public IUnknown
  112. {
  113. STDMETHOD(GetFolderId)(THIS_ FOLDERID *pID) PURE;
  114. STDMETHOD(GetMessageFolder)(THIS_ IMessageServer **ppServer) PURE;
  115. };
  116. DECLARE_INTERFACE_(IAthenaBrowser, IOleWindow)
  117. {
  118. // *** IUnknown methods ***
  119. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  120. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  121. STDMETHOD_(ULONG,Release) (THIS) PURE;
  122. // *** IOleWindow methods ***
  123. STDMETHOD(GetWindow) (THIS_ HWND * lphwnd) PURE;
  124. STDMETHOD(ContextSensitiveHelp) (THIS_ BOOL fEnterMode) PURE;
  125. // *** IAthenaBrowser methods ***
  126. STDMETHOD(TranslateAccelerator) (THIS_ LPMSG lpmsg) PURE;
  127. STDMETHOD(AddToolbar) (THIS_ IUnknown* punkSrc, DWORD dwIndex, BOOL fShow, BOOL fActivate) PURE;
  128. STDMETHOD(ShowToolbar) (THIS_ IUnknown* punkSrc, BOOL fShow) PURE;
  129. STDMETHOD(RemoveToolbar) (THIS_ IUnknown* punkSrc) PURE;
  130. STDMETHOD(HasFocus) (THIS_ UINT itb) PURE;
  131. STDMETHOD(OnViewWindowActive) (THIS_ struct IViewWindow *pAV) PURE;
  132. STDMETHOD(BrowseObject) (THIS_ FOLDERID idFolder, DWORD dwFlags) PURE;
  133. STDMETHOD(GetStatusBar) (THIS_ CStatusBar * * ppStatusBar) PURE;
  134. STDMETHOD(GetCoolbar) (THIS_ CBands * * ppCoolbar) PURE;
  135. STDMETHOD(GetLanguageMenu) (THIS_ HMENU *phMenu, UINT cp) PURE;
  136. STDMETHOD(InitPopupMenu) (THIS_ HMENU hMenu) PURE;
  137. STDMETHOD(UpdateToolbar) (THIS) PURE;
  138. STDMETHOD(GetFolderType) (THIS_ FOLDERTYPE *pftType) PURE;
  139. STDMETHOD(GetCurrentFolder) (THIS_ FOLDERID *pidFolder) PURE;
  140. STDMETHOD(GetCurrentView) (THIS_ IViewWindow **ppView) PURE;
  141. STDMETHOD(GetTreeView) (THIS_ CTreeView **ppTree) PURE;
  142. STDMETHOD(GetViewRect) (THIS_ LPRECT prc) PURE;
  143. STDMETHOD(GetFolderBar) (THIS_ CFolderBar **ppFolderBar) PURE;
  144. STDMETHOD(SetViewLayout)(THIS_ DWORD opt, LAYOUTPOS pos, BOOL fVisible, DWORD dwFlags, DWORD dwSize) PURE;
  145. STDMETHOD(GetViewLayout)(THIS_ DWORD opt, LAYOUTPOS *pPos, BOOL *pfVisible, DWORD *pdwFlags, DWORD *pdwSize) PURE;
  146. STDMETHOD(GetLayout) (THIS_ PLAYOUT playout) PURE;
  147. STDMETHOD(AccountsChanged) (THIS) PURE;
  148. STDMETHOD(CycleFocus)(THIS_ BOOL fReverse) PURE;
  149. STDMETHOD(ShowAdBar)(THIS_ BSTR bstr) PURE;
  150. };
  151. #define ITB_NONE ((UINT)-1)
  152. #define ITB_COOLBAR 0
  153. #define ITB_ADBAR 1
  154. #define ITB_BODYBAR 2
  155. #define ITB_OUTBAR 3
  156. #define ITB_FOLDERBAR 4
  157. #define ITB_NAVPANE 5
  158. #define ITB_TREE 6
  159. #define ITB_MAX 7
  160. //changing the name from ITB_VIEW to ITB_OEVIEW to fix the build break caused due to a redef in iedev
  161. #define ITB_OEVIEW (ITB_MAX + 1)
  162. /////////////////////////////////////////////////////////////////////////////
  163. //
  164. // CBrowser
  165. //
  166. class CBrowser :
  167. public IAthenaBrowser,
  168. public IOleCommandTarget,
  169. public IDockingWindowSite,
  170. public IInputObjectSite,
  171. public ITreeViewNotify,
  172. public IConnectionNotify,
  173. public IIdentityChangeNotify,
  174. public IStoreCallback
  175. {
  176. public:
  177. /////////////////////////////////////////////////////////////////////////
  178. //
  179. // OLE Interfaces
  180. //
  181. // IUnknown
  182. virtual STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
  183. virtual STDMETHODIMP_(ULONG) AddRef(void);
  184. virtual STDMETHODIMP_(ULONG) Release(void);
  185. // IOleWindow
  186. virtual STDMETHODIMP GetWindow(HWND * lphwnd);
  187. virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  188. // IAthenaBrowser (also IOleWindow)
  189. virtual STDMETHODIMP TranslateAccelerator(LPMSG lpmsg);
  190. virtual STDMETHODIMP AddToolbar(IUnknown* punkSrc, DWORD dwIndex, BOOL fShow, BOOL fActivate);
  191. virtual STDMETHODIMP ShowToolbar(IUnknown* punkSrc, BOOL fShow);
  192. virtual STDMETHODIMP RemoveToolbar(IUnknown* punkSrc);
  193. virtual STDMETHODIMP HasFocus(UINT itb);
  194. virtual STDMETHODIMP OnViewWindowActive(IViewWindow *pAV);
  195. virtual STDMETHODIMP BrowseObject(FOLDERID idFolder, DWORD dwFlags);
  196. virtual STDMETHODIMP GetStatusBar(CStatusBar * * ppStatusBar);
  197. virtual STDMETHODIMP GetCoolbar(CBands * * ppCoolbar);
  198. virtual STDMETHODIMP GetLanguageMenu(HMENU *phMenu, UINT cp);
  199. virtual STDMETHODIMP InitPopupMenu(HMENU hMenu);
  200. virtual STDMETHODIMP UpdateToolbar();
  201. virtual STDMETHODIMP GetFolderType(FOLDERTYPE *pftType);
  202. virtual STDMETHODIMP GetCurrentFolder(FOLDERID *pidFolder);
  203. virtual STDMETHODIMP GetCurrentView(IViewWindow **ppView);
  204. virtual STDMETHODIMP GetTreeView(CTreeView * * ppTree);
  205. virtual STDMETHODIMP GetViewRect(LPRECT prc);
  206. virtual STDMETHODIMP GetFolderBar(CFolderBar **ppFolderBar);
  207. virtual STDMETHODIMP SetViewLayout(DWORD opt, LAYOUTPOS pos, BOOL fVisible, DWORD dwFlags, DWORD dwSize);
  208. virtual STDMETHODIMP GetViewLayout(DWORD opt, LAYOUTPOS *pPos, BOOL *pfVisible, DWORD *pdwFlags, DWORD *pdwSize);
  209. virtual STDMETHODIMP GetLayout(PLAYOUT playout);
  210. virtual STDMETHODIMP AccountsChanged(void) { m_fRebuildAccountMenu = TRUE; return (S_OK); }
  211. virtual STDMETHODIMP CycleFocus(BOOL fReverse);
  212. virtual STDMETHODIMP ShowAdBar(BSTR bstr);
  213. // IOleCommandTarget
  214. virtual STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[],
  215. OLECMDTEXT *pCmdText);
  216. virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt,
  217. VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  218. // IDockingWindowSite (also IOleWindow)
  219. virtual STDMETHODIMP GetBorderDW(IUnknown* punkSrc, LPRECT lprectBorder);
  220. virtual STDMETHODIMP RequestBorderSpaceDW(IUnknown* punkSrc, LPCBORDERWIDTHS pborderwidths);
  221. virtual STDMETHODIMP SetBorderSpaceDW(IUnknown* punkSrc, LPCBORDERWIDTHS pborderwidths);
  222. // IInputObjectSite
  223. virtual STDMETHODIMP OnFocusChangeIS(IUnknown* punkSrc, BOOL fSetFocus);
  224. // ITreeViewNotify
  225. void OnSelChange(FOLDERID idFolder);
  226. void OnRename(FOLDERID idFolder);
  227. void OnDoubleClick(FOLDERID idFolder);
  228. // IStoreCallback Members
  229. STDMETHODIMP OnBegin(STOREOPERATIONTYPE tyOperation, STOREOPERATIONINFO *pOpInfo, IOperationCancel *pCancel) { return(E_NOTIMPL); }
  230. STDMETHODIMP OnTimeout(LPINETSERVER pServer, LPDWORD pdwTimeout, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  231. STDMETHODIMP CanConnect(LPCSTR pszAccountId, DWORD dwFlags) { return(E_NOTIMPL); }
  232. STDMETHODIMP OnLogonPrompt(LPINETSERVER pServer, IXPTYPE ixpServerType) { return(E_NOTIMPL); }
  233. STDMETHODIMP OnComplete(STOREOPERATIONTYPE tyOperation, HRESULT hrComplete, LPSTOREOPERATIONINFO pOpInfo, LPSTOREERROR pErrorInfo) { return(E_NOTIMPL); }
  234. STDMETHODIMP OnPrompt(HRESULT hrError, LPCTSTR pszText, LPCTSTR pszCaption, UINT uType, INT *piUserResponse) { return(E_NOTIMPL); }
  235. STDMETHODIMP OnProgress(STOREOPERATIONTYPE tyOperation, DWORD dwCurrent, DWORD dwMax, LPCSTR pszStatus) { return(E_NOTIMPL); }
  236. STDMETHODIMP GetParentWindow(DWORD dwReserved, HWND *phwndParent);
  237. // IConnectionNotify
  238. virtual STDMETHODIMP OnConnectionNotify(CONNNOTIFY nCode, LPVOID pvData, CConnectionManager *pConMan);
  239. // IIdentityChangeNotify
  240. virtual STDMETHODIMP QuerySwitchIdentities();
  241. virtual STDMETHODIMP SwitchIdentities();
  242. virtual STDMETHODIMP IdentityInformationChanged(DWORD dwType);
  243. void SetDocObjPointer(IBrowserDoc* pDocObj)
  244. {
  245. m_pDocObj = pDocObj;
  246. }
  247. /////////////////////////////////////////////////////////////////////////
  248. //
  249. // Constructors, Destructors, and Initialization
  250. //
  251. CBrowser();
  252. virtual ~CBrowser();
  253. HRESULT HrInit(UINT nCmdShow, FOLDERID idFolder, HWND hWndParent = NULL);
  254. HRESULT IsMenuMessage(MSG *lpmsg);
  255. HRESULT TranslateMenuMessage(MSG *lpmsg, LRESULT *lres);
  256. void WriteUnreadCount(void);
  257. private:
  258. // IAthenaToolbarFrame support functions
  259. void _OnFocusChange(UINT itb);
  260. UINT FindTBar(IUnknown* punkSrc);
  261. void ReleaseToolbarItem(int itb, BOOL fClose);
  262. void ResizeNextBorder(UINT itb);
  263. void GetClientArea(LPRECT prc);
  264. void SetFolderType(FOLDERID idFolder);
  265. void DeferedLanguageMenu();
  266. HRESULT LoadLayoutSettings(void);
  267. HRESULT SaveLayoutSettings(void);
  268. /////////////////////////////////////////////////////////////////////////
  269. //
  270. // Callback Functions
  271. //
  272. // Note: All callbacks must be made static members to avoid having the
  273. // implicit "this" pointer passed as the first parameter.
  274. //
  275. static LRESULT CALLBACK EXPORT_16 BrowserWndProc(HWND, UINT, WPARAM, LPARAM);
  276. /////////////////////////////////////////////////////////////////////////
  277. //
  278. // Message Handling
  279. //
  280. LRESULT WndProc(HWND, UINT, WPARAM, LPARAM);
  281. BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
  282. void OnSize(HWND hwnd, UINT state, int cxClient, int cyClient);
  283. void OnInitMenuPopup(HWND hwnd, HMENU hmenuPopup, UINT uPos, BOOL fSystemMenu);
  284. HRESULT OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
  285. void SpoolerDeliver(WPARAM wParam, LPARAM lParam);
  286. void EnableMenuCallback(HMENU hMenu, UINT wID);
  287. void FrameActivatePopups(BOOL fActive);
  288. void UpdateStatusBar(void);
  289. HRESULT CmdSendReceieveAccount(DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  290. HRESULT CmdDeleteAccel(DWORD nCmdID, DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);
  291. BOOL _InitToolbars();
  292. void _ResetMenu(FOLDERTYPE ftNew, BOOL fHideHotMail);
  293. HRESULT _CheckAndWriteUnreadNumber(DWORD dwSrvTypes);
  294. DWORD _GetNumberOfUnreadMsg(IMessageFolder *pFolder);
  295. inline void _AppendIdentityName(LPCTSTR pszIdentityName, LPSTR pszName, DWORD cchName);
  296. private:
  297. /////////////////////////////////////////////////////////////////////////
  298. //
  299. // Private Data
  300. //
  301. /////////////////////////////////////////////////////////////////////////
  302. // Shell Stuff
  303. UINT m_cRef;
  304. HWND m_hwnd; // Our window
  305. IViewWindow *m_pView;
  306. IOleCommandTarget *m_pViewCT;
  307. HWND m_hwndInner;
  308. FOLDERTYPE m_ftSel;
  309. FOLDERID m_idSelected;
  310. BOOL m_fPainted;
  311. HICON m_hIconPhone,
  312. m_hIconError,
  313. m_hIconAthena,
  314. m_hIconOffline,
  315. m_hIcon,
  316. m_hIconSm;
  317. BOOL m_fRebuildAccountMenu,
  318. m_fInitNewAcctMenu,
  319. m_fInternal;
  320. HMENU m_hMenu;
  321. HWNDLIST m_hlDisabled;
  322. BOOL m_fNoModifyAccts;
  323. /////////////////////////////////////////////////////////////////////////
  324. // Child support
  325. CTreeView *m_pTreeView;
  326. CStatusBar *m_pStatus;
  327. CBands *m_pCoolbar;
  328. CBodyBar *m_pBodyBar;
  329. CFolderBar *m_pFolderBar;
  330. HWND m_hwndLastFocus;
  331. CNavPane *m_pNavPane;
  332. TCHAR m_szName[CCHMAX_STRINGRES];
  333. /////////////////////////////////////////////////////////////////////////
  334. // Layout members
  335. struct SToolbarItem {
  336. IDockingWindow *ptbar;
  337. IOleCommandTarget *pOleCmdTarget;
  338. BORDERWIDTHS rcBorderTool;
  339. DWORD fShow;
  340. };
  341. SToolbarItem m_rgTBar[ITB_MAX];
  342. UINT m_itbLastFocus; // last one called OnFocusChange (can be ITB_NONE)
  343. LAYOUT m_rLayout;
  344. /////////////////////////////////////////////////////////////////////////
  345. // Mail stuff
  346. ULONG m_cAcctMenu;
  347. LPACCTMENU m_pAcctMenu;
  348. BOOL m_fAnimate;
  349. UINT_PTR m_idClearStatusTimer;
  350. /////////////////////////////////////////////////////////////////////////
  351. // View Language Menu
  352. HMENU m_hMenuLanguage;
  353. BOOL m_fEnvMenuInited;
  354. /////////////////////////////////////////////////////////////////////////
  355. IBrowserDoc *m_pDocObj;
  356. COutBar *m_pOutBar;
  357. DWORD m_dwIdentCookie;
  358. BOOL m_fSwitchIsLogout;
  359. CAdBar *m_pAdBar;
  360. };
  361. #define DISPID_MSGVIEW_BASE 1000
  362. #define DISPID_MSGVIEW_TOOLBAR (DISPID_MSGVIEW_BASE + 1)
  363. #define DISPID_MSGVIEW_STATUSBAR (DISPID_MSGVIEW_BASE + 2)
  364. #define DISPID_MSGVIEW_FOLDERBAR (DISPID_MSGVIEW_BASE + 4)
  365. #define DISPID_MSGVIEW_FOLDERLIST (DISPID_MSGVIEW_BASE + 5)
  366. #define DISPID_MSGVIEW_TIPOFTHEDAY (DISPID_MSGVIEW_BASE + 6)
  367. #define DISPID_MSGVIEW_INFOPANE (DISPID_MSGVIEW_BASE + 7)
  368. #define DISPID_MSGVIEW_PREVIEWPANE_MAIL (DISPID_MSGVIEW_BASE + 8)
  369. #define DISPID_MSGVIEW_PREVIEWPANE_NEWS (DISPID_MSGVIEW_BASE + 9)
  370. #define DISPID_MSGVIEW_FOLDER (DISPID_MSGVIEW_BASE + 10)
  371. #define DISPID_MSGVIEW_OUTLOOK_BAR (DISPID_MSGVIEW_BASE + 11)
  372. #define DISPID_MSGVIEW_CONTACTS (DISPID_MSGVIEW_BASE + 12)
  373. #define DISPID_MSGVIEW_FILTERBAR (DISPID_MSGVIEW_BASE + 13)
  374. /////////////////////////////////////////////////////////////////////////////
  375. // Drop Down treeview support
  376. void RegisterGlobalDropDown(HWND hwndCtrl);
  377. void UnregisterGlobalDropDown(HWND hwndCtrl);
  378. void CancelGlobalDropDown();
  379. HWND HwndGlobalDropDown();