home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / mailmisc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  15.6 KB  |  549 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __MAILMISC_H
  20. #define __MAILMISC_H
  21.  
  22. #include "outliner.h"
  23. #include "msgcom.h"
  24.  
  25. #define ID_COLUMN_FROM          1
  26. #define ID_COLUMN_SUBJECT       2
  27. #define ID_COLUMN_DATE          3
  28. #define ID_COLUMN_READ          4
  29. #define ID_COLUMN_THREAD        5
  30. #define ID_COLUMN_PRIORITY        6
  31. #define ID_COLUMN_STATUS        7
  32. #define ID_COLUMN_LENGTH        8
  33. #define ID_COLUMN_COUNT         9    
  34. #define ID_COLUMN_UNREAD        10
  35. #define ID_COLUMN_FOLDER        11
  36. #define ID_COLUMN_MARK            12
  37. #define ID_COLUMN_SLAMMER        13
  38.  
  39. // array of indexes for IDB_MAILNEWS
  40. #define IDX_LOCALMAIL            0
  41. #define IDX_REMOTEMAIL            1
  42. #define IDX_NEWSHOST            2
  43. #define IDX_MAILMESSAGE            3
  44. #define IDX_MAILREAD            4
  45. #define IDX_DRAFT                5
  46. #define IDX_NEWSGROUP            6
  47. #define IDX_NEWSARTICLE            7
  48. #define IDX_NEWSGROUPNEW        8
  49. #define IDX_NEWSNEW                9
  50. #define IDX_NEWSREAD            10
  51. #define IDX_UNREAD                11
  52. #define IDX_READ                12
  53. #define IDX_MARKED                13
  54. #define IDX_CHECKMARK            14
  55. #define IDX_CHECKBOX            15
  56. #define IDX_MAILFOLDERCLOSED    16
  57. #define IDX_MAILFOLDEROPEN        17
  58. #define IDX_MAILFOLDERCLOSEDNEW    18
  59. #define IDX_MAILFOLDEROPENNEW    19
  60. #define IDX_INBOXCLOSED            20
  61. #define IDX_INBOXOPEN            21
  62. #define IDX_INBOXCLOSEDNEW        22
  63. #define IDX_INBOXOPENNEW        23
  64. #define IDX_OUTBOXCLOSED        24
  65. #define IDX_OUTBOXOPEN            25
  66. #define IDX_SENTCLOSED            26
  67. #define IDX_SENTOPEN            27
  68. #define IDX_DRAFTSCLOSED        28
  69. #define IDX_DRAFTSOPEN            29
  70. #define IDX_TRASH                30
  71. #define IDX_TRASHOPEN            31
  72. #define IDX_THREADCLOSED        32
  73. #define IDX_THREADOPEN            33
  74. #define    IDX_THREADCLOSEDNEW        34
  75. #define IDX_THREADOPENNEW        35
  76. #define IDX_THREADWATCHED        36
  77. #define IDX_THREADWATCHEDNEW    37
  78. #define IDX_TWISTYOPEN            38
  79. #define IDX_TWISTYCLOSED        39
  80. #define IDX_MAILNEW                40
  81. #define IDX_COLLECTION            41
  82. #define IDX_CONTAINER            42
  83. #define IDX_SECNEWS                43
  84. #define IDX_THREADIGNOREDCLOSED    44
  85. #define IDX_THREADIGNOREDOPEN    45
  86. #define IDX_OFFLINENEWS            46
  87. #define IDX_FOLDEROPENOFFLINE    47
  88. #define IDX_FOLDERCLOSEDOFFLINE    48
  89. #define IDX_MAILOFFLINE            49
  90. #define IDX_NEWSHOSTOFFLINE        50
  91. #define IDX_NEWSMSGOFFLINE        51
  92. #define IDX_NEWSREADOFFLINE        52
  93. #define IDX_MAILREADOFFLINE        53
  94. #define IDX_MAILMSGOFFLINE        54
  95. #define IDX_IMAPMSGDELETED        55
  96. #define IDX_TEMPLATE            56
  97. #define IDX_TEMPLATEOPEN        57
  98.  
  99. // array of indexes for IDB_MAILCOL
  100. #define IDX_THREAD              0
  101. #define IDX_MAILCHECKMARK       1
  102. #define IDX_MAILMARKED          2
  103. #define IDX_MAILUNREAD          3
  104. #define IDX_UNTHREAD            4
  105.  
  106. #define NETSCAPE_MESSAGE_FORMAT "Netscape Message"
  107. #define NETSCAPE_FOLDER_FORMAT "Netscape Folder"
  108. #define NETSCAPE_SEARCH_FORMAT "Netscape Search"
  109.  
  110. int WFE_MSGTranslateFolderIcon( uint8 level, int32 iFlags, BOOL bOpen );
  111. void WFE_MSGBuildMessagePopup( HMENU hmenu, BOOL bNews, BOOL bInHeaders = FALSE );
  112.  
  113. ///////////////////////////////////////////////////////////////////////
  114. // CMessagePrefs
  115.  
  116. class CMsgPrefs {
  117. private:
  118.     MSG_Master *m_pMaster;
  119.  
  120. public:
  121.     CMsgPrefs();
  122.     ~CMsgPrefs();
  123.  
  124.     void Init();
  125.     void Shutdown();
  126.  
  127.     BOOL IsValid() const;
  128.     MSG_Master *GetMaster();
  129.  
  130.     CGenericDocTemplate *m_pFolderTemplate;
  131.     CGenericDocTemplate *m_pThreadTemplate;
  132.     CGenericDocTemplate *m_pMsgTemplate;
  133.  
  134.     // Lib Msg prefs structure
  135.     MSG_Prefs *m_pMsgPrefs;
  136.  
  137.     // Biff Context
  138.     MWContext *m_pBiffContext;
  139.  
  140.     CString m_csMailDir;
  141.     CString m_csMailHost;
  142.     CString m_csNewsDir;
  143.     CString m_csNewsHost;
  144.     CString m_csUsersEmailAddr;
  145.     CString m_csUsersFullName;
  146.     CString m_csUsersOrganization;
  147.     LPSTR m_pszUserSig;
  148.  
  149.     BOOL m_bThreadPaneMaxed;
  150.     BOOL m_bMessageReuse;
  151.     BOOL m_bThreadReuse;
  152. };
  153.  
  154. extern CMsgPrefs g_MsgPrefs;
  155.  
  156. typedef struct {
  157.     MSG_Pane *m_pane;
  158.     int m_count;
  159.     MSG_ViewIndex *m_indices;
  160. } MailNewsDragData;
  161.  
  162. ///////////////////////////////////////////////////////////////////////
  163. // CMailNewsOutliner
  164.  
  165. class CMailNewsOutliner: public CMSelectOutliner 
  166. {
  167. protected:
  168.     MSG_Pane *m_pPane;
  169.     int m_iMysticPlane;
  170.     BOOL m_bSelChanged;
  171.     int m_iSelBlock;
  172.     BOOL m_bExpandOrCollapse;
  173.  
  174. public:
  175.     CMailNewsOutliner();
  176.     ~CMailNewsOutliner();
  177.  
  178.     virtual void SetPane( MSG_Pane *pane );
  179.     MSG_Pane *GetPane() { return m_pPane; }
  180.  
  181.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  182.                                      MSG_NOTIFY_CODE notify, 
  183.                                      MSG_ViewIndex where,
  184.                                      int32 num);
  185.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  186.                                       MSG_NOTIFY_CODE notify, 
  187.                                       MSG_ViewIndex where,
  188.                                       int32 num);
  189.  
  190.     int GetMysticStuffDepth() const { return m_iMysticPlane; }
  191.  
  192.     void BlockSelNotify(BOOL bBlock) { m_iSelBlock += (bBlock ? 1 : -1); }
  193.  
  194. protected:
  195.     // Basic Overrides
  196.     virtual int ToggleExpansion( int iLine );
  197.     virtual int Expand( int iLine );
  198.     virtual int Collapse( int iLine );
  199.  
  200.     afx_msg BOOL OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message );
  201.     afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
  202.     afx_msg void OnRButtonDown( UINT nFlags, CPoint point );
  203.     afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
  204.     afx_msg void OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags );
  205.     DECLARE_MESSAGE_MAP()
  206. };
  207.  
  208. ///////////////////////////////////////////////////////////////////////
  209. // CFolderOutliner
  210.  
  211. class CFolderOutliner : public CMailNewsOutliner
  212. {
  213. protected:
  214.     MSG_FolderLine m_FolderLine;
  215.     OutlinerAncestorInfo * m_pAncestor;
  216.     LPTSTR m_pszExtraText;
  217.     CLIPFORMAT m_cfMessages, m_cfFolders, m_cfSearchMessages;
  218.  
  219.     DWORD m_dwPrevTime; 
  220.     UINT m_uTimer; 
  221.     BOOL m_bLButtonDown;
  222.     BOOL m_bDoubleClicked;
  223.     BOOL m_b3PaneParent;
  224.     int  m_nCurrentSelected;
  225.  
  226.     MSG_FolderInfo **m_pMysticStuff;
  227.     MSG_FolderInfo *m_MysticFocus;
  228.     MSG_FolderInfo *m_MysticSelection;
  229.  
  230. public:
  231.     CFolderOutliner ( );
  232.     ~CFolderOutliner ( );
  233.     
  234.     BOOL IsParent3PaneFrame() { return m_b3PaneParent; }
  235.     void SetCurrentSelected(int nIndex) { m_nCurrentSelected = nIndex; }
  236.     int     GetCurrentSelected() { return m_nCurrentSelected; }
  237.  
  238.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  239.                                      MSG_NOTIFY_CODE notify, 
  240.                                      MSG_ViewIndex where,
  241.                                      int32 num );
  242.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  243.                                       MSG_NOTIFY_CODE notify, 
  244.                                       MSG_ViewIndex where,
  245.                                       int32 num );
  246.  
  247. protected:
  248.     virtual void OnSelChanged();
  249.     virtual void OnSelDblClk();
  250.  
  251.     // Tree Info stuff
  252.     virtual int GetDepth( int iLine );
  253.     virtual int GetNumChildren( int iLine );
  254.     virtual BOOL IsCollapsed( int iLine );
  255.  
  256.     virtual LPCTSTR GetColumnText( UINT iColumn, void * pLineData );
  257.     virtual LPCTSTR GetColumnTip( UINT iColumn, void * pLineData );
  258.     virtual void * AcquireLineData( int iLine );
  259.     virtual void ReleaseLineData( void * pLineData );
  260.     virtual void GetTreeInfo( int iLine, uint32 * pFlags, int * iDepth, 
  261.                                OutlinerAncestorInfo ** pAncestor );
  262.     virtual HFONT GetLineFont ( void * pLineData );
  263.     virtual int TranslateIcon ( void *);
  264.     virtual int TranslateIconFolder ( void *);
  265.  
  266.     virtual void PropertyMenu ( int iSel, UINT flags );
  267.  
  268.     // Drag-Drop Stuff
  269.     // clip format
  270.     virtual void InitializeClipFormats(void);
  271.     virtual CLIPFORMAT * GetClipFormatList(void);
  272.  
  273.     // initiate drag
  274.     virtual COleDataSource * GetDataSource(void);
  275.  
  276.     // accept drop
  277.     virtual DROPEFFECT DropSelect(int iLineNo, COleDataObject *object);
  278.     virtual void AcceptDrop(int iLineNo, COleDataObject *object, DROPEFFECT effect);
  279.  
  280.     afx_msg int OnCreate(LPCREATESTRUCT lpcs);
  281.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  282.     afx_msg void OnTimer(UINT nIDEvent);
  283.     afx_msg void OnDestroy();
  284.    DECLARE_MESSAGE_MAP()
  285. };
  286.  
  287. ///////////////////////////////////////////////////////////////////////
  288. // CMessageOutliner
  289.  
  290. class CMessageOutliner : public CMailNewsOutliner
  291. {
  292. protected:
  293.     MSG_MessageLine m_MessageLine;
  294.     OutlinerAncestorInfo * m_pAncestor;
  295.     LPTSTR m_pszExtraText;
  296.     CLIPFORMAT m_cfMessages;
  297.  
  298.     MessageKey *m_pMysticStuff;
  299.     MessageKey m_MysticFocus;
  300.     MessageKey m_MysticSelection;
  301.     BOOL m_bNews, m_bDrafts;
  302.  
  303.     UINT m_uTimer; 
  304.     BOOL m_bLButtonDown;
  305.     BOOL m_bDoubleClicked;
  306.     int  m_nCurrentSelected;
  307.     DWORD m_dwPrevTime; 
  308.  
  309. public:
  310.     CMessageOutliner ( );
  311.     ~CMessageOutliner ( );
  312.  
  313.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  314.                                      MSG_NOTIFY_CODE notify, 
  315.                                      MSG_ViewIndex where,
  316.                                      int32 num);
  317.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  318.                                       MSG_NOTIFY_CODE notify, 
  319.                                       MSG_ViewIndex where,
  320.                                       int32 num);
  321.  
  322.     void SetCurrentSelected(int nIndex) { m_nCurrentSelected = nIndex; }
  323.     int     GetCurrentSelected() { return m_nCurrentSelected; }
  324.  
  325.     void SelectThread( int iLine, UINT flags = 0 );
  326.     void SelectFlagged();
  327.  
  328.     BOOL IsNews() const { return m_bNews; }
  329.     void SetNews(BOOL bNews) { m_bNews = bNews;}
  330.  
  331.     void EnsureFlagsVisible();
  332.  
  333. protected:
  334.     virtual void OnSelChanged();
  335.     virtual void OnSelDblClk();
  336.  
  337.     // Tree Info stuff
  338.     virtual int GetDepth( int iLine );
  339.     virtual int GetNumChildren( int iLine );
  340.     virtual int GetParentIndex( int iLine );
  341.     virtual BOOL IsCollapsed( int iLine );
  342.  
  343.     // Tree manip stuff
  344.     virtual int ExpandAll( int iLine );
  345.     virtual int CollapseAll( int iLine );
  346.  
  347.     virtual LPCTSTR GetColumnText ( UINT iColumn, void * pLineData );
  348.     virtual void * AcquireLineData ( int iLine );
  349.     virtual void ReleaseLineData ( void * pLineData );
  350.     virtual void GetTreeInfo ( int iLine, uint32 * pFlags, int * iDepth, 
  351.                                OutlinerAncestorInfo ** pAncestor );
  352.     virtual HFONT GetLineFont ( void * pLineData );
  353.     virtual int TranslateIcon ( void *);
  354.     virtual int TranslateIconFolder ( void *);
  355.  
  356.     virtual BOOL RenderData ( UINT iColumn, CRect & rect, CDC & pdc, LPCTSTR );
  357.  
  358.     virtual BOOL ColumnCommand ( int iColumn, int iLine );
  359.     virtual void PropertyMenu ( int iSel, UINT flags );
  360.  
  361.     // Drag Drop stuff
  362.  
  363.     // clip formats
  364.     virtual void InitializeClipFormats(void);
  365.     virtual CLIPFORMAT * GetClipFormatList(void);
  366.  
  367.     // initiate drag
  368.     virtual COleDataSource * GetDataSource(void);
  369.  
  370.     // accept drop
  371.     virtual DROPEFFECT DropSelect( int iLineNo, COleDataObject *object );
  372.     virtual void AcceptDrop( int iLineNo, COleDataObject *object, DROPEFFECT effect );
  373.  
  374.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  375.     afx_msg void OnTimer(UINT nIDEvent);
  376.     afx_msg void OnDestroy();
  377.    DECLARE_MESSAGE_MAP()
  378. };
  379.  
  380. ///////////////////////////////////////////////////////////////////////
  381. // CFolderOutlinerParent
  382.  
  383. class CFolderOutlinerParent : public COutlinerParent 
  384. {
  385. public:
  386.     CFolderOutlinerParent();
  387.     ~CFolderOutlinerParent();
  388.     virtual COutliner *GetOutliner();
  389.     virtual void CreateColumns ( void );
  390.  
  391. protected:
  392.     afx_msg void OnDestroy();
  393.     DECLARE_MESSAGE_MAP()
  394. };
  395.  
  396. // CMessageOutlinerParent
  397.  
  398. class CMessageOutlinerParent : public COutlinerParent 
  399. {
  400. protected:
  401.     MWContextType m_contextType;
  402.  
  403. public:
  404.     CMessageOutlinerParent();
  405.     ~CMessageOutlinerParent();
  406.     virtual COutliner *GetOutliner();
  407.     virtual void CreateColumns ( void );
  408.     virtual BOOL RenderData ( int idColumn, CRect & rect, CDC & dc, LPCTSTR );
  409.  
  410. protected:
  411.     virtual BOOL ColumnCommand ( int iColumn );
  412.  
  413.     afx_msg void OnDestroy();
  414.     DECLARE_MESSAGE_MAP()
  415. };
  416.  
  417. ///////////////////////////////////////////////////////////////////////
  418. // CFolderView
  419.  
  420. class CFolderView   :   public COutlinerView
  421. {
  422. public:
  423.     CFolderView ( )
  424.     {
  425.         m_pOutlinerParent = (COutlinerParent *) new CFolderOutlinerParent;
  426.     }
  427.     DECLARE_DYNCREATE(CFolderView)
  428. };
  429.  
  430. /////////////////////////////////////////////////////////////////////////////
  431. // CMailFolderHelper
  432. //
  433. // It's such a pain to use the same owner draw routines for a combo box
  434. // and a list using MFC. This just pulls out the important stuff into its
  435. // own, multiple inheritable class
  436.  
  437. class CMailFolderHelper {
  438. protected:
  439.     BOOL m_bStaticCtl;
  440.  
  441.     UINT m_nAddString, m_nSetItemData, m_nResetContent;
  442.  
  443.     int m_iInitialDepth;
  444.  
  445.     MSG_Master *m_pMaster;
  446.     LPIMAGEMAP m_pIImageMap;
  447.     LPUNKNOWN m_pIImageUnk;
  448.  
  449.     HFONT m_hFont, m_hBoldFont;
  450.  
  451.     CMailFolderHelper(UINT nAddString, UINT nSetItemData, UINT nResetContent );
  452.     ~CMailFolderHelper();
  453.  
  454.     void InitFonts( HDC hdc );
  455.  
  456.     void DoDrawItem( HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct, BOOL bNoPrettyName = FALSE);
  457.     void DoMeasureItem( HWND hWnd, LPMEASUREITEMSTRUCT lpMeasureItemStruct );
  458.  
  459.     virtual void SubPopulate( HWND hWnd, int &index, MSG_FolderInfo *folder );
  460.  
  461. public:
  462.     int Populate( HWND hWnd, MSG_Master *pMaster, MSG_FolderInfo *folderInfo );
  463.     int PopulateMailServer( HWND hWnd, MSG_Master *pMaster, BOOL bRoots = TRUE);
  464.     int PopulateMail( HWND hWnd, MSG_Master *pMaster, BOOL bRoots = TRUE);
  465.     virtual int PopulateNews( HWND hWnd, MSG_Master *pMaster, BOOL bRoots = TRUE );
  466. };
  467.  
  468. /////////////////////////////////////////////////////////////////////////////
  469. // CMailFolderCombo
  470.  
  471. class CMailFolderCombo: public CComboBox, public CMailFolderHelper {
  472.  
  473. protected:
  474.  
  475.     BOOL m_bNoPrettyName;
  476.  
  477.     virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
  478.     {
  479.         DoDrawItem( m_hWnd, lpDrawItemStruct, m_bNoPrettyName);
  480.     }
  481.     virtual void MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
  482.     {
  483.         DoMeasureItem( m_hWnd, lpMeasureItemStruct );
  484.     }
  485.  
  486. public:
  487.     CMailFolderCombo(): CMailFolderHelper( CB_ADDSTRING, CB_SETITEMDATA, CB_RESETCONTENT ) 
  488.         { m_bNoPrettyName = FALSE; }
  489.  
  490.     void NoPrettyName()    { m_bNoPrettyName = TRUE; }
  491.  
  492.     int Populate( MSG_Master *pMaster, MSG_FolderInfo *folderInfo )
  493.     {
  494.         return CMailFolderHelper::Populate( m_hWnd, pMaster, folderInfo );
  495.     }
  496.  
  497.     int PopulateMail( MSG_Master *pMaster, BOOL bRoots = TRUE )
  498.     {
  499.         return CMailFolderHelper::PopulateMail( m_hWnd, pMaster, bRoots );
  500.     }
  501.  
  502.     int PopulateMailServer( MSG_Master *pMaster, BOOL bRoots = TRUE )
  503.     {
  504.         return CMailFolderHelper::PopulateMailServer( m_hWnd, pMaster, bRoots );
  505.     }
  506. };
  507.  
  508. /////////////////////////////////////////////////////////////////////////////
  509. // CMailFolderList
  510.  
  511. class CMailFolderList: public CListBox, public CMailFolderHelper {
  512.  
  513. protected:
  514.     virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
  515.     {
  516.         DoDrawItem( m_hWnd, lpDrawItemStruct );
  517.     }
  518.     virtual void MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
  519.     {
  520.         DoMeasureItem( m_hWnd, lpMeasureItemStruct );
  521.     }
  522.  
  523. public:
  524.     CMailFolderList(): CMailFolderHelper( LB_ADDSTRING, LB_SETITEMDATA, LB_RESETCONTENT ) {}
  525.  
  526.     virtual int Populate( MSG_Master *pMaster, MSG_FolderInfo *folderInfo )
  527.     {
  528.         return CMailFolderHelper::Populate( m_hWnd, pMaster, folderInfo );
  529.     }
  530. };
  531.  
  532. class CMailNewsFrame;
  533.  
  534. class IMailFrame: public IUnknown
  535. {
  536. public:
  537.     virtual CMailNewsFrame *GetMailNewsFrame() = 0;
  538.     virtual MSG_Pane *GetPane() = 0;
  539.     virtual void PaneChanged( MSG_Pane *pane, XP_Bool asynchronous, 
  540.                               MSG_PANE_CHANGED_NOTIFY_CODE, int32 value) = 0;
  541.     virtual void AttachmentCount(MSG_Pane *messagepane, void* closure,
  542.                                  int32 numattachments, XP_Bool finishedloading) = 0;
  543.     virtual void UserWantsToSeeAttachments(MSG_Pane *messagepane, void *closure) = 0;
  544. };
  545.  
  546. typedef IMailFrame *LPMAILFRAME;
  547.  
  548. #endif
  549.