Bug 331557 Remove nsIAbDirectoryProperties (Convert pref functions to use ACString for values) r=bienvenu,sr=neil

This commit is contained in:
bugzilla%standard8.demon.co.uk 2006-05-14 11:00:18 +00:00
Родитель 8972c479c0
Коммит f25f77e558
10 изменённых файлов: 78 добавлений и 98 удалений

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

@ -58,7 +58,7 @@
// used for when creating new directories
// either from user input, or during bootstrapping
[scriptable, uuid(f94812de-1dd1-11b2-b0ab-9eb5e055f712)]
[scriptable, uuid(1c10fa4e-a7f2-4731-a3ec-a78be1086e29)]
interface nsIAbDirectoryProperties : nsISupports {
attribute AString description;
attribute string URI;
@ -100,8 +100,7 @@ interface nsIAbDirectory : nsISupports {
// eliminated a bit more.
// The filename for address books within this directory.
// XXX This needs to be a ACString when Get*StringValue change
readonly attribute string fileName;
readonly attribute ACString fileName;
// The URI of the address book
readonly attribute ACString URI;
@ -264,9 +263,8 @@ interface nsIAbDirectory : nsISupports {
//@{
long getIntValue(in string aName, in long aDefaultValue);
boolean getBoolValue(in string aName, in boolean aDefaultValue);
// XXX to do, convert Get*StringValue & users to use nsACString for result
string getStringValue(in string aName, in string aDefaultValue);
string getLocalizedStringValue(in string aName, in string aDefaultValue);
ACString getStringValue(in string aName, in ACString aDefaultValue);
AUTF8String getLocalizedStringValue(in string aName, in AUTF8String aDefaultValue);
//@}
/**
@ -285,6 +283,6 @@ interface nsIAbDirectory : nsISupports {
//@{
void setIntValue(in string aName, in long aValue);
void setBoolValue(in string aName, in boolean aValue);
void setStringValue(in string aName, in string aValue);
void setStringValue(in string aName, in ACString aValue);
//@}
};

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

@ -49,7 +49,7 @@ interface nsIMutableArray;
* XXX This should really inherit from nsIAbDirectory, and some day it will.
* But for now, doing that complicates implementation.
*/
[scriptable, uuid(0780ec5e-0e45-4a42-af26-ab927faace4f)]
[scriptable, uuid(78d1b2df-ab00-4ffc-abca-16b286a63df6)]
interface nsIAbLDAPDirectory : nsISupports
{
/**
@ -62,7 +62,7 @@ interface nsIAbLDAPDirectory : nsISupports
/**
* The Replication File Name to use.
*/
attribute string replicationFileName;
attribute ACString replicationFileName;
/**
* The version of LDAP protocol in use.
@ -72,7 +72,7 @@ interface nsIAbLDAPDirectory : nsISupports
/**
* The AuthDN to use to access the server.
*/
attribute string authDn;
attribute ACString authDn;
/**
* The Last Change Number used for replication.
@ -82,6 +82,6 @@ interface nsIAbLDAPDirectory : nsISupports
/**
* The LDAP server's scoping of the lastChangeNumber.
*/
attribute string dataVersion;
attribute ACString dataVersion;
};

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

@ -116,9 +116,9 @@ NS_IMETHODIMP nsAbDirProperty::GetDirType(PRInt32 *aDirType)
return GetIntValue("dirType", LDAPDirectory, aDirType);
}
NS_IMETHODIMP nsAbDirProperty::GetFileName(char* *aFileName)
NS_IMETHODIMP nsAbDirProperty::GetFileName(nsACString &aFileName)
{
return GetStringValue("filename", "", aFileName);
return GetStringValue("filename", EmptyCString(), aFileName);
}
NS_IMETHODIMP nsAbDirProperty::GetURI(nsACString &aURI)
@ -363,17 +363,17 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
rv = properties->SetPrefName(m_DirPrefId.get());
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString prefStringValue;
nsCAutoString prefStringValue;
PRInt32 prefIntValue;
if (m_DirPrefId.EqualsLiteral("ldap_2.servers.pab") ||
m_DirPrefId.EqualsLiteral("ldap_2.servers.history"))
{
// get default address book name from addressbook.properties
rv = GetLocalizedStringValue("description", "", getter_Copies(prefStringValue));
rv = GetLocalizedStringValue("description", EmptyCString(), prefStringValue);
}
else
{
rv = GetStringValue("description", "", getter_Copies(prefStringValue));
rv = GetStringValue("description", EmptyCString(), prefStringValue);
}
NS_ENSURE_SUCCESS(rv, rv);
@ -386,17 +386,17 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
rv = properties->SetDirType(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetFileName(getter_Copies(prefStringValue));
rv = GetFileName(prefStringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetFileName(prefStringValue);
rv = properties->SetFileName(prefStringValue.get());
NS_ENSURE_SUCCESS(rv, rv);
// the string "s" is the default uri ( <scheme> + "://" + <filename> )
rv = GetURI(prefStringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetURI(prefStringValue);
rv = properties->SetURI(prefStringValue.get());
NS_ENSURE_SUCCESS(rv, rv);
rv = GetIntValue("maxHits", kDefaultMaxHits, &prefIntValue);
@ -405,10 +405,10 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
rv = properties->SetMaxHits(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetStringValue("auth.dn", nsnull, getter_Copies(prefStringValue));
rv = GetStringValue("auth.dn", EmptyCString(), prefStringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetAuthDn(prefStringValue);
rv = properties->SetAuthDn(prefStringValue.get());
NS_ENSURE_SUCCESS(rv, rv);
rv = GetPalmSyncCategoryId(&prefIntValue);
@ -481,24 +481,20 @@ NS_IMETHODIMP nsAbDirProperty::GetBoolValue(const char *aName,
}
NS_IMETHODIMP nsAbDirProperty::GetStringValue(const char *aName,
const char *aDefaultValue,
char * *aResult)
const nsACString &aDefaultValue,
nsACString &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);
}
/* unfortunately, there may be some prefs out there which look like (null) */
if (NS_SUCCEEDED(m_DirectoryPrefs->GetCharPref(aName, getter_Copies(value))) &&
!value.EqualsLiteral("(null"))
aResult = value;
else
*aResult = nsCRT::strdup(aDefaultValue);
aResult = aDefaultValue;
return NS_OK;
}
@ -510,11 +506,9 @@ NS_IMETHODIMP nsAbDirProperty::GetStringValue(const char *aName,
* "ldap_2.servers.history.description"
*/
NS_IMETHODIMP nsAbDirProperty::GetLocalizedStringValue(const char *aName,
const char *aDefaultValue,
char * *aResult)
const nsACString &aDefaultValue,
nsACString &aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
return NS_ERROR_NOT_INITIALIZED;
@ -531,9 +525,9 @@ NS_IMETHODIMP nsAbDirProperty::GetLocalizedStringValue(const char *aName,
}
if (wvalue.IsEmpty())
*aResult = aDefaultValue ? nsCRT::strdup(aDefaultValue) : nsnull;
aResult = aDefaultValue;
else
*aResult = ToNewUTF8String(wvalue);
CopyUTF16toUTF8(wvalue, aResult);
return NS_OK;
}
@ -557,12 +551,12 @@ NS_IMETHODIMP nsAbDirProperty::SetBoolValue(const char *aName,
}
NS_IMETHODIMP nsAbDirProperty::SetStringValue(const char *aName,
const char *aValue)
const nsACString &aValue)
{
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
return NS_ERROR_NOT_INITIALIZED;
return m_DirectoryPrefs->SetCharPref(aName, aValue);
return m_DirectoryPrefs->SetCharPref(aName, PromiseFlatCString(aValue).get());
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

@ -201,8 +201,8 @@ nsresult nsAbLDAPProcessChangeLogData::OnLDAPSearchResult(nsILDAPMessage *aMessa
if (NS_FAILED(rv))
break;
nsXPIDLCString fileName;
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = mDirectory->GetReplicationFileName(fileName);
if (NS_FAILED(rv))
break;
@ -335,7 +335,7 @@ nsresult nsAbLDAPProcessChangeLogData::OnSearchAuthDNDone()
rv = mQuery->ConnectToLDAPServer(url, mAuthDN);
if(NS_SUCCEEDED(rv)) {
mState = kAuthenticatedBinding;
rv = mDirectory->SetAuthDn(mAuthDN.get());
rv = mDirectory->SetAuthDn(mAuthDN);
}
return rv;
@ -415,7 +415,7 @@ nsresult nsAbLDAPProcessChangeLogData::OnSearchRootDSEDone()
rv = mDirectory->SetLastChangeNumber(mRootDSEEntry.lastChangeNumber);
NS_ENSURE_SUCCESS(rv, rv);
rv = mDirectory->SetDataVersion(mRootDSEEntry.dataVersion.get());
rv = mDirectory->SetDataVersion(mRootDSEEntry.dataVersion);
return rv;
}

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

@ -208,20 +208,16 @@ nsresult nsAbLDAPDirectory::InitiateConnection ()
NS_IMETHODIMP nsAbLDAPDirectory::GetURI(nsACString &aURI)
{
// XXX to do, convert GetStringValue & users to use nsACString for result
nsXPIDLCString result;
nsresult rv = GetStringValue("uri", "", getter_Copies(result));
nsresult rv = GetStringValue("uri", EmptyCString(), aURI);
if (result.IsEmpty())
if (aURI.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
rv = GetFileName(aURI);
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kLDAPDirectoryRoot, 0);
aURI.Insert(kLDAPDirectoryRoot, 0);
}
aURI = result;
return NS_OK;
}
@ -512,9 +508,9 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetIsSecure(PRBool *aIsSecure)
{
NS_ENSURE_ARG_POINTER(aIsSecure);
nsXPIDLCString URI;
nsresult rv = GetStringValue("uri", "", getter_Copies(URI));
NS_ENSURE_SUCCESS(rv,rv);
nsCAutoString URI;
nsresult rv = GetStringValue("uri", EmptyCString(), URI);
NS_ENSURE_SUCCESS(rv, rv);
// to determine if this is a secure directory, check if the uri is ldaps:// or not
*aIsSecure = (strncmp(URI.get(), "ldaps:", 6) == 0);
@ -562,10 +558,9 @@ nsAbLDAPDirectory::SetSearchServerControls(nsIMutableArray *aControls)
NS_IMETHODIMP nsAbLDAPDirectory::GetProtocolVersion(PRUint32 *aProtocolVersion)
{
nsXPIDLCString versionString;
nsCAutoString versionString;
nsresult rv = GetStringValue("protocolVersion", "3",
getter_Copies(versionString));
nsresult rv = GetStringValue("protocolVersion", NS_LITERAL_CSTRING("3"), versionString);
NS_ENSURE_SUCCESS(rv, rv);
*aProtocolVersion = versionString.EqualsLiteral("3") ?
@ -580,25 +575,26 @@ 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");
aProtocolVersion == nsILDAPConnection::VERSION3 ?
NS_LITERAL_CSTRING("3") : NS_LITERAL_CSTRING("2"));
}
NS_IMETHODIMP nsAbLDAPDirectory::GetReplicationFileName(char* *aReplicationFileName)
NS_IMETHODIMP nsAbLDAPDirectory::GetReplicationFileName(nsACString &aReplicationFileName)
{
return GetStringValue("filename", "", aReplicationFileName);
return GetStringValue("filename", EmptyCString(), aReplicationFileName);
}
NS_IMETHODIMP nsAbLDAPDirectory::SetReplicationFileName(const char* aReplicationFileName)
NS_IMETHODIMP nsAbLDAPDirectory::SetReplicationFileName(const nsACString &aReplicationFileName)
{
return SetStringValue("filename", aReplicationFileName);
}
NS_IMETHODIMP nsAbLDAPDirectory::GetAuthDn(char * *aAuthDn)
NS_IMETHODIMP nsAbLDAPDirectory::GetAuthDn(nsACString &aAuthDn)
{
return GetStringValue("auth.Dn", "", aAuthDn);
return GetStringValue("auth.Dn", EmptyCString(), aAuthDn);
}
NS_IMETHODIMP nsAbLDAPDirectory::SetAuthDn(const char* aAuthDn)
NS_IMETHODIMP nsAbLDAPDirectory::SetAuthDn(const nsACString &aAuthDn)
{
// XXX We should cancel any existing LDAP connections here and
// be ready to re-initialise them with the new auth details.
@ -615,12 +611,12 @@ NS_IMETHODIMP nsAbLDAPDirectory::SetLastChangeNumber(PRInt32 aLastChangeNumber)
return SetIntValue("lastChangeNumber", aLastChangeNumber);
}
NS_IMETHODIMP nsAbLDAPDirectory::GetDataVersion(char * *aDataVersion)
NS_IMETHODIMP nsAbLDAPDirectory::GetDataVersion(nsACString &aDataVersion)
{
return GetStringValue("dataVersion", "", aDataVersion);
return GetStringValue("dataVersion", EmptyCString(), aDataVersion);
}
NS_IMETHODIMP nsAbLDAPDirectory::SetDataVersion(const char* aDataVersion)
NS_IMETHODIMP nsAbLDAPDirectory::SetDataVersion(const nsACString &aDataVersion)
{
return SetStringValue("dataVersion", aDataVersion);
}

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

@ -247,8 +247,8 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::Abort()
if(mReplicationFile) {
rv = mReplicationFile->Remove(PR_FALSE);
if(NS_SUCCEEDED(rv) && mDirectory) {
nsXPIDLCString fileName;
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = mDirectory->GetReplicationFileName(fileName);
// now put back the backed up replicated file if aborted
if(NS_SUCCEEDED(rv) && mBackupReplicationFile)
rv = mBackupReplicationFile->MoveToNative(nsnull, fileName);
@ -268,8 +268,8 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::PopulateAuthData()
if (!mDirectory)
return NS_ERROR_NOT_INITIALIZED;
nsXPIDLCString authDn;
nsresult rv = mDirectory->GetAuthDn(getter_Copies(authDn));
nsCAutoString authDn;
nsresult rv = mDirectory->GetAuthDn(authDn);
NS_ENSURE_SUCCESS(rv, rv);
mAuthDN.Assign(authDn);
@ -482,8 +482,8 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchResult(nsILDAPMessage *aMes
// now put back the backed up replicated file
if(mBackupReplicationFile && mDirectory)
{
nsXPIDLCString fileName;
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = mDirectory->GetReplicationFileName(fileName);
if (NS_SUCCEEDED(rv) && !fileName.IsEmpty())
{
rv = mBackupReplicationFile->MoveToNative(nsnull, fileName);
@ -511,8 +511,8 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
return rv;
}
nsXPIDLCString fileName;
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = mDirectory->GetReplicationFileName(fileName);
if (NS_FAILED(rv) || fileName.IsEmpty())
{
Done(PR_FALSE);

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

@ -75,8 +75,8 @@ nsresult nsAbLDAPReplicationQuery::InitLDAPData()
mDirectory = do_QueryInterface(resource, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString fileName;
rv = mDirectory->GetReplicationFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = mDirectory->GetReplicationFileName(fileName);
NS_ENSURE_SUCCESS(rv, rv);
// this is done here to take care of the problem related to bug # 99124.

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

@ -319,20 +319,16 @@ NS_IMETHODIMP nsAbMDBDirectory::GetDirUri(char **uri)
NS_IMETHODIMP nsAbMDBDirectory::GetURI(nsACString &aURI)
{
// XXX to do, convert GetStringValue & users to use nsACString for result
nsXPIDLCString result;
nsresult rv = GetStringValue("uri", "", getter_Copies(result));
nsresult rv = GetStringValue("uri", EmptyCString(), aURI);
if (result.IsEmpty())
if (aURI.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
rv = GetFileName(aURI);
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kMDBDirectoryRoot, 0);
aURI.Insert(kMDBDirectoryRoot, 0);
}
aURI = result;
return NS_OK;
}

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

@ -152,20 +152,16 @@ NS_IMETHODIMP nsAbOutlookDirectory::Init(const char *aUri)
NS_IMETHODIMP nsAbOutlookDirectory::GetURI(nsACString &aURI)
{
// XXX to do, convert GetStringValue & users to use nsACString for result
nsXPIDLCString result;
nsresult rv = GetStringValue("uri", "", getter_Copies(result));
nsresult rv = GetStringValue("uri", EmptyCString(), aURI);
if (result.IsEmpty())
if (aURI.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
rv = GetFileName(aURI);
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kMDBDirectoryRoot, 0);
aURI.Insert(kMDBDirectoryRoot, 0);
}
aURI = result;
return NS_OK;
}

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

@ -157,8 +157,8 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
nsCOMPtr <nsIAbDirectory> subDirectory = do_QueryInterface(item, &rv);
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString fileName;
rv = subDirectory->GetFileName(getter_Copies(fileName));
nsCAutoString fileName;
rv = subDirectory->GetFileName(fileName);
if(NS_FAILED(rv))
continue;
PRInt32 dirType;
@ -204,7 +204,7 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
if (NS_SUCCEEDED(rv))
{
// We don't have to skip mailing list since there's no mailing lists at the top level.
nsXPIDLCString fileName;
nsCAutoString fileName;
nsCAutoString uri;
nsXPIDLString description;
PRUint32 palmSyncTimeStamp;
@ -212,7 +212,7 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
rv = directory->GetDescription(getter_Copies(description));
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetFileName(getter_Copies(fileName));
rv = directory->GetFileName(fileName);
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetURI(uri);
if(NS_FAILED(rv)) return E_FAIL;