зеркало из https://github.com/mozilla/gecko-dev.git
fix 239474 address book quick search creates multiple ldap connections if you type slowly, r/sr=mscott
This commit is contained in:
Родитель
238de52537
Коммит
ac75a6dc7b
|
@ -56,7 +56,7 @@ interface nsIAbView : nsISupports
|
|||
* to netscape 6.x, etc, could cause
|
||||
* the "persisted" sortColumn to be bogus.
|
||||
*/
|
||||
wstring init(in string URI, in nsIAbViewListener abViewListener, in wstring sortColumn, in wstring sortDirection);
|
||||
wstring init(in string URI, in boolean aSearchView, in nsIAbViewListener abViewListener, in wstring sortColumn, in wstring sortDirection);
|
||||
void close();
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,7 @@ var dirTree = 0;
|
|||
var abList = 0;
|
||||
var gAbResultsTree = null;
|
||||
var gAbView = null;
|
||||
var gCurDirectory;
|
||||
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
var gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
|
@ -668,10 +669,19 @@ function CloseAbView()
|
|||
}
|
||||
}
|
||||
|
||||
function SetAbView(uri, sortColumn, sortDirection)
|
||||
function SetAbView(uri, searchView, sortColumn, sortDirection)
|
||||
{
|
||||
var actualSortColumn;
|
||||
if (gAbView && gCurDirectory == GetSelectedDirectory())
|
||||
{
|
||||
// re-init the view
|
||||
actualSortColumn = gAbView.init(uri, searchView, GetAbViewListener(), sortColumn, sortDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseAbView();
|
||||
|
||||
gCurDirectory = GetSelectedDirectory();
|
||||
if (!sortColumn)
|
||||
sortColumn = kDefaultSortColumn;
|
||||
|
||||
|
@ -680,8 +690,8 @@ function SetAbView(uri, sortColumn, sortDirection)
|
|||
|
||||
gAbView = Components.classes["@mozilla.org/addressbook/abview;1"].createInstance(Components.interfaces.nsIAbView);
|
||||
|
||||
var actualSortColumn = gAbView.init(uri, GetAbViewListener(), sortColumn, sortDirection);
|
||||
|
||||
actualSortColumn = gAbView.init(uri, searchView, GetAbViewListener(), sortColumn, sortDirection);
|
||||
}
|
||||
var boxObject = GetAbResultsBoxObject();
|
||||
boxObject.view = gAbView.QueryInterface(Components.interfaces.nsITreeView);
|
||||
|
||||
|
@ -715,7 +725,7 @@ function ChangeDirectoryByURI(uri)
|
|||
|
||||
var sortColumn = gAbResultsTree.getAttribute("sortCol");
|
||||
var sortDirection = document.getElementById(sortColumn).getAttribute("sortDirection");
|
||||
var actualSortColumn = SetAbView(uri, sortColumn, sortDirection);
|
||||
var actualSortColumn = SetAbView(uri, false, sortColumn, sortDirection);
|
||||
UpdateSortIndicators(actualSortColumn, sortDirection);
|
||||
|
||||
// only select the first card if there is a first card
|
||||
|
|
|
@ -445,7 +445,7 @@ function onEnterInSearchBar()
|
|||
searchURI += gQueryURIFormat.replace(/@V/g, encodeURIComponent(gSearchInput.value));
|
||||
}
|
||||
|
||||
SetAbView(searchURI, sortColumn, sortDirection);
|
||||
SetAbView(searchURI, true, sortColumn, sortDirection);
|
||||
|
||||
SelectFirstCard();
|
||||
}
|
||||
|
|
|
@ -144,6 +144,12 @@ function OnLoadAddressBook()
|
|||
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_results.version");
|
||||
|
||||
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
|
||||
try {
|
||||
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"].getService();
|
||||
gLDAPPrefsService = gLDAPPrefsService.QueryInterface( Components.interfaces.nsILDAPPrefsService);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP service\n" + ex + "\n");}
|
||||
|
||||
GetCurrentPrefs();
|
||||
|
||||
AddPrefObservers();
|
||||
|
@ -624,7 +630,7 @@ function onEnterInSearchBar()
|
|||
searchURI += gQueryURIFormat.replace(/@V/g, encodeURIComponent(gSearchInput.value));
|
||||
}
|
||||
|
||||
SetAbView(searchURI, sortColumn, sortDirection);
|
||||
SetAbView(searchURI, gSearchInput.value != "", sortColumn, sortDirection);
|
||||
|
||||
// XXX todo
|
||||
// this works for synchronous searches of local addressbooks,
|
||||
|
|
|
@ -100,6 +100,8 @@ NS_IMETHODIMP nsAbDirectoryRDFResource::Init(const char* aURI)
|
|||
|
||||
mIsQueryURI = PR_TRUE;
|
||||
}
|
||||
else
|
||||
mIsQueryURI = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,13 @@ nsAbLDAPDirectory::~nsAbLDAPDirectory()
|
|||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED3(nsAbLDAPDirectory, nsAbDirectoryRDFResource, nsIAbDirectory, nsIAbDirectoryQuery, nsIAbDirectorySearch)
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::Init(const char* aURI)
|
||||
{
|
||||
mInitialized = PR_FALSE;
|
||||
return nsAbDirectoryRDFResource::Init(aURI);
|
||||
}
|
||||
|
||||
nsresult nsAbLDAPDirectory::Initiate ()
|
||||
{
|
||||
if (!mIsQueryURI)
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
nsAbLDAPDirectory();
|
||||
virtual ~nsAbLDAPDirectory();
|
||||
|
||||
NS_IMETHOD Init(const char *aUri);
|
||||
|
||||
// nsIAbDirectory methods
|
||||
NS_IMETHOD GetOperations(PRInt32 *aOperations);
|
||||
NS_IMETHOD GetChildNodes(nsISimpleEnumerator* *result);
|
||||
|
|
|
@ -249,6 +249,8 @@ NS_IMETHODIMP nsAbMDBDirectory::Init(const char* aURI)
|
|||
|
||||
mIsQueryURI = PR_TRUE;
|
||||
}
|
||||
else
|
||||
mIsQueryURI = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ nsAbView::nsAbView()
|
|||
mMailListAtom = do_GetAtom("MailList");
|
||||
mSuppressSelectionChange = PR_FALSE;
|
||||
mSuppressCountChange = PR_FALSE;
|
||||
mSearchView = PR_FALSE;
|
||||
mGeneratedNameFormat = 0;
|
||||
}
|
||||
|
||||
|
@ -100,6 +101,7 @@ NS_IMETHODIMP nsAbView::Close()
|
|||
mAbViewListener = nsnull;
|
||||
mTree = nsnull;
|
||||
mTreeSelection = nsnull;
|
||||
mSearchView = PR_FALSE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -205,7 +207,7 @@ nsresult nsAbView::RemovePrefObservers()
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener,
|
||||
NS_IMETHODIMP nsAbView::Init(const char *aURI, PRBool aSearchView, nsIAbViewListener *abViewListener,
|
||||
const PRUnichar *colID, const PRUnichar *sortDirection, PRUnichar **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -215,22 +217,37 @@ NS_IMETHODIMP nsAbView::Init(const char *aURI, nsIAbViewListener *abViewListener
|
|||
mURI = aURI;
|
||||
mAbViewListener = abViewListener;
|
||||
|
||||
rv = AddPrefObservers();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
// clear out old cards
|
||||
PRInt32 i = mCards.Count();
|
||||
while(i-- > 0)
|
||||
{
|
||||
rv = RemoveCardAt(i);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "remove card failed\n");
|
||||
}
|
||||
if (!mDirectory || mSearchView != aSearchView)
|
||||
{
|
||||
mSearchView = aSearchView;
|
||||
rv = AddPrefObservers();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = SetGeneratedNameFormatFromPrefs();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
rv = SetGeneratedNameFormatFromPrefs();
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(nsDependentCString(aURI), getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(nsDependentCString(aURI), getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDirectory = do_QueryInterface(resource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDirectory = do_QueryInterface(resource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr <nsIRDFResource> resource = do_QueryInterface(mDirectory);
|
||||
rv = resource->Init(aURI);
|
||||
}
|
||||
rv = EnumerateCards();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ private:
|
|||
nsCOMPtr<nsICollation> mCollationKeyGenerator;
|
||||
nsCOMPtr<nsIAbViewListener> mAbViewListener;
|
||||
|
||||
PRPackedBool mSearchView;
|
||||
PRPackedBool mSuppressSelectionChange;
|
||||
PRPackedBool mSuppressCountChange;
|
||||
PRInt32 mGeneratedNameFormat;
|
||||
|
|
Загрузка…
Ссылка в новой задаче