From 975c77ce090f167a331a6fb2aeed4923bbfa8b1e Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Sun, 21 Jan 2007 18:49:58 +0000 Subject: [PATCH] Bug 361326 Address book directories obtained through RDF aren't always initialised properly (ldap part) r=iann_bugzilla,sr=bienvenu --- mailnews/addrbook/src/nsAbDirProperty.h | 6 ++++++ mailnews/addrbook/src/nsAbLDAPDirectory.cpp | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mailnews/addrbook/src/nsAbDirProperty.h b/mailnews/addrbook/src/nsAbDirProperty.h index 0958067314d5..326fc71756f8 100644 --- a/mailnews/addrbook/src/nsAbDirProperty.h +++ b/mailnews/addrbook/src/nsAbDirProperty.h @@ -84,7 +84,13 @@ protected: nsString m_ListNickName; nsString m_Description; PRBool m_IsMailList; + + /* + * Note that any derived implementations should ensure that this item + * (m_DirPrefId) is correctly initialised correctly + */ nsCString m_DirPrefId; // ie,"ldap_2.servers.pab" + nsCOMPtr m_DirectoryPrefs; nsCOMPtr m_AddressList; }; diff --git a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp index 281fb5b828b3..fa5802d1a79f 100644 --- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp +++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp @@ -84,6 +84,21 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsAbLDAPDirectory, nsAbDirectoryRDFResource, nsIAbD NS_IMETHODIMP nsAbLDAPDirectory::Init(const char* aURI) { mInitialized = PR_FALSE; + + // We need to ensure that the m_DirPrefId is initialized properly + nsCAutoString uri(aURI); + + // Find the first ? (of the search params) if there is one. + // We know we can start at the end of the moz-abldapdirectory:// because + // that's the URI we should have been passed. + PRInt32 searchCharLocation = uri.FindChar('?', kLDAPDirectoryRootLen); + + if (searchCharLocation == kNotFound) + uri.Right(m_DirPrefId, uri.Length() - kLDAPDirectoryRootLen); + else + uri.Mid(m_DirPrefId, kLDAPDirectoryRootLen, + searchCharLocation - kLDAPDirectoryRootLen); + return nsAbDirectoryRDFResource::Init(aURI); } @@ -623,4 +638,3 @@ NS_IMETHODIMP nsAbLDAPDirectory::SetDataVersion(const nsACString &aDataVersion) { return SetStringValue("dataVersion", aDataVersion); } -