Back to index

lightning-sunbird  0.9+nobinonly
nscpmapi.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 //
00038 // This is a header file for the MAPI support within 
00039 // Communicator. 
00040 //
00041 // Written by: Rich Pizzarro (rhp@netscape.com)
00042 //
00043 #ifndef _NSCPMAPI
00044 #define _NSCPMAPI
00045 
00046 #ifndef MAPI_OLE     // Because MSFT doesn't do this for us :-(
00047 #include <mapi.h>     // for MAPI specific types...        
00048 #endif 
00049 
00050 #ifdef WIN16
00051 typedef unsigned char       UCHAR;
00052 #endif 
00053 
00054 
00055 #define           MAX_NAME_LEN    256
00056 #define           MAX_PW_LEN      256
00057 #define           MAX_MSGINFO_LEN 512
00058 #define           MAX_CON         4     // Maximum MAPI session supported
00059 #define           MAX_POINTERS    32
00060 
00061 //
00062 // The MAPI class that will act as the internal mechanism for 
00063 // Communicator to control multiple MAPI sessions.
00064 //
00065 class CMAPIConnection 
00066 {
00067 protected:
00068   LONG        m_ID;
00069   BOOL        m_defaultConnection;  
00070   LONG        m_sessionCount;
00071   LONG        m_messageIndex;
00072   LPVOID      m_cookie;
00073   UCHAR       m_messageFindInfo[MAX_MSGINFO_LEN];
00074   UCHAR       m_profileName[MAX_NAME_LEN];
00075   UCHAR       m_password[MAX_PW_LEN];
00076 
00077   // Methods
00078 
00079 public:
00080   CMAPIConnection  ( LONG, LPSTR, LPSTR );
00081   ~CMAPIConnection ( );
00082 
00083   // ID related methods
00084   LONG   GetID( ) { return m_ID; } ;
00085 
00086   // Dealing with the default session...
00087   BOOL    IsDefault( ) { return m_defaultConnection; } ;
00088   void    SetDefault( BOOL flag ) { m_defaultConnection = flag; } ;
00089 
00090   // For handling multiple sessions on a profile name...
00091   LONG    GetSessionCount( ) { return m_sessionCount; } ;
00092   void    IncrementSessionCount() { ++m_sessionCount; } ;
00093   void    DecrementSessionCount() { --m_sessionCount; } ;
00094 
00095   // Information retrieval stuff...
00096   LPSTR   GetProfileName( ) { return (LPSTR) m_profileName; };
00097   LPSTR   GetPassword( ) { return (LPSTR) m_password; };
00098 
00099   // Dealing with message information...
00100   void    SetMessageIndex( LONG mIndex ) { m_messageIndex = mIndex; } ;
00101   LONG    GetMessageIndex( ) { return m_messageIndex; };
00102 
00103   void    SetMessageFindInfo( LPSTR info ) { lstrcpy((LPSTR)m_messageFindInfo, info); } ;
00104   LPSTR   GetMessageFindInfo( ) { return (LPSTR) m_messageFindInfo; };
00105 
00106   // For enumerating Messages...
00107   void    SetMapiListContext( LPVOID cookie) { m_cookie = cookie; } ;
00108   LPVOID  GetMapiListContext( ) { return m_cookie; };
00109 };
00110 
00111 //
00112 // Defines needed for requests being made with the WM_COPYDATA call...
00113 //
00114 typedef enum {
00115     NSCP_MAPIStartRequestID = 0,
00116     NSCP_MAPILogon,
00117     NSCP_MAPILogoff,
00118     NSCP_MAPIFree,
00119     NSCP_MAPISendMail,
00120     NSCP_MAPISendDocuments, 
00121     NSCP_MAPIFindNext,
00122     NSCP_MAPIReadMail,
00123     NSCP_MAPISaveMail,
00124     NSCP_MAPIDeleteMail,
00125     NSCP_MAPIAddress,
00126     NSCP_MAPIDetails,
00127     NSCP_MAPIResolveName,
00128     NSCP_MAPIEndRequestID       // Note: this is a marker for MAPI IPC requests
00129 } NSCP_IPC_REQUEST;
00130 
00131 //
00132 // This is to keep track of the pointers allocated in the MAPI DLL
00133 // and deal with them correctly.
00134 //
00135 #define   MAPI_MESSAGE_TYPE     0
00136 #define   MAPI_RECIPIENT_TYPE   1
00137  
00138 typedef struct {
00139   LPVOID    lpMem;
00140   UCHAR     memType;
00141 } memTrackerType;
00142 
00143 //
00144 // This is the generic message that WM_COPYDATA will send to the
00145 // Communicator product to allow it to attach to shared memory.
00146 // NOTE: On Win16, this will simply reference a pointer.
00147 //
00148 typedef struct {
00149   UCHAR   smemName[64]; // Name of shared memory
00150   DWORD   smemSize;     // Size of shared memory
00151   LPVOID  lpsmem;       // Will be really used in Win16 only
00152 } MAPIIPCType;
00153 
00154 //
00155 // These are message specific structures that will be used for 
00156 // the various MAPI operations.
00157 //
00158 typedef struct {
00159   ULONG     ulUIParam;
00160   FLAGS     flFlags;
00161   LHANDLE   lhSession;
00162   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
00163 // LPSTR     strSequence,  // LPSTR lpszProfileName, LPSTR lpszPassword
00164 // This is here to document the fact there will be a string sequence at 
00165 // this location
00166 } MAPILogonType;
00167 
00168 typedef struct {
00169   LHANDLE   lhSession;
00170   ULONG     ulUIParam;
00171   FLAGS     flFlags;
00172   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
00173 } MAPILogoffType;
00174 
00175 typedef struct {
00176   LHANDLE   lhSession;
00177   ULONG     ulUIParam;
00178   FLAGS     flFlags;
00179   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
00180   // The following is the "FLAT" representation of the (lpMapiMessage lpMessage) 
00181   // argument of this structure 
00182   FLAGS     MSG_flFlags;          // unread,return receipt                  
00183   ULONG     MSG_nRecipCount;      // Number of recipients                   
00184   ULONG     MSG_nFileCount;       // # of file attachments                  
00185   ULONG     MSG_ORIG_ulRecipClass; //  Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
00186   BYTE      dataBuf[1];           // For easy referencing
00187   //
00188   // This is where it gets CONFUSING...the following buffer of memory is a
00189   // contiguous chunk of memory for various strings that are part of this
00190   // multilevel structure. For any of the following structure, any numbers
00191   // are represented by strings that will have to be converted back to numeric
00192   // values with atoi() calls.
00193 
00194   // String 0: LPSTR lpszSubject;            // Message Subject
00195   // String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
00196   //           stored into a temp file and this will be the pointer to that file.
00197   // String 2: LPSTR lpszDateReceived;       // in YYYY/MM/DD HH:MM format
00198   // String 3: LPSTR lpszConversationID;     // conversation thread ID
00199   //
00200   // The following are for the originator of the message. Only ONE of these.
00201   //
00202   // String 4: LPSTR lpszName;             // Originator name                           
00203   // String 5: LPSTR lpszAddress;          // Originator address (optional)             
00204   //
00205   // The following strings are for the recipients for this message. There are
00206   // MSG_nRecipCount of these in a row:
00207   //
00208   // for (i=0; i<MSG_nRecipCount; i++)
00209   //      String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG        
00210   //      String x: LPSTR lpszName;     // Recipient N name                           
00211   //      String x: LPSTR lpszAddress;  // Recipient N address (optional)             
00212   //
00213   // Now, finally, add the attachments for this beast. There are MSG_nFileCount
00214   // attachments so it would look like the following:
00215   //
00216   // for (i=0; i<MSG_nFileCount; i++)
00217   //
00218   //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
00219   //                                   // This path should include the disk drive letter and directory name.
00220   //      String x: LPSTR lpszFileName // The display name for the attached file
00221   //
00222 } MAPISendMailType;
00223 
00224 typedef struct {
00225     ULONG     ulUIParam;
00226     ULONG     nFileCount;
00227     DWORD     ipcWorked;      // Necessary for IPC check with Communicator
00228     BYTE      dataBuf[1];     // For easy referencing
00229     //
00230     // The sequence of strings to follow are groups of PathName/FileName couples.
00231     // The strings will be parsed in MAPI[32].DLL and then put into this format:
00232     //
00233     // for (i=0; i<nFileCount; i++)
00234     //
00235     //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
00236     //                                   // This path should include the disk drive letter and directory name.
00237     //      String x: LPSTR lpszFileName // The display name for the attached file
00238 } MAPISendDocumentsType;
00239 
00240 typedef struct {
00241   LHANDLE     lhSession;
00242   ULONG       ulUIParam;
00243   FLAGS       flFlags;
00244   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
00245   UCHAR       lpszSeedMessageID[MAX_MSGINFO_LEN];
00246   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
00247 } MAPIFindNextType;
00248 
00249 typedef struct {
00250   LHANDLE     lhSession;
00251   ULONG       ulUIParam;
00252   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
00253   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
00254 } MAPIDeleteMailType;
00255 
00256 typedef struct {
00257   LHANDLE     lhSession;
00258   ULONG       ulUIParam;
00259   FLAGS       flFlags;
00260   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
00261   UCHAR       lpszName[MAX_NAME_LEN];
00262   // These are returned by Communicator
00263   UCHAR       lpszABookID[MAX_NAME_LEN];         
00264   UCHAR       lpszABookName[MAX_NAME_LEN];            
00265   UCHAR       lpszABookAddress[MAX_NAME_LEN];         
00266 } MAPIResolveNameType;
00267 
00268 typedef struct {
00269   LHANDLE     lhSession;
00270   ULONG       ulUIParam;
00271   FLAGS       flFlags;
00272   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
00273   UCHAR       lpszABookID[MAX_NAME_LEN];
00274 } MAPIDetailsType;
00275 
00276 typedef struct {
00277   LHANDLE     lhSession;
00278   ULONG       ulUIParam;
00279   FLAGS       flFlags;
00280   DWORD       ipcWorked;      // Necessary for IPC check with Communicator
00281   UCHAR       lpszMessageID[MAX_MSGINFO_LEN];
00282   //
00283   // The following is the "FLAT" representation of the (lpMapiMessage lpMessage) 
00284   // argument of this structure 
00285   //
00286   FLAGS     MSG_flFlags;          // unread, return or receipt                  
00287   ULONG     MSG_nRecipCount;      // Number of recipients                   
00288   ULONG     MSG_nFileCount;       // # of file attachments                  
00289   ULONG     MSG_ORIG_ulRecipClass; //  Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
00290   //
00291   // Output parameter for blob of information that will live on disk. 
00292   //
00293   UCHAR       lpszBlob[MAX_MSGINFO_LEN];    // file name on disk
00294   //
00295   // The format of this blob of information will be:
00296   //
00297   // String 0: LPSTR lpszSubject;            // Message Subject
00298   // String 1: LPSTR lpszNoteText FILE NAME; // Message Text will be
00299   //           stored into a temp file and this will be the pointer to that file.
00300   // String 2: LPSTR lpszDateReceived;       // in YYYY/MM/DD HH:MM format
00301   // String 3: LPSTR lpszConversationID;     // conversation thread ID
00302   //
00303   // The following are for the originator of the message. Only ONE of these.
00304   //
00305   // String 4: LPSTR lpszName;             // Originator name                           
00306   // String 5: LPSTR lpszAddress;          // Originator address (optional)             
00307   //
00308   // The following strings are for the recipients for this message. There are
00309   // MSG_nRecipCount of these in a row:
00310   //
00311   // for (i=0; i<MSG_nRecipCount; i++)
00312   //      String x: LPSTR lpszName;             // Recipient N name                           
00313   //      String x: LPSTR lpszAddress;          // Recipient N address (optional)             
00314   //      String x: LPSTR lpszRecipClass        // recipient class - sprintf of ULONG
00315   //
00316   // Now, finally, add the attachments for this beast. There are MSG_nFileCount
00317   // attachments so it would look like the following:
00318   //
00319   // for (i=0; i<MSG_nFileCount; i++)
00320   //
00321   //      String x: LPSTR lpszPathName // Fully qualified path of the attached file. 
00322   //                                   // This path should include the disk drive letter and directory name.
00323   //      String x: LPSTR lpszFileName // The display name for the attached file
00324   //
00325 } MAPIReadMailType;
00326 
00327 typedef struct {
00328   LHANDLE   lhSession;
00329   ULONG     ulUIParam;
00330   FLAGS     flFlags;
00331   UCHAR     lpszCaption[MAX_MSGINFO_LEN];
00332   DWORD     ipcWorked;      // Necessary for IPC check with Communicator
00333   // The following is the "FLAT" representation of the (lpMapiRecipDesc lpRecips) 
00334   // argument of this structure 
00335   ULONG     nRecips;              // number of recips to start with...
00336   ULONG     nNewRecips;           // number of recips returned...
00337   UCHAR     lpszBlob[MAX_MSGINFO_LEN];    // file name for blob of information 
00338                                           // that will live on disk. 
00339   BYTE      dataBuf[1];           // For easy referencing
00340   //
00341   // The following contiguous chunk of memory is the buffer that holds 
00342   // the recipients to load into the address picker...
00343   //
00344   // for (i=0; i<MSG_nRecipCount; i++)
00345   //      String x: LPSTR lpszRecipClass (ULONG) // Recipient class - MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG        
00346   //      String x: LPSTR lpszName;     // Recipient N name                           
00347   //      String x: LPSTR lpszAddress;  // Recipient N address (optional)             
00348   //
00349 } MAPIAddressType;
00350 
00351 #endif    // _NSCPMAPI