toolkit/components/places/nsNavHistoryQuery.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:b81955812f51
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /**
7 * The definitions of nsNavHistoryQuery and nsNavHistoryQueryOptions. This
8 * header file should only be included from nsNavHistory.h, include that if
9 * you want these classes.
10 */
11
12 #ifndef nsNavHistoryQuery_h_
13 #define nsNavHistoryQuery_h_
14
15 // nsNavHistoryQuery
16 //
17 // This class encapsulates the parameters for basic history queries for
18 // building UI, trees, lists, etc.
19
20 #include "mozilla/Attributes.h"
21
22 #define NS_NAVHISTORYQUERY_IID \
23 { 0xb10185e0, 0x86eb, 0x4612, { 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 } }
24
25 class nsNavHistoryQuery MOZ_FINAL : public nsINavHistoryQuery
26 {
27 public:
28 nsNavHistoryQuery();
29 // note: we use a copy constructor in Clone(), the default is good enough
30
31 NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)
32 NS_DECL_ISUPPORTS
33 NS_DECL_NSINAVHISTORYQUERY
34
35 int32_t MinVisits() { return mMinVisits; }
36 int32_t MaxVisits() { return mMaxVisits; }
37 PRTime BeginTime() { return mBeginTime; }
38 uint32_t BeginTimeReference() { return mBeginTimeReference; }
39 PRTime EndTime() { return mEndTime; }
40 uint32_t EndTimeReference() { return mEndTimeReference; }
41 const nsString& SearchTerms() { return mSearchTerms; }
42 bool OnlyBookmarked() { return mOnlyBookmarked; }
43 bool DomainIsHost() { return mDomainIsHost; }
44 const nsCString& Domain() { return mDomain; }
45 bool UriIsPrefix() { return mUriIsPrefix; }
46 nsIURI* Uri() { return mUri; } // NOT AddRef-ed!
47 bool AnnotationIsNot() { return mAnnotationIsNot; }
48 const nsCString& Annotation() { return mAnnotation; }
49 const nsTArray<int64_t>& Folders() const { return mFolders; }
50 const nsTArray<nsString>& Tags() const { return mTags; }
51 nsresult SetTags(const nsTArray<nsString>& aTags)
52 {
53 if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags))
54 return NS_ERROR_OUT_OF_MEMORY;
55
56 return NS_OK;
57 }
58 bool TagsAreNot() { return mTagsAreNot; }
59
60 const nsTArray<uint32_t>& Transitions() const { return mTransitions; }
61 nsresult SetTransitions(const nsTArray<uint32_t>& aTransitions)
62 {
63 if (!mTransitions.ReplaceElementsAt(0, mTransitions.Length(),
64 aTransitions))
65 return NS_ERROR_OUT_OF_MEMORY;
66
67 return NS_OK;
68 }
69
70 private:
71 ~nsNavHistoryQuery() {}
72
73 protected:
74
75 int32_t mMinVisits;
76 int32_t mMaxVisits;
77 PRTime mBeginTime;
78 uint32_t mBeginTimeReference;
79 PRTime mEndTime;
80 uint32_t mEndTimeReference;
81 nsString mSearchTerms;
82 bool mOnlyBookmarked;
83 bool mDomainIsHost;
84 nsCString mDomain; // Default is IsVoid, empty string is valid query
85 bool mUriIsPrefix;
86 nsCOMPtr<nsIURI> mUri;
87 bool mAnnotationIsNot;
88 nsCString mAnnotation;
89 nsTArray<int64_t> mFolders;
90 nsTArray<nsString> mTags;
91 bool mTagsAreNot;
92 nsTArray<uint32_t> mTransitions;
93 };
94
95 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID)
96
97 // nsNavHistoryQueryOptions
98
99 #define NS_NAVHISTORYQUERYOPTIONS_IID \
100 {0x95f8ba3b, 0xd681, 0x4d89, {0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18}}
101
102 class nsNavHistoryQueryOptions MOZ_FINAL : public nsINavHistoryQueryOptions
103 {
104 public:
105 nsNavHistoryQueryOptions()
106 : mSort(0)
107 , mResultType(0)
108 , mExcludeItems(false)
109 , mExcludeQueries(false)
110 , mExcludeReadOnlyFolders(false)
111 , mExpandQueries(true)
112 , mIncludeHidden(false)
113 , mMaxResults(0)
114 , mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY)
115 , mAsyncEnabled(false)
116 { }
117
118 NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID)
119
120 NS_DECL_ISUPPORTS
121 NS_DECL_NSINAVHISTORYQUERYOPTIONS
122
123 uint16_t SortingMode() const { return mSort; }
124 uint16_t ResultType() const { return mResultType; }
125 bool ExcludeItems() const { return mExcludeItems; }
126 bool ExcludeQueries() const { return mExcludeQueries; }
127 bool ExcludeReadOnlyFolders() const { return mExcludeReadOnlyFolders; }
128 bool ExpandQueries() const { return mExpandQueries; }
129 bool IncludeHidden() const { return mIncludeHidden; }
130 uint32_t MaxResults() const { return mMaxResults; }
131 uint16_t QueryType() const { return mQueryType; }
132 bool AsyncEnabled() const { return mAsyncEnabled; }
133
134 nsresult Clone(nsNavHistoryQueryOptions **aResult);
135
136 private:
137 nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other) {} // no copy
138
139 // IF YOU ADD MORE ITEMS:
140 // * Add a new getter for C++ above if it makes sense
141 // * Add to the serialization code (see nsNavHistory::QueriesToQueryString())
142 // * Add to the deserialization code (see nsNavHistory::QueryStringToQueries)
143 // * Add to the nsNavHistoryQueryOptions::Clone() function
144 // * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if applicable
145 uint16_t mSort;
146 nsCString mSortingAnnotation;
147 nsCString mParentAnnotationToExclude;
148 uint16_t mResultType;
149 bool mExcludeItems;
150 bool mExcludeQueries;
151 bool mExcludeReadOnlyFolders;
152 bool mExpandQueries;
153 bool mIncludeHidden;
154 uint32_t mMaxResults;
155 uint16_t mQueryType;
156 bool mAsyncEnabled;
157 };
158
159 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions, NS_NAVHISTORYQUERYOPTIONS_IID)
160
161 #endif // nsNavHistoryQuery_h_

mercurial