Back to index

lightning-sunbird  0.9+nobinonly
msgMapiMain.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corp.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef MSG_MAPI_MAIN_H_
00038 #define NSG_MAPI_MAIN_H_
00039 
00040 #define        MAX_NAME_LEN    256
00041 #define        MAX_PW_LEN      256
00042 #define        MAX_SESSIONS    50
00043 #define        MAPI_SENDCOMPLETE_EVENT   "SendCompletionEvent"
00044 
00045 #define MAPI_PROPERTIES_CHROME "chrome://messenger-mapi/locale/mapi.properties"
00046 #define PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND "mapi.blind-send.warn"
00047 #define PREF_MAPI_BLIND_SEND_ENABLED "mapi.blind-send.enabled"
00048 
00049 #include "nsXPIDLString.h"
00050 #include "nspr.h"
00051 #include "nsString.h"
00052 #include "nsHashtable.h"
00053 
00054 class nsMAPIConfiguration
00055 {
00056 private :
00057 
00058     static PRUint32 session_generator;
00059     static PRUint32 sessionCount;
00060     static nsMAPIConfiguration *m_pSelfRef;
00061     PRLock *m_Lock;
00062     PRUint32  m_nMaxSessions;
00063 
00064 
00065     nsHashtable m_ProfileMap;
00066     nsHashtable m_SessionMap;
00067     nsMAPIConfiguration();
00068 
00069 public :
00070     static nsMAPIConfiguration *GetMAPIConfiguration();
00071     void OpenConfiguration();
00072     PRInt16 RegisterSession(PRUint32 aHwnd, const PRUnichar *aUserName, \
00073                             const PRUnichar *aPassword, PRBool aForceDownLoad, \
00074                             PRBool aNewSession, PRUint32 *aSession, char *aIdKey);
00075     PRBool IsSessionValid(PRUint32 aSessionID);
00076     PRBool UnRegisterSession(PRUint32 aSessionID);
00077     PRUnichar *GetPassword(PRUint32 aSessionID);
00078     char *GetIdKey(PRUint32 aSessionID);
00079     void *GetMapiListContext(PRUint32 aSessionID);
00080     void SetMapiListContext(PRUint32 aSessionID, void *mapiListContext);
00081     ~nsMAPIConfiguration();
00082 
00083     // a util func
00084     static HRESULT GetMAPIErrorFromNSError (nsresult res) ;
00085 };
00086 
00087 class nsMAPISession
00088 {
00089     friend class nsMAPIConfiguration;
00090 
00091     private :
00092 
00093         PRBool   m_bIsForcedDownLoad;
00094         PRBool   m_bApp_or_Service;
00095         PRUint32 m_hAppHandle;
00096         PRUint32 m_nShared;
00097         char     *m_pIdKey;
00098         nsString m_pProfileName;
00099         nsString m_pPassword;
00100         PRInt32 m_messageIndex;
00101         void   *m_listContext; // used by findNext
00102 
00103     public :
00104 
00105         nsMAPISession(PRUint32 aHwnd, const PRUnichar *aUserName, \
00106                       const PRUnichar *aPassword, \
00107                       PRBool aForceDownLoad, char *aKey);
00108         PRUint32 IncrementSession();
00109         PRUint32 DecrementSession();
00110         PRUint32 GetSessionCount();
00111         PRUnichar *nsMAPISession::GetPassword();
00112         char *nsMAPISession::GetIdKey();
00113         ~nsMAPISession();
00114         // For enumerating Messages...
00115         void SetMapiListContext( void *listContext) { m_listContext = listContext; } 
00116         void *GetMapiListContext( ) { return m_listContext; }
00117 };
00118 
00119 #endif    // MSG_MAPI_MAIN_H_