toolkit/components/places/nsNavHistoryQuery.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     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  */
    12 #ifndef nsNavHistoryQuery_h_
    13 #define nsNavHistoryQuery_h_
    15 // nsNavHistoryQuery
    16 //
    17 //    This class encapsulates the parameters for basic history queries for
    18 //    building UI, trees, lists, etc.
    20 #include "mozilla/Attributes.h"
    22 #define NS_NAVHISTORYQUERY_IID \
    23 { 0xb10185e0, 0x86eb, 0x4612, { 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 } }
    25 class nsNavHistoryQuery MOZ_FINAL : public nsINavHistoryQuery
    26 {
    27 public:
    28   nsNavHistoryQuery();
    29   // note: we use a copy constructor in Clone(), the default is good enough
    31   NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)
    32   NS_DECL_ISUPPORTS
    33   NS_DECL_NSINAVHISTORYQUERY
    35   int32_t MinVisits() { return mMinVisits; }
    36   int32_t MaxVisits() { return mMaxVisits; }
    37   PRTime BeginTime() { return mBeginTime; }
    38   uint32_t BeginTimeReference() { return mBeginTimeReference; }
    39   PRTime EndTime() { return mEndTime; }
    40   uint32_t EndTimeReference() { return mEndTimeReference; }
    41   const nsString& SearchTerms() { return mSearchTerms; }
    42   bool OnlyBookmarked() { return mOnlyBookmarked; }
    43   bool DomainIsHost() { return mDomainIsHost; }
    44   const nsCString& Domain() { return mDomain; }
    45   bool UriIsPrefix() { return mUriIsPrefix; }
    46   nsIURI* Uri() { return mUri; } // NOT AddRef-ed!
    47   bool AnnotationIsNot() { return mAnnotationIsNot; }
    48   const nsCString& Annotation() { return mAnnotation; }
    49   const nsTArray<int64_t>& Folders() const { return mFolders; }
    50   const nsTArray<nsString>& Tags() const { return mTags; }
    51   nsresult SetTags(const nsTArray<nsString>& aTags)
    52   {
    53     if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags))
    54       return NS_ERROR_OUT_OF_MEMORY;
    56     return NS_OK;
    57   }
    58   bool TagsAreNot() { return mTagsAreNot; }
    60   const nsTArray<uint32_t>& Transitions() const { return mTransitions; }
    61   nsresult SetTransitions(const nsTArray<uint32_t>& aTransitions)
    62   {
    63     if (!mTransitions.ReplaceElementsAt(0, mTransitions.Length(),
    64                                         aTransitions))
    65       return NS_ERROR_OUT_OF_MEMORY;
    67     return NS_OK;
    68   }
    70 private:
    71   ~nsNavHistoryQuery() {}
    73 protected:
    75   int32_t mMinVisits;
    76   int32_t mMaxVisits;
    77   PRTime mBeginTime;
    78   uint32_t mBeginTimeReference;
    79   PRTime mEndTime;
    80   uint32_t mEndTimeReference;
    81   nsString mSearchTerms;
    82   bool mOnlyBookmarked;
    83   bool mDomainIsHost;
    84   nsCString mDomain; // Default is IsVoid, empty string is valid query
    85   bool mUriIsPrefix;
    86   nsCOMPtr<nsIURI> mUri;
    87   bool mAnnotationIsNot;
    88   nsCString mAnnotation;
    89   nsTArray<int64_t> mFolders;
    90   nsTArray<nsString> mTags;
    91   bool mTagsAreNot;
    92   nsTArray<uint32_t> mTransitions;
    93 };
    95 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID)
    97 // nsNavHistoryQueryOptions
    99 #define NS_NAVHISTORYQUERYOPTIONS_IID \
   100 {0x95f8ba3b, 0xd681, 0x4d89, {0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18}}
   102 class nsNavHistoryQueryOptions MOZ_FINAL : public nsINavHistoryQueryOptions
   103 {
   104 public:
   105   nsNavHistoryQueryOptions()
   106   : mSort(0)
   107   , mResultType(0)
   108   , mExcludeItems(false)
   109   , mExcludeQueries(false)
   110   , mExcludeReadOnlyFolders(false)
   111   , mExpandQueries(true)
   112   , mIncludeHidden(false)
   113   , mMaxResults(0)
   114   , mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY)
   115   , mAsyncEnabled(false)
   116   { }
   118   NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID)
   120   NS_DECL_ISUPPORTS
   121   NS_DECL_NSINAVHISTORYQUERYOPTIONS
   123   uint16_t SortingMode() const { return mSort; }
   124   uint16_t ResultType() const { return mResultType; }
   125   bool ExcludeItems() const { return mExcludeItems; }
   126   bool ExcludeQueries() const { return mExcludeQueries; }
   127   bool ExcludeReadOnlyFolders() const { return mExcludeReadOnlyFolders; }
   128   bool ExpandQueries() const { return mExpandQueries; }
   129   bool IncludeHidden() const { return mIncludeHidden; }
   130   uint32_t MaxResults() const { return mMaxResults; }
   131   uint16_t QueryType() const { return mQueryType; }
   132   bool AsyncEnabled() const { return mAsyncEnabled; }
   134   nsresult Clone(nsNavHistoryQueryOptions **aResult);
   136 private:
   137   nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other) {} // no copy
   139   // IF YOU ADD MORE ITEMS:
   140   //  * Add a new getter for C++ above if it makes sense
   141   //  * Add to the serialization code (see nsNavHistory::QueriesToQueryString())
   142   //  * Add to the deserialization code (see nsNavHistory::QueryStringToQueries)
   143   //  * Add to the nsNavHistoryQueryOptions::Clone() function
   144   //  * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if applicable
   145   uint16_t mSort;
   146   nsCString mSortingAnnotation;
   147   nsCString mParentAnnotationToExclude;
   148   uint16_t mResultType;
   149   bool mExcludeItems;
   150   bool mExcludeQueries;
   151   bool mExcludeReadOnlyFolders;
   152   bool mExpandQueries;
   153   bool mIncludeHidden;
   154   uint32_t mMaxResults;
   155   uint16_t mQueryType;
   156   bool mAsyncEnabled;
   157 };
   159 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions, NS_NAVHISTORYQUERYOPTIONS_IID)
   161 #endif // nsNavHistoryQuery_h_

mercurial