home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / docfile.ms / msp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  27.7 KB  |  841 lines

  1. /*
  2.  *  M S P . H
  3.  *
  4.  *  Definitions for the MAPI Sample Message Store Provider.
  5.  *
  6.  *  Copyright 1992-1995 Microsoft Corporation.  All Rights Reserved.
  7.  */
  8.  
  9. #ifdef _WIN32
  10. #define _INC_OLE
  11. #define INC_OLE2 /* Get the OLE2 stuff */
  12. #define INC_RPC  /* harmless on NT 3.5; Win95 needs it */
  13. #endif
  14.  
  15. #include <windows.h>
  16. #include <ole2.h>
  17.  
  18. #include <mapispi.h>
  19. #include <mapidbg.h>
  20. #include <mapiwin.h>
  21. #include <mapiutil.h>
  22. #include <mapival.h>
  23. #include <smpms.h>
  24.  
  25. #include <mapidefs.h>
  26. #include <mapicode.h>
  27. #include <mapitags.h>
  28. #include <mapiguid.h>
  29.  
  30. #include <imessage.h>
  31.  
  32. #include <limits.h>
  33. #include <memory.h>
  34.  
  35. #if defined(_WIN32)
  36. #define OLE_CHAR WCHAR
  37. #else
  38. #define OLE_CHAR char
  39. #endif
  40.  
  41. #define VALIDATE
  42.  
  43. #ifdef VALIDATE
  44. #define OBJ_ValidateParameters(pobj, intf, method, cbObj, _lpVtbl, arglist) \
  45.     {                                                                       \
  46.         Validate##_##intf##_##method arglist;                               \
  47.         if (IsBadWritePtr(pobj, cbObj) || (pobj)->lpVtbl != _lpVtbl)        \
  48.             return(ResultFromScode(MAPI_E_INVALID_PARAMETER)); }
  49.  
  50. #define OBJ_CheckParameters(pobj, intf, method, cbObj, _lpVtbl, arglist)    \
  51.     {                                                                       \
  52.         CheckParameters##_##intf##_##method arglist;                        \
  53.         AssertSz(!IsBadWritePtr(pobj, cbObj) && (pobj)->lpVtbl == _lpVtbl,  \
  54.             "Bad object pointer"); }
  55. #else
  56. #define OBJ_ValidateParameters(pobj, intf, method, cbObj, _lpVtbl, arglist)
  57. #define OBJ_CheckParameters(pobj, intf, method, cbObj, _lpVtbl, arglist)
  58. #endif /* VALIDATE */
  59.  
  60. typedef LPVOID *PPV;
  61.  
  62. #define NUM_RETRIES 6           /* number of times to retry opening a file */
  63.  
  64. /* Per-instance data. */
  65. typedef struct
  66. {
  67.     UINT        cRef;
  68.     LPMALLOC    lpmalloc;
  69. } INST, *PINST;
  70.  
  71. /* Linked Memory Routines */
  72. typedef struct _lmr
  73. {
  74.     LPALLOCATEBUFFER    lpAllocBuf;
  75.     LPALLOCATEMORE      lpAllocMore;
  76.     LPFREEBUFFER        lpFreeBuf;
  77. }   LMR, *PLMR;
  78.  
  79. #define         LMAlloc(plmr, lcb, ppv)             ((plmr)->lpAllocBuf(lcb, ppv))
  80. #define         LMAllocMore(plmr, lcb, pvLink, ppv) ((plmr)->lpAllocMore(lcb, pvLink, ppv))
  81. #define         LMFree(plmr, pv)                    ((plmr)->lpFreeBuf(pv))
  82.  
  83. #define IsBadIfacePtr(param, iface)                 \
  84.             (IsBadReadPtr((param), sizeof(iface))   \
  85.         ||  IsBadReadPtr((param)->lpVtbl, sizeof(iface##Vtbl)))
  86.  
  87. #define SMPMS_VERSION   (0x03)  /* For MAPI 1.0 */
  88.  
  89. typedef struct _EID             /* Sample Message Store EntryID */
  90. {
  91.     BYTE abFlags[4];
  92.     MAPIUID uidResource;
  93.     BYTE bVersion;
  94.     BYTE bVerPad[3];
  95.     TCHAR szPath[1];
  96. } EID, *PEID;
  97.  
  98. #define CbNewEID(_cbPath) \
  99.     (offsetof(EID,szPath) + (_cbPath)*sizeof(CHAR))
  100.  
  101. /* This includes the NULL terminator */
  102. #define CbEID(_peid) \
  103.     (offsetof(EID,szPath) + \
  104.     (((UINT)(lstrlen((_peid)->szPath)))*sizeof(CHAR)) + sizeof(CHAR))
  105.  
  106. /* This includes the NULL */
  107. #define CbEIDPath(peid) (CbEID(peid)-CbNewEID(0))
  108.  
  109. #define PR_FILENAME_SEQUENCE_NUMBER PROP_TAG(PT_LONG,       0x6600)
  110. #define PR_SMS_CONTENTS_SORT_ORDER  PROP_TAG(PT_MV_LONG,    0x6601)
  111.  
  112. #if defined(_WIN32)
  113. #define CRITICAL_SECTION_MEMBERS    CRITICAL_SECTION cs;
  114. #define CRITICAL_SECTION_MEMBERS_P  CRITICAL_SECTION *pcs;
  115. #else
  116. #define CRITICAL_SECTION_MEMBERS
  117. #define CRITICAL_SECTION_MEMBERS_P
  118. #endif
  119.  
  120. /* Object typedefs ------------------------------------------------------- */
  121.  
  122. typedef struct _OBJ     OBJ,        * POBJ,     ** PPOBJ;
  123. typedef struct _MSP     MSP,        * PMSP,     ** PPMSP;
  124. typedef struct _MSL     MSL,        * PMSL,     ** PPMSL;
  125. typedef struct _IMS     IMS,        * PIMS,     ** PPIMS;
  126. typedef struct _IFLD    IFLD,       * PIFLD,    ** PPIFLD;
  127. typedef struct _IMSG    IMSG,       * PIMSG,    ** PPIMSG;
  128. typedef struct _IATCH   IATCH,      * PIATCH,   ** PPIATCH;
  129. typedef struct _STM     STM,        * PSTM,     ** PPSTM;
  130. typedef struct _STG     STG,        * PSTG,     ** PPSTG;
  131.  
  132. /* Standard Object --------------------------------------------------------- */
  133.  
  134. #undef  INTERFACE
  135. #define INTERFACE struct _OBJ
  136.  
  137. #undef  MAPIMETHOD_
  138. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, OBJ_)
  139.         MAPI_IUNKNOWN_METHODS(IMPL)
  140. #undef  MAPIMETHOD_
  141. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  142.  
  143. DECLARE_MAPI_INTERFACE(OBJ_)
  144. {
  145.     MAPI_IUNKNOWN_METHODS(IMPL)
  146. };
  147.  
  148. #define STANDARD_OBJECT_MEMBERS     \
  149.     LONG                cRef;       \
  150.     WORD                wType;      \
  151.     WORD                wFlags;     \
  152.     POBJ                pobjParent; \
  153.     POBJ                pobjNext;   \
  154.     POBJ                pobjHead;   \
  155.     PIMS                pims;       \
  156.     CRITICAL_SECTION_MEMBERS_P      \
  157.  
  158. /* NOTE: If you modify this enumeration, you must also update various */
  159. /* structures in mspobj.c which use the type as an index into lookup tables */
  160. enum {
  161.     OT_MSPROVIDER,
  162.     OT_MSLOGON,
  163.     OT_MSGSTORE,
  164.     OT_FOLDER,
  165.     OT_MESSAGE,
  166.     OT_ATTACH,
  167.     OT_STREAM,
  168.     OT_TABLE,
  169.     OT_MAX
  170. };
  171.  
  172. #define OBJF_MODIFY     ((WORD)0x0001)
  173.  
  174. struct _OBJ
  175. {
  176.     OBJ_Vtbl *      lpVtbl;
  177.     STANDARD_OBJECT_MEMBERS
  178. };
  179.  
  180. typedef void (*LPFNNEUTER)(POBJ);
  181. extern LPFNNEUTER rgfnNeuter[];
  182.  
  183. #define OBJ_SetFlag(pobj, f)    ((pobj)->wFlags |=  (f))
  184. #define OBJ_ClearFlag(pobj, f)  ((pobj)->wFlags &= ~(f))
  185. #define OBJ_TestFlag(pobj, f)   ((pobj)->wFlags &   (f))
  186.  
  187. #ifdef _WIN32
  188. #define OBJ_Initialize(pobj, _vtbl, _wType, _pims, _pcs)    \
  189.     (pobj)->lpVtbl      = _vtbl;    \
  190.     (pobj)->cRef        = 1;        \
  191.     (pobj)->wType       = _wType;   \
  192.     (pobj)->pims        = _pims;    \
  193.     (pobj)->pcs         = _pcs;
  194. #else
  195. #define OBJ_Initialize(pobj, _vtbl, _wType, _pims, _pcs)    \
  196.     (pobj)->lpVtbl      = _vtbl;    \
  197.     (pobj)->cRef        = 1;        \
  198.     (pobj)->wType       = _wType;   \
  199.     (pobj)->pims        = _pims;
  200. #endif
  201.  
  202. #define OBJ_EnterCriticalSection(pobj)  EnterCriticalSection((pobj)->pcs)
  203. #define OBJ_LeaveCriticalSection(pobj)  LeaveCriticalSection((pobj)->pcs)
  204. #define MSP_EnterCriticalSection(pmsp)  OBJ_EnterCriticalSection((POBJ)pmsp)
  205. #define MSP_LeaveCriticalSection(pmsp)  OBJ_LeaveCriticalSection((POBJ)pmsp)
  206. #define IMS_EnterCriticalSection(pims)  OBJ_EnterCriticalSection((POBJ)pims)
  207. #define IMS_LeaveCriticalSection(pims)  OBJ_LeaveCriticalSection((POBJ)pims)
  208.  
  209. /*
  210.  *  MSPOBJ.C
  211.  */
  212.  
  213. BOOL    FQueryInterface(int wType, REFIID riid);
  214.  
  215. void    OBJ_Enqueue(POBJ pobj, POBJ pobjParent);
  216. void    OBJ_Dequeue(POBJ pobj);
  217. void    OBJ_Destroy(POBJ pobj);
  218.  
  219. extern CHAR szFolderTemplate[];         /*  "*.fld"         */
  220. extern CHAR szMessageTemplate[];        /*  "*.msg"         */
  221. extern CHAR szPropertyFileName[];       /*  "folder.prp"    */
  222. extern CHAR szHierarchyFileName[];      /*  "hierarch.tbl"  */
  223. extern CHAR szContentsFileName[];       /*  "contents.tbl"  */
  224. extern CHAR szOutgoingFileName[];       /*  "outgoing.tbl"  */
  225.  
  226. /*
  227.  *  MSPRFS.C
  228.  */
  229.  
  230. /* Manifest constants */
  231.  
  232. #define RFS_CREATE      ((ULONG) 0x00000001)
  233.  
  234. /* Typedefs */
  235.  
  236. typedef struct _RFS         /* Receive Folder Storage */
  237. {
  238.     LPTSTR szFile;          /* Name of docfile containing RecFldr settings */
  239. } RFS, * PRFS;
  240.  
  241. typedef struct _RFN         /* A single RFS Node */
  242. {
  243.     LPTSTR szClass;         /* Name of the message class */
  244.     LPTSTR szName;          /* Relative path name of receive folder, i.e. */
  245.                             /* EntryID minus the GUID                     */
  246. } RFN, * PRFN;
  247.  
  248. /* Exported functions */
  249.  
  250. BOOL FIsValidMessageClass(LPTSTR szMessageClass);
  251. HRESULT OpenRFS (LPTSTR szStoreRoot, LPTSTR szFile, ULONG ulFlags,
  252.     PRFS * lpprfs);
  253. HRESULT GetRFN (PRFS prfs, LPTSTR szClassName, PRFN * pprfn);
  254. VOID    FreeRFN (PRFN prfn);
  255. HRESULT DeleteRFN (PRFS prfs, LPTSTR szClassName);
  256. HRESULT AddRFN (PRFS, PRFN prfn);
  257. HRESULT CloseRFS (PRFS prfs);
  258.  
  259. /*
  260.  *  MSPMS.C
  261.  */
  262.  
  263. /* Manifest constants */
  264.  
  265. #define IMS_CREATE      ((WORD) 0x0002)
  266. #define IMS_INVALID     ((WORD) 0x0004)
  267.  
  268. /* Typedefs */
  269.  
  270. #undef  INTERFACE
  271. #define INTERFACE   struct _IMS
  272.  
  273. #undef  MAPIMETHOD_
  274. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, IMS_)
  275.         MAPI_IUNKNOWN_METHODS(IMPL)
  276.         MAPI_IMAPIPROP_METHODS(IMPL)
  277.         MAPI_IMSGSTORE_METHODS(IMPL)    
  278. #undef  MAPIMETHOD_
  279. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, IMS_)
  280.         MAPI_IUNKNOWN_METHODS(IMPL)
  281.         MAPI_IMAPIPROP_METHODS(IMPL)
  282.         MAPI_IMSGSTORE_METHODS(IMPL)
  283. #undef  MAPIMETHOD_
  284. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  285.  
  286. DECLARE_MAPI_INTERFACE(IMS_)
  287. {
  288.     MAPI_IUNKNOWN_METHODS(IMPL)
  289.     MAPI_IMAPIPROP_METHODS(IMPL)
  290.     MAPI_IMSGSTORE_METHODS(IMPL)    
  291. };
  292.  
  293. struct _IMS             /* Implementation of IMsgStore */
  294. {
  295.     IMS_Vtbl *      lpVtbl;     /* -> vtblIMS */
  296.     STANDARD_OBJECT_MEMBERS
  297.     LPTSTR      szStorePath;    /* Full path to the store root */
  298.     MAPIUID     uidResource;    /* Message Store unique identifier */
  299.     LPTSTR      szProps;        /* Full path to property docfile */
  300.     PMSL        pmsl;           /* Logon object (MAPI session stuff) */
  301.     PMSP        pmsp;           /* Provider object (global stuff) */
  302.     LMR         lmr;            /* Linked memory routines */
  303.     PRFS        prfs;           /* Struct handling access to receive folder */
  304.     LPMAPISUP   psup;           /* MAPI Support object */
  305.     SBinary     eidStore;       /* PR_STORE_ENTRYID */
  306.     LPTABLEDATA lptblOutgoing;  /* outgoing queue for this store */
  307.     HANDLE      hOGQueueMutex;  /* Mutex for reading/writing the OG Queue */
  308.     FILETIME    ftOGQueue;      /* The time of the OQ file when we read it */
  309.     ULONG       cOutgoingViews; /* number of views open on the outgoing queue */
  310.     ULONG       ulOQConn;       /* Connection for OQ unadvise */
  311.     HANDLE      hContTblMutex;  /* Mutex for reading/writing ALL cont tbls */
  312.     ULONG       ulTblConn;      /* Connection for Tbl unadvise */
  313.     LPMSGSESS   pmsgsess;       /* IMSG Session to create all messages within */
  314.     ULONG       ulFlagsSLT;     /* Flags for StoreLogoffTransports */
  315. };
  316.  
  317. #define MSF_SPOOLER         ((WORD)0x8000)
  318. #define MSF_BEINGDESTROYED  ((WORD)0x4000)
  319.  
  320. #define SMS_SUPPORTMASK     (STORE_ENTRYID_UNIQUE |     \
  321.                             STORE_ATTACH_OK |           \
  322.                             STORE_OLE_OK |              \
  323.                             STORE_NOTIFY_OK |           \
  324.                             STORE_MV_PROPS_OK |         \
  325.                             STORE_RESTRICTION_OK |      \
  326.                             STORE_SORT_OK |             \
  327.                             STORE_MODIFY_OK |           \
  328.                             STORE_CREATE_OK |           \
  329.                             STORE_SUBMIT_OK)
  330.  
  331. /* Outgoing Queue Notification Block (ONB) */
  332. /* This is the format of our extended cross-process notification for the */
  333. /* outgoing queue table. We use this to update the table data in other */
  334. /* processes after we change it in the originating process. The changes */
  335. /* that we pass across are either deleting a row (for example, when the */
  336. /* spooler calls FinishedMsg), or adding a row (for example, when the */
  337. /* client submits a message). */
  338.  
  339. typedef struct _ONB
  340. {
  341.     FILETIME ftBeforeUpdate;    /* time of the file before updating */
  342.     FILETIME ftAfterUpdate;     /* time of the file after applying the update */
  343.     LPVOID  pvRef;              /* memory offset from originating process */
  344.     ULONG   cbNtf;              /* # of bytes in abNtf (the flat notif below) */
  345.     BYTE    abNtf[1];           /* the update to apply to the table */
  346. } ONB, * PONB;
  347.  
  348. #define CbNewONB(_cb)       (offsetof(ONB,abNtf) + (_cb))
  349. #define CbONB(_ponb) \
  350.     (offsetof(ONB,abNtf) + (UINT)((_ponb)->cbNtf))
  351.  
  352.  
  353. /* Table Notification Block (TNB) */
  354. /* This is the format of our extended cross-process notification for */
  355. /* Contents and Hierarchy Tables. We use this notification to update a */
  356. /* table in other processes after we change it in the originating process. */
  357. /* The notification consists of an object notification containing the */
  358. /* entryids we need. The fnev tells the event type. We only use two of */
  359. /* the entryids in the object notification. The ParentID fields refer to */
  360. /* the parent folder of the table we need to update. The EntryID fields */
  361. /* refer to the object that changed within the folder. The ulObjType field */
  362. /* will be either MAPI_MESSAGE (for contents table changes) or MAPI_FOLDER */
  363. /* (for hierarchy table changes).  All other fields in the structure are */
  364. /* unused and should be set to 0. */
  365.  
  366. typedef struct _TNB
  367. {
  368.     ULONG   ulTableEvent;   /* TABLE_ROW_ (ADDED, DELETED, MODIFIED) */
  369.     LPVOID  pvRef;          /* memory offset from originating process */
  370.     ULONG   cbNtf;          /* # of bytes in abNtf (the flat notif below) */
  371.     BYTE    abNtf[1];       /* an object notification */
  372. } TNB, * PTNB;
  373.  
  374. #define CbNewTNB(_cb)       (offsetof(TNB,abNtf) + (_cb))
  375. #define CbTNB(_ptnb) \
  376.     (offsetof(TNB,abNtf) + (UINT)((_ptnb)->cbNtf))
  377.  
  378.  
  379. /* Exported functions */
  380. HRESULT HrOpenIMSPropsFileRetry(LPMSGSESS pmsgsess, LPTSTR szFile, PLMR plmr,
  381.     LPMAPISUP psup, BOOL fModify, LPMESSAGE * lppmsg);
  382. BOOL IMS_IsInvalid(PIMS pims);
  383.  
  384. /* Constructors */
  385.  
  386. HRESULT HrNewIMS(LPTSTR szStorePath, LPTSTR szStoreProps, PMSP pmsp,
  387.     PMSL pmsl, PRFS prfs, LPPROFSECT pps, LPMAPISUP psup, BOOL fCreate,
  388.     PIMS *ppims);
  389.  
  390. /* Non-virtual public methods */
  391.  
  392. void IMS_Neuter(PIMS pims);
  393. HRESULT HrInitIMSProps (PIMS pims, LPTSTR szPswd);
  394. VOID GetResourceUID (PIMS pims, LPMAPIUID lpuid);
  395. HRESULT HrUniqueFileName (PIMS pims, ULONG * lpulSeqNumber, LPTSTR *
  396.     lppszNewName);
  397. BOOL FIsInvalidEID (ULONG, PEID, PIMS);
  398. /* Others */
  399.  
  400. STDAPI_(void) MsgReleaseStg (ULONG ulCallerData, LPMESSAGE lpMessage);
  401. long STDAPICALLTYPE LSMSNotifCallback (LPVOID lpvContext,
  402.     ULONG cNotif, LPNOTIFICATION lpNotifs);
  403.  
  404. /* column properties for outgoing queue */
  405. #define OUTGOING_COLUMNS    13      /* number of columns in outgoing queue */
  406. static const SizedSPropTagArray(OUTGOING_COLUMNS, sptaOutgoing) =
  407. {
  408.     OUTGOING_COLUMNS,
  409.     {
  410.         PR_ENTRYID,
  411.         PR_SUBMIT_FLAGS,
  412.         PR_INSTANCE_KEY,    /* the index column */
  413.         PR_DISPLAY_TO,
  414.         PR_DISPLAY_CC,
  415.         PR_DISPLAY_BCC,
  416.         PR_SENDER_NAME,
  417.         PR_SUBJECT,
  418.         PR_CLIENT_SUBMIT_TIME,
  419.         PR_PRIORITY,
  420.         PR_MESSAGE_FLAGS,
  421.         PR_MESSAGE_SIZE,
  422.         PR_SPOOLER_STATUS
  423.     }
  424. };
  425.  
  426.  
  427. /*
  428.  *  MSPFLD.C
  429.  */
  430.  
  431. #define FAILED_SEARCH   (INVALID_HANDLE_VALUE)
  432.  
  433. #define MODIFY_INDEX    1       /* index of LAST_MODIFICATION_TIME in tables */
  434.  
  435. /* column properties for contents tables */
  436. #define CONTENTS_COLUMNS    22      /* number of columns in a table of messages */
  437. static const SizedSPropTagArray(CONTENTS_COLUMNS, sPropTagsContents) =
  438. {
  439.     CONTENTS_COLUMNS,
  440.     {
  441.         PR_ENTRYID,
  442.         PR_LAST_MODIFICATION_TIME,  /* must be in position MODIFY_INDEX */
  443.         PR_INSTANCE_KEY,            /* the index column */
  444.         PR_HASATTACH,
  445.         PR_SUBJECT,
  446.         PR_SENDER_NAME,
  447.         PR_DISPLAY_TO,
  448.         PR_DISPLAY_CC,
  449.         PR_CLIENT_SUBMIT_TIME,
  450.         PR_MESSAGE_DELIVERY_TIME,
  451.         PR_MESSAGE_FLAGS,
  452.         PR_PRIORITY,
  453.         PR_CONVERSATION_KEY,
  454.         PR_SEARCH_KEY,
  455.         PR_ICON,
  456.         PR_MINI_ICON,
  457.         PR_SENSITIVITY,
  458.         PR_MESSAGE_CLASS,
  459.         PR_RECORD_KEY,
  460.         PR_SPOOLER_STATUS,
  461.         PR_SENT_REPRESENTING_NAME,
  462.         PR_MSG_STATUS
  463.     }
  464. };
  465.  
  466. /* column properties for hierarchy tables */
  467. #define HIERARCHY_COLUMNS   12
  468. static const SizedSPropTagArray(HIERARCHY_COLUMNS, sPropTagsHierarchy) =
  469. {
  470.     HIERARCHY_COLUMNS,
  471.     {
  472.         PR_ENTRYID,
  473.         PR_LAST_MODIFICATION_TIME, /* must be in postion MODIFY_INDEX */
  474.         PR_DISPLAY_NAME,    /* the folder name */
  475.         PR_INSTANCE_KEY,    /* the index column */
  476.         PR_OBJECT_TYPE,
  477.         PR_COMMENT,
  478.         PR_CONTENT_COUNT,
  479.         PR_CONTENT_UNREAD,
  480.         PR_STATUS,
  481.         PR_SUBFOLDERS,
  482.         PR_FOLDER_TYPE,
  483.         PR_DEPTH            /* depth in hierarchy, must be last */
  484.     }
  485. } ;
  486.  
  487. #undef  INTERFACE
  488. #define INTERFACE struct _IFLD
  489.     
  490. #undef  MAPIMETHOD_
  491. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, IFLD_)
  492.         MAPI_IUNKNOWN_METHODS(IMPL)
  493.         MAPI_IMAPIPROP_METHODS(IMPL)
  494.         MAPI_IMAPICONTAINER_METHODS(IMPL)
  495.         MAPI_IMAPIFOLDER_METHODS(IMPL)
  496. #undef  MAPIMETHOD_
  497. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, IFLD_)
  498.         MAPI_IUNKNOWN_METHODS(IMPL)
  499.         MAPI_IMAPIPROP_METHODS(IMPL)
  500.         MAPI_IMAPICONTAINER_METHODS(IMPL)
  501.         MAPI_IMAPIFOLDER_METHODS(IMPL)
  502. #undef  MAPIMETHOD_
  503. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  504.  
  505. DECLARE_MAPI_INTERFACE(IFLD_)
  506. {
  507.     MAPI_IUNKNOWN_METHODS(IMPL)
  508.     MAPI_IMAPIPROP_METHODS(IMPL)
  509.     MAPI_IMAPICONTAINER_METHODS(IMPL)
  510.     MAPI_IMAPIFOLDER_METHODS(IMPL)
  511. };
  512.  
  513. extern IFLD_Vtbl    vtblIFLD;
  514.  
  515. /* we store PR_ENTRYID, PR_PARENT_ENTRYID and PR_INSTANCE_KEY internally */
  516. #define cpropIFLDInternal       3
  517.  
  518. /* Folder's instance data */
  519. struct _IFLD
  520. {
  521.     IFLD_Vtbl *     lpVtbl; /* -> vtblIFLD */
  522.     STANDARD_OBJECT_MEMBERS
  523.     PEID peid;                  /* EntryID of this folder */
  524.     ULONG           cval;       /* # of internal props */
  525.     LPSPropValue    pval;       /* internal prop values */
  526.     LPTABLEDATA lptblContents;  /* contents table for this folder */
  527.     ULONG cContentsViews;       /* number of views open on contents table*/
  528.     LPTABLEDATA lptblHierarchy; /* hierarchy table for this folder */
  529.     ULONG cHierarchyViews;      /* number of views open on hierarchy table */
  530. };
  531.  
  532. HRESULT HrNewIFLD(PEID peid, PIMS pims, BOOL fModify, PIFLD * ppifld);
  533. HRESULT HrCreateFolderStorage(PIFLD pifld, ULONG ulFolderType,
  534.     LPSTR szFolderName, LPSTR szFolderComment, BOOL fCreateDir,
  535.     PIMS pims, PEID *ppeid);
  536. HRESULT HrNewEID (PIFLD, PIMS, LPTSTR, ULONG *, PEID *);
  537. HRESULT HrIncrementOneROProp(PIFLD pifld, LONG lDelta, ULONG ulPT);
  538. HRESULT HrIsParent(PEID peidParent, PEID peidChild, BOOL *pfIsParent);
  539. HRESULT HrGetFileModTime(LPTSTR szStorePath, LPTSTR szFileName,
  540.     FILETIME *pft);
  541. HRESULT HrFullPathName (LPSTR, LPSTR, LPSTR, LPSTR *);
  542. HRESULT HrFullToRelative(LPTSTR, PIMS, LPTSTR *);
  543. HRESULT HrOpenPropertyMessageRetry(PEID peid, PIMS pims,
  544.     BOOL fModifyExclusive, LPMESSAGE *lppmsg);
  545. HRESULT HrFindFirstID( PIFLD, LPTSTR, ULONG *, LPTSTR *, HANDLE *,
  546.                     WIN32_FIND_DATA *, PEID *);
  547. HRESULT HrFindNextID( PIFLD, ULONG, LPTSTR, HANDLE, WIN32_FIND_DATA *, PEID *);
  548. void CloseIDSearch( HANDLE *, LPTSTR *);
  549. HRESULT HrFullToRelative( LPTSTR, PIMS, LPTSTR *);
  550. HRESULT HrUpdateRow(PIMS pims, LPTABLEDATA lptbl, PEID peid,
  551.     LPSPropTagArray pPTA, FILETIME *pft, ULONG ulObjType);
  552. void    IFLD_Neuter (PIFLD);
  553. void ChangeTable(PIMS pims, PEID peidTable, PEID peidObject,
  554.     ULONG ulObjType, ULONG ulTableEvent, BOOL fSendNotif);
  555. HRESULT HrRemoveRow( LPTABLEDATA lptbl, PEID peid);
  556.  
  557. /*
  558.  *  MSPMSG.C
  559.  */
  560.  
  561. #undef  INTERFACE
  562. #define INTERFACE struct _IMSG
  563.     
  564. #undef  MAPIMETHOD_
  565. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, IMSG_)
  566.         MAPI_IUNKNOWN_METHODS(IMPL)
  567.         MAPI_IMAPIPROP_METHODS(IMPL)
  568.         MAPI_IMESSAGE_METHODS(IMPL)
  569. #undef  MAPIMETHOD_
  570. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, IMSG_)
  571.         MAPI_IUNKNOWN_METHODS(IMPL)
  572.         MAPI_IMAPIPROP_METHODS(IMPL)
  573.         MAPI_IMESSAGE_METHODS(IMPL)
  574. #undef  MAPIMETHOD_
  575. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  576.  
  577. DECLARE_MAPI_INTERFACE(IMSG_)
  578. {
  579.     MAPI_IUNKNOWN_METHODS(IMPL)
  580.     MAPI_IMAPIPROP_METHODS(IMPL)
  581.     MAPI_IMESSAGE_METHODS(IMPL)
  582. };
  583.  
  584. extern IMSG_Vtbl    vtblIMSG;
  585.  
  586. struct _IMSG            /* Implementation of IMessage */
  587. {
  588.     IMSG_Vtbl * lpVtbl; /* -> vtblIMSG */
  589.     STANDARD_OBJECT_MEMBERS
  590.     LPMESSAGE       lpmsg;
  591.     PEID            peid;
  592.     ULONG           cval;
  593.     LPSPropValue    pval;
  594. };
  595.  
  596. #define MSGF_NEWLYCREATED           ((WORD)0x4000)
  597. #define MSGF_MSGINMSG               ((WORD)0x2000)
  598. #define MSGF_FRESH                  ((WORD)0x1000)
  599. #define MSGF_CREATEDSTORAGE         ((WORD)0x0800)
  600.  
  601. #define SET         1
  602. #define UNSET       2
  603. #define DONT_SAVE   4
  604.  
  605. /* Exported functions */
  606.  
  607. HRESULT HrNewIMSG(PEID peid, PIMS pims, BOOL fCreate, BOOL fModify,
  608.     ULONG ulSeqNum, LPSTR *pszFull, PIMSG *ppimsg);
  609. HRESULT HrSetFlags(PIMSG, ULONG, ULONG, ULONG); 
  610. HRESULT NewIMSGInIATCH (LPMESSAGE lpmsg, POBJ pobj, ULONG ulFlags, PIMSG * ppimsg);
  611. HRESULT InitIMSGProps(PIMSG pimsg);
  612. void IMSG_Neuter (PIMSG);
  613. HRESULT HrSetInternalProps(PLMR plmr, ULONG cprop, LPSPropValue *ppval,
  614.     ULONG *pcval, PEID peid, PEID peidParent, ULONG ulSeqNum);
  615.  
  616. /*
  617.  *  MSPATCH.C
  618.  */
  619.  
  620. #undef  INTERFACE
  621. #define INTERFACE struct _IATCH
  622.     
  623. #undef  MAPIMETHOD_
  624. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, IATCH_)
  625.         MAPI_IUNKNOWN_METHODS(IMPL)
  626.         MAPI_IMAPIPROP_METHODS(IMPL)
  627.         MAPI_IATTACH_METHODS(IMPL)
  628. #undef  MAPIMETHOD_
  629. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, IATCH_)
  630.         MAPI_IUNKNOWN_METHODS(IMPL)
  631.         MAPI_IMAPIPROP_METHODS(IMPL)
  632.         MAPI_IATTACH_METHODS(IMPL)
  633. #undef  MAPIMETHOD_
  634. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  635.  
  636. DECLARE_MAPI_INTERFACE(IATCH_)
  637. {
  638.     MAPI_IUNKNOWN_METHODS(IMPL)
  639.     MAPI_IMAPIPROP_METHODS(IMPL)
  640.     MAPI_IATTACH_METHODS(IMPL)
  641. };
  642.  
  643. extern IATCH_Vtbl   vtblIATCH;
  644.  
  645. struct _IATCH           /* Implementation of IAttach */
  646. {
  647.     IATCH_Vtbl *    lpVtbl; /* -> vtblIATCH */
  648.     STANDARD_OBJECT_MEMBERS
  649.     LPATTACH lpattach;
  650. };
  651.  
  652. /* Exported functions */
  653.  
  654. HRESULT HrNewIATCH(LPATTACH lpattach, PIMSG pimsg, BOOL fModify,
  655.     PIATCH * ppiatch);
  656. void IATCH_Neuter (PIATCH piatch);
  657.  
  658. /*
  659.  *  MSPGLE.C
  660.  */
  661.  
  662. HRESULT MapScodeSz (SCODE scArg, PIMS pims, LPTSTR * lppszError);
  663.  
  664. /*
  665.  *  MSPMISC.C
  666.  */
  667.  
  668. /* length in chars of file extension including . (no NULL) */
  669. #define CCH_EXT         4
  670.  
  671. /* length in chars of the base portion of a local name (no NULL) */
  672. #define CCH_BASE        8
  673.  
  674. /* length in chars of a local name of a message or folder, including NULL */
  675. #define CCH_NAME            (CCH_BASE + CCH_EXT + 1)
  676.  
  677. #define FOLDER_EXT      TEXT( ".fld" )  /* extension for folder directory names */
  678. #define MESSAGE_EXT     TEXT( ".msg" )  /* File name extension for messages */
  679. #define TEMP_EXT        TEXT( ".tmp" )  /* File name extension for messages */
  680.  
  681. /* Filename extension for read-receipt messages   */
  682. #define READRECEIPT_EXT TEXT( ".rrt" )
  683.  
  684. SCODE ScAlloc(ULONG lcb, LPVOID *ppv);
  685. SCODE ScAllocZ(ULONG lcb, LPVOID *ppv);
  686. SCODE ScRealloc(ULONG lcb, LPVOID pvOrig, LPVOID * ppv);
  687. void FreeNull(LPVOID pv);
  688. SCODE LMAllocZ(PLMR plmr, ULONG lcb, LPVOID *ppv);
  689. SCODE ScInitMSInstance(LPMALLOC lpmalloc);
  690. void DeinitMSInstance(void);
  691.  
  692. #define HrAlloc(a,b)        ResultFromScode(ScAlloc((a), (b)))
  693. #define HrAllocZ(a,b)       ResultFromScode(ScAllocZ((a), (b)))
  694. #define HrRealloc(a,b,c)    ResultFromScode(ScRealloc((a), (b), (c)))
  695.  
  696. LPTSTR SzBaseName (PEID);
  697.  
  698. BOOL FCheckEIDType(PEID peid, LPSTR szExt);
  699. BOOL FIsRoot (PEID peid);
  700. BOOL FIsFolder (PEID peid);
  701. BOOL FIsUnsavedMsg (PIMSG pimsg);
  702. #define FIsMessage(_peid)       FCheckEIDType((_peid), MESSAGE_EXT)
  703. #define FIsUnsavedEID(_peid)    FCheckEIDType((_peid), TEMP_EXT)
  704.  
  705. HRESULT HrDeconstructEID (PEID peid, LPMAPIUID * lppuid,
  706.     LPTSTR * lppszPath, LPTSTR * lppszFile);
  707. HRESULT HrAppendPath (LPTSTR szBase, LPTSTR szAppend, LPTSTR *
  708.     lppszFullPath);
  709. BOOL FAppendPathNoMem (LPTSTR szBase, LPTSTR szAppend,
  710.     ULONG cchFullPath, LPTSTR szFullPath);
  711. void ReplaceExt(LPTSTR szFile, LPTSTR szExt);
  712. HRESULT HrConstructEID(LPMAPIUID lpuidStore, PLMR plmr, LPSTR szNewName,
  713.     PEID *ppeidNew);
  714. HRESULT HrGetParentEID (PLMR, PEID, PEID *);
  715. HRESULT HrOpenParent(PIMS pims, PEID peid, ULONG ulFlags, PIFLD *ppifld);
  716.  
  717. void FreePropArrays (LPSPropValue *,
  718.     LPSPropTagArray *, LPSPropAttrArray *);
  719. HRESULT HrAllocPropArrays (ULONG, LPSPropValue *,
  720.     LPSPropTagArray *, LPSPropAttrArray *);
  721.  
  722. HRESULT HrWrap_GetProps(HRESULT hr, PIMS pims, ULONG cvalInt,
  723.     LPSPropValue pvalInt, ULONG * lpcValues, LPSPropValue * ppval,
  724.     BOOL fStore, BOOL fTagsSpecified, POBJ pobj);
  725.  
  726. BOOL FIsSubmittedMessage(PIMS pims, PEID peid);
  727.  
  728. HRESULT HrOpenIMsgSession(LPMSGSESS *ppmsgsess);
  729. HRESULT HrOpenIMsg(LPMSGSESS pmsgsess, LPSTR szFile, PLMR plmr, LPMAPISUP psup,
  730.     BOOL fCreate, BOOL fModify, BOOL fExclusive, LPMESSAGE *lppmsg);
  731.  
  732. HRESULT HrSetOneROProp(LPMESSAGE lpmsg, PLMR plmr, ULONG ulPT, LPVOID pv);
  733. HRESULT HrGetSingleProp(LPMAPIPROP pmprop, PLMR plmr, ULONG ulPT, LPVOID pv);
  734. HRESULT HrSetSingleProp(LPMAPIPROP pmprop, PLMR plmr, ULONG ulPT, LPVOID pv);
  735.  
  736. BOOL FContainsProp(ULONG ulPropTag, LPSPropTagArray ptaga);
  737.  
  738.  
  739. /*
  740.  *  MSPROVIDER object.
  741.  *  Returned by MSProviderInit() routine.
  742.  *  One is created for each Session logged
  743.  *  into this store provider on this process.
  744.  */
  745.  
  746. #undef  INTERFACE
  747. #define INTERFACE struct _MSP
  748.  
  749. #undef  MAPIMETHOD_
  750. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, MSP_)
  751.         MAPI_IUNKNOWN_METHODS(IMPL)
  752.         MAPI_IMSPROVIDER_METHODS(IMPL)
  753. #undef  MAPIMETHOD_
  754. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, MSP_)
  755.         MAPI_IUNKNOWN_METHODS(IMPL)
  756.         MAPI_IMSPROVIDER_METHODS(IMPL)
  757. #undef  MAPIMETHOD_
  758. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  759.  
  760. DECLARE_MAPI_INTERFACE(MSP_)
  761. {
  762.     MAPI_IUNKNOWN_METHODS(IMPL)
  763.     MAPI_IMSPROVIDER_METHODS(IMPL)
  764. };
  765.  
  766. extern MSP_Vtbl vtblMSP;
  767.  
  768. struct _MSP
  769. {
  770.     MSP_Vtbl *  lpVtbl;         /* -> vtblMSP */
  771.     STANDARD_OBJECT_MEMBERS
  772.     CRITICAL_SECTION_MEMBERS        /* Critical section (_WIN32 only) */
  773.     HINSTANCE       hInst;          /* Instance handle */
  774.     LMR             lmr;            /* Linked memory routines */
  775.     IFDBG(BOOL      fInvalid;)      /* TRUE if invalid (DEBUG only) */
  776. };
  777.  
  778. /*
  779.  *  LOGON object.
  780.  *  Returned from MSP_Logon().
  781.  *  Called by MAPI.DLL.  Equivalent to the IMSGSTORE object
  782.  *  returned on the same call but is used by MAPI instead of the client.
  783.  */
  784.  
  785. #undef  INTERFACE
  786. #define INTERFACE struct _MSL
  787.  
  788. #undef  MAPIMETHOD_
  789. #define MAPIMETHOD_(type, method)   MAPIMETHOD_DECLARE(type, method, MSL_)
  790.         MAPI_IUNKNOWN_METHODS(IMPL)
  791.         MAPI_IMSLOGON_METHODS(IMPL)
  792. #undef  MAPIMETHOD_
  793. #define MAPIMETHOD_(type, method)   MAPIMETHOD_TYPEDEF(type, method, MSL_)
  794.         MAPI_IUNKNOWN_METHODS(IMPL)
  795.         MAPI_IMSLOGON_METHODS(IMPL)
  796. #undef  MAPIMETHOD_
  797. #define MAPIMETHOD_(type, method)   STDMETHOD_(type, method)
  798.  
  799. DECLARE_MAPI_INTERFACE(MSL_)
  800. {
  801.     MAPI_IUNKNOWN_METHODS(IMPL)
  802.     MAPI_IMSLOGON_METHODS(IMPL)
  803. };
  804.  
  805. extern MSL_Vtbl vtblMSL;
  806. extern MAPIUID uidProvider;
  807.  
  808. struct _MSL
  809. {
  810.     MSL_Vtbl *      lpVtbl;     /* -> vtblMSL */
  811.     STANDARD_OBJECT_MEMBERS
  812.     CRITICAL_SECTION_MEMBERS        /* Critical section (_WIN32) */
  813.     LMR                 lmr;        /* Linked memory routines */
  814.     IFDBG(BOOL          fInvalid;)  /* TRUE if invalid (DEBUG only) */
  815. };
  816.  
  817.  
  818. /*
  819.  *  MSPTBL.C
  820.  */
  821.  
  822. HRESULT HrGetTableName(POBJ, LPSTR, LPSTR, LPSTR *);
  823. HRESULT HrSyncOutgoingTable(LPTABLEDATA lptbl, PIMS pims);
  824. HRESULT HrSyncContentsTable(PIFLD pifld, BOOL fWriteTable);
  825. HRESULT HrReadTableFromDisk(LPTABLEDATA, POBJ, LPSTR, ULONG, LPSTR);
  826. HRESULT HrWriteTableOnDisk(LPTABLEDATA, POBJ, LPSTR, LPSTR);
  827.  
  828. /*
  829.  *  MSPNTFY.C
  830.  */
  831.  
  832. HRESULT HrUpdateOutgoingQueue(PIMS pims, PIMSG pimsg, PEID peid,
  833.     ULONG ulTableEvent);
  834. HRESULT HrSetupPrivateNotifications(PIMS pims);
  835. HRESULT HrNewOutgoingTableData(PIMS pims);
  836. HRESULT HrCreateOGQueueMutex(HANDLE *phQMutex);
  837.  
  838. HRESULT HrSendNotif(PIMS pims, PEID peidParent, PEID peidObject,
  839.     ULONG ulTableEvent, ULONG ulObjType);
  840.  
  841.