mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-26 18:31:29 +00:00
Bug 323181 nsIAbLDAPReplicationQuery.idl should use nsIAb*Directory instead of DIR_Server as a member. r=bienvenu,sr=neil
This commit is contained in:
parent
b38195389e
commit
b3a33a385e
@ -56,6 +56,7 @@ PACKAGE_FILE = addrbook.pkg
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
necko \
|
||||
pref \
|
||||
mime \
|
||||
rdf \
|
||||
msgbase \
|
||||
|
@ -72,7 +72,7 @@ interface nsIAbDirectoryProperties : nsISupports {
|
||||
attribute long position;
|
||||
};
|
||||
|
||||
[scriptable, uuid(2edfc712-e6c5-11d8-9a39-000a95dc234c)]
|
||||
[scriptable, uuid(d6d55de3-261d-4149-987d-3a88ceb5f2a9)]
|
||||
interface nsIAbDirectory : nsISupports {
|
||||
|
||||
// Types of operation
|
||||
@ -214,6 +214,51 @@ interface nsIAbDirectory : nsISupports {
|
||||
wstring getValueForCard(in nsIAbCard card, in string name);
|
||||
void setValueForCard(in nsIAbCard card, in string name, in wstring value);
|
||||
|
||||
// the id of the directory used in prefs
|
||||
attribute ACString dirPrefId;
|
||||
/**
|
||||
* The id of the directory used in prefs e.g. "ldap_2.servers.pab"
|
||||
* Setting this will cause directoryPrefs to be updated.
|
||||
*/
|
||||
attribute ACString dirPrefId;
|
||||
|
||||
/**
|
||||
* @name getXXXValue
|
||||
*
|
||||
* Helper functions to get different types of pref, but return a default
|
||||
* value if a pref value was not obtained.
|
||||
*
|
||||
* @param aName The name of the pref within the branch dirPrefId to
|
||||
* get a value from.
|
||||
*
|
||||
* @param aDefaultValue The default value to return if getting the pref fails
|
||||
* or the pref is not present.
|
||||
*
|
||||
* @return The value of the pref or the default value.
|
||||
*
|
||||
* @exception NS_ERROR_NOT_INITIALIZED if the pref branch couldn't
|
||||
* be obtained (e.g. dirPrefId isn't set).
|
||||
*/
|
||||
//@{
|
||||
long getIntValue(in string aName, in long aDefaultValue);
|
||||
boolean getBoolValue(in string aName, in boolean aDefaultValue);
|
||||
string getStringValue(in string aName, in string aDefaultValue);
|
||||
//@}
|
||||
|
||||
/**
|
||||
* @name setXXXValue
|
||||
*
|
||||
* Helper functions to set different types of pref values.
|
||||
*
|
||||
* @param aName The name of the pref within the branch dirPrefId to
|
||||
* get a value from.
|
||||
*
|
||||
* @param aValue The value to set the pref to.
|
||||
*
|
||||
* @exception NS_ERROR_NOT_INITIALIZED if the pref branch couldn't
|
||||
* be obtained (e.g. dirPrefId isn't set).
|
||||
*/
|
||||
//@{
|
||||
void setIntValue(in string aName, in long aValue);
|
||||
void setBoolValue(in string aName, in boolean aValue);
|
||||
void setStringValue(in string aName, in string aValue);
|
||||
//@}
|
||||
};
|
||||
|
@ -49,14 +49,39 @@ interface nsIMutableArray;
|
||||
* XXX This should really inherit from nsIAbDirectory, and some day it will.
|
||||
* But for now, doing that complicates implementation.
|
||||
*/
|
||||
[scriptable, uuid(27ef9414-6959-4085-b5e3-bc491c0e6554)]
|
||||
[scriptable, uuid(0780ec5e-0e45-4a42-af26-ab927faace4f)]
|
||||
interface nsIAbLDAPDirectory : nsISupports
|
||||
{
|
||||
/**
|
||||
* If set, these arrays of nsILDAPControls are passed through to the
|
||||
* nsILDAPOperation that searchExt is called on.
|
||||
*/
|
||||
attribute nsIMutableArray searchServerControls;
|
||||
attribute nsIMutableArray searchClientControls;
|
||||
/**
|
||||
* If set, these arrays of nsILDAPControls are passed through to the
|
||||
* nsILDAPOperation that searchExt is called on.
|
||||
*/
|
||||
attribute nsIMutableArray searchServerControls;
|
||||
attribute nsIMutableArray searchClientControls;
|
||||
|
||||
/**
|
||||
* The Replication File Name to use.
|
||||
*/
|
||||
attribute string replicationFileName;
|
||||
|
||||
/**
|
||||
* The version of LDAP protocol in use.
|
||||
*/
|
||||
attribute unsigned long protocolVersion;
|
||||
|
||||
/**
|
||||
* The AuthDN to use to access the server.
|
||||
*/
|
||||
attribute string authDn;
|
||||
|
||||
/**
|
||||
* The Last Change Number used for replication.
|
||||
*/
|
||||
attribute long lastChangeNumber;
|
||||
|
||||
/**
|
||||
* The LDAP server's scoping of the lastChangeNumber.
|
||||
*/
|
||||
attribute string dataVersion;
|
||||
};
|
||||
|
||||
|
@ -37,27 +37,23 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsDirPrefs.h"
|
||||
%}
|
||||
[ptr] native DIR_Server(DIR_Server);
|
||||
|
||||
interface nsIWebProgressListener;
|
||||
interface nsILDAPURL;
|
||||
interface nsILDAPConnection;
|
||||
interface nsILDAPOperation;
|
||||
interface nsIAbLDAPDirectory;
|
||||
|
||||
/**
|
||||
* this interface provides methods to perform LDAP Replication Queries
|
||||
*/
|
||||
[scriptable, uuid(00D568A1-3C3B-11d6-B7B9-00B0D06E5F27)]
|
||||
[scriptable, uuid(91c213f7-a381-4b1d-adf3-af58a2bb95d2)]
|
||||
interface nsIAbLDAPReplicationQuery : nsISupports {
|
||||
|
||||
readonly attribute nsILDAPURL replicationURL;
|
||||
readonly attribute nsILDAPConnection connection;
|
||||
readonly attribute nsILDAPOperation operation;
|
||||
|
||||
[noscript] readonly attribute DIR_Server replicationServerInfo;
|
||||
readonly attribute nsIAbLDAPDirectory lDAPDirectory;
|
||||
|
||||
/**
|
||||
* initialize for the query
|
||||
|
@ -109,7 +109,6 @@ CPPSRCS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsDirPrefs.h \
|
||||
nsAbCardProperty.h \
|
||||
nsAbMDBCardProperty.h \
|
||||
nsVCardObj.h \
|
||||
|
@ -38,21 +38,15 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAbDirProperty.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "prmem.h"
|
||||
#include "nsCRT.h"
|
||||
#include "rdf.h"
|
||||
|
||||
#include "mdb.h"
|
||||
|
||||
nsAbDirProperty::nsAbDirProperty(void)
|
||||
: m_LastModifiedDate(0)
|
||||
{
|
||||
@ -309,7 +303,13 @@ NS_IMETHODIMP nsAbDirProperty::GetDirPrefId(nsACString &aDirPrefId)
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetDirPrefId(const nsACString &aDirPrefId)
|
||||
{
|
||||
m_DirPrefId.Assign(aDirPrefId);
|
||||
if (!m_DirPrefId.Equals(aDirPrefId))
|
||||
{
|
||||
m_DirPrefId.Assign(aDirPrefId);
|
||||
// Clear the directory pref branch so that it is re-initialized next
|
||||
// time its required.
|
||||
m_DirectoryPrefs = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -375,6 +375,101 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbDirProperty::InitDirectoryPrefs()
|
||||
{
|
||||
if (m_DirPrefId.IsEmpty())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCString realPrefId(m_DirPrefId);
|
||||
realPrefId.Append('.');
|
||||
|
||||
return prefService->GetBranch(realPrefId.get(), getter_AddRefs(m_DirectoryPrefs));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetIntValue(const char *aName,
|
||||
PRInt32 aDefaultValue,
|
||||
PRInt32 *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (NS_FAILED(m_DirectoryPrefs->GetIntPref(aName, aResult)))
|
||||
*aResult = aDefaultValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetBoolValue(const char *aName,
|
||||
PRBool aDefaultValue,
|
||||
PRBool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (NS_FAILED(m_DirectoryPrefs->GetBoolPref(aName, aResult)))
|
||||
*aResult = aDefaultValue;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::GetStringValue(const char *aName,
|
||||
const char *aDefaultValue,
|
||||
char * *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsXPIDLCString value;
|
||||
|
||||
if (NS_SUCCEEDED(m_DirectoryPrefs->GetCharPref(aName, getter_Copies(value))))
|
||||
{
|
||||
/* unfortunately, there may be some prefs out there which look like this */
|
||||
*aResult = value.EqualsLiteral("(null)") ?
|
||||
nsCRT::strdup(aDefaultValue) : ToNewCString(value);
|
||||
}
|
||||
else
|
||||
*aResult = nsCRT::strdup(aDefaultValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetIntValue(const char *aName,
|
||||
PRInt32 aValue)
|
||||
{
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return m_DirectoryPrefs->SetIntPref(aName, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetBoolValue(const char *aName,
|
||||
PRBool aValue)
|
||||
{
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return m_DirectoryPrefs->SetBoolPref(aName, aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbDirProperty::SetStringValue(const char *aName,
|
||||
const char *aValue)
|
||||
{
|
||||
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return m_DirectoryPrefs->SetCharPref(aName, aValue);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsAbDirectoryProperties::nsAbDirectoryProperties(void)
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
/*
|
||||
* Address Book Directory
|
||||
@ -68,11 +69,14 @@ public:
|
||||
NS_DECL_NSIABDIRECTORY
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Initialise the directory prefs for this branch
|
||||
*/
|
||||
nsresult InitDirectoryPrefs();
|
||||
|
||||
nsresult GetAttributeName(PRUnichar **aName, nsString& value);
|
||||
nsresult SetAttributeName(const PRUnichar *aName, nsString& arrtibute);
|
||||
|
||||
|
||||
nsString m_DirName;
|
||||
PRUint32 m_LastModifiedDate;
|
||||
|
||||
@ -81,10 +85,8 @@ protected:
|
||||
nsString m_Description;
|
||||
PRBool m_IsMailList;
|
||||
nsCString m_DirPrefId; // ie,"ldap_2.servers.pab"
|
||||
|
||||
|
||||
nsCOMPtr<nsISupportsArray> m_AddressList;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> m_DirectoryPrefs;
|
||||
nsCOMPtr<nsISupportsArray> m_AddressList;
|
||||
};
|
||||
|
||||
class nsAbDirectoryProperties: public nsIAbDirectoryProperties
|
||||
|
@ -1,4 +1,6 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
@ -173,7 +175,7 @@ nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchEntry(nsILDAPMessage *aMessag
|
||||
nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchResult(nsILDAPMessage *aMessage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMessage);
|
||||
if(!mInitialized)
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PRInt32 errorCode;
|
||||
@ -192,20 +194,25 @@ nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchResult(nsILDAPMessage *aMessa
|
||||
// before starting the changeLog check the DB file, if its not there or bogus
|
||||
// we need to create a new one and set to all.
|
||||
nsCOMPtr<nsIAddrBookSession> abSession = do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv);
|
||||
if(NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsCOMPtr<nsILocalFile> dbPath;
|
||||
rv = abSession->GetUserProfileDirectory(getter_AddRefs(dbPath));
|
||||
if(NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = dbPath->AppendNative(nsDependentCString(mDirServerInfo->fileName));
|
||||
if(NS_FAILED(rv))
|
||||
nsXPIDLCString fileName;
|
||||
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
rv = dbPath->AppendNative(fileName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
PRBool fileExists;
|
||||
rv = dbPath->Exists(&fileExists);
|
||||
if(NS_FAILED(rv))
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
PRInt64 fileSize;
|
||||
@ -310,8 +317,6 @@ nsresult nsAbLDAPProcessChangeLogData::GetAuthData()
|
||||
if(NS_SUCCEEDED(rv) && btnResult) {
|
||||
CopyUTF16toUTF8(username, mAuthUserID);
|
||||
CopyUTF16toUTF8(password, mAuthPswd);
|
||||
mDirServerInfo->enableAuth=PR_TRUE;
|
||||
mDirServerInfo->savePassword=PR_TRUE;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
@ -321,8 +326,8 @@ nsresult nsAbLDAPProcessChangeLogData::GetAuthData()
|
||||
|
||||
nsresult nsAbLDAPProcessChangeLogData::OnSearchAuthDNDone()
|
||||
{
|
||||
if(!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsILDAPURL> url;
|
||||
nsresult rv = mQuery->GetReplicationURL(getter_AddRefs(url));
|
||||
@ -330,8 +335,7 @@ nsresult nsAbLDAPProcessChangeLogData::OnSearchAuthDNDone()
|
||||
rv = mQuery->ConnectToLDAPServer(url, mAuthDN);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
mState = kAuthenticatedBinding;
|
||||
PR_FREEIF(mDirServerInfo->authDn);
|
||||
mDirServerInfo->authDn=ToNewCString(mAuthDN);
|
||||
rv = mDirectory->SetAuthDn(mAuthDN.get());
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -340,7 +344,7 @@ nsresult nsAbLDAPProcessChangeLogData::OnSearchAuthDNDone()
|
||||
nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(nsILDAPMessage *aMessage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMessage);
|
||||
if(!mInitialized)
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// populate the RootDSEChangeLogEntry
|
||||
@ -367,13 +371,16 @@ nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(nsILDAPMessage *aMessag
|
||||
}
|
||||
}
|
||||
|
||||
if((mRootDSEEntry.lastChangeNumber > 0)
|
||||
&& (mDirServerInfo->replInfo->lastChangeNumber < mRootDSEEntry.lastChangeNumber)
|
||||
&& (mDirServerInfo->replInfo->lastChangeNumber > mRootDSEEntry.firstChangeNumber)
|
||||
)
|
||||
PRInt32 lastChangeNumber;
|
||||
mDirectory->GetLastChangeNumber(&lastChangeNumber);
|
||||
|
||||
if ((mRootDSEEntry.lastChangeNumber > 0) &&
|
||||
(lastChangeNumber < mRootDSEEntry.lastChangeNumber) &&
|
||||
(lastChangeNumber > mRootDSEEntry.firstChangeNumber))
|
||||
mUseChangeLog = PR_TRUE;
|
||||
|
||||
if(mRootDSEEntry.lastChangeNumber && (mDirServerInfo->replInfo->lastChangeNumber == mRootDSEEntry.lastChangeNumber)) {
|
||||
if (mRootDSEEntry.lastChangeNumber &&
|
||||
(lastChangeNumber == mRootDSEEntry.lastChangeNumber)) {
|
||||
Done(PR_TRUE); // we are up to date no need to replicate, db not open yet so call Done
|
||||
return NS_OK;
|
||||
}
|
||||
@ -383,7 +390,7 @@ nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(nsILDAPMessage *aMessag
|
||||
|
||||
nsresult nsAbLDAPProcessChangeLogData::OnSearchRootDSEDone()
|
||||
{
|
||||
if(!mInitialized)
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
@ -405,9 +412,10 @@ nsresult nsAbLDAPProcessChangeLogData::OnSearchRootDSEDone()
|
||||
mListener->OnStateChange(nsnull, nsnull, nsIWebProgressListener::STATE_START, PR_TRUE);
|
||||
}
|
||||
|
||||
mDirServerInfo->replInfo->lastChangeNumber = mRootDSEEntry.lastChangeNumber;
|
||||
PR_FREEIF(mDirServerInfo->replInfo->dataVersion);
|
||||
mDirServerInfo->replInfo->dataVersion = ToNewCString(mRootDSEEntry.dataVersion);
|
||||
rv = mDirectory->SetLastChangeNumber(mRootDSEEntry.lastChangeNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDirectory->SetDataVersion(mRootDSEEntry.dataVersion.get());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
@ -118,8 +118,8 @@ NS_IMETHODIMP nsAbLDAPChangeLogQuery::DoReplicationQuery()
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryAuthDN(const nsACString & aValueUsedToFindDn)
|
||||
{
|
||||
if(!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -127,9 +127,16 @@ NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryAuthDN(const nsACString & aValueUsedT
|
||||
do_GetService("@mozilla.org/addressbook/ldap-attribute-map-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbLDAPAttributeMap> attrMap;
|
||||
rv = mapSvc->GetMapForPrefBranch(nsDependentCString(mDirServer->prefName), getter_AddRefs(attrMap));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIAbDirectory> abDirectory(do_QueryInterface(mDirectory, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString prefBaseName;
|
||||
rv = abDirectory->GetDirPrefId(prefBaseName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbLDAPAttributeMap> attrMap;
|
||||
rv = mapSvc->GetMapForPrefBranch(prefBaseName, getter_AddRefs(attrMap));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString filter;
|
||||
rv = attrMap->GetFirstAttribute(NS_LITERAL_CSTRING("PrimaryEmail"), filter);
|
||||
@ -168,23 +175,27 @@ NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryRootDSE()
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryChangeLog(const nsACString & aChangeLogDN, PRInt32 aLastChangeNo)
|
||||
{
|
||||
if(!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if(aChangeLogDN.IsEmpty())
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (aChangeLogDN.IsEmpty())
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// make sure that the filter here just have one condition
|
||||
// and should not be enclosed in enclosing brackets.
|
||||
// also condition '>' doesnot work, it should be '>='/
|
||||
nsCAutoString filter (NS_LITERAL_CSTRING("changenumber>="));
|
||||
filter.AppendInt(mDirServer->replInfo->lastChangeNumber+1);
|
||||
PRInt32 lastChangeNumber;
|
||||
nsresult rv = mDirectory->GetLastChangeNumber(&lastChangeNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult rv = CreateNewLDAPOperation();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// make sure that the filter here just have one condition
|
||||
// and should not be enclosed in enclosing brackets.
|
||||
// also condition '>' doesnot work, it should be '>='/
|
||||
nsCAutoString filter (NS_LITERAL_CSTRING("changenumber>="));
|
||||
filter.AppendInt(lastChangeNumber + 1);
|
||||
|
||||
return mOperation->SearchExt(aChangeLogDN, nsILDAPURL::SCOPE_ONELEVEL, filter,
|
||||
sizeof(sChangeLogEntryAttribs),
|
||||
sChangeLogEntryAttribs, 0, 0);
|
||||
rv = CreateNewLDAPOperation();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return mOperation->SearchExt(aChangeLogDN, nsILDAPURL::SCOPE_ONELEVEL, filter,
|
||||
sizeof(sChangeLogEntryAttribs),
|
||||
sChangeLogEntryAttribs, 0, 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPChangeLogQuery::QueryChangedEntries(const nsACString & aChangedEntryDN)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -493,16 +493,8 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetIsSecure(PRBool *aIsSecure)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsSecure);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// use mURINoQuery to get a prefName
|
||||
nsCAutoString prefName;
|
||||
prefName = nsDependentCString(mURINoQuery.get() + kLDAPDirectoryRootLen) + NS_LITERAL_CSTRING(".uri");
|
||||
|
||||
nsXPIDLCString URI;
|
||||
rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(URI));
|
||||
nsresult rv = GetStringValue("uri", "", getter_Copies(URI));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// to determine if this is a secure directory, check if the uri is ldaps:// or not
|
||||
@ -548,3 +540,69 @@ nsAbLDAPDirectory::SetSearchServerControls(nsIMutableArray *aControls)
|
||||
mSearchServerControls = aControls;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetProtocolVersion(PRUint32 *aProtocolVersion)
|
||||
{
|
||||
nsXPIDLCString versionString;
|
||||
|
||||
nsresult rv = GetStringValue("protocolVersion", "3",
|
||||
getter_Copies(versionString));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aProtocolVersion = versionString.EqualsLiteral("3") ?
|
||||
(PRUint32)nsILDAPConnection::VERSION3 :
|
||||
(PRUint32)nsILDAPConnection::VERSION2;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::SetProtocolVersion(PRUint32 aProtocolVersion)
|
||||
{
|
||||
// XXX We should cancel any existing LDAP connections here and
|
||||
// be ready to re-initialise them with the new auth details.
|
||||
return SetStringValue("protocolVersion",
|
||||
aProtocolVersion == nsILDAPConnection::VERSION3 ? "3" : "2");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetReplicationFileName(char* *aReplicationFileName)
|
||||
{
|
||||
return GetStringValue("filename", "", aReplicationFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::SetReplicationFileName(const char* aReplicationFileName)
|
||||
{
|
||||
return SetStringValue("filename", aReplicationFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetAuthDn(char * *aAuthDn)
|
||||
{
|
||||
return GetStringValue("auth.Dn", "", aAuthDn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::SetAuthDn(const char* aAuthDn)
|
||||
{
|
||||
// XXX We should cancel any existing LDAP connections here and
|
||||
// be ready to re-initialise them with the new auth details.
|
||||
return SetStringValue("auth.Dn", aAuthDn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetLastChangeNumber(PRInt32 *aLastChangeNumber)
|
||||
{
|
||||
return GetIntValue("lastChangeNumber", -1, aLastChangeNumber);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::SetLastChangeNumber(PRInt32 aLastChangeNumber)
|
||||
{
|
||||
return SetIntValue("lastChangeNumber", aLastChangeNumber);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::GetDataVersion(char * *aDataVersion)
|
||||
{
|
||||
return GetStringValue("dataVersion", "", aDataVersion);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPDirectory::SetDataVersion(const char* aDataVersion)
|
||||
{
|
||||
return SetStringValue("dataVersion", aDataVersion);
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,7 @@ nsAbLDAPProcessReplicationData::nsAbLDAPProcessReplicationData()
|
||||
mProtocol(-1),
|
||||
mCount(0),
|
||||
mDBOpen(PR_FALSE),
|
||||
mInitialized(PR_FALSE),
|
||||
mDirServerInfo(nsnull)
|
||||
mInitialized(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -79,24 +78,38 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::Init(nsIAbLDAPReplicationQuery *qu
|
||||
|
||||
mQuery = query;
|
||||
|
||||
nsresult rv = mQuery->GetReplicationServerInfo(&mDirServerInfo);
|
||||
nsresult rv = mQuery->GetLDAPDirectory(getter_AddRefs(mDirectory));
|
||||
if(NS_FAILED(rv)) {
|
||||
mQuery = nsnull;
|
||||
return rv;
|
||||
}
|
||||
if(!mDirServerInfo) {
|
||||
mQuery = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAbLDAPAttributeMapService> mapSvc =
|
||||
do_GetService("@mozilla.org/addressbook/ldap-attribute-map-service;1",
|
||||
&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
mQuery = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mapSvc->GetMapForPrefBranch(
|
||||
nsDependentCString(mDirServerInfo->prefName), getter_AddRefs(mAttrMap));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIAbDirectory> abDirectory(do_QueryInterface(mDirectory, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
mQuery = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsXPIDLCString prefBaseName;
|
||||
rv = abDirectory->GetDirPrefId(prefBaseName);
|
||||
if (NS_FAILED(rv)) {
|
||||
mQuery = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mapSvc->GetMapForPrefBranch(prefBaseName, getter_AddRefs(mAttrMap));
|
||||
if (NS_FAILED(rv)) {
|
||||
mQuery = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
mListener = progressListener;
|
||||
|
||||
@ -234,10 +247,12 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::Abort()
|
||||
// delete the unsaved replication file
|
||||
if(mReplicationFile) {
|
||||
rv = mReplicationFile->Remove(PR_FALSE);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
if(NS_SUCCEEDED(rv) && mDirectory) {
|
||||
nsXPIDLCString fileName;
|
||||
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
|
||||
// now put back the backed up replicated file if aborted
|
||||
if(mBackupReplicationFile && mDirServerInfo->replInfo)
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, nsDependentCString(mDirServerInfo->fileName));
|
||||
if(NS_SUCCEEDED(rv) && mBackupReplicationFile)
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,9 +266,15 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::Abort()
|
||||
// this should get the authDN from prefs and password from PswdMgr
|
||||
NS_IMETHODIMP nsAbLDAPProcessReplicationData::PopulateAuthData()
|
||||
{
|
||||
mAuthDN.Assign(mDirServerInfo->authDn);
|
||||
if (!mDirectory)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsXPIDLCString authDn;
|
||||
nsresult rv = mDirectory->GetAuthDn(getter_Copies(authDn));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mAuthDN.Assign(authDn);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr <nsIPasswordManagerInternal> passwordMgrInt = do_GetService(NS_PASSWORDMANAGER_CONTRACTID, &rv);
|
||||
if(NS_SUCCEEDED(rv) && passwordMgrInt) {
|
||||
// Get the current server URI
|
||||
@ -460,10 +481,15 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchResult(nsILDAPMessage *aMes
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Replication File Remove on Failure failed");
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
// now put back the backed up replicated file
|
||||
if(mBackupReplicationFile && mDirServerInfo->replInfo)
|
||||
if(mBackupReplicationFile && mDirectory)
|
||||
{
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, nsDependentCString(mDirServerInfo->fileName));
|
||||
nsXPIDLCString fileName;
|
||||
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
|
||||
if (NS_SUCCEEDED(rv) && !fileName.IsEmpty())
|
||||
{
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, fileName);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Replication Backup File Move back on Failure failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -475,7 +501,7 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchResult(nsILDAPMessage *aMes
|
||||
|
||||
nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
||||
{
|
||||
if(!mInitialized)
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
@ -486,10 +512,13 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
||||
return rv;
|
||||
}
|
||||
|
||||
if(!mDirServerInfo->fileName) {
|
||||
Done(PR_FALSE);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsXPIDLCString fileName;
|
||||
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
|
||||
if (NS_FAILED(rv) || fileName.IsEmpty())
|
||||
{
|
||||
Done(PR_FALSE);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = abSession->GetUserProfileDirectory(getter_AddRefs(mReplicationFile));
|
||||
if(NS_FAILED(rv)) {
|
||||
@ -497,7 +526,7 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mReplicationFile->AppendNative(nsDependentCString(mDirServerInfo->fileName));
|
||||
rv = mReplicationFile->AppendNative(fileName);
|
||||
if(NS_FAILED(rv)) {
|
||||
Done(PR_FALSE);
|
||||
return rv;
|
||||
@ -545,7 +574,8 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
||||
|
||||
if(aCreate) {
|
||||
// set backup file to existing replication file for move
|
||||
mBackupReplicationFile->SetNativeLeafName(nsDependentCString(mDirServerInfo->fileName));
|
||||
mBackupReplicationFile->SetNativeLeafName(fileName);
|
||||
|
||||
rv = mBackupReplicationFile->MoveTo(nsnull, backupFileLeafName);
|
||||
// set the backup file leaf name now
|
||||
if (NS_SUCCEEDED(rv))
|
||||
@ -553,7 +583,8 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
||||
}
|
||||
else {
|
||||
// set backup file to existing replication file for copy
|
||||
mBackupReplicationFile->SetNativeLeafName(nsDependentCString(mDirServerInfo->fileName));
|
||||
mBackupReplicationFile->SetNativeLeafName(fileName);
|
||||
|
||||
// specify the parent here specifically,
|
||||
// passing nsnull to copy to the same dir actually renames existing file
|
||||
// instead of making another copy of the existing file.
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIAbLDAPAttributeMap.h"
|
||||
#include "nsIAbLDAPDirectory.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsAbLDAPProcessReplicationData : public nsIAbLDAPProcessReplicationData
|
||||
@ -77,7 +78,7 @@ protected :
|
||||
PRBool mDBOpen;
|
||||
PRBool mInitialized;
|
||||
|
||||
DIR_Server * mDirServerInfo;
|
||||
nsCOMPtr<nsIAbLDAPDirectory> mDirectory;
|
||||
nsCString mAuthDN; // authDN of the user
|
||||
nsCString mAuthPswd; // pswd of the authDN user
|
||||
nsCOMPtr<nsIAbLDAPAttributeMap> mAttrMap; // maps ab properties to ldap attrs
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -50,59 +50,85 @@
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIRDFService.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAbLDAPReplicationQuery, nsIAbLDAPReplicationQuery)
|
||||
|
||||
nsAbLDAPReplicationQuery::nsAbLDAPReplicationQuery()
|
||||
: mInitialized(PR_FALSE),
|
||||
mDirServer(nsnull)
|
||||
: mInitialized(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsAbLDAPReplicationQuery::~nsAbLDAPReplicationQuery()
|
||||
{
|
||||
DIR_DeleteServer(mDirServer);
|
||||
}
|
||||
|
||||
nsresult nsAbLDAPReplicationQuery::InitLDAPData()
|
||||
{
|
||||
mDirServer = (DIR_Server *) PR_Calloc(1, sizeof(DIR_Server));
|
||||
if (!mDirServer) return NS_ERROR_NULL_POINTER;
|
||||
nsresult rv;
|
||||
|
||||
DIR_InitServerWithType(mDirServer, LDAPDirectory);
|
||||
// since DeleteServer frees the prefName make a copy of prefName string
|
||||
mDirServer->prefName = nsCRT::strdup(mDirPrefName.get());
|
||||
DIR_GetPrefsForOneServer(mDirServer, PR_FALSE, PR_FALSE);
|
||||
nsCOMPtr<nsIRDFService> rdfService = do_GetService("@mozilla.org/rdf/rdf-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString resourceURI(kLDAPDirectoryRoot);
|
||||
resourceURI.Append(mDirPrefName);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource(resourceURI, getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mDirectory = do_QueryInterface(resource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString fileName;
|
||||
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// this is done here to take care of the problem related to bug # 99124.
|
||||
// earlier versions of Mozilla could have the fileName associated with the directory
|
||||
// to be abook.mab which is the profile's personal addressbook. If the pref points to
|
||||
// it, calls nsDirPrefs to generate a new server filename.
|
||||
if (!nsCRT::strcasecmp(mDirServer->fileName,kPersonalAddressbook)
|
||||
|| !mDirServer->fileName || !(*mDirServer->fileName)) {
|
||||
// initialize mDirServer->filename is null or else DIR_SetServerFileName doesnot work
|
||||
PR_FREEIF(mDirServer->fileName);
|
||||
mDirServer->fileName=nsnull;
|
||||
DIR_SetServerFileName(mDirServer);
|
||||
// this is done here to take care of the problem related to bug # 99124.
|
||||
// earlier versions of Mozilla could have the fileName associated with the directory
|
||||
// to be abook.mab which is the profile's personal addressbook. If the pref points to
|
||||
// it, calls nsDirPrefs to generate a new server filename.
|
||||
if (fileName.IsEmpty() || fileName.Equals(NS_LITERAL_CSTRING(kPersonalAddressbook)))
|
||||
{
|
||||
// Ensure fileName is empty for DIR_GenerateAbFileName to work
|
||||
// correctly.
|
||||
fileName.Truncate();
|
||||
// XXX This should be replaced by a local function at some stage.
|
||||
// For now we'll continue using the nsDirPrefs version.
|
||||
DIR_Server* server = DIR_GetServerFromList(mDirPrefName.get());
|
||||
if (server)
|
||||
{
|
||||
DIR_SetServerFileName(server);
|
||||
// Now ensure the prefs are saved
|
||||
DIR_SavePrefsForOneServer(server);
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mURL = do_CreateInstance(NS_LDAPURL_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = mURL->SetSpec(nsDependentCString(mDirServer->uri));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mOperation = do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
|
||||
|
||||
}
|
||||
|
||||
rv = mDirectory->SetReplicationFileName(fileName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mURL = do_CreateInstance(NS_LDAPURL_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIAbDirectory> abDirectory(do_QueryInterface(mDirectory, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIAbDirectoryProperties> dirProperties;
|
||||
rv = abDirectory->GetDirectoryProperties(getter_AddRefs(dirProperties));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXPIDLCString uri;
|
||||
rv = dirProperties->GetURI(getter_Copies(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mURL->SetSpec(uri);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mOperation = do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbLDAPReplicationQuery::CreateNewLDAPOperation()
|
||||
@ -171,11 +197,8 @@ NS_IMETHODIMP nsAbLDAPReplicationQuery::ConnectToLDAPServer(nsILDAPURL *aURL, co
|
||||
}
|
||||
|
||||
PRUint32 protocolVersion;
|
||||
if (DIR_TestFlag(mDirServer, DIR_LDAP_VERSION3)) {
|
||||
protocolVersion = nsILDAPConnection::VERSION3;
|
||||
} else {
|
||||
protocolVersion = nsILDAPConnection::VERSION2;
|
||||
}
|
||||
rv = mDirectory->GetProtocolVersion(&protocolVersion);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// initialize the LDAP connection
|
||||
return mConnection->Init(host.get(), port,
|
||||
@ -264,9 +287,6 @@ NS_IMETHODIMP nsAbLDAPReplicationQuery::Done(PRBool aSuccess)
|
||||
if (NS_SUCCEEDED(rv))
|
||||
replicationService->Done(aSuccess);
|
||||
|
||||
if (aSuccess)
|
||||
DIR_SavePrefsForOneServer(mDirServer);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -304,14 +324,11 @@ NS_IMETHODIMP nsAbLDAPReplicationQuery::GetReplicationURL(nsILDAPURL * *aReplica
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbLDAPReplicationQuery::GetReplicationServerInfo(DIR_Server * *aReplicationServerInfo)
|
||||
NS_IMETHODIMP nsAbLDAPReplicationQuery::GetLDAPDirectory(nsIAbLDAPDirectory * *aDirectory)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReplicationServerInfo);
|
||||
if (!mInitialized)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
NS_ENSURE_ARG_POINTER(aDirectory);
|
||||
|
||||
*aReplicationServerInfo = mDirServer;
|
||||
NS_IF_ADDREF(*aDirectory = mDirectory);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIAbLDAPReplicationQuery.h"
|
||||
#include "nsIAbLDAPReplicationData.h"
|
||||
#include "nsIAbLDAPDirectory.h"
|
||||
#include "nsILDAPConnection.h"
|
||||
#include "nsILDAPOperation.h"
|
||||
#include "nsILDAPURL.h"
|
||||
@ -55,7 +56,6 @@ public:
|
||||
NS_DECL_NSIABLDAPREPLICATIONQUERY
|
||||
|
||||
nsAbLDAPReplicationQuery();
|
||||
virtual ~nsAbLDAPReplicationQuery();
|
||||
|
||||
nsresult InitLDAPData();
|
||||
nsresult CreateNewLDAPOperation();
|
||||
@ -65,13 +65,12 @@ protected :
|
||||
nsCOMPtr<nsILDAPConnection> mConnection;
|
||||
nsCOMPtr<nsILDAPOperation> mOperation;
|
||||
nsCOMPtr<nsILDAPURL> mURL;
|
||||
nsCOMPtr<nsIAbLDAPDirectory> mDirectory;
|
||||
|
||||
nsCOMPtr<nsIAbLDAPProcessReplicationData> mDataProcessor;
|
||||
|
||||
PRBool mInitialized;
|
||||
nsCString mDirPrefName;
|
||||
DIR_Server * mDirServer;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsAbLDAPReplicationQuery_h__
|
||||
|
@ -236,6 +236,31 @@ nsresult DIR_GetDirServers()
|
||||
return rv;
|
||||
}
|
||||
|
||||
DIR_Server* DIR_GetServerFromList(const char* prefName)
|
||||
{
|
||||
DIR_Server* result = nsnull;
|
||||
|
||||
if (!dir_ServerList)
|
||||
DIR_GetDirServers();
|
||||
|
||||
if (dir_ServerList)
|
||||
{
|
||||
PRInt32 count = dir_ServerList->Count();
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
DIR_Server *server = (DIR_Server *)dir_ServerList->ElementAt(i);
|
||||
|
||||
if (server && strcmp(server->prefName, prefName) == 0)
|
||||
{
|
||||
result = server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static nsresult dir_ConvertToMabFileName()
|
||||
{
|
||||
if (dir_ServerList)
|
||||
|
@ -155,6 +155,7 @@ typedef struct DIR_Server
|
||||
|
||||
nsVoidArray* DIR_GetDirectories();
|
||||
nsresult DIR_GetDirServers();
|
||||
DIR_Server* DIR_GetServerFromList(const char* prefName);
|
||||
nsresult DIR_ShutDown(void); /* FEs should call this when the app is shutting down. It frees all DIR_Servers regardless of ref count values! */
|
||||
|
||||
nsresult DIR_AddNewAddressBook(const PRUnichar *dirName, const char *fileName, PRBool migrating, const char * uri, int maxHits, const char * authDn, DirectoryType dirType, DIR_Server** pServer);
|
||||
|
Loading…
Reference in New Issue
Block a user