Back to index

lightning-sunbird  0.9+nobinonly
nsIFormProcessor.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) 1999
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 
00045 #ifndef nsIFormProcessor_h__
00046 #define nsIFormProcessor_h__
00047 
00048 #include "nsISupports.h"
00049 #include "prtypes.h"
00050 
00051 #include "nsIDOMHTMLInputElement.h"
00052 
00053 class nsString;
00054 class nsVoidArray;
00055 
00056 // {0ae53c0f-8ea2-4916-bedc-717443c3e185}
00057 #define NS_FORMPROCESSOR_CID \
00058 { 0x0ae53c0f, 0x8ea2, 0x4916, { 0xbe, 0xdc, 0x71, 0x74, 0x43, 0xc3, 0xe1, 0x85 } }
00059 
00060 #define NS_FORMPROCESSOR_CONTRACTID "@mozilla.org/layout/form-processor;1"
00061 
00062 // 4ff86376-6982-4f64-a683-a6ae4984afd7
00063 #define NS_IFORMPROCESSOR_IID      \
00064 { 0x4ff86376, 0x6982, 0x4f64, { 0xa6, 0x83, 0xa6, 0xae, 0x49, 0x84, 0xaf, 0xd7 } }
00065 
00066 
00067 
00068 // XXX:In the future, we should examine combining this interface with nsIFormSubmitObserver.
00069 // nsIFormSubmitObserver could have a before, during, and after form submission methods.
00070 // The before and after methods would be passed a nsISupports interface. The During would
00071 // Have the same method signature as ProcessValue.
00072 
00073 
00074 class nsIFormProcessor : public nsISupports {
00075 public:
00076   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMPROCESSOR_IID)
00077 
00078   /* ProcessValue is called for each name value pair that is 
00079    * about to be submitted for both "get" and "post" form submissions.
00080    *
00081    * The formprocessor is registered as a service that gets called for
00082    * every form submission.
00083    *
00084    *   @param aElement element which the attribute/value pair is submitted for
00085    *   @param aName    value of the form element name attribute about to be submitted
00086    *   @param aValue   On entry it contains the value about to be submitted for aName. 
00087    *                   On exit it contains the value which will actually be submitted for aName.
00088    *                   
00089    */
00090   NS_IMETHOD ProcessValue(nsIDOMHTMLElement *aElement, 
00091                           const nsAString& aName,
00092                           nsAString& aValue) = 0;
00093 
00094   /* Provide content for a form element. This method provides a mechanism to provide 
00095    * content which comes from a source other than the document (i.e. a local database)
00096    *  
00097    *   @param aFormType   Type of form to get content for.
00098    *   @param aOptions    List of nsStrings which define the contents for the form element
00099    *   @param aAttr       Attribute to be attached to the form element. It is used to identify
00100    *                      the form element contains non-standard content.
00101    */
00102 
00103   NS_IMETHOD ProvideContent(const nsAString& aFormType, 
00104                             nsVoidArray& aContent,
00105                             nsAString& aAttribute) = 0;
00106 
00107 };
00108 
00109 #endif /* nsIFormProcessor_h__ */
00110