home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / addrdlg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  15.2 KB  |  508 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. #ifndef _addrdlg_h_
  19. #define _addrdlg_h_
  20.  
  21. // ADDRDLG.H
  22. //
  23. // DESCRIPTION:
  24. //        This file contains the declarations of the for the address picker 
  25. //        dialog
  26. //
  27.  
  28. #include "outliner.h"
  29. #include "apimsg.h"
  30. #include "addrbook.h"
  31. #include "mailfrm.h"
  32. #include "mailpriv.h"
  33. #include "mnrccln.h"
  34.  
  35. class COutlinerView;
  36. class CAddrDialog;
  37. class CAddrDialogOutliner;
  38. class CAddrDialogOutlinerParent;
  39. class CAddrDialogDirOutliner;
  40. class CAddrDialogDirOutlinerParent;
  41. class CAddrDialogEntryList;
  42.  
  43. // Definitions for column headings in the outliner control
  44.  
  45. #define DEF_VISIBLE_COLUMNS            5
  46. #define ID_COLADDR_TYPE                1
  47. #define ID_COLADDR_NAME                2
  48. #define ID_COLADDR_EMAIL            3
  49. #define ID_COLADDR_COMPANY            4
  50. #define ID_COLADDR_PHONE            5
  51. #define ID_COLADDR_LOCALITY            6
  52. #define ID_COLADDR_NICKNAME            7
  53.  
  54. #define DEF_DIRVISIBLE_COLUMNS        2
  55. #define ID_COLDIR_TYPE                1
  56. #define ID_COLDIR_NAME                2
  57.  
  58. // array of indexes for IDB_ADDRESSBOOK bitmap
  59. #define IDX_ADDRESSBOOKPERSON   0
  60. #define IDX_ADDRESSBOOKLIST        1
  61. #define IDX_ADDRESSBOOKPERCARD  2
  62.  
  63. // array of indexes for IDB_DIRLIST bitmap
  64. #define IDX_DIRLDAPAB            0
  65. #define IDX_DIRPERSONALAB        1
  66.  
  67. class CAddressPickerDropTarget : public COleDropTarget
  68. {
  69. public:
  70.  
  71.     CAddrDialog* m_pOwner;
  72. //Construction
  73.     CAddressPickerDropTarget(CAddrDialog* pOwner) { m_pOwner = pOwner; }
  74.     BOOL        OnDrop(CWnd *, COleDataObject *, DROPEFFECT, CPoint);
  75.     DROPEFFECT  OnDragOver(CWnd *, COleDataObject *, DWORD, CPoint);
  76. };
  77.  
  78. // address book context
  79. class CAddrDialogCX: public CStubsCX
  80. {
  81. protected:
  82.     CAddrDialog* m_pDialog;
  83.  
  84.     int32 m_lPercent;
  85.     CString m_csProgress;
  86.     BOOL m_bAnimated;
  87.  
  88. public:
  89.     CAddrDialogCX(CAddrDialog *pDialog);
  90.     // void DestroyContext();
  91.  
  92. public:
  93.     int32 QueryProgressPercent();
  94.     void SetProgressBarPercent(MWContext *pContext, int32 lPercent);
  95.  
  96.     void Progress(MWContext *pContext, const char *pMessage);
  97.     void AllConnectionsComplete(MWContext *pContext);
  98.  
  99.     void UpdateStopState( MWContext *pContext );
  100.     
  101.     CWnd *GetDialogOwner() const;
  102. };
  103.  
  104.  
  105.  
  106. /****************************************************************************
  107. *
  108. *    Class: CAddrDialogOutlinerParent
  109. *
  110. *    DESCRIPTION:
  111. *        This class is the window around the column/list object in the address 
  112. *        book.  It is mainly purpose is to draw the column headings.
  113. *
  114. ****************************************************************************/
  115. class CAddrDialogOutlinerParent : public COutlinerParent 
  116. {
  117. public:
  118.     CAddrDialogOutlinerParent();
  119.     virtual ~CAddrDialogOutlinerParent();
  120.     virtual COutliner * GetOutliner ( );
  121.     virtual void CreateColumns ( );
  122.     virtual BOOL RenderData ( int idColumn, CRect & rect, CDC & dc, const char *);
  123.     virtual BOOL ColumnCommand ( int idColumn );
  124.  
  125. // Implementation
  126. protected:
  127.     // Generated message map functions
  128.     //{{AFX_MSG(CAddrDialogOutlinerParent)
  129.     afx_msg void OnLButtonUp ( UINT nFlags, CPoint point );
  130.     //}}AFX_MSG
  131.  
  132.     DECLARE_MESSAGE_MAP()
  133. };
  134.  
  135. /****************************************************************************
  136. *
  137. *    Class: CAddrDialogDirOutlinerParent
  138. *
  139. *    DESCRIPTION:
  140. *        This class is the window around the column directorylist 
  141. *        object in the address book.  It is mainly purpose is to draw 
  142. *        the column headings.
  143. *
  144. ****************************************************************************/
  145. class CAddrDialogDirOutlinerParent : public COutlinerParent 
  146. {
  147. public:
  148.     CAddrDialogDirOutlinerParent();
  149.     virtual ~CAddrDialogDirOutlinerParent();
  150.     virtual COutliner * GetOutliner ( );
  151.     virtual void CreateColumns ( );
  152.     virtual BOOL RenderData ( int idColumn, CRect & rect, CDC & dc, const char *);
  153.  
  154. // Implementation
  155. protected:
  156.     // Generated message map functions
  157.     //{{AFX_MSG(CAddrDialogDirOutlinerParent)
  158.     afx_msg void OnLButtonUp ( UINT nFlags, CPoint point );
  159.     //}}AFX_MSG
  160.  
  161.     DECLARE_MESSAGE_MAP()
  162. };
  163.  
  164.  
  165. /****************************************************************************
  166. *
  167. *    Class: CAddrDialogDirOutliner
  168. *
  169. *    DESCRIPTION:
  170. *        This class is the column/list object for the directory list
  171. *        in the address book
  172. *
  173. ****************************************************************************/
  174. class CAddrDialogDirOutliner : public CMSelectOutliner
  175. {
  176. friend class CAddrDialogDirOutlinerParent;
  177.  
  178. protected:
  179.     int                    m_lineindex;
  180.     char*                m_pszExtraText;
  181.     CLIPFORMAT            m_cfAddresses;
  182.     ABPane*                m_pane;
  183.     int                    m_iMysticPlane;
  184.     MWContext*            m_pContext;
  185.     int                    m_dirIndex;
  186.     DIR_Server*            m_pDirLine;
  187.     HFONT                m_hFont;
  188.  
  189. public:
  190.     CAddrDialogDirOutliner ( );
  191.     virtual ~CAddrDialogDirOutliner ( );
  192.  
  193.     void    UpdateCount();
  194.     void    OnChangeDirectory(int dirIndex);
  195.     void    SetDirectoryIndex (int dirIndex);
  196.     int        GetDirectoryIndex () { return m_dirIndex; }
  197.  
  198.     virtual void OnSelChanged();
  199.     virtual void SetTotalLines( int iLines );
  200.     virtual void OnSelDblClk();
  201.  
  202.     virtual HFONT GetLineFont( void *pLineData );
  203.     virtual LPCTSTR GetColumnText ( UINT iColumn, void * pLineData );
  204.     virtual void * AcquireLineData ( int iLine );
  205.     virtual void ReleaseLineData ( void * pLineData );
  206.     virtual void GetTreeInfo ( int iLine, uint32 * pFlags, int * iDepth, 
  207.                                OutlinerAncestorInfo ** pAncestor );
  208.     virtual int TranslateIcon ( void *);
  209.     virtual int TranslateIconFolder ( void *);
  210.     virtual BOOL ColumnCommand ( int iColumn, int iLine );
  211.  
  212.     void SetPane( ABPane *pane );
  213.     ABPane* GetPane() { return m_pane; }
  214.  
  215.     MWContext *GetContext() { return m_pContext; }
  216.     void SetContext( MWContext *pContext ) { m_pContext = pContext; }
  217.  
  218.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  219.                                      MSG_NOTIFY_CODE notify, 
  220.                                      MSG_ViewIndex where,
  221.                                      int32 num);
  222.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  223.                                       MSG_NOTIFY_CODE notify, 
  224.                                       MSG_ViewIndex where,
  225.                                       int32 num);
  226.  
  227.     virtual BOOL RenderData ( UINT iColumn, CRect & rect, CDC & pdc, const char * );
  228.  
  229. // Implementation
  230. protected:
  231.     // Generated message map functions
  232.     //{{AFX_MSG(CAddrDialogDirOutliner)
  233.     //}}AFX_MSG
  234.  
  235.     DECLARE_MESSAGE_MAP()
  236.  
  237.  
  238. };
  239.  
  240. /****************************************************************************
  241. *
  242. *    Class: CAddrDialog
  243. *
  244. *    DESCRIPTION:
  245. *        This class is the address picker from the compose window
  246. *
  247. ****************************************************************************/
  248. typedef BOOL (*MAPIAddressCallbackProc)(int totalCount, int currentIndex, 
  249.                                         int addrType, LPSTR addrString); // rhp - for MAPI
  250. typedef BOOL (*MAPIAddressGetAddrProc)(LPSTR *name, LPSTR *address, int *addrType);    // rhp - for MAPI
  251.  
  252. class CAddrDialog : public CDialog, public IMailFrame {
  253.  
  254. // Attributes
  255. public:
  256.  
  257.     friend class CAddrDialogEntryList;
  258.  
  259.     int            m_iWidth;
  260.     UINT        m_uTypedownClock;
  261.     CString        m_save;
  262.     int            m_savedir;
  263.     int            m_idefButtonID;
  264.  
  265.     enum { IDD = IDD_ADDRESSPICKER };
  266.  
  267.     // ClassWizard generated virtual function overrides
  268.     //{{AFX_VIRTUAL(CAddrDialog)
  269. public:
  270. protected:
  271.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  272.     //}}AFX_VIRTUAL
  273.  
  274.     //{{AFX_DATA(CAddrDialog)
  275.     CString    m_name;
  276.     int        m_directory;
  277.     //}}AFX_DATA
  278.  
  279. protected:
  280.  
  281.     CNetscapeStatusBar            m_barStatus;
  282.  
  283.     CMailNewsSplitter            *m_pSplitter;
  284.     CAddrDialogOutlinerParent    *m_pOutlinerParent;
  285.     CAddrDialogOutliner            *m_pOutliner;
  286.     CAddrDialogDirOutliner        *m_pDirOutliner;
  287.     CAddrDialogDirOutlinerParent    *m_pDirOutlinerParent;
  288.     CAddrDialogCX                *m_pCX;
  289.     HFONT                        m_pFont;
  290.  
  291.     LPMSGLIST            m_pIAddrList;
  292.     ABPane                *m_addrBookPane;
  293.     BOOL                m_bSearching;
  294.     CMailNewsResourceSwitcher m_MailNewsResourceSwitcher;
  295.  
  296.     CAddressPickerDropTarget *m_pDropTarget;
  297.  
  298.   // rhp - MAPI stuff...
  299.   BOOL                    m_isMAPI;
  300.   LPSTR                   m_mapiHeader;
  301.   MAPIAddressCallbackProc m_mapiCBProc; 
  302.   MAPIAddressGetAddrProc  m_mapiGetAddrProc;
  303.   void                    ProcessMAPIOnDone(void);
  304.   void                    ProcessMAPIAddressPopulation(void);
  305.  
  306.     // IUnknown Interface
  307.     STDMETHODIMP            QueryInterface(REFIID,LPVOID *);
  308.     STDMETHODIMP_(ULONG)    AddRef(void);
  309.     STDMETHODIMP_(ULONG)    Release(void);
  310.  
  311. // Support for IMsgList Interface (Called by CAddrDialogEntryList)
  312.     virtual void ListChangeStarting( MSG_Pane* pane, XP_Bool asynchronous,
  313.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  314.                                      int32 num);
  315.     virtual void ListChangeFinished( MSG_Pane* pane, XP_Bool asynchronous,
  316.                                      MSG_NOTIFY_CODE notify, MSG_ViewIndex where,
  317.                                      int32 num);
  318.  
  319.     CListBox * GetBucket() { return (CListBox*)GetDlgItem(IDC_ADDRESSBKT); }
  320.  
  321.     DIR_Server* GetCurrentDirectoryServer ();
  322.     void PerformDirectorySearch ();
  323.     void PerformChangeDirectory (int dirIndex);
  324.     void PerformTypedown (char* searchString);
  325.     void PerformListDirectory (char* searchString);
  326.     void UpdateDirectories();
  327.     void CleanupOnClose();
  328.     void GetFormattedString(char* fullname, MSG_HEADER_SET header, char** formatted);
  329.     void AddStringToBucket(CListBox *pBucket, MSG_HEADER_SET header, 
  330.                            char* fullname, ABID type, ABID entryID);
  331.  
  332. // Operations
  333. public:
  334.     CAddrDialog(CWnd* pParent = NULL, 
  335.     BOOL isMapi = FALSE, LPSTR winText = NULL, 
  336.     MAPIAddressCallbackProc mapiCB = NULL,
  337.     MAPIAddressGetAddrProc mapiGetProc = NULL); // rhp - MAPI
  338.  
  339.     void OnUpdateDirectorySelection (int dirIndex);
  340.     int GetDefaultButtonID () { return m_idefButtonID; }
  341.     void SetDefaultButtonID (int newDefault) { m_idefButtonID = newDefault; }
  342.     void MoveSelections(MSG_HEADER_SET header);
  343.     enum { ToolInvalid = -1, ToolText = 0, ToolPictures = 1, ToolBoth = 2 };
  344.  
  345.     // From CStubsCX
  346.     void Progress(const char *pMessage);
  347.     void SetProgressBarPercent(int32 lPercent);
  348.     void AllConnectionsComplete(MWContext *pContext);
  349.     void SetStatusText(const char* pMessage);
  350.     void DoUpdateWidget( int command, AB_CommandType cmd, BOOL bUseCheck );
  351.  
  352.     // Support for IMailFrame
  353.     virtual CMailNewsFrame *GetMailNewsFrame();
  354.     virtual MSG_Pane *GetPane();
  355.     virtual void PaneChanged( MSG_Pane *pane, XP_Bool asynchronous, 
  356.                               MSG_PANE_CHANGED_NOTIFY_CODE, int32 value);
  357.     virtual void AttachmentCount(MSG_Pane *messagepane, void* closure,
  358.                                  int32 numattachments, XP_Bool finishedloading) {};
  359.     virtual void UserWantsToSeeAttachments(MSG_Pane *messagepane, void *closure) {};
  360.  
  361.     // Callback from LDAP search
  362.     void SetSearchResults(MSG_ViewIndex index, int32 num);
  363.     XP_Bool IsSearching () { return m_bSearching; }
  364.  
  365.     static void HandleErrorReturn(int errorID);
  366.  
  367.     void Create();
  368.     void DoUpdateAddressBook( CCmdUI* pCmdUI, AB_CommandType cmd, BOOL bUseCheck = TRUE );
  369.  
  370.     //drop
  371.     BOOL IsDragInListBox(CPoint *pPoint);
  372.     BOOL ProcessVCardData(COleDataObject * pDataObject,CPoint &point);
  373.  
  374.     void UpdateMsgButtons();
  375.  
  376. // Overrides
  377.     // ClassWizard generated virtual function overrides
  378.     //{{AFX_VIRTUAL(CAddrDialog)
  379.     public:
  380.     virtual  BOOL OnInitDialog( );
  381.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  382.     protected:
  383.     //}}AFX_VIRTUAL
  384.  
  385. // Implementation
  386. protected:
  387.     // Generated message map functions
  388.     //{{AFX_MSG(CAddrDialog)
  389.     afx_msg void OnKeyDown ( UINT nChar, UINT nRepCnt, UINT nFlags );
  390.     afx_msg int OnCreate( LPCREATESTRUCT );
  391.     afx_msg void OnSize( UINT, int, int);
  392.     afx_msg void OnTimer( UINT );
  393.     afx_msg void OnSetFocusName();
  394.     afx_msg void OnSetFocusBucket();
  395.     afx_msg void OnChangeName();
  396.     afx_msg void OnChangeDirectory();
  397.     afx_msg void OnDirectorySearch();
  398.     afx_msg void OnStopSearch();
  399.     afx_msg void OnDone();
  400.     afx_msg void OnCancel();
  401.     afx_msg void OnComposeMsg(void);
  402.     afx_msg void OnComposeCCMsg(void);
  403.     afx_msg void OnComposeBCCMsg(void);
  404.     afx_msg void OnGetProperties(void);
  405.     afx_msg void OnRemove(void);
  406.     afx_msg    void OnSortType(void);
  407.     afx_msg    void OnSortName(void);
  408.     afx_msg    void OnSortNickName(void);
  409.     afx_msg    void OnSortEmailAddress(void);
  410.     afx_msg    void OnSortCompany(void);
  411.     afx_msg    void OnSortLocality(void);
  412.     afx_msg    void OnSortAscending(void);
  413.     afx_msg    void OnSortDescending(void);
  414.     afx_msg void OnSelchange();
  415.     afx_msg void OnHelp();
  416.     //}}AFX_MSG
  417.     DECLARE_MESSAGE_MAP()
  418. };
  419.  
  420.  
  421. /****************************************************************************
  422. *
  423. *    Class: CAddrDialogOutliner
  424. *
  425. *    DESCRIPTION:
  426. *        This class is the column/list object in the address book
  427. *
  428. ****************************************************************************/
  429. class CAddrDialogOutliner : public CMSelectOutliner
  430. {
  431. friend class CAddrDialogOutlinerParent;
  432.  
  433. protected:
  434.     int                    m_attribSortBy;
  435.     int                    m_lineindex;
  436.     char*                m_pszExtraText;
  437.     CLIPFORMAT            m_cfAddresses;
  438.     ABPane*                m_pane;
  439.     int                    m_iMysticPlane;
  440.     BOOL                m_bSortAscending;
  441.     MWContext*            m_pContext;
  442.     int                    m_dirIndex;
  443.     AB_EntryLine        m_EntryLine;
  444.     HFONT                m_hFont;
  445.     CString                m_psTypedown;
  446.     UINT                m_uTypedownClock;
  447.  
  448. public:
  449.     CAddrDialogOutliner ( );
  450.     virtual ~CAddrDialogOutliner ( );
  451.  
  452.     void    UpdateCount();
  453.     void    OnTypedown (char* name);
  454.     void    OnChangeDirectory(int dirIndex);
  455.     int        GetSortBy() { return m_attribSortBy; }
  456.     void    SetDirectoryIndex (int dirIndex);
  457.     int        GetDirectoryIndex () { return m_dirIndex; }
  458.     BOOL    GetSortAscending() { return m_bSortAscending; }
  459.     DIR_Server* GetCurrentDirectoryServer ();
  460.  
  461.     virtual void OnSelChanged();
  462.     virtual void SetTotalLines( int iLines );
  463.     virtual void OnSelDblClk();
  464.  
  465.     virtual HFONT GetLineFont( void *pLineData );
  466.     virtual LPCTSTR GetColumnText ( UINT iColumn, void * pLineData );
  467.     virtual void * AcquireLineData ( int iLine );
  468.     virtual void ReleaseLineData ( void * pLineData );
  469.     virtual void GetTreeInfo ( int iLine, uint32 * pFlags, int * iDepth, 
  470.                                OutlinerAncestorInfo ** pAncestor );
  471.     virtual int TranslateIcon ( void *);
  472.     virtual int TranslateIconFolder ( void *);
  473.  
  474.     void SetPane( ABPane *pane );
  475.     ABPane* GetPane() { return m_pane; }
  476.  
  477.     MWContext *GetContext() { return m_pContext; }
  478.     void SetContext( MWContext *pContext ) { m_pContext = pContext; }
  479.  
  480.     virtual void MysticStuffStarting( XP_Bool asynchronous,
  481.                                      MSG_NOTIFY_CODE notify, 
  482.                                      MSG_ViewIndex where,
  483.                                      int32 num);
  484.     virtual void MysticStuffFinishing( XP_Bool asynchronous,
  485.                                       MSG_NOTIFY_CODE notify, 
  486.                                       MSG_ViewIndex where,
  487.                                       int32 num);
  488.  
  489.     virtual BOOL RenderData ( UINT iColumn, CRect & rect, CDC & pdc, const char * );
  490.  
  491.     virtual BOOL ColumnCommand ( int iColumn, int iLine );
  492.  
  493. // Implementation
  494. protected:
  495.     // Generated message map functions
  496.     //{{AFX_MSG(CAddrDialogOutliner)
  497.     afx_msg void OnTimer( UINT );
  498.     afx_msg void OnKeyDown ( UINT nChar, UINT nRepCnt, UINT nFlags );
  499.     afx_msg void OnKillFocus( CWnd* pNewWnd );
  500.     //}}AFX_MSG
  501.  
  502.     DECLARE_MESSAGE_MAP()
  503.  
  504.  
  505. };
  506.  
  507. #endif
  508.