From 302bf1b523012e11b60425d6eee1221ebc2724eb Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sun, 3 Nov 2019 00:17:46 -0400 Subject: Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1 --- mailnews/base/search/src/nsMsgSearchSession.h | 98 +++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 mailnews/base/search/src/nsMsgSearchSession.h (limited to 'mailnews/base/search/src/nsMsgSearchSession.h') diff --git a/mailnews/base/search/src/nsMsgSearchSession.h b/mailnews/base/search/src/nsMsgSearchSession.h new file mode 100644 index 000000000..d5d62654f --- /dev/null +++ b/mailnews/base/search/src/nsMsgSearchSession.h @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsMsgSearchSession_h___ +#define nsMsgSearchSession_h___ + +#include "nscore.h" +#include "nsMsgSearchCore.h" +#include "nsIMsgSearchSession.h" +#include "nsIUrlListener.h" +#include "nsIMsgWindow.h" +#include "nsITimer.h" +// Disable deprecation warnings generated by nsISupportsArray and associated +// classes. +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif defined(_MSC_VER) +#pragma warning (disable : 4996) +#endif +#include "nsISupportsArray.h" +#include "nsCOMArray.h" +#include "nsWeakReference.h" +#include "nsTObserverArray.h" + +class nsMsgSearchAdapter; +class nsMsgSearchBoolExpression; +class nsMsgSearchScopeTerm; + +class nsMsgSearchSession : public nsIMsgSearchSession, public nsIUrlListener, public nsSupportsWeakReference +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIMSGSEARCHSESSION + NS_DECL_NSIURLLISTENER + + nsMsgSearchSession(); + +protected: + virtual ~nsMsgSearchSession(); + + nsWeakPtr m_msgWindowWeak; + nsresult Initialize(); + nsresult StartTimer(); + nsresult TimeSlice (bool *aDone); + nsMsgSearchScopeTerm *GetRunningScope(); + void StopRunning(); + nsresult BeginSearching(); + nsresult DoNextSearch(); + nsresult SearchWOUrls (); + nsresult GetNextUrl(); + nsresult NotifyListenersDone(nsresult status); + void EnableFolderNotifications(bool aEnable); + void ReleaseFolderDBRef(); + + nsTArray> m_scopeList; + nsCOMPtr m_termList; + + nsTArray > m_listenerList; + nsTArray m_listenerFlagList; + /** + * Iterator index for m_listenerList/m_listenerFlagList. We used to use an + * nsTObserverArray for m_listenerList but its auto-adjusting iterator was + * not helping us keep our m_listenerFlagList iterator correct. + * + * We are making the simplifying assumption that our notifications are + * non-reentrant. In the exceptional case that it turns out they are + * reentrant, we assume that this is the result of canceling a search while + * the session is active and initiating a new one. In that case, we assume + * the outer iteration can safely be abandoned. + * + * This value is defined to be the index of the next listener we will process. + * This allows us to use the sentinel value of -1 to convey that no iteration + * is in progress (and the iteration process to abort if the value transitions + * to -1, which we always set on conclusion of our loop). + */ + int32_t m_iListener; + + void DestroyTermList (); + void DestroyScopeList (); + + static void TimerCallback(nsITimer *aTimer, void *aClosure); + // support for searching multiple scopes in serial + nsresult TimeSliceSerial (bool *aDone); + nsresult TimeSliceParallel (); + + nsMsgSearchAttribValue m_sortAttribute; + uint32_t m_idxRunningScope; + nsMsgSearchType m_searchType; + bool m_handlingError; + nsCString m_runningUrl; // The url for the current search + nsCOMPtr m_backgroundTimer; + bool m_searchPaused; + nsMsgSearchBoolExpression *m_expressionTree; +}; + +#endif -- cgit v1.2.3