Bug 331557 Remove nsIAbDirectoryProperties (Remove c++ uses of GetDirectoryProperties). r=Neil,sr=bienvenu

This commit is contained in:
bugzilla%standard8.demon.co.uk 2006-05-01 15:24:29 +00:00
parent baadb38d0a
commit 1c4d5b51ed
12 changed files with 367 additions and 190 deletions

View File

@ -72,147 +72,171 @@ interface nsIAbDirectoryProperties : nsISupports {
attribute long position; attribute long position;
}; };
[scriptable, uuid(d6d55de3-261d-4149-987d-3a88ceb5f2a9)] [scriptable, uuid(93d8e498-7c03-4ad0-9cd4-933d43e3724a)]
interface nsIAbDirectory : nsISupports { interface nsIAbDirectory : nsISupports {
// Types of operation // Types of operation
// Perform linear reading of directory card // Perform linear reading of directory card
// content // content
const long opRead = 0x1; const long opRead = 0x1;
// Perform modification and deletion on a // Perform modification and deletion on a
// directories content // directories content
const long opWrite = 0x2; const long opWrite = 0x2;
// Perform searching on a directory card // Perform searching on a directory card
// content via the uri format: // content via the uri format:
// scheme://path?query // scheme://path?query
const long opSearch = 0x4; const long opSearch = 0x4;
// The supported operations // The supported operations
readonly attribute long operations; readonly attribute long operations;
// The description of the directory // The description of the directory
attribute wstring dirName; attribute wstring dirName;
// will be used for LDAP replication
attribute unsigned long lastModifiedDate;
// Defines whether this directory is a mail // XXX This should really be replaced by a QI or something better
// list or not readonly attribute long dirType;
attribute PRBool isMailList;
// XXX These are readonly for now, until we get nsIAbDirectoryProperties
// 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;
// The URI of the address book
readonly attribute ACString URI;
// The position of the directory on the display.
readonly attribute long position;
// The palm sync category id.
readonly attribute long palmSyncCategoryId;
// The palm sync time stamp
readonly attribute unsigned long palmSyncTimeStamp;
// XXX End "readonly XXX"
// will be used for LDAP replication
attribute unsigned long lastModifiedDate;
// Defines whether this directory is a mail
// list or not
attribute PRBool isMailList;
// Get the directory properties // Get the directory properties
readonly attribute nsIAbDirectoryProperties directoryProperties; readonly attribute nsIAbDirectoryProperties directoryProperties;
// Get the children directories // Get the children directories
readonly attribute nsISimpleEnumerator childNodes; readonly attribute nsISimpleEnumerator childNodes;
/** /**
* Get the cards associated with the directory. This will return the cards * Get the cards associated with the directory. This will return the cards
* associated with the mailing lists too. * associated with the mailing lists too.
*/ */
readonly attribute nsISimpleEnumerator childCards; readonly attribute nsISimpleEnumerator childCards;
// Modifies a top level directory, // Modifies a top level directory,
// which also updates the preferences // which also updates the preferences
void modifyDirectory(in nsIAbDirectory directory, in nsIAbDirectoryProperties aProperties); void modifyDirectory(in nsIAbDirectory directory, in nsIAbDirectoryProperties aProperties);
// Deletes either a mailing list or a top // Deletes either a mailing list or a top
// level directory, which also updates the // level directory, which also updates the
// preferences // preferences
void deleteDirectory(in nsIAbDirectory dierctory); void deleteDirectory(in nsIAbDirectory dierctory);
// Delete the array of cards // Delete the array of cards
void deleteCards(in nsISupportsArray cards); void deleteCards(in nsISupportsArray cards);
// Check if directory contains card // Check if directory contains card
// If the implementation is asynchronous the card // If the implementation is asynchronous the card
// may not yet have arrived. If it is in the process // may not yet have arrived. If it is in the process
// of obtaining cards the method will throw an // of obtaining cards the method will throw an
// NS_ERROR_NOT_AVAILABLE exception if the card // NS_ERROR_NOT_AVAILABLE exception if the card
// cannot be found. // cannot be found.
boolean hasCard(in nsIAbCard cards); boolean hasCard(in nsIAbCard cards);
// Check if directory contains directory // Check if directory contains directory
boolean hasDirectory(in nsIAbDirectory dir); boolean hasDirectory(in nsIAbDirectory dir);
/** /**
* return value is the card that got added * return value is the card that got added
* we need to do this, as the card we pass in might * we need to do this, as the card we pass in might
* be an abstract nsIAbCard, and the caller might need * be an abstract nsIAbCard, and the caller might need
* the "real" card (the mdbcard) to get / set * the "real" card (the mdbcard or similar) to get / set
* non-standard card values * non-standard card values
*/ */
nsIAbCard addCard(in nsIAbCard card); nsIAbCard addCard(in nsIAbCard card);
void dropCard(in nsIAbCard card, in boolean needToCopyCard); void dropCard(in nsIAbCard card, in boolean needToCopyCard);
/** /**
* directory is local (example, mork based) or remote (example, LDAP) * directory is local (example, mork based) or remote (example, LDAP)
*/ */
readonly attribute boolean isRemote; readonly attribute boolean isRemote;
/** /**
* directory is secure (as in LDAP over SSL) * directory is secure (as in LDAP over SSL)
*/ */
readonly attribute boolean isSecure; readonly attribute boolean isSecure;
/** /**
* directory should be searched when doing local autocomplete * directory should be searched when doing local autocomplete
*/ */
readonly attribute boolean searchDuringLocalAutocomplete; readonly attribute boolean searchDuringLocalAutocomplete;
// Mail list specific // Mail list specific
readonly attribute boolean supportsMailingLists; readonly attribute boolean supportsMailingLists;
// XXX todo // XXX todo
// fix this, ugh // fix this, ugh
// This attribute servers two purposes // This attribute servers two purposes
// depending if the directory is a mail list. // depending if the directory is a mail list.
// If not mail list directories are stored here // If not mail list directories are stored here
// If so mail list card entries are stored here // If so mail list card entries are stored here
attribute nsISupportsArray addressLists; attribute nsISupportsArray addressLists;
// Specific to a directory which stores mail lists // Specific to a directory which stores mail lists
// Creates a new mailing list in the directory // Creates a new mailing list in the directory
// with the properties defined by list // with the properties defined by list
void addMailList (in nsIAbDirectory list); void addMailList (in nsIAbDirectory list);
// Creates a new mailing list in the directory with // Creates a new mailing list in the directory with
// the properties defined by list and return a db key // the properties defined by list and return a db key
void addMailListWithKey (in nsIAbDirectory list, out PRUint32 key); void addMailListWithKey (in nsIAbDirectory list, out PRUint32 key);
// Specific to a directory which is a mail list // Specific to a directory which is a mail list
attribute wstring listNickName; attribute wstring listNickName;
attribute wstring description; attribute wstring description;
/** /**
* Edits an existing mailing list (specified as listCard) * Edits an existing mailing list (specified as listCard)
* into the directory specified by the uri * into the directory specified by the uri
* XXX javadoc me * XXX javadoc me
*/ */
void editMailListToDatabase(in string uri, in nsIAbCard listCard); void editMailListToDatabase(in string uri, in nsIAbCard listCard);
// Copies mail list properties from the srcList // Copies mail list properties from the srcList
void copyMailList(in nsIAbDirectory srcList); void copyMailList(in nsIAbDirectory srcList);
/* /*
Only creates a top level address book Only creates a top level address book
which is stored in the preferences which is stored in the preferences
Need to change to factory based approach Need to change to factory based approach
to create new address books to create new address books
This method should become redundant or This method should become redundant or
be only associated with card folders be only associated with card folders
*/ */
void createNewDirectory(in nsIAbDirectoryProperties aProperties); void createNewDirectory(in nsIAbDirectoryProperties aProperties);
/* create a directory by passing the display name and address book uri */ /* create a directory by passing the display name and address book uri */
void createDirectoryByURI(in wstring displayName, in string uri, in boolean migrating); void createDirectoryByURI(in wstring displayName, in string uri, in boolean migrating);
wstring getValueForCard(in nsIAbCard card, in string name); wstring getValueForCard(in nsIAbCard card, in string name);
void setValueForCard(in nsIAbCard card, in string name, in wstring value); void setValueForCard(in nsIAbCard card, in string name, in wstring value);
/** /**
* The id of the directory used in prefs e.g. "ldap_2.servers.pab" * The id of the directory used in prefs e.g. "ldap_2.servers.pab"
@ -240,7 +264,9 @@ interface nsIAbDirectory : nsISupports {
//@{ //@{
long getIntValue(in string aName, in long aDefaultValue); long getIntValue(in string aName, in long aDefaultValue);
boolean getBoolValue(in string aName, in boolean 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 getStringValue(in string aName, in string aDefaultValue);
string getLocalizedStringValue(in string aName, in string aDefaultValue);
//@} //@}
/** /**

View File

@ -42,11 +42,16 @@
#include "nsIAbCard.h" #include "nsIAbCard.h"
#include "nsDirPrefs.h" #include "nsDirPrefs.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "prmem.h" #include "prmem.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "rdf.h" #include "rdf.h"
// From nsDirPrefs
#define kDefaultMaxHits 100
#define kDefaultPosition 1
nsAbDirProperty::nsAbDirProperty(void) nsAbDirProperty::nsAbDirProperty(void)
: m_LastModifiedDate(0) : m_LastModifiedDate(0)
{ {
@ -106,6 +111,39 @@ NS_IMETHODIMP nsAbDirProperty::SetDirName(const PRUnichar * aDirName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsAbDirProperty::GetDirType(PRInt32 *aDirType)
{
return GetIntValue("dirType", LDAPDirectory, aDirType);
}
NS_IMETHODIMP nsAbDirProperty::GetFileName(char* *aFileName)
{
return GetStringValue("filename", "", aFileName);
}
NS_IMETHODIMP nsAbDirProperty::GetURI(nsACString &aURI)
{
// XXX Should we complete this for Mailing Lists?
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsAbDirProperty::GetPosition(PRInt32 *aPosition)
{
return GetIntValue("position", kDefaultPosition, aPosition);
}
NS_IMETHODIMP nsAbDirProperty::GetPalmSyncCategoryId(PRInt32 *aPalmSyncCategoryId)
{
return GetIntValue("PalmCategoryId", -1, aPalmSyncCategoryId);
}
NS_IMETHODIMP nsAbDirProperty::GetPalmSyncTimeStamp(PRUint32 *aPalmSyncTimeStamp)
{
// Prefs only accept unsigned longs, but we need time stamp as a unsigned
// int, so unfortunately we have to do this conversion
return GetIntValue("PalmSyncTimeStamp", 0, (PRInt32*)aPalmSyncTimeStamp);
}
NS_IMETHODIMP nsAbDirProperty::GetLastModifiedDate(PRUint32 *aLastModifiedDate) NS_IMETHODIMP nsAbDirProperty::GetLastModifiedDate(PRUint32 *aLastModifiedDate)
{ {
if (aLastModifiedDate) if (aLastModifiedDate)
@ -318,60 +356,82 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
NS_ENSURE_ARG_POINTER(aDirectoryProperties); NS_ENSURE_ARG_POINTER(aDirectoryProperties);
nsresult rv; nsresult rv;
DIR_Server *server = (DIR_Server *)PR_Malloc(sizeof(DIR_Server));
if (!server)
return NS_ERROR_OUT_OF_MEMORY;
DIR_InitServer(server); nsCOMPtr<nsIAbDirectoryProperties> properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv);
nsCAutoString prefId; NS_ENSURE_SUCCESS(rv, rv);
rv = GetDirPrefId(prefId);
if (NS_SUCCEEDED(rv)) { rv = properties->SetPrefName(m_DirPrefId.get());
server->prefName = ToNewCString(prefId); NS_ENSURE_SUCCESS(rv, rv);
DIR_GetPrefsForOneServer(server, PR_FALSE, PR_FALSE);
// Now create the obj and move info in DIR_Server to it. nsXPIDLCString prefStringValue;
nsCOMPtr<nsIAbDirectoryProperties> properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv); PRInt32 prefIntValue;
if (m_DirPrefId.EqualsLiteral("ldap_2.servers.pab") ||
if (NS_SUCCEEDED(rv)) { m_DirPrefId.EqualsLiteral("ldap_2.servers.history"))
NS_ConvertUTF8toUTF16 description (server->description); {
// get default address book name from addressbook.properties
rv = properties->SetDescription(description); rv = GetLocalizedStringValue("description", "", getter_Copies(prefStringValue));
if (NS_SUCCEEDED(rv))
rv = properties->SetFileName(server->fileName);
if (NS_SUCCEEDED(rv))
rv = properties->SetPrefName(server->prefName);
if (NS_SUCCEEDED(rv))
rv = properties->SetURI(server->uri);
if (NS_SUCCEEDED(rv))
rv = properties->SetDirType(server->dirType);
if (NS_SUCCEEDED(rv))
rv = properties->SetMaxHits(server->maxHits);
if (NS_SUCCEEDED(rv))
rv = properties->SetAuthDn(server->authDn);
if (NS_SUCCEEDED(rv))
rv = properties->SetCategoryId(server->PalmCategoryId);
if (NS_SUCCEEDED(rv))
rv = properties->SetSyncTimeStamp(server->PalmSyncTimeStamp);
if (NS_SUCCEEDED(rv))
rv = properties->SetPosition(server->position);
if (NS_SUCCEEDED(rv))
NS_ADDREF(*aDirectoryProperties = properties);
}
} }
else
{
rv = GetStringValue("description", "", getter_Copies(prefStringValue));
}
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetDescription(NS_ConvertUTF8toUTF16(prefStringValue));
NS_ENSURE_SUCCESS(rv, rv);
rv = GetDirType(&prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetDirType(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetFileName(getter_Copies(prefStringValue));
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetFileName(prefStringValue);
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);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetIntValue("maxHits", kDefaultMaxHits, &prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetMaxHits(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetStringValue("auth.dn", nsnull, getter_Copies(prefStringValue));
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetAuthDn(prefStringValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetPalmSyncCategoryId(&prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetCategoryId(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 timeStamp;
rv = GetPalmSyncTimeStamp(&timeStamp);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetSyncTimeStamp(timeStamp);
NS_ENSURE_SUCCESS(rv, rv);
rv = GetPosition(&prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
rv = properties->SetPosition(prefIntValue);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aDirectoryProperties = properties);
DIR_DeleteServer(server);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsAbDirProperty::GetDirPrefId failed!");
return rv; return rv;
} }
@ -442,6 +502,41 @@ NS_IMETHODIMP nsAbDirProperty::GetStringValue(const char *aName,
return NS_OK; return NS_OK;
} }
/*
* Get localized unicode string pref from properties file, convert into an
* UTF8 string since address book prefs store as UTF8 strings. So far there
* are 2 default prefs stored in addressbook.properties.
* "ldap_2.servers.pab.description"
* "ldap_2.servers.history.description"
*/
NS_IMETHODIMP nsAbDirProperty::GetLocalizedStringValue(const char *aName,
const char *aDefaultValue,
char * *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
if (!m_DirectoryPrefs && NS_FAILED(InitDirectoryPrefs()))
return NS_ERROR_NOT_INITIALIZED;
nsXPIDLString wvalue;
nsCOMPtr<nsIPrefLocalizedString> locStr;
nsresult rv = m_DirectoryPrefs->GetComplexValue(aName,
NS_GET_IID(nsIPrefLocalizedString),
getter_AddRefs(locStr));
if (NS_SUCCEEDED(rv))
{
rv = locStr->ToString(getter_Copies(wvalue));
NS_ENSURE_SUCCESS(rv, rv);
}
if (wvalue.IsEmpty())
*aResult = aDefaultValue ? nsCRT::strdup(aDefaultValue) : nsnull;
else
*aResult = ToNewUTF8String(wvalue);
return NS_OK;
}
NS_IMETHODIMP nsAbDirProperty::SetIntValue(const char *aName, NS_IMETHODIMP nsAbDirProperty::SetIntValue(const char *aName,
PRInt32 aValue) PRInt32 aValue)

View File

@ -206,6 +206,25 @@ 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));
if (result.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kLDAPDirectoryRoot, 0);
}
aURI = result;
return NS_OK;
}
NS_IMETHODIMP nsAbLDAPDirectory::GetOperations(PRInt32 *aOperations) NS_IMETHODIMP nsAbLDAPDirectory::GetOperations(PRInt32 *aOperations)
{ {
*aOperations = nsIAbDirectory::opSearch; *aOperations = nsIAbDirectory::opSearch;

View File

@ -64,7 +64,8 @@ public:
NS_IMETHOD Init(const char *aUri); NS_IMETHOD Init(const char *aUri);
// nsIAbDirectory methods // nsIAbDirectory methods
NS_IMETHOD GetURI(nsACString &aURI);
NS_IMETHOD GetOperations(PRInt32 *aOperations); NS_IMETHOD GetOperations(PRInt32 *aOperations);
NS_IMETHOD GetChildNodes(nsISimpleEnumerator* *result); NS_IMETHOD GetChildNodes(nsISimpleEnumerator* *result);
NS_IMETHOD GetChildCards(nsISimpleEnumerator* *result); NS_IMETHOD GetChildCards(nsISimpleEnumerator* *result);

View File

@ -109,12 +109,8 @@ nsresult nsAbLDAPReplicationQuery::InitLDAPData()
nsCOMPtr<nsIAbDirectory> abDirectory(do_QueryInterface(mDirectory, &rv)); nsCOMPtr<nsIAbDirectory> abDirectory(do_QueryInterface(mDirectory, &rv));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAbDirectoryProperties> dirProperties; nsCAutoString uri;
rv = abDirectory->GetDirectoryProperties(getter_AddRefs(dirProperties)); rv = abDirectory->GetURI(uri);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString uri;
rv = dirProperties->GetURI(getter_Copies(uri));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = mURL->SetSpec(uri); rv = mURL->SetSpec(uri);

View File

@ -317,6 +317,25 @@ NS_IMETHODIMP nsAbMDBDirectory::GetDirUri(char **uri)
// nsIAbDirectory methods // nsIAbDirectory methods
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));
if (result.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kMDBDirectoryRoot, 0);
}
aURI = result;
return NS_OK;
}
NS_IMETHODIMP nsAbMDBDirectory::GetChildNodes(nsISimpleEnumerator* *aResult) NS_IMETHODIMP nsAbMDBDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
{ {
if (mIsQueryURI) if (mIsQueryURI)

View File

@ -75,6 +75,7 @@ public:
NS_DECL_NSIADDRDBLISTENER NS_DECL_NSIADDRDBLISTENER
// nsIAbMDBDirectory methods // nsIAbMDBDirectory methods
NS_IMETHOD GetURI(nsACString &aURI);
NS_IMETHOD ClearDatabase(); NS_IMETHOD ClearDatabase();
NS_IMETHOD NotifyDirItemAdded(nsISupports *item) { return NotifyItemAdded(item);} NS_IMETHOD NotifyDirItemAdded(nsISupports *item) { return NotifyItemAdded(item);}
NS_IMETHOD RemoveElementsFromAddressList(); NS_IMETHOD RemoveElementsFromAddressList();

View File

@ -148,6 +148,26 @@ NS_IMETHODIMP nsAbOutlookDirectory::Init(const char *aUri)
} }
// nsIAbDirectory methods // nsIAbDirectory methods
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));
if (result.IsEmpty())
{
rv = GetFileName(getter_Copies(result));
NS_ENSURE_SUCCESS(rv, rv);
result.Insert(kMDBDirectoryRoot);
}
aURI = result;
return NS_OK;
}
NS_IMETHODIMP nsAbOutlookDirectory::GetChildNodes(nsISimpleEnumerator **aNodes) NS_IMETHODIMP nsAbOutlookDirectory::GetChildNodes(nsISimpleEnumerator **aNodes)
{ {
if (!aNodes) { return NS_ERROR_NULL_POINTER ; } if (!aNodes) { return NS_ERROR_NULL_POINTER ; }

View File

@ -124,6 +124,7 @@ static DIR_Server *dir_MatchServerPrefToServer(nsVoidArray *wholeList, const cha
static PRBool dir_ValidateAndAddNewServer(nsVoidArray *wholeList, const char *fullprefname); static PRBool dir_ValidateAndAddNewServer(nsVoidArray *wholeList, const char *fullprefname);
static void DIR_DeleteServerList(nsVoidArray *wholeList); static void DIR_DeleteServerList(nsVoidArray *wholeList);
static char *dir_CreateServerPrefName(DIR_Server *server); static char *dir_CreateServerPrefName(DIR_Server *server);
static void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, PRBool oldstyle /* 4.0 Branch */);
static PRInt32 dir_UserId = 0; static PRInt32 dir_UserId = 0;
@ -1624,7 +1625,7 @@ static char *dir_CreateServerPrefName (DIR_Server *server)
return prefName; return prefName;
} }
void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, PRBool oldstyle /* 4.0 Branch */) static void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, PRBool oldstyle /* 4.0 Branch */)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIPrefBranch> pPref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); nsCOMPtr<nsIPrefBranch> pPref(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));

View File

@ -181,7 +181,6 @@ PRBool DIR_SetServerPosition(nsVoidArray *wholeList, DIR_Server *server, PRInt32
*/ */
nsresult DIR_GetServerPreferences(nsVoidArray** list); nsresult DIR_GetServerPreferences(nsVoidArray** list);
nsresult DIR_SaveServerPreferences(nsVoidArray *wholeList); nsresult DIR_SaveServerPreferences(nsVoidArray *wholeList);
void DIR_GetPrefsForOneServer(DIR_Server *server, PRBool reinitialize, PRBool oldstyle);
void DIR_SavePrefsForOneServer(DIR_Server *server); void DIR_SavePrefsForOneServer(DIR_Server *server);
void DIR_SetServerFileName(DIR_Server* pServer); void DIR_SetServerFileName(DIR_Server* pServer);

View File

@ -706,16 +706,12 @@ nsAbDirectoryDataSource::createDirectoryTreeNameSortNode(nsIAbDirectory* directo
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
// Get directory type. // Get directory type.
nsCOMPtr <nsIAbDirectoryProperties> properties; PRInt32 dirType;
rv = directory->GetDirectoryProperties(getter_AddRefs(properties)); rv = directory->GetDirType(&dirType);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 dirType;
rv = properties->GetDirType(&dirType);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PRInt32 position; PRInt32 position;
rv = properties->GetPosition(&position); rv = directory->GetPosition(&position);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
// top level sort will be by position. Sort by type under that... // top level sort will be by position. Sort by type under that...

View File

@ -157,20 +157,21 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
nsCOMPtr <nsIAbDirectory> subDirectory = do_QueryInterface(item, &rv); nsCOMPtr <nsIAbDirectory> subDirectory = do_QueryInterface(item, &rv);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
nsCOMPtr <nsIAbDirectoryProperties> properties;
nsXPIDLCString fileName; nsXPIDLCString fileName;
rv = subDirectory->GetDirectoryProperties(getter_AddRefs(properties)); rv = subDirectory->GetFileName(getter_Copies(fileName));
if(NS_FAILED(rv)) if(NS_FAILED(rv))
continue; continue;
rv = properties->GetFileName(getter_Copies(fileName)); PRInt32 dirType;
rv = subDirectory->GetDirType(&dirType);
if(NS_FAILED(rv)) if(NS_FAILED(rv))
continue; continue;
PRUint32 dirType;
rv = properties->GetDirType(&dirType); PRBool disableThisAB;
nsCAutoString prefName; rv = subDirectory->GetBoolValue("disablePalmSync",
subDirectory->GetDirPrefId(prefName); PR_FALSE, &disableThisAB);
prefName.Append(".disablePalmSync"); if (NS_FAILED(rv))
PRBool disableThisAB = GetBoolPref(prefName.get(), PR_FALSE); continue;
// Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's // Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's
if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) && if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) &&
strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) || strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) ||
@ -203,31 +204,29 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
// We don't have to skip mailing list since there's no mailing lists at the top level. // We don't have to skip mailing list since there's no mailing lists at the top level.
nsCOMPtr <nsIAbDirectoryProperties> properties; nsXPIDLCString fileName;
rv = directory->GetDirectoryProperties(getter_AddRefs(properties)); nsAutoCString uri;
if(NS_FAILED(rv)) return E_FAIL;
nsXPIDLCString fileName, uri;
nsAutoString description; nsAutoString description;
PRUint32 dirType, palmSyncTimeStamp; PRUint32 palmSyncTimeStamp;
PRInt32 palmCategoryIndex; PRInt32 dirType, palmCategoryIndex;
rv = properties->GetDescription(description); rv = directory->GetDescription(description);
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetFileName(getter_Copies(fileName)); rv = directory->GetFileName(getter_Copies(fileName));
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetURI(getter_Copies(uri)); rv = directory->GetURI(uri);
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetDirType(&dirType); rv = directory->GetDirType(&dirType);
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetSyncTimeStamp(&palmSyncTimeStamp); rv = directory->GetSyncTimeStamp(&palmSyncTimeStamp);
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetCategoryId(&palmCategoryIndex); rv = directory->GetCategoryId(&palmCategoryIndex);
if(NS_FAILED(rv)) return E_FAIL; if(NS_FAILED(rv)) return E_FAIL;
nsCAutoString prefName;
directory->GetDirPrefId(prefName); PRBool disableThisAB;
prefName.Append(".disablePalmSync"); rv = directory->GetBoolValue("disablePalmSync", PR_FALSE, &disableThisAB);
PRBool disableThisAB = GetBoolPref(prefName.get(), PR_FALSE); if (NS_FAILED(rv)) return E_FAIL;
// Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's // Skip/Ignore 4.X addrbooks (ie, with ".na2" extension), and non personal AB's
if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) && if (disableThisAB || ((fileName.Length() > kABFileName_PreviousSuffixLen) &&
strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) || strcmp(fileName.get() + fileName.Length() - kABFileName_PreviousSuffixLen, kABFileName_PreviousSuffix) == 0) ||
@ -266,7 +265,12 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
if (palmSyncTimeStamp <= 0) if (palmSyncTimeStamp <= 0)
dirFlag |= kFirstTimeSyncDirFlag; dirFlag |= kFirstTimeSyncDirFlag;
// was this the pab? // was this the pab?
if (prefName.Equals("ldap_2.servers.pab.disablePalmSync")) nsCAutoString prefName;
rv = directory->GetDirPrefId(prefName);
if (NS_FAILED(rv))
break;
if (prefName.Equals("ldap_2.servers.pab"))
dirFlag |= kIsPabDirFlag; dirFlag |= kIsPabDirFlag;
*dirFlagsList = (BOOL) dirFlag; *dirFlagsList = (BOOL) dirFlag;
dirFlagsList++; dirFlagsList++;