1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Netscape Public License
5
* Version 1.1 (the "License"); you may not use this file except in
6
* compliance with the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/NPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is Mozilla Communicator client code.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1998
19
* the Initial Developer. All Rights Reserved.
22
* Joe Hewitt <hewitt@netscape.com> (Original Author)
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
38
#ifndef __nsFormHistory__
39
#define __nsFormHistory__
41
#include "nsIFormHistory.h"
42
#include "nsIAutoCompleteResultTypes.h"
43
#include "nsIFormSubmitObserver.h"
46
#include "nsIObserver.h"
47
#include "nsIPrefBranch.h"
48
#include "nsWeakReference.h"
51
class nsFormHistory : public nsIFormHistory,
53
public nsIFormSubmitObserver,
54
public nsSupportsWeakReference
58
NS_DECL_NSIFORMHISTORY
61
// nsIFormSubmitObserver
62
NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindowInternal* window, nsIURI* actionURL, PRBool* cancelSubmit);
65
virtual ~nsFormHistory();
68
static nsFormHistory *GetInstance();
69
static void ReleaseInstance(void);
71
nsresult AutoCompleteSearch(const nsAString &aInputName, const nsAString &aInputValue,
72
nsIAutoCompleteMdbResult *aPrevResult, nsIAutoCompleteResult **aNewResult);
74
static mdb_column kToken_ValueColumn;
75
static mdb_column kToken_NameColumn;
79
nsresult OpenDatabase();
80
nsresult OpenExistingFile(const char *aPath);
81
nsresult CreateNewFile(const char *aPath);
82
nsresult CloseDatabase();
83
nsresult CreateTokens();
85
nsresult CopyRowsFromTable(nsIMdbTable *sourceTable);
87
mdb_err UseThumb(nsIMdbThumb *aThumb, PRBool *aDone);
89
nsresult AppendRow(const nsAString &aValue, const nsAString &aName, nsIMdbRow **aResult);
90
nsresult SetRowValue(nsIMdbRow *aRow, mdb_column aCol, const nsAString &aValue);
91
nsresult GetRowValue(nsIMdbRow *aRow, mdb_column aCol, nsAString &aValue);
93
PRBool RowMatch(nsIMdbRow *aRow, const nsAString &aInputName, const nsAString &aInputValue, PRUnichar **aValue);
95
PR_STATIC_CALLBACK(int) SortComparison(const void *v1, const void *v2, void *closureVoid);
97
nsresult EntriesExistInternal(const nsAString *aName, const nsAString *aValue, PRBool *_retval);
99
nsresult RemoveEntriesInternal(const nsAString *aName);
101
static PRBool FormHistoryEnabled();
103
static nsFormHistory *gFormHistory;
105
static PRBool gFormHistoryEnabled;
106
static PRBool gPrefsInitialized;
108
nsCOMPtr<nsIMdbFactory> mMdbFactory;
109
nsCOMPtr<nsIPrefBranch> mPrefBranch;
113
PRInt64 mFileSizeOnDisk;
116
mdb_scope kToken_RowScope;
117
mdb_kind kToken_Kind;
120
#endif // __nsFormHistory__