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