home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / mapi / win16 / dev / smh / _smh.h < prev    next >
Encoding:
Text File  |  1995-07-11  |  13.9 KB  |  428 lines

  1. /*
  2.  *  _ S M H . H
  3.  *
  4.  *  Sample mail handling hook
  5.  *  Copyright 1992-95 Microsoft Corporation.  All Rights Reserved.
  6.  */
  7.  
  8. /*
  9.  *  Object Vtable definition and declairation
  10.  */
  11. #undef  INTERFACE
  12. #define INTERFACE struct _SMH
  13. #undef  MAPIMETHOD_
  14. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, SMH_)
  15.         MAPI_IUNKNOWN_METHODS (IMPL)
  16.         MAPI_ISPOOLERHOOK_METHODS (IMPL)
  17. #undef  MAPIMETHOD_
  18. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, SMH_)
  19.         MAPI_IUNKNOWN_METHODS (IMPL)
  20.         MAPI_ISPOOLERHOOK_METHODS (IMPL)
  21. #undef  MAPIMETHOD_
  22. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  23. DECLARE_MAPI_INTERFACE (SMH_)
  24. {
  25.     MAPI_IUNKNOWN_METHODS (IMPL)
  26.     MAPI_ISPOOLERHOOK_METHODS (IMPL)
  27. };
  28.  
  29. /*
  30.  *  Misc. Defines
  31.  *
  32.  *  GROW_SIZE is the incremental amount to grow buffers that hold arrays
  33.  *  of structures.  This is used to reduce the number of allocations in
  34.  *  certain situations (ie. configuration)
  35.  */
  36. #define GROW_SIZE   4
  37.  
  38. /*
  39.  *  cStoMax is the maximum number of stores per profile supported by SMH.
  40.  *  This limit is purely an imposed limit and can be increased or
  41.  *  decreased with no other changes required.
  42.  */
  43. #define cStoMax     64
  44.  
  45. /*
  46.  *  cchRuleMax is used to limit the names and values of filters.
  47.  */
  48. #define cchRuleMax  79
  49.  
  50.  
  51. /*
  52.  *  Store table structure definitions
  53.  *
  54.  *  STOENTRY
  55.  *      This structure is used as a part of the STOTABLE structure.
  56.  *      The union component to the structure allows SMH to cast an
  57.  *      LPSPropValue pointer to a LPSTOENTRY where the first property
  58.  *      is dropped in favor of storing an LPMDB.
  59.  *
  60.  *  STO
  61.  *      This stucture is defined such that SMH can cast an SRow pointer
  62.  *      to an LPSTO.  Again, this construct is used extensively by the
  63.  *      STOTABLE implementation.
  64.  *
  65.  *  STOTABLE
  66.  *      This stucture can be mapped to an SRowSet.  The store table
  67.  *      implementation uses this to let MAPI allocate the memory needed
  68.  *      for keeping pointers to open stores.
  69.  */
  70. typedef struct _STOENTRY
  71. {
  72.     union
  73.     {
  74.         LPMDB           lpmdb;
  75.         SPropValue      valPad;
  76.     };
  77.     SPropValue          lpProps[];
  78.  
  79. } STOENTRY, FAR * LPSTOENTRY;
  80.  
  81. typedef struct _STO
  82. {
  83.     ULONG               ulReserved;
  84.     ULONG               cValues;
  85.     union
  86.     {
  87.         LPSTOENTRY      lpstoe;
  88.         LPSPropValue    lpProps;
  89.     };
  90.  
  91. } STO, FAR * LPSTO;
  92.  
  93. typedef struct _STOTABLE
  94. {
  95.     ULONG               cSto;
  96.     STO                 aSto[cStoMax];
  97.  
  98. } STOTABLE, FAR * LPSTOTABLE;
  99.  
  100.  
  101. /*
  102.  *  Archive bucket structures definitions
  103.  *
  104.  *  DFT
  105.  *      The DFT structure contains two FILETIMEs that define the delta of
  106.  *      time supported by the archive folder.
  107.  *
  108.  *  BKIT
  109.  *      The BKIT structure contains all the information required to
  110.  *      process the archival of a message into that bucket.
  111.  *
  112.  *      The EntryID of the parent folder, the year folder, and the
  113.  *      monthly folder are all cashed as is the MAPIFOLDER object.  The
  114.  *      DFT for the year and month are cached as well.
  115.  */
  116. typedef struct _DFT
  117. {
  118.     FILETIME            ftStart;
  119.     FILETIME            ftEnd;
  120.  
  121. } DFT, FAR * LPDFT;
  122.  
  123. typedef struct _BKIT
  124. {
  125.     ULONG               cbeid;
  126.     LPENTRYID           lpeid;
  127.     LPMAPIFOLDER        lpfldr;
  128.     DFT                 dft;
  129.  
  130.     ULONG               cbeidYr;
  131.     LPENTRYID           lpeidYr;
  132.     LPMAPIFOLDER        lpfldrYr;
  133.     DFT                 dftYr;
  134.  
  135.     ULONG               cbeidParent;
  136.     LPENTRYID           lpeidParent;
  137.     LPMAPIFOLDER        lpfldrParent;
  138.  
  139. } BKIT, FAR * LPBKIT;
  140.  
  141.  
  142. /*
  143.  *  SMH stucture definitions
  144.  *  
  145.  *  WB
  146.  *      The WB (wastebasket) structure contains the information
  147.  *      required to archive deleted mail on any given message store
  148.  *  
  149.  *  RULE
  150.  *      The RULE structure contains the information required to filter an
  151.  *      inbound message into the desired target folder
  152.  *  
  153.  *  OOF
  154.  *      The OOF structure contains the information required to generate
  155.  *      out-of-office responses to incoming messages
  156.  *  
  157.  *  SMH
  158.  *      The SMH object is supports the ISpoolerHook interface and is the
  159.  *      object handed to mapi to facilitate all message filtering.
  160.  *  
  161.  */
  162. typedef struct _WB
  163. {
  164.     struct _WB FAR *    wbNext;         /* next pointer */
  165.     struct _SMH FAR *   lpsmh;          /* owning SMH object */
  166.  
  167.     LPMDB               lpmdb;          /* MDB on which this WB applies */
  168.     LPMAPITABLE         lptbl;          /* contents table of the wastebasket */
  169.     LPMAPIFOLDER        lpfldr;         /* folder object of the wastebasket */
  170.     LPSPropValue        lpvalEid;       /* entryid of the wastebasket */
  171.     ULONG               ulAdvz;         /* connection ID returned from Advise() */
  172.     BKIT                bkit;           /* bucket cache for this WB */
  173.  
  174. } WB, FAR * LPWB;
  175.  
  176. typedef struct _RULE
  177. {
  178.     struct _RULE FAR *  rlNext;         /* next pointer */
  179.  
  180.     MAPIUID             muid;           /* profile section UID */
  181.     UINT                rlTyp;          /* rule type */
  182.     ULONG               ulFlags;        /* rule attributes */
  183.     SRestriction FAR *  lpres;          /* recipient rule restriction */
  184.     TCHAR               lpszData[cchRuleMax];   /* value to filter against */
  185.     TCHAR               lpszSound[cchRuleMax];  /* sound to play */
  186.     LPMDB               lpmdb;          /* MDB owning the target folder */
  187.     LPMAPIFOLDER        lpfldr;         /* target folder for filter */
  188.     LPSPropValue        lpvalEid;       /* entryid of target folder */
  189.     BKIT                bkit;           /* bucket cache for rule */
  190.  
  191. } RULE, FAR * LPRULE;
  192.  
  193. typedef struct _OOF
  194. {
  195.     HINSTANCE           hlib;           /* library handle */
  196.     LPTABLEDATA         lptad;          /* Table data object */
  197.     LPMAPITABLE         lptbl;          /* Table data view */
  198.     ULONG               cRecips;        /* Count of recips */
  199.  
  200. } OOF, FAR * LPOOF;
  201.  
  202. typedef struct _SMH
  203. {
  204.     SMH_Vtbl FAR *      lpVtbl;
  205.     ULONG               lcInit;         /* object refcount */
  206.     HANDLE              hevtConfig;     /* configuration change event */
  207.     HINSTANCE           hinst;          /* DLL instance */
  208.  
  209.     LPMAPISESSION       lpsess;         /* client session */
  210.     LPALLOCATEBUFFER    lpfnAlloc;      /* MAPIAllocateBuffer */
  211.     LPALLOCATEMORE      lpfnAllocMore;  /* MAPIAllocateMore */
  212.     LPFREEBUFFER        lpfnFree;       /* MAPIFreeBuffer */
  213.     MAPIUID             muid;           /* hook provider section UID */
  214.  
  215.     BOOL                fCatSm:1;       /* options flags */
  216.     BOOL                fCatSmByYr:1;
  217.     BOOL                fCatWb:1;
  218.     LPSTOTABLE          lpstotbl;       /* store table */
  219.     SPropValue          valEx;          /* msg class exclustions */
  220.     LPWB                lstWb;          /* list pointer of WBs */
  221.     LPRULE              lstRl;          /* list pointer of rules */
  222.     BKIT                bkitSm;         /* bucket cache for sent mail */
  223.     OOF                 oof;            /* OOF information */
  224.  
  225. } SMH, FAR * LPSMH;
  226.  
  227.  
  228. /*
  229.  *  Configuration dialog structure definition
  230.  *
  231.  *  SMHDLG
  232.  *      This structure is used to pass important information in and out
  233.  *      of the configuration dialogs and property sheets.
  234.  */
  235. typedef struct _SMHDLG
  236. {
  237.     HINSTANCE           hinst;          /* DLL instance */
  238.     HWND                hwnd;           /* parent window */
  239.  
  240.     LPALLOCATEBUFFER    lpfnAlloc;      /* MAPIAllocateBuffer */
  241.     LPALLOCATEMORE      lpfnAllocMore;  /* MAPIAllocateMore */
  242.     LPFREEBUFFER        lpfnFree;       /* MAPIFreeBuffer */
  243.     LPMALLOC            lpmalloc;       /* pointer to LPMALLOC obj */
  244.     LPMAPISUP           lpsup;          /* pointer to support obj */
  245.     LPPROVIDERADMIN     lpadmin;        /* pointer to profile admin obj */
  246.  
  247.     LPSPropTagArray     lpspt;          /* proptag array of config props */
  248.     LPSPropValue        lpvalSMH;       /* config prop values */
  249.     LPPROFSECT          lpsec;          /* profile section obj */
  250.  
  251.     ULONG               ulFlags;        /* configuration flags */
  252.     SCODE               sc;             /* dialog failure error code */
  253.  
  254.     LPSPropValue        lpval;          /* short-term propval buffer */
  255.     TCHAR               rgchT[cchRuleMax + 1];  /* stort-term name buffer */
  256.  
  257.     BOOL                fDirty;         /* configuration changed flag */
  258.  
  259.     UINT                cmuid;          /* rule UID list count */
  260.     UINT                cmuidMax;       /* rule UID list max */
  261.     LPMAPIUID           lpmuid;         /* rule UID list */
  262.  
  263. } SMHDLG, FAR * LPSMHDLG;
  264.  
  265.  
  266. /*
  267.  *  SMH proptags
  268.  */
  269. #define PR_SMH_FLAGS                    PROP_TAG(PT_LONG,       0x6600)
  270. #define PR_SMH_RULES                    PROP_TAG(PT_BINARY,     0x6601)
  271. #define PR_SMH_EXCLUSIONS               PROP_TAG(PT_MV_TSTRING, 0x6602)
  272.  
  273. /*
  274.  *  Values for PR_SMH_FLAGS
  275.  */
  276. #define SMH_FILTER_SENTMAIL             ((ULONG)0x00000001)
  277. #define SMH_FILTER_SENTMAIL_YR          ((ULONG)0x00000002)
  278. #define SMH_FILTER_DELETED              ((ULONG)0x00000010)
  279. #define SMH_FILTER_DELETED_YR           ((ULONG)0x00000020)
  280. #define SMH_FILTER_INBOUND              ((ULONG)0x00000100)
  281. #define SMH_UNREAD_VIEWER               ((ULONG)0x00001000)
  282.  
  283. /*
  284.  *  RULE proptags
  285.  */
  286. #define PR_RULE_TYPE                    PROP_TAG(PT_LONG,       0x6610)
  287. #define PR_RULE_DATA                    PROP_TAG(PT_BINARY,     0x6611)
  288. #define PR_RULE_FLAGS                   PROP_TAG(PT_LONG,       0x6612)
  289. #define PR_RULE_TARGET_ENTRYID          PROP_TAG(PT_BINARY,     0x6613)
  290. #define PR_RULE_TARGET_PATH             PROP_TAG(PT_TSTRING,    0x6614)
  291. #define PR_RULE_TARGET_PATH_A           PROP_TAG(PT_STRING8,    0x6614)
  292. #define PR_RULE_TARGET_PATH_W           PROP_TAG(PT_UNICODE,    0x6614)
  293. #define PR_RULE_STORE_ENTRYID           PROP_TAG(PT_BINARY,     0x6615)
  294. #define PR_RULE_STORE_DISPLAY_NAME      PROP_TAG(PT_TSTRING,    0x6616)
  295. #define PR_RULE_STORE_DISPLAY_NAME_A    PROP_TAG(PT_STRING8,    0x6616)
  296. #define PR_RULE_STORE_DISPLAY_NAME_W    PROP_TAG(PT_UNICODE,    0x6616)
  297. #define PR_RULE_SOUND_FILENAME          PROP_TAG(PT_TSTRING,    0x6617)
  298. #define PR_RULE_SOUND_FILENAME_A        PROP_TAG(PT_STRING8,    0x6617)
  299. #define PR_RULE_SOUND_FILENAME_W        PROP_TAG(PT_UNICODE,    0x6617)
  300.  
  301.  
  302. /*
  303.  *  Values for PR_RULE_TYPE
  304.  */
  305. #define RL_SUBJECT                      ((UINT)0x0001)
  306. #define RL_FROM                         ((UINT)0x0002)
  307. #define RL_ATTACH                       ((UINT)0x0004)
  308. #define RL_BODY                         ((UINT)0x0008)
  309. #define RL_TO                           ((UINT)0x0010)
  310. #define RL_CC                           ((UINT)0x0020)
  311. #define RL_BCC                          ((UINT)0x0040)
  312. #define RL_RECIP                        ((UINT)0x0080)
  313. #define RL_CLASS                        ((UINT)0x0100)
  314.  
  315. /*
  316.  *  Values for PR_RULE_FLAGS
  317.  */
  318. #define RULE_ARCHIVED                   ((ULONG)0x00000001)
  319. #define RULE_ARCHIVED_BY_YEAR           ((ULONG)0x00000002)
  320. #define RULE_NOT                        ((ULONG)0x00000004)
  321. #define RULE_DELETE                     ((ULONG)0x00000008)
  322. #define RULE_TERMINAL                   ((ULONG)0x80000000)
  323.  
  324. /*
  325.  *  Rule configuration flags
  326.  */
  327. #define NEW_RULE                        ((UINT)1)
  328. #define EDIT_RULE                       ((UINT)2)
  329.  
  330. /* Logon properties */
  331.  
  332. enum {ipSMHFlags, ipRules, ipExc, cpMax};
  333.  
  334. /* Rule properties */
  335.  
  336. enum {ipDisp, ipType, ipData, ipRLFlags, ipEID, ipPath, ipSEID, ipStore, ipSound, cpRLMax};
  337.  
  338. /* Message properties */
  339.  
  340. enum {ipMsgFlgs, ipSubj, ipSentRep, ipSentRepEA, cpMsgPrps};
  341.  
  342. /* Recipient restriction enums */
  343.  
  344. enum {ivRecip, ivEmail, ivDispNm, cvMax };
  345. enum {iresAnd, iresRecip, iresOr, iresEmail, iresDispNm, cresMax };
  346.  
  347.  
  348. /*
  349.  *  Logon properties required flags
  350.  */
  351. #define REQ_PR_SMH_FLAGS                ((ULONG)(1<<ipSMHFlags))
  352. #define REQ_PR_SMH_RULES                ((ULONG)(1<<ipRules))
  353. #define REQ_PROPS                       REQ_PR_SMH_FLAGS
  354. ULONG UlChkReqProps (ULONG cval, LPSPropValue lpval);
  355.  
  356.  
  357. /*
  358.  *  Configuration dialogs
  359.  */
  360. #if !defined (_WIN95)
  361. #define RegDlg3D(_inst)         Ctl3dRegister (_inst);
  362. #define MakeDlg3D(_dlg)         Ctl3dSubclassDlgEx(_dlg, CTL3D_ALL)
  363. #define UnregDlg3D(_inst)       Ctl3dUnregister (_inst);
  364. #else
  365. #define RegDlg3D(_inst)
  366. #define MakeDlg3D(_dlg)
  367. #define UnregDlg3D(_inst)
  368. #endif
  369.  
  370. #define FHandleWm(_fn,_dlg,_wm,_wp,_lp) HANDLE_WM_##_wm(_dlg,_wp,_lp,_fn##_##_wm)
  371. HRESULT HrDisplayPropSheets (HINSTANCE hinst, HWND hwnd, LPSMHDLG lpsmhdlg);
  372.  
  373.  
  374. /*
  375.  *  Configuration Events
  376.  */
  377. #ifdef  WIN32
  378. HRESULT HrGetConfigEvent (HANDLE FAR *);
  379. VOID SignalConfigChanged (VOID);
  380. BOOL FConfigChanged (HANDLE);
  381. #define ResetConfigEvent(_hevt)     ResetEvent(_hevt)
  382. #define CloseConfigEvent(_hevt)     CloseHandle(_hevt)
  383. #else
  384. #define HrGetConfigEvent(_lphevt)   (hrSuccess)
  385. #define SignalConfigChanged()
  386. #define FConfigChanged(_hevt)       (FALSE)
  387. #define ResetConfigEvent(_hevt)
  388. #define CloseConfigEvent(_hevt)
  389. #endif
  390.  
  391.  
  392. /*
  393.  *  Stores table
  394.  */
  395. HRESULT HrInitStoresTable (LPSMH, LPMAPISESSION);
  396. HRESULT HrOpenMdbFromEid (LPSMH, ULONG, LPENTRYID, LPMDB FAR *);
  397. HRESULT HrOpenMdbFromName (LPSMH, LPTSTR, LPMDB FAR *);
  398. HRESULT HrOpenStoEntry (LPMAPISESSION, LPSTO, LPMDB FAR *);
  399. VOID ReleaseStoresTable (LPSMH);
  400.  
  401.  
  402. /*
  403.  *  WM_NOTIFY #defines (taken from WINUSER.H)
  404.  */
  405. #ifdef  WIN16
  406. typedef struct tagNMHDR
  407. {
  408.     HWND  hwndFrom;
  409.     UINT  idFrom;
  410.     UINT  code;
  411. }   NMHDR;
  412. typedef NMHDR FAR * LPNMHDR;
  413. #define WM_NOTIFY   0x004E
  414. #define HANDLE_WM_NOTIFY(hwnd,wParam,lParam,fn) (fn)((hwnd),(int)(wParam),(NMHDR FAR*)(lParam))
  415.  
  416. /*
  417.  *  Mapped bitmapi #defines (taken from COMMCTRL.H)
  418.  */
  419. typedef struct
  420. {
  421.     COLORREF from;
  422.     COLORREF to;
  423. } COLORMAP, FAR * LPCOLORMAP;
  424.  
  425. HBITMAP WINAPI CreateMappedBitmap(HINSTANCE hInstance, INT idBitmap, BOOL bDiscardable,
  426.     LPCOLORMAP lpColorMap, INT iNumMaps);
  427. #endif  /* WIN16 */
  428.