home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / nscpmapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  12.8 KB  |  333 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. // This is a header file for the MAPI support within 
  20. // Communicator. 
  21. //
  22. // Written by: Rich Pizzarro (rhp@netscape.com)
  23. //
  24. #ifndef _NSCPMAPI
  25. #define _NSCPMAPI
  26.  
  27. #ifndef MAPI_OLE    // Because MSFT doesn't do this for us :-(
  28. #include <mapi.h>     // for MAPI specific types...        
  29. #endif 
  30.  
  31. #ifdef WIN16
  32. typedef unsigned char    UCHAR;
  33. #endif 
  34.  
  35.  
  36. #define           MAX_NAME_LEN    256
  37. #define           MAX_PW_LEN      256
  38. #define           MAX_MSGINFO_LEN 512
  39. #define           MAX_CON         4     // Maximum MAPI session supported
  40. #define           MAX_POINTERS    32
  41.  
  42. //
  43. // The MAPI class that will act as the internal mechanism for 
  44. // Communicator to control multiple MAPI sessions.
  45. //
  46. class CMAPIConnection 
  47. {
  48. protected:
  49.   LONG        m_ID;
  50.   BOOL        m_defaultConnection;  
  51.   LONG        m_sessionCount;
  52.   LONG        m_messageIndex;
  53.   LPVOID      m_cookie;
  54.   UCHAR       m_messageFindInfo[MAX_MSGINFO_LEN];
  55.   UCHAR       m_profileName[MAX_NAME_LEN];
  56.   UCHAR       m_password[MAX_PW_LEN];
  57.  
  58.   // Methods
  59.  
  60. public:
  61.   CMAPIConnection  ( LONG, LPSTR, LPSTR );
  62.   ~CMAPIConnection ( );
  63.  
  64.   // ID related methods
  65.   LONG   GetID( ) { return m_ID; } ;
  66.  
  67.   // Dealing with the default session...
  68.   BOOL    IsDefault( ) { return m_defaultConnection; } ;
  69.   void    SetDefault( BOOL flag ) { m_defaultConnection = flag; } ;
  70.  
  71.   // For handling multiple sessions on a profile name...
  72.   LONG    GetSessionCount( ) { return m_sessionCount; } ;
  73.   void    IncrementSessionCount() { ++m_sessionCount; } ;
  74.   void    DecrementSessionCount() { --m_sessionCount; } ;
  75.  
  76.   // Information retrieval stuff...
  77.   LPSTR   GetProfileName( ) { return (LPSTR) m_profileName; };
  78.   LPSTR   GetPassword( ) { return (LPSTR) m_password; };
  79.  
  80.   // Dealing with message information...
  81.   void    SetMessageIndex( LONG mIndex ) { m_messageIndex = mIndex; } ;
  82.   LONG    GetMessageIndex( ) { return m_messageIndex; };
  83.  
  84.   void    SetMessageFindInfo( LPSTR info ) { lstrcpy((LPSTR)m_messageFindInfo, info); } ;
  85.   LPSTR   GetMessageFindInfo( ) { return (LPSTR) m_messageFindInfo; };
  86.  
  87.   // For enumerating Messages...
  88.   void    SetMapiListContext( LPVOID cookie) { m_cookie = cookie; } ;
  89.   LPVOID  GetMapiListContext( ) { return m_cookie; };
  90. };
  91.  
  92. //
  93. // Defines needed for requests being made with the WM_COPYDATA call...
  94. //
  95. typedef enum {
  96.     NSCP_MAPIStartRequestID = 0,
  97.     NSCP_MAPILogon,
  98.     NSCP_MAPILogoff,
  99.     NSCP_MAPIFree,
  100.     NSCP_MAPISendMail,
  101.     NSCP_MAPISendDocuments, 
  102.     NSCP_MAPIFindNext,
  103.     NSCP_MAPIReadMail,
  104.     NSCP_MAPISaveMail,
  105.     NSCP_MAPIDeleteMail,
  106.     NSCP_MAPIAddress,
  107.     NSCP_MAPIDetails,
  108.     NSCP_MAPIResolveName,
  109.     NSCP_MAPIEndRequestID       // Note: this is a marker for MAPI IPC requests
  110. } NSCP_IPC_REQUEST;
  111.  
  112. //
  113. // This is to keep track of the pointers allocated in the MAPI DLL
  114. // and deal with them correctly.
  115. //
  116. #define   MAPI_MESSAGE_TYPE     0
  117. #define   MAPI_RECIPIENT_TYPE   1
  118.  
  119. typedef struct {
  120.   LPVOID    lpMem;
  121.   UCHAR     memType;
  122. } memTrackerType;
  123.  
  124. //
  125. // This is the generic message that WM_COPYDATA will send to the
  126. // Communicator product to allow it to attach to shared memory.
  127. // NOTE: On Win16, this will simply reference a pointer.
  128. //
  129. typedef struct {
  130.   UCHAR   smemName[64]; // Name of shared memory
  131.   DWORD   smemSize;     // Size of shared memory
  132.   LPVOID  lpsmem;       // Will be really used in Win16 only
  133. } MAPIIPCType;
  134.  
  135. //
  136. // These are message specific structures that will be used for 
  137. // the various MAPI operations.
  138. //
  139. typedef struct {
  140.   ULONG     ulUIParam;
  141.   FLAGS     flFlags;
  142.   LHANDLE   lhSession;
  143.   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
  144. // LPSTR     strSequence,  // LPSTR lpszProfileName, LPSTR lpszPassword
  145. // This is here to document the fact there will be a string sequence at 
  146. // this location
  147. } MAPILogonType;
  148.  
  149. typedef struct {
  150.   LHANDLE   lhSession;
  151.   ULONG     ulUIParam;
  152.   FLAGS     flFlags;
  153.   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
  154. } MAPILogoffType;
  155.  
  156. typedef struct {
  157.   LHANDLE   lhSession;
  158.   ULONG     ulUIParam;
  159.   FLAGS     flFlags;
  160.   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
  161.   // The following is the "FLAT" representation of the (lpMapiMessage lpMessage) 
  162.   // argument of this structure 
  163.   FLAGS     MSG_flFlags;          // unread,return receipt                  
  164.   ULONG     MSG_nRecipCount;      // Number of recipients                   
  165.   ULONG     MSG_nFileCount;       // # of file attachments                  
  166.   ULONG     MSG_ORIG_ulRecipClass; //  Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
  167.   BYTE      dataBuf[1];           // For easy referencing
  168.   //
  169.   // This is where it gets CONFUSING...the following buffer of memory is a
  170.   // contiguous chunk of memory for various strings that are part of this
  171.   // multilevel structure. For any of the following structure, any numbers
  172.   // are represented by strings that will have to be converted back to numeric
  173.   // values with atoi() calls.
  174.  
  175.   // String 0: LPSTR lpszSubject;            // Message Subject
  176.   // String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
  177.   //           stored into a temp file and this will be the pointer to that file.
  178.   // String 2: LPSTR lpszDateReceived;       // in YYYY/MM/DD HH:MM format
  179.   // String 3: LPSTR lpszConversationID;     // conversation thread ID
  180.   //
  181.   // The following are for the originator of the message. Only ONE of these.
  182.   //
  183.   // String 4: LPSTR lpszName;             // Originator name                           
  184.   // String 5: LPSTR lpszAddress;          // Originator address (optional)             
  185.   //
  186.   // The following strings are for the recipients for this message. There are
  187.   // MSG_nRecipCount of these in a row:
  188.   //
  189.   // for (i=0; i<MSG_nRecipCount; i++)
  190.   //      String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG        
  191.   //      String x: LPSTR lpszName;     // Recipient N name                           
  192.   //      String x: LPSTR lpszAddress;  // Recipient N address (optional)             
  193.   //
  194.   // Now, finally, add the attachments for this beast. There are MSG_nFileCount
  195.   // attachments so it would look like the following:
  196.   //
  197.   // for (i=0; i<MSG_nFileCount; i++)
  198.   //
  199.   //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
  200.   //                                   // This path should include the disk drive letter and directory name.
  201.   //      String x: LPSTR lpszFileName // The display name for the attached file
  202.   //
  203. } MAPISendMailType;
  204.  
  205. typedef struct {
  206.     ULONG     ulUIParam;
  207.     ULONG     nFileCount;
  208.     DWORD     ipcWorked;      // Necessary for IPC check with Communicator
  209.     BYTE      dataBuf[1];     // For easy referencing
  210.     //
  211.     // The sequence of strings to follow are groups of PathName/FileName couples.
  212.     // The strings will be parsed in MAPI[32].DLL and then put into this format:
  213.     //
  214.     // for (i=0; i<nFileCount; i++)
  215.     //
  216.     //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
  217.     //                                   // This path should include the disk drive letter and directory name.
  218.     //      String x: LPSTR lpszFileName // The display name for the attached file
  219. } MAPISendDocumentsType;
  220.  
  221. typedef struct {
  222.   LHANDLE     lhSession;
  223.   ULONG       ulUIParam;
  224.   FLAGS       flFlags;
  225.   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
  226.   UCHAR       lpszSeedMessageID[MAX_MSGINFO_LEN];
  227.   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
  228. } MAPIFindNextType;
  229.  
  230. typedef struct {
  231.   LHANDLE     lhSession;
  232.   ULONG       ulUIParam;
  233.   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
  234.   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
  235. } MAPIDeleteMailType;
  236.  
  237. typedef struct {
  238.   LHANDLE     lhSession;
  239.   ULONG       ulUIParam;
  240.   FLAGS       flFlags;
  241.   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
  242.   UCHAR       lpszName[MAX_NAME_LEN];
  243.   // These are returned by Communicator
  244.   UCHAR       lpszABookID[MAX_NAME_LEN];         
  245.   UCHAR       lpszABookName[MAX_NAME_LEN];            
  246.   UCHAR       lpszABookAddress[MAX_NAME_LEN];         
  247. } MAPIResolveNameType;
  248.  
  249. typedef struct {
  250.   LHANDLE     lhSession;
  251.   ULONG       ulUIParam;
  252.   FLAGS       flFlags;
  253.   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
  254.   UCHAR       lpszABookID[MAX_NAME_LEN];
  255. } MAPIDetailsType;
  256.  
  257. typedef struct {
  258.   LHANDLE     lhSession;
  259.   ULONG       ulUIParam;
  260.   FLAGS       flFlags;
  261.   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
  262.   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
  263.   //
  264.   // The following is the "FLAT" representation of the (lpMapiMessage lpMessage) 
  265.   // argument of this structure 
  266.   //
  267.   FLAGS     MSG_flFlags;          // unread, return or receipt                  
  268.   ULONG     MSG_nRecipCount;      // Number of recipients                   
  269.   ULONG     MSG_nFileCount;       // # of file attachments                  
  270.   ULONG     MSG_ORIG_ulRecipClass; //  Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
  271.   //
  272.   // Output parameter for blob of information that will live on disk. 
  273.   //
  274.   UCHAR       lpszBlob[MAX_MSGINFO_LEN];    // file name on disk
  275.   //
  276.   // The format of this blob of information will be:
  277.   //
  278.   // String 0: LPSTR lpszSubject;            // Message Subject
  279.   // String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
  280.   //           stored into a temp file and this will be the pointer to that file.
  281.   // String 2: LPSTR lpszDateReceived;       // in YYYY/MM/DD HH:MM format
  282.   // String 3: LPSTR lpszConversationID;     // conversation thread ID
  283.   //
  284.   // The following are for the originator of the message. Only ONE of these.
  285.   //
  286.   // String 4: LPSTR lpszName;             // Originator name                           
  287.   // String 5: LPSTR lpszAddress;          // Originator address (optional)             
  288.   //
  289.   // The following strings are for the recipients for this message. There are
  290.   // MSG_nRecipCount of these in a row:
  291.   //
  292.   // for (i=0; i<MSG_nRecipCount; i++)
  293.   //      String x: LPSTR lpszName;             // Recipient N name                           
  294.   //      String x: LPSTR lpszAddress;          // Recipient N address (optional)             
  295.   //      String x: LPSTR lpszRecipClass        // recipient class - sprintf of ULONG
  296.   //
  297.   // Now, finally, add the attachments for this beast. There are MSG_nFileCount
  298.   // attachments so it would look like the following:
  299.   //
  300.   // for (i=0; i<MSG_nFileCount; i++)
  301.   //
  302.   //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
  303.   //                                   // This path should include the disk drive letter and directory name.
  304.   //      String x: LPSTR lpszFileName // The display name for the attached file
  305.   //
  306. } MAPIReadMailType;
  307.  
  308. typedef struct {
  309.   LHANDLE   lhSession;
  310.   ULONG     ulUIParam;
  311.   FLAGS     flFlags;
  312.   UCHAR     lpszCaption[MAX_MSGINFO_LEN];
  313.   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
  314.   // The following is the "FLAT" representation of the (lpMapiRecipDesc lpRecips) 
  315.   // argument of this structure 
  316.   ULONG     nRecips;              // number of recips to start with...
  317.   ULONG     nNewRecips;           // number of recips returned...
  318.   UCHAR     lpszBlob[MAX_MSGINFO_LEN];    // file name for blob of information 
  319.                                           // that will live on disk. 
  320.   BYTE      dataBuf[1];           // For easy referencing
  321.   //
  322.   // The following contiguous chunk of memory is the buffer that holds 
  323.   // the recipients to load into the address picker...
  324.   //
  325.   // for (i=0; i<MSG_nRecipCount; i++)
  326.   //      String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG        
  327.   //      String x: LPSTR lpszName;     // Recipient N name                           
  328.   //      String x: LPSTR lpszAddress;  // Recipient N address (optional)             
  329.   //
  330. } MAPIAddressType;
  331.  
  332. #endif    // _NSCPMAPI
  333.