fix search of imap/news while offline r=naving, sr=sspitzer 77808

This commit is contained in:
bienvenu%netscape.com 2001-05-09 13:44:57 +00:00
Родитель c153462eef
Коммит 3661eefb8d
5 изменённых файлов: 49 добавлений и 32 удалений

Просмотреть файл

@ -79,7 +79,7 @@ public:
static PRUnichar *EscapeImapSearchProtocol(const PRUnichar *imapCommand);
static PRUnichar *EscapeQuoteImapSearchProtocol(const PRUnichar *imapCommand);
static char *UnEscapeSearchUrl (const char *commandSpecificData);
static PRBool SearchIsOffline();
// This stuff lives in the base class because the IMAP search syntax
// is used by the Dredd SEARCH command as well as IMAP itself
static const char *m_kImapBefore;

Просмотреть файл

@ -795,7 +795,7 @@ nsresult nsMsgSearchOfflineNews::OpenSummaryFile ()
nsCOMPtr <nsIMsgFolder> scopeFolder;
err = m_scope->GetFolder(getter_AddRefs(scopeFolder));
if (NS_SUCCEEDED(err) && scopeFolder)
err = scopeFolder->GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), &m_db);
err = scopeFolder->GetMsgDatabase(nsnull, &m_db);
return err;
}

Просмотреть файл

@ -30,7 +30,8 @@
#include "nsXPIDLString.h"
#include "nsMsgSearchTerm.h"
#include "nsMsgSearchBoolExpression.h"
#include "nsIIOService.h"
#include "nsNetCID.h"
// This stuff lives in the base class because the IMAP search syntax
// is used by the Dredd SEARCH command as well as IMAP itself
@ -60,6 +61,7 @@ const char *nsMsgSearchAdapter::m_kImapNotAnswered = " UNANSWERED ";
const char *nsMsgSearchAdapter::m_kImapCharset = " CHARSET ";
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMETHODIMP nsMsgSearchAdapter::FindTargetFolder(const nsMsgResultElement *,nsIMsgFolder * *)
{
@ -977,6 +979,16 @@ nsMsgSearchValidityManager::~nsMsgSearchValidityManager ()
NS_IMPL_ISUPPORTS1(nsMsgSearchValidityManager, nsIMsgSearchValidityManager)
PRBool nsMsgSearchAdapter::SearchIsOffline()
{
PRBool offline = PR_FALSE;
nsresult rv;
nsCOMPtr <nsIIOService> ioService = do_GetService(kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && ioService)
ioService->GetOffline(&offline);
return offline;
}
//-----------------------------------------------------------------------------
// Bottleneck accesses to the objects so we can allocate and initialize them
@ -993,11 +1005,23 @@ nsresult nsMsgSearchValidityManager::GetTable (int whichTable, nsIMsgSearchValid
// hack alert...currently FEs are setting scope to News even if it should be set to OfflineNewsgroups...
// i'm fixing this by checking if we are in offline mode...
#ifdef DOING_OFFLINE
if (NET_IsOffline() && (whichTable == news || whichTable == newsEx))
if (whichTable == news || whichTable == newsEx || whichTable == onlineMail)
{
nsresult rv;
nsCOMPtr <nsIIOService> ioService = do_GetService(kIOServiceCID, &rv);
if (NS_SUCCEEDED(rv) && ioService)
{
PRBool offline;
ioService->GetOffline(&offline);
if (offline)
{
if (whichTable == news || whichTable == newsEx)
whichTable = localNews;
#endif
else
whichTable = offlineMail;
}
}
}
switch (whichTable)
{
case offlineMail:
@ -1020,13 +1044,11 @@ nsresult nsMsgSearchValidityManager::GetTable (int whichTable, nsIMsgSearchValid
err = InitNewsTable ();
*ppOutTable = m_newsTable;
break;
#ifdef DOING_OFFLINE
case localNews:
if (!m_localNewsTable)
err = InitLocalNewsTable();
*ppOutTable = m_localNewsTable;
break;
#endif
#ifdef DOING_EXNEWSSEARCH
case newsEx:
if (!m_newsExTable)

Просмотреть файл

@ -208,11 +208,11 @@ nsMsgSearchSession::AddScopeTerm(nsMsgSearchScopeValue attrib,
if (!newsFolder->IsSubscribed())
return NS_OK;
#endif
// It would be nice if the FEs did this, but I guess no one knows
// that offline news searching is supposed to work
if (NET_IsOffline())
if (nsMsgSearchAdapter::SearchIsOffline())
attrib = nsMsgSearchScope::OfflineNewsgroup;
#endif
}
if (attrib == nsMsgSearchScope::AllSearchableGroups)

Просмотреть файл

@ -1287,19 +1287,13 @@ nsMsgSearchScopeTerm::GetSearchSession(nsIMsgSearchSession** aResult)
return NS_OK;
}
// ### purely temporary
static PRBool NET_IsOffline()
{
return PR_FALSE;
}
PRBool nsMsgSearchScopeTerm::IsOfflineNews()
{
switch (m_attribute)
{
case nsMsgSearchScope::Newsgroup:
case nsMsgSearchScope::AllSearchableGroups:
if (NET_IsOffline() || !m_searchServer)
if (nsMsgSearchAdapter::SearchIsOffline() || !m_searchServer)
return PR_TRUE;
else
return PR_FALSE;
@ -1315,7 +1309,7 @@ PRBool nsMsgSearchScopeTerm::IsOfflineMail ()
// Find out whether "this" mail folder is online or offline
NS_ASSERTION(m_folder, "scope doesn't have folder");
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_folder);
if (imapFolder /* && !NET_IsOffline() && m_searchServer */) // make sure we are not in offline IMAP (mscott)
if (imapFolder && !nsMsgSearchAdapter::SearchIsOffline() && m_searchServer) // make sure we are not in offline IMAP (mscott)
return PR_FALSE;
return PR_TRUE; // if POP or IMAP in offline mode
}
@ -1324,8 +1318,9 @@ PRBool nsMsgSearchScopeTerm::IsOfflineIMAPMail()
{
// Find out whether "this" mail folder is an offline IMAP folder
NS_ASSERTION(m_folder, "scope doesn't have folder");
// if (m_folder->GetType() == FOLDER_IMAPMAIL && (NET_IsOffline() || !m_searchServer))
// return PR_TRUE;
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_folder);
if (imapFolder && (nsMsgSearchAdapter::SearchIsOffline() || !m_searchServer))
return PR_TRUE;
return PR_FALSE; // we are not an IMAP folder that is offline
}