~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/toolkit/components/satchel/src/nsFormHistory.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
3
 *
 
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/
 
8
 *
 
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
 
12
 * License.
 
13
 *
 
14
 * The Original Code is Mozilla Communicator client code.
 
15
 *
 
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.
 
20
 *
 
21
 * Contributor(s):
 
22
 *   Joe Hewitt <hewitt@netscape.com> (Original Author)
 
23
 *
 
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.
 
35
 *
 
36
 * ***** END LICENSE BLOCK ***** */
 
37
 
 
38
#ifndef __nsFormHistory__
 
39
#define __nsFormHistory__
 
40
 
 
41
#include "nsIFormHistory.h"
 
42
#include "nsIAutoCompleteResultTypes.h"
 
43
#include "nsIFormSubmitObserver.h"
 
44
#include "nsString.h"
 
45
#include "nsCOMPtr.h"
 
46
#include "nsIObserver.h"
 
47
#include "nsIPrefBranch.h"
 
48
#include "nsWeakReference.h"
 
49
#include "mdb.h"
 
50
 
 
51
class nsFormHistory : public nsIFormHistory,
 
52
                      public nsIObserver,
 
53
                      public nsIFormSubmitObserver,
 
54
                      public nsSupportsWeakReference
 
55
{
 
56
public:
 
57
  NS_DECL_ISUPPORTS
 
58
  NS_DECL_NSIFORMHISTORY
 
59
  NS_DECL_NSIOBSERVER
 
60
  
 
61
  // nsIFormSubmitObserver
 
62
  NS_IMETHOD Notify(nsIContent* formNode, nsIDOMWindowInternal* window, nsIURI* actionURL, PRBool* cancelSubmit);
 
63
 
 
64
  nsFormHistory();
 
65
  virtual ~nsFormHistory();
 
66
  nsresult Init();
 
67
 
 
68
  static nsFormHistory *GetInstance();
 
69
  static void ReleaseInstance(void);
 
70
 
 
71
  nsresult AutoCompleteSearch(const nsAString &aInputName, const nsAString &aInputValue,
 
72
                              nsIAutoCompleteMdbResult *aPrevResult, nsIAutoCompleteResult **aNewResult);
 
73
 
 
74
  static mdb_column kToken_ValueColumn;
 
75
  static mdb_column kToken_NameColumn;
 
76
 
 
77
protected:
 
78
  // Database I/O
 
79
  nsresult OpenDatabase();
 
80
  nsresult OpenExistingFile(const char *aPath);
 
81
  nsresult CreateNewFile(const char *aPath);
 
82
  nsresult CloseDatabase();
 
83
  nsresult CreateTokens();
 
84
  nsresult Flush();
 
85
  nsresult CopyRowsFromTable(nsIMdbTable *sourceTable);
 
86
  
 
87
  mdb_err UseThumb(nsIMdbThumb *aThumb, PRBool *aDone);
 
88
  
 
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);
 
92
  
 
93
  PRBool RowMatch(nsIMdbRow *aRow, const nsAString &aInputName, const nsAString &aInputValue, PRUnichar **aValue);
 
94
  
 
95
  PR_STATIC_CALLBACK(int) SortComparison(const void *v1, const void *v2, void *closureVoid);
 
96
 
 
97
  nsresult EntriesExistInternal(const nsAString *aName, const nsAString *aValue, PRBool *_retval);
 
98
 
 
99
  nsresult RemoveEntriesInternal(const nsAString *aName);
 
100
 
 
101
  static PRBool FormHistoryEnabled();
 
102
 
 
103
  static nsFormHistory *gFormHistory;
 
104
 
 
105
  static PRBool gFormHistoryEnabled;
 
106
  static PRBool gPrefsInitialized;
 
107
 
 
108
  nsCOMPtr<nsIMdbFactory> mMdbFactory;
 
109
  nsCOMPtr<nsIPrefBranch> mPrefBranch;
 
110
  nsIMdbEnv* mEnv;
 
111
  nsIMdbStore* mStore;
 
112
  nsIMdbTable* mTable;
 
113
  PRInt64 mFileSizeOnDisk;
 
114
  
 
115
  // database tokens
 
116
  mdb_scope kToken_RowScope;
 
117
  mdb_kind kToken_Kind;
 
118
};
 
119
 
 
120
#endif // __nsFormHistory__