Source code

Revision control

Other Tools

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