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 { \
24 0xb10185e0, 0x86eb, 0x4612, { \
25 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 \
26 } \
27 }
28
29 class nsNavHistoryQuery final : public nsINavHistoryQuery {
30 public:
31 nsNavHistoryQuery();
32 nsNavHistoryQuery(const nsNavHistoryQuery& aOther);
33
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)
35 NS_DECL_ISUPPORTS
36 NS_DECL_NSINAVHISTORYQUERY
37
38 int32_t MinVisits() { return mMinVisits; }
MaxVisits()39 int32_t MaxVisits() { return mMaxVisits; }
BeginTime()40 PRTime BeginTime() { return mBeginTime; }
BeginTimeReference()41 uint32_t BeginTimeReference() { return mBeginTimeReference; }
EndTime()42 PRTime EndTime() { return mEndTime; }
EndTimeReference()43 uint32_t EndTimeReference() { return mEndTimeReference; }
SearchTerms()44 const nsString& SearchTerms() { return mSearchTerms; }
OnlyBookmarked()45 bool OnlyBookmarked() { return mOnlyBookmarked; }
DomainIsHost()46 bool DomainIsHost() { return mDomainIsHost; }
Domain()47 const nsCString& Domain() { return mDomain; }
Uri()48 nsIURI* Uri() { return mUri; } // NOT AddRef-ed!
AnnotationIsNot()49 bool AnnotationIsNot() { return mAnnotationIsNot; }
Annotation()50 const nsCString& Annotation() { return mAnnotation; }
Parents()51 const nsTArray<nsCString>& Parents() const { return mParents; }
52
Tags()53 const nsTArray<nsString>& Tags() const { return mTags; }
SetTags(nsTArray<nsString> aTags)54 void SetTags(nsTArray<nsString> aTags) { mTags = std::move(aTags); }
TagsAreNot()55 bool TagsAreNot() { return mTagsAreNot; }
56
Transitions()57 const nsTArray<uint32_t>& Transitions() const { return mTransitions; }
58
59 nsresult Clone(nsNavHistoryQuery** _clone);
60
61 private:
62 ~nsNavHistoryQuery() = default;
63
64 protected:
65 // IF YOU ADD MORE ITEMS:
66 // * Add to the copy constructor
67 int32_t mMinVisits;
68 int32_t mMaxVisits;
69 PRTime mBeginTime;
70 uint32_t mBeginTimeReference;
71 PRTime mEndTime;
72 uint32_t mEndTimeReference;
73 nsString mSearchTerms;
74 bool mOnlyBookmarked;
75 bool mDomainIsHost;
76 nsCString mDomain; // Default is IsVoid, empty string is valid query
77 nsCOMPtr<nsIURI> mUri;
78 bool mAnnotationIsNot;
79 nsCString mAnnotation;
80 nsTArray<nsCString> mParents;
81 nsTArray<nsString> mTags;
82 bool mTagsAreNot;
83 nsTArray<uint32_t> mTransitions;
84 };
85
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery,NS_NAVHISTORYQUERY_IID)86 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID)
87
88 // nsNavHistoryQueryOptions
89
90 #define NS_NAVHISTORYQUERYOPTIONS_IID \
91 { \
92 0x95f8ba3b, 0xd681, 0x4d89, { \
93 0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18 \
94 } \
95 }
96
97 class nsNavHistoryQueryOptions final : public nsINavHistoryQueryOptions {
98 public:
99 nsNavHistoryQueryOptions();
100 nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other);
101
102 NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID)
103
104 NS_DECL_ISUPPORTS
105 NS_DECL_NSINAVHISTORYQUERYOPTIONS
106
107 uint16_t SortingMode() const { return mSort; }
108 uint16_t ResultType() const { return mResultType; }
109 bool ExcludeItems() const { return mExcludeItems; }
110 bool ExcludeQueries() const { return mExcludeQueries; }
111 bool ExpandQueries() const { return mExpandQueries; }
112 bool IncludeHidden() const { return mIncludeHidden; }
113 uint32_t MaxResults() const { return mMaxResults; }
114 uint16_t QueryType() const { return mQueryType; }
115 bool AsyncEnabled() const { return mAsyncEnabled; }
116
117 nsresult Clone(nsNavHistoryQueryOptions** _clone);
118
119 private:
120 ~nsNavHistoryQueryOptions() = default;
121
122 // IF YOU ADD MORE ITEMS:
123 // * Add to the copy constructor
124 // * Add a new getter for C++ above if it makes sense
125 // * Add to the serialization code (see nsNavHistory::QueriesToQueryString())
126 // * Add to the deserialization code (see nsNavHistory::QueryStringToQueries)
127 // * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if
128 // applicable
129 uint16_t mSort;
130 uint16_t mResultType;
131 bool mExcludeItems;
132 bool mExcludeQueries;
133 bool mExpandQueries;
134 bool mIncludeHidden;
135 uint32_t mMaxResults;
136 uint16_t mQueryType;
137 bool mAsyncEnabled;
138 };
139
140 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions,
141 NS_NAVHISTORYQUERYOPTIONS_IID)
142
143 #endif // nsNavHistoryQuery_h_
144