LCOV - code coverage report
Current view: directory - toolkit/components/places - nsNavHistoryQuery.h (source / functions) Found Hit Coverage
Test: app.info Lines: 44 42 95.5 %
Date: 2012-06-02 Functions: 35 35 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Places code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Google Inc.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2005
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Brett Wilson <brettw@gmail.com> (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : /**
      40                 :  * The definitions of nsNavHistoryQuery and nsNavHistoryQueryOptions. This
      41                 :  * header file should only be included from nsNavHistory.h, include that if
      42                 :  * you want these classes.
      43                 :  */
      44                 : 
      45                 : #ifndef nsNavHistoryQuery_h_
      46                 : #define nsNavHistoryQuery_h_
      47                 : 
      48                 : // nsNavHistoryQuery
      49                 : //
      50                 : //    This class encapsulates the parameters for basic history queries for
      51                 : //    building UI, trees, lists, etc.
      52                 : 
      53                 : #define NS_NAVHISTORYQUERY_IID \
      54                 : { 0xb10185e0, 0x86eb, 0x4612, { 0x95, 0x7c, 0x09, 0x34, 0xf2, 0xb1, 0xce, 0xd7 } }
      55                 : 
      56                 : class nsNavHistoryQuery : public nsINavHistoryQuery
      57             899 : {
      58                 : public:
      59                 :   nsNavHistoryQuery();
      60                 :   // note: we use a copy constructor in Clone(), the default is good enough
      61                 : 
      62                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERY_IID)
      63                 :   NS_DECL_ISUPPORTS
      64                 :   NS_DECL_NSINAVHISTORYQUERY
      65                 : 
      66            1527 :   PRInt32 MinVisits() { return mMinVisits; }
      67            1523 :   PRInt32 MaxVisits() { return mMaxVisits; }
      68             183 :   PRTime BeginTime() { return mBeginTime; }
      69             183 :   PRUint32 BeginTimeReference() { return mBeginTimeReference; }
      70             183 :   PRTime EndTime() { return mEndTime; }
      71             183 :   PRUint32 EndTimeReference() { return mEndTimeReference; }
      72            1210 :   const nsString& SearchTerms() { return mSearchTerms; }
      73            1558 :   bool OnlyBookmarked() { return mOnlyBookmarked; }
      74             124 :   bool DomainIsHost() { return mDomainIsHost; }
      75            1925 :   const nsCString& Domain() { return mDomain; }
      76             190 :   bool UriIsPrefix() { return mUriIsPrefix; }
      77            1483 :   nsIURI* Uri() { return mUri; } // NOT AddRef-ed!
      78              26 :   bool AnnotationIsNot() { return mAnnotationIsNot; }
      79             622 :   const nsCString& Annotation() { return mAnnotation; }
      80            4302 :   const nsTArray<PRInt64>& Folders() const { return mFolders; }
      81            7347 :   const nsTArray<nsString>& Tags() const { return mTags; }
      82             570 :   nsresult SetTags(const nsTArray<nsString>& aTags)
      83                 :   {
      84             570 :     if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags))
      85               0 :       return NS_ERROR_OUT_OF_MEMORY;
      86                 : 
      87             570 :     return NS_OK;
      88                 :   }
      89             156 :   bool TagsAreNot() { return mTagsAreNot; }
      90                 : 
      91            6725 :   const nsTArray<PRUint32>& Transitions() const { return mTransitions; }
      92             405 :   nsresult SetTransitions(const nsTArray<PRUint32>& aTransitions)
      93                 :   {
      94             405 :     if (!mTransitions.ReplaceElementsAt(0, mTransitions.Length(),
      95             405 :                                         aTransitions))
      96               0 :       return NS_ERROR_OUT_OF_MEMORY;
      97                 : 
      98             405 :     return NS_OK;
      99                 :   }
     100                 : 
     101                 : private:
     102            7644 :   ~nsNavHistoryQuery() {}
     103                 : 
     104                 : protected:
     105                 : 
     106                 :   PRInt32 mMinVisits;
     107                 :   PRInt32 mMaxVisits;
     108                 :   PRTime mBeginTime;
     109                 :   PRUint32 mBeginTimeReference;
     110                 :   PRTime mEndTime;
     111                 :   PRUint32 mEndTimeReference;
     112                 :   nsString mSearchTerms;
     113                 :   bool mOnlyBookmarked;
     114                 :   bool mDomainIsHost;
     115                 :   nsCString mDomain; // Default is IsVoid, empty string is valid query
     116                 :   bool mUriIsPrefix;
     117                 :   nsCOMPtr<nsIURI> mUri;
     118                 :   bool mAnnotationIsNot;
     119                 :   nsCString mAnnotation;
     120                 :   nsTArray<PRInt64> mFolders;
     121                 :   nsTArray<nsString> mTags;
     122                 :   bool mTagsAreNot;
     123                 :   nsTArray<PRUint32> mTransitions;
     124                 : };
     125                 : 
     126                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQuery, NS_NAVHISTORYQUERY_IID)
     127                 : 
     128                 : // nsNavHistoryQueryOptions
     129                 : 
     130                 : #define NS_NAVHISTORYQUERYOPTIONS_IID \
     131                 : {0x95f8ba3b, 0xd681, 0x4d89, {0xab, 0xd1, 0xfd, 0xae, 0xf2, 0xa3, 0xde, 0x18}}
     132                 : 
     133                 : class nsNavHistoryQueryOptions : public nsINavHistoryQueryOptions
     134            5870 : {
     135                 : public:
     136            5870 :   nsNavHistoryQueryOptions()
     137                 :   : mSort(0)
     138                 :   , mResultType(0)
     139                 :   , mExcludeItems(false)
     140                 :   , mExcludeQueries(false)
     141                 :   , mExcludeReadOnlyFolders(false)
     142                 :   , mExpandQueries(true)
     143                 :   , mIncludeHidden(false)
     144                 :   , mRedirectsMode(nsINavHistoryQueryOptions::REDIRECTS_MODE_ALL)
     145                 :   , mMaxResults(0)
     146                 :   , mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY)
     147            5870 :   , mAsyncEnabled(false)
     148            5870 :   { }
     149                 : 
     150                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYQUERYOPTIONS_IID)
     151                 : 
     152                 :   NS_DECL_ISUPPORTS
     153                 :   NS_DECL_NSINAVHISTORYQUERYOPTIONS
     154                 : 
     155            7124 :   PRUint16 SortingMode() const { return mSort; }
     156           15266 :   PRUint16 ResultType() const { return mResultType; }
     157            6920 :   bool ExcludeItems() const { return mExcludeItems; }
     158            4275 :   bool ExcludeQueries() const { return mExcludeQueries; }
     159            3810 :   bool ExcludeReadOnlyFolders() const { return mExcludeReadOnlyFolders; }
     160            3243 :   bool ExpandQueries() const { return mExpandQueries; }
     161            3540 :   bool IncludeHidden() const { return mIncludeHidden; }
     162            3769 :   PRUint16 RedirectsMode() const { return mRedirectsMode; }
     163            6707 :   PRUint32 MaxResults() const { return mMaxResults; }
     164            9590 :   PRUint16 QueryType() const { return mQueryType; }
     165            4256 :   bool AsyncEnabled() const { return mAsyncEnabled; }
     166                 : 
     167                 :   nsresult Clone(nsNavHistoryQueryOptions **aResult);
     168                 : 
     169                 : private:
     170                 :   nsNavHistoryQueryOptions(const nsNavHistoryQueryOptions& other) {} // no copy
     171                 : 
     172                 :   // IF YOU ADD MORE ITEMS:
     173                 :   //  * Add a new getter for C++ above if it makes sense
     174                 :   //  * Add to the serialization code (see nsNavHistory::QueriesToQueryString())
     175                 :   //  * Add to the deserialization code (see nsNavHistory::QueryStringToQueries)
     176                 :   //  * Add to the nsNavHistoryQueryOptions::Clone() function
     177                 :   //  * Add to the nsNavHistory.cpp::GetSimpleBookmarksQueryFolder function if applicable
     178                 :   PRUint16 mSort;
     179                 :   nsCString mSortingAnnotation;
     180                 :   nsCString mParentAnnotationToExclude;
     181                 :   PRUint16 mResultType;
     182                 :   bool mExcludeItems;
     183                 :   bool mExcludeQueries;
     184                 :   bool mExcludeReadOnlyFolders;
     185                 :   bool mExpandQueries;
     186                 :   bool mIncludeHidden;
     187                 :   PRUint16 mRedirectsMode;
     188                 :   PRUint32 mMaxResults;
     189                 :   PRUint16 mQueryType;
     190                 :   bool mAsyncEnabled;
     191                 : };
     192                 : 
     193                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryQueryOptions, NS_NAVHISTORYQUERYOPTIONS_IID)
     194                 : 
     195                 : #endif // nsNavHistoryQuery_h_

Generated by: LCOV version 1.7