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