зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bugs 183574, 188444, 189123, 189140 and 189995. Deleting addrbooks on either or both sides of palm and mozilla now works. Empty addrbooks are now synced. Added logging facility to mozilla conduit dll. r/sr=sspitzer.
This commit is contained in:
Родитель
3b838a1833
Коммит
296325ba34
|
@ -42,7 +42,8 @@ import "unknwn.idl";
|
|||
// this is defined so that we can return an array of strings(i.e array of AB Description strings)
|
||||
typedef struct
|
||||
{
|
||||
LPTSTR lpszABDesc;
|
||||
LPTSTR lpszABName;
|
||||
LPTSTR lpszABUrl;
|
||||
}nsMozABDesc, *lpnsMozABDesc;
|
||||
|
||||
// This structure defines the data fields for MozAB based on "nsIAbCard.idl"
|
||||
|
@ -144,5 +145,10 @@ interface IPalmSync : IUnknown
|
|||
// Send an ack for done and update the palm rec id for new records added
|
||||
HRESULT nsAckSyncDone([in] BOOL aIsSuccess, [in] int aCatID, [in] int aNewRecCount, [in, size_is(aNewRecCount)] unsigned long * aNewPalmRecIDList);
|
||||
|
||||
// Update the Address Book's category id and mod time.
|
||||
HRESULT nsUpdateABSyncInfo([in] BOOL aIsUnicode, [in] unsigned long aCategoryId, [in] LPTSTR aABName);
|
||||
|
||||
// Delete an addressbook
|
||||
HRESULT nsDeleteAB([in] BOOL aIsUnicode, [in] unsigned long aCategoryId, [in] LPTSTR aABName, [in] LPTSTR aABUrl);
|
||||
};
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#include <windows.h>
|
||||
#include "syncmgr.h"
|
||||
#include <tchar.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MozABConduitSync.h"
|
||||
#include "MozABConduitRecord.h"
|
||||
|
@ -47,6 +50,9 @@
|
|||
#define MAX_PROD_ID_TEXT 255
|
||||
#define PERSONAL "Personal"
|
||||
|
||||
// Global var
|
||||
FILE *gFD = NULL; // logging.
|
||||
|
||||
CMozABConduitSync::CMozABConduitSync(CSyncProperties& rProps)
|
||||
{
|
||||
m_dbHH = NULL;
|
||||
|
@ -56,6 +62,12 @@ CMozABConduitSync::CMozABConduitSync(CSyncProperties& rProps)
|
|||
m_ConduitHandle = (CONDHANDLE)0;
|
||||
memcpy(&m_rSyncProperties, &rProps, sizeof(m_rSyncProperties));
|
||||
memset(&m_SystemInfo, 0, sizeof(m_SystemInfo));
|
||||
|
||||
// See if logging is turned on (ie, check env variable "MOZ_CONDUIT_LOG"
|
||||
// for a logfile like "c:\\temp\\conduitlog.txt").
|
||||
char *envVar = getenv(ENV_VAR_CONDUTI_LOG);
|
||||
if(envVar != NULL )
|
||||
gFD = fopen(envVar, "a+");
|
||||
}
|
||||
|
||||
CMozABConduitSync::~CMozABConduitSync()
|
||||
|
@ -75,6 +87,9 @@ CMozABConduitSync::~CMozABConduitSync()
|
|||
retval = SyncUnRegisterConduit(m_ConduitHandle);
|
||||
m_ConduitHandle = 0;
|
||||
}
|
||||
|
||||
if (gFD)
|
||||
fclose(gFD);
|
||||
}
|
||||
|
||||
long CMozABConduitSync::Perform(void)
|
||||
|
@ -221,180 +236,294 @@ DWORD WINAPI DoFastSync(LPVOID lpParameter)
|
|||
long retval=0;
|
||||
BOOL success = FALSE;
|
||||
|
||||
// Log the start time.
|
||||
time_t ltime;
|
||||
time( <ime );
|
||||
CONDUIT_LOG1(gFD, "------------ START OF PALM SYNC ------------ at %s", ctime(<ime));
|
||||
|
||||
CMozABConduitSync * sync = (CMozABConduitSync * ) lpParameter;
|
||||
if(!sync)
|
||||
if(!sync || !sync->m_dbHH)
|
||||
return retval;
|
||||
|
||||
DWORD mozABCount=0;
|
||||
DWORD * mozCatIDList = NULL; // freed by MSCOM/Mozilla
|
||||
CPString ** mozABNameList = NULL; // freed by MSCOM/Mozilla
|
||||
CPString ** mozABUrlList = NULL; // freed by MSCOM/Mozilla
|
||||
BOOL * mozIsFirstSyncList = NULL; // freed by MSCOM/Mozilla
|
||||
BOOL neverDidPalmSyncBefore = TRUE; // 1st time palm sync?
|
||||
DWORD mozABIndex;
|
||||
|
||||
if(sync->m_dbHH) {
|
||||
DWORD mozABCount=0;
|
||||
DWORD * mozCatIDList = NULL; // freed by MSCOM/Mozilla
|
||||
CPString ** mozABNameList = NULL; // freed by MSCOM/Mozilla
|
||||
BOOL * mozIsFirstSyncList = NULL; // freed by MSCOM/Mozilla
|
||||
retval = sync->m_dbHH->OpenDB(FALSE);
|
||||
if (!retval)
|
||||
retval = sync->m_dbHH->LoadCategories();
|
||||
|
||||
retval = sync->m_dbHH->OpenDB(FALSE);
|
||||
if (!retval)
|
||||
retval = sync->m_dbHH->LoadCategories();
|
||||
if(!retval)
|
||||
retval = sync->m_dbPC->GetPCABList(&mozABCount, &mozCatIDList, &mozABNameList, &mozABUrlList, &mozIsFirstSyncList);
|
||||
|
||||
if(!retval)
|
||||
retval = sync->m_dbPC->GetPCABList(&mozABCount, &mozCatIDList, &mozABNameList, &mozIsFirstSyncList);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
// Create an array to help us identify addrbooks that have been deleted on Palm.
|
||||
DWORD *mozABSeen = (DWORD *) CoTaskMemAlloc(sizeof(DWORD) * mozABCount);
|
||||
if (!mozABSeen)
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
else
|
||||
memset(mozABSeen, FALSE, sizeof(DWORD) * mozABCount);
|
||||
|
||||
// for each category synchronize
|
||||
if (!retval) {
|
||||
CPCategory * pCategory = sync->m_dbHH->GetFirstCategory();
|
||||
while (pCategory) {
|
||||
CPalmRecord ** recordListHH = NULL;
|
||||
DWORD recordCountHH=0;
|
||||
|
||||
DWORD catID = pCategory->GetID();
|
||||
DWORD catIndex = pCategory->GetIndex();
|
||||
CPString catName(pCategory->GetName());
|
||||
|
||||
DWORD mozABIndex=0;
|
||||
BOOL foundInABList=FALSE;
|
||||
for(mozABIndex=0; mozABIndex<mozABCount; mozABIndex++) {
|
||||
// if this category has been synchronized before
|
||||
if(catID == mozCatIDList[mozABIndex]) {
|
||||
retval = sync->m_dbHH->LoadUpdatedRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
foundInABList = TRUE;
|
||||
break;
|
||||
}
|
||||
// if corresponding category exists but not synchronized before
|
||||
if(!catName.CompareNoCase(mozABNameList[mozABIndex]->GetBuffer(0))) {
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
foundInABList = TRUE;
|
||||
break;
|
||||
}
|
||||
// if it is PAB, called 'Personal' on Palm and 'Personal Address Book' in Mozilla/Netscape
|
||||
CPString personal(PERSONAL);
|
||||
if( (catName.Find(personal) != -1) &&
|
||||
(mozABNameList[mozABIndex]->Find(personal) != -1) ) {
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
foundInABList = TRUE;
|
||||
break;
|
||||
}
|
||||
} // end of for
|
||||
|
||||
if(!retval && foundInABList) {
|
||||
CPalmRecord ** recordListPC=NULL;
|
||||
DWORD recordCountPC=0;
|
||||
DWORD newRecAddedCount = 0;
|
||||
DWORD * newRecIDList=NULL;
|
||||
retval = sync->m_dbPC->SynchronizePCAB(catID, catName,
|
||||
recordCountHH, recordListHH,
|
||||
&recordCountPC, &recordListPC);
|
||||
if (!retval) {
|
||||
newRecIDList = (DWORD *) calloc(recordCountPC, sizeof(DWORD));
|
||||
for (unsigned long i=0; i < recordCountPC; i++) {
|
||||
if(!recordListPC[i])
|
||||
continue;
|
||||
CPalmRecord palmRec = *recordListPC[i];
|
||||
palmRec.SetCategory(catIndex);
|
||||
if(palmRec.GetAttribs() == ATTR_DELETED)
|
||||
retval = sync->m_dbHH->DeleteARecord(palmRec);
|
||||
else if(palmRec.GetAttribs() == ATTR_MODIFIED)
|
||||
retval = sync->m_dbHH->UpdateARecord(palmRec);
|
||||
else if(palmRec.GetAttribs() == ATTR_NEW) {
|
||||
retval = sync->m_dbHH->AddARecord(palmRec); // should we check existing recs?
|
||||
if(!retval && (newRecAddedCount < recordCountPC)) {
|
||||
newRecIDList[newRecAddedCount] = palmRec.GetID();
|
||||
newRecAddedCount++;
|
||||
}
|
||||
}
|
||||
delete recordListPC[i]; // once done with PC record, delete
|
||||
}
|
||||
}
|
||||
// the MozAB is now synchronized
|
||||
if(!retval)
|
||||
mozIsFirstSyncList[mozABIndex] = FALSE;
|
||||
// delete the PC recordList now that palm is updated
|
||||
if(recordListPC)
|
||||
free(recordListPC);
|
||||
// notify Mozilla that sync is done so that memory can be freed
|
||||
if(!retval)
|
||||
success = TRUE;
|
||||
|
||||
if(newRecAddedCount) {
|
||||
if(newRecAddedCount != recordCountPC)
|
||||
newRecIDList = (DWORD *) realloc(newRecIDList, newRecAddedCount);
|
||||
retval = sync->m_dbPC->NotifySyncDone(success, catID, newRecAddedCount, newRecIDList);
|
||||
}
|
||||
else
|
||||
retval = sync->m_dbPC->NotifySyncDone(success);
|
||||
|
||||
if(newRecIDList)
|
||||
free(newRecIDList);
|
||||
}
|
||||
|
||||
if(!retval && !foundInABList) {
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
if(!retval && recordCountHH)
|
||||
retval = sync->m_dbPC->AddRecords(catID, catName, recordCountHH, recordListHH);
|
||||
}
|
||||
// delete and free HH records and recordList once synced
|
||||
if(recordListHH) {
|
||||
CPalmRecord ** tempRecordListHH = recordListHH;
|
||||
for(DWORD i=0; i < recordCountHH; i++) {
|
||||
if(*tempRecordListHH)
|
||||
delete *tempRecordListHH;
|
||||
tempRecordListHH++;
|
||||
}
|
||||
free(recordListHH);
|
||||
}
|
||||
|
||||
pCategory = sync->m_dbHH->GetNextCategory();
|
||||
} // end of while
|
||||
|
||||
// deal with any Moz AB not existing in Palm, ones not sync'ed above
|
||||
for(DWORD mozABIndex=0; mozABIndex<mozABCount; mozABIndex++) {
|
||||
if(mozIsFirstSyncList[mozABIndex]) {
|
||||
CPalmRecord ** recordListPC=NULL;
|
||||
DWORD recordCountPC=0;
|
||||
DWORD * newRecIDList=NULL;
|
||||
CPCategory cat;
|
||||
retval = sync->m_dbPC->LoadAllRecords(*mozABNameList[mozABIndex],
|
||||
&recordCountPC, &recordListPC);
|
||||
if(!retval && recordCountPC) {
|
||||
cat.SetName(mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
retval = sync->m_dbHH->AddCategory(cat);
|
||||
}
|
||||
|
||||
if(!retval) {
|
||||
newRecIDList = (DWORD *) calloc(recordCountPC, sizeof(DWORD));
|
||||
for (unsigned long i=0; i < recordCountPC; i++) {
|
||||
if(!recordListPC[i])
|
||||
continue;
|
||||
CPalmRecord palmRec = *recordListPC[i];
|
||||
palmRec.SetCategory(cat.GetIndex());
|
||||
retval = sync->m_dbHH->AddARecord(palmRec); // should we check existing recs?
|
||||
newRecIDList[i] = palmRec.GetID();
|
||||
delete recordListPC[i]; // delete the record now that it is used
|
||||
}
|
||||
}
|
||||
// the MozAB is now synchronized
|
||||
if(!retval)
|
||||
mozIsFirstSyncList[mozABIndex] = FALSE;
|
||||
// delete the recordList now that palm is updated
|
||||
if(recordListPC)
|
||||
free(recordListPC);
|
||||
// notify Mozilla that sync is done so that memory can be freed
|
||||
if(!retval)
|
||||
success = TRUE;
|
||||
else
|
||||
recordCountPC=0;
|
||||
retval = sync->m_dbPC->NotifySyncDone(success, cat.GetID(), recordCountPC, newRecIDList);
|
||||
if(newRecIDList)
|
||||
free(newRecIDList);
|
||||
}
|
||||
} // end of mozAB for loop
|
||||
}
|
||||
|
||||
// update category info in HH
|
||||
sync->m_dbHH->CompactCategoriesToHH();
|
||||
|
||||
// close the HH DB once synced
|
||||
retval = sync->m_dbHH->CloseDB(FALSE);
|
||||
// See if palm sync was performed before.
|
||||
for(mozABIndex=0; mozABIndex<mozABCount; mozABIndex++)
|
||||
if (! mozIsFirstSyncList[mozABIndex])
|
||||
{
|
||||
neverDidPalmSyncBefore = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
// Log moz addrbooks.
|
||||
for (mozABIndex=0; mozABIndex<mozABCount; mozABIndex++)
|
||||
{
|
||||
CONDUIT_LOG4(gFD, "Moz AB[%d] category id=%d, name= '%s', url= '%s'\n",
|
||||
mozABIndex, mozCatIDList[mozABIndex], mozABNameList[mozABIndex]->GetBuffer(0), mozABUrlList[mozABIndex]->GetBuffer(0));
|
||||
}
|
||||
|
||||
// For each category, try to find the corresponding AB in the moz AB list
|
||||
// and see if it has been synchronized before and take action accordingly.
|
||||
CPCategory * pCategory = sync->m_dbHH->GetFirstCategory();
|
||||
while (pCategory)
|
||||
{
|
||||
CPalmRecord ** recordListHH = NULL;
|
||||
DWORD recordCountHH=0;
|
||||
|
||||
DWORD catID = pCategory->GetID();
|
||||
DWORD catIndex = pCategory->GetIndex();
|
||||
DWORD catFlags = pCategory->GetFlags();
|
||||
CPString catName(pCategory->GetName());
|
||||
|
||||
BOOL abRenamed = FALSE;
|
||||
BOOL foundInABList=FALSE;
|
||||
for(mozABIndex=0; mozABIndex<mozABCount; mozABIndex++)
|
||||
{
|
||||
// Palm only allows 15 chars for category names.
|
||||
CPString cutOffName;
|
||||
if (mozABNameList[mozABIndex]->Length() > 15)
|
||||
cutOffName = mozABNameList[mozABIndex]->Left(15);
|
||||
else
|
||||
cutOffName = *mozABNameList[mozABIndex];
|
||||
|
||||
// if this category has been synchronized before
|
||||
if(catID == mozCatIDList[mozABIndex]) {
|
||||
retval = sync->m_dbHH->LoadUpdatedRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
CONDUIT_LOG2(gFD, "Category id = %d, name = '%s' has been synced before\n", catID, catName.GetBuffer(0));
|
||||
foundInABList = TRUE;
|
||||
mozABSeen[mozABIndex] = TRUE; // mark it seen
|
||||
if (catName.CompareNoCase(cutOffName.GetBuffer(0)))
|
||||
{
|
||||
abRenamed = TRUE;
|
||||
CONDUIT_LOG3(gFD, "Category id = %d, name = '%s' was renamed (from '%s') on Palm so do the same on moz\n",
|
||||
catID, catName.GetBuffer(0), mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// if corresponding category exists but not synchronized before
|
||||
if(!catName.CompareNoCase(cutOffName.GetBuffer(0))){
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
CONDUIT_LOG2(gFD, "Category id = %d, name = '%s' has not been synced before\n", catID, catName.GetBuffer(0));
|
||||
foundInABList = TRUE;
|
||||
mozABSeen[mozABIndex] = TRUE; // mark it seen
|
||||
break;
|
||||
}
|
||||
} // end of for
|
||||
|
||||
if(!retval && foundInABList)
|
||||
{
|
||||
CPalmRecord ** recordListPC=NULL;
|
||||
DWORD recordCountPC=0;
|
||||
DWORD newRecAddedCount = 0;
|
||||
DWORD * newRecIDList=NULL;
|
||||
retval = sync->m_dbPC->SynchronizePCAB(catID, catName,
|
||||
recordCountHH, recordListHH,
|
||||
&recordCountPC, &recordListPC);
|
||||
// SynchronizePCAB() returns a list of modified moz records so update those on Palm.
|
||||
if (!retval) {
|
||||
unsigned long i;
|
||||
newRecIDList = (DWORD *) calloc(recordCountPC, sizeof(DWORD));
|
||||
for (i=0; i < recordCountPC; i++) {
|
||||
if(!recordListPC[i])
|
||||
continue;
|
||||
CPalmRecord palmRec = *recordListPC[i];
|
||||
palmRec.SetCategory(catIndex);
|
||||
if(palmRec.GetAttribs() == ATTR_DELETED)
|
||||
retval = sync->m_dbHH->DeleteARecord(palmRec);
|
||||
else if(palmRec.GetAttribs() == ATTR_MODIFIED)
|
||||
retval = sync->m_dbHH->UpdateARecord(palmRec);
|
||||
else if(palmRec.GetAttribs() == ATTR_NEW) {
|
||||
retval = sync->m_dbHH->AddARecord(palmRec); // should we check existing recs?
|
||||
if(!retval && (newRecAddedCount < recordCountPC)) {
|
||||
newRecIDList[newRecAddedCount] = palmRec.GetID();
|
||||
newRecAddedCount++;
|
||||
}
|
||||
}
|
||||
delete recordListPC[i]; // once done with PC record, delete
|
||||
}
|
||||
}
|
||||
// the MozAB is now synchronized
|
||||
if(!retval)
|
||||
mozIsFirstSyncList[mozABIndex] = FALSE;
|
||||
// delete the PC recordList now that palm is updated
|
||||
if(recordListPC)
|
||||
free(recordListPC);
|
||||
// notify Mozilla that sync is done so that memory can be freed
|
||||
if(!retval)
|
||||
success = TRUE;
|
||||
|
||||
if(newRecAddedCount) {
|
||||
if(newRecAddedCount != recordCountPC)
|
||||
newRecIDList = (DWORD *) realloc(newRecIDList, newRecAddedCount);
|
||||
retval = sync->m_dbPC->NotifySyncDone(success, catID, newRecAddedCount, newRecIDList);
|
||||
}
|
||||
else
|
||||
retval = sync->m_dbPC->NotifySyncDone(success);
|
||||
|
||||
if(newRecIDList)
|
||||
free(newRecIDList);
|
||||
|
||||
// See if it was renamed on palm. Use delete and add AB to implement rename here.
|
||||
if (abRenamed)
|
||||
{
|
||||
// We should not reanme personal and collected address books here.
|
||||
if (mozABUrlList[mozABIndex]->CompareNoCase(PERSONAL_ADDRBOOK_URL) &&
|
||||
mozABUrlList[mozABIndex]->CompareNoCase(COLLECTED_ADDRBOOK_URL))
|
||||
{
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
if(!retval)
|
||||
retval = sync->m_dbPC->AddRecords(catID, catName, recordCountHH, recordListHH);
|
||||
if(!retval)
|
||||
retval = sync->m_dbPC->DeletePCAB(mozCatIDList[mozABIndex], *mozABNameList[mozABIndex], *mozABUrlList[mozABIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If this category can't be found in the moz AB list then two cases here:
|
||||
// 1. If catFlags is not CAT_DIRTY then this category has been deleted
|
||||
// on moz so remove it from palm side.
|
||||
// 2. else, if we never did palm sync on moz before then it's a new one
|
||||
// on palm. So create a new AB in moz with all records in this category
|
||||
// (even if it's an empty AB).
|
||||
if(!retval && !foundInABList) {
|
||||
if (catFlags != CAT_DIRTY && !neverDidPalmSyncBefore)
|
||||
{
|
||||
CONDUIT_LOG2(gFD, "Category id = %d, name = '%s' is removed from moz and needs to be removed from palm\n", catID, catName.GetBuffer(0));
|
||||
sync->m_dbHH->DeleteCategory(catIndex, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
CONDUIT_LOG2(gFD, "Category id = %d, name = '%s' is new on palm and needs to be added to moz\n", catID, catName.GetBuffer(0));
|
||||
retval = sync->m_dbHH->LoadAllRecordsInCategory(catIndex, &recordListHH, &recordCountHH);
|
||||
if(!retval)
|
||||
retval = sync->m_dbPC->AddRecords(catID, catName, recordCountHH, recordListHH);
|
||||
}
|
||||
}
|
||||
|
||||
// delete and free HH records and recordList once synced
|
||||
if(recordListHH) {
|
||||
CPalmRecord ** tempRecordListHH = recordListHH;
|
||||
for(DWORD i=0; i < recordCountHH; i++) {
|
||||
if(*tempRecordListHH)
|
||||
delete *tempRecordListHH;
|
||||
tempRecordListHH++;
|
||||
}
|
||||
free(recordListHH);
|
||||
}
|
||||
|
||||
// Process next category
|
||||
pCategory = sync->m_dbHH->GetNextCategory();
|
||||
} // end of while
|
||||
|
||||
// Deal with any Moz AB not existing in Palm, ones not sync'ed above,
|
||||
// and the case where Palm ABs have been deleted.
|
||||
for(mozABIndex=0; mozABIndex<mozABCount; mozABIndex++)
|
||||
{
|
||||
if(mozIsFirstSyncList[mozABIndex])
|
||||
{
|
||||
CONDUIT_LOG3(gFD, "Moz AB[%d] category id = %d, name = '%s' doesn't exist on Palm so needs to be added to palm\n",
|
||||
mozABIndex, mozCatIDList[mozABIndex], mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
CPalmRecord ** recordListPC=NULL;
|
||||
DWORD recordCountPC=0;
|
||||
DWORD * newRecIDList=NULL;
|
||||
CPCategory cat;
|
||||
retval = sync->m_dbPC->LoadAllRecords(*mozABNameList[mozABIndex],
|
||||
&recordCountPC, &recordListPC);
|
||||
if(!retval) {
|
||||
cat.SetName(mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
retval = sync->m_dbHH->AddCategory(cat);
|
||||
}
|
||||
|
||||
if(!retval) {
|
||||
newRecIDList = (DWORD *) calloc(recordCountPC, sizeof(DWORD));
|
||||
for (unsigned long i=0; i < recordCountPC; i++) {
|
||||
if(!recordListPC[i])
|
||||
continue;
|
||||
CPalmRecord palmRec = *recordListPC[i];
|
||||
palmRec.SetCategory(cat.GetIndex());
|
||||
retval = sync->m_dbHH->AddARecord(palmRec); // should we check existing recs?
|
||||
newRecIDList[i] = palmRec.GetID();
|
||||
delete recordListPC[i]; // delete the record now that it is used
|
||||
}
|
||||
}
|
||||
// the MozAB is now synchronized
|
||||
if(!retval)
|
||||
mozIsFirstSyncList[mozABIndex] = FALSE;
|
||||
// delete the recordList now that palm is updated
|
||||
if(recordListPC)
|
||||
free(recordListPC);
|
||||
// notify Mozilla that sync is done so that memory can be freed
|
||||
if(!retval)
|
||||
success = TRUE;
|
||||
else
|
||||
recordCountPC=0;
|
||||
retval = sync->m_dbPC->NotifySyncDone(success, cat.GetID(), recordCountPC, newRecIDList);
|
||||
if(newRecIDList)
|
||||
free(newRecIDList);
|
||||
|
||||
// Lastly, update the AB with new category id and mod time.
|
||||
retval = sync->m_dbPC->UpdatePCABSyncInfo(cat.GetID(), *mozABNameList[mozABIndex]);
|
||||
}
|
||||
else if (!mozABSeen[mozABIndex] && !neverDidPalmSyncBefore)
|
||||
{
|
||||
// We should not delete personal and collected address books here. Rather,
|
||||
// reset the mod time so next time we can sync them back to Palm again.
|
||||
if (mozABUrlList[mozABIndex]->CompareNoCase(PERSONAL_ADDRBOOK_URL) &&
|
||||
mozABUrlList[mozABIndex]->CompareNoCase(COLLECTED_ADDRBOOK_URL))
|
||||
{
|
||||
CONDUIT_LOG3(gFD, "Moz AB[%d] category id = %d, name = '%s' is removed on Palm and needs to be removed from moz\n",
|
||||
mozABIndex, mozCatIDList[mozABIndex], mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
retval = sync->m_dbPC->DeletePCAB(mozCatIDList[mozABIndex], *mozABNameList[mozABIndex], *mozABUrlList[mozABIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
CONDUIT_LOG3(gFD, "Moz AB[%d] category id = %d, name = '%s', is removed on Palm but only need to update sync info on moz\n",
|
||||
mozABIndex, mozCatIDList[mozABIndex], mozABNameList[mozABIndex]->GetBuffer(0));
|
||||
// Reset category id and mod time.
|
||||
retval = sync->m_dbPC->UpdatePCABSyncInfo(-1, *mozABNameList[mozABIndex]);
|
||||
}
|
||||
}
|
||||
} // end of mozAB not existing in Palm for loop
|
||||
|
||||
// Purge deleted Palm record permanently (in case they were logically deleted).
|
||||
sync->m_dbHH->PurgeDeletedRecs();
|
||||
|
||||
// Free stuff we allocated.
|
||||
CoTaskMemFree(mozABSeen);
|
||||
|
||||
// update category info in HH
|
||||
sync->m_dbHH->CompactCategoriesToHH();
|
||||
|
||||
// close the HH DB once synced
|
||||
retval = sync->m_dbHH->CloseDB(FALSE);
|
||||
|
||||
// Log the end time.
|
||||
time( <ime );
|
||||
CONDUIT_LOG1(gFD, "------------ END OF PALM SYNC ------------ at %s\n", ctime(<ime));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,27 @@
|
|||
#include "MozABHHManager.h"
|
||||
#include "MozABPCManager.h"
|
||||
|
||||
#define PERSONAL_ADDRBOOK_URL "moz-abmdbdirectory://abook.mab"
|
||||
#define COLLECTED_ADDRBOOK_URL "moz-abmdbdirectory://history.mab"
|
||||
|
||||
#define ENV_VAR_CONDUTI_LOG "MOZ_CONDUIT_LOG"
|
||||
|
||||
#define CONDUIT_LOG0(fd, format) \
|
||||
if (fd) \
|
||||
fprintf(fd, format);
|
||||
#define CONDUIT_LOG1(fd, format, arg1) \
|
||||
if (fd) \
|
||||
fprintf(fd, format, arg1);
|
||||
#define CONDUIT_LOG2(fd, format, arg1, arg2) \
|
||||
if (fd) \
|
||||
fprintf(fd, format, arg1, arg2);
|
||||
#define CONDUIT_LOG3(fd, format, arg1, arg2, arg3) \
|
||||
if (fd) \
|
||||
fprintf(fd, format, arg1, arg2, arg3);
|
||||
#define CONDUIT_LOG4(fd, format, arg1, arg2, arg3, arg4) \
|
||||
if (fd) \
|
||||
fprintf(fd, format, arg1, arg2, arg3, arg4);
|
||||
|
||||
class CMozABConduitSync
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -258,7 +258,10 @@ long MozABHHManager::DeleteCategory(DWORD dwCategory, BOOL bMoveToUnfiled)
|
|||
BYTE sCategory = LOBYTE(LOWORD(dwCategory));
|
||||
|
||||
if (!bMoveToUnfiled)
|
||||
{
|
||||
retval = SyncPurgeAllRecsInCategory(m_hhDB, sCategory);
|
||||
m_pCatMgr->DeleteByIndex(dwCategory); // delete category itself
|
||||
}
|
||||
else
|
||||
retval = SyncChangeCategory(m_hhDB, sCategory, 0);
|
||||
return retval;
|
||||
|
@ -396,6 +399,8 @@ long MozABHHManager::LoadUpdatedRecords(DWORD catIndex, CPalmRecord ***ppRecordL
|
|||
memset(palmRecordList, 0, sizeof(CPalmRecord *) * dwRecCount);
|
||||
*ppRecordList = palmRecordList;
|
||||
|
||||
// SyncReadNextModifiedRecInCategory() does not seem to be returning
|
||||
// deleted palm records, so SyncReadNextModifiedRec() is used instead.
|
||||
CPalmRecord *pPalmRec;
|
||||
*pListSize = 0;
|
||||
while ((!retval) && (*pListSize < dwRecCount)) {
|
||||
|
@ -403,13 +408,10 @@ long MozABHHManager::LoadUpdatedRecords(DWORD catIndex, CPalmRecord ***ppRecordL
|
|||
if(retval)
|
||||
break;
|
||||
m_rInfo.m_RecIndex = 0;
|
||||
if(catIndex >= 0) {
|
||||
m_rInfo.m_CatId = catIndex;
|
||||
retval = SyncReadNextModifiedRecInCategory(m_rInfo);
|
||||
}
|
||||
else
|
||||
retval = SyncReadNextModifiedRec(m_rInfo);
|
||||
if (!retval) {
|
||||
retval = SyncReadNextModifiedRec(m_rInfo);
|
||||
// Does it belong to the category we care about?
|
||||
if (!retval && m_rInfo.m_CatId == catIndex)
|
||||
{
|
||||
pPalmRec = new CPalmRecord(m_rInfo);
|
||||
if (pPalmRec) {
|
||||
*palmRecordList = pPalmRec;
|
||||
|
@ -723,3 +725,7 @@ long MozABHHManager::DeleteARecord(CPalmRecord & palmRec)
|
|||
return retval;
|
||||
}
|
||||
|
||||
long MozABHHManager::PurgeDeletedRecs(void)
|
||||
{
|
||||
return (SyncPurgeDeletedRecs(m_hhDB));
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
long AddARecord(CPalmRecord & palmRec);
|
||||
long DeleteARecord(CPalmRecord & palmRec);
|
||||
long UpdateARecord(CPalmRecord & palmRec);
|
||||
long PurgeDeletedRecs(void);
|
||||
|
||||
protected:
|
||||
char m_szName[SYNC_DB_NAMELEN];
|
||||
|
|
|
@ -86,7 +86,7 @@ BOOL MozABPCManager::InitMozPalmSyncInstance(IPalmSync **aRetValue)
|
|||
}
|
||||
|
||||
// this function allocates the list as well as the strings, caller should free list and delete strings
|
||||
long MozABPCManager::GetPCABList(DWORD * pCategoryCount, DWORD ** pCategoryIdList, CPString *** pCategoryNameList, BOOL ** pIsFirstTimeSyncList)
|
||||
long MozABPCManager::GetPCABList(DWORD * pCategoryCount, DWORD ** pCategoryIdList, CPString *** pCategoryNameList, CPString *** pCategoryUrlList, BOOL ** pIsFirstTimeSyncList)
|
||||
{
|
||||
lpnsMozABDesc mozABNameList=NULL;
|
||||
|
||||
|
@ -116,16 +116,31 @@ long MozABPCManager::GetPCABList(DWORD * pCategoryCount, DWORD ** pCategoryIdLis
|
|||
memset(abNameList, 0, sizeof(CPString *) * dwMozABCount);
|
||||
*pCategoryNameList = abNameList;
|
||||
|
||||
CPString ** abUrlList = (CPString **) malloc(sizeof(CPString *) * dwMozABCount);
|
||||
if (!abUrlList) {
|
||||
free(mozABNameList);
|
||||
free(abNameList);
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
memset(abUrlList, 0, sizeof(CPString *) * dwMozABCount);
|
||||
*pCategoryUrlList = abUrlList;
|
||||
|
||||
for (int i=0; i < dwMozABCount; i++) {
|
||||
CPString * pABName = new CPString((LPCTSTR) mozABNameList[i].lpszABDesc);
|
||||
if (pABName) {
|
||||
CPString * pABName = new CPString((LPCTSTR) mozABNameList[i].lpszABName);
|
||||
if (pABName)
|
||||
*abNameList = pABName;
|
||||
abNameList++;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
}
|
||||
CoTaskMemFree(mozABNameList[i].lpszABDesc);
|
||||
CoTaskMemFree(mozABNameList[i].lpszABName);
|
||||
abNameList++;
|
||||
|
||||
CPString * pABUrl = new CPString((LPCTSTR) mozABNameList[i].lpszABUrl);
|
||||
if (pABUrl)
|
||||
*abUrlList = pABUrl;
|
||||
else
|
||||
return GEN_ERR_LOW_MEMORY;
|
||||
CoTaskMemFree(mozABNameList[i].lpszABUrl);
|
||||
abUrlList++;
|
||||
}
|
||||
|
||||
CoTaskMemFree(mozABNameList);
|
||||
|
@ -300,3 +315,28 @@ long MozABPCManager::NotifySyncDone(BOOL success, DWORD catID, DWORD newRecCount
|
|||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::UpdatePCABSyncInfo(DWORD categoryId, CPString & categoryName)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsUpdateABSyncInfo(FALSE, categoryId, categoryName);
|
||||
long retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
long MozABPCManager::DeletePCAB(DWORD categoryId, CPString & categoryName, CPString & categoryUrl)
|
||||
{
|
||||
IPalmSync *pNsPalmSync = NULL;
|
||||
// get the interface
|
||||
if (!InitMozPalmSyncInstance(&pNsPalmSync))
|
||||
return GEN_ERR_NOT_SUPPORTED;
|
||||
|
||||
HRESULT hres = pNsPalmSync->nsDeleteAB(FALSE, categoryId, categoryName, categoryUrl);
|
||||
long retval = (long) hres;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
// this will return the list of ABs in Mozilla and if they were synced before
|
||||
long GetPCABList(DWORD * pCategoryCount, DWORD ** pCategoryIdList,
|
||||
CPString *** pCategoryNameList, BOOL ** pIsFirstTimeSyncList);
|
||||
CPString *** pCategoryNameList, CPString *** pCategoryURLList, BOOL ** pIsFirstTimeSyncList);
|
||||
// this will update a Mozilla AB with updated Palm records and
|
||||
// return updated records in a Mozilla AB after the last sync
|
||||
// this will take care of first time sync also in which case
|
||||
|
@ -67,7 +67,12 @@ public:
|
|||
// this load all records in an Moz AB
|
||||
long LoadAllRecords(CPString & ABName, DWORD * pPCRecListCount, CPalmRecord *** pPCRecList);
|
||||
|
||||
long NotifySyncDone(BOOL success, DWORD catID=-1, DWORD newRecCount=0, DWORD * newRecIDList=NULL);
|
||||
long NotifySyncDone(BOOL success, DWORD catID=-1, DWORD newRecCount=0, DWORD * newRecIDList=NULL);
|
||||
|
||||
// Update/Reset category id and mod time in an Moz AB
|
||||
long UpdatePCABSyncInfo(DWORD categoryId, CPString & categoryName);
|
||||
// Delete an Moz AB
|
||||
long DeletePCAB(DWORD categoryId, CPString & categoryName, CPString & categoryUrl);
|
||||
|
||||
private:
|
||||
// this will initiate the communication with Mozilla
|
||||
|
|
|
@ -140,24 +140,37 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
|
|||
// server->description is represented in UTF8, we need to do some conversion...
|
||||
if(aIsUnicode) {
|
||||
// convert to Unicode
|
||||
nsAutoString abName;
|
||||
nsAutoString abName, abUrl;
|
||||
rv = ConvertToUnicode("UTF-8", server->description, abName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
rv = ConvertToUnicode("UTF-8", server->uri, abUrl);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
// add to the list
|
||||
m_ServerDescList->lpszABDesc = (LPTSTR) CoTaskMemAlloc(sizeof(PRUnichar) * (abName.Length()+1));
|
||||
wcscpy(m_ServerDescList->lpszABDesc, abName.get());
|
||||
m_ServerDescList->lpszABName = (LPTSTR) CoTaskMemAlloc(sizeof(PRUnichar) * (abName.Length()+1));
|
||||
wcscpy(m_ServerDescList->lpszABName, abName.get());
|
||||
m_ServerDescList->lpszABUrl = (LPTSTR) CoTaskMemAlloc(sizeof(PRUnichar) * (abUrl.Length()+1));
|
||||
wcscpy(m_ServerDescList->lpszABUrl, abUrl.get());
|
||||
}
|
||||
else {
|
||||
// we need to convert the description from UTF-8 to Unicode and then to ASCII
|
||||
nsAutoString abUName;
|
||||
nsAutoString abUName, abUUrl;
|
||||
rv = ConvertToUnicode("UTF-8", server->description, abUName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsCAutoString abName = NS_LossyConvertUCS2toASCII(abUName);
|
||||
|
||||
m_ServerDescList->lpszABDesc = (LPTSTR) CoTaskMemAlloc(sizeof(char) * (abName.Length()+1));
|
||||
strcpy((char*)m_ServerDescList->lpszABDesc, abName.get());
|
||||
rv = ConvertToUnicode("UTF-8", server->uri, abUUrl);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsCAutoString abUrl = NS_LossyConvertUCS2toASCII(abUUrl);
|
||||
|
||||
m_ServerDescList->lpszABName = (LPTSTR) CoTaskMemAlloc(sizeof(char) * (abName.Length()+1));
|
||||
strcpy((char*)m_ServerDescList->lpszABName, abName.get());
|
||||
|
||||
m_ServerDescList->lpszABUrl = (LPTSTR) CoTaskMemAlloc(sizeof(char) * (abUrl.Length()+1));
|
||||
strcpy((char*)m_ServerDescList->lpszABUrl, abUrl.get());
|
||||
}
|
||||
m_ServerDescList++;
|
||||
|
||||
|
@ -256,4 +269,41 @@ STDMETHODIMP CPalmSyncImp::nsAckSyncDone(BOOL aIsSuccess, int aCatID, int aNewRe
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
// Update the category id and mod tiem for the Address Book in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsUpdateABSyncInfo(BOOL aIsUnicode, unsigned long aCategoryId, LPTSTR aABName)
|
||||
{
|
||||
nsresult rv;
|
||||
if(m_PalmHotSync)
|
||||
rv = ((nsAbPalmHotSync *)m_PalmHotSync)->UpdateSyncInfo(aCategoryId);
|
||||
else
|
||||
{
|
||||
// Launch another ABpalmHotSync session.
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (char*)aABName, aCategoryId);
|
||||
rv = palmHotSync.Initialize();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = palmHotSync.UpdateSyncInfo(aCategoryId);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Delete an Address Book in Mozilla
|
||||
STDMETHODIMP CPalmSyncImp::nsDeleteAB(BOOL aIsUnicode, unsigned long aCategoryId, LPTSTR aABName, LPTSTR aABUrl)
|
||||
{
|
||||
// This is an independent operation so use a local nsAbPalmHotSync var
|
||||
// (ie the callers don't need to call AckSyncdone after this is done).
|
||||
nsAbPalmHotSync palmHotSync(aIsUnicode, aABName, (char*)aABName, aCategoryId);
|
||||
|
||||
nsresult rv = palmHotSync.DeleteAB(aCategoryId, aABName, (char*)aABUrl);;
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,10 @@ public :
|
|||
int * aMozRecCount, lpnsABCOMCardStruct * aMozRecList);
|
||||
|
||||
STDMETHODIMP nsAckSyncDone(BOOL aIsSuccess, int aCatID, int aNewRecCount, unsigned long * aNewPalmRecIDList);
|
||||
|
||||
STDMETHODIMP nsUpdateABSyncInfo(BOOL aIsUnicode, unsigned long aCategoryId, LPTSTR aABName);
|
||||
|
||||
STDMETHODIMP nsDeleteAB(BOOL aIsUnicode, unsigned long aCategoryId, LPTSTR aABName, LPTSTR aABUrl);
|
||||
|
||||
private :
|
||||
PRInt32 m_cRef;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsAbPalmSync.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
|
@ -195,7 +195,7 @@ nsresult nsAbPalmHotSync::Initialize()
|
|||
if(NS_FAILED(rv)) return rv ;
|
||||
|
||||
// if Palm category is not already assigned check the AB name
|
||||
if(abName.Find(mAbName) != kNotFound)
|
||||
if(abName == mAbName)
|
||||
break;
|
||||
|
||||
server = nsnull;
|
||||
|
@ -219,7 +219,7 @@ nsresult nsAbPalmHotSync::AddAllRecordsInNewAB(PRInt32 aCount, lpnsABCOMCardStru
|
|||
nsAutoString fileName(mAbName.get());
|
||||
fileName.AppendWithConversion(".mab");
|
||||
fileName.StripWhitespace();
|
||||
nsresult rv = DIR_AddNewAddressBook(mAbName.get(), NS_ConvertUCS2toUTF8(fileName).get(),
|
||||
nsresult rv = DIR_AddNewAddressBook(mAbName.get(), nsnull /*let filename be generated*/,
|
||||
PR_FALSE, MAPIDirectory, &server);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -238,7 +238,7 @@ nsresult nsAbPalmHotSync::AddAllRecordsInNewAB(PRInt32 aCount, lpnsABCOMCardStru
|
|||
|
||||
// new DB here so no need to backup
|
||||
rv = UpdateMozABWithPalmRecords();
|
||||
|
||||
|
||||
rv = mABDB->Close(NS_SUCCEEDED(rv));
|
||||
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
|
@ -771,13 +771,13 @@ nsresult nsAbPalmHotSync::UpdateMozABWithPalmRecords()
|
|||
rv = mABDB->GetCardFromAttribute(nsnull, CARD_ATTRIB_PALMID, recordIDBuf,
|
||||
PR_FALSE, getter_AddRefs(existingCard));
|
||||
if(NS_SUCCEEDED(rv) && existingCard) {
|
||||
if(palmRec->dwStatus == ATTR_DELETED) {
|
||||
if(palmRec->dwStatus & ATTR_DELETED) {
|
||||
mABDB->DeleteCard(existingCard, PR_FALSE);
|
||||
continue;
|
||||
}
|
||||
if(palmRec->dwStatus == ATTR_NEW)
|
||||
if(palmRec->dwStatus & ATTR_NEW)
|
||||
continue;
|
||||
if(palmRec->dwStatus == ATTR_MODIFIED) {
|
||||
if(palmRec->dwStatus & ATTR_MODIFIED) {
|
||||
PRBool isEqual=PR_FALSE;
|
||||
ipcCard.Equals(existingCard, &isEqual);
|
||||
if(isEqual)
|
||||
|
@ -882,3 +882,63 @@ nsresult nsAbPalmHotSync::Done(PRBool aSuccess, PRInt32 aPalmCatID, PRUint32 aPa
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsAbPalmHotSync::UpdateSyncInfo(unsigned long aCategoryId)
|
||||
{
|
||||
if (!mDirServerInfo)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// aCategoryId = -1 means that callers want to reset the mod time as well.
|
||||
mDBOpen = PR_FALSE;
|
||||
PRUint32 modTimeInSec;
|
||||
nsAddrDatabase::PRTime2Seconds(PR_Now(), &modTimeInSec);
|
||||
if (aCategoryId >= 0)
|
||||
mDirServerInfo->PalmSyncTimeStamp = modTimeInSec;
|
||||
else
|
||||
mDirServerInfo->PalmSyncTimeStamp = 0; // Reset mod time.
|
||||
mDirServerInfo->PalmCategoryId = aCategoryId;
|
||||
DIR_SavePrefsForOneServer(mDirServerInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsAbPalmHotSync::DeleteAB(unsigned long aCategoryId, PRUnichar * aAbName, char * aABUrl)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsArray> parentArray(do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsArray> selectedArray(do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID));
|
||||
|
||||
nsCOMPtr<nsIRDFService> rdfService = do_GetService (NS_RDF_CONTRACTID "/rdf-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Parent nsIABDirectory: like "moz-abdirectory://".
|
||||
nsCOMPtr <nsIRDFResource> resource;
|
||||
rv = rdfService->GetResource("moz-abdirectory://", getter_AddRefs(resource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIAbDirectory> parentDirectory = do_QueryInterface(resource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
parentArray->AppendElement(parentDirectory);
|
||||
|
||||
// Selected folder nsIABDirectory: like "moz-abmdbdirectory://abook-1.mab"
|
||||
nsCOMPtr <nsIRDFResource> childResource;
|
||||
rv = rdfService->GetResource(aABUrl, getter_AddRefs(childResource));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr <nsIAbDirectory> selectedDirectory = do_QueryInterface(childResource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
selectedArray->AppendElement(selectedDirectory);
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> ds;
|
||||
rv = rdfService->GetDataSource("rdf:addressdirectory", getter_AddRefs(ds));
|
||||
if (NS_FAILED(rv) || !ds)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr <nsIAddressBook> ab = do_CreateInstance(NS_ADDRESSBOOK_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !ab)
|
||||
return rv;
|
||||
|
||||
return(ab->DeleteAddressBooks(ds, parentArray, selectedArray));
|
||||
}
|
||||
|
|
|
@ -75,6 +75,12 @@ public:
|
|||
// this will be called when an AckSyncDone is recieved from the Conduit
|
||||
nsresult Done(PRBool aSuccess, PRInt32 aPalmCatID, PRUint32 aPalmRecIDListCount = 0, unsigned long * aPalmRecordIDList = nsnull);
|
||||
|
||||
// this will upate AB with new category id and mod time.
|
||||
nsresult UpdateSyncInfo(unsigned long aCategoryId);
|
||||
|
||||
// this will delete an AB
|
||||
nsresult DeleteAB(unsigned long aCategoryId, PRUnichar * aAbName, char * aABUrl);
|
||||
|
||||
protected:
|
||||
|
||||
PRBool mIsPalmDataUnicode;
|
||||
|
|
Загрузка…
Ссылка в новой задаче