1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/nsNavHistoryQuery.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,161 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/** 1.10 + * The definitions of nsNavHistoryQuery and nsNavHistoryQueryOptions. This 1.11 + * header file should only be included from nsNavHistory.h, include that if 1.12 + * you want these classes. 1.13 + */ 1.14 + 1.15 +#ifndef nsNavHistoryQuery_h_ 1.16 +#define nsNavHistoryQuery_h_ 1.17 + 1.18 +// nsNavHistoryQuery 1.19 +// 1.20 +// This class encapsulates the parameters for basic history queries for 1.21 +// building UI, trees, lists, etc. 1.22 + 1.23 +#include "mozilla/Attributes.h" 1.24 + 1.25 +#define NS_NAVHISTORYQUERY_IID \ 1.26 +{ 0xb10185e0, 0x86eb, 0x4612, { 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 } } 1.27 + 1.28 +class nsNavHistoryQuery MOZ_FINAL : public nsINavHistoryQuery 1.29 +{ 1.30 +public: 1.31 + nsNavHistoryQuery(); 1.32 + // note: we use a copy constructor in Clone(), the default is good enough 1.33 + 1.34 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID) 1.35 + NS_DECL_ISUPPORTS 1.36 + NS_DECL_NSINAVHISTORYQUERY 1.37 + 1.38 + int32_t MinVisits() { return mMinVisits; } 1.39 + int32_t MaxVisits() { return mMaxVisits; } 1.40 + PRTime BeginTime() { return mBeginTime; } 1.41 + uint32_t BeginTimeReference() { return mBeginTimeReference; } 1.42 + PRTime EndTime() { return mEndTime; } 1.43 + uint32_t EndTimeReference() { return mEndTimeReference; } 1.44 + const nsString& SearchTerms() { return mSearchTerms; } 1.45 + bool OnlyBookmarked() { return mOnlyBookmarked; } 1.46 + bool DomainIsHost() { return mDomainIsHost; } 1.47 + const nsCString& Domain() { return mDomain; } 1.48 + bool UriIsPrefix() { return mUriIsPrefix; } 1.49 + nsIURI* Uri() { return mUri; } // NOT AddRef-ed! 1.50 + bool AnnotationIsNot() { return mAnnotationIsNot; } 1.51 + const nsCString& Annotation() { return mAnnotation; } 1.52 + const nsTArray<int64_t>& Folders() const { return mFolders; } 1.53 + const nsTArray<nsString>& Tags() const { return mTags; } 1.54 + nsresult SetTags(const nsTArray<nsString>& aTags) 1.55 + { 1.56 + if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags)) 1.57 + return NS_ERROR_OUT_OF_MEMORY; 1.58 + 1.59 + return NS_OK; 1.60 + } 1.61 + bool TagsAreNot() { return mTagsAreNot; } 1.62 + 1.63 + const nsTArray<uint32_t>& Transitions() const { return mTransitions; } 1.64 + nsresult SetTransitions(const nsTArray<uint32_t>& aTransitions) 1.65 + { 1.66 + if (!mTransitions.ReplaceElementsAt(0, mTransitions.Length(), 1.67 + aTransitions)) 1.68 + return NS_ERROR_OUT_OF_MEMORY; 1.69 + 1.70 + return NS_OK; 1.71 + } 1.72 + 1.73 +private: 1.74 + ~nsNavHistoryQuery() {} 1.75 + 1.76 +protected: 1.77 + 1.78 + int32_t mMinVisits; 1.79 + int32_t mMaxVisits; 1.80 + PRTime mBeginTime; 1.81 + uint32_t mBeginTimeReference; 1.82 + PRTime mEndTime; 1.83 + uint32_t mEndTimeReference; 1.84 + nsString mSearchTerms; 1.85 + bool mOnlyBookmarked; 1.86 + bool mDomainIsHost; 1.87 + nsCString mDomain; // Default is IsVoid, empty string is valid query 1.88 + bool mUriIsPrefix; 1.89 + nsCOMPtr<nsIURI> mUri; 1.90 + bool mAnnotationIsNot; 1.91 + nsCString mAnnotation; 1.92 + nsTArray<int64_t> mFolders; 1.93 + nsTArray<nsString> mTags; 1.94 + bool mTagsAreNot; 1.95 + nsTArray<uint32_t> mTransitions; 1.96 +}; 1.97 + 1.98 +NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID) 1.99 + 1.100 +// nsNavHistoryQueryOptions 1.101 + 1.102 +#define NS_NAVHISTORYQUERYOPTIONS_IID \ 1.103 +{0x95f8ba3b, 0xd681, 0x4d89, {0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18}} 1.104 + 1.105 +class nsNavHistoryQueryOptions MOZ_FINAL : public nsINavHistoryQueryOptions 1.106 +{ 1.107 +public: 1.108 + nsNavHistoryQueryOptions() 1.109 + : mSort(0) 1.110 + , mResultType(0) 1.111 + , mExcludeItems(false) 1.112 + , mExcludeQueries(false) 1.113 + , mExcludeReadOnlyFolders(false) 1.114 + , mExpandQueries(true) 1.115 + , mIncludeHidden(false) 1.116 + , mMaxResults(0) 1.117 + , mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY) 1.118 + , mAsyncEnabled(false) 1.119 + { } 1.120 + 1.121 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID) 1.122 + 1.123 + NS_DECL_ISUPPORTS 1.124 + NS_DECL_NSINAVHISTORYQUERYOPTIONS 1.125 + 1.126 + uint16_t SortingMode() const { return mSort; } 1.127 + uint16_t ResultType() const { return mResultType; } 1.128 + bool ExcludeItems() const { return mExcludeItems; } 1.129 + bool ExcludeQueries() const { return mExcludeQueries; } 1.130 + bool ExcludeReadOnlyFolders() const { return mExcludeReadOnlyFolders; } 1.131 + bool ExpandQueries() const { return mExpandQueries; } 1.132 + bool IncludeHidden() const { return mIncludeHidden; } 1.133 + uint32_t MaxResults() const { return mMaxResults; } 1.134 + uint16_t QueryType() const { return mQueryType; } 1.135 + bool AsyncEnabled() const { return mAsyncEnabled; } 1.136 + 1.137 + nsresult Clone(nsNavHistoryQueryOptions **aResult); 1.138 + 1.139 +private: 1.140 + nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other) {} // no copy 1.141 + 1.142 + // IF YOU ADD MORE ITEMS: 1.143 + // * Add a new getter for C++ above if it makes sense 1.144 + // * Add to the serialization code (see nsNavHistory::QueriesToQueryString()) 1.145 + // * Add to the deserialization code (see nsNavHistory::QueryStringToQueries) 1.146 + // * Add to the nsNavHistoryQueryOptions::Clone() function 1.147 + // * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if applicable 1.148 + uint16_t mSort; 1.149 + nsCString mSortingAnnotation; 1.150 + nsCString mParentAnnotationToExclude; 1.151 + uint16_t mResultType; 1.152 + bool mExcludeItems; 1.153 + bool mExcludeQueries; 1.154 + bool mExcludeReadOnlyFolders; 1.155 + bool mExpandQueries; 1.156 + bool mIncludeHidden; 1.157 + uint32_t mMaxResults; 1.158 + uint16_t mQueryType; 1.159 + bool mAsyncEnabled; 1.160 +}; 1.161 + 1.162 +NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions, NS_NAVHISTORYQUERYOPTIONS_IID) 1.163 + 1.164 +#endif // nsNavHistoryQuery_h_