Back to index

lightning-sunbird  0.9+nobinonly
msgCore.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; 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 /* Include files we are going to want available to all files....these files include
00039    NSPR, memory, and string header files among others */
00040 
00041 #ifndef msgCore_h__
00042 #define msgCore_h__
00043 
00044 #include "nscore.h"
00045 
00046 #include "nsCRT.h"
00047 #include "nsString.h"
00048 #include "nsVoidArray.h"
00049 
00050 class nsIMsgDBHdr;
00051 class nsIMsgFolder;
00052 
00053 // include common interfaces such as the service manager and the repository....
00054 #include "nsIServiceManager.h"
00055 #include "nsIComponentManager.h"
00056 
00057 /*
00058  * These are folder property strings, which are used in several places.
00059 
00060  */
00061 #define MRU_TIME_PROPERTY "MRUTime"
00062 
00063 /* NS_ERROR_MODULE_MAILNEWS is defined in mozilla/xpcom/public/nsError.h */
00064 
00065 /*
00066  * NS_ERROR macros - use these macros to generate error constants
00067  * to be used by XPCOM interfaces and possibly other useful things
00068  * do not use these macros in your code - declare error macros for
00069  * each specific error you need.
00070  *
00071  * for example:
00072  * #define NS_MSG_ERROR_NO_SUCH_FOLDER NS_MSG_GENERATE_FAILURE(4)
00073  * 
00074  */
00075 
00076 /* use these routines to generate error values */
00077 #define NS_MSG_GENERATE_RESULT(severity, value) \
00078 NS_ERROR_GENERATE(severity, NS_ERROR_MODULE_MAILNEWS, value)
00079 
00080 #define NS_MSG_GENERATE_SUCCESS(value) \
00081 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MAILNEWS, value)
00082 
00083 #define NS_MSG_GENERATE_FAILURE(value) \
00084 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MAILNEWS, value)
00085 
00086 /* these are shortcuts to generate simple errors with a zero value */
00087 #define NS_MSG_SUCCESS NS_MSG_GENERATE_SUCCESS(0)
00088 #define NS_MSG_FAILURE NS_MSG_GENERATE_FAILURE(0)
00089 
00090 #define IS_SPACE(VAL) NS_IS_SPACE(VAL)
00091 #define IS_DIGIT(i)   NS_IS_DIGIT(i)
00092 #define IS_ALPHA(VAL) NS_IS_ALPHA(VAL)
00093 
00094 
00095 /* for retrieving information out of messenger nsresults */
00096 
00097 #define NS_IS_MSG_ERROR(err) \
00098  (NS_ERROR_GET_MODULE(err) == NS_ERROR_MODULE_MAILNEWS)
00099 
00100 #define NS_MSG_SUCCEEDED(err) \
00101  (NS_IS_MSG_ERROR(err) && NS_SUCCEEDED(err))
00102 
00103 #define NS_MSG_FAILED(err) \
00104  (NS_IS_MSG_ERROR(err) && NS_FAILED(err))
00105 
00106 #define NS_MSG_PASSWORD_PROMPT_CANCELLED NS_MSG_GENERATE_SUCCESS(1)
00107 
00108 /* This is where we define our errors. There has to be a central
00109    place so we don't use the same error codes for different errors.
00110 */
00111 #define NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE NS_MSG_GENERATE_FAILURE(5)
00112 #define NS_MSG_ERROR_FOLDER_SUMMARY_MISSING NS_MSG_GENERATE_FAILURE(6)
00113 #define NS_MSG_ERROR_FOLDER_MISSING NS_MSG_GENERATE_FAILURE(7)
00114 
00115 #define NS_MSG_MESSAGE_NOT_FOUND NS_MSG_GENERATE_FAILURE(8)
00116 #define NS_MSG_NOT_A_MAIL_FOLDER NS_MSG_GENERATE_FAILURE(9)
00117 
00118 #define NS_MSG_FOLDER_BUSY NS_MSG_GENERATE_FAILURE(10)
00119 
00120 #define NS_MSG_COULD_NOT_CREATE_DIRECTORY NS_MSG_GENERATE_FAILURE(11)
00121 #define NS_MSG_CANT_CREATE_FOLDER NS_MSG_GENERATE_FAILURE(12)
00122 
00123 #define NS_MSG_FILTER_PARSE_ERROR NS_MSG_GENERATE_FAILURE(13)
00124 
00125 #define NS_MSG_FOLDER_UNREADABLE NS_MSG_GENERATE_FAILURE(14)
00126 
00127 #define NS_MSG_ERROR_WRITING_MAIL_FOLDER NS_MSG_GENERATE_FAILURE(15)
00128 
00129 #define NS_MSG_ERROR_NO_SEARCH_VALUES NS_MSG_GENERATE_FAILURE(16)
00130 
00131 #define NS_MSG_ERROR_INVALID_SEARCH_SCOPE NS_MSG_GENERATE_FAILURE(17)
00132 
00133 #define NS_MSG_ERROR_INVALID_SEARCH_TERM NS_MSG_GENERATE_FAILURE(18)
00134 
00135 #define NS_MSG_FOLDER_EXISTS NS_MSG_GENERATE_FAILURE(19)
00136 
00137 #define NS_MSG_ERROR_OFFLINE NS_MSG_GENERATE_FAILURE(20)
00138 
00139 #define NS_MSG_POP_FILTER_TARGET_ERROR NS_MSG_GENERATE_FAILURE(21)
00140 
00141 #define NS_MSG_INVALID_OR_MISSING_SERVER NS_MSG_GENERATE_FAILURE(22)
00142 
00143 #define NS_MSG_SERVER_USERNAME_MISSING NS_MSG_GENERATE_FAILURE(23)
00144 
00145 #define NS_MSG_INVALID_DBVIEW_INDEX NS_MSG_GENERATE_FAILURE(24)
00146 
00147 #define NS_MSG_NEWS_ARTICLE_NOT_FOUND NS_MSG_GENERATE_FAILURE(25)
00148 
00149 #define NS_MSG_ERROR_COPY_FOLDER_ABORTED NS_MSG_GENERATE_FAILURE(26)
00150 // this error means a url was queued but never run because one of the urls
00151 // it was queued after failed. We send an OnStopRunningUrl with this error code 
00152 // so the listeners can know that we didn't run the url.
00153 #define NS_MSG_ERROR_URL_ABORTED NS_MSG_GENERATE_FAILURE(27)
00154 /* ducarroz: error codes for message compose are defined into compose\src\nsMsgComposeStringBundle.h.
00155              Message compose use the same error code space than other mailnews modules. To avoid any
00156              conflict, I reserve values between 12500 and 12999 for it.
00157 */
00158 #define NS_MSG_CUSTOM_HEADERS_OVERFLOW NS_MSG_GENERATE_FAILURE(28) //when num of custom headers exceeds 50
00159 #define NS_MSG_INVALID_CUSTOM_HEADER NS_MSG_GENERATE_FAILURE(29) //when custom header has invalid characters (as per rfc 2822) 
00160 
00161 #define NS_MSG_USER_NOT_AUTHENTICATED NS_MSG_GENERATE_FAILURE(30) // when local caches are password protect and user isn't auth
00162 
00163 #define NS_MSG_ERROR_COPYING_FROM_TMP_DOWNLOAD NS_MSG_GENERATE_FAILURE(31) // pop3 downloaded to tmp file, and failed.
00164 
00165 #define NS_MSGCOMP_ERROR_BEGIN     12500
00166 /* NS_ERROR_NNTP_NO_CROSS_POSTING lives here, and not in nsMsgComposeStringBundle.h, because it is used in news and compose. */
00167 #define NS_ERROR_NNTP_NO_CROSS_POSTING NS_MSG_GENERATE_FAILURE(12554)
00168 #define NS_MSGCOMP_ERROR_END       12999
00169 
00170 #define MSG_LINEBREAK NS_LINEBREAK
00171 #define MSG_LINEBREAK_LEN NS_LINEBREAK_LEN
00172 
00173 #ifdef MOZ_STATIC_MAIL_BUILD
00174 #define NS_MSG_BASE
00175 #define NS_MSG_BASE_STATIC_MEMBER_(type) type
00176 #else
00177 
00178 #ifdef _IMPL_NS_MSG_BASE
00179 #define NS_MSG_BASE                      NS_EXPORT
00180 #define NS_MSG_BASE_STATIC_MEMBER_(type) NS_EXPORT_STATIC_MEMBER_(type)
00181 #else
00182 #define NS_MSG_BASE                      NS_IMPORT
00183 #define NS_MSG_BASE_STATIC_MEMBER_(type) NS_IMPORT_STATIC_MEMBER_(type)
00184 #endif
00185 
00186 #endif // MOZ_STATIC_MAIL_BUILD
00187 
00189 // Utilities 
00190 
00191 // mscott: one wouldn't normally have to add the NS_MSG_BASE prefix here 
00192 // except this function is implemented in base\util.
00193 nsresult NS_MSG_BASE
00194 nsGetMailFolderSeparator(nsString& result);
00195 
00197 
00198 #endif