Bug 377622 Remove palm sync time stamp and category id from ab code. r=bienvenu,sr=mscott

git-svn-id: svn://10.0.0.236/trunk@224793 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugzilla%standard8.demon.co.uk
2007-04-20 14:33:17 +00:00
parent fabcaef6ac
commit f2fa71ac0d
12 changed files with 38 additions and 139 deletions

View File

@@ -421,15 +421,13 @@ function AbOnRenameAddressBook(aName)
// the RDF resource URI for LDAPDirectory will be like: "moz-abmdbdirectory://abook-3.mab"
var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);
// Copy existing dir type category id and mod time so they won't get reset.
// Copy existing property items so they won't get reset.
var oldProperties = selectedABDirectory.directoryProperties;
// Create and fill in properties info
var properties = Components.classes["@mozilla.org/addressbook/properties;1"].createInstance(Components.interfaces.nsIAbDirectoryProperties);
properties.URI = selectedABURI;
properties.dirType = oldProperties.dirType;
properties.categoryId = oldProperties.categoryId;
properties.syncTimeStamp = oldProperties.syncTimeStamp;
properties.description = aName;
// Now do the modification.

View File

@@ -374,11 +374,6 @@ function onAccept()
var selectedABURI = "moz-abldapdirectory://" + gCurrentDirectoryString;
var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);
// Carry over existing palm category id and mod time if it was synced before.
var oldProperties = selectedABDirectory.directoryProperties;
properties.categoryId = oldProperties.categoryId;
properties.syncTimeStamp = oldProperties.syncTimeStamp;
// Now do the modification.
addressbook.modifyAddressBook(addressbookDS, parentDir, selectedABDirectory, properties);
window.opener.gNewServerString = gCurrentDirectoryString;

View File

@@ -58,7 +58,8 @@
// used for when creating new directories
// either from user input, or during bootstrapping
[scriptable, uuid(1c10fa4e-a7f2-4731-a3ec-a78be1086e29)]
// Note this interface is expected to go away soon, see bug 331557
[scriptable, uuid(c69e64ca-0fe7-477b-a0cf-711537b33af9)]
interface nsIAbDirectoryProperties : nsISupports {
attribute AString description;
attribute string URI;
@@ -67,12 +68,10 @@ interface nsIAbDirectoryProperties : nsISupports {
attribute unsigned long dirType;
attribute unsigned long maxHits;
attribute string authDn;
attribute unsigned long syncTimeStamp;
attribute long categoryId;
attribute long position;
};
[scriptable, uuid(831251b9-3d8d-462a-9460-71674e505f6c)]
[scriptable, uuid(2f8feba2-23fd-49cf-b154-41432506af8d)]
interface nsIAbDirectory : nsISupports {
// Types of operation
@@ -108,12 +107,6 @@ interface nsIAbDirectory : nsISupports {
// 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

View File

@@ -407,15 +407,13 @@ function AbOnRenameAddressBook(aName)
// the RDF resource URI for LDAPDirectory will be like: "moz-abmdbdirectory://abook-3.mab"
var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);
// Copy existing dir type category id and mod time so they won't get reset.
// Copy existing property items so they won't get reset.
var oldProperties = selectedABDirectory.directoryProperties;
// Create and fill in properties info
var properties = Components.classes["@mozilla.org/addressbook/properties;1"].createInstance(Components.interfaces.nsIAbDirectoryProperties);
properties.URI = selectedABURI;
properties.dirType = oldProperties.dirType;
properties.categoryId = oldProperties.categoryId;
properties.syncTimeStamp = oldProperties.syncTimeStamp;
properties.description = aName;
// Now do the modification.

View File

@@ -433,8 +433,7 @@ NS_IMETHODIMP nsAbBSDirectory::ModifyDirectory(nsIAbDirectory *directory, nsIAbD
nsAutoString description;
nsXPIDLCString uri;
nsXPIDLCString authDn;
PRUint32 maxHits, palmSyncTimeStamp;
PRInt32 palmCategoryId;
PRUint32 maxHits;
rv = aProperties->GetDescription(description);
NS_ENSURE_SUCCESS(rv, rv);
@@ -458,14 +457,6 @@ NS_IMETHODIMP nsAbBSDirectory::ModifyDirectory(nsIAbDirectory *directory, nsIAbD
nsCRT::free(server->authDn);
server->authDn = ToNewCString(authDn);
rv = aProperties->GetSyncTimeStamp(&palmSyncTimeStamp);
NS_ENSURE_SUCCESS(rv, rv);
server->PalmSyncTimeStamp = palmSyncTimeStamp;
rv = aProperties->GetCategoryId(&palmCategoryId);
NS_ENSURE_SUCCESS(rv, rv);
server->PalmCategoryId = palmCategoryId;
DIR_SavePrefsForOneServer(server);
if (!oldValue.Equals(description)) {

View File

@@ -132,18 +132,6 @@ 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)
{
if (aLastModifiedDate)
@@ -405,19 +393,6 @@ NS_IMETHODIMP nsAbDirProperty::GetDirectoryProperties(nsIAbDirectoryProperties *
rv = properties->SetAuthDn(prefStringValue.get());
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);
@@ -559,8 +534,6 @@ nsAbDirectoryProperties::nsAbDirectoryProperties(void)
{
mDirType = LDAPDirectory;
mMaxHits = 0;
mSyncTimeStamp = 0;
mCategoryId = -1;
mPosition = 0;
}
@@ -666,19 +639,6 @@ NS_IMETHODIMP nsAbDirectoryProperties::GetAuthDn(char **aAuthDn)
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryProperties::SetCategoryId(PRInt32 aCategoryId)
{
mCategoryId = aCategoryId;
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryProperties::GetCategoryId(PRInt32 *aCategoryId)
{
NS_ENSURE_ARG_POINTER(aCategoryId);
*aCategoryId = mCategoryId;
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryProperties::SetPosition(PRInt32 aPosition)
{
mPosition = aPosition;
@@ -691,17 +651,3 @@ NS_IMETHODIMP nsAbDirectoryProperties::GetPosition(PRInt32 *aPosition)
*aPosition = mPosition;
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryProperties::SetSyncTimeStamp(PRUint32 aSyncTimeStamp)
{
mSyncTimeStamp = aSyncTimeStamp;
return NS_OK;
}
NS_IMETHODIMP nsAbDirectoryProperties::GetSyncTimeStamp(PRUint32 *aSyncTimeStamp)
{
NS_ENSURE_ARG_POINTER(aSyncTimeStamp);
*aSyncTimeStamp = mSyncTimeStamp;
return NS_OK;
}

View File

@@ -112,8 +112,6 @@ private:
PRUint32 mDirType;
PRUint32 mMaxHits;
nsCString mAuthDn;
PRUint32 mSyncTimeStamp;
PRInt32 mCategoryId;
PRInt32 mPosition;
};
#endif

View File

@@ -502,8 +502,6 @@ static nsresult DIR_InitServer(DIR_Server *server)
server->csid = CS_UTF8;
server->locale = nsnull;
server->uri = nsnull;
// initialize the palm category
server->PalmCategoryId = -1;
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
@@ -1033,16 +1031,6 @@ static DIR_PrefId DIR_AtomizePrefName(const char *prefname)
case 'v': /* vlvDisabled */
rc = idVLVDisabled;
break;
case 'P':
switch (prefname[4]) {
case 'C': /* PalmCategoryId */
rc = idPalmCategory;
break;
case 'S': /* PalmSyncTimeStamp */
rc = idPalmSyncTimeStamp;
break;
}
break;
}
PR_ASSERT(rc != idNone);
@@ -1748,9 +1736,6 @@ static void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, P
dir_GetReplicationInfo (prefstring, server);
server->PalmCategoryId = DIR_GetIntPref (prefstring, "PalmCategoryId", -1);
server->PalmSyncTimeStamp = DIR_GetIntPref (prefstring, "PalmSyncTimeStamp", 0);
/* Get authentication prefs */
server->enableAuth = DIR_GetBoolPref (prefstring, "auth.enabled", kDefaultEnableAuth);
server->authDn = DIR_GetStringPref (prefstring, "auth.dn", nsnull);
@@ -2374,9 +2359,6 @@ void DIR_SavePrefsForOneServer(DIR_Server *server)
dir_SaveReplicationInfo (prefstring, server);
DIR_SetIntPref (prefstring, "PalmCategoryId", server->PalmCategoryId, -1);
DIR_SetIntPref (prefstring, "PalmSyncTimeStamp", server->PalmSyncTimeStamp, 0);
DIR_ClearFlag(server, DIR_SAVING_SERVER);
}

View File

@@ -96,8 +96,6 @@ typedef enum
idReplLastChangeNumber,
idReplDataVersion,
idReplSyncURL,
idPalmCategory,
idPalmSyncTimeStamp,
idProtocolVersion,
idAttributeMap
} DIR_PrefId;
@@ -147,10 +145,6 @@ typedef struct DIR_Server
/* Replication fields */
DIR_ReplicationInfo *replInfo;
/* fields for palm Sync */
PRInt32 PalmCategoryId;
PRUint32 PalmSyncTimeStamp;
} DIR_Server;
/* We are developing a new model for managing DIR_Servers. In the 4.0x world, the FEs managed each list.

View File

@@ -218,10 +218,11 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetDirType(&dirType);
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetPalmSyncTimeStamp(&palmSyncTimeStamp);
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetPalmSyncCategoryId(&palmCategoryIndex);
if(NS_FAILED(rv)) return E_FAIL;
rv = directory->GetIntValue("PalmCategoryId", -1, &palmCategoryIndex);
if (NS_FAILED(rv)) return E_FAIL;
rv = directory->GetIntValue("PalmSyncTimeStamp", 0,
(PRInt32*)&palmSyncTimeStamp);
if (NS_FAILED(rv)) return E_FAIL;
PRBool disableThisAB;
rv = directory->GetBoolValue("disablePalmSync", PR_FALSE, &disableThisAB);

View File

@@ -200,23 +200,22 @@ nsresult nsAbPalmHotSync::GetABInterface()
if (NS_SUCCEEDED(rv))
{
// TODO: may need to skip mailing list?? but maybe not since there's no mailing list on the top level.
nsCOMPtr <nsIAbDirectoryProperties> properties;
rv = directory->GetDirectoryProperties(getter_AddRefs(properties));
if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetDescription(description);
rv = directory->GetDescription(description);
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;
rv = properties->GetURI(getter_Copies(uri));
rv = directory->GetURI(getter_Copies(uri));
if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetDirType(&dirType);
rv = directory->GetDirType(&dirType);
if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetSyncTimeStamp(&palmSyncTimeStamp);
if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetCategoryId(&palmCategoryIndex);
if(NS_FAILED(rv)) return E_FAIL;
rv = properties->GetPrefName(getter_Copies(prefName));
rv = directory->GetDirPrefId(getter_Copies(prefName));
if (NS_FAILED(rv)) return E_FAIL;
rv = directory->GetIntValue("PalmCategoryId", -1, &palmCategoryIndex);
if (NS_FAILED(rv)) return E_FAIL;
rv = directory->GetIntValue("PalmSyncTimeStamp", 0,
(PRInt32*)&palmSyncTimeStamp);
if (NS_FAILED(rv)) return E_FAIL;
// Skip/Ignore 4.X addrbooks (ie, with ".na2" extension).
if (((fileName.Length() > kABFileName_PreviousSuffixLen) &&
@@ -1027,14 +1026,11 @@ nsresult nsAbPalmHotSync::RenameAB(long aCategoryIndex, const char * aABUrl)
NS_ENSURE_SUCCESS(rv,rv);
rv = properties->SetDirType(kPABDirectory); // pab dir type for PalmSync
NS_ENSURE_SUCCESS(rv,rv);
rv = properties->SetCategoryId(aCategoryIndex);
NS_ENSURE_SUCCESS(rv,rv);
PRUint32 modTimeInSec;
PRTime2Seconds(PR_Now(), &modTimeInSec);
rv = properties->SetSyncTimeStamp(modTimeInSec);
NS_ENSURE_SUCCESS(rv,rv);
return(ModifyAB(aABUrl, properties));
return ModifyAB(aABUrl, properties, modTimeInSec, aCategoryIndex);
}
nsresult nsAbPalmHotSync::NewAB(const nsString& aAbName)
@@ -1066,15 +1062,14 @@ nsresult nsAbPalmHotSync::UpdateABInfo(PRUint32 aModTime, PRInt32 aCategoryIndex
NS_ENSURE_SUCCESS(rv,rv);
rv = properties->SetDirType(mDirType);
NS_ENSURE_SUCCESS(rv,rv);
rv = properties->SetCategoryId(aCategoryIndex);
NS_ENSURE_SUCCESS(rv,rv);
rv = properties->SetSyncTimeStamp(aModTime);
NS_ENSURE_SUCCESS(rv,rv);
return(ModifyAB(mUri.get(), properties));
return(ModifyAB(mUri.get(), properties, aModTime, aCategoryIndex));
}
nsresult nsAbPalmHotSync::ModifyAB(const char * aABUrl, nsIAbDirectoryProperties *aProperties)
nsresult nsAbPalmHotSync::ModifyAB(const char * aABUrl,
nsIAbDirectoryProperties *aProperties,
const PRUint32 aModTime,
const PRInt32 aCategoryId)
{
nsresult rv;
@@ -1096,6 +1091,13 @@ nsresult nsAbPalmHotSync::ModifyAB(const char * aABUrl, nsIAbDirectoryProperties
nsCOMPtr <nsIAbDirectory> selectedDirectory = do_QueryInterface(childResource, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Now set the mod time and category id directly via the selected directory.
rv = selectedDirectory->SetIntValue("PalmSyncTimeStamp", aModTime);
NS_ENSURE_SUCCESS(rv, rv);
rv = selectedDirectory->SetIntValue("PalmSyncCategoryId", aCategoryId);
NS_ENSURE_SUCCESS(rv, rV);
// RDF data source for addrbook
nsCOMPtr<nsIRDFDataSource> ds;
rv = rdfService->GetDataSource("rdf:addressdirectory", getter_AddRefs(ds));

View File

@@ -143,7 +143,8 @@ protected:
void ConvertAssignPalmIDAttrib(PRUint32 id, nsIAbMDBCard * card);
nsresult GetABInterface();
nsresult UpdateABInfo(PRUint32 modTime, PRInt32 categoryId);
nsresult ModifyAB(const char * ABUrl, nsIAbDirectoryProperties *properties);
nsresult ModifyAB(const char * ABUrl, nsIAbDirectoryProperties *properties,
const PRUint32 aModTime, const PRInt32 aCategoryId);
nsresult NewAB(const nsString& aAbName);
};