Back to index

lightning-sunbird  0.9+nobinonly
nsNNTPNewsgroupPost.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef __nsNNTPNewsgroupPost_h
00039 #define __nsNNTPNewsgroupPost_h
00040 
00041 #include "msgCore.h"
00042 #include "nsINNTPNewsgroupPost.h"
00043 #include "nsCOMPtr.h"
00044 #include "nsIFileSpec.h"
00045 #include "prmem.h"
00046 #include "nsISupportsObsolete.h"
00047 
00048 #define IDX_HEADER_FROM             0
00049 #define IDX_HEADER_NEWSGROUPS       1
00050 #define IDX_HEADER_SUBJECT          2
00051 
00052 // set this to the last required header
00053 #define IDX_HEADER_LAST_REQUIRED    IDX_HEADER_SUBJECT
00054 
00055 #define IDX_HEADER_PATH             3
00056 #define IDX_HEADER_DATE             4
00057 
00058 #define IDX_HEADER_REPLYTO          5
00059 #define IDX_HEADER_SENDER           6
00060 #define IDX_HEADER_FOLLOWUPTO       7
00061 #define IDX_HEADER_DATERECEIVED     8
00062 #define IDX_HEADER_EXPIRES          9
00063 #define IDX_HEADER_CONTROL          10
00064 #define IDX_HEADER_DISTRIBUTION     11
00065 #define IDX_HEADER_ORGANIZATION     12
00066 #define IDX_HEADER_REFERENCES       13
00067 
00068 // stuff that's required to be in the message,
00069 // but probably generated on the server
00070 #define IDX_HEADER_RELAYVERSION     14
00071 #define IDX_HEADER_POSTINGVERSION   15
00072 #define IDX_HEADER_MESSAGEID        16
00073 
00074 // keep this in sync with the above
00075 #define HEADER_LAST                 IDX_HEADER_MESSAGEID
00076 
00077 class nsNNTPNewsgroupPost : public nsINNTPNewsgroupPost {
00078     
00079 public:
00080     nsNNTPNewsgroupPost();
00081     virtual ~nsNNTPNewsgroupPost();
00082     
00083     NS_DECL_ISUPPORTS
00084     
00085     // Required headers
00086     NS_IMPL_CLASS_GETSET_STR(RelayVersion, m_header[IDX_HEADER_RELAYVERSION]);
00087     NS_IMPL_CLASS_GETSET_STR(PostingVersion, m_header[IDX_HEADER_POSTINGVERSION]);
00088     NS_IMPL_CLASS_GETSET_STR(From, m_header[IDX_HEADER_FROM]);
00089     NS_IMPL_CLASS_GETSET_STR(Date, m_header[IDX_HEADER_DATE]);
00090     NS_IMPL_CLASS_GETSET_STR(Subject, m_header[IDX_HEADER_SUBJECT]);
00091 
00092     NS_IMPL_CLASS_GETTER_STR(GetNewsgroups, m_header[IDX_HEADER_NEWSGROUPS]); 
00093     NS_IMPL_CLASS_GETSET_STR(Path, m_header[IDX_HEADER_PATH]);
00094 
00095     // Optional Headers
00096     NS_IMPL_CLASS_GETSET_STR(ReplyTo, m_header[IDX_HEADER_REPLYTO]);
00097     NS_IMPL_CLASS_GETSET_STR(Sender, m_header[IDX_HEADER_SENDER]);
00098     NS_IMPL_CLASS_GETSET_STR(FollowupTo, m_header[IDX_HEADER_FOLLOWUPTO]);
00099     NS_IMPL_CLASS_GETSET_STR(DateRecieved, m_header[IDX_HEADER_DATERECEIVED]);
00100     NS_IMPL_CLASS_GETSET_STR(Expires, m_header[IDX_HEADER_EXPIRES]);
00101     NS_IMPL_CLASS_GETSET_STR(Control, m_header[IDX_HEADER_CONTROL]);
00102     NS_IMPL_CLASS_GETSET_STR(Distribution, m_header[IDX_HEADER_DISTRIBUTION]);
00103     NS_IMPL_CLASS_GETSET_STR(Organization, m_header[IDX_HEADER_ORGANIZATION]);
00104     NS_IMPL_CLASS_GETSET_STR(Body, m_body);    
00105     NS_IMPL_CLASS_GETTER_STR(GetReferences, m_header[IDX_HEADER_REFERENCES]);
00106 
00107     NS_IMPL_CLASS_GETTER(GetIsControl, PRBool, m_isControl);
00108 
00109     // the message can be stored in a file....allow accessors for getting and setting
00110     // the file name to post...
00111     NS_IMETHOD SetPostMessageFile(nsIFileSpec * aFileName);
00112     NS_IMETHOD GetPostMessageFile(nsIFileSpec ** aFileName);
00113 
00114     NS_IMETHOD AddNewsgroup(const char *newsgroupName);
00115     
00116 private:
00117     nsIFileSpec *m_postMessageFile;
00118     char *m_header[HEADER_LAST+1];
00119     char *m_body;
00120     char *m_messageBuffer;
00121     PRBool m_isControl;
00122 };
00123 
00124 #endif /* __nsNNTPNewsgroupPost_h */