michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * The definitions of nsNavHistoryQuery and nsNavHistoryQueryOptions. This michael@0: * header file should only be included from nsNavHistory.h, include that if michael@0: * you want these classes. michael@0: */ michael@0: michael@0: #ifndef nsNavHistoryQuery_h_ michael@0: #define nsNavHistoryQuery_h_ michael@0: michael@0: // nsNavHistoryQuery michael@0: // michael@0: // This class encapsulates the parameters for basic history queries for michael@0: // building UI, trees, lists, etc. michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: #define NS_NAVHISTORYQUERY_IID \ michael@0: { 0xb10185e0, 0x86eb, 0x4612, { 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 } } michael@0: michael@0: class nsNavHistoryQuery MOZ_FINAL : public nsINavHistoryQuery michael@0: { michael@0: public: michael@0: nsNavHistoryQuery(); michael@0: // note: we use a copy constructor in Clone(), the default is good enough michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID) michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSINAVHISTORYQUERY michael@0: michael@0: int32_t MinVisits() { return mMinVisits; } michael@0: int32_t MaxVisits() { return mMaxVisits; } michael@0: PRTime BeginTime() { return mBeginTime; } michael@0: uint32_t BeginTimeReference() { return mBeginTimeReference; } michael@0: PRTime EndTime() { return mEndTime; } michael@0: uint32_t EndTimeReference() { return mEndTimeReference; } michael@0: const nsString& SearchTerms() { return mSearchTerms; } michael@0: bool OnlyBookmarked() { return mOnlyBookmarked; } michael@0: bool DomainIsHost() { return mDomainIsHost; } michael@0: const nsCString& Domain() { return mDomain; } michael@0: bool UriIsPrefix() { return mUriIsPrefix; } michael@0: nsIURI* Uri() { return mUri; } // NOT AddRef-ed! michael@0: bool AnnotationIsNot() { return mAnnotationIsNot; } michael@0: const nsCString& Annotation() { return mAnnotation; } michael@0: const nsTArray& Folders() const { return mFolders; } michael@0: const nsTArray& Tags() const { return mTags; } michael@0: nsresult SetTags(const nsTArray& aTags) michael@0: { michael@0: if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags)) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: bool TagsAreNot() { return mTagsAreNot; } michael@0: michael@0: const nsTArray& Transitions() const { return mTransitions; } michael@0: nsresult SetTransitions(const nsTArray& aTransitions) michael@0: { michael@0: if (!mTransitions.ReplaceElementsAt(0, mTransitions.Length(), michael@0: aTransitions)) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: private: michael@0: ~nsNavHistoryQuery() {} michael@0: michael@0: protected: michael@0: michael@0: int32_t mMinVisits; michael@0: int32_t mMaxVisits; michael@0: PRTime mBeginTime; michael@0: uint32_t mBeginTimeReference; michael@0: PRTime mEndTime; michael@0: uint32_t mEndTimeReference; michael@0: nsString mSearchTerms; michael@0: bool mOnlyBookmarked; michael@0: bool mDomainIsHost; michael@0: nsCString mDomain; // Default is IsVoid, empty string is valid query michael@0: bool mUriIsPrefix; michael@0: nsCOMPtr mUri; michael@0: bool mAnnotationIsNot; michael@0: nsCString mAnnotation; michael@0: nsTArray mFolders; michael@0: nsTArray mTags; michael@0: bool mTagsAreNot; michael@0: nsTArray mTransitions; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID) michael@0: michael@0: // nsNavHistoryQueryOptions michael@0: michael@0: #define NS_NAVHISTORYQUERYOPTIONS_IID \ michael@0: {0x95f8ba3b, 0xd681, 0x4d89, {0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18}} michael@0: michael@0: class nsNavHistoryQueryOptions MOZ_FINAL : public nsINavHistoryQueryOptions michael@0: { michael@0: public: michael@0: nsNavHistoryQueryOptions() michael@0: : mSort(0) michael@0: , mResultType(0) michael@0: , mExcludeItems(false) michael@0: , mExcludeQueries(false) michael@0: , mExcludeReadOnlyFolders(false) michael@0: , mExpandQueries(true) michael@0: , mIncludeHidden(false) michael@0: , mMaxResults(0) michael@0: , mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY) michael@0: , mAsyncEnabled(false) michael@0: { } michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID) michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSINAVHISTORYQUERYOPTIONS michael@0: michael@0: uint16_t SortingMode() const { return mSort; } michael@0: uint16_t ResultType() const { return mResultType; } michael@0: bool ExcludeItems() const { return mExcludeItems; } michael@0: bool ExcludeQueries() const { return mExcludeQueries; } michael@0: bool ExcludeReadOnlyFolders() const { return mExcludeReadOnlyFolders; } michael@0: bool ExpandQueries() const { return mExpandQueries; } michael@0: bool IncludeHidden() const { return mIncludeHidden; } michael@0: uint32_t MaxResults() const { return mMaxResults; } michael@0: uint16_t QueryType() const { return mQueryType; } michael@0: bool AsyncEnabled() const { return mAsyncEnabled; } michael@0: michael@0: nsresult Clone(nsNavHistoryQueryOptions **aResult); michael@0: michael@0: private: michael@0: nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other) {} // no copy michael@0: michael@0: // IF YOU ADD MORE ITEMS: michael@0: // * Add a new getter for C++ above if it makes sense michael@0: // * Add to the serialization code (see nsNavHistory::QueriesToQueryString()) michael@0: // * Add to the deserialization code (see nsNavHistory::QueryStringToQueries) michael@0: // * Add to the nsNavHistoryQueryOptions::Clone() function michael@0: // * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if applicable michael@0: uint16_t mSort; michael@0: nsCString mSortingAnnotation; michael@0: nsCString mParentAnnotationToExclude; michael@0: uint16_t mResultType; michael@0: bool mExcludeItems; michael@0: bool mExcludeQueries; michael@0: bool mExcludeReadOnlyFolders; michael@0: bool mExpandQueries; michael@0: bool mIncludeHidden; michael@0: uint32_t mMaxResults; michael@0: uint16_t mQueryType; michael@0: bool mAsyncEnabled; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions, NS_NAVHISTORYQUERYOPTIONS_IID) michael@0: michael@0: #endif // nsNavHistoryQuery_h_