зеркало из https://github.com/mozilla/pjs.git
Add New Card function and remove hardcoded datd from address book
This commit is contained in:
Родитель
71fff5c1c0
Коммит
af33a52297
|
@ -37,7 +37,7 @@ EXPORTS= \
|
|||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libaddrbook_s.a \
|
||||
$(DIST)/lib/libmsgmork_s.a \
|
||||
$(DIST)/lib/librdfutil_s.a \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
|
@ -47,7 +47,6 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(NSPR_LIBS) \
|
||||
-L$(DIST)/bin \
|
||||
-lxpcom \
|
||||
-lmsgbaseutil \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -37,11 +37,8 @@ CPP_OBJS= \
|
|||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\msgbaseutil.lib \
|
||||
$(DIST)\lib\msgmork_s.lib \
|
||||
$(DIST)\lib\addrbook_s.lib \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\rdfutil_s.lib \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -23,34 +23,46 @@
|
|||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#define NS_ABDIRECTORYDATASOURCE_CID \
|
||||
#define NS_ADDRESSBOOK_CID \
|
||||
{ /* {D60B84F2-2A8C-11d3-9E07-00A0C92B5F0D} */ \
|
||||
0xd60b84f2, 0x2a8c, 0x11d3, \
|
||||
{ 0x9e, 0x7, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd } \
|
||||
};
|
||||
|
||||
#define NS_ABDIRECTORYDATASOURCE_CID \
|
||||
{ /* 0A79186D-F754-11d2-A2DA-001083003D0C */ \
|
||||
0xa79186d, 0xf754, 0x11d2, \
|
||||
{0xa2, 0xda, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
#define NS_ABDIRECTORYRESOURCE_CID \
|
||||
#define NS_ABDIRECTORYRESOURCE_CID \
|
||||
{ /* {6C21831D-FCC2-11d2-A2E2-001083003D0C}*/ \
|
||||
0x6c21831d, 0xfcc2, 0x11d2, \
|
||||
{0xa2, 0xe2, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
#define NS_ABCARDDATASOURCE_CID \
|
||||
#define NS_ABCARDDATASOURCE_CID \
|
||||
{ /* 1920E486-0709-11d3-A2EC-001083003D0C */ \
|
||||
0x1920e486, 0x709, 0x11d3, \
|
||||
{0xa2, 0xec, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
#define NS_ABCARDRESOURCE_CID \
|
||||
#define NS_ABCARDRESOURCE_CID \
|
||||
{ /* {1920E487-0709-11d3-A2EC-001083003D0C}*/ \
|
||||
0x1920e487, 0x709, 0x11d3, \
|
||||
{0xa2, 0xec, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
#define NS_ADDRESSBOOKDB_CID \
|
||||
#define NS_ADDRESSBOOKDB_CID \
|
||||
{ /* 63187917-1D19-11d3-A302-001083003D0C */ \
|
||||
0x63187917, 0x1d19, 0x11d3, \
|
||||
{0xa3, 0x2, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
|
||||
}
|
||||
|
||||
#define NS_ABCARDPROPERTY_CID \
|
||||
{ /* 2B722171-2CEA-11d3-9E0B-00A0C92B5F0D */ \
|
||||
0x2b722171, 0x2cea, 0x11d3, \
|
||||
{0x9e, 0xb, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd} \
|
||||
}
|
||||
|
||||
#endif // nsAbBaseCID_h__
|
||||
|
|
|
@ -35,14 +35,17 @@
|
|||
#include "nsAbDirectory.h"
|
||||
#include "nsAbCard.h"
|
||||
#include "nsAddrDatabase.h"
|
||||
#include "nsAddressBook.h"
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
static NS_DEFINE_CID(kAddressBookCID, NS_ADDRESSBOOK_CID);
|
||||
static NS_DEFINE_CID(kAbDirectoryDataSourceCID, NS_ABDIRECTORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kAbDirectoryCID, NS_ABDIRECTORYRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kAbCardDataSourceCID, NS_ABCARDDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kAbCardCID, NS_ABCARDRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDB, NS_ADDRESSBOOKDB_CID);
|
||||
static NS_DEFINE_CID(kAbCardPropertyCID, NS_ABCARDPROPERTY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -124,7 +127,20 @@ nsresult nsAbFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, voi
|
|||
// ClassID check happens here
|
||||
// Whenever you add a new class that supports an interface, plug it in here!!!
|
||||
|
||||
if (mClassID.Equals(kAbDirectoryDataSourceCID))
|
||||
if (mClassID.Equals(kAddressBookCID))
|
||||
{
|
||||
nsresult rv;
|
||||
nsAddressBook * addressBook = new nsAddressBook();
|
||||
if (addressBook)
|
||||
rv = addressBook->QueryInterface(aIID, aResult);
|
||||
else
|
||||
rv = NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (NS_FAILED(rv) && addressBook)
|
||||
delete addressBook;
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kAbDirectoryDataSourceCID))
|
||||
{
|
||||
nsresult rv;
|
||||
nsABDirectoryDataSource * directoryDataSource = new nsABDirectoryDataSource();
|
||||
|
@ -150,7 +166,7 @@ nsresult nsAbFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, voi
|
|||
delete directory;
|
||||
return rv;
|
||||
}
|
||||
if (mClassID.Equals(kAbCardDataSourceCID))
|
||||
else if (mClassID.Equals(kAbCardDataSourceCID))
|
||||
{
|
||||
nsresult rv;
|
||||
nsABCardDataSource * cardDataSource = new nsABCardDataSource();
|
||||
|
@ -188,7 +204,20 @@ nsresult nsAbFactory::CreateInstance(nsISupports *aOuter, const nsIID &aIID, voi
|
|||
if (NS_FAILED(rv) && abDatabase)
|
||||
delete abDatabase;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if (mClassID.Equals(kAbCardPropertyCID))
|
||||
{
|
||||
nsresult rv;
|
||||
nsAbCardProperty * abCardProperty = new nsAbCardProperty();
|
||||
if (abCardProperty)
|
||||
rv = abCardProperty->QueryInterface(aIID, aResult);
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv) && abCardProperty)
|
||||
delete abCardProperty;
|
||||
return rv;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
@ -237,6 +266,12 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
|
|||
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kAddressBookCID,
|
||||
"Address Book DOM interaction object",
|
||||
"component://netscape/addressbook",
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
// register our RDF datasources:
|
||||
rv = compMgr->RegisterComponent(kAbDirectoryDataSourceCID,
|
||||
"Mail/News Address Book Directory Data Source",
|
||||
|
@ -270,6 +305,14 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
|
|||
path, PR_TRUE, PR_TRUE);
|
||||
if (NS_FAILED(rv))finalResult = rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kAbCardPropertyCID,
|
||||
"Mail/News Address Book Card Property",
|
||||
"component://netscape/addressbook/cardproperty",
|
||||
path, PR_TRUE, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
|
@ -285,6 +328,9 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* path)
|
|||
NS_WITH_SERVICE1(nsIComponentManager, compMgr, aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kAddressBookCID, path);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kAbDirectoryDataSourceCID, path);
|
||||
if (NS_FAILED(rv)) finalResult = rv;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ XPIDLSRCS = \
|
|||
nsIAddrDBAnnouncer.idl \
|
||||
nsIAddrDBListener.idl \
|
||||
nsIAddrDatabase.idl \
|
||||
nsIAddressBook.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
|
|
@ -26,6 +26,7 @@ XPIDLSRCS = \
|
|||
.\nsIAddrDBAnnouncer.idl \
|
||||
.\nsIAddrDBListener.idl \
|
||||
.\nsIAddrDatabase.idl \
|
||||
.\nsIAddressBook.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -21,25 +21,48 @@
|
|||
[scriptable, uuid(FA5C977F-04C8-11d3-A2EB-001083003D0C)]
|
||||
interface nsIAbCard : nsIAbBase {
|
||||
|
||||
attribute string personName;
|
||||
attribute string listName;
|
||||
attribute string email;
|
||||
attribute string city;
|
||||
attribute string FirstName;
|
||||
attribute string LastName;
|
||||
attribute string DisplayName;
|
||||
attribute string NickName;
|
||||
attribute string PrimaryEmail;
|
||||
attribute string SecondEmail;
|
||||
attribute string WorkPhone;
|
||||
attribute string HomePhone;
|
||||
attribute string FaxNumber;
|
||||
attribute string PagerNumber;
|
||||
attribute string CellularNumber;
|
||||
attribute string HomeAddress;
|
||||
attribute string HomeAddress2;
|
||||
attribute string HomeCity;
|
||||
attribute string HomeState;
|
||||
attribute string HomeZipCode;
|
||||
attribute string HomeCountry;
|
||||
attribute string WorkAddress;
|
||||
attribute string WorkAddress2;
|
||||
attribute string WorkCity;
|
||||
attribute string WorkState;
|
||||
attribute string WorkZipCode;
|
||||
attribute string WorkCountry;
|
||||
attribute string JobTitle;
|
||||
attribute string Department;
|
||||
attribute string Company;
|
||||
attribute string WebPage1;
|
||||
attribute string WebPage2;
|
||||
attribute string BirthYear;
|
||||
attribute string BirthMonth;
|
||||
attribute string BirthDay;
|
||||
attribute string Custom1;
|
||||
attribute string Custom2;
|
||||
attribute string Custom3;
|
||||
attribute string Custom4;
|
||||
attribute string Notes;
|
||||
|
||||
attribute string firstName;
|
||||
attribute string lastName;
|
||||
attribute string displayName;
|
||||
attribute string primaryEmail;
|
||||
attribute string secondEmail;
|
||||
attribute string workPhone;
|
||||
attribute string homePhone;
|
||||
attribute string faxNumber;
|
||||
attribute string pagerNumber;
|
||||
attribute string cellularNumber;
|
||||
attribute string workCity;
|
||||
attribute string organization;
|
||||
attribute string nickName;
|
||||
attribute unsigned long dbRowID;
|
||||
attribute boolean SendPlainText;
|
||||
|
||||
|
||||
attribute unsigned long DbTableID;
|
||||
attribute unsigned long DbRowID;
|
||||
|
||||
void GetCardValue(in string attrname, out string value);
|
||||
void SetCardValue(in string attrname, in string value);
|
||||
|
|
|
@ -25,4 +25,6 @@ interface nsIAbDirectory : nsIAbBase {
|
|||
nsIEnumerator GetChildCards();
|
||||
|
||||
nsIAbCard CreateCardFromDirectory();
|
||||
|
||||
void AddChildCards(in string uriName, out nsIAbCard childCard);
|
||||
};
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
|
||||
#include "nsIAddrDBAnnouncer.idl"
|
||||
#include "nsIAbCard.idl"
|
||||
#include "nsIAbDirectory.idl"
|
||||
|
||||
[ref] native nsFileSpec(nsFileSpec);
|
||||
[ptr] native nsFileSpec(nsFileSpec);
|
||||
[ptr] native nsIMdbTableRowCursor(nsIMdbTableRowCursor);
|
||||
[ptr] native nsIMdbEnv(nsIMdbEnv);
|
||||
|
||||
|
@ -32,15 +33,17 @@
|
|||
[scriptable, uuid(A4186D8B-1DD0-11d3-A303-001083003D0C)]
|
||||
interface nsIAddrDatabase : nsIAddrDBAnnouncer {
|
||||
|
||||
attribute nsFileSpec dbPath;
|
||||
|
||||
void Open(in nsFileSpec folderName, in boolean create,
|
||||
out nsIAddrDatabase pMessageDB, in boolean upgrading);
|
||||
void Close(in boolean forceCommit);
|
||||
void OpenMDB(in string dbName, in boolean create);
|
||||
void OpenMDB(in nsFileSpec dbName, in boolean create);
|
||||
void CloseMDB(in boolean commit);
|
||||
|
||||
void Commit(in unsigned long commitType);
|
||||
void ForceClosed();
|
||||
|
||||
void CreateNewCardAndAddToDB(in nsIAbCard newCard, in boolean benotify);
|
||||
void EnumerateCards(out nsIEnumerator result);
|
||||
void EnumerateCards(in nsIAbDirectory directory, out nsIEnumerator result);
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ function OnLoadAddressBook()
|
|||
// Work section
|
||||
cvData.cvhWork = doc.getElementById("cvhWork");
|
||||
cvData.cvJobTitle = doc.getElementById("cvJobTitle");
|
||||
cvData.cvOrganization = doc.getElementById("cvOrganization");
|
||||
cvData.cvCompany = doc.getElementById("cvCompany");
|
||||
cvData.cvWorkAddress = doc.getElementById("cvWorkAddress");
|
||||
cvData.cvWorkCityStZip = doc.getElementById("cvWorkCityStZip");
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ function DisplayCardViewPane(abNode)
|
|||
var cardResource = parent.parent.rdf.GetResource(uri);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
|
||||
var name = card.personName;// FIX ME - this should be displayName
|
||||
var name = card.DisplayName;// FIX ME - this should be displayName
|
||||
|
||||
var data = parent.parent.cvData;
|
||||
var visible;
|
||||
|
@ -66,9 +66,9 @@ function DisplayCardViewPane(abNode)
|
|||
|
||||
/* Name section */
|
||||
cvSetNode(data.cvhName, name);
|
||||
cvSetNode(data.cvNickname, "\"" + card.nickName + "\"");
|
||||
cvSetNode(data.cvEmail1, card.primaryEmail);
|
||||
cvSetNode(data.cvEmail2, card.secondEmail);
|
||||
cvSetNode(data.cvNickname, "\"" + card.NickName + "\"");
|
||||
cvSetNode(data.cvEmail1, card.PrimaryEmail);
|
||||
cvSetNode(data.cvEmail2, card.SecondEmail);
|
||||
/* Home section */
|
||||
visible = cvSetNode(data.cvHomeAddress, "not yet supported");
|
||||
visible = cvSetNode(data.cvHomeCityStZip, "not yet supported") || visible;
|
||||
|
@ -77,15 +77,15 @@ function DisplayCardViewPane(abNode)
|
|||
visible = cvSetNode(data.cvNotes, "not yet supported");
|
||||
cvSetVisible(data.cvhOther, visible);
|
||||
/* Phone section */
|
||||
visible = cvSetPhone(data.cvPhWork, "Work: ", card.workPhone);
|
||||
visible = cvSetPhone(data.cvPhHome, "Home: ", card.homePhone) || visible;
|
||||
visible = cvSetPhone(data.cvPhFax, "Fax: ", card.faxNumber) || visible;
|
||||
visible = cvSetPhone(data.cvPhCellular, "Cellular: ", card.cellularNumber) || visible;
|
||||
visible = cvSetPhone(data.cvPhPager, "Pager: ", card.pagerNumber) || visible;
|
||||
visible = cvSetPhone(data.cvPhWork, "Work: ", card.WorkPhone);
|
||||
visible = cvSetPhone(data.cvPhHome, "Home: ", card.HomePhone) || visible;
|
||||
visible = cvSetPhone(data.cvPhFax, "Fax: ", card.FaxNumber) || visible;
|
||||
visible = cvSetPhone(data.cvPhCellular, "Cellular: ", card.CellularNumber) || visible;
|
||||
visible = cvSetPhone(data.cvPhPager, "Pager: ", card.PagerNumber) || visible;
|
||||
cvSetVisible(data.cvhPhone, visible);
|
||||
/* Work section */
|
||||
visible = cvSetNode(data.cvJobTitle, "not yet supported");
|
||||
visible = cvSetNode(data.cvOrganization, card.organization) || visible;
|
||||
visible = cvSetNode(data.cvCompany, card.Company) || visible;
|
||||
visible = cvSetNode(data.cvWorkAddress, "not yet supported") || visible;
|
||||
visible = cvSetNode(data.cvWorkCityStZip, "not yet supported") || visible;
|
||||
cvSetVisible(data.cvhWork, visible);
|
||||
|
@ -122,7 +122,7 @@ function ClearCardViewPane()
|
|||
// Work section
|
||||
cvSetVisible(data.cvhWork, false);
|
||||
cvSetVisible(data.cvJobTitle, false);
|
||||
cvSetVisible(data.cvOrganization, false);
|
||||
cvSetVisible(data.cvCompany, false);
|
||||
cvSetVisible(data.cvWorkAddress, false);
|
||||
cvSetVisible(data.cvWorkCityStZip, false);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<html:div class="CardViewHeading" id="cvhWork">Work</html:div>
|
||||
<spring class="CardViewHeadingSpace"/>
|
||||
<html:div class="CardViewText" id="cvJobTitle">*</html:div>
|
||||
<html:div class="CardViewText" id="cvOrganization">*</html:div>
|
||||
<html:div class="CardViewText" id="cvComapny">*</html:div>
|
||||
<html:div class="CardViewText" id="cvWorkAddress">*</html:div>
|
||||
<html:div class="CardViewText" id="cvWorkCityStZip">*</html:div>
|
||||
</box>
|
||||
|
|
|
@ -2,25 +2,25 @@ function EditCardOKButton()
|
|||
{
|
||||
dump("OK Hit\n");
|
||||
|
||||
var card = Components.classes["component://netscape/rdf/resource-factory?name=abcard"].createInstance();
|
||||
card = card.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
dump("card = " + card + "\n");
|
||||
var cardproperty = Components.classes["component://netscape/addressbook/cardproperty"].createInstance();
|
||||
cardproperty = cardproperty.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
dump("cardproperty = " + cardproperty + "\n");
|
||||
|
||||
if (card)
|
||||
if (cardproperty)
|
||||
{
|
||||
card.SetCardValue('firstname', document.getElementById('firstname').value);
|
||||
card.SetCardValue('lastname', document.getElementById('lastname').value);
|
||||
card.SetCardValue('displayname', document.getElementById('displayname').value);
|
||||
card.SetCardValue('nickname', document.getElementById('nickname').value);
|
||||
card.SetCardValue('primaryemail', document.getElementById('primaryemail').value);
|
||||
card.SetCardValue('secondemail', document.getElementById('secondemail').value);
|
||||
card.SetCardValue('workphone', document.getElementById('workphone').value);
|
||||
card.SetCardValue('homephone', document.getElementById('homephone').value);
|
||||
card.SetCardValue('faxnumber', document.getElementById('faxnumber').value);
|
||||
card.SetCardValue('pagernumber', document.getElementById('pagernumber').value);
|
||||
card.SetCardValue('cellularnumber', document.getElementById('cellularnumber').value);
|
||||
cardproperty.SetCardValue('FirstName', document.getElementById('FirstName').value);
|
||||
cardproperty.SetCardValue('LastName', document.getElementById('LastName').value);
|
||||
cardproperty.SetCardValue('DisplayName', document.getElementById('DisplayName').value);
|
||||
cardproperty.SetCardValue('NickName', document.getElementById('NickName').value);
|
||||
cardproperty.SetCardValue('PrimaryEmail', document.getElementById('PrimaryEmail').value);
|
||||
cardproperty.SetCardValue('SecondEmail', document.getElementById('SecondEmail').value);
|
||||
cardproperty.SetCardValue('WorkPhone', document.getElementById('WorkPhone').value);
|
||||
cardproperty.SetCardValue('HomePhone', document.getElementById('HomePhone').value);
|
||||
cardproperty.SetCardValue('FaxNumber', document.getElementById('FaxNumber').value);
|
||||
cardproperty.SetCardValue('PagerNumber', document.getElementById('PagerNumber').value);
|
||||
cardproperty.SetCardValue('CellularNumber', document.getElementById('CellularNumber').value);
|
||||
|
||||
card.AddCardToDatabase();
|
||||
cardproperty.AddCardToDatabase();
|
||||
}
|
||||
top.window.close();
|
||||
}
|
||||
|
|
|
@ -83,23 +83,23 @@
|
|||
<box align="vertical" style="width:100%">
|
||||
<box align="horizontal" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="firstname">&firstname.label;</html:label>
|
||||
<html:input type="text" id="firstname" class="CardEdit"/>
|
||||
<html:label for="FirstName">&firstname.label;</html:label>
|
||||
<html:input type="text" id="FirstName" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="lastname">&lastname.label;</html:label>
|
||||
<html:input id="lastname" type="text" class="CardEdit"/>
|
||||
<html:label for="LastName">&lastname.label;</html:label>
|
||||
<html:input id="LastName" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="displayname">&displayname.label;</html:label>
|
||||
<html:input id="displayname" type="text" class="CardEdit"/>
|
||||
<html:label for="DisplayName">&displayname.label;</html:label>
|
||||
<html:input id="DisplayName" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="nickname">&nickname.label;</html:label>
|
||||
<html:input id="nickname" type="text" class="CardEdit"/>
|
||||
<html:label for="NickName">&nickname.label;</html:label>
|
||||
<html:input id="NickName" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
@ -112,13 +112,13 @@
|
|||
<box align="vertical" style="width:100%">
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="primaryemail">&primaryemail.label;</html:label>
|
||||
<html:input id="primaryemail" type="text" class="CardEdit"/>
|
||||
<html:label for="PrimaryEmail">&primaryemail.label;</html:label>
|
||||
<html:input id="PrimaryEmail" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="secondemail">&secondemail.label;</html:label>
|
||||
<html:input id="secondemail" type="text" class="CardEdit"/>
|
||||
<html:label for="SecondEmail">&secondemail.label;</html:label>
|
||||
<html:input id="SecondEmail" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
|
@ -135,28 +135,28 @@
|
|||
<box align="vertical" style="width:100%">
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workphone">&workphone.label;</html:label>
|
||||
<html:input id="workphone" type="text" class="CardEdit"/>
|
||||
<html:label for="WorkPhone">&workphone.label;</html:label>
|
||||
<html:input id="WorkPhone" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homephone">&homephone.label;</html:label>
|
||||
<html:input id="homephone" type="text" class="CardEdit"/>
|
||||
<html:label for="HomePhone">&homephone.label;</html:label>
|
||||
<html:input id="HomePhone" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="faxnumber">&faxnumber.label;</html:label>
|
||||
<html:input id="faxnumber" type="text" class="CardEdit"/>
|
||||
<html:label for="FaxNumber">&faxnumber.label;</html:label>
|
||||
<html:input id="FaxNumber" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="pagernumber">&pagernumber.label;</html:label>
|
||||
<html:input id="pagernumber" type="text" class="CardEdit"/>
|
||||
<html:label for="PagerNumber">&pagernumber.label;</html:label>
|
||||
<html:input id="PagerNumber" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="cellularnumber">&cellularnumber.label;</html:label>
|
||||
<html:input id="cellularnumber" type="text" class="CardEdit"/>
|
||||
<html:label for="CellularNumber">&cellularnumber.label;</html:label>
|
||||
<html:input id="CellularNumber" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
@ -174,31 +174,31 @@
|
|||
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homeaddress">&homeaddress.label;</html:label>
|
||||
<html:input type="text" id="homeaddress" class="CardEdit"/>
|
||||
<html:label for="HomeAddress">&homeaddress.label;</html:label>
|
||||
<html:input type="text" id="HomeAddress" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homeaddress2">&homeaddress2.label;</html:label>
|
||||
<html:input type="text" id="homeaddress2" class="CardEdit"/>
|
||||
<html:label for="HomeAddress2">&homeaddress2.label;</html:label>
|
||||
<html:input type="text" id="HomeAddress2" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homecity">&homecity.label;</html:label>
|
||||
<html:input id="homecity" type="text" class="CardEdit"/>
|
||||
<html:label for="HomeCity">&homecity.label;</html:label>
|
||||
<html:input id="HomeCity" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homestate">&homestate.label;</html:label>
|
||||
<html:input id="homestate" type="text" class="CardEdit" style="min-width:1em; width:4em"/>
|
||||
<html:label for="HomeState">&homestate.label;</html:label>
|
||||
<html:input id="HomeState" type="text" class="CardEdit" style="min-width:1em; width:4em"/>
|
||||
<spring style="width:1.5em"/>
|
||||
<html:label for="homezipcode">&homezipcode.label;</html:label>
|
||||
<html:input id="homezipcode" type="text" class="CardEdit" style="min-width:1em; width:3em"/>
|
||||
<html:label for="HomeZipCode">&homezipcode.label;</html:label>
|
||||
<html:input id="HomeZipCode" type="text" class="CardEdit" style="min-width:1em; width:3em"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="homecountry">&homecountry.label;</html:label>
|
||||
<html:input id="homecountry" type="text" class="CardEdit"/>
|
||||
<html:label for="HomeCountry">&homecountry.label;</html:label>
|
||||
<html:input id="HomeCountry" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
@ -212,31 +212,31 @@
|
|||
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workaddress">&workaddress.label;</html:label>
|
||||
<html:input type="text" id="workaddress" class="CardEdit"/>
|
||||
<html:label for="WorkAddress">&workaddress.label;</html:label>
|
||||
<html:input type="text" id="WorkAddress" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workaddress2">&workaddress2.label;</html:label>
|
||||
<html:input type="text" id="workaddress2" class="CardEdit"/>
|
||||
<html:label for="WorkAddress2">&workaddress2.label;</html:label>
|
||||
<html:input type="text" id="WorkAddress2" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workcity">&workcity.label;</html:label>
|
||||
<html:input id="workcity" type="text" class="CardEdit"/>
|
||||
<html:label for="WorkCity">&workcity.label;</html:label>
|
||||
<html:input id="WorkCity" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workstate">&workstate.label;</html:label>
|
||||
<html:input id="workstate" type="text" class="CardEdit" style="min-width:1em; width:4em"/>
|
||||
<html:label for="WorkState">&workstate.label;</html:label>
|
||||
<html:input id="WorkState" type="text" class="CardEdit" style="min-width:1em; width:4em"/>
|
||||
<spring style="width:1.5em"/>
|
||||
<html:label for="workzipcode">&workzipcode.label;</html:label>
|
||||
<html:input id="workzipcode" type="text" class="CardEdit" style="min-width:1em; width:3em"/>
|
||||
<html:label for="WorkZipCode">&workzipcode.label;</html:label>
|
||||
<html:input id="WorkZipCode" type="text" class="CardEdit" style="min-width:1em; width:3em"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="workcountry">&workcountry.label;</html:label>
|
||||
<html:input id="workcountry" type="text" class="CardEdit"/>
|
||||
<html:label for="WorkCountry">&workcountry.label;</html:label>
|
||||
<html:input id="WorkCountry" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
@ -250,13 +250,13 @@
|
|||
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="webpage1">&webpage1.label;</html:label>
|
||||
<html:input type="text" id="webpage1" class="CardEdit"/>
|
||||
<html:label for="WebPage1">&webpage1.label;</html:label>
|
||||
<html:input type="text" id="WebPage1" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="webpage2">&webpage2.label;</html:label>
|
||||
<html:input type="text" id="webpage2" class="CardEdit"/>
|
||||
<html:label for="WebPage2">&webpage2.label;</html:label>
|
||||
<html:input type="text" id="WebPage2" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
@ -268,23 +268,23 @@
|
|||
<box align="vertical" style="width:100%">
|
||||
<box align="horizontal" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="custom1">&custom1.label;</html:label>
|
||||
<html:input type="text" id="custom1" class="CardEdit"/>
|
||||
<html:label for="Custom1">&custom1.label;</html:label>
|
||||
<html:input type="text" id="Custom1" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="custom2">&custom2.label;</html:label>
|
||||
<html:input type="text" id="custom2" class="CardEdit"/>
|
||||
<html:label for="Custom2">&custom2.label;</html:label>
|
||||
<html:input type="text" id="Custom2" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="custom3">&custom3.label;</html:label>
|
||||
<html:input type="text" id="custom3" class="CardEdit"/>
|
||||
<html:label for="Custom3">&custom3.label;</html:label>
|
||||
<html:input type="text" id="Custom3" class="CardEdit"/>
|
||||
</box>
|
||||
<box align="horizontal" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:label for="custom4">&custom4.label;</html:label>
|
||||
<html:input type="text" id="custom4" class="CardEdit"/>
|
||||
<html:label for="Custom4">&custom4.label;</html:label>
|
||||
<html:input type="text" id="Custom4" class="CardEdit"/>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
|
@ -294,7 +294,7 @@
|
|||
</html:legend>
|
||||
|
||||
<box align="vertical" style="width:100%">
|
||||
<html:input id="notes" type="text" class="CardEdit"/>
|
||||
<html:input id="Notes" type="text" class="CardEdit"/>
|
||||
</box>
|
||||
</html:fieldset>
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
<!ENTITY nameColumn.label "Name">
|
||||
<!ENTITY emailColumn.label "Email">
|
||||
<!ENTITY phoneColumn.label "Phone#">
|
||||
<!ENTITY orgColumn.label "Organization">
|
||||
<!ENTITY nicknameColumn.label "Nickname">
|
||||
<!ENTITY cityColumn.label "City">
|
||||
]>
|
||||
|
||||
<window xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
|
@ -28,44 +25,29 @@
|
|||
<treerow >
|
||||
<treecell>
|
||||
<treeindentation />
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#PersonName" align="right" />
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#DisplayName" align="right" />
|
||||
</treecell>
|
||||
<treecell>
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Email" align="right" style="list-style-image: none;" />
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#PrimaryEmail" align="right" style="list-style-image: none;" />
|
||||
</treecell>
|
||||
<treecell>
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#WorkPhone" align="right" style="list-style-image: none;" />
|
||||
</treecell>
|
||||
<treecell>
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Organization" align="right" style="list-style-image: none;" />
|
||||
</treecell>
|
||||
<treecell>
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Nickname" align="right" style="list-style-image: none;" />
|
||||
</treecell>
|
||||
<treecell>
|
||||
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#City" align="right" style="list-style-image: none;" />
|
||||
</treecell>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
|
||||
<treecol style="width:13%" id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#PersonName"/>
|
||||
<treecol style="width:21%" id="EmailColumn" rdf:resource="http://home.netscape.com/NC-rdf#Email"/>
|
||||
<treecol style="width:13%" id="WorkPhoneColumn" rdf:resource="http://home.netscape.com/NC-rdf#WorkPhone"/>
|
||||
<treecol style="width:20%" id="OrganizationColumn" rdf:resource="http://home.netscape.com/NC-rdf#Organization"/>
|
||||
<treecol style="width:13%" id="NicknameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Nickname"/>
|
||||
<treecol style="width:20%" id="CityColumn" rdf:resource="http://home.netscape.com/NC-rdf#City"/>
|
||||
<treecol style="width:20%" id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#DisplayName"/>
|
||||
<treecol style="width:21%" id="EmailColumn" rdf:resource="http://home.netscape.com/NC-rdf#PrimaryEmail"/>
|
||||
<treecol style="width:20%" id="WorkPhoneColumn" rdf:resource="http://home.netscape.com/NC-rdf#WorkPhone"/>
|
||||
|
||||
<treehead>
|
||||
<treerow>
|
||||
<treecell>&nameColumn.label;</treecell>
|
||||
<treecell>&emailColumn.label;</treecell>
|
||||
<treecell>&phoneColumn.label;</treecell>
|
||||
<treecell>&orgColumn.label;</treecell>
|
||||
<treecell>&nicknameColumn.label;</treecell>
|
||||
<treecell>&cityColumn.label;</treecell>
|
||||
</treerow>
|
||||
</treehead>
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ function AddSelectedAddressesIntoBucket(prefix)
|
|||
uri = selArray[item].getAttribute('id');
|
||||
cardResource = rdf.GetResource(uri);
|
||||
card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
address = prefix + "\"" + card.personName + "\" <" + card.email + ">";
|
||||
address = prefix + "\"" + card.DisplayName + "\" <" + card.PrimaryEmail + ">";
|
||||
AddAddressIntoBucket(bucketDoc, address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ EXPORTS = \
|
|||
nsDirectoryDataSource.h \
|
||||
nsDirPrefs.h \
|
||||
nsAddrDatabase.h\
|
||||
nsAddressBook.h\
|
||||
nsAbCardProperty.h\
|
||||
nsAbRDFResource.h\
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -41,6 +44,9 @@ CPPSRCS = \
|
|||
nsAbCard.cpp \
|
||||
nsDirPrefs.cpp \
|
||||
nsAddrDatabase.cpp\
|
||||
nsAddressBook.cpp\
|
||||
nsAbCardProperty.cpp\
|
||||
nsAbRDFResource.cpp\
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -30,6 +30,9 @@ EXPORTS= \
|
|||
nsAbCard.h \
|
||||
nsDirPrefs.h \
|
||||
nsAddrDatabase.h \
|
||||
nsAddressBook.h \
|
||||
nsAbCardProperty.h \
|
||||
nsAbRDFResource.h \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
@ -44,6 +47,9 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsAbCard.obj \
|
||||
.\$(OBJDIR)\nsDirPrefs.obj \
|
||||
.\$(OBJDIR)\nsAddrDatabase.obj \
|
||||
.\$(OBJDIR)\nsAddressBook.obj \
|
||||
.\$(OBJDIR)\nsAbCardProperty.obj \
|
||||
.\$(OBJDIR)\nsAbRDFResource.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "msgCore.h" // precompiled header...
|
||||
|
||||
#include "nsAbCard.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -28,6 +26,8 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAbBaseCID.h"
|
||||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDB, NS_ADDRESSBOOKDB_CID);
|
||||
|
@ -60,18 +60,6 @@ nsABCard::nsABCard(void)
|
|||
}
|
||||
}*/
|
||||
|
||||
m_pFirstName = nsnull;
|
||||
m_pLastName = nsnull;
|
||||
m_pDisplayName = nsnull;
|
||||
m_pPrimaryEmail = nsnull;
|
||||
m_pSecondEmail = nsnull;
|
||||
m_pWorkPhone = nsnull;
|
||||
m_pHomePhone = nsnull;
|
||||
m_pFaxNumber = nsnull;
|
||||
m_pPagerNumber = nsnull;
|
||||
m_pCellularNumber = nsnull;
|
||||
|
||||
m_dbRowID = -1;
|
||||
}
|
||||
|
||||
nsABCard::~nsABCard(void)
|
||||
|
@ -96,17 +84,6 @@ nsABCard::~nsABCard(void)
|
|||
mListeners->RemoveElementAt(i);
|
||||
delete mListeners;
|
||||
}
|
||||
|
||||
PR_FREEIF(m_pFirstName);
|
||||
PR_FREEIF(m_pLastName);
|
||||
PR_FREEIF(m_pDisplayName);
|
||||
PR_FREEIF(m_pPrimaryEmail);
|
||||
PR_FREEIF(m_pSecondEmail);
|
||||
PR_FREEIF(m_pWorkPhone);
|
||||
PR_FREEIF(m_pHomePhone);
|
||||
PR_FREEIF(m_pFaxNumber);
|
||||
PR_FREEIF(m_pPagerNumber);
|
||||
PR_FREEIF(m_pCellularNumber);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsABCard, nsRDFResource, nsIAbCard)
|
||||
|
@ -142,7 +119,7 @@ nsFilterBy(nsISupportsArray* array, nsArrayFilter filter, void* data,
|
|||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP nsABCard::OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -158,55 +135,7 @@ NS_IMETHODIMP nsABCard::OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator)
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsABCard::AddUnique(nsISupports* element)
|
||||
{
|
||||
// XXX fix this
|
||||
return mSubDirectories->AppendElement(element);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsABCard::ReplaceElement(nsISupports* element, nsISupports* newElement)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsABCard::GetChildNodes(nsIEnumerator* *result)
|
||||
{
|
||||
if (!mInitialized)
|
||||
{
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1") ||
|
||||
!PL_strcmp(mURI, "abcard://Pab1/Card2") ||
|
||||
!PL_strcmp(mURI, "abcard://Pab2/Card1") ||
|
||||
!PL_strcmp(mURI, "abcard://Pab2/Card2") ||
|
||||
!PL_strcmp(mURI, "abcard://Pab3/Card1") ||
|
||||
!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i= 0; i < 6; i++)
|
||||
{
|
||||
nsCOMPtr<nsIAbCard> card;
|
||||
if (i == 0)
|
||||
AddSubNode("PersonName", getter_AddRefs(card));
|
||||
if (i == 1)
|
||||
AddSubNode("Email", getter_AddRefs(card));
|
||||
if (i == 2)
|
||||
AddSubNode("WorkPhone", getter_AddRefs(card));
|
||||
if (i == 3)
|
||||
AddSubNode("Organization", getter_AddRefs(card));
|
||||
if (i == 4)
|
||||
AddSubNode("Nickname", getter_AddRefs(card));
|
||||
if (i == 5)
|
||||
AddSubNode("City", getter_AddRefs(card));
|
||||
}
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
}
|
||||
return mSubDirectories->Enumerate(result);
|
||||
}
|
||||
*/
|
||||
|
||||
nsresult nsABCard::AddSubNode(nsAutoString name, nsIAbCard **childCard)
|
||||
{
|
||||
|
@ -239,517 +168,13 @@ nsresult nsABCard::AddSubNode(nsAutoString name, nsIAbCard **childCard)
|
|||
|
||||
mSubDirectories->AppendElement(card);
|
||||
*childCard = card;
|
||||
NS_ADDREF(*childCard);
|
||||
NS_IF_ADDREF(*childCard);
|
||||
|
||||
(void)nsServiceManager::ReleaseService(kRDFServiceCID, rdf);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::AddAddrBookListener(nsIAbListener * listener)
|
||||
{
|
||||
if (! mListeners)
|
||||
{
|
||||
mListeners = new nsVoidArray();
|
||||
if(!mListeners)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mListeners->AppendElement(listener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::RemoveAddrBookListener(nsIAbListener * listener)
|
||||
{
|
||||
if (! mListeners)
|
||||
return NS_OK;
|
||||
mListeners->RemoveElement(listener);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetPersonName(char **name)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("John");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("Mary");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("Lisa");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("Frank");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("Teri");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("Ted");
|
||||
*name = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetListName(char **listname)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("John");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("Mary");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("Lisa");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("Frank");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("Teri");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("Ted");
|
||||
*listname = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetEmail(char **email)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("john@foo.com");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("mary@foo.com");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("lisa@foo.com");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("frank@foo.com");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("teri@foo.com");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("ted@foo.com");
|
||||
*email = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetCity(char **city)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("Mountian View");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("San Francisco");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("San Jose");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("San Jose");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("Sunnyvale");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("Sunnyvale");
|
||||
*city = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetFirstName(char * *aFirstName)
|
||||
{
|
||||
if (aFirstName && m_pFirstName)
|
||||
*aFirstName = PL_strdup(m_pFirstName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetLastName(char * *aLastName)
|
||||
{
|
||||
if (aLastName && m_pLastName)
|
||||
*aLastName = PL_strdup(m_pLastName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetDisplayName(char * *aDisplayName)
|
||||
{
|
||||
if (aDisplayName && m_pDisplayName)
|
||||
*aDisplayName = PL_strdup(m_pDisplayName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetPrimaryEmail(char * *aPrimaryEmail)
|
||||
{
|
||||
if (aPrimaryEmail && m_pPrimaryEmail)
|
||||
*aPrimaryEmail = PL_strdup(m_pPrimaryEmail);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsABCard::GetSecondEmail(char * *aSecondEmail)
|
||||
{
|
||||
if (aSecondEmail && m_pSecondEmail)
|
||||
*aSecondEmail = PL_strdup(m_pSecondEmail);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetWorkPhone(char * *aWorkPhone)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("1111");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("6666");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("2222");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("4444");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("7777");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("3333");
|
||||
*aWorkPhone = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
|
||||
if (aWorkPhone && m_pWorkPhone)
|
||||
*aWorkPhone = PL_strdup(m_pWorkPhone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetHomePhone(char * *aHomePhone)
|
||||
{
|
||||
if (aHomePhone && m_pHomePhone)
|
||||
*aHomePhone = PL_strdup(m_pHomePhone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetFaxNumber(char * *aFaxNumber)
|
||||
{
|
||||
if (aFaxNumber && m_pFaxNumber)
|
||||
*aFaxNumber = PL_strdup(m_pFaxNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetPagerNumber(char * *aPagerNumber)
|
||||
{
|
||||
if (aPagerNumber && m_pPagerNumber)
|
||||
*aPagerNumber = PL_strdup(m_pPagerNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetCellularNumber(char * *aCellularNumber)
|
||||
{
|
||||
if (aCellularNumber && m_pCellularNumber)
|
||||
*aCellularNumber = PL_strdup(m_pCellularNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetWorkCity(char * *aWorkCity)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetOrganization(char * *aOrganization)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("Market");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("Sales");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("Engineer");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("Finance");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("Human Resource");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("Payroll");
|
||||
*aOrganization = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetNickName(char * *aNickName)
|
||||
{
|
||||
nsString tempName;
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card1"))
|
||||
tempName.Append("John");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab1/Card2"))
|
||||
tempName.Append("Mary");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card1"))
|
||||
tempName.Append("Lisa");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab2/Card2"))
|
||||
tempName.Append("Frank");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card1"))
|
||||
tempName.Append("Teri");
|
||||
if (!PL_strcmp(mURI, "abcard://Pab3/Card2"))
|
||||
tempName.Append("Ted");
|
||||
*aNickName = tempName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetPersonName(char * aPersonName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetListName(char * aListName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetEmail(char * aEmail)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetCity(char * aCity)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetFirstName(char * aFirstName)
|
||||
{
|
||||
if (aFirstName)
|
||||
{
|
||||
PR_FREEIF(m_pFirstName);
|
||||
m_pFirstName = PL_strdup(aFirstName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetLastName(char * aLastName)
|
||||
{
|
||||
if (aLastName)
|
||||
{
|
||||
PR_FREEIF(m_pLastName);
|
||||
m_pLastName = PL_strdup(aLastName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetDisplayName(char * aDisplayName)
|
||||
{
|
||||
if (aDisplayName)
|
||||
{
|
||||
PR_FREEIF(m_pDisplayName);
|
||||
m_pDisplayName = PL_strdup(aDisplayName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetPrimaryEmail(char * aPrimaryEmail)
|
||||
{
|
||||
if (aPrimaryEmail)
|
||||
{
|
||||
PR_FREEIF(m_pPrimaryEmail);
|
||||
m_pPrimaryEmail = PL_strdup(aPrimaryEmail);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetSecondEmail(char * aSecondEmail)
|
||||
{
|
||||
if (aSecondEmail)
|
||||
{
|
||||
PR_FREEIF(m_pSecondEmail);
|
||||
m_pSecondEmail = PL_strdup(aSecondEmail);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetWorkPhone(char * aWorkPhone)
|
||||
{
|
||||
if (aWorkPhone)
|
||||
{
|
||||
PR_FREEIF(m_pWorkPhone);
|
||||
m_pWorkPhone = PL_strdup(aWorkPhone);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetHomePhone(char * aHomePhone)
|
||||
{
|
||||
if (aHomePhone)
|
||||
{
|
||||
PR_FREEIF(m_pHomePhone);
|
||||
m_pHomePhone = PL_strdup(aHomePhone);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetFaxNumber(char * aFaxNumber)
|
||||
{
|
||||
if (aFaxNumber)
|
||||
{
|
||||
PR_FREEIF(m_pFaxNumber);
|
||||
m_pFaxNumber = PL_strdup(aFaxNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetPagerNumber(char * aPagerNumber)
|
||||
{
|
||||
if (aPagerNumber)
|
||||
{
|
||||
PR_FREEIF(m_pPagerNumber);
|
||||
m_pPagerNumber = PL_strdup(aPagerNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetCellularNumber(char * aCellularNumber)
|
||||
{
|
||||
if (aCellularNumber)
|
||||
{
|
||||
PR_FREEIF(m_pCellularNumber);
|
||||
m_pCellularNumber = PL_strdup(aCellularNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetWorkCity(char * aWorkCity)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetOrganization(char * aOrganization)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetNickName(char * aNickName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetDbRowID(PRUint32 *aDbRowID)
|
||||
{
|
||||
*aDbRowID = m_dbRowID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetDbRowID(PRUint32 aDbRowID)
|
||||
{
|
||||
m_dbRowID = aDbRowID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetCardValue(const char *attrname, char **value)
|
||||
{
|
||||
if (!PL_strcmp(attrname, "firstname"))
|
||||
GetFirstName(value);
|
||||
else if (!PL_strcmp(attrname, "lastname"))
|
||||
GetLastName(value);
|
||||
else if (!PL_strcmp(attrname, "displayname"))
|
||||
GetDisplayName(value);
|
||||
else if (!PL_strcmp(attrname, "nickname"))
|
||||
GetNickName(value);
|
||||
else if (!PL_strcmp(attrname, "primaryemail"))
|
||||
GetPrimaryEmail(value);
|
||||
else if (!PL_strcmp(attrname, "secondemail"))
|
||||
GetSecondEmail(value);
|
||||
else if (!PL_strcmp(attrname, "workphone"))
|
||||
GetWorkPhone(value);
|
||||
else if (!PL_strcmp(attrname, "homephone"))
|
||||
GetHomePhone(value);
|
||||
else if (!PL_strcmp(attrname, "faxnumber"))
|
||||
GetFaxNumber(value);
|
||||
else if (!PL_strcmp(attrname, "pagernumber"))
|
||||
GetPagerNumber(value);
|
||||
else if (!PL_strcmp(attrname, "cellularnumber"))
|
||||
GetCellularNumber(value);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetCardValue(const char *attrname, const char *value)
|
||||
{
|
||||
nsAutoString cardValue(value);
|
||||
char* valueStr = cardValue.ToNewCString();
|
||||
if (!PL_strcmp(attrname, "firstname"))
|
||||
SetFirstName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "lastname"))
|
||||
SetLastName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "displayname"))
|
||||
SetDisplayName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "nickname"))
|
||||
SetNickName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "primaryemail"))
|
||||
SetPrimaryEmail(valueStr);
|
||||
else if (!PL_strcmp(attrname, "secondemail"))
|
||||
SetSecondEmail(valueStr);
|
||||
else if (!PL_strcmp(attrname, "workphone"))
|
||||
SetWorkPhone(valueStr);
|
||||
else if (!PL_strcmp(attrname, "homephone"))
|
||||
SetHomePhone(valueStr);
|
||||
else if (!PL_strcmp(attrname, "faxnumber"))
|
||||
SetFaxNumber(valueStr);
|
||||
else if (!PL_strcmp(attrname, "pagernumber"))
|
||||
SetPagerNumber(valueStr);
|
||||
else if (!PL_strcmp(attrname, "cellularnumber"))
|
||||
SetCellularNumber(valueStr);
|
||||
|
||||
delete[] valueStr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::AddCardToDatabase()
|
||||
{
|
||||
// find out which database, which directory to add
|
||||
// get RDF directory selected node
|
||||
|
||||
nsresult openAddrDB = NS_OK;
|
||||
if (!mDatabase)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIFileSpec* userdir;
|
||||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_UserProfileDirectory50, &userdir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsServiceManager::ReleaseService(kFileLocatorCID, locator);
|
||||
|
||||
nsFileSpec dbPath;
|
||||
userdir->GetFileSpec(&dbPath);
|
||||
dbPath += "abook.mab";
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory;
|
||||
rv = nsComponentManager::CreateInstance(kAddressBookDB, nsnull, nsCOMTypeInfo<nsIAddrDatabase>::GetIID(),
|
||||
(void **) getter_AddRefs(addrDBFactory));
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
openAddrDB = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
|
||||
|
||||
if (mDatabase)
|
||||
{
|
||||
mDatabase->AddListener(this);
|
||||
mDatabase->CreateNewCardAndAddToDB(this, PR_TRUE);
|
||||
mDatabase->Close(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetName(char **name)
|
||||
{
|
||||
SetName("Personal Address Book");
|
||||
*name = mCardName.ToNewCString();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetName(char * name)
|
||||
{
|
||||
mCardName = name;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetParent(nsIAbBase* *parent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::SetParent(nsIAbBase *parent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::GetChildNamed(const char* name, nsISupports* *result)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsABCard::ContainsChildNamed(const char *name, PRBool* containsChild)
|
||||
{
|
||||
nsCOMPtr<nsISupports> child;
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
#ifndef nsABCard_h__
|
||||
#define nsABCard_h__
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "nsIAbCard.h" /* include the interface we are going to support */
|
||||
#include "nsIAbBase.h"
|
||||
#include "nsAbCardProperty.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAddrDBListener.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
|
@ -37,7 +38,7 @@
|
|||
* Address Book Directory
|
||||
*/
|
||||
|
||||
class nsABCard: public nsRDFResource, public nsIAbCard, public nsIAddrDBListener
|
||||
class nsABCard: public nsRDFResource, public nsAbCardProperty
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
virtual ~nsABCard(void);
|
||||
|
||||
// nsICollection methods:
|
||||
|
||||
NS_IMETHOD Count(PRUint32 *result) {
|
||||
return mSubDirectories->Count(result);
|
||||
}
|
||||
|
@ -69,7 +71,8 @@ public:
|
|||
return mSubDirectories->Clear();
|
||||
}
|
||||
|
||||
// nsIFolder methods:
|
||||
// nsIAbBase methods:
|
||||
/*
|
||||
NS_IMETHOD GetURI(char* *name) { return nsRDFResource::GetValue(name); }
|
||||
NS_IMETHOD GetName(char **name);
|
||||
NS_IMETHOD SetName(char *name);
|
||||
|
@ -79,59 +82,15 @@ public:
|
|||
NS_IMETHOD GetChildNodes(nsIEnumerator* *result);
|
||||
NS_IMETHOD AddAddrBookListener(nsIAbListener * listener);
|
||||
NS_IMETHOD RemoveAddrBookListener(nsIAbListener * listener);
|
||||
NS_IMETHOD AddUnique(nsISupports* element);
|
||||
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
|
||||
|
||||
|
||||
// nsIAddrDBListener methods:
|
||||
NS_IMETHOD OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD OnCardEntryChange(PRUint32 abCode, PRUint32 entryID, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator);
|
||||
|
||||
// nsIAbCard methods:
|
||||
NS_IMETHOD AddUnique(nsISupports* element);
|
||||
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
|
||||
NS_IMETHOD GetPersonName(char * *personName);
|
||||
NS_IMETHOD SetPersonName(char * personName);
|
||||
NS_IMETHOD GetListName(char * *listName);
|
||||
NS_IMETHOD SetListName(char * listName);
|
||||
NS_IMETHOD GetEmail(char * *email);
|
||||
NS_IMETHOD SetEmail(char * email);
|
||||
NS_IMETHOD GetCity(char * *city);
|
||||
NS_IMETHOD SetCity(char * city);
|
||||
|
||||
NS_IMETHOD GetFirstName(char * *aFirstName);
|
||||
NS_IMETHOD SetFirstName(char * aFirstName);
|
||||
NS_IMETHOD GetLastName(char * *aLastName);
|
||||
NS_IMETHOD SetLastName(char * aLastName);
|
||||
NS_IMETHOD GetDisplayName(char * *aDisplayName);
|
||||
NS_IMETHOD SetDisplayName(char * aDisplayName);
|
||||
NS_IMETHOD GetPrimaryEmail(char * *aPrimaryEmail);
|
||||
NS_IMETHOD SetPrimaryEmail(char * aPrimaryEmail);
|
||||
NS_IMETHOD GetSecondEmail(char * *aSecondEmail);
|
||||
NS_IMETHOD SetSecondEmail(char * aSecondEmail);
|
||||
NS_IMETHOD GetWorkPhone(char * *aWorkPhone);
|
||||
NS_IMETHOD SetWorkPhone(char * aWorkPhone);
|
||||
NS_IMETHOD GetHomePhone(char * *aHomePhone);
|
||||
NS_IMETHOD SetHomePhone(char * aHomePhone);
|
||||
NS_IMETHOD GetFaxNumber(char * *aFaxNumber);
|
||||
NS_IMETHOD SetFaxNumber(char * aFaxNumber);
|
||||
NS_IMETHOD GetPagerNumber(char * *aPagerNumber);
|
||||
NS_IMETHOD SetPagerNumber(char * aPagerNumber);
|
||||
NS_IMETHOD GetCellularNumber(char * *aCellularNumber);
|
||||
NS_IMETHOD SetCellularNumber(char * aCellularNumber);
|
||||
NS_IMETHOD GetWorkCity(char * *aWorkCity);
|
||||
NS_IMETHOD SetWorkCity(char * aWorkCity);
|
||||
NS_IMETHOD GetOrganization(char * *aOrganization);
|
||||
NS_IMETHOD SetOrganization(char * aOrganization);
|
||||
NS_IMETHOD GetNickName(char * *aNickName);
|
||||
NS_IMETHOD SetNickName(char * aNickName);
|
||||
|
||||
NS_IMETHOD GetDbRowID(PRUint32 *aDbRowID);
|
||||
NS_IMETHOD SetDbRowID(PRUint32 aDbRowID);
|
||||
|
||||
NS_IMETHOD GetCardValue(const char *attrname, char **value);
|
||||
NS_IMETHOD SetCardValue(const char *attrname, const char *value);
|
||||
NS_IMETHOD AddCardToDatabase();
|
||||
|
||||
*/
|
||||
|
||||
// NS_IMETHOD GetPrettiestName(char ** name);
|
||||
|
||||
|
@ -170,21 +129,6 @@ protected:
|
|||
PRInt16 mCsid; // default csid for folder/newsgroup - maintained by fe.
|
||||
PRUint8 mDepth;
|
||||
PRInt32 mPrefFlags; // prefs like MSG_PREF_OFFLINE, MSG_PREF_ONE_PANE, etc
|
||||
|
||||
char* m_pFirstName;
|
||||
char* m_pLastName;
|
||||
char* m_pDisplayName;
|
||||
char* m_pPrimaryEmail;
|
||||
char* m_pSecondEmail;
|
||||
char* m_pWorkPhone;
|
||||
char* m_pHomePhone;
|
||||
char* m_pFaxNumber;
|
||||
char* m_pPagerNumber;
|
||||
char* m_pCellularNumber;
|
||||
|
||||
PRUint32 m_dbRowID;
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> mDatabase;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,20 +27,63 @@
|
|||
#include "nsAbBaseCID.h"
|
||||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
|
||||
#include "nsAddrDatabase.h"
|
||||
|
||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
||||
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
|
||||
// that multiply inherits from nsISupports
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kAddressBookDB, NS_ADDRESSBOOKDB_CID);
|
||||
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
/* The definition is nsAddrDatabase.cpp */
|
||||
extern const char *kFirstNameColumn;
|
||||
extern const char *kLastNameColumn;
|
||||
extern const char *kDisplayNameColumn;
|
||||
extern const char *kNicknameColumn;
|
||||
extern const char *kPriEmailColumn;
|
||||
extern const char *k2ndEmailColumn;
|
||||
extern const char *kPlainTextColumn;
|
||||
extern const char *kWorkPhoneColumn;
|
||||
extern const char *kHomePhoneColumn;
|
||||
extern const char *kFaxColumn;
|
||||
extern const char *kPagerColumn;
|
||||
extern const char *kCellularColumn;
|
||||
extern const char *kHomeAddressColumn;
|
||||
extern const char *kHomeAddress2Column;
|
||||
extern const char *kHomeCityColumn;
|
||||
extern const char *kHomeStateColumn;
|
||||
extern const char *kHomeZipCodeColumn;
|
||||
extern const char *kHomeCountryColumn;
|
||||
extern const char *kWorkAddressColumn;
|
||||
extern const char *kWorkAddress2Column;
|
||||
extern const char *kWorkCityColumn;
|
||||
extern const char *kWorkStateColumn;
|
||||
extern const char *kWorkZipCodeColumn;
|
||||
extern const char *kWorkCountryColumn;
|
||||
extern const char *kJobTitleColumn;
|
||||
extern const char *kDepartmentColumn;
|
||||
extern const char *kCompanyColumn;
|
||||
extern const char *kWebPage1Column;
|
||||
extern const char *kWebPage2Column;
|
||||
extern const char *kBirthYearColumn;
|
||||
extern const char *kBirthMonthColumn;
|
||||
extern const char *kBirthDayColumn;
|
||||
extern const char *kCustom1Column;
|
||||
extern const char *kCustom2Column;
|
||||
extern const char *kCustom3Column;
|
||||
extern const char *kCustom4Column;
|
||||
extern const char *kNotesColumn;
|
||||
/* end */
|
||||
|
||||
nsAbCardProperty::nsAbCardProperty(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
m_pListName = nsnull;
|
||||
m_pWorkCity = nsnull;
|
||||
m_pOrganization = nsnull;
|
||||
|
||||
m_pFirstName = nsnull;
|
||||
m_pLastName = nsnull;
|
||||
m_pDisplayName = nsnull;
|
||||
|
@ -53,8 +96,36 @@ nsAbCardProperty::nsAbCardProperty(void)
|
|||
m_pPagerNumber = nsnull;
|
||||
m_pCellularNumber = nsnull;
|
||||
|
||||
m_dbTableID = -1;
|
||||
m_dbRowID = -1;
|
||||
m_pHomeAddress = nsnull;
|
||||
m_pHomeAddress2 = nsnull;
|
||||
m_pHomeCity = nsnull;
|
||||
m_pHomeState = nsnull;
|
||||
m_pHomeZipCode = nsnull;
|
||||
m_pHomeCountry = nsnull;
|
||||
m_pWorkAddress = nsnull;
|
||||
m_pWorkAddress2 = nsnull;
|
||||
m_pWorkCity = nsnull;
|
||||
m_pWorkState = nsnull;
|
||||
m_pWorkZipCode = nsnull;
|
||||
m_pWorkCountry = nsnull;
|
||||
m_pJobTitle = nsnull;
|
||||
m_pDepartment = nsnull;
|
||||
m_pCompany = nsnull;
|
||||
m_pWebPage1 = nsnull;
|
||||
m_pWebPage2 = nsnull;
|
||||
m_pBirthYear = nsnull;
|
||||
m_pBirthMonth = nsnull;
|
||||
m_pBirthDay = nsnull;
|
||||
m_pCustom1 = nsnull;
|
||||
m_pCustom2 = nsnull;
|
||||
m_pCustom3 = nsnull;
|
||||
m_pCustom4 = nsnull;
|
||||
m_pNote = nsnull;
|
||||
|
||||
m_bSendPlainText = PR_FALSE;
|
||||
|
||||
m_dbTableID = 0;
|
||||
m_dbRowID = 0;
|
||||
}
|
||||
|
||||
nsAbCardProperty::~nsAbCardProperty(void)
|
||||
|
@ -62,10 +133,6 @@ nsAbCardProperty::~nsAbCardProperty(void)
|
|||
if(mDatabase)
|
||||
mDatabase->RemoveListener(this);
|
||||
|
||||
PR_FREEIF(m_pListName);
|
||||
PR_FREEIF(m_pWorkCity);
|
||||
PR_FREEIF(m_pOrganization);
|
||||
|
||||
PR_FREEIF(m_pFirstName);
|
||||
PR_FREEIF(m_pLastName);
|
||||
PR_FREEIF(m_pDisplayName);
|
||||
|
@ -77,6 +144,32 @@ nsAbCardProperty::~nsAbCardProperty(void)
|
|||
PR_FREEIF(m_pFaxNumber);
|
||||
PR_FREEIF(m_pPagerNumber);
|
||||
PR_FREEIF(m_pCellularNumber);
|
||||
PR_FREEIF(m_pHomeAddress);
|
||||
PR_FREEIF(m_pHomeAddress2);
|
||||
PR_FREEIF(m_pHomeCity);
|
||||
PR_FREEIF(m_pHomeState);
|
||||
PR_FREEIF(m_pHomeZipCode);
|
||||
PR_FREEIF(m_pHomeCountry);
|
||||
PR_FREEIF(m_pWorkAddress);
|
||||
PR_FREEIF(m_pWorkAddress2);
|
||||
PR_FREEIF(m_pWorkCity);
|
||||
PR_FREEIF(m_pWorkState);
|
||||
PR_FREEIF(m_pWorkZipCode);
|
||||
PR_FREEIF(m_pWorkCountry);
|
||||
PR_FREEIF(m_pJobTitle);
|
||||
PR_FREEIF(m_pDepartment);
|
||||
PR_FREEIF(m_pCompany);
|
||||
PR_FREEIF(m_pWebPage1);
|
||||
PR_FREEIF(m_pWebPage2);
|
||||
PR_FREEIF(m_pBirthYear);
|
||||
PR_FREEIF(m_pBirthMonth);
|
||||
PR_FREEIF(m_pBirthDay);
|
||||
PR_FREEIF(m_pCustom1);
|
||||
PR_FREEIF(m_pCustom2);
|
||||
PR_FREEIF(m_pCustom3);
|
||||
PR_FREEIF(m_pCustom4);
|
||||
PR_FREEIF(m_pNote);
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAbCardProperty)
|
||||
|
@ -115,244 +208,41 @@ NS_IMETHODIMP nsAbCardProperty::OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instiga
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetListName(char **listname)
|
||||
nsresult nsAbCardProperty::GetAttributeName(char **aName, char* pValue)
|
||||
{
|
||||
SetListName("List1");
|
||||
if (listname && m_pListName)
|
||||
*listname = PL_strdup(m_pListName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetWorkCity(char **city)
|
||||
{
|
||||
SetWorkCity("Mountain View");
|
||||
if (city && m_pWorkCity)
|
||||
*city = PL_strdup(m_pWorkCity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetFirstName(char * *aFirstName)
|
||||
{
|
||||
if (aFirstName && m_pFirstName)
|
||||
*aFirstName = PL_strdup(m_pFirstName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetLastName(char * *aLastName)
|
||||
{
|
||||
if (aLastName && m_pLastName)
|
||||
*aLastName = PL_strdup(m_pLastName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetDisplayName(char * *aDisplayName)
|
||||
{
|
||||
if (aDisplayName && m_pDisplayName)
|
||||
*aDisplayName = PL_strdup(m_pDisplayName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetPrimaryEmail(char * *aPrimaryEmail)
|
||||
{
|
||||
if (aPrimaryEmail && m_pPrimaryEmail)
|
||||
*aPrimaryEmail = PL_strdup(m_pPrimaryEmail);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsAbCardProperty::GetSecondEmail(char * *aSecondEmail)
|
||||
{
|
||||
if (aSecondEmail && m_pSecondEmail)
|
||||
*aSecondEmail = PL_strdup(m_pSecondEmail);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetWorkPhone(char * *aWorkPhone)
|
||||
{
|
||||
if (aWorkPhone && m_pWorkPhone)
|
||||
*aWorkPhone = PL_strdup(m_pWorkPhone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetHomePhone(char * *aHomePhone)
|
||||
{
|
||||
if (aHomePhone && m_pHomePhone)
|
||||
*aHomePhone = PL_strdup(m_pHomePhone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetFaxNumber(char * *aFaxNumber)
|
||||
{
|
||||
if (aFaxNumber && m_pFaxNumber)
|
||||
*aFaxNumber = PL_strdup(m_pFaxNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetPagerNumber(char * *aPagerNumber)
|
||||
{
|
||||
if (aPagerNumber && m_pPagerNumber)
|
||||
*aPagerNumber = PL_strdup(m_pPagerNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetCellularNumber(char * *aCellularNumber)
|
||||
{
|
||||
if (aCellularNumber && m_pCellularNumber)
|
||||
*aCellularNumber = PL_strdup(m_pCellularNumber);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetOrganization(char * *aOrganization)
|
||||
{
|
||||
SetOrganization("Mail");
|
||||
if (aOrganization && m_pOrganization)
|
||||
*aOrganization = PL_strdup(m_pOrganization);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetNickName(char * *aNickName)
|
||||
{
|
||||
if (aNickName && m_pNickName)
|
||||
*aNickName = PL_strdup(m_pNickName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetListName(char * aListName)
|
||||
{
|
||||
if (aListName)
|
||||
if (aName)
|
||||
{
|
||||
PR_FREEIF(m_pListName);
|
||||
m_pListName = PL_strdup(aListName);
|
||||
if (pValue)
|
||||
*aName = PL_strdup(pValue);
|
||||
else
|
||||
*aName = PL_strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_RDF_NO_VALUE;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsAbCardProperty::SetAttributeName(char *aName, char **arrtibute)
|
||||
{
|
||||
if (aName)
|
||||
{
|
||||
char *pValue = *arrtibute;
|
||||
PR_FREEIF(pValue);
|
||||
*arrtibute = PL_strdup(aName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetFirstName(char * aFirstName)
|
||||
NS_IMETHODIMP nsAbCardProperty::GetSendPlainText(PRBool *aSendPlainText)
|
||||
{
|
||||
if (aFirstName)
|
||||
{
|
||||
PR_FREEIF(m_pFirstName);
|
||||
m_pFirstName = PL_strdup(aFirstName);
|
||||
}
|
||||
*aSendPlainText = m_bSendPlainText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetLastName(char * aLastName)
|
||||
NS_IMETHODIMP nsAbCardProperty::SetSendPlainText(PRBool aSendPlainText)
|
||||
{
|
||||
if (aLastName)
|
||||
{
|
||||
PR_FREEIF(m_pLastName);
|
||||
m_pLastName = PL_strdup(aLastName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetDisplayName(char * aDisplayName)
|
||||
{
|
||||
if (aDisplayName)
|
||||
{
|
||||
PR_FREEIF(m_pDisplayName);
|
||||
m_pDisplayName = PL_strdup(aDisplayName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetPrimaryEmail(char * aPrimaryEmail)
|
||||
{
|
||||
if (aPrimaryEmail)
|
||||
{
|
||||
PR_FREEIF(m_pPrimaryEmail);
|
||||
m_pPrimaryEmail = PL_strdup(aPrimaryEmail);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetSecondEmail(char * aSecondEmail)
|
||||
{
|
||||
if (aSecondEmail)
|
||||
{
|
||||
PR_FREEIF(m_pSecondEmail);
|
||||
m_pSecondEmail = PL_strdup(aSecondEmail);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetWorkPhone(char * aWorkPhone)
|
||||
{
|
||||
if (aWorkPhone)
|
||||
{
|
||||
PR_FREEIF(m_pWorkPhone);
|
||||
m_pWorkPhone = PL_strdup(aWorkPhone);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetHomePhone(char * aHomePhone)
|
||||
{
|
||||
if (aHomePhone)
|
||||
{
|
||||
PR_FREEIF(m_pHomePhone);
|
||||
m_pHomePhone = PL_strdup(aHomePhone);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetFaxNumber(char * aFaxNumber)
|
||||
{
|
||||
if (aFaxNumber)
|
||||
{
|
||||
PR_FREEIF(m_pFaxNumber);
|
||||
m_pFaxNumber = PL_strdup(aFaxNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetPagerNumber(char * aPagerNumber)
|
||||
{
|
||||
if (aPagerNumber)
|
||||
{
|
||||
PR_FREEIF(m_pPagerNumber);
|
||||
m_pPagerNumber = PL_strdup(aPagerNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetCellularNumber(char * aCellularNumber)
|
||||
{
|
||||
if (aCellularNumber)
|
||||
{
|
||||
PR_FREEIF(m_pCellularNumber);
|
||||
m_pCellularNumber = PL_strdup(aCellularNumber);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetWorkCity(char * aWorkCity)
|
||||
{
|
||||
if (aWorkCity)
|
||||
{
|
||||
PR_FREEIF(m_pWorkCity);
|
||||
m_pWorkCity = PL_strdup(aWorkCity);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetOrganization(char * aOrganization)
|
||||
{
|
||||
if (aOrganization)
|
||||
{
|
||||
PR_FREEIF(m_pOrganization);
|
||||
m_pOrganization = PL_strdup(aOrganization);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAbCardProperty::SetNickName(char * aNickName)
|
||||
{
|
||||
if (aNickName)
|
||||
{
|
||||
PR_FREEIF(m_pNickName);
|
||||
m_pNickName = PL_strdup(aNickName);
|
||||
}
|
||||
m_bSendPlainText = aSendPlainText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -382,28 +272,73 @@ NS_IMETHODIMP nsAbCardProperty::SetDbRowID(PRUint32 aDbRowID)
|
|||
|
||||
NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, char **value)
|
||||
{
|
||||
if (!PL_strcmp(attrname, "firstname"))
|
||||
if (!PL_strcmp(attrname, kFirstNameColumn))
|
||||
GetFirstName(value);
|
||||
else if (!PL_strcmp(attrname, "lastname"))
|
||||
else if (!PL_strcmp(attrname, kLastNameColumn))
|
||||
GetLastName(value);
|
||||
else if (!PL_strcmp(attrname, "displayname"))
|
||||
else if (!PL_strcmp(attrname, kDisplayNameColumn))
|
||||
GetDisplayName(value);
|
||||
else if (!PL_strcmp(attrname, "nickname"))
|
||||
else if (!PL_strcmp(attrname, kNicknameColumn))
|
||||
GetNickName(value);
|
||||
else if (!PL_strcmp(attrname, "primaryemail"))
|
||||
else if (!PL_strcmp(attrname, kPriEmailColumn))
|
||||
GetPrimaryEmail(value);
|
||||
else if (!PL_strcmp(attrname, "secondemail"))
|
||||
else if (!PL_strcmp(attrname, k2ndEmailColumn))
|
||||
GetSecondEmail(value);
|
||||
else if (!PL_strcmp(attrname, "workphone"))
|
||||
else if (!PL_strcmp(attrname, kWorkPhoneColumn))
|
||||
GetWorkPhone(value);
|
||||
else if (!PL_strcmp(attrname, "homephone"))
|
||||
else if (!PL_strcmp(attrname, kHomePhoneColumn))
|
||||
GetHomePhone(value);
|
||||
else if (!PL_strcmp(attrname, "faxnumber"))
|
||||
else if (!PL_strcmp(attrname, kFaxColumn))
|
||||
GetFaxNumber(value);
|
||||
else if (!PL_strcmp(attrname, "pagernumber"))
|
||||
else if (!PL_strcmp(attrname, kPagerColumn))
|
||||
GetPagerNumber(value);
|
||||
else if (!PL_strcmp(attrname, "cellularnumber"))
|
||||
else if (!PL_strcmp(attrname, kCellularColumn))
|
||||
GetCellularNumber(value);
|
||||
else if (!PL_strcmp(attrname, kHomeAddressColumn))
|
||||
GetHomeAddress(value);
|
||||
else if (!PL_strcmp(attrname, kHomeAddress2Column))
|
||||
GetHomeAddress2(value);
|
||||
else if (!PL_strcmp(attrname, kHomeCityColumn))
|
||||
GetHomeCity(value);
|
||||
else if (!PL_strcmp(attrname, kHomeStateColumn))
|
||||
GetHomeState(value);
|
||||
else if (!PL_strcmp(attrname, kHomeZipCodeColumn))
|
||||
GetHomeZipCode(value);
|
||||
else if (!PL_strcmp(attrname, kHomeCountryColumn))
|
||||
GetHomeCountry(value);
|
||||
else if (!PL_strcmp(attrname, kWorkAddressColumn))
|
||||
GetWorkAddress(value);
|
||||
else if (!PL_strcmp(attrname, kWorkAddress2Column))
|
||||
GetWorkAddress2(value);
|
||||
else if (!PL_strcmp(attrname, kWorkCityColumn))
|
||||
GetWorkCity(value);
|
||||
else if (!PL_strcmp(attrname, kWorkStateColumn))
|
||||
GetWorkState(value);
|
||||
else if (!PL_strcmp(attrname, kWorkZipCodeColumn))
|
||||
GetWorkZipCode(value);
|
||||
else if (!PL_strcmp(attrname, kWorkCountryColumn))
|
||||
GetWorkCountry(value);
|
||||
else if (!PL_strcmp(attrname, kWebPage1Column))
|
||||
GetWebPage1(value);
|
||||
else if (!PL_strcmp(attrname, kWebPage2Column))
|
||||
GetWebPage2(value);
|
||||
else if (!PL_strcmp(attrname, kBirthYearColumn))
|
||||
GetBirthYear(value);
|
||||
else if (!PL_strcmp(attrname, kBirthMonthColumn))
|
||||
GetBirthMonth(value);
|
||||
else if (!PL_strcmp(attrname, kBirthDayColumn))
|
||||
GetBirthDay(value);
|
||||
else if (!PL_strcmp(attrname, kCustom1Column))
|
||||
GetCustom1(value);
|
||||
else if (!PL_strcmp(attrname, kCustom2Column))
|
||||
GetCustom2(value);
|
||||
else if (!PL_strcmp(attrname, kCustom3Column))
|
||||
GetCustom3(value);
|
||||
else if (!PL_strcmp(attrname, kCustom4Column))
|
||||
GetCustom4(value);
|
||||
else if (!PL_strcmp(attrname, kNotesColumn))
|
||||
GetNotes(value);
|
||||
/* else handle pass down attribute */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -412,28 +347,74 @@ NS_IMETHODIMP nsAbCardProperty::SetCardValue(const char *attrname, const char *v
|
|||
{
|
||||
nsAutoString cardValue(value);
|
||||
char* valueStr = cardValue.ToNewCString();
|
||||
if (!PL_strcmp(attrname, "firstname"))
|
||||
|
||||
if (!PL_strcmp(attrname, kFirstNameColumn))
|
||||
SetFirstName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "lastname"))
|
||||
else if (!PL_strcmp(attrname, kLastNameColumn))
|
||||
SetLastName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "displayname"))
|
||||
else if (!PL_strcmp(attrname, kDisplayNameColumn))
|
||||
SetDisplayName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "nickname"))
|
||||
else if (!PL_strcmp(attrname, kNicknameColumn))
|
||||
SetNickName(valueStr);
|
||||
else if (!PL_strcmp(attrname, "primaryemail"))
|
||||
else if (!PL_strcmp(attrname, kPriEmailColumn))
|
||||
SetPrimaryEmail(valueStr);
|
||||
else if (!PL_strcmp(attrname, "secondemail"))
|
||||
else if (!PL_strcmp(attrname, k2ndEmailColumn))
|
||||
SetSecondEmail(valueStr);
|
||||
else if (!PL_strcmp(attrname, "workphone"))
|
||||
else if (!PL_strcmp(attrname, kWorkPhoneColumn))
|
||||
SetWorkPhone(valueStr);
|
||||
else if (!PL_strcmp(attrname, "homephone"))
|
||||
else if (!PL_strcmp(attrname, kHomePhoneColumn))
|
||||
SetHomePhone(valueStr);
|
||||
else if (!PL_strcmp(attrname, "faxnumber"))
|
||||
else if (!PL_strcmp(attrname, kFaxColumn))
|
||||
SetFaxNumber(valueStr);
|
||||
else if (!PL_strcmp(attrname, "pagernumber"))
|
||||
else if (!PL_strcmp(attrname, kPagerColumn))
|
||||
SetPagerNumber(valueStr);
|
||||
else if (!PL_strcmp(attrname, "cellularnumber"))
|
||||
else if (!PL_strcmp(attrname, kCellularColumn))
|
||||
SetCellularNumber(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeAddressColumn))
|
||||
SetHomeAddress(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeAddress2Column))
|
||||
SetHomeAddress2(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeCityColumn))
|
||||
SetHomeCity(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeStateColumn))
|
||||
SetHomeState(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeZipCodeColumn))
|
||||
SetHomeZipCode(valueStr);
|
||||
else if (!PL_strcmp(attrname, kHomeCountryColumn))
|
||||
SetHomeCountry(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkAddressColumn))
|
||||
SetWorkAddress(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkAddress2Column))
|
||||
SetWorkAddress2(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkCityColumn))
|
||||
SetWorkCity(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkStateColumn))
|
||||
SetWorkState(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkZipCodeColumn))
|
||||
SetWorkZipCode(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWorkCountryColumn))
|
||||
SetWorkCountry(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWebPage1Column))
|
||||
SetWebPage1(valueStr);
|
||||
else if (!PL_strcmp(attrname, kWebPage2Column))
|
||||
SetWebPage2(valueStr);
|
||||
else if (!PL_strcmp(attrname, kBirthYearColumn))
|
||||
SetBirthYear(valueStr);
|
||||
else if (!PL_strcmp(attrname, kBirthMonthColumn))
|
||||
SetBirthMonth(valueStr);
|
||||
else if (!PL_strcmp(attrname, kBirthDayColumn))
|
||||
SetBirthDay(valueStr);
|
||||
else if (!PL_strcmp(attrname, kCustom1Column))
|
||||
SetCustom1(valueStr);
|
||||
else if (!PL_strcmp(attrname, kCustom2Column))
|
||||
SetCustom2(valueStr);
|
||||
else if (!PL_strcmp(attrname, kCustom3Column))
|
||||
SetCustom3(valueStr);
|
||||
else if (!PL_strcmp(attrname, kCustom4Column))
|
||||
SetCustom4(valueStr);
|
||||
else if (!PL_strcmp(attrname, kNotesColumn))
|
||||
SetNotes(valueStr);
|
||||
/* else handle pass down attribute */
|
||||
|
||||
delete[] valueStr;
|
||||
|
||||
|
|
|
@ -52,75 +52,122 @@ public:
|
|||
NS_IMETHOD OnCardEntryChange(PRUint32 abCode, PRUint32 entryID, nsIAddrDBListener *instigator);
|
||||
NS_IMETHOD OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator);
|
||||
|
||||
// nsICollection methods:
|
||||
|
||||
NS_IMETHOD Count(PRUint32 *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD GetElementAt(PRUint32 i, nsISupports* *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD SetElementAt(PRUint32 i, nsISupports* value) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD AppendElement(nsISupports *aElement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD RemoveElement(nsISupports *aElement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD Clear(void) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
// nsICollection methods:
|
||||
|
||||
// nsIAbBase methods:
|
||||
|
||||
NS_IMETHOD GetURI(char* *name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetName(char **name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetName(char *name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetChildNamed(const char *name, nsISupports* *result) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetParent(nsIAbBase* *parent) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetParent(nsIAbBase *parent) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetChildNodes(nsIEnumerator* *result) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD AddAddrBookListener(nsIAbListener * listener) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD RemoveAddrBookListener(nsIAbListener * listener) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD AddUnique(nsISupports* element) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD Count(PRUint32 *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD GetElementAt(PRUint32 i, nsISupports* *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD SetElementAt(PRUint32 i, nsISupports* value) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD AppendElement(nsISupports *aElement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD RemoveElement(nsISupports *aElement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD Enumerate(nsIEnumerator* *result) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHOD Clear(void) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIAbBase methods:
|
||||
|
||||
NS_IMETHOD GetURI(char* *name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetName(char **name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetName(char *name) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetChildNamed(const char *name, nsISupports* *result) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetParent(nsIAbBase* *parent) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD SetParent(nsIAbBase *parent) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD GetChildNodes(nsIEnumerator* *result) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD AddAddrBookListener(nsIAbListener * listener) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD RemoveAddrBookListener(nsIAbListener * listener) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD AddUnique(nsISupports* element) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
|
||||
// nsIAbCard methods:
|
||||
NS_IMETHOD GetListName(char * *listName);
|
||||
NS_IMETHOD SetListName(char * listName);
|
||||
NS_IMETHOD GetFirstName(char * *aFirstName) { return GetAttributeName(aFirstName, m_pFirstName); }
|
||||
NS_IMETHOD GetLastName(char * *aLastName) { return GetAttributeName(aLastName, m_pLastName); }
|
||||
NS_IMETHOD GetDisplayName(char * *aDisplayName) { return GetAttributeName(aDisplayName, m_pDisplayName); }
|
||||
NS_IMETHOD GetNickName(char * *aNickName) { return GetAttributeName(aNickName, m_pNickName); }
|
||||
NS_IMETHOD GetPrimaryEmail(char * *aPrimaryEmail) { return GetAttributeName(aPrimaryEmail, m_pPrimaryEmail); }
|
||||
NS_IMETHOD GetSecondEmail(char * *aSecondEmail) { return GetAttributeName(aSecondEmail, m_pSecondEmail); }
|
||||
NS_IMETHOD GetWorkPhone(char * *aWorkPhone) { return GetAttributeName(aWorkPhone, m_pWorkPhone); }
|
||||
NS_IMETHOD GetHomePhone(char * *aHomePhone) { return GetAttributeName(aHomePhone, m_pHomePhone); }
|
||||
NS_IMETHOD GetFaxNumber(char * *aFaxNumber) { return GetAttributeName(aFaxNumber, m_pFaxNumber); }
|
||||
NS_IMETHOD GetPagerNumber(char * *aPagerNumber) { return GetAttributeName(aPagerNumber, m_pPagerNumber); }
|
||||
NS_IMETHOD GetCellularNumber(char * *aCellularNumber) { return GetAttributeName(aCellularNumber, m_pCellularNumber); }
|
||||
NS_IMETHOD GetHomeAddress(char * *aHomeAddress) { return GetAttributeName(aHomeAddress, m_pHomeAddress); }
|
||||
NS_IMETHOD GetHomeAddress2(char * *aHomeAddress2) { return GetAttributeName(aHomeAddress2, m_pHomeAddress2); }
|
||||
NS_IMETHOD GetHomeCity(char * *aHomeCity) { return GetAttributeName(aHomeCity, m_pHomeCity); }
|
||||
NS_IMETHOD GetHomeState(char * *aHomeState) { return GetAttributeName(aHomeState, m_pHomeState); }
|
||||
NS_IMETHOD GetHomeZipCode(char * *aHomeZipCode) { return GetAttributeName(aHomeZipCode, m_pHomeZipCode); }
|
||||
NS_IMETHOD GetHomeCountry(char * *aHomecountry) { return GetAttributeName(aHomecountry, m_pHomeCountry); }
|
||||
NS_IMETHOD GetWorkAddress(char * *aWorkAddress) { return GetAttributeName(aWorkAddress, m_pWorkAddress); }
|
||||
NS_IMETHOD GetWorkAddress2(char * *aWorkAddress2) { return GetAttributeName(aWorkAddress2, m_pWorkAddress2); }
|
||||
NS_IMETHOD GetWorkCity(char * *aWorkCity) { return GetAttributeName(aWorkCity, m_pWorkCity); }
|
||||
NS_IMETHOD GetWorkState(char * *aWorkState) { return GetAttributeName(aWorkState, m_pWorkState); }
|
||||
NS_IMETHOD GetWorkZipCode(char * *aWorkZipCode) { return GetAttributeName(aWorkZipCode, m_pWorkZipCode); }
|
||||
NS_IMETHOD GetWorkCountry(char * *aWorkCountry) { return GetAttributeName(aWorkCountry, m_pWorkCountry); }
|
||||
NS_IMETHOD GetJobTitle(char * *aJobTitle) { return GetAttributeName(aJobTitle, m_pJobTitle); }
|
||||
NS_IMETHOD GetDepartment(char * *aDepartment) { return GetAttributeName(aDepartment, m_pDepartment); }
|
||||
NS_IMETHOD GetCompany(char * *aCompany) { return GetAttributeName(aCompany, m_pCompany); }
|
||||
NS_IMETHOD GetWebPage1(char * *aWebPage1) { return GetAttributeName(aWebPage1, m_pWebPage1); }
|
||||
NS_IMETHOD GetWebPage2(char * *aWebPage2) { return GetAttributeName(aWebPage2, m_pWebPage2); }
|
||||
NS_IMETHOD GetBirthYear(char * *aBirthYear) { return GetAttributeName(aBirthYear, m_pBirthYear); }
|
||||
NS_IMETHOD GetBirthMonth(char * *aBirthMonth) { return GetAttributeName(aBirthMonth, m_pBirthMonth); }
|
||||
NS_IMETHOD GetBirthDay(char * *aBirthDay) { return GetAttributeName(aBirthDay, m_pBirthDay); }
|
||||
NS_IMETHOD GetCustom1(char * *aCustom1) { return GetAttributeName(aCustom1, m_pCustom1); }
|
||||
NS_IMETHOD GetCustom2(char * *aCustom2) { return GetAttributeName(aCustom2, m_pCustom2); }
|
||||
NS_IMETHOD GetCustom3(char * *aCustom3) { return GetAttributeName(aCustom3, m_pCustom3); }
|
||||
NS_IMETHOD GetCustom4(char * *aCustom4) { return GetAttributeName(aCustom4, m_pCustom4); }
|
||||
NS_IMETHOD GetNotes(char * *aNotes) { return GetAttributeName(aNotes, m_pNote); }
|
||||
|
||||
NS_IMETHOD GetFirstName(char * *aFirstName);
|
||||
NS_IMETHOD SetFirstName(char * aFirstName);
|
||||
NS_IMETHOD GetLastName(char * *aLastName);
|
||||
NS_IMETHOD SetLastName(char * aLastName);
|
||||
NS_IMETHOD GetDisplayName(char * *aDisplayName);
|
||||
NS_IMETHOD SetDisplayName(char * aDisplayName);
|
||||
NS_IMETHOD GetPrimaryEmail(char * *aPrimaryEmail);
|
||||
NS_IMETHOD SetPrimaryEmail(char * aPrimaryEmail);
|
||||
NS_IMETHOD GetSecondEmail(char * *aSecondEmail);
|
||||
NS_IMETHOD SetSecondEmail(char * aSecondEmail);
|
||||
NS_IMETHOD GetWorkPhone(char * *aWorkPhone);
|
||||
NS_IMETHOD SetWorkPhone(char * aWorkPhone);
|
||||
NS_IMETHOD GetHomePhone(char * *aHomePhone);
|
||||
NS_IMETHOD SetHomePhone(char * aHomePhone);
|
||||
NS_IMETHOD GetFaxNumber(char * *aFaxNumber);
|
||||
NS_IMETHOD SetFaxNumber(char * aFaxNumber);
|
||||
NS_IMETHOD GetPagerNumber(char * *aPagerNumber);
|
||||
NS_IMETHOD SetPagerNumber(char * aPagerNumber);
|
||||
NS_IMETHOD GetCellularNumber(char * *aCellularNumber);
|
||||
NS_IMETHOD SetCellularNumber(char * aCellularNumber);
|
||||
NS_IMETHOD GetWorkCity(char * *aWorkCity);
|
||||
NS_IMETHOD SetWorkCity(char * aWorkCity);
|
||||
NS_IMETHOD GetOrganization(char * *aOrganization);
|
||||
NS_IMETHOD SetOrganization(char * aOrganization);
|
||||
NS_IMETHOD GetNickName(char * *aNickName);
|
||||
NS_IMETHOD SetNickName(char * aNickName);
|
||||
NS_IMETHOD SetFirstName(char * aFirstName) { return SetAttributeName(aFirstName, &m_pFirstName); }
|
||||
NS_IMETHOD SetLastName(char * aLastName) { return SetAttributeName(aLastName, &m_pLastName); }
|
||||
NS_IMETHOD SetDisplayName(char * aDisplayName) { return SetAttributeName(aDisplayName, &m_pDisplayName); }
|
||||
NS_IMETHOD SetNickName(char * aNickName) { return SetAttributeName(aNickName, &m_pNickName); }
|
||||
NS_IMETHOD SetPrimaryEmail(char * aPrimaryEmail) { return SetAttributeName(aPrimaryEmail, &m_pPrimaryEmail); }
|
||||
NS_IMETHOD SetSecondEmail(char * aSecondEmail) { return SetAttributeName(aSecondEmail, &m_pSecondEmail); }
|
||||
NS_IMETHOD SetWorkPhone(char * aWorkPhone) { return SetAttributeName(aWorkPhone, &m_pWorkPhone); }
|
||||
NS_IMETHOD SetHomePhone(char * aHomePhone) { return SetAttributeName(aHomePhone, &m_pHomePhone); }
|
||||
NS_IMETHOD SetFaxNumber(char * aFaxNumber) { return SetAttributeName(aFaxNumber, &m_pFaxNumber); }
|
||||
NS_IMETHOD SetPagerNumber(char * aPagerNumber) { return SetAttributeName(aPagerNumber, &m_pPagerNumber); }
|
||||
NS_IMETHOD SetCellularNumber(char * aCellularNumber) { return SetAttributeName(aCellularNumber, &m_pCellularNumber); }
|
||||
NS_IMETHOD SetHomeAddress(char * aHomeAddress) { return SetAttributeName(aHomeAddress, &m_pHomeAddress); }
|
||||
NS_IMETHOD SetHomeAddress2(char * aHomeAddress2) { return SetAttributeName(aHomeAddress2, &m_pHomeAddress2); }
|
||||
NS_IMETHOD SetHomeCity(char * aHomeCity) { return SetAttributeName(aHomeCity, &m_pHomeCity); }
|
||||
NS_IMETHOD SetHomeState(char * aHomeState) { return SetAttributeName(aHomeState, &m_pHomeState); }
|
||||
NS_IMETHOD SetHomeZipCode(char * aHomeZipCode) { return SetAttributeName(aHomeZipCode, &m_pHomeZipCode); }
|
||||
NS_IMETHOD SetHomeCountry(char * aHomecountry) { return SetAttributeName(aHomecountry, &m_pHomeCountry); }
|
||||
NS_IMETHOD SetWorkAddress(char * aWorkAddress) { return SetAttributeName(aWorkAddress, &m_pWorkAddress); }
|
||||
NS_IMETHOD SetWorkAddress2(char * aWorkAddress2) { return SetAttributeName(aWorkAddress2, &m_pWorkAddress2); }
|
||||
NS_IMETHOD SetWorkCity(char * aWorkCity) { return SetAttributeName(aWorkCity, &m_pWorkCity); }
|
||||
NS_IMETHOD SetWorkState(char * aWorkState) { return SetAttributeName(aWorkState, &m_pWorkState); }
|
||||
NS_IMETHOD SetWorkZipCode(char * aWorkZipCode) { return SetAttributeName(aWorkZipCode, &m_pWorkZipCode); }
|
||||
NS_IMETHOD SetWorkCountry(char * aWorkCountry) { return SetAttributeName(aWorkCountry, &m_pWorkCountry); }
|
||||
NS_IMETHOD SetJobTitle(char * aJobTitle) { return SetAttributeName(aJobTitle, &m_pJobTitle); }
|
||||
NS_IMETHOD SetDepartment(char * aDepartment) { return SetAttributeName(aDepartment, &m_pDepartment); }
|
||||
NS_IMETHOD SetCompany(char * aCompany) { return SetAttributeName(aCompany, &m_pCompany); }
|
||||
NS_IMETHOD SetWebPage1(char * aWebPage1) { return SetAttributeName(aWebPage1, &m_pWebPage1); }
|
||||
NS_IMETHOD SetWebPage2(char * aWebPage2) { return SetAttributeName(aWebPage2, &m_pWebPage2); }
|
||||
NS_IMETHOD SetBirthYear(char * aBirthYear) { return SetAttributeName(aBirthYear, &m_pBirthYear); }
|
||||
NS_IMETHOD SetBirthMonth(char * aBirthMonth) { return SetAttributeName(aBirthMonth, &m_pBirthMonth); }
|
||||
NS_IMETHOD SetBirthDay(char * aBirthDay) { return SetAttributeName(aBirthDay, &m_pBirthDay); }
|
||||
NS_IMETHOD SetCustom1(char * aCustom1) { return SetAttributeName(aCustom1, &m_pCustom1); }
|
||||
NS_IMETHOD SetCustom2(char * aCustom2) { return SetAttributeName(aCustom2, &m_pCustom2); }
|
||||
NS_IMETHOD SetCustom3(char * aCustom3) { return SetAttributeName(aCustom3, &m_pCustom3); }
|
||||
NS_IMETHOD SetCustom4(char * aCustom4) { return SetAttributeName(aCustom4, &m_pCustom4); }
|
||||
NS_IMETHOD SetNotes(char * aNotes) { return SetAttributeName(aNotes, &m_pNote); }
|
||||
|
||||
NS_IMETHOD GetSendPlainText(PRBool *aSendPlainText);
|
||||
NS_IMETHOD SetSendPlainText(PRBool aSendPlainText);
|
||||
|
||||
NS_IMETHOD GetDbTableID(PRUint32 *aDbTableID);
|
||||
NS_IMETHOD SetDbTableID(PRUint32 aDbTableID);
|
||||
|
@ -133,9 +180,8 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
char* m_pListName;
|
||||
char* m_pWorkCity;
|
||||
char* m_pOrganization;
|
||||
nsresult GetAttributeName(char **aName, char* pValue);
|
||||
nsresult SetAttributeName(char *aName, char** arrtibute);
|
||||
|
||||
char* m_pFirstName;
|
||||
char* m_pLastName;
|
||||
|
@ -148,6 +194,33 @@ protected:
|
|||
char* m_pFaxNumber;
|
||||
char* m_pPagerNumber;
|
||||
char* m_pCellularNumber;
|
||||
char* m_pHomeAddress;
|
||||
char* m_pHomeAddress2;
|
||||
char* m_pHomeCity;
|
||||
char* m_pHomeState;
|
||||
char* m_pHomeZipCode;
|
||||
char* m_pHomeCountry;
|
||||
char* m_pWorkAddress;
|
||||
char* m_pWorkAddress2;
|
||||
char* m_pWorkCity;
|
||||
char* m_pWorkState;
|
||||
char* m_pWorkZipCode;
|
||||
char* m_pWorkCountry;
|
||||
char* m_pJobTitle;
|
||||
char* m_pDepartment;
|
||||
char* m_pCompany;
|
||||
char* m_pWebPage1;
|
||||
char* m_pWebPage2;
|
||||
char* m_pBirthYear;
|
||||
char* m_pBirthMonth;
|
||||
char* m_pBirthDay;
|
||||
char* m_pCustom1;
|
||||
char* m_pCustom2;
|
||||
char* m_pCustom3;
|
||||
char* m_pCustom4;
|
||||
char* m_pNote;
|
||||
|
||||
PRBool m_bSendPlainText;
|
||||
|
||||
PRUint32 m_dbTableID;
|
||||
PRUint32 m_dbRowID;
|
||||
|
|
|
@ -165,8 +165,8 @@ nsABDirectory::GetChildNodes(nsIEnumerator* *result)
|
|||
if (!PL_strcmp(mURI, "abdirectory:/") && GetDirList())
|
||||
{
|
||||
PRInt32 count = GetDirList()->Count();
|
||||
/* check :set count = 1 for personal addressbook only for now*/
|
||||
/* count = 1; */
|
||||
/* check: set count = 1 for personal addressbook only for now*/
|
||||
count = 1;
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ nsresult nsABDirectory::AddSubDirectory(nsAutoString name, nsIAbDirectory **chil
|
|||
|
||||
mSubDirectories->AppendElement(directory);
|
||||
*childDir = directory;
|
||||
NS_ADDREF(*childDir);
|
||||
NS_IF_ADDREF(*childDir);
|
||||
|
||||
(void)nsServiceManager::ReleaseService(kRDFServiceCID, rdf);
|
||||
|
||||
|
@ -238,17 +238,15 @@ nsresult nsABDirectory::GetAbDatabase()
|
|||
rv = locator->GetFileLocation(nsSpecialFileSpec::App_UserProfileDirectory50, &userdir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsServiceManager::ReleaseService(kFileLocatorCID, locator);
|
||||
|
||||
nsFileSpec dbPath;
|
||||
userdir->GetFileSpec(&dbPath);
|
||||
dbPath += "abook.mab";
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> addrDBFactory;
|
||||
rv = nsComponentManager::CreateInstance(kAddressBookDB, nsnull, nsCOMTypeInfo<nsIAddrDatabase>::GetIID(),
|
||||
(void **) getter_AddRefs(addrDBFactory));
|
||||
NS_WITH_SERVICE(nsIAddrDatabase, addrDBFactory, kAddressBookDB, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && addrDBFactory)
|
||||
openAddrDB = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
|
||||
openAddrDB = addrDBFactory->Open(&dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);
|
||||
|
||||
// if (mDatabase)
|
||||
// mDatabase->AddListener(this);
|
||||
|
@ -258,45 +256,16 @@ nsresult nsABDirectory::GetAbDatabase()
|
|||
|
||||
NS_IMETHODIMP nsABDirectory::GetChildCards(nsIEnumerator* *result)
|
||||
{
|
||||
if (!mCardInitialized)
|
||||
{
|
||||
if (!PL_strcmp(mURI, "abdirectory://Pab1") ||
|
||||
!PL_strcmp(mURI, "abdirectory://Pab2") ||
|
||||
!PL_strcmp(mURI, "abdirectory://Pab3"))
|
||||
{
|
||||
PRInt32 j;
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
nsAutoString currentCardStr;
|
||||
if (!PL_strcmp(mURI, "abdirectory://Pab1"))
|
||||
currentCardStr.Append("abcard://Pab1/Card");
|
||||
if (!PL_strcmp(mURI, "abdirectory://Pab2"))
|
||||
currentCardStr.Append("abcard://Pab2/Card");
|
||||
if (!PL_strcmp(mURI, "abdirectory://Pab3"))
|
||||
currentCardStr.Append("abcard://Pab3/Card");
|
||||
nsCOMPtr<nsIAbCard> childCard;
|
||||
if (j == 0) currentCardStr.Append('1');
|
||||
if (j == 1) currentCardStr.Append('2');
|
||||
AddChildCards(currentCardStr, getter_AddRefs(childCard));
|
||||
}
|
||||
}
|
||||
mCardInitialized = PR_TRUE;
|
||||
}
|
||||
// return mSubCards->Enumerate(result);
|
||||
return mSubDirectories->Enumerate(result);
|
||||
|
||||
#ifdef HOOK_UP_DB
|
||||
nsresult rv = GetAbDatabase();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && mDatabase)
|
||||
{
|
||||
rv = mDatabase->EnumerateCards(result);
|
||||
rv = mDatabase->EnumerateCards(this, result);
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsABDirectory::AddChildCards(nsAutoString name, nsIAbCard **childCard)
|
||||
NS_IMETHODIMP nsABDirectory::AddChildCards(const char *uriName, nsIAbCard **childCard)
|
||||
{
|
||||
if(!childCard)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -307,7 +276,7 @@ nsresult nsABDirectory::AddChildCards(nsAutoString name, nsIAbCard **childCard)
|
|||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoString uri(name);
|
||||
nsAutoString uri(uriName);
|
||||
char* uriStr = uri.ToNewCString();
|
||||
if (uriStr == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -390,8 +359,8 @@ NS_IMETHODIMP nsABDirectory::GetName(char **name)
|
|||
{
|
||||
PRInt32 count = GetDirList()->Count();
|
||||
PRInt32 i;
|
||||
/* check :set count = 1 for personal addressbook only for now*/
|
||||
/* count = 1; */
|
||||
/* check: set count = 1 for personal addressbook only for now*/
|
||||
count = 1;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
DIR_Server *server = (DIR_Server *)GetDirList()->ElementAt(i);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#ifndef nsABDirectory_h__
|
||||
#define nsABDirectory_h__
|
||||
|
||||
#include "msgCore.h"
|
||||
//#include "msgCore.h"
|
||||
#include "nsIAbDirectory.h" /* include the interface we are going to support */
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsIAbCard.h"
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
return mSubDirectories->Clear();
|
||||
}
|
||||
|
||||
// nsIABBase methods:
|
||||
// nsIAbBase methods:
|
||||
NS_IMETHOD GetURI(char* *name) { return nsRDFResource::GetValue(name); }
|
||||
NS_IMETHOD GetName(char **name);
|
||||
NS_IMETHOD SetName(char *name);
|
||||
|
@ -80,12 +80,12 @@ public:
|
|||
NS_IMETHOD AddAddrBookListener(nsIAbListener * listener);
|
||||
NS_IMETHOD RemoveAddrBookListener(nsIAbListener * listener);
|
||||
|
||||
|
||||
// nsIAbDirectory methods:
|
||||
NS_IMETHOD AddUnique(nsISupports* element);
|
||||
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
|
||||
NS_IMETHOD GetChildCards(nsIEnumerator* *result);
|
||||
NS_IMETHOD CreateCardFromDirectory(nsIAbCard* *result);
|
||||
NS_IMETHOD AddChildCards(const char *uriName, nsIAbCard **childCard);
|
||||
// NS_IMETHOD GetVisibleSubFolders(nsIEnumerator* *result);
|
||||
|
||||
// NS_IMETHOD GetPrettyName(char ** name);
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
nsresult nsAbRDFResource::GetAbDatabase();
|
||||
nsresult GetAbDatabase();
|
||||
|
||||
nsCOMPtr<nsIAddrDatabase> mDatabase;
|
||||
|
||||
|
|
|
@ -25,19 +25,24 @@
|
|||
#include "nsAbBaseCID.h"
|
||||
#include "nsIAbCard.h"
|
||||
#include "nsAbCard.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#include "prmem.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
#include "nsICollation.h"
|
||||
|
||||
#include "nsCollationCID.h"
|
||||
#include "nsMorkCID.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIMdbFactoryFactory.h"
|
||||
|
||||
extern "C" nsIMdbFactory* MakeMdbFactory();
|
||||
static NS_DEFINE_CID(kCMorkFactory, NS_MORK_CID);
|
||||
|
||||
const int kAddressBookDBVersion = 1;
|
||||
const PRInt32 kAddressBookDBVersion = 1;
|
||||
|
||||
enum nsAddrDBCommitType {
|
||||
kSmallCommit,
|
||||
|
@ -72,20 +77,46 @@ const char *kCategoryTableKind = "ns:addrbk:db:table:kind:category";
|
|||
|
||||
const char *kCardRowScope = "ns:addrbk:db:row:scope:card:all";
|
||||
|
||||
const char *kFirstNameColumnToken = "firstname";
|
||||
const char *kLastNameColumnToken = "lastname";
|
||||
const char *kDisplayNameColumnToken = "displayname";
|
||||
const char *kPriEmailColumnToken = "primaryemail";
|
||||
const char *k2ndEmailColumnToken = "secondemail";
|
||||
const char *kWorkPhoneColumnToken = "workphone";
|
||||
const char *kHomePhoneColumnToken = "homephone";
|
||||
const char *kFaxColumnToken = "faxnumber";
|
||||
const char *kPagerColumnToken = "pagernumber";
|
||||
const char *kCellularColumnToken = "cellularnumber";
|
||||
const char *kWorkCityColumnToken = "workcity";
|
||||
const char *kOrganizationColumnToken = "organization";
|
||||
const char *kNicknameColumnToken = "nickname";
|
||||
const char *kAddressCharSetColumnToken = "addrCharSet";
|
||||
const char *kFirstNameColumn = "FirstName";
|
||||
const char *kLastNameColumn = "LastName";
|
||||
const char *kDisplayNameColumn = "DisplayName";
|
||||
const char *kNicknameColumn = "NickName";
|
||||
const char *kPriEmailColumn = "PrimaryEmail";
|
||||
const char *k2ndEmailColumn = "SecondEmail";
|
||||
const char *kPlainTextColumn = "SendPlainText";
|
||||
const char *kWorkPhoneColumn = "WorkPhone";
|
||||
const char *kHomePhoneColumn = "HomePhone";
|
||||
const char *kFaxColumn = "FaxNumber";
|
||||
const char *kPagerColumn = "PagerNumber";
|
||||
const char *kCellularColumn = "CellularNumber";
|
||||
const char *kHomeAddressColumn = "HomeAddress";
|
||||
const char *kHomeAddress2Column = "HomeAddress2";
|
||||
const char *kHomeCityColumn = "HomeCity";
|
||||
const char *kHomeStateColumn = "HomeState";
|
||||
const char *kHomeZipCodeColumn = "HomeZipCode";
|
||||
const char *kHomeCountryColumn = "HomeCountry";
|
||||
const char *kWorkAddressColumn = "WorkAddress";
|
||||
const char *kWorkAddress2Column = "WorkAddress2";
|
||||
const char *kWorkCityColumn = "WorkCity";
|
||||
const char *kWorkStateColumn = "WorkState";
|
||||
const char *kWorkZipCodeColumn = "WorkZipCode";
|
||||
const char *kWorkCountryColumn = "WorkCountry";
|
||||
const char *kJobTitleColumn = "JobTitle";
|
||||
const char *kDepartmentColumn = "Department";
|
||||
const char *kCompanyColumn = "Company";
|
||||
const char *kWebPage1Column = "WebPage1";
|
||||
const char *kWebPage2Column = "WebPage2";
|
||||
const char *kBirthYearColumn = "BirthYear";
|
||||
const char *kBirthMonthColumn = "BirthMonth";
|
||||
const char *kBirthDayColumn = "BirthDay";
|
||||
const char *kCustom1Column = "Custom1";
|
||||
const char *kCustom2Column = "Custom2";
|
||||
const char *kCustom3Column = "Custom3";
|
||||
const char *kCustom4Column = "Custom4";
|
||||
const char *kNotesColumn = "Notes";
|
||||
|
||||
const char *kAddressCharSetColumn = "AddrCharSet";
|
||||
|
||||
|
||||
struct mdbOid gAddressBookTableOID;
|
||||
struct mdbOid gMailListTableOID;
|
||||
|
@ -102,20 +133,42 @@ nsAddrDatabase::nsAddrDatabase()
|
|||
m_historyTableKind(0),
|
||||
m_mailListTableKind(0),
|
||||
m_categoryTableKind(0),
|
||||
m_firstNameColumnToken(0),
|
||||
m_lastNameColumnToken(0),
|
||||
m_displayNameColumnToken(0),
|
||||
m_priEmailColumnToken(0),
|
||||
m_FirstNameColumnToken(0),
|
||||
m_LastNameColumnToken(0),
|
||||
m_DisplayNameColumnToken(0),
|
||||
m_NickNameColumnToken(0),
|
||||
m_PriEmailColumnToken(0),
|
||||
m_2ndEmailColumnToken(0),
|
||||
m_workPhoneColumnToken(0),
|
||||
m_homePhoneColumnToken(0),
|
||||
m_faxColumnToken(0),
|
||||
m_pagerColumnToken(0),
|
||||
m_cellularColumnToken(0),
|
||||
m_workCityColumnToken(0),
|
||||
m_organizationColumnToken(0),
|
||||
m_nicknameColumnToken(0),
|
||||
m_addressCharSetColumnToken(0)
|
||||
m_WorkPhoneColumnToken(0),
|
||||
m_HomePhoneColumnToken(0),
|
||||
m_FaxColumnToken(0),
|
||||
m_PagerColumnToken(0),
|
||||
m_CellularColumnToken(0),
|
||||
m_HomeAddressColumnToken(0),
|
||||
m_HomeAddress2ColumnToken(0),
|
||||
m_HomeCityColumnToken(0),
|
||||
m_HomeStateColumnToken(0),
|
||||
m_HomeZipCodeColumnToken(0),
|
||||
m_HomeCountryColumnToken(0),
|
||||
m_WorkAddressColumnToken(0),
|
||||
m_WorkAddress2ColumnToken(0),
|
||||
m_WorkCityColumnToken(0),
|
||||
m_WorkStateColumnToken(0),
|
||||
m_WorkZipCodeColumnToken(0),
|
||||
m_WorkCountryColumnToken(0),
|
||||
m_WebPage1ColumnToken(0),
|
||||
m_WebPage2ColumnToken(0),
|
||||
m_BirthYearColumnToken(0),
|
||||
m_BirthMonthColumnToken(0),
|
||||
m_BirthDayColumnToken(0),
|
||||
m_Custom1ColumnToken(0),
|
||||
m_Custom2ColumnToken(0),
|
||||
m_Custom3ColumnToken(0),
|
||||
m_Custom4ColumnToken(0),
|
||||
m_NotesColumnToken(0),
|
||||
m_PlainTextColumnToken(0),
|
||||
m_AddressCharSetColumnToken(0),
|
||||
m_dbDirectory(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -129,6 +182,8 @@ nsAddrDatabase::~nsAddrDatabase()
|
|||
NS_ASSERTION(m_ChangeListeners->Count() == 0, "shouldn't have any listeners");
|
||||
delete m_ChangeListeners;
|
||||
}
|
||||
|
||||
CleanupCache();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsAddrDatabase)
|
||||
|
@ -267,7 +322,7 @@ nsAddrDatabase::CleanupCache()
|
|||
//----------------------------------------------------------------------
|
||||
// FindInCache - this addrefs the db it finds.
|
||||
//----------------------------------------------------------------------
|
||||
nsAddrDatabase* nsAddrDatabase::FindInCache(nsFileSpec &dbName)
|
||||
nsAddrDatabase* nsAddrDatabase::FindInCache(nsFileSpec *dbName)
|
||||
{
|
||||
for (PRInt32 i = 0; i < GetDBCache()->Count(); i++)
|
||||
{
|
||||
|
@ -296,9 +351,9 @@ PRInt32 nsAddrDatabase::FindInCache(nsAddrDatabase* pAddrDB)
|
|||
return(-1);
|
||||
}
|
||||
|
||||
PRBool nsAddrDatabase::MatchDbName(nsFileSpec &dbName) // returns PR_TRUE if they match
|
||||
PRBool nsAddrDatabase::MatchDbName(nsFileSpec* dbName) // returns PR_TRUE if they match
|
||||
{
|
||||
return (m_dbName == dbName);
|
||||
return (m_dbName == (*dbName));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -315,10 +370,11 @@ void nsAddrDatabase::RemoveFromCache(nsAddrDatabase* pAddrDB)
|
|||
|
||||
nsIMdbFactory *nsAddrDatabase::GetMDBFactory()
|
||||
{
|
||||
static nsIMdbFactory *gMDBFactory = NULL;
|
||||
static nsIMdbFactory *gMDBFactory = nsnull;
|
||||
if (!gMDBFactory)
|
||||
{
|
||||
// gMDBFactory = MakeMdbFactory(); //new nsIMdbFactory;
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kCMorkFactory, nsnull, nsIMdbFactoryFactory::GetIID(), (void **) &gMDBFactory);
|
||||
}
|
||||
return gMDBFactory;
|
||||
}
|
||||
|
@ -428,8 +484,21 @@ void nsAddrDatabase::NativeToUnix(char*& ioPath)
|
|||
}
|
||||
#endif /* XP_MAC */
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::GetDbPath(nsFileSpec * *aDbPath)
|
||||
{
|
||||
nsFileSpec *filePath = new nsFileSpec();
|
||||
*aDbPath = filePath;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::SetDbPath(nsFileSpec * aDbPath)
|
||||
{
|
||||
m_dbName = (*aDbPath);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::Open
|
||||
(nsFileSpec &pabName, PRBool create, nsIAddrDatabase** pAddrDB, PRBool upgrading)
|
||||
(nsFileSpec* pabName, PRBool create, nsIAddrDatabase** pAddrDB, PRBool upgrading)
|
||||
{
|
||||
nsAddrDatabase *pAddressBookDB;
|
||||
nsresult err = NS_OK;
|
||||
|
@ -449,15 +518,16 @@ NS_IMETHODIMP nsAddrDatabase::Open
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// pAddressBookDB->m_dbName = new nsFileSpec(pabName);
|
||||
pAddressBookDB->AddRef();
|
||||
|
||||
err = pAddressBookDB->OpenMDB((const char *) pabName, create);
|
||||
err = pAddressBookDB->OpenMDB(pabName, create);
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
pAddressBookDB->SetDbPath(pabName);
|
||||
*pAddrDB = pAddressBookDB;
|
||||
if (pAddressBookDB)
|
||||
GetDBCache()->AppendElement(pAddressBookDB);
|
||||
NS_IF_ADDREF(*pAddrDB);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -473,7 +543,7 @@ NS_IMETHODIMP nsAddrDatabase::Open
|
|||
// Open the MDB database synchronously. If successful, this routine
|
||||
// will set up the m_mdbStore and m_mdbEnv of the database object
|
||||
// so other database calls can work.
|
||||
NS_IMETHODIMP nsAddrDatabase::OpenMDB(const char *dbName, PRBool create)
|
||||
NS_IMETHODIMP nsAddrDatabase::OpenMDB(nsFileSpec *dbName, PRBool create)
|
||||
{
|
||||
nsresult ret = NS_OK;
|
||||
nsIMdbFactory *myMDBFactory = GetMDBFactory();
|
||||
|
@ -483,19 +553,19 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
if (NS_SUCCEEDED(ret))
|
||||
{
|
||||
nsIMdbThumb *thumb;
|
||||
nsFileSpec dbPath(dbName);
|
||||
char *nativeFileName = nsCRT::strdup(dbName);
|
||||
const char *pFilename = dbName->GetCString(); /* do not free */
|
||||
char *nativeFileName = PL_strdup(pFilename);
|
||||
|
||||
if (!nativeFileName)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (m_mdbEnv)
|
||||
m_mdbEnv->SetAutoClear(PR_TRUE);
|
||||
m_dbName = nsCRT::strdup(dbName);
|
||||
|
||||
#if defined(XP_PC) || defined(XP_MAC)
|
||||
UnixToNative(nativeFileName);
|
||||
#endif
|
||||
if (!dbPath.Exists())
|
||||
if (!dbName->Exists())
|
||||
ret = NS_ERROR_FAILURE; // check: use the right error code later
|
||||
else
|
||||
{
|
||||
|
@ -511,11 +581,15 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
first512Bytes.mYarn_Form = 0; // what to do with this? we're storing csid in the msg hdr...
|
||||
|
||||
{
|
||||
nsIOFileStream *dbStream = new nsIOFileStream(nsFileSpec(dbName));
|
||||
PRInt32 bytesRead = dbStream->read(bufFirst512Bytes, sizeof(bufFirst512Bytes));
|
||||
first512Bytes.mYarn_Fill = bytesRead;
|
||||
dbStream->close();
|
||||
delete dbStream;
|
||||
nsFileSpec ioStream(dbName->GetCString());
|
||||
nsIOFileStream *dbStream = new nsIOFileStream(ioStream);
|
||||
if (dbStream)
|
||||
{
|
||||
PRInt32 bytesRead = dbStream->read(bufFirst512Bytes, sizeof(bufFirst512Bytes));
|
||||
first512Bytes.mYarn_Fill = bytesRead;
|
||||
dbStream->close();
|
||||
delete dbStream;
|
||||
}
|
||||
}
|
||||
ret = myMDBFactory->CanOpenFilePort(m_mdbEnv, nativeFileName, // the file to investigate
|
||||
&first512Bytes, &canOpen, &outFormatVersion);
|
||||
|
@ -532,6 +606,9 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
else
|
||||
ret = NS_ERROR_FAILURE; //check: use the right error code
|
||||
}
|
||||
|
||||
PR_FREEIF(nativeFileName);
|
||||
|
||||
if (NS_SUCCEEDED(ret) && thumb)
|
||||
{
|
||||
mdb_count outTotal; // total somethings to do in operation
|
||||
|
@ -567,11 +644,10 @@ NS_IMETHODIMP nsAddrDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
inOpenPolicy.mOpenPolicy_MinMemory = 0;
|
||||
inOpenPolicy.mOpenPolicy_MaxLazy = 0;
|
||||
|
||||
ret = myMDBFactory->CreateNewFileStore(m_mdbEnv, NULL, dbName, &inOpenPolicy, &m_mdbStore);
|
||||
ret = myMDBFactory->CreateNewFileStore(m_mdbEnv, NULL, dbName->GetCString(), &inOpenPolicy, &m_mdbStore);
|
||||
if (ret == NS_OK)
|
||||
ret = InitNewDB();
|
||||
}
|
||||
nsCRT::free(nativeFileName);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -738,20 +814,44 @@ nsresult nsAddrDatabase::InitMDBInfo()
|
|||
err = GetStore()->StringToToken(GetEnv(), kCardRowScope, &m_cardRowScopeToken);
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
GetStore()->StringToToken(GetEnv(), kFirstNameColumnToken, &m_firstNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kLastNameColumnToken, &m_lastNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kDisplayNameColumnToken, &m_displayNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kPriEmailColumnToken, &m_priEmailColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), k2ndEmailColumnToken, &m_2ndEmailColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkPhoneColumnToken, &m_workPhoneColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomePhoneColumnToken, &m_homePhoneColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kFaxColumnToken, &m_faxColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kPagerColumnToken, &m_pagerColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCellularColumnToken, &m_cellularColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkCityColumnToken, &m_workCityColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kOrganizationColumnToken, &m_organizationColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kNicknameColumnToken, &m_nicknameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kAddressCharSetColumnToken, &m_addressCharSetColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kFirstNameColumn, &m_FirstNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kLastNameColumn, &m_LastNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kDisplayNameColumn, &m_DisplayNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kNicknameColumn, &m_NickNameColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kPriEmailColumn, &m_PriEmailColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), k2ndEmailColumn, &m_2ndEmailColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkPhoneColumn, &m_WorkPhoneColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomePhoneColumn, &m_HomePhoneColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kFaxColumn, &m_FaxColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kPagerColumn, &m_PagerColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCellularColumn, &m_CellularColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeAddressColumn, &m_HomeAddressColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeAddress2Column, &m_HomeAddress2ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeCityColumn, &m_HomeCityColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeStateColumn, &m_HomeStateColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeZipCodeColumn, &m_HomeZipCodeColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kHomeCountryColumn, &m_HomeCountryColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkAddressColumn, &m_WorkAddressColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkAddress2Column, &m_WorkAddress2ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkCityColumn, &m_WorkCityColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkStateColumn, &m_WorkStateColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkZipCodeColumn, &m_WorkZipCodeColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWorkCountryColumn, &m_WorkCountryColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kJobTitleColumn, &m_JobTitleColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kDepartmentColumn, &m_DepartmentColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCompanyColumn, &m_CompanyColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWebPage1Column, &m_WebPage1ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kWebPage2Column, &m_WebPage2ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kBirthYearColumn, &m_BirthYearColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kBirthMonthColumn, &m_BirthMonthColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kBirthDayColumn, &m_BirthDayColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCustom1Column, &m_Custom1ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCustom2Column, &m_Custom2ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCustom3Column, &m_Custom3ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kCustom4Column, &m_Custom4ColumnToken);
|
||||
GetStore()->StringToToken(GetEnv(), kNotesColumn, &m_NotesColumnToken);
|
||||
|
||||
GetStore()->StringToToken(GetEnv(), kAddressCharSetColumn, &m_AddressCharSetColumnToken);
|
||||
err = GetStore()->StringToToken(GetEnv(), kPabTableKind, &m_pabTableKind);
|
||||
if (NS_SUCCEEDED(err))
|
||||
{
|
||||
|
@ -795,19 +895,23 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool
|
|||
char* pStr = nsnull;
|
||||
newCard->GetFirstName(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_firstNameColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_FirstNameColumnToken, pStr);
|
||||
|
||||
newCard->GetLastName(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_lastNameColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_LastNameColumnToken, pStr);
|
||||
|
||||
newCard->GetDisplayName(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_displayNameColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_DisplayNameColumnToken, pStr);
|
||||
|
||||
newCard->GetNickName(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_NickNameColumnToken, pStr);
|
||||
|
||||
newCard->GetPrimaryEmail(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_priEmailColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_PriEmailColumnToken, pStr);
|
||||
|
||||
newCard->GetSecondEmail(&pStr);
|
||||
if (pStr)
|
||||
|
@ -815,23 +919,124 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool
|
|||
|
||||
newCard->GetWorkPhone(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_workPhoneColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_WorkPhoneColumnToken, pStr);
|
||||
|
||||
newCard->GetHomePhone(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_homePhoneColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_HomePhoneColumnToken, pStr);
|
||||
|
||||
newCard->GetFaxNumber(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_faxColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_FaxColumnToken, pStr);
|
||||
|
||||
newCard->GetPagerNumber(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_pagerColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_PagerColumnToken, pStr);
|
||||
|
||||
newCard->GetCellularNumber(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_cellularColumnToken, pStr);
|
||||
AddCardColumn(cardRow, m_CellularColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeAddress(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeAddressColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeAddress2(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeAddress2ColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeCity(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeCityColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeState(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeStateColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeZipCode(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeZipCodeColumnToken, pStr);
|
||||
|
||||
newCard->GetHomeCountry(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_HomeCountryColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkAddress(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkAddressColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkAddress2(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkAddress2ColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkCity(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkCityColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkState(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkStateColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkZipCode(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkZipCodeColumnToken, pStr);
|
||||
|
||||
newCard->GetWorkCountry(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WorkCountryColumnToken, pStr);
|
||||
|
||||
newCard->GetJobTitle(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_JobTitleColumnToken, pStr);
|
||||
|
||||
newCard->GetDepartment(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_DepartmentColumnToken, pStr);
|
||||
|
||||
newCard->GetCompany(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_CompanyColumnToken, pStr);
|
||||
|
||||
newCard->GetWebPage1(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WebPage1ColumnToken, pStr);
|
||||
|
||||
newCard->GetWebPage2(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_WebPage2ColumnToken, pStr);
|
||||
|
||||
newCard->GetBirthYear(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_BirthYearColumnToken, pStr);
|
||||
|
||||
newCard->GetBirthMonth(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_BirthMonthColumnToken, pStr);
|
||||
|
||||
newCard->GetBirthDay(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_BirthDayColumnToken, pStr);
|
||||
|
||||
newCard->GetCustom1(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_Custom1ColumnToken, pStr);
|
||||
|
||||
newCard->GetCustom2(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_Custom2ColumnToken, pStr);
|
||||
|
||||
newCard->GetCustom3(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_Custom3ColumnToken, pStr);
|
||||
|
||||
newCard->GetCustom4(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_Custom4ColumnToken, pStr);
|
||||
|
||||
newCard->GetNotes(&pStr);
|
||||
if (pStr)
|
||||
AddCardColumn(cardRow, m_NotesColumnToken, pStr);
|
||||
|
||||
|
||||
err = m_mdbPabTable->AddRow(GetEnv(), cardRow);
|
||||
}
|
||||
|
@ -860,6 +1065,324 @@ mdb_err nsAddrDatabase::AddCardColumn(nsIMdbRow* cardRow, mdb_column inColumn, c
|
|||
return err;
|
||||
}
|
||||
|
||||
nsresult nsAddrDatabase::GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken, nsString &str)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
nsIMdbCell *cardCell;
|
||||
|
||||
if (cardRow)
|
||||
{
|
||||
err = cardRow->GetCell(GetEnv(), outToken, &cardCell);
|
||||
if (err == NS_OK && cardCell)
|
||||
{
|
||||
struct mdbYarn yarn;
|
||||
cardCell->AliasYarn(GetEnv(), &yarn);
|
||||
str.SetString((const char *) yarn.mYarn_Buf, yarn.mYarn_Fill);
|
||||
cardCell->CutStrongRef(GetEnv()); // always release ref
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
nsresult nsAddrDatabase::GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
if (!newCard || !cardRow)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsAutoString tempString;
|
||||
char *tempCString = nsnull;
|
||||
|
||||
GetStringColumn(cardRow, m_FirstNameColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetFirstName(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_LastNameColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetLastName(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_DisplayNameColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetDisplayName(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_NickNameColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetNickName(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_PriEmailColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetPrimaryEmail(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_2ndEmailColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetSecondEmail(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkPhoneColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkPhone(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomePhoneColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomePhone(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_FaxColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetFaxNumber(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_PagerColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetPagerNumber(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_CellularColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCellularNumber(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeAddressColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeAddress(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeAddress2ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeAddress2(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeCityColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeCity(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeStateColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeState(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeZipCodeColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeZipCode(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_HomeCountryColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetHomeCountry(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkAddressColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkAddress(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkAddress2ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkAddress2(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkCityColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkCity(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkStateColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkState(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkZipCodeColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkZipCode(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WorkCountryColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWorkCountry(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_JobTitleColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetJobTitle(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_DepartmentColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetDepartment(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_CompanyColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCompany(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WebPage1ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWebPage1(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_WebPage2ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetWebPage2(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_BirthYearColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetBirthYear(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_BirthMonthColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetBirthMonth(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_BirthDayColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetBirthDay(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_Custom1ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCustom1(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_Custom2ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCustom2(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_Custom3ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCustom3(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_Custom4ColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetCustom4(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
GetStringColumn(cardRow, m_NotesColumnToken, tempString);
|
||||
if (tempString.Length())
|
||||
{
|
||||
tempCString = tempString.ToNewCString();
|
||||
newCard->SetNotes(tempCString);
|
||||
delete [] tempCString;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
class nsAddrDBEnumerator : public nsIEnumerator {
|
||||
public:
|
||||
|
@ -932,10 +1455,10 @@ NS_IMETHODIMP nsAddrDBEnumerator::CurrentItem(nsISupports **aItem)
|
|||
{
|
||||
if (mCurrentRow)
|
||||
{
|
||||
nsCOMPtr<nsIAbCard> temp = mResultCard;
|
||||
nsresult rv;
|
||||
rv = mDB->CreateABCard(mCurrentRow, getter_AddRefs(mResultCard));
|
||||
*aItem = mResultCard;
|
||||
NS_IF_ADDREF(*aItem);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -948,9 +1471,10 @@ NS_IMETHODIMP nsAddrDBEnumerator::IsDone(void)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP nsAddrDatabase::EnumerateCards(nsIEnumerator **result)
|
||||
NS_IMETHODIMP nsAddrDatabase::EnumerateCards(nsIAbDirectory *directory, nsIEnumerator **result)
|
||||
{
|
||||
nsAddrDBEnumerator* e = new nsAddrDBEnumerator(this, nsnull);
|
||||
m_dbDirectory = directory;
|
||||
if (e == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(e);
|
||||
|
@ -970,7 +1494,7 @@ nsresult nsAddrDatabase::CreateABCard(nsIMdbRow* cardRow, nsIAbCard **result)
|
|||
nsCOMPtr<nsIRDFResource> resource;
|
||||
|
||||
mdbOid outOid;
|
||||
mdb_id rowID=-1;
|
||||
mdb_id rowID=0;
|
||||
mdb_id tableID = 1; /* check: temperarily set to 1 for now */
|
||||
if (cardRow->GetOid(GetEnv(), &outOid) == NS_OK)
|
||||
rowID = outOid.mOid_Id;
|
||||
|
@ -978,23 +1502,20 @@ nsresult nsAddrDatabase::CreateABCard(nsIMdbRow* cardRow, nsIAbCard **result)
|
|||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
cardURI = PR_smprintf("abcard://Pab%d/Card%d", tableID, rowID);
|
||||
nsCOMPtr<nsIAbCard> personCard;
|
||||
rv = m_dbDirectory->AddChildCards(cardURI, getter_AddRefs(personCard));
|
||||
if (personCard)
|
||||
{
|
||||
GetCardFromDB(personCard, cardRow);
|
||||
personCard->SetDbTableID(tableID);
|
||||
personCard->SetDbRowID(rowID);
|
||||
}
|
||||
*result = personCard;
|
||||
NS_IF_ADDREF(*result);
|
||||
}
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = rdfService->GetResource(cardURI, getter_AddRefs(resource));
|
||||
}
|
||||
if(cardURI)
|
||||
PR_smprintf_free(cardURI);
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIAbCard> personCard(do_QueryInterface(resource, &rv));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
*result = personCard;
|
||||
NS_IF_ADDREF(*result);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,15 +44,17 @@ public:
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// nsIAddrDatabase methods:
|
||||
|
||||
NS_IMETHOD Open(nsFileSpec & folderName, PRBool create, nsIAddrDatabase **pAddrDB, PRBool upgrading);
|
||||
NS_IMETHOD GetDbPath(nsFileSpec * *aDbPath);
|
||||
NS_IMETHOD SetDbPath(nsFileSpec * aDbPath);
|
||||
NS_IMETHOD Open(nsFileSpec * folderName, PRBool create, nsIAddrDatabase **pMessageDB, PRBool upgrading);
|
||||
NS_IMETHOD Close(PRBool forceCommit);
|
||||
NS_IMETHOD OpenMDB(const char *dbName, PRBool create);
|
||||
NS_IMETHOD OpenMDB(nsFileSpec *dbName, PRBool create);
|
||||
NS_IMETHOD CloseMDB(PRBool commit);
|
||||
NS_IMETHOD Commit(PRUint32 commitType);
|
||||
NS_IMETHOD ForceClosed();
|
||||
|
||||
NS_IMETHOD CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool benotify);
|
||||
NS_IMETHOD EnumerateCards(nsIEnumerator **result);
|
||||
NS_IMETHOD EnumerateCards(nsIAbDirectory *directory, nsIEnumerator **result);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// nsAddrDatabase methods:
|
||||
|
@ -67,7 +69,7 @@ public:
|
|||
nsIMdbTableRowCursor *GetTableRowCursor();
|
||||
nsIMdbTable *GetPabTable() {return m_mdbPabTable;}
|
||||
|
||||
static nsAddrDatabase* FindInCache(nsFileSpec &dbName);
|
||||
static nsAddrDatabase* FindInCache(nsFileSpec *dbName);
|
||||
|
||||
//helper function to fill in nsStrings from hdr row cell contents.
|
||||
nsresult RowCellColumnTonsString(nsIMdbRow *row, mdb_token columnToken, nsString &resultStr);
|
||||
|
@ -93,7 +95,7 @@ protected:
|
|||
{GetDBCache()->AppendElement(pAddrDB);}
|
||||
static void RemoveFromCache(nsAddrDatabase* pAddrDB);
|
||||
static PRInt32 FindInCache(nsAddrDatabase* pAddrDB);
|
||||
PRBool MatchDbName(nsFileSpec &dbName); // returns TRUE if they match
|
||||
PRBool MatchDbName(nsFileSpec *dbName); // returns TRUE if they match
|
||||
|
||||
#if defined(XP_PC) || defined(XP_MAC) // this should go away when we can provide our own file stream to MDB/Mork
|
||||
static void UnixToNative(char*& ioPath);
|
||||
|
@ -104,6 +106,8 @@ protected:
|
|||
|
||||
|
||||
mdb_err AddCardColumn(nsIMdbRow* cardRow, mdb_column inColumn, char* str);
|
||||
nsresult GetStringColumn(nsIMdbRow *cardRow, mdb_token outToken, nsString &str);
|
||||
nsresult GetCardFromDB(nsIAbCard *newCard, nsIMdbRow* cardRow);
|
||||
|
||||
|
||||
static nsVoidArray/*<nsAddrDatabase>*/* GetDBCache();
|
||||
|
@ -127,22 +131,50 @@ protected:
|
|||
mdb_kind m_historyTableKind;
|
||||
mdb_kind m_mailListTableKind;
|
||||
mdb_kind m_categoryTableKind;
|
||||
|
||||
mdb_scope m_cardRowScopeToken;
|
||||
mdb_token m_firstNameColumnToken;
|
||||
mdb_token m_lastNameColumnToken;
|
||||
mdb_token m_displayNameColumnToken;
|
||||
mdb_token m_priEmailColumnToken;
|
||||
|
||||
mdb_token m_FirstNameColumnToken;
|
||||
mdb_token m_LastNameColumnToken;
|
||||
mdb_token m_DisplayNameColumnToken;
|
||||
mdb_token m_NickNameColumnToken;
|
||||
mdb_token m_PriEmailColumnToken;
|
||||
mdb_token m_2ndEmailColumnToken;
|
||||
mdb_token m_workPhoneColumnToken;
|
||||
mdb_token m_homePhoneColumnToken;
|
||||
mdb_token m_faxColumnToken;
|
||||
mdb_token m_pagerColumnToken;
|
||||
mdb_token m_cellularColumnToken;
|
||||
mdb_token m_workCityColumnToken;
|
||||
mdb_token m_organizationColumnToken;
|
||||
mdb_token m_nicknameColumnToken;
|
||||
mdb_token m_addressCharSetColumnToken;
|
||||
mdb_token m_WorkPhoneColumnToken;
|
||||
mdb_token m_HomePhoneColumnToken;
|
||||
mdb_token m_FaxColumnToken;
|
||||
mdb_token m_PagerColumnToken;
|
||||
mdb_token m_CellularColumnToken;
|
||||
mdb_token m_HomeAddressColumnToken;
|
||||
mdb_token m_HomeAddress2ColumnToken;
|
||||
mdb_token m_HomeCityColumnToken;
|
||||
mdb_token m_HomeStateColumnToken;
|
||||
mdb_token m_HomeZipCodeColumnToken;
|
||||
mdb_token m_HomeCountryColumnToken;
|
||||
mdb_token m_WorkAddressColumnToken;
|
||||
mdb_token m_WorkAddress2ColumnToken;
|
||||
mdb_token m_WorkCityColumnToken;
|
||||
mdb_token m_WorkStateColumnToken;
|
||||
mdb_token m_WorkZipCodeColumnToken;
|
||||
mdb_token m_WorkCountryColumnToken;
|
||||
mdb_token m_JobTitleColumnToken;
|
||||
mdb_token m_DepartmentColumnToken;
|
||||
mdb_token m_CompanyColumnToken;
|
||||
mdb_token m_WebPage1ColumnToken;
|
||||
mdb_token m_WebPage2ColumnToken;
|
||||
mdb_token m_BirthYearColumnToken;
|
||||
mdb_token m_BirthMonthColumnToken;
|
||||
mdb_token m_BirthDayColumnToken;
|
||||
mdb_token m_Custom1ColumnToken;
|
||||
mdb_token m_Custom2ColumnToken;
|
||||
mdb_token m_Custom3ColumnToken;
|
||||
mdb_token m_Custom4ColumnToken;
|
||||
mdb_token m_NotesColumnToken;
|
||||
|
||||
mdb_token m_PlainTextColumnToken;
|
||||
|
||||
mdb_token m_AddressCharSetColumnToken;
|
||||
|
||||
nsIAbDirectory* m_dbDirectory;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,12 +52,10 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|||
|
||||
static NS_DEFINE_CID(kAbCardDataSourceCID, NS_ABCARDDATASOURCE_CID);
|
||||
|
||||
nsIRDFResource* nsABCardDataSource::kNC_PersonName;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_ListName;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_Email;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_City;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_Organization;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_DisplayName;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_PrimaryEmail;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_WorkPhone;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_City;
|
||||
nsIRDFResource* nsABCardDataSource::kNC_Nickname;
|
||||
|
||||
// commands
|
||||
|
@ -66,12 +64,10 @@ nsIRDFResource* nsABCardDataSource::kNC_NewCard;
|
|||
|
||||
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, PersonName);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, ListName);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Email);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, City);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Organization);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, DisplayName);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, PrimaryEmail);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, WorkPhone);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, City);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Nickname);
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Delete);
|
||||
|
@ -164,11 +160,9 @@ nsABCardDataSource::~nsABCardDataSource (void)
|
|||
|
||||
nsrefcnt refcnt;
|
||||
|
||||
NS_RELEASE2(kNC_PersonName, refcnt);
|
||||
NS_RELEASE2(kNC_ListName, refcnt);
|
||||
NS_RELEASE2(kNC_Email, refcnt);
|
||||
NS_RELEASE2(kNC_DisplayName, refcnt);
|
||||
NS_RELEASE2(kNC_PrimaryEmail, refcnt);
|
||||
NS_RELEASE2(kNC_City, refcnt);
|
||||
NS_RELEASE2(kNC_Organization, refcnt);
|
||||
NS_RELEASE2(kNC_WorkPhone, refcnt);
|
||||
NS_RELEASE2(kNC_Nickname, refcnt);
|
||||
|
||||
|
@ -191,13 +185,11 @@ nsresult nsABCardDataSource::Init()
|
|||
|
||||
mRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
|
||||
if (! kNC_PersonName) {
|
||||
if (! kNC_DisplayName) {
|
||||
|
||||
mRDFService->GetResource(kURINC_PersonName, &kNC_PersonName);
|
||||
mRDFService->GetResource(kURINC_ListName, &kNC_ListName);
|
||||
mRDFService->GetResource(kURINC_Email, &kNC_Email);
|
||||
mRDFService->GetResource(kURINC_DisplayName, &kNC_DisplayName);
|
||||
mRDFService->GetResource(kURINC_PrimaryEmail, &kNC_PrimaryEmail);
|
||||
mRDFService->GetResource(kURINC_City, &kNC_City);
|
||||
mRDFService->GetResource(kURINC_Organization, &kNC_Organization);
|
||||
mRDFService->GetResource(kURINC_WorkPhone, &kNC_WorkPhone);
|
||||
mRDFService->GetResource(kURINC_Nickname, &kNC_Nickname);
|
||||
|
||||
|
@ -294,9 +286,8 @@ NS_IMETHODIMP nsABCardDataSource::GetTargets(nsIRDFResource* source,
|
|||
nsCOMPtr<nsIAbCard> card(do_QueryInterface(source, &rv));
|
||||
if (NS_SUCCEEDED(rv) && card)
|
||||
{
|
||||
if((kNC_PersonName == property) || (kNC_ListName == property) ||
|
||||
(kNC_Email == property) || (kNC_City == property) ||
|
||||
(kNC_Organization == property) || (kNC_WorkPhone == property) ||
|
||||
if((kNC_DisplayName == property) || (kNC_PrimaryEmail == property) ||
|
||||
(kNC_City == property) || (kNC_WorkPhone == property) ||
|
||||
(kNC_Nickname == property))
|
||||
{
|
||||
nsSingletonEnumerator* cursor =
|
||||
|
@ -466,11 +457,9 @@ nsABCardDataSource::getCardArcLabelsOut(nsIAbCard *card,
|
|||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
(*arcs)->AppendElement(kNC_PersonName);
|
||||
(*arcs)->AppendElement(kNC_ListName);
|
||||
(*arcs)->AppendElement(kNC_Email);
|
||||
(*arcs)->AppendElement(kNC_DisplayName);
|
||||
(*arcs)->AppendElement(kNC_PrimaryEmail);
|
||||
(*arcs)->AppendElement(kNC_City);
|
||||
(*arcs)->AppendElement(kNC_Organization);
|
||||
(*arcs)->AppendElement(kNC_WorkPhone);
|
||||
(*arcs)->AppendElement(kNC_Nickname);
|
||||
return NS_OK;
|
||||
|
@ -620,7 +609,7 @@ NS_IMETHODIMP nsABCardDataSource::OnItemPropertyChanged(nsISupports *item, const
|
|||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if(PL_strcmp("PersonName", property) == 0)
|
||||
if(PL_strcmp("DisplayName", property) == 0)
|
||||
{
|
||||
NotifyPropertyChanged(resource, kNC_DirName, oldValue, newValue);
|
||||
}
|
||||
|
@ -649,27 +638,26 @@ nsresult nsABCardDataSource::createCardNode(nsIAbCard* card,
|
|||
nsIRDFResource* property,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
char *name;
|
||||
char *name = nsnull;
|
||||
nsresult rv = NS_RDF_NO_VALUE;
|
||||
|
||||
if ((kNC_PersonName == property))
|
||||
rv = card->GetPersonName(&name);
|
||||
else if ((kNC_ListName == property))
|
||||
rv = card->GetListName(&name);
|
||||
else if ((kNC_Email == property))
|
||||
rv = card->GetEmail(&name);
|
||||
if ((kNC_DisplayName == property))
|
||||
rv = card->GetDisplayName(&name);
|
||||
else if ((kNC_PrimaryEmail == property))
|
||||
rv = card->GetPrimaryEmail(&name);
|
||||
else if ((kNC_City == property))
|
||||
rv = card->GetCity(&name);
|
||||
else if ((kNC_Organization == property))
|
||||
rv = card->GetOrganization(&name);
|
||||
rv = card->GetWorkCity(&name);
|
||||
else if ((kNC_WorkPhone == property))
|
||||
rv = card->GetWorkPhone(&name);
|
||||
else if ((kNC_Nickname == property))
|
||||
rv = card->GetNickName(&name);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsString nameString(name);
|
||||
createNode(nameString, target);
|
||||
delete[] name;
|
||||
if (name)
|
||||
{
|
||||
nsString nameString(name);
|
||||
createNode(nameString, target);
|
||||
delete[] name;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,12 +152,10 @@ protected:
|
|||
static PRBool assertEnumFunc(nsISupports *aElement, void *aData);
|
||||
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
|
||||
|
||||
static nsIRDFResource* kNC_PersonName;
|
||||
static nsIRDFResource* kNC_ListName;
|
||||
static nsIRDFResource* kNC_Email;
|
||||
static nsIRDFResource* kNC_City;
|
||||
static nsIRDFResource* kNC_Organization;
|
||||
static nsIRDFResource* kNC_DisplayName;
|
||||
static nsIRDFResource* kNC_PrimaryEmail;
|
||||
static nsIRDFResource* kNC_WorkPhone;
|
||||
static nsIRDFResource* kNC_City;
|
||||
static nsIRDFResource* kNC_Nickname;
|
||||
|
||||
// commands
|
||||
|
|
|
@ -739,3 +739,4 @@ nsresult nsABDirectoryDataSource::DoNewDirectory(nsIAbDirectory *directory, nsIS
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIAbCard.h"
|
||||
#include "nsDirPrefs.h"
|
||||
#include "nsIAbListener.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
static const char kAddrBookRootURI[] = "abdirectory:/";
|
||||
|
|
Загрузка…
Ссылка в новой задаче